babylon.d.ts 2.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310
  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. * @param radians the angle in radians
  3823. */
  3824. constructor(radians: number);
  3825. /**
  3826. * Get value in degrees
  3827. * @returns the Angle value in degrees (float)
  3828. */
  3829. degrees(): number;
  3830. /**
  3831. * Get value in radians
  3832. * @returns the Angle value in radians (float)
  3833. */
  3834. radians(): number;
  3835. /**
  3836. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3837. * @param a defines first vector
  3838. * @param b defines second vector
  3839. * @returns a new Angle
  3840. */
  3841. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3842. /**
  3843. * Gets a new Angle object from the given float in radians
  3844. * @param radians defines the angle value in radians
  3845. * @returns a new Angle
  3846. */
  3847. static FromRadians(radians: number): Angle;
  3848. /**
  3849. * Gets a new Angle object from the given float in degrees
  3850. * @param degrees defines the angle value in degrees
  3851. * @returns a new Angle
  3852. */
  3853. static FromDegrees(degrees: number): Angle;
  3854. }
  3855. /**
  3856. * This represents an arc in a 2d space.
  3857. */
  3858. export class Arc2 {
  3859. /** Defines the start point of the arc */
  3860. startPoint: Vector2;
  3861. /** Defines the mid point of the arc */
  3862. midPoint: Vector2;
  3863. /** Defines the end point of the arc */
  3864. endPoint: Vector2;
  3865. /**
  3866. * Defines the center point of the arc.
  3867. */
  3868. centerPoint: Vector2;
  3869. /**
  3870. * Defines the radius of the arc.
  3871. */
  3872. radius: number;
  3873. /**
  3874. * Defines the angle of the arc (from mid point to end point).
  3875. */
  3876. angle: Angle;
  3877. /**
  3878. * Defines the start angle of the arc (from start point to middle point).
  3879. */
  3880. startAngle: Angle;
  3881. /**
  3882. * Defines the orientation of the arc (clock wise/counter clock wise).
  3883. */
  3884. orientation: Orientation;
  3885. /**
  3886. * Creates an Arc object from the three given points : start, middle and end.
  3887. * @param startPoint Defines the start point of the arc
  3888. * @param midPoint Defines the midlle point of the arc
  3889. * @param endPoint Defines the end point of the arc
  3890. */
  3891. constructor(
  3892. /** Defines the start point of the arc */
  3893. startPoint: Vector2,
  3894. /** Defines the mid point of the arc */
  3895. midPoint: Vector2,
  3896. /** Defines the end point of the arc */
  3897. endPoint: Vector2);
  3898. }
  3899. /**
  3900. * Represents a 2D path made up of multiple 2D points
  3901. */
  3902. export class Path2 {
  3903. private _points;
  3904. private _length;
  3905. /**
  3906. * If the path start and end point are the same
  3907. */
  3908. closed: boolean;
  3909. /**
  3910. * Creates a Path2 object from the starting 2D coordinates x and y.
  3911. * @param x the starting points x value
  3912. * @param y the starting points y value
  3913. */
  3914. constructor(x: number, y: number);
  3915. /**
  3916. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3917. * @param x the added points x value
  3918. * @param y the added points y value
  3919. * @returns the updated Path2.
  3920. */
  3921. addLineTo(x: number, y: number): Path2;
  3922. /**
  3923. * 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.
  3924. * @param midX middle point x value
  3925. * @param midY middle point y value
  3926. * @param endX end point x value
  3927. * @param endY end point y value
  3928. * @param numberOfSegments (default: 36)
  3929. * @returns the updated Path2.
  3930. */
  3931. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3932. /**
  3933. * Closes the Path2.
  3934. * @returns the Path2.
  3935. */
  3936. close(): Path2;
  3937. /**
  3938. * Gets the sum of the distance between each sequential point in the path
  3939. * @returns the Path2 total length (float).
  3940. */
  3941. length(): number;
  3942. /**
  3943. * Gets the points which construct the path
  3944. * @returns the Path2 internal array of points.
  3945. */
  3946. getPoints(): Vector2[];
  3947. /**
  3948. * Retreives the point at the distance aways from the starting point
  3949. * @param normalizedLengthPosition the length along the path to retreive the point from
  3950. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3951. */
  3952. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3953. /**
  3954. * Creates a new path starting from an x and y position
  3955. * @param x starting x value
  3956. * @param y starting y value
  3957. * @returns a new Path2 starting at the coordinates (x, y).
  3958. */
  3959. static StartingAt(x: number, y: number): Path2;
  3960. }
  3961. /**
  3962. * Represents a 3D path made up of multiple 3D points
  3963. */
  3964. export class Path3D {
  3965. /**
  3966. * an array of Vector3, the curve axis of the Path3D
  3967. */
  3968. path: Vector3[];
  3969. private _curve;
  3970. private _distances;
  3971. private _tangents;
  3972. private _normals;
  3973. private _binormals;
  3974. private _raw;
  3975. /**
  3976. * new Path3D(path, normal, raw)
  3977. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3978. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3979. * @param path an array of Vector3, the curve axis of the Path3D
  3980. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3981. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3982. */
  3983. constructor(
  3984. /**
  3985. * an array of Vector3, the curve axis of the Path3D
  3986. */
  3987. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3988. /**
  3989. * Returns the Path3D array of successive Vector3 designing its curve.
  3990. * @returns the Path3D array of successive Vector3 designing its curve.
  3991. */
  3992. getCurve(): Vector3[];
  3993. /**
  3994. * Returns an array populated with tangent vectors on each Path3D curve point.
  3995. * @returns an array populated with tangent vectors on each Path3D curve point.
  3996. */
  3997. getTangents(): Vector3[];
  3998. /**
  3999. * Returns an array populated with normal vectors on each Path3D curve point.
  4000. * @returns an array populated with normal vectors on each Path3D curve point.
  4001. */
  4002. getNormals(): Vector3[];
  4003. /**
  4004. * Returns an array populated with binormal vectors on each Path3D curve point.
  4005. * @returns an array populated with binormal vectors on each Path3D curve point.
  4006. */
  4007. getBinormals(): Vector3[];
  4008. /**
  4009. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4010. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. */
  4012. getDistances(): number[];
  4013. /**
  4014. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4015. * @param path path which all values are copied into the curves points
  4016. * @param firstNormal which should be projected onto the curve
  4017. * @returns the same object updated.
  4018. */
  4019. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4020. private _compute;
  4021. private _getFirstNonNullVector;
  4022. private _getLastNonNullVector;
  4023. private _normalVector;
  4024. }
  4025. /**
  4026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4027. * A Curve3 is designed from a series of successive Vector3.
  4028. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4029. */
  4030. export class Curve3 {
  4031. private _points;
  4032. private _length;
  4033. /**
  4034. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4035. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4036. * @param v1 (Vector3) the control point
  4037. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4038. * @param nbPoints (integer) the wanted number of points in the curve
  4039. * @returns the created Curve3
  4040. */
  4041. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4042. /**
  4043. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4044. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4045. * @param v1 (Vector3) the first control point
  4046. * @param v2 (Vector3) the second control point
  4047. * @param v3 (Vector3) the end point of the Cubic Bezier
  4048. * @param nbPoints (integer) the wanted number of points in the curve
  4049. * @returns the created Curve3
  4050. */
  4051. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4052. /**
  4053. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4054. * @param p1 (Vector3) the origin point of the Hermite Spline
  4055. * @param t1 (Vector3) the tangent vector at the origin point
  4056. * @param p2 (Vector3) the end point of the Hermite Spline
  4057. * @param t2 (Vector3) the tangent vector at the end point
  4058. * @param nbPoints (integer) the wanted number of points in the curve
  4059. * @returns the created Curve3
  4060. */
  4061. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4062. /**
  4063. * Returns a Curve3 object along a CatmullRom Spline curve :
  4064. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4065. * @param nbPoints (integer) the wanted number of points between each curve control points
  4066. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4070. /**
  4071. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4072. * A Curve3 is designed from a series of successive Vector3.
  4073. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4074. * @param points points which make up the curve
  4075. */
  4076. constructor(points: Vector3[]);
  4077. /**
  4078. * @returns the Curve3 stored array of successive Vector3
  4079. */
  4080. getPoints(): Vector3[];
  4081. /**
  4082. * @returns the computed length (float) of the curve.
  4083. */
  4084. length(): number;
  4085. /**
  4086. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4087. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4088. * curveA and curveB keep unchanged.
  4089. * @param curve the curve to continue from this curve
  4090. * @returns the newly constructed curve
  4091. */
  4092. continue(curve: DeepImmutable<Curve3>): Curve3;
  4093. private _computeLength;
  4094. }
  4095. /**
  4096. * Contains position and normal vectors for a vertex
  4097. */
  4098. export class PositionNormalVertex {
  4099. /** the position of the vertex (defaut: 0,0,0) */
  4100. position: Vector3;
  4101. /** the normal of the vertex (defaut: 0,1,0) */
  4102. normal: Vector3;
  4103. /**
  4104. * Creates a PositionNormalVertex
  4105. * @param position the position of the vertex (defaut: 0,0,0)
  4106. * @param normal the normal of the vertex (defaut: 0,1,0)
  4107. */
  4108. constructor(
  4109. /** the position of the vertex (defaut: 0,0,0) */
  4110. position?: Vector3,
  4111. /** the normal of the vertex (defaut: 0,1,0) */
  4112. normal?: Vector3);
  4113. /**
  4114. * Clones the PositionNormalVertex
  4115. * @returns the cloned PositionNormalVertex
  4116. */
  4117. clone(): PositionNormalVertex;
  4118. }
  4119. /**
  4120. * Contains position, normal and uv vectors for a vertex
  4121. */
  4122. export class PositionNormalTextureVertex {
  4123. /** the position of the vertex (defaut: 0,0,0) */
  4124. position: Vector3;
  4125. /** the normal of the vertex (defaut: 0,1,0) */
  4126. normal: Vector3;
  4127. /** the uv of the vertex (default: 0,0) */
  4128. uv: Vector2;
  4129. /**
  4130. * Creates a PositionNormalTextureVertex
  4131. * @param position the position of the vertex (defaut: 0,0,0)
  4132. * @param normal the normal of the vertex (defaut: 0,1,0)
  4133. * @param uv the uv of the vertex (default: 0,0)
  4134. */
  4135. constructor(
  4136. /** the position of the vertex (defaut: 0,0,0) */
  4137. position?: Vector3,
  4138. /** the normal of the vertex (defaut: 0,1,0) */
  4139. normal?: Vector3,
  4140. /** the uv of the vertex (default: 0,0) */
  4141. uv?: Vector2);
  4142. /**
  4143. * Clones the PositionNormalTextureVertex
  4144. * @returns the cloned PositionNormalTextureVertex
  4145. */
  4146. clone(): PositionNormalTextureVertex;
  4147. }
  4148. /**
  4149. * @hidden
  4150. */
  4151. export class Tmp {
  4152. static Color3: Color3[];
  4153. static Color4: Color4[];
  4154. static Vector2: Vector2[];
  4155. static Vector3: Vector3[];
  4156. static Vector4: Vector4[];
  4157. static Quaternion: Quaternion[];
  4158. static Matrix: Matrix[];
  4159. }
  4160. }
  4161. declare module BABYLON {
  4162. /**
  4163. * Class used to enable access to offline support
  4164. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4165. */
  4166. export interface IOfflineProvider {
  4167. /**
  4168. * Gets a boolean indicating if scene must be saved in the database
  4169. */
  4170. enableSceneOffline: boolean;
  4171. /**
  4172. * Gets a boolean indicating if textures must be saved in the database
  4173. */
  4174. enableTexturesOffline: boolean;
  4175. /**
  4176. * Open the offline support and make it available
  4177. * @param successCallback defines the callback to call on success
  4178. * @param errorCallback defines the callback to call on error
  4179. */
  4180. open(successCallback: () => void, errorCallback: () => void): void;
  4181. /**
  4182. * Loads an image from the offline support
  4183. * @param url defines the url to load from
  4184. * @param image defines the target DOM image
  4185. */
  4186. loadImage(url: string, image: HTMLImageElement): void;
  4187. /**
  4188. * Loads a file from offline support
  4189. * @param url defines the URL to load from
  4190. * @param sceneLoaded defines a callback to call on success
  4191. * @param progressCallBack defines a callback to call when progress changed
  4192. * @param errorCallback defines a callback to call on error
  4193. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4194. */
  4195. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4196. }
  4197. }
  4198. declare module BABYLON {
  4199. /**
  4200. * A class serves as a medium between the observable and its observers
  4201. */
  4202. export class EventState {
  4203. /**
  4204. * Create a new EventState
  4205. * @param mask defines the mask associated with this state
  4206. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4207. * @param target defines the original target of the state
  4208. * @param currentTarget defines the current target of the state
  4209. */
  4210. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4211. /**
  4212. * Initialize the current event state
  4213. * @param mask defines the mask associated with this state
  4214. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4215. * @param target defines the original target of the state
  4216. * @param currentTarget defines the current target of the state
  4217. * @returns the current event state
  4218. */
  4219. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4220. /**
  4221. * An Observer can set this property to true to prevent subsequent observers of being notified
  4222. */
  4223. skipNextObservers: boolean;
  4224. /**
  4225. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4226. */
  4227. mask: number;
  4228. /**
  4229. * The object that originally notified the event
  4230. */
  4231. target?: any;
  4232. /**
  4233. * The current object in the bubbling phase
  4234. */
  4235. currentTarget?: any;
  4236. /**
  4237. * This will be populated with the return value of the last function that was executed.
  4238. * If it is the first function in the callback chain it will be the event data.
  4239. */
  4240. lastReturnValue?: any;
  4241. }
  4242. /**
  4243. * Represent an Observer registered to a given Observable object.
  4244. */
  4245. export class Observer<T> {
  4246. /**
  4247. * Defines the callback to call when the observer is notified
  4248. */
  4249. callback: (eventData: T, eventState: EventState) => void;
  4250. /**
  4251. * Defines the mask of the observer (used to filter notifications)
  4252. */
  4253. mask: number;
  4254. /**
  4255. * Defines the current scope used to restore the JS context
  4256. */
  4257. scope: any;
  4258. /** @hidden */
  4259. _willBeUnregistered: boolean;
  4260. /**
  4261. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4262. */
  4263. unregisterOnNextCall: boolean;
  4264. /**
  4265. * Creates a new observer
  4266. * @param callback defines the callback to call when the observer is notified
  4267. * @param mask defines the mask of the observer (used to filter notifications)
  4268. * @param scope defines the current scope used to restore the JS context
  4269. */
  4270. constructor(
  4271. /**
  4272. * Defines the callback to call when the observer is notified
  4273. */
  4274. callback: (eventData: T, eventState: EventState) => void,
  4275. /**
  4276. * Defines the mask of the observer (used to filter notifications)
  4277. */
  4278. mask: number,
  4279. /**
  4280. * Defines the current scope used to restore the JS context
  4281. */
  4282. scope?: any);
  4283. }
  4284. /**
  4285. * Represent a list of observers registered to multiple Observables object.
  4286. */
  4287. export class MultiObserver<T> {
  4288. private _observers;
  4289. private _observables;
  4290. /**
  4291. * Release associated resources
  4292. */
  4293. dispose(): void;
  4294. /**
  4295. * Raise a callback when one of the observable will notify
  4296. * @param observables defines a list of observables to watch
  4297. * @param callback defines the callback to call on notification
  4298. * @param mask defines the mask used to filter notifications
  4299. * @param scope defines the current scope used to restore the JS context
  4300. * @returns the new MultiObserver
  4301. */
  4302. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4303. }
  4304. /**
  4305. * The Observable class is a simple implementation of the Observable pattern.
  4306. *
  4307. * 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.
  4308. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4309. * 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).
  4310. * 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.
  4311. */
  4312. export class Observable<T> {
  4313. private _observers;
  4314. private _eventState;
  4315. private _onObserverAdded;
  4316. /**
  4317. * Creates a new observable
  4318. * @param onObserverAdded defines a callback to call when a new observer is added
  4319. */
  4320. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4321. /**
  4322. * Create a new Observer with the specified callback
  4323. * @param callback the callback that will be executed for that Observer
  4324. * @param mask the mask used to filter observers
  4325. * @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.
  4326. * @param scope optional scope for the callback to be called from
  4327. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4328. * @returns the new observer created for the callback
  4329. */
  4330. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4331. /**
  4332. * Create a new Observer with the specified callback and unregisters after the next notification
  4333. * @param callback the callback that will be executed for that Observer
  4334. * @returns the new observer created for the callback
  4335. */
  4336. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4337. /**
  4338. * Remove an Observer from the Observable object
  4339. * @param observer the instance of the Observer to remove
  4340. * @returns false if it doesn't belong to this Observable
  4341. */
  4342. remove(observer: Nullable<Observer<T>>): boolean;
  4343. /**
  4344. * Remove a callback from the Observable object
  4345. * @param callback the callback to remove
  4346. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4347. * @returns false if it doesn't belong to this Observable
  4348. */
  4349. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4350. private _deferUnregister;
  4351. private _remove;
  4352. /**
  4353. * Notify all Observers by calling their respective callback with the given data
  4354. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4355. * @param eventData defines the data to send to all observers
  4356. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4357. * @param target defines the original target of the state
  4358. * @param currentTarget defines the current target of the state
  4359. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4360. */
  4361. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4362. /**
  4363. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4364. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4365. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4366. * and it is crucial that all callbacks will be executed.
  4367. * The order of the callbacks is kept, callbacks are not executed parallel.
  4368. *
  4369. * @param eventData The data to be sent to each callback
  4370. * @param mask is used to filter observers defaults to -1
  4371. * @param target defines the callback target (see EventState)
  4372. * @param currentTarget defines he current object in the bubbling phase
  4373. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4374. */
  4375. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4376. /**
  4377. * Notify a specific observer
  4378. * @param observer defines the observer to notify
  4379. * @param eventData defines the data to be sent to each callback
  4380. * @param mask is used to filter observers defaults to -1
  4381. */
  4382. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4383. /**
  4384. * Gets a boolean indicating if the observable has at least one observer
  4385. * @returns true is the Observable has at least one Observer registered
  4386. */
  4387. hasObservers(): boolean;
  4388. /**
  4389. * Clear the list of observers
  4390. */
  4391. clear(): void;
  4392. /**
  4393. * Clone the current observable
  4394. * @returns a new observable
  4395. */
  4396. clone(): Observable<T>;
  4397. /**
  4398. * Does this observable handles observer registered with a given mask
  4399. * @param mask defines the mask to be tested
  4400. * @return whether or not one observer registered with the given mask is handeled
  4401. **/
  4402. hasSpecificMask(mask?: number): boolean;
  4403. }
  4404. }
  4405. declare module BABYLON {
  4406. /**
  4407. * Class used to help managing file picking and drag'n'drop
  4408. * File Storage
  4409. */
  4410. export class FilesInputStore {
  4411. /**
  4412. * List of files ready to be loaded
  4413. */
  4414. static FilesToLoad: {
  4415. [key: string]: File;
  4416. };
  4417. }
  4418. }
  4419. declare module BABYLON {
  4420. /** Defines the cross module used constants to avoid circular dependncies */
  4421. export class Constants {
  4422. /** Defines that alpha blending is disabled */
  4423. static readonly ALPHA_DISABLE: number;
  4424. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4425. static readonly ALPHA_ADD: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4427. static readonly ALPHA_COMBINE: number;
  4428. /** Defines that alpha blending to DEST - SRC * DEST */
  4429. static readonly ALPHA_SUBTRACT: number;
  4430. /** Defines that alpha blending to SRC * DEST */
  4431. static readonly ALPHA_MULTIPLY: number;
  4432. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4433. static readonly ALPHA_MAXIMIZED: number;
  4434. /** Defines that alpha blending to SRC + DEST */
  4435. static readonly ALPHA_ONEONE: number;
  4436. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4437. static readonly ALPHA_PREMULTIPLIED: number;
  4438. /**
  4439. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4440. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4441. */
  4442. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4443. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4444. static readonly ALPHA_INTERPOLATE: number;
  4445. /**
  4446. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4447. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4448. */
  4449. static readonly ALPHA_SCREENMODE: number;
  4450. /** Defines that the ressource is not delayed*/
  4451. static readonly DELAYLOADSTATE_NONE: number;
  4452. /** Defines that the ressource was successfully delay loaded */
  4453. static readonly DELAYLOADSTATE_LOADED: number;
  4454. /** Defines that the ressource is currently delay loading */
  4455. static readonly DELAYLOADSTATE_LOADING: number;
  4456. /** Defines that the ressource is delayed and has not started loading */
  4457. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4458. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4459. static readonly NEVER: number;
  4460. /** 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 */
  4461. static readonly ALWAYS: number;
  4462. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4463. static readonly LESS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4465. static readonly EQUAL: number;
  4466. /** 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 */
  4467. static readonly LEQUAL: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4469. static readonly GREATER: number;
  4470. /** 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 */
  4471. static readonly GEQUAL: number;
  4472. /** 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 */
  4473. static readonly NOTEQUAL: number;
  4474. /** Passed to stencilOperation to specify that stencil value must be kept */
  4475. static readonly KEEP: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4477. static readonly REPLACE: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4479. static readonly INCR: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4481. static readonly DECR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4483. static readonly INVERT: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4485. static readonly INCR_WRAP: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4487. static readonly DECR_WRAP: number;
  4488. /** Texture is not repeating outside of 0..1 UVs */
  4489. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4490. /** Texture is repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4492. /** Texture is repeating and mirrored */
  4493. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4494. /** ALPHA */
  4495. static readonly TEXTUREFORMAT_ALPHA: number;
  4496. /** LUMINANCE */
  4497. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4498. /** LUMINANCE_ALPHA */
  4499. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4500. /** RGB */
  4501. static readonly TEXTUREFORMAT_RGB: number;
  4502. /** RGBA */
  4503. static readonly TEXTUREFORMAT_RGBA: number;
  4504. /** RED */
  4505. static readonly TEXTUREFORMAT_RED: number;
  4506. /** RED (2nd reference) */
  4507. static readonly TEXTUREFORMAT_R: number;
  4508. /** RG */
  4509. static readonly TEXTUREFORMAT_RG: number;
  4510. /** RED_INTEGER */
  4511. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4512. /** RED_INTEGER (2nd reference) */
  4513. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4514. /** RG_INTEGER */
  4515. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4516. /** RGB_INTEGER */
  4517. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4518. /** RGBA_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4520. /** UNSIGNED_BYTE */
  4521. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4522. /** UNSIGNED_BYTE (2nd reference) */
  4523. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4524. /** FLOAT */
  4525. static readonly TEXTURETYPE_FLOAT: number;
  4526. /** HALF_FLOAT */
  4527. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4528. /** BYTE */
  4529. static readonly TEXTURETYPE_BYTE: number;
  4530. /** SHORT */
  4531. static readonly TEXTURETYPE_SHORT: number;
  4532. /** UNSIGNED_SHORT */
  4533. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4534. /** INT */
  4535. static readonly TEXTURETYPE_INT: number;
  4536. /** UNSIGNED_INT */
  4537. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4538. /** UNSIGNED_SHORT_4_4_4_4 */
  4539. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4540. /** UNSIGNED_SHORT_5_5_5_1 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4542. /** UNSIGNED_SHORT_5_6_5 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4544. /** UNSIGNED_INT_2_10_10_10_REV */
  4545. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4546. /** UNSIGNED_INT_24_8 */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4548. /** UNSIGNED_INT_10F_11F_11F_REV */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4550. /** UNSIGNED_INT_5_9_9_9_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4552. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4553. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4554. /** nearest is mag = nearest and min = nearest and mip = linear */
  4555. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4556. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4557. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4558. /** Trilinear is mag = linear and min = linear and mip = linear */
  4559. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4560. /** nearest is mag = nearest and min = nearest and mip = linear */
  4561. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4562. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4563. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4564. /** Trilinear is mag = linear and min = linear and mip = linear */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4566. /** mag = nearest and min = nearest and mip = nearest */
  4567. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4568. /** mag = nearest and min = linear and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = linear */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4572. /** mag = nearest and min = linear and mip = none */
  4573. static readonly TEXTURE_NEAREST_LINEAR: number;
  4574. /** mag = nearest and min = nearest and mip = none */
  4575. static readonly TEXTURE_NEAREST_NEAREST: number;
  4576. /** mag = linear and min = nearest and mip = nearest */
  4577. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4578. /** mag = linear and min = nearest and mip = linear */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4580. /** mag = linear and min = linear and mip = none */
  4581. static readonly TEXTURE_LINEAR_LINEAR: number;
  4582. /** mag = linear and min = nearest and mip = none */
  4583. static readonly TEXTURE_LINEAR_NEAREST: number;
  4584. /** Explicit coordinates mode */
  4585. static readonly TEXTURE_EXPLICIT_MODE: number;
  4586. /** Spherical coordinates mode */
  4587. static readonly TEXTURE_SPHERICAL_MODE: number;
  4588. /** Planar coordinates mode */
  4589. static readonly TEXTURE_PLANAR_MODE: number;
  4590. /** Cubic coordinates mode */
  4591. static readonly TEXTURE_CUBIC_MODE: number;
  4592. /** Projection coordinates mode */
  4593. static readonly TEXTURE_PROJECTION_MODE: number;
  4594. /** Skybox coordinates mode */
  4595. static readonly TEXTURE_SKYBOX_MODE: number;
  4596. /** Inverse Cubic coordinates mode */
  4597. static readonly TEXTURE_INVCUBIC_MODE: number;
  4598. /** Equirectangular coordinates mode */
  4599. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4600. /** Equirectangular Fixed coordinates mode */
  4601. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed Mirrored coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4604. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4605. static readonly SCALEMODE_FLOOR: number;
  4606. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4607. static readonly SCALEMODE_NEAREST: number;
  4608. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4609. static readonly SCALEMODE_CEILING: number;
  4610. /**
  4611. * The dirty texture flag value
  4612. */
  4613. static readonly MATERIAL_TextureDirtyFlag: number;
  4614. /**
  4615. * The dirty light flag value
  4616. */
  4617. static readonly MATERIAL_LightDirtyFlag: number;
  4618. /**
  4619. * The dirty fresnel flag value
  4620. */
  4621. static readonly MATERIAL_FresnelDirtyFlag: number;
  4622. /**
  4623. * The dirty attribute flag value
  4624. */
  4625. static readonly MATERIAL_AttributesDirtyFlag: number;
  4626. /**
  4627. * The dirty misc flag value
  4628. */
  4629. static readonly MATERIAL_MiscDirtyFlag: number;
  4630. /**
  4631. * The all dirty flag value
  4632. */
  4633. static readonly MATERIAL_AllDirtyFlag: number;
  4634. /**
  4635. * Returns the triangle fill mode
  4636. */
  4637. static readonly MATERIAL_TriangleFillMode: number;
  4638. /**
  4639. * Returns the wireframe mode
  4640. */
  4641. static readonly MATERIAL_WireFrameFillMode: number;
  4642. /**
  4643. * Returns the point fill mode
  4644. */
  4645. static readonly MATERIAL_PointFillMode: number;
  4646. /**
  4647. * Returns the point list draw mode
  4648. */
  4649. static readonly MATERIAL_PointListDrawMode: number;
  4650. /**
  4651. * Returns the line list draw mode
  4652. */
  4653. static readonly MATERIAL_LineListDrawMode: number;
  4654. /**
  4655. * Returns the line loop draw mode
  4656. */
  4657. static readonly MATERIAL_LineLoopDrawMode: number;
  4658. /**
  4659. * Returns the line strip draw mode
  4660. */
  4661. static readonly MATERIAL_LineStripDrawMode: number;
  4662. /**
  4663. * Returns the triangle strip draw mode
  4664. */
  4665. static readonly MATERIAL_TriangleStripDrawMode: number;
  4666. /**
  4667. * Returns the triangle fan draw mode
  4668. */
  4669. static readonly MATERIAL_TriangleFanDrawMode: number;
  4670. /**
  4671. * Stores the clock-wise side orientation
  4672. */
  4673. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4674. /**
  4675. * Stores the counter clock-wise side orientation
  4676. */
  4677. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4678. /**
  4679. * Nothing
  4680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4681. */
  4682. static readonly ACTION_NothingTrigger: number;
  4683. /**
  4684. * On pick
  4685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4686. */
  4687. static readonly ACTION_OnPickTrigger: number;
  4688. /**
  4689. * On left pick
  4690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4691. */
  4692. static readonly ACTION_OnLeftPickTrigger: number;
  4693. /**
  4694. * On right pick
  4695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4696. */
  4697. static readonly ACTION_OnRightPickTrigger: number;
  4698. /**
  4699. * On center pick
  4700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4701. */
  4702. static readonly ACTION_OnCenterPickTrigger: number;
  4703. /**
  4704. * On pick down
  4705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4706. */
  4707. static readonly ACTION_OnPickDownTrigger: number;
  4708. /**
  4709. * On double pick
  4710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4711. */
  4712. static readonly ACTION_OnDoublePickTrigger: number;
  4713. /**
  4714. * On pick up
  4715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4716. */
  4717. static readonly ACTION_OnPickUpTrigger: number;
  4718. /**
  4719. * On pick out.
  4720. * This trigger will only be raised if you also declared a OnPickDown
  4721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4722. */
  4723. static readonly ACTION_OnPickOutTrigger: number;
  4724. /**
  4725. * On long press
  4726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4727. */
  4728. static readonly ACTION_OnLongPressTrigger: number;
  4729. /**
  4730. * On pointer over
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPointerOverTrigger: number;
  4734. /**
  4735. * On pointer out
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnPointerOutTrigger: number;
  4739. /**
  4740. * On every frame
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnEveryFrameTrigger: number;
  4744. /**
  4745. * On intersection enter
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4749. /**
  4750. * On intersection exit
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnIntersectionExitTrigger: number;
  4754. /**
  4755. * On key down
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnKeyDownTrigger: number;
  4759. /**
  4760. * On key up
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnKeyUpTrigger: number;
  4764. /**
  4765. * Billboard mode will only apply to Y axis
  4766. */
  4767. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4768. /**
  4769. * Billboard mode will apply to all axes
  4770. */
  4771. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4772. /**
  4773. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4774. */
  4775. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4776. /**
  4777. * Gets or sets base Assets URL
  4778. */
  4779. static readonly PARTICLES_BaseAssetsUrl: string;
  4780. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4781. * Test order :
  4782. * Is the bounding sphere outside the frustum ?
  4783. * If not, are the bounding box vertices outside the frustum ?
  4784. * It not, then the cullable object is in the frustum.
  4785. */
  4786. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4787. /** Culling strategy : Bounding Sphere Only.
  4788. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4789. * It's also less accurate than the standard because some not visible objects can still be selected.
  4790. * Test : is the bounding sphere outside the frustum ?
  4791. * If not, then the cullable object is in the frustum.
  4792. */
  4793. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4794. /** Culling strategy : Optimistic Inclusion.
  4795. * This in an inclusion test first, then the standard exclusion test.
  4796. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4797. * 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.
  4798. * Anyway, it's as accurate as the standard strategy.
  4799. * Test :
  4800. * Is the cullable object bounding sphere center in the frustum ?
  4801. * If not, apply the default culling strategy.
  4802. */
  4803. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4804. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4805. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4806. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4807. * 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.
  4808. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4809. * Test :
  4810. * Is the cullable object bounding sphere center in the frustum ?
  4811. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4812. */
  4813. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4814. /**
  4815. * No logging while loading
  4816. */
  4817. static readonly SCENELOADER_NO_LOGGING: number;
  4818. /**
  4819. * Minimal logging while loading
  4820. */
  4821. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4822. /**
  4823. * Summary logging while loading
  4824. */
  4825. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4826. /**
  4827. * Detailled logging while loading
  4828. */
  4829. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4830. }
  4831. }
  4832. declare module BABYLON {
  4833. /**
  4834. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4835. * Babylon.js
  4836. */
  4837. export class DomManagement {
  4838. /**
  4839. * Checks if the window object exists
  4840. * @returns true if the window object exists
  4841. */
  4842. static IsWindowObjectExist(): boolean;
  4843. /**
  4844. * Extracts text content from a DOM element hierarchy
  4845. * @param element defines the root element
  4846. * @returns a string
  4847. */
  4848. static GetDOMTextContent(element: HTMLElement): string;
  4849. }
  4850. }
  4851. declare module BABYLON {
  4852. /**
  4853. * Logger used througouht the application to allow configuration of
  4854. * the log level required for the messages.
  4855. */
  4856. export class Logger {
  4857. /**
  4858. * No log
  4859. */
  4860. static readonly NoneLogLevel: number;
  4861. /**
  4862. * Only message logs
  4863. */
  4864. static readonly MessageLogLevel: number;
  4865. /**
  4866. * Only warning logs
  4867. */
  4868. static readonly WarningLogLevel: number;
  4869. /**
  4870. * Only error logs
  4871. */
  4872. static readonly ErrorLogLevel: number;
  4873. /**
  4874. * All logs
  4875. */
  4876. static readonly AllLogLevel: number;
  4877. private static _LogCache;
  4878. /**
  4879. * Gets a value indicating the number of loading errors
  4880. * @ignorenaming
  4881. */
  4882. static errorsCount: number;
  4883. /**
  4884. * Callback called when a new log is added
  4885. */
  4886. static OnNewCacheEntry: (entry: string) => void;
  4887. private static _AddLogEntry;
  4888. private static _FormatMessage;
  4889. private static _LogDisabled;
  4890. private static _LogEnabled;
  4891. private static _WarnDisabled;
  4892. private static _WarnEnabled;
  4893. private static _ErrorDisabled;
  4894. private static _ErrorEnabled;
  4895. /**
  4896. * Log a message to the console
  4897. */
  4898. static Log: (message: string) => void;
  4899. /**
  4900. * Write a warning message to the console
  4901. */
  4902. static Warn: (message: string) => void;
  4903. /**
  4904. * Write an error message to the console
  4905. */
  4906. static Error: (message: string) => void;
  4907. /**
  4908. * Gets current log cache (list of logs)
  4909. */
  4910. static readonly LogCache: string;
  4911. /**
  4912. * Clears the log cache
  4913. */
  4914. static ClearLogCache(): void;
  4915. /**
  4916. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4917. */
  4918. static LogLevels: number;
  4919. }
  4920. }
  4921. declare module BABYLON {
  4922. /** @hidden */
  4923. export class _TypeStore {
  4924. /** @hidden */
  4925. static RegisteredTypes: {
  4926. [key: string]: Object;
  4927. };
  4928. /** @hidden */
  4929. static GetClass(fqdn: string): any;
  4930. }
  4931. }
  4932. declare module BABYLON {
  4933. /**
  4934. * Class containing a set of static utilities functions for deep copy.
  4935. */
  4936. export class DeepCopier {
  4937. /**
  4938. * Tries to copy an object by duplicating every property
  4939. * @param source defines the source object
  4940. * @param destination defines the target object
  4941. * @param doNotCopyList defines a list of properties to avoid
  4942. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4943. */
  4944. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4945. }
  4946. }
  4947. declare module BABYLON {
  4948. /**
  4949. * Class containing a set of static utilities functions for precision date
  4950. */
  4951. export class PrecisionDate {
  4952. /**
  4953. * Gets either window.performance.now() if supported or Date.now() else
  4954. */
  4955. static readonly Now: number;
  4956. }
  4957. }
  4958. declare module BABYLON {
  4959. /** @hidden */
  4960. export class _DevTools {
  4961. static WarnImport(name: string): string;
  4962. }
  4963. }
  4964. declare module BABYLON {
  4965. /**
  4966. * Class used to evalaute queries containing `and` and `or` operators
  4967. */
  4968. export class AndOrNotEvaluator {
  4969. /**
  4970. * Evaluate a query
  4971. * @param query defines the query to evaluate
  4972. * @param evaluateCallback defines the callback used to filter result
  4973. * @returns true if the query matches
  4974. */
  4975. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4976. private static _HandleParenthesisContent;
  4977. private static _SimplifyNegation;
  4978. }
  4979. }
  4980. declare module BABYLON {
  4981. /**
  4982. * Class used to store custom tags
  4983. */
  4984. export class Tags {
  4985. /**
  4986. * Adds support for tags on the given object
  4987. * @param obj defines the object to use
  4988. */
  4989. static EnableFor(obj: any): void;
  4990. /**
  4991. * Removes tags support
  4992. * @param obj defines the object to use
  4993. */
  4994. static DisableFor(obj: any): void;
  4995. /**
  4996. * Gets a boolean indicating if the given object has tags
  4997. * @param obj defines the object to use
  4998. * @returns a boolean
  4999. */
  5000. static HasTags(obj: any): boolean;
  5001. /**
  5002. * Gets the tags available on a given object
  5003. * @param obj defines the object to use
  5004. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5005. * @returns the tags
  5006. */
  5007. static GetTags(obj: any, asString?: boolean): any;
  5008. /**
  5009. * Adds tags to an object
  5010. * @param obj defines the object to use
  5011. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5012. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5013. */
  5014. static AddTagsTo(obj: any, tagsString: string): void;
  5015. /**
  5016. * @hidden
  5017. */
  5018. static _AddTagTo(obj: any, tag: string): void;
  5019. /**
  5020. * Removes specific tags from a specific object
  5021. * @param obj defines the object to use
  5022. * @param tagsString defines the tags to remove
  5023. */
  5024. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5025. /**
  5026. * @hidden
  5027. */
  5028. static _RemoveTagFrom(obj: any, tag: string): void;
  5029. /**
  5030. * Defines if tags hosted on an object match a given query
  5031. * @param obj defines the object to use
  5032. * @param tagsQuery defines the tag query
  5033. * @returns a boolean
  5034. */
  5035. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5036. }
  5037. }
  5038. declare module BABYLON {
  5039. /**
  5040. * Manages the defines for the Material
  5041. */
  5042. export class MaterialDefines {
  5043. private _keys;
  5044. private _isDirty;
  5045. /** @hidden */
  5046. _renderId: number;
  5047. /** @hidden */
  5048. _areLightsDirty: boolean;
  5049. /** @hidden */
  5050. _areAttributesDirty: boolean;
  5051. /** @hidden */
  5052. _areTexturesDirty: boolean;
  5053. /** @hidden */
  5054. _areFresnelDirty: boolean;
  5055. /** @hidden */
  5056. _areMiscDirty: boolean;
  5057. /** @hidden */
  5058. _areImageProcessingDirty: boolean;
  5059. /** @hidden */
  5060. _normals: boolean;
  5061. /** @hidden */
  5062. _uvs: boolean;
  5063. /** @hidden */
  5064. _needNormals: boolean;
  5065. /** @hidden */
  5066. _needUVs: boolean;
  5067. /**
  5068. * Specifies if the material needs to be re-calculated
  5069. */
  5070. readonly isDirty: boolean;
  5071. /**
  5072. * Marks the material to indicate that it has been re-calculated
  5073. */
  5074. markAsProcessed(): void;
  5075. /**
  5076. * Marks the material to indicate that it needs to be re-calculated
  5077. */
  5078. markAsUnprocessed(): void;
  5079. /**
  5080. * Marks the material to indicate all of its defines need to be re-calculated
  5081. */
  5082. markAllAsDirty(): void;
  5083. /**
  5084. * Marks the material to indicate that image processing needs to be re-calculated
  5085. */
  5086. markAsImageProcessingDirty(): void;
  5087. /**
  5088. * Marks the material to indicate the lights need to be re-calculated
  5089. */
  5090. markAsLightDirty(): void;
  5091. /**
  5092. * Marks the attribute state as changed
  5093. */
  5094. markAsAttributesDirty(): void;
  5095. /**
  5096. * Marks the texture state as changed
  5097. */
  5098. markAsTexturesDirty(): void;
  5099. /**
  5100. * Marks the fresnel state as changed
  5101. */
  5102. markAsFresnelDirty(): void;
  5103. /**
  5104. * Marks the misc state as changed
  5105. */
  5106. markAsMiscDirty(): void;
  5107. /**
  5108. * Rebuilds the material defines
  5109. */
  5110. rebuild(): void;
  5111. /**
  5112. * Specifies if two material defines are equal
  5113. * @param other - A material define instance to compare to
  5114. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5115. */
  5116. isEqual(other: MaterialDefines): boolean;
  5117. /**
  5118. * Clones this instance's defines to another instance
  5119. * @param other - material defines to clone values to
  5120. */
  5121. cloneTo(other: MaterialDefines): void;
  5122. /**
  5123. * Resets the material define values
  5124. */
  5125. reset(): void;
  5126. /**
  5127. * Converts the material define values to a string
  5128. * @returns - String of material define information
  5129. */
  5130. toString(): string;
  5131. }
  5132. }
  5133. declare module BABYLON {
  5134. /**
  5135. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5136. */
  5137. export class PerformanceMonitor {
  5138. private _enabled;
  5139. private _rollingFrameTime;
  5140. private _lastFrameTimeMs;
  5141. /**
  5142. * constructor
  5143. * @param frameSampleSize The number of samples required to saturate the sliding window
  5144. */
  5145. constructor(frameSampleSize?: number);
  5146. /**
  5147. * Samples current frame
  5148. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5149. */
  5150. sampleFrame(timeMs?: number): void;
  5151. /**
  5152. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5153. */
  5154. readonly averageFrameTime: number;
  5155. /**
  5156. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5157. */
  5158. readonly averageFrameTimeVariance: number;
  5159. /**
  5160. * Returns the frame time of the most recent frame
  5161. */
  5162. readonly instantaneousFrameTime: number;
  5163. /**
  5164. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5165. */
  5166. readonly averageFPS: number;
  5167. /**
  5168. * Returns the average framerate in frames per second using the most recent frame time
  5169. */
  5170. readonly instantaneousFPS: number;
  5171. /**
  5172. * Returns true if enough samples have been taken to completely fill the sliding window
  5173. */
  5174. readonly isSaturated: boolean;
  5175. /**
  5176. * Enables contributions to the sliding window sample set
  5177. */
  5178. enable(): void;
  5179. /**
  5180. * Disables contributions to the sliding window sample set
  5181. * Samples will not be interpolated over the disabled period
  5182. */
  5183. disable(): void;
  5184. /**
  5185. * Returns true if sampling is enabled
  5186. */
  5187. readonly isEnabled: boolean;
  5188. /**
  5189. * Resets performance monitor
  5190. */
  5191. reset(): void;
  5192. }
  5193. /**
  5194. * RollingAverage
  5195. *
  5196. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5197. */
  5198. export class RollingAverage {
  5199. /**
  5200. * Current average
  5201. */
  5202. average: number;
  5203. /**
  5204. * Current variance
  5205. */
  5206. variance: number;
  5207. protected _samples: Array<number>;
  5208. protected _sampleCount: number;
  5209. protected _pos: number;
  5210. protected _m2: number;
  5211. /**
  5212. * constructor
  5213. * @param length The number of samples required to saturate the sliding window
  5214. */
  5215. constructor(length: number);
  5216. /**
  5217. * Adds a sample to the sample set
  5218. * @param v The sample value
  5219. */
  5220. add(v: number): void;
  5221. /**
  5222. * Returns previously added values or null if outside of history or outside the sliding window domain
  5223. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5224. * @return Value previously recorded with add() or null if outside of range
  5225. */
  5226. history(i: number): number;
  5227. /**
  5228. * Returns true if enough samples have been taken to completely fill the sliding window
  5229. * @return true if sample-set saturated
  5230. */
  5231. isSaturated(): boolean;
  5232. /**
  5233. * Resets the rolling average (equivalent to 0 samples taken so far)
  5234. */
  5235. reset(): void;
  5236. /**
  5237. * Wraps a value around the sample range boundaries
  5238. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5239. * @return Wrapped position in sample range
  5240. */
  5241. protected _wrapPosition(i: number): number;
  5242. }
  5243. }
  5244. declare module BABYLON {
  5245. /**
  5246. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5247. * The underlying implementation relies on an associative array to ensure the best performances.
  5248. * The value can be anything including 'null' but except 'undefined'
  5249. */
  5250. export class StringDictionary<T> {
  5251. /**
  5252. * This will clear this dictionary and copy the content from the 'source' one.
  5253. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5254. * @param source the dictionary to take the content from and copy to this dictionary
  5255. */
  5256. copyFrom(source: StringDictionary<T>): void;
  5257. /**
  5258. * Get a value based from its key
  5259. * @param key the given key to get the matching value from
  5260. * @return the value if found, otherwise undefined is returned
  5261. */
  5262. get(key: string): T | undefined;
  5263. /**
  5264. * Get a value from its key or add it if it doesn't exist.
  5265. * This method will ensure you that a given key/data will be present in the dictionary.
  5266. * @param key the given key to get the matching value from
  5267. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5268. * The factory will only be invoked if there's no data for the given key.
  5269. * @return the value corresponding to the key.
  5270. */
  5271. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5272. /**
  5273. * Get a value from its key if present in the dictionary otherwise add it
  5274. * @param key the key to get the value from
  5275. * @param val if there's no such key/value pair in the dictionary add it with this value
  5276. * @return the value corresponding to the key
  5277. */
  5278. getOrAdd(key: string, val: T): T;
  5279. /**
  5280. * Check if there's a given key in the dictionary
  5281. * @param key the key to check for
  5282. * @return true if the key is present, false otherwise
  5283. */
  5284. contains(key: string): boolean;
  5285. /**
  5286. * Add a new key and its corresponding value
  5287. * @param key the key to add
  5288. * @param value the value corresponding to the key
  5289. * @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
  5290. */
  5291. add(key: string, value: T): boolean;
  5292. /**
  5293. * Update a specific value associated to a key
  5294. * @param key defines the key to use
  5295. * @param value defines the value to store
  5296. * @returns true if the value was updated (or false if the key was not found)
  5297. */
  5298. set(key: string, value: T): boolean;
  5299. /**
  5300. * Get the element of the given key and remove it from the dictionary
  5301. * @param key defines the key to search
  5302. * @returns the value associated with the key or null if not found
  5303. */
  5304. getAndRemove(key: string): Nullable<T>;
  5305. /**
  5306. * Remove a key/value from the dictionary.
  5307. * @param key the key to remove
  5308. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5309. */
  5310. remove(key: string): boolean;
  5311. /**
  5312. * Clear the whole content of the dictionary
  5313. */
  5314. clear(): void;
  5315. /**
  5316. * Gets the current count
  5317. */
  5318. readonly count: number;
  5319. /**
  5320. * Execute a callback on each key/val of the dictionary.
  5321. * Note that you can remove any element in this dictionary in the callback implementation
  5322. * @param callback the callback to execute on a given key/value pair
  5323. */
  5324. forEach(callback: (key: string, val: T) => void): void;
  5325. /**
  5326. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5327. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5328. * Note that you can remove any element in this dictionary in the callback implementation
  5329. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5330. * @returns the first item
  5331. */
  5332. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5333. private _count;
  5334. private _data;
  5335. }
  5336. }
  5337. declare module BABYLON {
  5338. /**
  5339. * Helper class that provides a small promise polyfill
  5340. */
  5341. export class PromisePolyfill {
  5342. /**
  5343. * Static function used to check if the polyfill is required
  5344. * If this is the case then the function will inject the polyfill to window.Promise
  5345. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5346. */
  5347. static Apply(force?: boolean): void;
  5348. }
  5349. }
  5350. declare module BABYLON {
  5351. /**
  5352. * Class used to store data that will be store in GPU memory
  5353. */
  5354. export class Buffer {
  5355. private _engine;
  5356. private _buffer;
  5357. /** @hidden */
  5358. _data: Nullable<DataArray>;
  5359. private _updatable;
  5360. private _instanced;
  5361. /**
  5362. * Gets the byte stride.
  5363. */
  5364. readonly byteStride: number;
  5365. /**
  5366. * Constructor
  5367. * @param engine the engine
  5368. * @param data the data to use for this buffer
  5369. * @param updatable whether the data is updatable
  5370. * @param stride the stride (optional)
  5371. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5372. * @param instanced whether the buffer is instanced (optional)
  5373. * @param useBytes set to true if the stride in in bytes (optional)
  5374. */
  5375. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5376. /**
  5377. * Create a new VertexBuffer based on the current buffer
  5378. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5379. * @param offset defines offset in the buffer (0 by default)
  5380. * @param size defines the size in floats of attributes (position is 3 for instance)
  5381. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5382. * @param instanced defines if the vertex buffer contains indexed data
  5383. * @param useBytes defines if the offset and stride are in bytes
  5384. * @returns the new vertex buffer
  5385. */
  5386. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5387. /**
  5388. * Gets a boolean indicating if the Buffer is updatable?
  5389. * @returns true if the buffer is updatable
  5390. */
  5391. isUpdatable(): boolean;
  5392. /**
  5393. * Gets current buffer's data
  5394. * @returns a DataArray or null
  5395. */
  5396. getData(): Nullable<DataArray>;
  5397. /**
  5398. * Gets underlying native buffer
  5399. * @returns underlying native buffer
  5400. */
  5401. getBuffer(): Nullable<WebGLBuffer>;
  5402. /**
  5403. * Gets the stride in float32 units (i.e. byte stride / 4).
  5404. * May not be an integer if the byte stride is not divisible by 4.
  5405. * DEPRECATED. Use byteStride instead.
  5406. * @returns the stride in float32 units
  5407. */
  5408. getStrideSize(): number;
  5409. /**
  5410. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5411. * @param data defines the data to store
  5412. */
  5413. create(data?: Nullable<DataArray>): void;
  5414. /** @hidden */
  5415. _rebuild(): void;
  5416. /**
  5417. * Update current buffer data
  5418. * @param data defines the data to store
  5419. */
  5420. update(data: DataArray): void;
  5421. /**
  5422. * Updates the data directly.
  5423. * @param data the new data
  5424. * @param offset the new offset
  5425. * @param vertexCount the vertex count (optional)
  5426. * @param useBytes set to true if the offset is in bytes
  5427. */
  5428. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5429. /**
  5430. * Release all resources
  5431. */
  5432. dispose(): void;
  5433. }
  5434. /**
  5435. * Specialized buffer used to store vertex data
  5436. */
  5437. export class VertexBuffer {
  5438. /** @hidden */
  5439. _buffer: Buffer;
  5440. private _kind;
  5441. private _size;
  5442. private _ownsBuffer;
  5443. private _instanced;
  5444. private _instanceDivisor;
  5445. /**
  5446. * The byte type.
  5447. */
  5448. static readonly BYTE: number;
  5449. /**
  5450. * The unsigned byte type.
  5451. */
  5452. static readonly UNSIGNED_BYTE: number;
  5453. /**
  5454. * The short type.
  5455. */
  5456. static readonly SHORT: number;
  5457. /**
  5458. * The unsigned short type.
  5459. */
  5460. static readonly UNSIGNED_SHORT: number;
  5461. /**
  5462. * The integer type.
  5463. */
  5464. static readonly INT: number;
  5465. /**
  5466. * The unsigned integer type.
  5467. */
  5468. static readonly UNSIGNED_INT: number;
  5469. /**
  5470. * The float type.
  5471. */
  5472. static readonly FLOAT: number;
  5473. /**
  5474. * Gets or sets the instance divisor when in instanced mode
  5475. */
  5476. instanceDivisor: number;
  5477. /**
  5478. * Gets the byte stride.
  5479. */
  5480. readonly byteStride: number;
  5481. /**
  5482. * Gets the byte offset.
  5483. */
  5484. readonly byteOffset: number;
  5485. /**
  5486. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5487. */
  5488. readonly normalized: boolean;
  5489. /**
  5490. * Gets the data type of each component in the array.
  5491. */
  5492. readonly type: number;
  5493. /**
  5494. * Constructor
  5495. * @param engine the engine
  5496. * @param data the data to use for this vertex buffer
  5497. * @param kind the vertex buffer kind
  5498. * @param updatable whether the data is updatable
  5499. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5500. * @param stride the stride (optional)
  5501. * @param instanced whether the buffer is instanced (optional)
  5502. * @param offset the offset of the data (optional)
  5503. * @param size the number of components (optional)
  5504. * @param type the type of the component (optional)
  5505. * @param normalized whether the data contains normalized data (optional)
  5506. * @param useBytes set to true if stride and offset are in bytes (optional)
  5507. */
  5508. 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);
  5509. /** @hidden */
  5510. _rebuild(): void;
  5511. /**
  5512. * Returns the kind of the VertexBuffer (string)
  5513. * @returns a string
  5514. */
  5515. getKind(): string;
  5516. /**
  5517. * Gets a boolean indicating if the VertexBuffer is updatable?
  5518. * @returns true if the buffer is updatable
  5519. */
  5520. isUpdatable(): boolean;
  5521. /**
  5522. * Gets current buffer's data
  5523. * @returns a DataArray or null
  5524. */
  5525. getData(): Nullable<DataArray>;
  5526. /**
  5527. * Gets underlying native buffer
  5528. * @returns underlying native buffer
  5529. */
  5530. getBuffer(): Nullable<WebGLBuffer>;
  5531. /**
  5532. * Gets the stride in float32 units (i.e. byte stride / 4).
  5533. * May not be an integer if the byte stride is not divisible by 4.
  5534. * DEPRECATED. Use byteStride instead.
  5535. * @returns the stride in float32 units
  5536. */
  5537. getStrideSize(): number;
  5538. /**
  5539. * Returns the offset as a multiple of the type byte length.
  5540. * DEPRECATED. Use byteOffset instead.
  5541. * @returns the offset in bytes
  5542. */
  5543. getOffset(): number;
  5544. /**
  5545. * Returns the number of components per vertex attribute (integer)
  5546. * @returns the size in float
  5547. */
  5548. getSize(): number;
  5549. /**
  5550. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5551. * @returns true if this buffer is instanced
  5552. */
  5553. getIsInstanced(): boolean;
  5554. /**
  5555. * Returns the instancing divisor, zero for non-instanced (integer).
  5556. * @returns a number
  5557. */
  5558. getInstanceDivisor(): number;
  5559. /**
  5560. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5561. * @param data defines the data to store
  5562. */
  5563. create(data?: DataArray): void;
  5564. /**
  5565. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5566. * This function will create a new buffer if the current one is not updatable
  5567. * @param data defines the data to store
  5568. */
  5569. update(data: DataArray): void;
  5570. /**
  5571. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5572. * Returns the directly updated WebGLBuffer.
  5573. * @param data the new data
  5574. * @param offset the new offset
  5575. * @param useBytes set to true if the offset is in bytes
  5576. */
  5577. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5578. /**
  5579. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5580. */
  5581. dispose(): void;
  5582. /**
  5583. * Enumerates each value of this vertex buffer as numbers.
  5584. * @param count the number of values to enumerate
  5585. * @param callback the callback function called for each value
  5586. */
  5587. forEach(count: number, callback: (value: number, index: number) => void): void;
  5588. /**
  5589. * Positions
  5590. */
  5591. static readonly PositionKind: string;
  5592. /**
  5593. * Normals
  5594. */
  5595. static readonly NormalKind: string;
  5596. /**
  5597. * Tangents
  5598. */
  5599. static readonly TangentKind: string;
  5600. /**
  5601. * Texture coordinates
  5602. */
  5603. static readonly UVKind: string;
  5604. /**
  5605. * Texture coordinates 2
  5606. */
  5607. static readonly UV2Kind: string;
  5608. /**
  5609. * Texture coordinates 3
  5610. */
  5611. static readonly UV3Kind: string;
  5612. /**
  5613. * Texture coordinates 4
  5614. */
  5615. static readonly UV4Kind: string;
  5616. /**
  5617. * Texture coordinates 5
  5618. */
  5619. static readonly UV5Kind: string;
  5620. /**
  5621. * Texture coordinates 6
  5622. */
  5623. static readonly UV6Kind: string;
  5624. /**
  5625. * Colors
  5626. */
  5627. static readonly ColorKind: string;
  5628. /**
  5629. * Matrix indices (for bones)
  5630. */
  5631. static readonly MatricesIndicesKind: string;
  5632. /**
  5633. * Matrix weights (for bones)
  5634. */
  5635. static readonly MatricesWeightsKind: string;
  5636. /**
  5637. * Additional matrix indices (for bones)
  5638. */
  5639. static readonly MatricesIndicesExtraKind: string;
  5640. /**
  5641. * Additional matrix weights (for bones)
  5642. */
  5643. static readonly MatricesWeightsExtraKind: string;
  5644. /**
  5645. * Deduces the stride given a kind.
  5646. * @param kind The kind string to deduce
  5647. * @returns The deduced stride
  5648. */
  5649. static DeduceStride(kind: string): number;
  5650. /**
  5651. * Gets the byte length of the given type.
  5652. * @param type the type
  5653. * @returns the number of bytes
  5654. */
  5655. static GetTypeByteLength(type: number): number;
  5656. /**
  5657. * Enumerates each value of the given parameters as numbers.
  5658. * @param data the data to enumerate
  5659. * @param byteOffset the byte offset of the data
  5660. * @param byteStride the byte stride of the data
  5661. * @param componentCount the number of components per element
  5662. * @param componentType the type of the component
  5663. * @param count the total number of components
  5664. * @param normalized whether the data is normalized
  5665. * @param callback the callback function called for each value
  5666. */
  5667. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5668. private static _GetFloatValue;
  5669. }
  5670. }
  5671. declare module BABYLON {
  5672. /**
  5673. * Class representing spherical polynomial coefficients to the 3rd degree
  5674. */
  5675. export class SphericalPolynomial {
  5676. /**
  5677. * The x coefficients of the spherical polynomial
  5678. */
  5679. x: Vector3;
  5680. /**
  5681. * The y coefficients of the spherical polynomial
  5682. */
  5683. y: Vector3;
  5684. /**
  5685. * The z coefficients of the spherical polynomial
  5686. */
  5687. z: Vector3;
  5688. /**
  5689. * The xx coefficients of the spherical polynomial
  5690. */
  5691. xx: Vector3;
  5692. /**
  5693. * The yy coefficients of the spherical polynomial
  5694. */
  5695. yy: Vector3;
  5696. /**
  5697. * The zz coefficients of the spherical polynomial
  5698. */
  5699. zz: Vector3;
  5700. /**
  5701. * The xy coefficients of the spherical polynomial
  5702. */
  5703. xy: Vector3;
  5704. /**
  5705. * The yz coefficients of the spherical polynomial
  5706. */
  5707. yz: Vector3;
  5708. /**
  5709. * The zx coefficients of the spherical polynomial
  5710. */
  5711. zx: Vector3;
  5712. /**
  5713. * Adds an ambient color to the spherical polynomial
  5714. * @param color the color to add
  5715. */
  5716. addAmbient(color: Color3): void;
  5717. /**
  5718. * Scales the spherical polynomial by the given amount
  5719. * @param scale the amount to scale
  5720. */
  5721. scale(scale: number): void;
  5722. /**
  5723. * Gets the spherical polynomial from harmonics
  5724. * @param harmonics the spherical harmonics
  5725. * @returns the spherical polynomial
  5726. */
  5727. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5728. /**
  5729. * Constructs a spherical polynomial from an array.
  5730. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5731. * @returns the spherical polynomial
  5732. */
  5733. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5734. }
  5735. /**
  5736. * Class representing spherical harmonics coefficients to the 3rd degree
  5737. */
  5738. export class SphericalHarmonics {
  5739. /**
  5740. * The l0,0 coefficients of the spherical harmonics
  5741. */
  5742. l00: Vector3;
  5743. /**
  5744. * The l1,-1 coefficients of the spherical harmonics
  5745. */
  5746. l1_1: Vector3;
  5747. /**
  5748. * The l1,0 coefficients of the spherical harmonics
  5749. */
  5750. l10: Vector3;
  5751. /**
  5752. * The l1,1 coefficients of the spherical harmonics
  5753. */
  5754. l11: Vector3;
  5755. /**
  5756. * The l2,-2 coefficients of the spherical harmonics
  5757. */
  5758. l2_2: Vector3;
  5759. /**
  5760. * The l2,-1 coefficients of the spherical harmonics
  5761. */
  5762. l2_1: Vector3;
  5763. /**
  5764. * The l2,0 coefficients of the spherical harmonics
  5765. */
  5766. l20: Vector3;
  5767. /**
  5768. * The l2,1 coefficients of the spherical harmonics
  5769. */
  5770. l21: Vector3;
  5771. /**
  5772. * The l2,2 coefficients of the spherical harmonics
  5773. */
  5774. lL22: Vector3;
  5775. /**
  5776. * Adds a light to the spherical harmonics
  5777. * @param direction the direction of the light
  5778. * @param color the color of the light
  5779. * @param deltaSolidAngle the delta solid angle of the light
  5780. */
  5781. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5782. /**
  5783. * Scales the spherical harmonics by the given amount
  5784. * @param scale the amount to scale
  5785. */
  5786. scale(scale: number): void;
  5787. /**
  5788. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5789. *
  5790. * ```
  5791. * E_lm = A_l * L_lm
  5792. * ```
  5793. *
  5794. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5795. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5796. * the scaling factors are given in equation 9.
  5797. */
  5798. convertIncidentRadianceToIrradiance(): void;
  5799. /**
  5800. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5801. *
  5802. * ```
  5803. * L = (1/pi) * E * rho
  5804. * ```
  5805. *
  5806. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5807. */
  5808. convertIrradianceToLambertianRadiance(): void;
  5809. /**
  5810. * Gets the spherical harmonics from polynomial
  5811. * @param polynomial the spherical polynomial
  5812. * @returns the spherical harmonics
  5813. */
  5814. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5815. /**
  5816. * Constructs a spherical harmonics from an array.
  5817. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5818. * @returns the spherical harmonics
  5819. */
  5820. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5821. }
  5822. }
  5823. declare module BABYLON {
  5824. /**
  5825. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5826. */
  5827. export interface CubeMapInfo {
  5828. /**
  5829. * The pixel array for the front face.
  5830. * This is stored in format, left to right, up to down format.
  5831. */
  5832. front: Nullable<ArrayBufferView>;
  5833. /**
  5834. * The pixel array for the back face.
  5835. * This is stored in format, left to right, up to down format.
  5836. */
  5837. back: Nullable<ArrayBufferView>;
  5838. /**
  5839. * The pixel array for the left face.
  5840. * This is stored in format, left to right, up to down format.
  5841. */
  5842. left: Nullable<ArrayBufferView>;
  5843. /**
  5844. * The pixel array for the right face.
  5845. * This is stored in format, left to right, up to down format.
  5846. */
  5847. right: Nullable<ArrayBufferView>;
  5848. /**
  5849. * The pixel array for the up face.
  5850. * This is stored in format, left to right, up to down format.
  5851. */
  5852. up: Nullable<ArrayBufferView>;
  5853. /**
  5854. * The pixel array for the down face.
  5855. * This is stored in format, left to right, up to down format.
  5856. */
  5857. down: Nullable<ArrayBufferView>;
  5858. /**
  5859. * The size of the cubemap stored.
  5860. *
  5861. * Each faces will be size * size pixels.
  5862. */
  5863. size: number;
  5864. /**
  5865. * The format of the texture.
  5866. *
  5867. * RGBA, RGB.
  5868. */
  5869. format: number;
  5870. /**
  5871. * The type of the texture data.
  5872. *
  5873. * UNSIGNED_INT, FLOAT.
  5874. */
  5875. type: number;
  5876. /**
  5877. * Specifies whether the texture is in gamma space.
  5878. */
  5879. gammaSpace: boolean;
  5880. }
  5881. /**
  5882. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5883. */
  5884. export class PanoramaToCubeMapTools {
  5885. private static FACE_FRONT;
  5886. private static FACE_BACK;
  5887. private static FACE_RIGHT;
  5888. private static FACE_LEFT;
  5889. private static FACE_DOWN;
  5890. private static FACE_UP;
  5891. /**
  5892. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5893. *
  5894. * @param float32Array The source data.
  5895. * @param inputWidth The width of the input panorama.
  5896. * @param inputHeight The height of the input panorama.
  5897. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5898. * @return The cubemap data
  5899. */
  5900. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5901. private static CreateCubemapTexture;
  5902. private static CalcProjectionSpherical;
  5903. }
  5904. }
  5905. declare module BABYLON {
  5906. /**
  5907. * Helper class dealing with the extraction of spherical polynomial dataArray
  5908. * from a cube map.
  5909. */
  5910. export class CubeMapToSphericalPolynomialTools {
  5911. private static FileFaces;
  5912. /**
  5913. * Converts a texture to the according Spherical Polynomial data.
  5914. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5915. *
  5916. * @param texture The texture to extract the information from.
  5917. * @return The Spherical Polynomial data.
  5918. */
  5919. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5920. /**
  5921. * Converts a cubemap to the according Spherical Polynomial data.
  5922. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5923. *
  5924. * @param cubeInfo The Cube map to extract the information from.
  5925. * @return The Spherical Polynomial data.
  5926. */
  5927. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5928. }
  5929. }
  5930. declare module BABYLON {
  5931. /**
  5932. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5933. * during the life time of the application.
  5934. */
  5935. export class EngineStore {
  5936. /** Gets the list of created engines */
  5937. static Instances: Engine[];
  5938. /**
  5939. * Gets the latest created engine
  5940. */
  5941. static readonly LastCreatedEngine: Nullable<Engine>;
  5942. /**
  5943. * Gets the latest created scene
  5944. */
  5945. static readonly LastCreatedScene: Nullable<Scene>;
  5946. }
  5947. }
  5948. declare module BABYLON {
  5949. /**
  5950. * Define options used to create a render target texture
  5951. */
  5952. export class RenderTargetCreationOptions {
  5953. /**
  5954. * Specifies is mipmaps must be generated
  5955. */
  5956. generateMipMaps?: boolean;
  5957. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5958. generateDepthBuffer?: boolean;
  5959. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5960. generateStencilBuffer?: boolean;
  5961. /** Defines texture type (int by default) */
  5962. type?: number;
  5963. /** Defines sampling mode (trilinear by default) */
  5964. samplingMode?: number;
  5965. /** Defines format (RGBA by default) */
  5966. format?: number;
  5967. }
  5968. }
  5969. declare module BABYLON {
  5970. /**
  5971. * @hidden
  5972. **/
  5973. export class _AlphaState {
  5974. private _isAlphaBlendDirty;
  5975. private _isBlendFunctionParametersDirty;
  5976. private _isBlendEquationParametersDirty;
  5977. private _isBlendConstantsDirty;
  5978. private _alphaBlend;
  5979. private _blendFunctionParameters;
  5980. private _blendEquationParameters;
  5981. private _blendConstants;
  5982. /**
  5983. * Initializes the state.
  5984. */
  5985. constructor();
  5986. readonly isDirty: boolean;
  5987. alphaBlend: boolean;
  5988. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5989. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5990. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5991. reset(): void;
  5992. apply(gl: WebGLRenderingContext): void;
  5993. }
  5994. }
  5995. declare module BABYLON {
  5996. /**
  5997. * @hidden
  5998. **/
  5999. export class _DepthCullingState {
  6000. private _isDepthTestDirty;
  6001. private _isDepthMaskDirty;
  6002. private _isDepthFuncDirty;
  6003. private _isCullFaceDirty;
  6004. private _isCullDirty;
  6005. private _isZOffsetDirty;
  6006. private _isFrontFaceDirty;
  6007. private _depthTest;
  6008. private _depthMask;
  6009. private _depthFunc;
  6010. private _cull;
  6011. private _cullFace;
  6012. private _zOffset;
  6013. private _frontFace;
  6014. /**
  6015. * Initializes the state.
  6016. */
  6017. constructor();
  6018. readonly isDirty: boolean;
  6019. zOffset: number;
  6020. cullFace: Nullable<number>;
  6021. cull: Nullable<boolean>;
  6022. depthFunc: Nullable<number>;
  6023. depthMask: boolean;
  6024. depthTest: boolean;
  6025. frontFace: Nullable<number>;
  6026. reset(): void;
  6027. apply(gl: WebGLRenderingContext): void;
  6028. }
  6029. }
  6030. declare module BABYLON {
  6031. /**
  6032. * @hidden
  6033. **/
  6034. export class _StencilState {
  6035. /** 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 */
  6036. static readonly ALWAYS: number;
  6037. /** Passed to stencilOperation to specify that stencil value must be kept */
  6038. static readonly KEEP: number;
  6039. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6040. static readonly REPLACE: number;
  6041. private _isStencilTestDirty;
  6042. private _isStencilMaskDirty;
  6043. private _isStencilFuncDirty;
  6044. private _isStencilOpDirty;
  6045. private _stencilTest;
  6046. private _stencilMask;
  6047. private _stencilFunc;
  6048. private _stencilFuncRef;
  6049. private _stencilFuncMask;
  6050. private _stencilOpStencilFail;
  6051. private _stencilOpDepthFail;
  6052. private _stencilOpStencilDepthPass;
  6053. readonly isDirty: boolean;
  6054. stencilFunc: number;
  6055. stencilFuncRef: number;
  6056. stencilFuncMask: number;
  6057. stencilOpStencilFail: number;
  6058. stencilOpDepthFail: number;
  6059. stencilOpStencilDepthPass: number;
  6060. stencilMask: number;
  6061. stencilTest: boolean;
  6062. constructor();
  6063. reset(): void;
  6064. apply(gl: WebGLRenderingContext): void;
  6065. }
  6066. }
  6067. declare module BABYLON {
  6068. /**
  6069. * @hidden
  6070. **/
  6071. export class _TimeToken {
  6072. _startTimeQuery: Nullable<WebGLQuery>;
  6073. _endTimeQuery: Nullable<WebGLQuery>;
  6074. _timeElapsedQuery: Nullable<WebGLQuery>;
  6075. _timeElapsedQueryEnded: boolean;
  6076. }
  6077. }
  6078. declare module BABYLON {
  6079. /**
  6080. * Internal interface used to track InternalTexture already bound to the GL context
  6081. */
  6082. export interface IInternalTextureTracker {
  6083. /**
  6084. * Gets or set the previous tracker in the list
  6085. */
  6086. previous: Nullable<IInternalTextureTracker>;
  6087. /**
  6088. * Gets or set the next tracker in the list
  6089. */
  6090. next: Nullable<IInternalTextureTracker>;
  6091. }
  6092. /**
  6093. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6094. */
  6095. export class DummyInternalTextureTracker {
  6096. /**
  6097. * Gets or set the previous tracker in the list
  6098. */
  6099. previous: Nullable<IInternalTextureTracker>;
  6100. /**
  6101. * Gets or set the next tracker in the list
  6102. */
  6103. next: Nullable<IInternalTextureTracker>;
  6104. }
  6105. }
  6106. declare module BABYLON {
  6107. /**
  6108. * Class used to store data associated with WebGL texture data for the engine
  6109. * This class should not be used directly
  6110. */
  6111. export class InternalTexture implements IInternalTextureTracker {
  6112. /** hidden */
  6113. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6114. /**
  6115. * The source of the texture data is unknown
  6116. */
  6117. static DATASOURCE_UNKNOWN: number;
  6118. /**
  6119. * Texture data comes from an URL
  6120. */
  6121. static DATASOURCE_URL: number;
  6122. /**
  6123. * Texture data is only used for temporary storage
  6124. */
  6125. static DATASOURCE_TEMP: number;
  6126. /**
  6127. * Texture data comes from raw data (ArrayBuffer)
  6128. */
  6129. static DATASOURCE_RAW: number;
  6130. /**
  6131. * Texture content is dynamic (video or dynamic texture)
  6132. */
  6133. static DATASOURCE_DYNAMIC: number;
  6134. /**
  6135. * Texture content is generated by rendering to it
  6136. */
  6137. static DATASOURCE_RENDERTARGET: number;
  6138. /**
  6139. * Texture content is part of a multi render target process
  6140. */
  6141. static DATASOURCE_MULTIRENDERTARGET: number;
  6142. /**
  6143. * Texture data comes from a cube data file
  6144. */
  6145. static DATASOURCE_CUBE: number;
  6146. /**
  6147. * Texture data comes from a raw cube data
  6148. */
  6149. static DATASOURCE_CUBERAW: number;
  6150. /**
  6151. * Texture data come from a prefiltered cube data file
  6152. */
  6153. static DATASOURCE_CUBEPREFILTERED: number;
  6154. /**
  6155. * Texture content is raw 3D data
  6156. */
  6157. static DATASOURCE_RAW3D: number;
  6158. /**
  6159. * Texture content is a depth texture
  6160. */
  6161. static DATASOURCE_DEPTHTEXTURE: number;
  6162. /**
  6163. * Texture data comes from a raw cube data encoded with RGBD
  6164. */
  6165. static DATASOURCE_CUBERAW_RGBD: number;
  6166. /**
  6167. * Defines if the texture is ready
  6168. */
  6169. isReady: boolean;
  6170. /**
  6171. * Defines if the texture is a cube texture
  6172. */
  6173. isCube: boolean;
  6174. /**
  6175. * Defines if the texture contains 3D data
  6176. */
  6177. is3D: boolean;
  6178. /**
  6179. * Gets the URL used to load this texture
  6180. */
  6181. url: string;
  6182. /**
  6183. * Gets the sampling mode of the texture
  6184. */
  6185. samplingMode: number;
  6186. /**
  6187. * Gets a boolean indicating if the texture needs mipmaps generation
  6188. */
  6189. generateMipMaps: boolean;
  6190. /**
  6191. * Gets the number of samples used by the texture (WebGL2+ only)
  6192. */
  6193. samples: number;
  6194. /**
  6195. * Gets the type of the texture (int, float...)
  6196. */
  6197. type: number;
  6198. /**
  6199. * Gets the format of the texture (RGB, RGBA...)
  6200. */
  6201. format: number;
  6202. /**
  6203. * Observable called when the texture is loaded
  6204. */
  6205. onLoadedObservable: Observable<InternalTexture>;
  6206. /**
  6207. * Gets the width of the texture
  6208. */
  6209. width: number;
  6210. /**
  6211. * Gets the height of the texture
  6212. */
  6213. height: number;
  6214. /**
  6215. * Gets the depth of the texture
  6216. */
  6217. depth: number;
  6218. /**
  6219. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6220. */
  6221. baseWidth: number;
  6222. /**
  6223. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6224. */
  6225. baseHeight: number;
  6226. /**
  6227. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6228. */
  6229. baseDepth: number;
  6230. /**
  6231. * Gets a boolean indicating if the texture is inverted on Y axis
  6232. */
  6233. invertY: boolean;
  6234. /**
  6235. * Gets or set the previous tracker in the list
  6236. */
  6237. previous: Nullable<IInternalTextureTracker>;
  6238. /**
  6239. * Gets or set the next tracker in the list
  6240. */
  6241. next: Nullable<IInternalTextureTracker>;
  6242. /** @hidden */
  6243. _invertVScale: boolean;
  6244. /** @hidden */
  6245. _initialSlot: number;
  6246. /** @hidden */
  6247. _designatedSlot: number;
  6248. /** @hidden */
  6249. _dataSource: number;
  6250. /** @hidden */
  6251. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6252. /** @hidden */
  6253. _bufferView: Nullable<ArrayBufferView>;
  6254. /** @hidden */
  6255. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6256. /** @hidden */
  6257. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6258. /** @hidden */
  6259. _size: number;
  6260. /** @hidden */
  6261. _extension: string;
  6262. /** @hidden */
  6263. _files: Nullable<string[]>;
  6264. /** @hidden */
  6265. _workingCanvas: HTMLCanvasElement;
  6266. /** @hidden */
  6267. _workingContext: CanvasRenderingContext2D;
  6268. /** @hidden */
  6269. _framebuffer: Nullable<WebGLFramebuffer>;
  6270. /** @hidden */
  6271. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6272. /** @hidden */
  6273. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6274. /** @hidden */
  6275. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6276. /** @hidden */
  6277. _attachments: Nullable<number[]>;
  6278. /** @hidden */
  6279. _cachedCoordinatesMode: Nullable<number>;
  6280. /** @hidden */
  6281. _cachedWrapU: Nullable<number>;
  6282. /** @hidden */
  6283. _cachedWrapV: Nullable<number>;
  6284. /** @hidden */
  6285. _cachedWrapR: Nullable<number>;
  6286. /** @hidden */
  6287. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6288. /** @hidden */
  6289. _isDisabled: boolean;
  6290. /** @hidden */
  6291. _compression: Nullable<string>;
  6292. /** @hidden */
  6293. _generateStencilBuffer: boolean;
  6294. /** @hidden */
  6295. _generateDepthBuffer: boolean;
  6296. /** @hidden */
  6297. _comparisonFunction: number;
  6298. /** @hidden */
  6299. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6300. /** @hidden */
  6301. _lodGenerationScale: number;
  6302. /** @hidden */
  6303. _lodGenerationOffset: number;
  6304. /** @hidden */
  6305. _lodTextureHigh: BaseTexture;
  6306. /** @hidden */
  6307. _lodTextureMid: BaseTexture;
  6308. /** @hidden */
  6309. _lodTextureLow: BaseTexture;
  6310. /** @hidden */
  6311. _isRGBD: boolean;
  6312. /** @hidden */
  6313. _webGLTexture: Nullable<WebGLTexture>;
  6314. /** @hidden */
  6315. _references: number;
  6316. private _engine;
  6317. /**
  6318. * Gets the Engine the texture belongs to.
  6319. * @returns The babylon engine
  6320. */
  6321. getEngine(): Engine;
  6322. /**
  6323. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6324. */
  6325. readonly dataSource: number;
  6326. /**
  6327. * Creates a new InternalTexture
  6328. * @param engine defines the engine to use
  6329. * @param dataSource defines the type of data that will be used
  6330. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6331. */
  6332. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6333. /**
  6334. * Increments the number of references (ie. the number of Texture that point to it)
  6335. */
  6336. incrementReferences(): void;
  6337. /**
  6338. * Change the size of the texture (not the size of the content)
  6339. * @param width defines the new width
  6340. * @param height defines the new height
  6341. * @param depth defines the new depth (1 by default)
  6342. */
  6343. updateSize(width: int, height: int, depth?: int): void;
  6344. /** @hidden */
  6345. _rebuild(): void;
  6346. /** @hidden */
  6347. _swapAndDie(target: InternalTexture): void;
  6348. /**
  6349. * Dispose the current allocated resources
  6350. */
  6351. dispose(): void;
  6352. }
  6353. }
  6354. declare module BABYLON {
  6355. /**
  6356. * This represents the main contract an easing function should follow.
  6357. * Easing functions are used throughout the animation system.
  6358. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6359. */
  6360. export interface IEasingFunction {
  6361. /**
  6362. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6363. * of the easing function.
  6364. * The link below provides some of the most common examples of easing functions.
  6365. * @see https://easings.net/
  6366. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6367. * @returns the corresponding value on the curve defined by the easing function
  6368. */
  6369. ease(gradient: number): number;
  6370. }
  6371. /**
  6372. * Base class used for every default easing function.
  6373. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6374. */
  6375. export class EasingFunction implements IEasingFunction {
  6376. /**
  6377. * Interpolation follows the mathematical formula associated with the easing function.
  6378. */
  6379. static readonly EASINGMODE_EASEIN: number;
  6380. /**
  6381. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6382. */
  6383. static readonly EASINGMODE_EASEOUT: number;
  6384. /**
  6385. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6386. */
  6387. static readonly EASINGMODE_EASEINOUT: number;
  6388. private _easingMode;
  6389. /**
  6390. * Sets the easing mode of the current function.
  6391. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6392. */
  6393. setEasingMode(easingMode: number): void;
  6394. /**
  6395. * Gets the current easing mode.
  6396. * @returns the easing mode
  6397. */
  6398. getEasingMode(): number;
  6399. /**
  6400. * @hidden
  6401. */
  6402. easeInCore(gradient: number): number;
  6403. /**
  6404. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6405. * of the easing function.
  6406. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6407. * @returns the corresponding value on the curve defined by the easing function
  6408. */
  6409. ease(gradient: number): number;
  6410. }
  6411. /**
  6412. * Easing function with a circle shape (see link below).
  6413. * @see https://easings.net/#easeInCirc
  6414. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6415. */
  6416. export class CircleEase extends EasingFunction implements IEasingFunction {
  6417. /** @hidden */
  6418. easeInCore(gradient: number): number;
  6419. }
  6420. /**
  6421. * Easing function with a ease back shape (see link below).
  6422. * @see https://easings.net/#easeInBack
  6423. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6424. */
  6425. export class BackEase extends EasingFunction implements IEasingFunction {
  6426. /** Defines the amplitude of the function */
  6427. amplitude: number;
  6428. /**
  6429. * Instantiates a back ease easing
  6430. * @see https://easings.net/#easeInBack
  6431. * @param amplitude Defines the amplitude of the function
  6432. */
  6433. constructor(
  6434. /** Defines the amplitude of the function */
  6435. amplitude?: number);
  6436. /** @hidden */
  6437. easeInCore(gradient: number): number;
  6438. }
  6439. /**
  6440. * Easing function with a bouncing shape (see link below).
  6441. * @see https://easings.net/#easeInBounce
  6442. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6443. */
  6444. export class BounceEase extends EasingFunction implements IEasingFunction {
  6445. /** Defines the number of bounces */
  6446. bounces: number;
  6447. /** Defines the amplitude of the bounce */
  6448. bounciness: number;
  6449. /**
  6450. * Instantiates a bounce easing
  6451. * @see https://easings.net/#easeInBounce
  6452. * @param bounces Defines the number of bounces
  6453. * @param bounciness Defines the amplitude of the bounce
  6454. */
  6455. constructor(
  6456. /** Defines the number of bounces */
  6457. bounces?: number,
  6458. /** Defines the amplitude of the bounce */
  6459. bounciness?: number);
  6460. /** @hidden */
  6461. easeInCore(gradient: number): number;
  6462. }
  6463. /**
  6464. * Easing function with a power of 3 shape (see link below).
  6465. * @see https://easings.net/#easeInCubic
  6466. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6467. */
  6468. export class CubicEase extends EasingFunction implements IEasingFunction {
  6469. /** @hidden */
  6470. easeInCore(gradient: number): number;
  6471. }
  6472. /**
  6473. * Easing function with an elastic shape (see link below).
  6474. * @see https://easings.net/#easeInElastic
  6475. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6476. */
  6477. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6478. /** Defines the number of oscillations*/
  6479. oscillations: number;
  6480. /** Defines the amplitude of the oscillations*/
  6481. springiness: number;
  6482. /**
  6483. * Instantiates an elastic easing function
  6484. * @see https://easings.net/#easeInElastic
  6485. * @param oscillations Defines the number of oscillations
  6486. * @param springiness Defines the amplitude of the oscillations
  6487. */
  6488. constructor(
  6489. /** Defines the number of oscillations*/
  6490. oscillations?: number,
  6491. /** Defines the amplitude of the oscillations*/
  6492. springiness?: number);
  6493. /** @hidden */
  6494. easeInCore(gradient: number): number;
  6495. }
  6496. /**
  6497. * Easing function with an exponential shape (see link below).
  6498. * @see https://easings.net/#easeInExpo
  6499. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6500. */
  6501. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6502. /** Defines the exponent of the function */
  6503. exponent: number;
  6504. /**
  6505. * Instantiates an exponential easing function
  6506. * @see https://easings.net/#easeInExpo
  6507. * @param exponent Defines the exponent of the function
  6508. */
  6509. constructor(
  6510. /** Defines the exponent of the function */
  6511. exponent?: number);
  6512. /** @hidden */
  6513. easeInCore(gradient: number): number;
  6514. }
  6515. /**
  6516. * Easing function with a power shape (see link below).
  6517. * @see https://easings.net/#easeInQuad
  6518. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6519. */
  6520. export class PowerEase extends EasingFunction implements IEasingFunction {
  6521. /** Defines the power of the function */
  6522. power: number;
  6523. /**
  6524. * Instantiates an power base easing function
  6525. * @see https://easings.net/#easeInQuad
  6526. * @param power Defines the power of the function
  6527. */
  6528. constructor(
  6529. /** Defines the power of the function */
  6530. power?: number);
  6531. /** @hidden */
  6532. easeInCore(gradient: number): number;
  6533. }
  6534. /**
  6535. * Easing function with a power of 2 shape (see link below).
  6536. * @see https://easings.net/#easeInQuad
  6537. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6538. */
  6539. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6540. /** @hidden */
  6541. easeInCore(gradient: number): number;
  6542. }
  6543. /**
  6544. * Easing function with a power of 4 shape (see link below).
  6545. * @see https://easings.net/#easeInQuart
  6546. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6547. */
  6548. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6549. /** @hidden */
  6550. easeInCore(gradient: number): number;
  6551. }
  6552. /**
  6553. * Easing function with a power of 5 shape (see link below).
  6554. * @see https://easings.net/#easeInQuint
  6555. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6556. */
  6557. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6558. /** @hidden */
  6559. easeInCore(gradient: number): number;
  6560. }
  6561. /**
  6562. * Easing function with a sin shape (see link below).
  6563. * @see https://easings.net/#easeInSine
  6564. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6565. */
  6566. export class SineEase extends EasingFunction implements IEasingFunction {
  6567. /** @hidden */
  6568. easeInCore(gradient: number): number;
  6569. }
  6570. /**
  6571. * Easing function with a bezier shape (see link below).
  6572. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6573. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6574. */
  6575. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6576. /** Defines the x component of the start tangent in the bezier curve */
  6577. x1: number;
  6578. /** Defines the y component of the start tangent in the bezier curve */
  6579. y1: number;
  6580. /** Defines the x component of the end tangent in the bezier curve */
  6581. x2: number;
  6582. /** Defines the y component of the end tangent in the bezier curve */
  6583. y2: number;
  6584. /**
  6585. * Instantiates a bezier function
  6586. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6587. * @param x1 Defines the x component of the start tangent in the bezier curve
  6588. * @param y1 Defines the y component of the start tangent in the bezier curve
  6589. * @param x2 Defines the x component of the end tangent in the bezier curve
  6590. * @param y2 Defines the y component of the end tangent in the bezier curve
  6591. */
  6592. constructor(
  6593. /** Defines the x component of the start tangent in the bezier curve */
  6594. x1?: number,
  6595. /** Defines the y component of the start tangent in the bezier curve */
  6596. y1?: number,
  6597. /** Defines the x component of the end tangent in the bezier curve */
  6598. x2?: number,
  6599. /** Defines the y component of the end tangent in the bezier curve */
  6600. y2?: number);
  6601. /** @hidden */
  6602. easeInCore(gradient: number): number;
  6603. }
  6604. }
  6605. declare module BABYLON {
  6606. /**
  6607. * Defines an interface which represents an animation key frame
  6608. */
  6609. export interface IAnimationKey {
  6610. /**
  6611. * Frame of the key frame
  6612. */
  6613. frame: number;
  6614. /**
  6615. * Value at the specifies key frame
  6616. */
  6617. value: any;
  6618. /**
  6619. * The input tangent for the cubic hermite spline
  6620. */
  6621. inTangent?: any;
  6622. /**
  6623. * The output tangent for the cubic hermite spline
  6624. */
  6625. outTangent?: any;
  6626. /**
  6627. * The animation interpolation type
  6628. */
  6629. interpolation?: AnimationKeyInterpolation;
  6630. }
  6631. /**
  6632. * Enum for the animation key frame interpolation type
  6633. */
  6634. export enum AnimationKeyInterpolation {
  6635. /**
  6636. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6637. */
  6638. STEP = 1
  6639. }
  6640. }
  6641. declare module BABYLON {
  6642. /**
  6643. * Represents the range of an animation
  6644. */
  6645. export class AnimationRange {
  6646. /**The name of the animation range**/
  6647. name: string;
  6648. /**The starting frame of the animation */
  6649. from: number;
  6650. /**The ending frame of the animation*/
  6651. to: number;
  6652. /**
  6653. * Initializes the range of an animation
  6654. * @param name The name of the animation range
  6655. * @param from The starting frame of the animation
  6656. * @param to The ending frame of the animation
  6657. */
  6658. constructor(
  6659. /**The name of the animation range**/
  6660. name: string,
  6661. /**The starting frame of the animation */
  6662. from: number,
  6663. /**The ending frame of the animation*/
  6664. to: number);
  6665. /**
  6666. * Makes a copy of the animation range
  6667. * @returns A copy of the animation range
  6668. */
  6669. clone(): AnimationRange;
  6670. }
  6671. }
  6672. declare module BABYLON {
  6673. /**
  6674. * Composed of a frame, and an action function
  6675. */
  6676. export class AnimationEvent {
  6677. /** The frame for which the event is triggered **/
  6678. frame: number;
  6679. /** The event to perform when triggered **/
  6680. action: (currentFrame: number) => void;
  6681. /** Specifies if the event should be triggered only once**/
  6682. onlyOnce?: boolean | undefined;
  6683. /**
  6684. * Specifies if the animation event is done
  6685. */
  6686. isDone: boolean;
  6687. /**
  6688. * Initializes the animation event
  6689. * @param frame The frame for which the event is triggered
  6690. * @param action The event to perform when triggered
  6691. * @param onlyOnce Specifies if the event should be triggered only once
  6692. */
  6693. constructor(
  6694. /** The frame for which the event is triggered **/
  6695. frame: number,
  6696. /** The event to perform when triggered **/
  6697. action: (currentFrame: number) => void,
  6698. /** Specifies if the event should be triggered only once**/
  6699. onlyOnce?: boolean | undefined);
  6700. /** @hidden */
  6701. _clone(): AnimationEvent;
  6702. }
  6703. }
  6704. declare module BABYLON {
  6705. /**
  6706. * Interface used to define a behavior
  6707. */
  6708. export interface Behavior<T> {
  6709. /** gets or sets behavior's name */
  6710. name: string;
  6711. /**
  6712. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6713. */
  6714. init(): void;
  6715. /**
  6716. * Called when the behavior is attached to a target
  6717. * @param target defines the target where the behavior is attached to
  6718. */
  6719. attach(target: T): void;
  6720. /**
  6721. * Called when the behavior is detached from its target
  6722. */
  6723. detach(): void;
  6724. }
  6725. /**
  6726. * Interface implemented by classes supporting behaviors
  6727. */
  6728. export interface IBehaviorAware<T> {
  6729. /**
  6730. * Attach a behavior
  6731. * @param behavior defines the behavior to attach
  6732. * @returns the current host
  6733. */
  6734. addBehavior(behavior: Behavior<T>): T;
  6735. /**
  6736. * Remove a behavior from the current object
  6737. * @param behavior defines the behavior to detach
  6738. * @returns the current host
  6739. */
  6740. removeBehavior(behavior: Behavior<T>): T;
  6741. /**
  6742. * Gets a behavior using its name to search
  6743. * @param name defines the name to search
  6744. * @returns the behavior or null if not found
  6745. */
  6746. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6747. }
  6748. }
  6749. declare module BABYLON {
  6750. /**
  6751. * @hidden
  6752. */
  6753. export class IntersectionInfo {
  6754. bu: Nullable<number>;
  6755. bv: Nullable<number>;
  6756. distance: number;
  6757. faceId: number;
  6758. subMeshId: number;
  6759. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6760. }
  6761. }
  6762. declare module BABYLON {
  6763. /**
  6764. * Class used to store bounding sphere information
  6765. */
  6766. export class BoundingSphere {
  6767. /**
  6768. * Gets the center of the bounding sphere in local space
  6769. */
  6770. readonly center: Vector3;
  6771. /**
  6772. * Radius of the bounding sphere in local space
  6773. */
  6774. radius: number;
  6775. /**
  6776. * Gets the center of the bounding sphere in world space
  6777. */
  6778. readonly centerWorld: Vector3;
  6779. /**
  6780. * Radius of the bounding sphere in world space
  6781. */
  6782. radiusWorld: number;
  6783. /**
  6784. * Gets the minimum vector in local space
  6785. */
  6786. readonly minimum: Vector3;
  6787. /**
  6788. * Gets the maximum vector in local space
  6789. */
  6790. readonly maximum: Vector3;
  6791. private _worldMatrix;
  6792. private static readonly TmpVector3;
  6793. /**
  6794. * Creates a new bounding sphere
  6795. * @param min defines the minimum vector (in local space)
  6796. * @param max defines the maximum vector (in local space)
  6797. * @param worldMatrix defines the new world matrix
  6798. */
  6799. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6800. /**
  6801. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6802. * @param min defines the new minimum vector (in local space)
  6803. * @param max defines the new maximum vector (in local space)
  6804. * @param worldMatrix defines the new world matrix
  6805. */
  6806. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6807. /**
  6808. * Scale the current bounding sphere by applying a scale factor
  6809. * @param factor defines the scale factor to apply
  6810. * @returns the current bounding box
  6811. */
  6812. scale(factor: number): BoundingSphere;
  6813. /**
  6814. * Gets the world matrix of the bounding box
  6815. * @returns a matrix
  6816. */
  6817. getWorldMatrix(): DeepImmutable<Matrix>;
  6818. /** @hidden */
  6819. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6820. /**
  6821. * Tests if the bounding sphere is intersecting the frustum planes
  6822. * @param frustumPlanes defines the frustum planes to test
  6823. * @returns true if there is an intersection
  6824. */
  6825. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6826. /**
  6827. * Tests if the bounding sphere center is in between the frustum planes.
  6828. * Used for optimistic fast inclusion.
  6829. * @param frustumPlanes defines the frustum planes to test
  6830. * @returns true if the sphere center is in between the frustum planes
  6831. */
  6832. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6833. /**
  6834. * Tests if a point is inside the bounding sphere
  6835. * @param point defines the point to test
  6836. * @returns true if the point is inside the bounding sphere
  6837. */
  6838. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6839. /**
  6840. * Checks if two sphere intersct
  6841. * @param sphere0 sphere 0
  6842. * @param sphere1 sphere 1
  6843. * @returns true if the speres intersect
  6844. */
  6845. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6846. }
  6847. }
  6848. declare module BABYLON {
  6849. /**
  6850. * Class used to store bounding box information
  6851. */
  6852. export class BoundingBox implements ICullable {
  6853. /**
  6854. * Gets the 8 vectors representing the bounding box in local space
  6855. */
  6856. readonly vectors: Vector3[];
  6857. /**
  6858. * Gets the center of the bounding box in local space
  6859. */
  6860. readonly center: Vector3;
  6861. /**
  6862. * Gets the center of the bounding box in world space
  6863. */
  6864. readonly centerWorld: Vector3;
  6865. /**
  6866. * Gets the extend size in local space
  6867. */
  6868. readonly extendSize: Vector3;
  6869. /**
  6870. * Gets the extend size in world space
  6871. */
  6872. readonly extendSizeWorld: Vector3;
  6873. /**
  6874. * Gets the OBB (object bounding box) directions
  6875. */
  6876. readonly directions: Vector3[];
  6877. /**
  6878. * Gets the 8 vectors representing the bounding box in world space
  6879. */
  6880. readonly vectorsWorld: Vector3[];
  6881. /**
  6882. * Gets the minimum vector in world space
  6883. */
  6884. readonly minimumWorld: Vector3;
  6885. /**
  6886. * Gets the maximum vector in world space
  6887. */
  6888. readonly maximumWorld: Vector3;
  6889. /**
  6890. * Gets the minimum vector in local space
  6891. */
  6892. readonly minimum: Vector3;
  6893. /**
  6894. * Gets the maximum vector in local space
  6895. */
  6896. readonly maximum: Vector3;
  6897. private _worldMatrix;
  6898. private static readonly TmpVector3;
  6899. /**
  6900. * @hidden
  6901. */
  6902. _tag: number;
  6903. /**
  6904. * Creates a new bounding box
  6905. * @param min defines the minimum vector (in local space)
  6906. * @param max defines the maximum vector (in local space)
  6907. * @param worldMatrix defines the new world matrix
  6908. */
  6909. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6910. /**
  6911. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6912. * @param min defines the new minimum vector (in local space)
  6913. * @param max defines the new maximum vector (in local space)
  6914. * @param worldMatrix defines the new world matrix
  6915. */
  6916. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6917. /**
  6918. * Scale the current bounding box by applying a scale factor
  6919. * @param factor defines the scale factor to apply
  6920. * @returns the current bounding box
  6921. */
  6922. scale(factor: number): BoundingBox;
  6923. /**
  6924. * Gets the world matrix of the bounding box
  6925. * @returns a matrix
  6926. */
  6927. getWorldMatrix(): DeepImmutable<Matrix>;
  6928. /** @hidden */
  6929. _update(world: DeepImmutable<Matrix>): void;
  6930. /**
  6931. * Tests if the bounding box is intersecting the frustum planes
  6932. * @param frustumPlanes defines the frustum planes to test
  6933. * @returns true if there is an intersection
  6934. */
  6935. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6936. /**
  6937. * Tests if the bounding box is entirely inside the frustum planes
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @returns true if there is an inclusion
  6940. */
  6941. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /**
  6943. * Tests if a point is inside the bounding box
  6944. * @param point defines the point to test
  6945. * @returns true if the point is inside the bounding box
  6946. */
  6947. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6948. /**
  6949. * Tests if the bounding box intersects with a bounding sphere
  6950. * @param sphere defines the sphere to test
  6951. * @returns true if there is an intersection
  6952. */
  6953. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6954. /**
  6955. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6956. * @param min defines the min vector to use
  6957. * @param max defines the max vector to use
  6958. * @returns true if there is an intersection
  6959. */
  6960. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6961. /**
  6962. * Tests if two bounding boxes are intersections
  6963. * @param box0 defines the first box to test
  6964. * @param box1 defines the second box to test
  6965. * @returns true if there is an intersection
  6966. */
  6967. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6968. /**
  6969. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6970. * @param minPoint defines the minimum vector of the bounding box
  6971. * @param maxPoint defines the maximum vector of the bounding box
  6972. * @param sphereCenter defines the sphere center
  6973. * @param sphereRadius defines the sphere radius
  6974. * @returns true if there is an intersection
  6975. */
  6976. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6977. /**
  6978. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6979. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6980. * @param frustumPlanes defines the frustum planes to test
  6981. * @return true if there is an inclusion
  6982. */
  6983. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6984. /**
  6985. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6986. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6987. * @param frustumPlanes defines the frustum planes to test
  6988. * @return true if there is an intersection
  6989. */
  6990. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6991. }
  6992. }
  6993. declare module BABYLON {
  6994. /** @hidden */
  6995. export class Collider {
  6996. /** Define if a collision was found */
  6997. collisionFound: boolean;
  6998. /**
  6999. * Define last intersection point in local space
  7000. */
  7001. intersectionPoint: Vector3;
  7002. /**
  7003. * Define last collided mesh
  7004. */
  7005. collidedMesh: Nullable<AbstractMesh>;
  7006. private _collisionPoint;
  7007. private _planeIntersectionPoint;
  7008. private _tempVector;
  7009. private _tempVector2;
  7010. private _tempVector3;
  7011. private _tempVector4;
  7012. private _edge;
  7013. private _baseToVertex;
  7014. private _destinationPoint;
  7015. private _slidePlaneNormal;
  7016. private _displacementVector;
  7017. /** @hidden */
  7018. _radius: Vector3;
  7019. /** @hidden */
  7020. _retry: number;
  7021. private _velocity;
  7022. private _basePoint;
  7023. private _epsilon;
  7024. /** @hidden */
  7025. _velocityWorldLength: number;
  7026. /** @hidden */
  7027. _basePointWorld: Vector3;
  7028. private _velocityWorld;
  7029. private _normalizedVelocity;
  7030. /** @hidden */
  7031. _initialVelocity: Vector3;
  7032. /** @hidden */
  7033. _initialPosition: Vector3;
  7034. private _nearestDistance;
  7035. private _collisionMask;
  7036. collisionMask: number;
  7037. /**
  7038. * Gets the plane normal used to compute the sliding response (in local space)
  7039. */
  7040. readonly slidePlaneNormal: Vector3;
  7041. /** @hidden */
  7042. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7043. /** @hidden */
  7044. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7045. /** @hidden */
  7046. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7047. /** @hidden */
  7048. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7049. /** @hidden */
  7050. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7051. /** @hidden */
  7052. _getResponse(pos: Vector3, vel: Vector3): void;
  7053. }
  7054. }
  7055. declare module BABYLON {
  7056. /**
  7057. * Interface for cullable objects
  7058. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7059. */
  7060. export interface ICullable {
  7061. /**
  7062. * Checks if the object or part of the object is in the frustum
  7063. * @param frustumPlanes Camera near/planes
  7064. * @returns true if the object is in frustum otherwise false
  7065. */
  7066. isInFrustum(frustumPlanes: Plane[]): boolean;
  7067. /**
  7068. * Checks if a cullable object (mesh...) is in the camera frustum
  7069. * Unlike isInFrustum this cheks the full bounding box
  7070. * @param frustumPlanes Camera near/planes
  7071. * @returns true if the object is in frustum otherwise false
  7072. */
  7073. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7074. }
  7075. /**
  7076. * Info for a bounding data of a mesh
  7077. */
  7078. export class BoundingInfo implements ICullable {
  7079. /**
  7080. * Bounding box for the mesh
  7081. */
  7082. readonly boundingBox: BoundingBox;
  7083. /**
  7084. * Bounding sphere for the mesh
  7085. */
  7086. readonly boundingSphere: BoundingSphere;
  7087. private _isLocked;
  7088. private static readonly TmpVector3;
  7089. /**
  7090. * Constructs bounding info
  7091. * @param minimum min vector of the bounding box/sphere
  7092. * @param maximum max vector of the bounding box/sphere
  7093. * @param worldMatrix defines the new world matrix
  7094. */
  7095. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7096. /**
  7097. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7098. * @param min defines the new minimum vector (in local space)
  7099. * @param max defines the new maximum vector (in local space)
  7100. * @param worldMatrix defines the new world matrix
  7101. */
  7102. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7103. /**
  7104. * min vector of the bounding box/sphere
  7105. */
  7106. readonly minimum: Vector3;
  7107. /**
  7108. * max vector of the bounding box/sphere
  7109. */
  7110. readonly maximum: Vector3;
  7111. /**
  7112. * If the info is locked and won't be updated to avoid perf overhead
  7113. */
  7114. isLocked: boolean;
  7115. /**
  7116. * Updates the bounding sphere and box
  7117. * @param world world matrix to be used to update
  7118. */
  7119. update(world: DeepImmutable<Matrix>): void;
  7120. /**
  7121. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7122. * @param center New center of the bounding info
  7123. * @param extend New extend of the bounding info
  7124. * @returns the current bounding info
  7125. */
  7126. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7127. /**
  7128. * Scale the current bounding info by applying a scale factor
  7129. * @param factor defines the scale factor to apply
  7130. * @returns the current bounding info
  7131. */
  7132. scale(factor: number): BoundingInfo;
  7133. /**
  7134. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7135. * @param frustumPlanes defines the frustum to test
  7136. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7137. * @returns true if the bounding info is in the frustum planes
  7138. */
  7139. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7140. /**
  7141. * Gets the world distance between the min and max points of the bounding box
  7142. */
  7143. readonly diagonalLength: number;
  7144. /**
  7145. * Checks if a cullable object (mesh...) is in the camera frustum
  7146. * Unlike isInFrustum this cheks the full bounding box
  7147. * @param frustumPlanes Camera near/planes
  7148. * @returns true if the object is in frustum otherwise false
  7149. */
  7150. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7151. /** @hidden */
  7152. _checkCollision(collider: Collider): boolean;
  7153. /**
  7154. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7155. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7156. * @param point the point to check intersection with
  7157. * @returns if the point intersects
  7158. */
  7159. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7160. /**
  7161. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7162. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7163. * @param boundingInfo the bounding info to check intersection with
  7164. * @param precise if the intersection should be done using OBB
  7165. * @returns if the bounding info intersects
  7166. */
  7167. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7168. }
  7169. }
  7170. declare module BABYLON {
  7171. /**
  7172. * Defines an array and its length.
  7173. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7174. */
  7175. export interface ISmartArrayLike<T> {
  7176. /**
  7177. * The data of the array.
  7178. */
  7179. data: Array<T>;
  7180. /**
  7181. * The active length of the array.
  7182. */
  7183. length: number;
  7184. }
  7185. /**
  7186. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7187. */
  7188. export class SmartArray<T> implements ISmartArrayLike<T> {
  7189. /**
  7190. * The full set of data from the array.
  7191. */
  7192. data: Array<T>;
  7193. /**
  7194. * The active length of the array.
  7195. */
  7196. length: number;
  7197. protected _id: number;
  7198. /**
  7199. * Instantiates a Smart Array.
  7200. * @param capacity defines the default capacity of the array.
  7201. */
  7202. constructor(capacity: number);
  7203. /**
  7204. * Pushes a value at the end of the active data.
  7205. * @param value defines the object to push in the array.
  7206. */
  7207. push(value: T): void;
  7208. /**
  7209. * Iterates over the active data and apply the lambda to them.
  7210. * @param func defines the action to apply on each value.
  7211. */
  7212. forEach(func: (content: T) => void): void;
  7213. /**
  7214. * Sorts the full sets of data.
  7215. * @param compareFn defines the comparison function to apply.
  7216. */
  7217. sort(compareFn: (a: T, b: T) => number): void;
  7218. /**
  7219. * Resets the active data to an empty array.
  7220. */
  7221. reset(): void;
  7222. /**
  7223. * Releases all the data from the array as well as the array.
  7224. */
  7225. dispose(): void;
  7226. /**
  7227. * Concats the active data with a given array.
  7228. * @param array defines the data to concatenate with.
  7229. */
  7230. concat(array: any): void;
  7231. /**
  7232. * Returns the position of a value in the active data.
  7233. * @param value defines the value to find the index for
  7234. * @returns the index if found in the active data otherwise -1
  7235. */
  7236. indexOf(value: T): number;
  7237. /**
  7238. * Returns whether an element is part of the active data.
  7239. * @param value defines the value to look for
  7240. * @returns true if found in the active data otherwise false
  7241. */
  7242. contains(value: T): boolean;
  7243. private static _GlobalId;
  7244. }
  7245. /**
  7246. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7247. * The data in this array can only be present once
  7248. */
  7249. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7250. private _duplicateId;
  7251. /**
  7252. * Pushes a value at the end of the active data.
  7253. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7254. * @param value defines the object to push in the array.
  7255. */
  7256. push(value: T): void;
  7257. /**
  7258. * Pushes a value at the end of the active data.
  7259. * If the data is already present, it won t be added again
  7260. * @param value defines the object to push in the array.
  7261. * @returns true if added false if it was already present
  7262. */
  7263. pushNoDuplicate(value: T): boolean;
  7264. /**
  7265. * Resets the active data to an empty array.
  7266. */
  7267. reset(): void;
  7268. /**
  7269. * Concats the active data with a given array.
  7270. * This ensures no dupplicate will be present in the result.
  7271. * @param array defines the data to concatenate with.
  7272. */
  7273. concatWithNoDuplicate(array: any): void;
  7274. }
  7275. }
  7276. declare module BABYLON {
  7277. /**
  7278. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7279. * separate meshes. This can be use to improve performances.
  7280. * @see http://doc.babylonjs.com/how_to/multi_materials
  7281. */
  7282. export class MultiMaterial extends Material {
  7283. private _subMaterials;
  7284. /**
  7285. * Gets or Sets the list of Materials used within the multi material.
  7286. * They need to be ordered according to the submeshes order in the associated mesh
  7287. */
  7288. subMaterials: Nullable<Material>[];
  7289. /**
  7290. * Function used to align with Node.getChildren()
  7291. * @returns the list of Materials used within the multi material
  7292. */
  7293. getChildren(): Nullable<Material>[];
  7294. /**
  7295. * Instantiates a new Multi Material
  7296. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7297. * separate meshes. This can be use to improve performances.
  7298. * @see http://doc.babylonjs.com/how_to/multi_materials
  7299. * @param name Define the name in the scene
  7300. * @param scene Define the scene the material belongs to
  7301. */
  7302. constructor(name: string, scene: Scene);
  7303. private _hookArray;
  7304. /**
  7305. * Get one of the submaterial by its index in the submaterials array
  7306. * @param index The index to look the sub material at
  7307. * @returns The Material if the index has been defined
  7308. */
  7309. getSubMaterial(index: number): Nullable<Material>;
  7310. /**
  7311. * Get the list of active textures for the whole sub materials list.
  7312. * @returns All the textures that will be used during the rendering
  7313. */
  7314. getActiveTextures(): BaseTexture[];
  7315. /**
  7316. * Gets the current class name of the material e.g. "MultiMaterial"
  7317. * Mainly use in serialization.
  7318. * @returns the class name
  7319. */
  7320. getClassName(): string;
  7321. /**
  7322. * Checks if the material is ready to render the requested sub mesh
  7323. * @param mesh Define the mesh the submesh belongs to
  7324. * @param subMesh Define the sub mesh to look readyness for
  7325. * @param useInstances Define whether or not the material is used with instances
  7326. * @returns true if ready, otherwise false
  7327. */
  7328. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7329. /**
  7330. * Clones the current material and its related sub materials
  7331. * @param name Define the name of the newly cloned material
  7332. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7333. * @returns the cloned material
  7334. */
  7335. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7336. /**
  7337. * Serializes the materials into a JSON representation.
  7338. * @returns the JSON representation
  7339. */
  7340. serialize(): any;
  7341. /**
  7342. * Dispose the material and release its associated resources
  7343. * @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)
  7344. * @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)
  7345. * @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)
  7346. */
  7347. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7348. /**
  7349. * Creates a MultiMaterial from parsed MultiMaterial data.
  7350. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7351. * @param scene defines the hosting scene
  7352. * @returns a new MultiMaterial
  7353. */
  7354. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7355. }
  7356. }
  7357. declare module BABYLON {
  7358. /**
  7359. * Class used to represent data loading progression
  7360. */
  7361. export class SceneLoaderFlags {
  7362. private static _ForceFullSceneLoadingForIncremental;
  7363. private static _ShowLoadingScreen;
  7364. private static _CleanBoneMatrixWeights;
  7365. private static _loggingLevel;
  7366. /**
  7367. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7368. */
  7369. static ForceFullSceneLoadingForIncremental: boolean;
  7370. /**
  7371. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7372. */
  7373. static ShowLoadingScreen: boolean;
  7374. /**
  7375. * Defines the current logging level (while loading the scene)
  7376. * @ignorenaming
  7377. */
  7378. static loggingLevel: number;
  7379. /**
  7380. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7381. */
  7382. static CleanBoneMatrixWeights: boolean;
  7383. }
  7384. }
  7385. declare module BABYLON {
  7386. /**
  7387. * 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.
  7388. * @see https://doc.babylonjs.com/how_to/transformnode
  7389. */
  7390. export class TransformNode extends Node {
  7391. /**
  7392. * Object will not rotate to face the camera
  7393. */
  7394. static BILLBOARDMODE_NONE: number;
  7395. /**
  7396. * Object will rotate to face the camera but only on the x axis
  7397. */
  7398. static BILLBOARDMODE_X: number;
  7399. /**
  7400. * Object will rotate to face the camera but only on the y axis
  7401. */
  7402. static BILLBOARDMODE_Y: number;
  7403. /**
  7404. * Object will rotate to face the camera but only on the z axis
  7405. */
  7406. static BILLBOARDMODE_Z: number;
  7407. /**
  7408. * Object will rotate to face the camera
  7409. */
  7410. static BILLBOARDMODE_ALL: number;
  7411. private _forward;
  7412. private _forwardInverted;
  7413. private _up;
  7414. private _right;
  7415. private _rightInverted;
  7416. private _position;
  7417. private _rotation;
  7418. private _rotationQuaternion;
  7419. protected _scaling: Vector3;
  7420. protected _isDirty: boolean;
  7421. private _transformToBoneReferal;
  7422. /**
  7423. * Set the billboard mode. Default is 0.
  7424. *
  7425. * | Value | Type | Description |
  7426. * | --- | --- | --- |
  7427. * | 0 | BILLBOARDMODE_NONE | |
  7428. * | 1 | BILLBOARDMODE_X | |
  7429. * | 2 | BILLBOARDMODE_Y | |
  7430. * | 4 | BILLBOARDMODE_Z | |
  7431. * | 7 | BILLBOARDMODE_ALL | |
  7432. *
  7433. */
  7434. billboardMode: number;
  7435. /**
  7436. * 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
  7437. */
  7438. scalingDeterminant: number;
  7439. /**
  7440. * Sets the distance of the object to max, often used by skybox
  7441. */
  7442. infiniteDistance: boolean;
  7443. /**
  7444. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7445. * By default the system will update normals to compensate
  7446. */
  7447. ignoreNonUniformScaling: boolean;
  7448. /** @hidden */
  7449. _poseMatrix: Matrix;
  7450. /** @hidden */
  7451. _localMatrix: Matrix;
  7452. private _absolutePosition;
  7453. private _pivotMatrix;
  7454. private _pivotMatrixInverse;
  7455. protected _postMultiplyPivotMatrix: boolean;
  7456. protected _isWorldMatrixFrozen: boolean;
  7457. /** @hidden */
  7458. _indexInSceneTransformNodesArray: number;
  7459. /**
  7460. * An event triggered after the world matrix is updated
  7461. */
  7462. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7463. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7464. /**
  7465. * Gets a string identifying the name of the class
  7466. * @returns "TransformNode" string
  7467. */
  7468. getClassName(): string;
  7469. /**
  7470. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7471. */
  7472. position: Vector3;
  7473. /**
  7474. * 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)).
  7475. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7476. */
  7477. rotation: Vector3;
  7478. /**
  7479. * 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)).
  7480. */
  7481. scaling: Vector3;
  7482. /**
  7483. * 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).
  7484. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7485. */
  7486. rotationQuaternion: Nullable<Quaternion>;
  7487. /**
  7488. * The forward direction of that transform in world space.
  7489. */
  7490. readonly forward: Vector3;
  7491. /**
  7492. * The up direction of that transform in world space.
  7493. */
  7494. readonly up: Vector3;
  7495. /**
  7496. * The right direction of that transform in world space.
  7497. */
  7498. readonly right: Vector3;
  7499. /**
  7500. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7501. * @param matrix the matrix to copy the pose from
  7502. * @returns this TransformNode.
  7503. */
  7504. updatePoseMatrix(matrix: Matrix): TransformNode;
  7505. /**
  7506. * Returns the mesh Pose matrix.
  7507. * @returns the pose matrix
  7508. */
  7509. getPoseMatrix(): Matrix;
  7510. /** @hidden */
  7511. _isSynchronized(): boolean;
  7512. /** @hidden */
  7513. _initCache(): void;
  7514. /**
  7515. * Flag the transform node as dirty (Forcing it to update everything)
  7516. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7517. * @returns this transform node
  7518. */
  7519. markAsDirty(property: string): TransformNode;
  7520. /**
  7521. * Returns the current mesh absolute position.
  7522. * Returns a Vector3.
  7523. */
  7524. readonly absolutePosition: Vector3;
  7525. /**
  7526. * Sets a new matrix to apply before all other transformation
  7527. * @param matrix defines the transform matrix
  7528. * @returns the current TransformNode
  7529. */
  7530. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7531. /**
  7532. * Sets a new pivot matrix to the current node
  7533. * @param matrix defines the new pivot matrix to use
  7534. * @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
  7535. * @returns the current TransformNode
  7536. */
  7537. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7538. /**
  7539. * Returns the mesh pivot matrix.
  7540. * Default : Identity.
  7541. * @returns the matrix
  7542. */
  7543. getPivotMatrix(): Matrix;
  7544. /**
  7545. * Prevents the World matrix to be computed any longer.
  7546. * @returns the TransformNode.
  7547. */
  7548. freezeWorldMatrix(): TransformNode;
  7549. /**
  7550. * Allows back the World matrix computation.
  7551. * @returns the TransformNode.
  7552. */
  7553. unfreezeWorldMatrix(): this;
  7554. /**
  7555. * True if the World matrix has been frozen.
  7556. */
  7557. readonly isWorldMatrixFrozen: boolean;
  7558. /**
  7559. * Retuns the mesh absolute position in the World.
  7560. * @returns a Vector3.
  7561. */
  7562. getAbsolutePosition(): Vector3;
  7563. /**
  7564. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7565. * @param absolutePosition the absolute position to set
  7566. * @returns the TransformNode.
  7567. */
  7568. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7569. /**
  7570. * Sets the mesh position in its local space.
  7571. * @param vector3 the position to set in localspace
  7572. * @returns the TransformNode.
  7573. */
  7574. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7575. /**
  7576. * Returns the mesh position in the local space from the current World matrix values.
  7577. * @returns a new Vector3.
  7578. */
  7579. getPositionExpressedInLocalSpace(): Vector3;
  7580. /**
  7581. * Translates the mesh along the passed Vector3 in its local space.
  7582. * @param vector3 the distance to translate in localspace
  7583. * @returns the TransformNode.
  7584. */
  7585. locallyTranslate(vector3: Vector3): TransformNode;
  7586. private static _lookAtVectorCache;
  7587. /**
  7588. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7589. * @param targetPoint the position (must be in same space as current mesh) to look at
  7590. * @param yawCor optional yaw (y-axis) correction in radians
  7591. * @param pitchCor optional pitch (x-axis) correction in radians
  7592. * @param rollCor optional roll (z-axis) correction in radians
  7593. * @param space the choosen space of the target
  7594. * @returns the TransformNode.
  7595. */
  7596. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7597. /**
  7598. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7599. * This Vector3 is expressed in the World space.
  7600. * @param localAxis axis to rotate
  7601. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7602. */
  7603. getDirection(localAxis: Vector3): Vector3;
  7604. /**
  7605. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7606. * localAxis is expressed in the mesh local space.
  7607. * result is computed in the Wordl space from the mesh World matrix.
  7608. * @param localAxis axis to rotate
  7609. * @param result the resulting transformnode
  7610. * @returns this TransformNode.
  7611. */
  7612. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7613. /**
  7614. * Sets this transform node rotation to the given local axis.
  7615. * @param localAxis the axis in local space
  7616. * @param yawCor optional yaw (y-axis) correction in radians
  7617. * @param pitchCor optional pitch (x-axis) correction in radians
  7618. * @param rollCor optional roll (z-axis) correction in radians
  7619. * @returns this TransformNode
  7620. */
  7621. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7622. /**
  7623. * Sets a new pivot point to the current node
  7624. * @param point defines the new pivot point to use
  7625. * @param space defines if the point is in world or local space (local by default)
  7626. * @returns the current TransformNode
  7627. */
  7628. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7629. /**
  7630. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7631. * @returns the pivot point
  7632. */
  7633. getPivotPoint(): Vector3;
  7634. /**
  7635. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7636. * @param result the vector3 to store the result
  7637. * @returns this TransformNode.
  7638. */
  7639. getPivotPointToRef(result: Vector3): TransformNode;
  7640. /**
  7641. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7642. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7643. */
  7644. getAbsolutePivotPoint(): Vector3;
  7645. /**
  7646. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7647. * @param result vector3 to store the result
  7648. * @returns this TransformNode.
  7649. */
  7650. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7651. /**
  7652. * Defines the passed node as the parent of the current node.
  7653. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7654. * @param node the node ot set as the parent
  7655. * @returns this TransformNode.
  7656. */
  7657. setParent(node: Nullable<Node>): TransformNode;
  7658. private _nonUniformScaling;
  7659. /**
  7660. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7661. */
  7662. readonly nonUniformScaling: boolean;
  7663. /** @hidden */
  7664. _updateNonUniformScalingState(value: boolean): boolean;
  7665. /**
  7666. * Attach the current TransformNode to another TransformNode associated with a bone
  7667. * @param bone Bone affecting the TransformNode
  7668. * @param affectedTransformNode TransformNode associated with the bone
  7669. * @returns this object
  7670. */
  7671. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7672. /**
  7673. * Detach the transform node if its associated with a bone
  7674. * @returns this object
  7675. */
  7676. detachFromBone(): TransformNode;
  7677. private static _rotationAxisCache;
  7678. /**
  7679. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7680. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7681. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7682. * The passed axis is also normalized.
  7683. * @param axis the axis to rotate around
  7684. * @param amount the amount to rotate in radians
  7685. * @param space Space to rotate in (Default: local)
  7686. * @returns the TransformNode.
  7687. */
  7688. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7689. /**
  7690. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7691. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7692. * The passed axis is also normalized. .
  7693. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7694. * @param point the point to rotate around
  7695. * @param axis the axis to rotate around
  7696. * @param amount the amount to rotate in radians
  7697. * @returns the TransformNode
  7698. */
  7699. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7700. /**
  7701. * Translates the mesh along the axis vector for the passed distance in the given space.
  7702. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7703. * @param axis the axis to translate in
  7704. * @param distance the distance to translate
  7705. * @param space Space to rotate in (Default: local)
  7706. * @returns the TransformNode.
  7707. */
  7708. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7709. /**
  7710. * Adds a rotation step to the mesh current rotation.
  7711. * x, y, z are Euler angles expressed in radians.
  7712. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7713. * This means this rotation is made in the mesh local space only.
  7714. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7715. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7716. * ```javascript
  7717. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7718. * ```
  7719. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7720. * 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.
  7721. * @param x Rotation to add
  7722. * @param y Rotation to add
  7723. * @param z Rotation to add
  7724. * @returns the TransformNode.
  7725. */
  7726. addRotation(x: number, y: number, z: number): TransformNode;
  7727. /**
  7728. * Computes the world matrix of the node
  7729. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7730. * @returns the world matrix
  7731. */
  7732. computeWorldMatrix(force?: boolean): Matrix;
  7733. protected _afterComputeWorldMatrix(): void;
  7734. /**
  7735. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7736. * @param func callback function to add
  7737. *
  7738. * @returns the TransformNode.
  7739. */
  7740. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7741. /**
  7742. * Removes a registered callback function.
  7743. * @param func callback function to remove
  7744. * @returns the TransformNode.
  7745. */
  7746. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7747. /**
  7748. * Gets the position of the current mesh in camera space
  7749. * @param camera defines the camera to use
  7750. * @returns a position
  7751. */
  7752. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7753. /**
  7754. * Returns the distance from the mesh to the active camera
  7755. * @param camera defines the camera to use
  7756. * @returns the distance
  7757. */
  7758. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7759. /**
  7760. * Clone the current transform node
  7761. * @param name Name of the new clone
  7762. * @param newParent New parent for the clone
  7763. * @param doNotCloneChildren Do not clone children hierarchy
  7764. * @returns the new transform node
  7765. */
  7766. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7767. /**
  7768. * Serializes the objects information.
  7769. * @param currentSerializationObject defines the object to serialize in
  7770. * @returns the serialized object
  7771. */
  7772. serialize(currentSerializationObject?: any): any;
  7773. /**
  7774. * Returns a new TransformNode object parsed from the source provided.
  7775. * @param parsedTransformNode is the source.
  7776. * @param scene the scne the object belongs to
  7777. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7778. * @returns a new TransformNode object parsed from the source provided.
  7779. */
  7780. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7781. /**
  7782. * Get all child-transformNodes of this node
  7783. * @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
  7784. * @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
  7785. * @returns an array of TransformNode
  7786. */
  7787. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7788. /**
  7789. * Releases resources associated with this transform node.
  7790. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7791. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7792. */
  7793. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7794. }
  7795. }
  7796. declare module BABYLON {
  7797. /**
  7798. * Class used to override all child animations of a given target
  7799. */
  7800. export class AnimationPropertiesOverride {
  7801. /**
  7802. * Gets or sets a value indicating if animation blending must be used
  7803. */
  7804. enableBlending: boolean;
  7805. /**
  7806. * Gets or sets the blending speed to use when enableBlending is true
  7807. */
  7808. blendingSpeed: number;
  7809. /**
  7810. * Gets or sets the default loop mode to use
  7811. */
  7812. loopMode: number;
  7813. }
  7814. }
  7815. declare module BABYLON {
  7816. /**
  7817. * Class used to store bone information
  7818. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7819. */
  7820. export class Bone extends Node {
  7821. /**
  7822. * defines the bone name
  7823. */
  7824. name: string;
  7825. private static _tmpVecs;
  7826. private static _tmpQuat;
  7827. private static _tmpMats;
  7828. /**
  7829. * Gets the list of child bones
  7830. */
  7831. children: Bone[];
  7832. /** Gets the animations associated with this bone */
  7833. animations: Animation[];
  7834. /**
  7835. * Gets or sets bone length
  7836. */
  7837. length: number;
  7838. /**
  7839. * @hidden Internal only
  7840. * Set this value to map this bone to a different index in the transform matrices
  7841. * Set this value to -1 to exclude the bone from the transform matrices
  7842. */
  7843. _index: Nullable<number>;
  7844. private _skeleton;
  7845. private _localMatrix;
  7846. private _restPose;
  7847. private _baseMatrix;
  7848. private _absoluteTransform;
  7849. private _invertedAbsoluteTransform;
  7850. private _parent;
  7851. private _scalingDeterminant;
  7852. private _worldTransform;
  7853. private _localScaling;
  7854. private _localRotation;
  7855. private _localPosition;
  7856. private _needToDecompose;
  7857. private _needToCompose;
  7858. /** @hidden */
  7859. _linkedTransformNode: Nullable<TransformNode>;
  7860. /** @hidden */
  7861. /** @hidden */
  7862. _matrix: Matrix;
  7863. /**
  7864. * Create a new bone
  7865. * @param name defines the bone name
  7866. * @param skeleton defines the parent skeleton
  7867. * @param parentBone defines the parent (can be null if the bone is the root)
  7868. * @param localMatrix defines the local matrix
  7869. * @param restPose defines the rest pose matrix
  7870. * @param baseMatrix defines the base matrix
  7871. * @param index defines index of the bone in the hiearchy
  7872. */
  7873. constructor(
  7874. /**
  7875. * defines the bone name
  7876. */
  7877. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7878. /**
  7879. * Gets the parent skeleton
  7880. * @returns a skeleton
  7881. */
  7882. getSkeleton(): Skeleton;
  7883. /**
  7884. * Gets parent bone
  7885. * @returns a bone or null if the bone is the root of the bone hierarchy
  7886. */
  7887. getParent(): Nullable<Bone>;
  7888. /**
  7889. * Sets the parent bone
  7890. * @param parent defines the parent (can be null if the bone is the root)
  7891. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7892. */
  7893. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7894. /**
  7895. * Gets the local matrix
  7896. * @returns a matrix
  7897. */
  7898. getLocalMatrix(): Matrix;
  7899. /**
  7900. * Gets the base matrix (initial matrix which remains unchanged)
  7901. * @returns a matrix
  7902. */
  7903. getBaseMatrix(): Matrix;
  7904. /**
  7905. * Gets the rest pose matrix
  7906. * @returns a matrix
  7907. */
  7908. getRestPose(): Matrix;
  7909. /**
  7910. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7911. */
  7912. getWorldMatrix(): Matrix;
  7913. /**
  7914. * Sets the local matrix to rest pose matrix
  7915. */
  7916. returnToRest(): void;
  7917. /**
  7918. * Gets the inverse of the absolute transform matrix.
  7919. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7920. * @returns a matrix
  7921. */
  7922. getInvertedAbsoluteTransform(): Matrix;
  7923. /**
  7924. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7925. * @returns a matrix
  7926. */
  7927. getAbsoluteTransform(): Matrix;
  7928. /**
  7929. * Links with the given transform node.
  7930. * The local matrix of this bone is copied from the transform node every frame.
  7931. * @param transformNode defines the transform node to link to
  7932. */
  7933. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  7934. /** Gets or sets current position (in local space) */
  7935. position: Vector3;
  7936. /** Gets or sets current rotation (in local space) */
  7937. rotation: Vector3;
  7938. /** Gets or sets current rotation quaternion (in local space) */
  7939. rotationQuaternion: Quaternion;
  7940. /** Gets or sets current scaling (in local space) */
  7941. scaling: Vector3;
  7942. /**
  7943. * Gets the animation properties override
  7944. */
  7945. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  7946. private _decompose;
  7947. private _compose;
  7948. /**
  7949. * Update the base and local matrices
  7950. * @param matrix defines the new base or local matrix
  7951. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7952. * @param updateLocalMatrix defines if the local matrix should be updated
  7953. */
  7954. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  7955. /** @hidden */
  7956. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  7957. /**
  7958. * Flag the bone as dirty (Forcing it to update everything)
  7959. */
  7960. markAsDirty(): void;
  7961. private _markAsDirtyAndCompose;
  7962. private _markAsDirtyAndDecompose;
  7963. /**
  7964. * Translate the bone in local or world space
  7965. * @param vec The amount to translate the bone
  7966. * @param space The space that the translation is in
  7967. * @param mesh The mesh that this bone is attached to. This is only used in world space
  7968. */
  7969. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  7970. /**
  7971. * Set the postion of the bone in local or world space
  7972. * @param position The position to set the bone
  7973. * @param space The space that the position is in
  7974. * @param mesh The mesh that this bone is attached to. This is only used in world space
  7975. */
  7976. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  7977. /**
  7978. * Set the absolute position of the bone (world space)
  7979. * @param position The position to set the bone
  7980. * @param mesh The mesh that this bone is attached to
  7981. */
  7982. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  7983. /**
  7984. * Scale the bone on the x, y and z axes (in local space)
  7985. * @param x The amount to scale the bone on the x axis
  7986. * @param y The amount to scale the bone on the y axis
  7987. * @param z The amount to scale the bone on the z axis
  7988. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  7989. */
  7990. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  7991. /**
  7992. * Set the bone scaling in local space
  7993. * @param scale defines the scaling vector
  7994. */
  7995. setScale(scale: Vector3): void;
  7996. /**
  7997. * Gets the current scaling in local space
  7998. * @returns the current scaling vector
  7999. */
  8000. getScale(): Vector3;
  8001. /**
  8002. * Gets the current scaling in local space and stores it in a target vector
  8003. * @param result defines the target vector
  8004. */
  8005. getScaleToRef(result: Vector3): void;
  8006. /**
  8007. * Set the yaw, pitch, and roll of the bone in local or world space
  8008. * @param yaw The rotation of the bone on the y axis
  8009. * @param pitch The rotation of the bone on the x axis
  8010. * @param roll The rotation of the bone on the z axis
  8011. * @param space The space that the axes of rotation are in
  8012. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8013. */
  8014. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8015. /**
  8016. * Add a rotation to the bone on an axis in local or world space
  8017. * @param axis The axis to rotate the bone on
  8018. * @param amount The amount to rotate the bone
  8019. * @param space The space that the axis is in
  8020. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8021. */
  8022. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8023. /**
  8024. * Set the rotation of the bone to a particular axis angle in local or world space
  8025. * @param axis The axis to rotate the bone on
  8026. * @param angle The angle that the bone should be rotated to
  8027. * @param space The space that the axis is in
  8028. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8029. */
  8030. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8031. /**
  8032. * Set the euler rotation of the bone in local of world space
  8033. * @param rotation The euler rotation that the bone should be set to
  8034. * @param space The space that the rotation is in
  8035. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8036. */
  8037. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8038. /**
  8039. * Set the quaternion rotation of the bone in local of world space
  8040. * @param quat The quaternion rotation that the bone should be set to
  8041. * @param space The space that the rotation is in
  8042. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8043. */
  8044. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8045. /**
  8046. * Set the rotation matrix of the bone in local of world space
  8047. * @param rotMat The rotation matrix that the bone should be set to
  8048. * @param space The space that the rotation is in
  8049. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8050. */
  8051. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8052. private _rotateWithMatrix;
  8053. private _getNegativeRotationToRef;
  8054. /**
  8055. * Get the position of the bone in local or world space
  8056. * @param space The space that the returned position is in
  8057. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8058. * @returns The position of the bone
  8059. */
  8060. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8061. /**
  8062. * Copy the position of the bone to a vector3 in local or world space
  8063. * @param space The space that the returned position is in
  8064. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8065. * @param result The vector3 to copy the position to
  8066. */
  8067. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8068. /**
  8069. * Get the absolute position of the bone (world space)
  8070. * @param mesh The mesh that this bone is attached to
  8071. * @returns The absolute position of the bone
  8072. */
  8073. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8074. /**
  8075. * Copy the absolute position of the bone (world space) to the result param
  8076. * @param mesh The mesh that this bone is attached to
  8077. * @param result The vector3 to copy the absolute position to
  8078. */
  8079. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8080. /**
  8081. * Compute the absolute transforms of this bone and its children
  8082. */
  8083. computeAbsoluteTransforms(): void;
  8084. /**
  8085. * Get the world direction from an axis that is in the local space of the bone
  8086. * @param localAxis The local direction that is used to compute the world direction
  8087. * @param mesh The mesh that this bone is attached to
  8088. * @returns The world direction
  8089. */
  8090. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8091. /**
  8092. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8093. * @param localAxis The local direction that is used to compute the world direction
  8094. * @param mesh The mesh that this bone is attached to
  8095. * @param result The vector3 that the world direction will be copied to
  8096. */
  8097. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8098. /**
  8099. * Get the euler rotation of the bone in local or world space
  8100. * @param space The space that the rotation should be in
  8101. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8102. * @returns The euler rotation
  8103. */
  8104. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8105. /**
  8106. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8107. * @param space The space that the rotation should be in
  8108. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8109. * @param result The vector3 that the rotation should be copied to
  8110. */
  8111. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8112. /**
  8113. * Get the quaternion rotation of the bone in either local or world space
  8114. * @param space The space that the rotation should be in
  8115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8116. * @returns The quaternion rotation
  8117. */
  8118. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8119. /**
  8120. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8121. * @param space The space that the rotation should be in
  8122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8123. * @param result The quaternion that the rotation should be copied to
  8124. */
  8125. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8126. /**
  8127. * Get the rotation matrix of the bone in local or world space
  8128. * @param space The space that the rotation should be in
  8129. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8130. * @returns The rotation matrix
  8131. */
  8132. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8133. /**
  8134. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8135. * @param space The space that the rotation should be in
  8136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8137. * @param result The quaternion that the rotation should be copied to
  8138. */
  8139. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8140. /**
  8141. * Get the world position of a point that is in the local space of the bone
  8142. * @param position The local position
  8143. * @param mesh The mesh that this bone is attached to
  8144. * @returns The world position
  8145. */
  8146. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8147. /**
  8148. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8149. * @param position The local position
  8150. * @param mesh The mesh that this bone is attached to
  8151. * @param result The vector3 that the world position should be copied to
  8152. */
  8153. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8154. /**
  8155. * Get the local position of a point that is in world space
  8156. * @param position The world position
  8157. * @param mesh The mesh that this bone is attached to
  8158. * @returns The local position
  8159. */
  8160. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8161. /**
  8162. * Get the local position of a point that is in world space and copy it to the result param
  8163. * @param position The world position
  8164. * @param mesh The mesh that this bone is attached to
  8165. * @param result The vector3 that the local position should be copied to
  8166. */
  8167. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8168. }
  8169. }
  8170. declare module BABYLON {
  8171. /**
  8172. * Class for creating a cube texture
  8173. */
  8174. export class CubeTexture extends BaseTexture {
  8175. private _delayedOnLoad;
  8176. /**
  8177. * The url of the texture
  8178. */
  8179. url: string;
  8180. /**
  8181. * Gets or sets the center of the bounding box associated with the cube texture.
  8182. * It must define where the camera used to render the texture was set
  8183. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8184. */
  8185. boundingBoxPosition: Vector3;
  8186. private _boundingBoxSize;
  8187. /**
  8188. * Gets or sets the size of the bounding box associated with the cube texture
  8189. * When defined, the cubemap will switch to local mode
  8190. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8191. * @example https://www.babylonjs-playground.com/#RNASML
  8192. */
  8193. /**
  8194. * Returns the bounding box size
  8195. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8196. */
  8197. boundingBoxSize: Vector3;
  8198. protected _rotationY: number;
  8199. /**
  8200. * Sets texture matrix rotation angle around Y axis in radians.
  8201. */
  8202. /**
  8203. * Gets texture matrix rotation angle around Y axis radians.
  8204. */
  8205. rotationY: number;
  8206. /**
  8207. * Are mip maps generated for this texture or not.
  8208. */
  8209. readonly noMipmap: boolean;
  8210. private _noMipmap;
  8211. private _files;
  8212. private _extensions;
  8213. private _textureMatrix;
  8214. private _format;
  8215. private _createPolynomials;
  8216. /** @hidden */
  8217. _prefiltered: boolean;
  8218. /**
  8219. * Creates a cube texture from an array of image urls
  8220. * @param files defines an array of image urls
  8221. * @param scene defines the hosting scene
  8222. * @param noMipmap specifies if mip maps are not used
  8223. * @returns a cube texture
  8224. */
  8225. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8226. /**
  8227. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8228. * @param url defines the url of the prefiltered texture
  8229. * @param scene defines the scene the texture is attached to
  8230. * @param forcedExtension defines the extension of the file if different from the url
  8231. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8232. * @return the prefiltered texture
  8233. */
  8234. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8235. /**
  8236. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8237. * as prefiltered data.
  8238. * @param rootUrl defines the url of the texture or the root name of the six images
  8239. * @param scene defines the scene the texture is attached to
  8240. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8241. * @param noMipmap defines if mipmaps should be created or not
  8242. * @param files defines the six files to load for the different faces
  8243. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8244. * @param onError defines a callback triggered in case of error during load
  8245. * @param format defines the internal format to use for the texture once loaded
  8246. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8247. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8248. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8249. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8250. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8251. * @return the cube texture
  8252. */
  8253. 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);
  8254. /**
  8255. * Get the current class name of the texture useful for serialization or dynamic coding.
  8256. * @returns "CubeTexture"
  8257. */
  8258. getClassName(): string;
  8259. /**
  8260. * Update the url (and optional buffer) of this texture if url was null during construction.
  8261. * @param url the url of the texture
  8262. * @param forcedExtension defines the extension to use
  8263. * @param onLoad callback called when the texture is loaded (defaults to null)
  8264. */
  8265. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8266. /**
  8267. * Delays loading of the cube texture
  8268. * @param forcedExtension defines the extension to use
  8269. */
  8270. delayLoad(forcedExtension?: string): void;
  8271. /**
  8272. * Returns the reflection texture matrix
  8273. * @returns the reflection texture matrix
  8274. */
  8275. getReflectionTextureMatrix(): Matrix;
  8276. /**
  8277. * Sets the reflection texture matrix
  8278. * @param value Reflection texture matrix
  8279. */
  8280. setReflectionTextureMatrix(value: Matrix): void;
  8281. /**
  8282. * Parses text to create a cube texture
  8283. * @param parsedTexture define the serialized text to read from
  8284. * @param scene defines the hosting scene
  8285. * @param rootUrl defines the root url of the cube texture
  8286. * @returns a cube texture
  8287. */
  8288. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8289. /**
  8290. * Makes a clone, or deep copy, of the cube texture
  8291. * @returns a new cube texture
  8292. */
  8293. clone(): CubeTexture;
  8294. }
  8295. }
  8296. declare module BABYLON {
  8297. /** @hidden */
  8298. export var postprocessVertexShader: {
  8299. name: string;
  8300. shader: string;
  8301. };
  8302. }
  8303. declare module BABYLON {
  8304. /**
  8305. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8306. * This is the base of the follow, arc rotate cameras and Free camera
  8307. * @see http://doc.babylonjs.com/features/cameras
  8308. */
  8309. export class TargetCamera extends Camera {
  8310. private static _RigCamTransformMatrix;
  8311. private static _TargetTransformMatrix;
  8312. private static _TargetFocalPoint;
  8313. /**
  8314. * Define the current direction the camera is moving to
  8315. */
  8316. cameraDirection: Vector3;
  8317. /**
  8318. * Define the current rotation the camera is rotating to
  8319. */
  8320. cameraRotation: Vector2;
  8321. /**
  8322. * When set, the up vector of the camera will be updated by the rotation of the camera
  8323. */
  8324. updateUpVectorFromRotation: boolean;
  8325. private _tmpQuaternion;
  8326. /**
  8327. * Define the current rotation of the camera
  8328. */
  8329. rotation: Vector3;
  8330. /**
  8331. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8332. */
  8333. rotationQuaternion: Quaternion;
  8334. /**
  8335. * Define the current speed of the camera
  8336. */
  8337. speed: number;
  8338. /**
  8339. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8340. * around all axis.
  8341. */
  8342. noRotationConstraint: boolean;
  8343. /**
  8344. * Define the current target of the camera as an object or a position.
  8345. */
  8346. lockedTarget: any;
  8347. /** @hidden */
  8348. _currentTarget: Vector3;
  8349. /** @hidden */
  8350. _initialFocalDistance: number;
  8351. /** @hidden */
  8352. _viewMatrix: Matrix;
  8353. /** @hidden */
  8354. _camMatrix: Matrix;
  8355. /** @hidden */
  8356. _cameraTransformMatrix: Matrix;
  8357. /** @hidden */
  8358. _cameraRotationMatrix: Matrix;
  8359. /** @hidden */
  8360. _referencePoint: Vector3;
  8361. /** @hidden */
  8362. _transformedReferencePoint: Vector3;
  8363. protected _globalCurrentTarget: Vector3;
  8364. protected _globalCurrentUpVector: Vector3;
  8365. /** @hidden */
  8366. _reset: () => void;
  8367. private _defaultUp;
  8368. /**
  8369. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8370. * This is the base of the follow, arc rotate cameras and Free camera
  8371. * @see http://doc.babylonjs.com/features/cameras
  8372. * @param name Defines the name of the camera in the scene
  8373. * @param position Defines the start position of the camera in the scene
  8374. * @param scene Defines the scene the camera belongs to
  8375. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8376. */
  8377. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8378. /**
  8379. * Gets the position in front of the camera at a given distance.
  8380. * @param distance The distance from the camera we want the position to be
  8381. * @returns the position
  8382. */
  8383. getFrontPosition(distance: number): Vector3;
  8384. /** @hidden */
  8385. _getLockedTargetPosition(): Nullable<Vector3>;
  8386. private _storedPosition;
  8387. private _storedRotation;
  8388. private _storedRotationQuaternion;
  8389. /**
  8390. * Store current camera state of the camera (fov, position, rotation, etc..)
  8391. * @returns the camera
  8392. */
  8393. storeState(): Camera;
  8394. /**
  8395. * Restored camera state. You must call storeState() first
  8396. * @returns whether it was successful or not
  8397. * @hidden
  8398. */
  8399. _restoreStateValues(): boolean;
  8400. /** @hidden */
  8401. _initCache(): void;
  8402. /** @hidden */
  8403. _updateCache(ignoreParentClass?: boolean): void;
  8404. /** @hidden */
  8405. _isSynchronizedViewMatrix(): boolean;
  8406. /** @hidden */
  8407. _computeLocalCameraSpeed(): number;
  8408. /** @hidden */
  8409. setTarget(target: Vector3): void;
  8410. /**
  8411. * Return the current target position of the camera. This value is expressed in local space.
  8412. * @returns the target position
  8413. */
  8414. getTarget(): Vector3;
  8415. /** @hidden */
  8416. _decideIfNeedsToMove(): boolean;
  8417. /** @hidden */
  8418. _updatePosition(): void;
  8419. /** @hidden */
  8420. _checkInputs(): void;
  8421. protected _updateCameraRotationMatrix(): void;
  8422. /**
  8423. * 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)
  8424. * @returns the current camera
  8425. */
  8426. private _rotateUpVectorWithCameraRotationMatrix;
  8427. private _cachedRotationZ;
  8428. private _cachedQuaternionRotationZ;
  8429. /** @hidden */
  8430. _getViewMatrix(): Matrix;
  8431. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8432. /**
  8433. * @hidden
  8434. */
  8435. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8436. /**
  8437. * @hidden
  8438. */
  8439. _updateRigCameras(): void;
  8440. private _getRigCamPositionAndTarget;
  8441. /**
  8442. * Gets the current object class name.
  8443. * @return the class name
  8444. */
  8445. getClassName(): string;
  8446. }
  8447. }
  8448. declare module BABYLON {
  8449. /**
  8450. * @ignore
  8451. * This is a list of all the different input types that are available in the application.
  8452. * Fo instance: ArcRotateCameraGamepadInput...
  8453. */
  8454. export var CameraInputTypes: {};
  8455. /**
  8456. * This is the contract to implement in order to create a new input class.
  8457. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8458. */
  8459. export interface ICameraInput<TCamera extends Camera> {
  8460. /**
  8461. * Defines the camera the input is attached to.
  8462. */
  8463. camera: Nullable<TCamera>;
  8464. /**
  8465. * Gets the class name of the current intput.
  8466. * @returns the class name
  8467. */
  8468. getClassName(): string;
  8469. /**
  8470. * Get the friendly name associated with the input class.
  8471. * @returns the input friendly name
  8472. */
  8473. getSimpleName(): string;
  8474. /**
  8475. * Attach the input controls to a specific dom element to get the input from.
  8476. * @param element Defines the element the controls should be listened from
  8477. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8478. */
  8479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8480. /**
  8481. * Detach the current controls from the specified dom element.
  8482. * @param element Defines the element to stop listening the inputs from
  8483. */
  8484. detachControl(element: Nullable<HTMLElement>): void;
  8485. /**
  8486. * Update the current camera state depending on the inputs that have been used this frame.
  8487. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8488. */
  8489. checkInputs?: () => void;
  8490. }
  8491. /**
  8492. * Represents a map of input types to input instance or input index to input instance.
  8493. */
  8494. export interface CameraInputsMap<TCamera extends Camera> {
  8495. /**
  8496. * Accessor to the input by input type.
  8497. */
  8498. [name: string]: ICameraInput<TCamera>;
  8499. /**
  8500. * Accessor to the input by input index.
  8501. */
  8502. [idx: number]: ICameraInput<TCamera>;
  8503. }
  8504. /**
  8505. * This represents the input manager used within a camera.
  8506. * It helps dealing with all the different kind of input attached to a camera.
  8507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8508. */
  8509. export class CameraInputsManager<TCamera extends Camera> {
  8510. /**
  8511. * Defines the list of inputs attahed to the camera.
  8512. */
  8513. attached: CameraInputsMap<TCamera>;
  8514. /**
  8515. * Defines the dom element the camera is collecting inputs from.
  8516. * This is null if the controls have not been attached.
  8517. */
  8518. attachedElement: Nullable<HTMLElement>;
  8519. /**
  8520. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8521. */
  8522. noPreventDefault: boolean;
  8523. /**
  8524. * Defined the camera the input manager belongs to.
  8525. */
  8526. camera: TCamera;
  8527. /**
  8528. * Update the current camera state depending on the inputs that have been used this frame.
  8529. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8530. */
  8531. checkInputs: () => void;
  8532. /**
  8533. * Instantiate a new Camera Input Manager.
  8534. * @param camera Defines the camera the input manager blongs to
  8535. */
  8536. constructor(camera: TCamera);
  8537. /**
  8538. * Add an input method to a camera
  8539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8540. * @param input camera input method
  8541. */
  8542. add(input: ICameraInput<TCamera>): void;
  8543. /**
  8544. * Remove a specific input method from a camera
  8545. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8546. * @param inputToRemove camera input method
  8547. */
  8548. remove(inputToRemove: ICameraInput<TCamera>): void;
  8549. /**
  8550. * Remove a specific input type from a camera
  8551. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8552. * @param inputType the type of the input to remove
  8553. */
  8554. removeByType(inputType: string): void;
  8555. private _addCheckInputs;
  8556. /**
  8557. * Attach the input controls to the currently attached dom element to listen the events from.
  8558. * @param input Defines the input to attach
  8559. */
  8560. attachInput(input: ICameraInput<TCamera>): void;
  8561. /**
  8562. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8563. * @param element Defines the dom element to collect the events from
  8564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8565. */
  8566. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8567. /**
  8568. * Detach the current manager inputs controls from a specific dom element.
  8569. * @param element Defines the dom element to collect the events from
  8570. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8571. */
  8572. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8573. /**
  8574. * Rebuild the dynamic inputCheck function from the current list of
  8575. * defined inputs in the manager.
  8576. */
  8577. rebuildInputCheck(): void;
  8578. /**
  8579. * Remove all attached input methods from a camera
  8580. */
  8581. clear(): void;
  8582. /**
  8583. * Serialize the current input manager attached to a camera.
  8584. * This ensures than once parsed,
  8585. * the input associated to the camera will be identical to the current ones
  8586. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8587. */
  8588. serialize(serializedCamera: any): void;
  8589. /**
  8590. * Parses an input manager serialized JSON to restore the previous list of inputs
  8591. * and states associated to a camera.
  8592. * @param parsedCamera Defines the JSON to parse
  8593. */
  8594. parse(parsedCamera: any): void;
  8595. }
  8596. }
  8597. declare module BABYLON {
  8598. /**
  8599. * Gather the list of keyboard event types as constants.
  8600. */
  8601. export class KeyboardEventTypes {
  8602. /**
  8603. * The keydown event is fired when a key becomes active (pressed).
  8604. */
  8605. static readonly KEYDOWN: number;
  8606. /**
  8607. * The keyup event is fired when a key has been released.
  8608. */
  8609. static readonly KEYUP: number;
  8610. }
  8611. /**
  8612. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8613. */
  8614. export class KeyboardInfo {
  8615. /**
  8616. * Defines the type of event (KeyboardEventTypes)
  8617. */
  8618. type: number;
  8619. /**
  8620. * Defines the related dom event
  8621. */
  8622. event: KeyboardEvent;
  8623. /**
  8624. * Instantiates a new keyboard info.
  8625. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8626. * @param type Defines the type of event (KeyboardEventTypes)
  8627. * @param event Defines the related dom event
  8628. */
  8629. constructor(
  8630. /**
  8631. * Defines the type of event (KeyboardEventTypes)
  8632. */
  8633. type: number,
  8634. /**
  8635. * Defines the related dom event
  8636. */
  8637. event: KeyboardEvent);
  8638. }
  8639. /**
  8640. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8641. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8642. */
  8643. export class KeyboardInfoPre extends KeyboardInfo {
  8644. /**
  8645. * Defines the type of event (KeyboardEventTypes)
  8646. */
  8647. type: number;
  8648. /**
  8649. * Defines the related dom event
  8650. */
  8651. event: KeyboardEvent;
  8652. /**
  8653. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8654. */
  8655. skipOnPointerObservable: boolean;
  8656. /**
  8657. * Instantiates a new keyboard pre info.
  8658. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8659. * @param type Defines the type of event (KeyboardEventTypes)
  8660. * @param event Defines the related dom event
  8661. */
  8662. constructor(
  8663. /**
  8664. * Defines the type of event (KeyboardEventTypes)
  8665. */
  8666. type: number,
  8667. /**
  8668. * Defines the related dom event
  8669. */
  8670. event: KeyboardEvent);
  8671. }
  8672. }
  8673. declare module BABYLON {
  8674. /**
  8675. * Manage the keyboard inputs to control the movement of a free camera.
  8676. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8677. */
  8678. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8679. /**
  8680. * Defines the camera the input is attached to.
  8681. */
  8682. camera: FreeCamera;
  8683. /**
  8684. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8685. */
  8686. keysUp: number[];
  8687. /**
  8688. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8689. */
  8690. keysDown: number[];
  8691. /**
  8692. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8693. */
  8694. keysLeft: number[];
  8695. /**
  8696. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8697. */
  8698. keysRight: number[];
  8699. private _keys;
  8700. private _onCanvasBlurObserver;
  8701. private _onKeyboardObserver;
  8702. private _engine;
  8703. private _scene;
  8704. /**
  8705. * Attach the input controls to a specific dom element to get the input from.
  8706. * @param element Defines the element the controls should be listened from
  8707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8708. */
  8709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8710. /**
  8711. * Detach the current controls from the specified dom element.
  8712. * @param element Defines the element to stop listening the inputs from
  8713. */
  8714. detachControl(element: Nullable<HTMLElement>): void;
  8715. /**
  8716. * Update the current camera state depending on the inputs that have been used this frame.
  8717. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8718. */
  8719. checkInputs(): void;
  8720. /**
  8721. * Gets the class name of the current intput.
  8722. * @returns the class name
  8723. */
  8724. getClassName(): string;
  8725. /** @hidden */
  8726. _onLostFocus(): void;
  8727. /**
  8728. * Get the friendly name associated with the input class.
  8729. * @returns the input friendly name
  8730. */
  8731. getSimpleName(): string;
  8732. }
  8733. }
  8734. declare module BABYLON {
  8735. /**
  8736. * Interface describing all the common properties and methods a shadow light needs to implement.
  8737. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8738. * as well as binding the different shadow properties to the effects.
  8739. */
  8740. export interface IShadowLight extends Light {
  8741. /**
  8742. * The light id in the scene (used in scene.findLighById for instance)
  8743. */
  8744. id: string;
  8745. /**
  8746. * The position the shdow will be casted from.
  8747. */
  8748. position: Vector3;
  8749. /**
  8750. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8751. */
  8752. direction: Vector3;
  8753. /**
  8754. * The transformed position. Position of the light in world space taking parenting in account.
  8755. */
  8756. transformedPosition: Vector3;
  8757. /**
  8758. * The transformed direction. Direction of the light in world space taking parenting in account.
  8759. */
  8760. transformedDirection: Vector3;
  8761. /**
  8762. * The friendly name of the light in the scene.
  8763. */
  8764. name: string;
  8765. /**
  8766. * Defines the shadow projection clipping minimum z value.
  8767. */
  8768. shadowMinZ: number;
  8769. /**
  8770. * Defines the shadow projection clipping maximum z value.
  8771. */
  8772. shadowMaxZ: number;
  8773. /**
  8774. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8775. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8776. */
  8777. computeTransformedInformation(): boolean;
  8778. /**
  8779. * Gets the scene the light belongs to.
  8780. * @returns The scene
  8781. */
  8782. getScene(): Scene;
  8783. /**
  8784. * Callback defining a custom Projection Matrix Builder.
  8785. * This can be used to override the default projection matrix computation.
  8786. */
  8787. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8788. /**
  8789. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8790. * @param matrix The materix to updated with the projection information
  8791. * @param viewMatrix The transform matrix of the light
  8792. * @param renderList The list of mesh to render in the map
  8793. * @returns The current light
  8794. */
  8795. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8796. /**
  8797. * Gets the current depth scale used in ESM.
  8798. * @returns The scale
  8799. */
  8800. getDepthScale(): number;
  8801. /**
  8802. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8803. * @returns true if a cube texture needs to be use
  8804. */
  8805. needCube(): boolean;
  8806. /**
  8807. * Detects if the projection matrix requires to be recomputed this frame.
  8808. * @returns true if it requires to be recomputed otherwise, false.
  8809. */
  8810. needProjectionMatrixCompute(): boolean;
  8811. /**
  8812. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8813. */
  8814. forceProjectionMatrixCompute(): void;
  8815. /**
  8816. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8817. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8818. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8819. */
  8820. getShadowDirection(faceIndex?: number): Vector3;
  8821. /**
  8822. * Gets the minZ used for shadow according to both the scene and the light.
  8823. * @param activeCamera The camera we are returning the min for
  8824. * @returns the depth min z
  8825. */
  8826. getDepthMinZ(activeCamera: Camera): number;
  8827. /**
  8828. * Gets the maxZ used for shadow according to both the scene and the light.
  8829. * @param activeCamera The camera we are returning the max for
  8830. * @returns the depth max z
  8831. */
  8832. getDepthMaxZ(activeCamera: Camera): number;
  8833. }
  8834. /**
  8835. * Base implementation IShadowLight
  8836. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8837. */
  8838. export abstract class ShadowLight extends Light implements IShadowLight {
  8839. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8840. protected _position: Vector3;
  8841. protected _setPosition(value: Vector3): void;
  8842. /**
  8843. * Sets the position the shadow will be casted from. Also use as the light position for both
  8844. * point and spot lights.
  8845. */
  8846. /**
  8847. * Sets the position the shadow will be casted from. Also use as the light position for both
  8848. * point and spot lights.
  8849. */
  8850. position: Vector3;
  8851. protected _direction: Vector3;
  8852. protected _setDirection(value: Vector3): void;
  8853. /**
  8854. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8855. * Also use as the light direction on spot and directional lights.
  8856. */
  8857. /**
  8858. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8859. * Also use as the light direction on spot and directional lights.
  8860. */
  8861. direction: Vector3;
  8862. private _shadowMinZ;
  8863. /**
  8864. * Gets the shadow projection clipping minimum z value.
  8865. */
  8866. /**
  8867. * Sets the shadow projection clipping minimum z value.
  8868. */
  8869. shadowMinZ: number;
  8870. private _shadowMaxZ;
  8871. /**
  8872. * Sets the shadow projection clipping maximum z value.
  8873. */
  8874. /**
  8875. * Gets the shadow projection clipping maximum z value.
  8876. */
  8877. shadowMaxZ: number;
  8878. /**
  8879. * Callback defining a custom Projection Matrix Builder.
  8880. * This can be used to override the default projection matrix computation.
  8881. */
  8882. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8883. /**
  8884. * The transformed position. Position of the light in world space taking parenting in account.
  8885. */
  8886. transformedPosition: Vector3;
  8887. /**
  8888. * The transformed direction. Direction of the light in world space taking parenting in account.
  8889. */
  8890. transformedDirection: Vector3;
  8891. private _needProjectionMatrixCompute;
  8892. /**
  8893. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8894. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8895. */
  8896. computeTransformedInformation(): boolean;
  8897. /**
  8898. * Return the depth scale used for the shadow map.
  8899. * @returns the depth scale.
  8900. */
  8901. getDepthScale(): number;
  8902. /**
  8903. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8904. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8905. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8906. */
  8907. getShadowDirection(faceIndex?: number): Vector3;
  8908. /**
  8909. * Returns the ShadowLight absolute position in the World.
  8910. * @returns the position vector in world space
  8911. */
  8912. getAbsolutePosition(): Vector3;
  8913. /**
  8914. * Sets the ShadowLight direction toward the passed target.
  8915. * @param target The point to target in local space
  8916. * @returns the updated ShadowLight direction
  8917. */
  8918. setDirectionToTarget(target: Vector3): Vector3;
  8919. /**
  8920. * Returns the light rotation in euler definition.
  8921. * @returns the x y z rotation in local space.
  8922. */
  8923. getRotation(): Vector3;
  8924. /**
  8925. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8926. * @returns true if a cube texture needs to be use
  8927. */
  8928. needCube(): boolean;
  8929. /**
  8930. * Detects if the projection matrix requires to be recomputed this frame.
  8931. * @returns true if it requires to be recomputed otherwise, false.
  8932. */
  8933. needProjectionMatrixCompute(): boolean;
  8934. /**
  8935. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8936. */
  8937. forceProjectionMatrixCompute(): void;
  8938. /** @hidden */
  8939. _initCache(): void;
  8940. /** @hidden */
  8941. _isSynchronized(): boolean;
  8942. /**
  8943. * Computes the world matrix of the node
  8944. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8945. * @returns the world matrix
  8946. */
  8947. computeWorldMatrix(force?: boolean): Matrix;
  8948. /**
  8949. * Gets the minZ used for shadow according to both the scene and the light.
  8950. * @param activeCamera The camera we are returning the min for
  8951. * @returns the depth min z
  8952. */
  8953. getDepthMinZ(activeCamera: Camera): number;
  8954. /**
  8955. * Gets the maxZ used for shadow according to both the scene and the light.
  8956. * @param activeCamera The camera we are returning the max for
  8957. * @returns the depth max z
  8958. */
  8959. getDepthMaxZ(activeCamera: Camera): number;
  8960. /**
  8961. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8962. * @param matrix The materix to updated with the projection information
  8963. * @param viewMatrix The transform matrix of the light
  8964. * @param renderList The list of mesh to render in the map
  8965. * @returns The current light
  8966. */
  8967. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8968. }
  8969. }
  8970. declare module BABYLON {
  8971. /**
  8972. * "Static Class" containing the most commonly used helper while dealing with material for
  8973. * rendering purpose.
  8974. *
  8975. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8976. *
  8977. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8978. */
  8979. export class MaterialHelper {
  8980. /**
  8981. * Bind the current view position to an effect.
  8982. * @param effect The effect to be bound
  8983. * @param scene The scene the eyes position is used from
  8984. */
  8985. static BindEyePosition(effect: Effect, scene: Scene): void;
  8986. /**
  8987. * Helps preparing the defines values about the UVs in used in the effect.
  8988. * UVs are shared as much as we can accross channels in the shaders.
  8989. * @param texture The texture we are preparing the UVs for
  8990. * @param defines The defines to update
  8991. * @param key The channel key "diffuse", "specular"... used in the shader
  8992. */
  8993. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8994. /**
  8995. * Binds a texture matrix value to its corrsponding uniform
  8996. * @param texture The texture to bind the matrix for
  8997. * @param uniformBuffer The uniform buffer receivin the data
  8998. * @param key The channel key "diffuse", "specular"... used in the shader
  8999. */
  9000. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9001. /**
  9002. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9003. * @param mesh defines the current mesh
  9004. * @param scene defines the current scene
  9005. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9006. * @param pointsCloud defines if point cloud rendering has to be turned on
  9007. * @param fogEnabled defines if fog has to be turned on
  9008. * @param alphaTest defines if alpha testing has to be turned on
  9009. * @param defines defines the current list of defines
  9010. */
  9011. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9012. /**
  9013. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9014. * @param scene defines the current scene
  9015. * @param engine defines the current engine
  9016. * @param defines specifies the list of active defines
  9017. * @param useInstances defines if instances have to be turned on
  9018. * @param useClipPlane defines if clip plane have to be turned on
  9019. */
  9020. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9021. /**
  9022. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9023. * @param mesh The mesh containing the geometry data we will draw
  9024. * @param defines The defines to update
  9025. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9026. * @param useBones Precise whether bones should be used or not (override mesh info)
  9027. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9028. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9029. * @returns false if defines are considered not dirty and have not been checked
  9030. */
  9031. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9032. /**
  9033. * Prepares the defines related to the light information passed in parameter
  9034. * @param scene The scene we are intending to draw
  9035. * @param mesh The mesh the effect is compiling for
  9036. * @param defines The defines to update
  9037. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9038. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9039. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9040. * @returns true if normals will be required for the rest of the effect
  9041. */
  9042. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9043. /**
  9044. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9045. * that won t be acctive due to defines being turned off.
  9046. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9047. * @param samplersList The samplers list
  9048. * @param defines The defines helping in the list generation
  9049. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9050. */
  9051. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9052. /**
  9053. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9054. * @param defines The defines to update while falling back
  9055. * @param fallbacks The authorized effect fallbacks
  9056. * @param maxSimultaneousLights The maximum number of lights allowed
  9057. * @param rank the current rank of the Effect
  9058. * @returns The newly affected rank
  9059. */
  9060. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9061. /**
  9062. * Prepares the list of attributes required for morph targets according to the effect defines.
  9063. * @param attribs The current list of supported attribs
  9064. * @param mesh The mesh to prepare the morph targets attributes for
  9065. * @param defines The current Defines of the effect
  9066. */
  9067. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9068. /**
  9069. * Prepares the list of attributes required for bones according to the effect defines.
  9070. * @param attribs The current list of supported attribs
  9071. * @param mesh The mesh to prepare the bones attributes for
  9072. * @param defines The current Defines of the effect
  9073. * @param fallbacks The current efffect fallback strategy
  9074. */
  9075. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9076. /**
  9077. * Prepares the list of attributes required for instances according to the effect defines.
  9078. * @param attribs The current list of supported attribs
  9079. * @param defines The current Defines of the effect
  9080. */
  9081. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9082. /**
  9083. * Binds the light shadow information to the effect for the given mesh.
  9084. * @param light The light containing the generator
  9085. * @param scene The scene the lights belongs to
  9086. * @param mesh The mesh we are binding the information to render
  9087. * @param lightIndex The light index in the effect used to render the mesh
  9088. * @param effect The effect we are binding the data to
  9089. */
  9090. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9091. /**
  9092. * Binds the light information to the effect.
  9093. * @param light The light containing the generator
  9094. * @param effect The effect we are binding the data to
  9095. * @param lightIndex The light index in the effect used to render
  9096. */
  9097. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9098. /**
  9099. * Binds the lights information from the scene to the effect for the given mesh.
  9100. * @param scene The scene the lights belongs to
  9101. * @param mesh The mesh we are binding the information to render
  9102. * @param effect The effect we are binding the data to
  9103. * @param defines The generated defines for the effect
  9104. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9105. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9106. */
  9107. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9108. private static _tempFogColor;
  9109. /**
  9110. * Binds the fog information from the scene to the effect for the given mesh.
  9111. * @param scene The scene the lights belongs to
  9112. * @param mesh The mesh we are binding the information to render
  9113. * @param effect The effect we are binding the data to
  9114. * @param linearSpace Defines if the fog effect is applied in linear space
  9115. */
  9116. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9117. /**
  9118. * Binds the bones information from the mesh to the effect.
  9119. * @param mesh The mesh we are binding the information to render
  9120. * @param effect The effect we are binding the data to
  9121. */
  9122. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9123. /**
  9124. * Binds the morph targets information from the mesh to the effect.
  9125. * @param abstractMesh The mesh we are binding the information to render
  9126. * @param effect The effect we are binding the data to
  9127. */
  9128. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9129. /**
  9130. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9131. * @param defines The generated defines used in the effect
  9132. * @param effect The effect we are binding the data to
  9133. * @param scene The scene we are willing to render with logarithmic scale for
  9134. */
  9135. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9136. /**
  9137. * Binds the clip plane information from the scene to the effect.
  9138. * @param scene The scene the clip plane information are extracted from
  9139. * @param effect The effect we are binding the data to
  9140. */
  9141. static BindClipPlane(effect: Effect, scene: Scene): void;
  9142. }
  9143. }
  9144. declare module BABYLON {
  9145. /** @hidden */
  9146. export var kernelBlurVaryingDeclaration: {
  9147. name: string;
  9148. shader: string;
  9149. };
  9150. }
  9151. declare module BABYLON {
  9152. /** @hidden */
  9153. export var kernelBlurFragment: {
  9154. name: string;
  9155. shader: string;
  9156. };
  9157. }
  9158. declare module BABYLON {
  9159. /** @hidden */
  9160. export var kernelBlurFragment2: {
  9161. name: string;
  9162. shader: string;
  9163. };
  9164. }
  9165. declare module BABYLON {
  9166. /** @hidden */
  9167. export var kernelBlurPixelShader: {
  9168. name: string;
  9169. shader: string;
  9170. };
  9171. }
  9172. declare module BABYLON {
  9173. /** @hidden */
  9174. export var kernelBlurVertex: {
  9175. name: string;
  9176. shader: string;
  9177. };
  9178. }
  9179. declare module BABYLON {
  9180. /** @hidden */
  9181. export var kernelBlurVertexShader: {
  9182. name: string;
  9183. shader: string;
  9184. };
  9185. }
  9186. declare module BABYLON {
  9187. /**
  9188. * The Blur Post Process which blurs an image based on a kernel and direction.
  9189. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9190. */
  9191. export class BlurPostProcess extends PostProcess {
  9192. /** The direction in which to blur the image. */
  9193. direction: Vector2;
  9194. private blockCompilation;
  9195. protected _kernel: number;
  9196. protected _idealKernel: number;
  9197. protected _packedFloat: boolean;
  9198. private _staticDefines;
  9199. /**
  9200. * Sets the length in pixels of the blur sample region
  9201. */
  9202. /**
  9203. * Gets the length in pixels of the blur sample region
  9204. */
  9205. kernel: number;
  9206. /**
  9207. * Sets wether or not the blur needs to unpack/repack floats
  9208. */
  9209. /**
  9210. * Gets wether or not the blur is unpacking/repacking floats
  9211. */
  9212. packedFloat: boolean;
  9213. /**
  9214. * Creates a new instance BlurPostProcess
  9215. * @param name The name of the effect.
  9216. * @param direction The direction in which to blur the image.
  9217. * @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.
  9218. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9219. * @param camera The camera to apply the render pass to.
  9220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9221. * @param engine The engine which the post process will be applied. (default: current engine)
  9222. * @param reusable If the post process can be reused on the same frame. (default: false)
  9223. * @param textureType Type of textures used when performing the post process. (default: 0)
  9224. * @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)
  9225. */
  9226. constructor(name: string,
  9227. /** The direction in which to blur the image. */
  9228. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9229. /**
  9230. * Updates the effect with the current post process compile time values and recompiles the shader.
  9231. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9232. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9233. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9234. * @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
  9235. * @param onCompiled Called when the shader has been compiled.
  9236. * @param onError Called if there is an error when compiling a shader.
  9237. */
  9238. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9239. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9240. /**
  9241. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9242. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9243. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9244. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9245. * The gaps between physical kernels are compensated for in the weighting of the samples
  9246. * @param idealKernel Ideal blur kernel.
  9247. * @return Nearest best kernel.
  9248. */
  9249. protected _nearestBestKernel(idealKernel: number): number;
  9250. /**
  9251. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9252. * @param x The point on the Gaussian distribution to sample.
  9253. * @return the value of the Gaussian function at x.
  9254. */
  9255. protected _gaussianWeight(x: number): number;
  9256. /**
  9257. * Generates a string that can be used as a floating point number in GLSL.
  9258. * @param x Value to print.
  9259. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9260. * @return GLSL float string.
  9261. */
  9262. protected _glslFloat(x: number, decimalFigures?: number): string;
  9263. }
  9264. }
  9265. declare module BABYLON {
  9266. /** @hidden */
  9267. export var shadowMapPixelShader: {
  9268. name: string;
  9269. shader: string;
  9270. };
  9271. }
  9272. declare module BABYLON {
  9273. /** @hidden */
  9274. export var bonesDeclaration: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module BABYLON {
  9280. /** @hidden */
  9281. export var morphTargetsVertexGlobalDeclaration: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module BABYLON {
  9287. /** @hidden */
  9288. export var morphTargetsVertexDeclaration: {
  9289. name: string;
  9290. shader: string;
  9291. };
  9292. }
  9293. declare module BABYLON {
  9294. /** @hidden */
  9295. export var instancesDeclaration: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module BABYLON {
  9301. /** @hidden */
  9302. export var helperFunctions: {
  9303. name: string;
  9304. shader: string;
  9305. };
  9306. }
  9307. declare module BABYLON {
  9308. /** @hidden */
  9309. export var morphTargetsVertex: {
  9310. name: string;
  9311. shader: string;
  9312. };
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var instancesVertex: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var bonesVertex: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var shadowMapVertexShader: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var depthBoxBlurPixelShader: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /**
  9344. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9345. */
  9346. export interface ICustomShaderOptions {
  9347. /**
  9348. * Gets or sets the custom shader name to use
  9349. */
  9350. shaderName: string;
  9351. /**
  9352. * The list of attribute names used in the shader
  9353. */
  9354. attributes?: string[];
  9355. /**
  9356. * The list of unifrom names used in the shader
  9357. */
  9358. uniforms?: string[];
  9359. /**
  9360. * The list of sampler names used in the shader
  9361. */
  9362. samplers?: string[];
  9363. /**
  9364. * The list of defines used in the shader
  9365. */
  9366. defines?: string[];
  9367. }
  9368. /**
  9369. * Interface to implement to create a shadow generator compatible with BJS.
  9370. */
  9371. export interface IShadowGenerator {
  9372. /**
  9373. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9374. * @returns The render target texture if present otherwise, null
  9375. */
  9376. getShadowMap(): Nullable<RenderTargetTexture>;
  9377. /**
  9378. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9379. * @returns The render target texture if the shadow map is present otherwise, null
  9380. */
  9381. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9382. /**
  9383. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9384. * @param subMesh The submesh we want to render in the shadow map
  9385. * @param useInstances Defines wether will draw in the map using instances
  9386. * @returns true if ready otherwise, false
  9387. */
  9388. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9389. /**
  9390. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9391. * @param defines Defines of the material we want to update
  9392. * @param lightIndex Index of the light in the enabled light list of the material
  9393. */
  9394. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9395. /**
  9396. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9397. * defined in the generator but impacting the effect).
  9398. * It implies the unifroms available on the materials are the standard BJS ones.
  9399. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9400. * @param effect The effect we are binfing the information for
  9401. */
  9402. bindShadowLight(lightIndex: string, effect: Effect): void;
  9403. /**
  9404. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9405. * (eq to shadow prjection matrix * light transform matrix)
  9406. * @returns The transform matrix used to create the shadow map
  9407. */
  9408. getTransformMatrix(): Matrix;
  9409. /**
  9410. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9411. * Cube and 2D textures for instance.
  9412. */
  9413. recreateShadowMap(): void;
  9414. /**
  9415. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9416. * @param onCompiled Callback triggered at the and of the effects compilation
  9417. * @param options Sets of optional options forcing the compilation with different modes
  9418. */
  9419. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9420. useInstances: boolean;
  9421. }>): void;
  9422. /**
  9423. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9424. * @param options Sets of optional options forcing the compilation with different modes
  9425. * @returns A promise that resolves when the compilation completes
  9426. */
  9427. forceCompilationAsync(options?: Partial<{
  9428. useInstances: boolean;
  9429. }>): Promise<void>;
  9430. /**
  9431. * Serializes the shadow generator setup to a json object.
  9432. * @returns The serialized JSON object
  9433. */
  9434. serialize(): any;
  9435. /**
  9436. * Disposes the Shadow map and related Textures and effects.
  9437. */
  9438. dispose(): void;
  9439. }
  9440. /**
  9441. * Default implementation IShadowGenerator.
  9442. * This is the main object responsible of generating shadows in the framework.
  9443. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9444. */
  9445. export class ShadowGenerator implements IShadowGenerator {
  9446. /**
  9447. * Shadow generator mode None: no filtering applied.
  9448. */
  9449. static readonly FILTER_NONE: number;
  9450. /**
  9451. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9452. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9453. */
  9454. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9455. /**
  9456. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9457. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9458. */
  9459. static readonly FILTER_POISSONSAMPLING: number;
  9460. /**
  9461. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9462. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9463. */
  9464. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9465. /**
  9466. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9467. * edge artifacts on steep falloff.
  9468. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9469. */
  9470. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9471. /**
  9472. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9473. * edge artifacts on steep falloff.
  9474. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9475. */
  9476. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9477. /**
  9478. * Shadow generator mode PCF: Percentage Closer Filtering
  9479. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9480. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9481. */
  9482. static readonly FILTER_PCF: number;
  9483. /**
  9484. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9485. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9486. * Contact Hardening
  9487. */
  9488. static readonly FILTER_PCSS: number;
  9489. /**
  9490. * Reserved for PCF and PCSS
  9491. * Highest Quality.
  9492. *
  9493. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9494. *
  9495. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9496. */
  9497. static readonly QUALITY_HIGH: number;
  9498. /**
  9499. * Reserved for PCF and PCSS
  9500. * Good tradeoff for quality/perf cross devices
  9501. *
  9502. * Execute PCF on a 3*3 kernel.
  9503. *
  9504. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9505. */
  9506. static readonly QUALITY_MEDIUM: number;
  9507. /**
  9508. * Reserved for PCF and PCSS
  9509. * The lowest quality but the fastest.
  9510. *
  9511. * Execute PCF on a 1*1 kernel.
  9512. *
  9513. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9514. */
  9515. static readonly QUALITY_LOW: number;
  9516. /** Gets or sets the custom shader name to use */
  9517. customShaderOptions: ICustomShaderOptions;
  9518. /**
  9519. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9520. */
  9521. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9522. private _bias;
  9523. /**
  9524. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9525. */
  9526. /**
  9527. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9528. */
  9529. bias: number;
  9530. private _normalBias;
  9531. /**
  9532. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9533. */
  9534. /**
  9535. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9536. */
  9537. normalBias: number;
  9538. private _blurBoxOffset;
  9539. /**
  9540. * Gets the blur box offset: offset applied during the blur pass.
  9541. * Only useful if useKernelBlur = false
  9542. */
  9543. /**
  9544. * Sets the blur box offset: offset applied during the blur pass.
  9545. * Only useful if useKernelBlur = false
  9546. */
  9547. blurBoxOffset: number;
  9548. private _blurScale;
  9549. /**
  9550. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9551. * 2 means half of the size.
  9552. */
  9553. /**
  9554. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9555. * 2 means half of the size.
  9556. */
  9557. blurScale: number;
  9558. private _blurKernel;
  9559. /**
  9560. * Gets the blur kernel: kernel size of the blur pass.
  9561. * Only useful if useKernelBlur = true
  9562. */
  9563. /**
  9564. * Sets the blur kernel: kernel size of the blur pass.
  9565. * Only useful if useKernelBlur = true
  9566. */
  9567. blurKernel: number;
  9568. private _useKernelBlur;
  9569. /**
  9570. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9571. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9572. */
  9573. /**
  9574. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9575. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9576. */
  9577. useKernelBlur: boolean;
  9578. private _depthScale;
  9579. /**
  9580. * Gets the depth scale used in ESM mode.
  9581. */
  9582. /**
  9583. * Sets the depth scale used in ESM mode.
  9584. * This can override the scale stored on the light.
  9585. */
  9586. depthScale: number;
  9587. private _filter;
  9588. /**
  9589. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9590. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9591. */
  9592. /**
  9593. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9594. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9595. */
  9596. filter: number;
  9597. /**
  9598. * Gets if the current filter is set to Poisson Sampling.
  9599. */
  9600. /**
  9601. * Sets the current filter to Poisson Sampling.
  9602. */
  9603. usePoissonSampling: boolean;
  9604. /**
  9605. * Gets if the current filter is set to ESM.
  9606. */
  9607. /**
  9608. * Sets the current filter is to ESM.
  9609. */
  9610. useExponentialShadowMap: boolean;
  9611. /**
  9612. * Gets if the current filter is set to filtered ESM.
  9613. */
  9614. /**
  9615. * Gets if the current filter is set to filtered ESM.
  9616. */
  9617. useBlurExponentialShadowMap: boolean;
  9618. /**
  9619. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9620. * exponential to prevent steep falloff artifacts).
  9621. */
  9622. /**
  9623. * Sets the current filter to "close ESM" (using the inverse of the
  9624. * exponential to prevent steep falloff artifacts).
  9625. */
  9626. useCloseExponentialShadowMap: boolean;
  9627. /**
  9628. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9629. * exponential to prevent steep falloff artifacts).
  9630. */
  9631. /**
  9632. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9633. * exponential to prevent steep falloff artifacts).
  9634. */
  9635. useBlurCloseExponentialShadowMap: boolean;
  9636. /**
  9637. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9638. */
  9639. /**
  9640. * Sets the current filter to "PCF" (percentage closer filtering).
  9641. */
  9642. usePercentageCloserFiltering: boolean;
  9643. private _filteringQuality;
  9644. /**
  9645. * Gets the PCF or PCSS Quality.
  9646. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9647. */
  9648. /**
  9649. * Sets the PCF or PCSS Quality.
  9650. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9651. */
  9652. filteringQuality: number;
  9653. /**
  9654. * Gets if the current filter is set to "PCSS" (contact hardening).
  9655. */
  9656. /**
  9657. * Sets the current filter to "PCSS" (contact hardening).
  9658. */
  9659. useContactHardeningShadow: boolean;
  9660. private _contactHardeningLightSizeUVRatio;
  9661. /**
  9662. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9663. * Using a ratio helps keeping shape stability independently of the map size.
  9664. *
  9665. * It does not account for the light projection as it was having too much
  9666. * instability during the light setup or during light position changes.
  9667. *
  9668. * Only valid if useContactHardeningShadow is true.
  9669. */
  9670. /**
  9671. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9672. * Using a ratio helps keeping shape stability independently of the map size.
  9673. *
  9674. * It does not account for the light projection as it was having too much
  9675. * instability during the light setup or during light position changes.
  9676. *
  9677. * Only valid if useContactHardeningShadow is true.
  9678. */
  9679. contactHardeningLightSizeUVRatio: number;
  9680. private _darkness;
  9681. /**
  9682. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9683. * 0 means strongest and 1 would means no shadow.
  9684. * @returns the darkness.
  9685. */
  9686. getDarkness(): number;
  9687. /**
  9688. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9689. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9690. * @returns the shadow generator allowing fluent coding.
  9691. */
  9692. setDarkness(darkness: number): ShadowGenerator;
  9693. private _transparencyShadow;
  9694. /**
  9695. * Sets the ability to have transparent shadow (boolean).
  9696. * @param transparent True if transparent else False
  9697. * @returns the shadow generator allowing fluent coding
  9698. */
  9699. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9700. private _shadowMap;
  9701. private _shadowMap2;
  9702. /**
  9703. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9704. * @returns The render target texture if present otherwise, null
  9705. */
  9706. getShadowMap(): Nullable<RenderTargetTexture>;
  9707. /**
  9708. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9709. * @returns The render target texture if the shadow map is present otherwise, null
  9710. */
  9711. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9712. /**
  9713. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9714. * @param mesh Mesh to add
  9715. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9716. * @returns the Shadow Generator itself
  9717. */
  9718. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9719. /**
  9720. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9721. * @param mesh Mesh to remove
  9722. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9723. * @returns the Shadow Generator itself
  9724. */
  9725. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9726. /**
  9727. * Controls the extent to which the shadows fade out at the edge of the frustum
  9728. * Used only by directionals and spots
  9729. */
  9730. frustumEdgeFalloff: number;
  9731. private _light;
  9732. /**
  9733. * Returns the associated light object.
  9734. * @returns the light generating the shadow
  9735. */
  9736. getLight(): IShadowLight;
  9737. /**
  9738. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9739. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9740. * It might on the other hand introduce peter panning.
  9741. */
  9742. forceBackFacesOnly: boolean;
  9743. private _scene;
  9744. private _lightDirection;
  9745. private _effect;
  9746. private _viewMatrix;
  9747. private _projectionMatrix;
  9748. private _transformMatrix;
  9749. private _cachedPosition;
  9750. private _cachedDirection;
  9751. private _cachedDefines;
  9752. private _currentRenderID;
  9753. private _boxBlurPostprocess;
  9754. private _kernelBlurXPostprocess;
  9755. private _kernelBlurYPostprocess;
  9756. private _blurPostProcesses;
  9757. private _mapSize;
  9758. private _currentFaceIndex;
  9759. private _currentFaceIndexCache;
  9760. private _textureType;
  9761. private _defaultTextureMatrix;
  9762. /** @hidden */
  9763. static _SceneComponentInitialization: (scene: Scene) => void;
  9764. /**
  9765. * Creates a ShadowGenerator object.
  9766. * A ShadowGenerator is the required tool to use the shadows.
  9767. * Each light casting shadows needs to use its own ShadowGenerator.
  9768. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9769. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9770. * @param light The light object generating the shadows.
  9771. * @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.
  9772. */
  9773. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9774. private _initializeGenerator;
  9775. private _initializeShadowMap;
  9776. private _initializeBlurRTTAndPostProcesses;
  9777. private _renderForShadowMap;
  9778. private _renderSubMeshForShadowMap;
  9779. private _applyFilterValues;
  9780. /**
  9781. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9782. * @param onCompiled Callback triggered at the and of the effects compilation
  9783. * @param options Sets of optional options forcing the compilation with different modes
  9784. */
  9785. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9786. useInstances: boolean;
  9787. }>): void;
  9788. /**
  9789. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9790. * @param options Sets of optional options forcing the compilation with different modes
  9791. * @returns A promise that resolves when the compilation completes
  9792. */
  9793. forceCompilationAsync(options?: Partial<{
  9794. useInstances: boolean;
  9795. }>): Promise<void>;
  9796. /**
  9797. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9798. * @param subMesh The submesh we want to render in the shadow map
  9799. * @param useInstances Defines wether will draw in the map using instances
  9800. * @returns true if ready otherwise, false
  9801. */
  9802. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9803. /**
  9804. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9805. * @param defines Defines of the material we want to update
  9806. * @param lightIndex Index of the light in the enabled light list of the material
  9807. */
  9808. prepareDefines(defines: any, lightIndex: number): void;
  9809. /**
  9810. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9811. * defined in the generator but impacting the effect).
  9812. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9813. * @param effect The effect we are binfing the information for
  9814. */
  9815. bindShadowLight(lightIndex: string, effect: Effect): void;
  9816. /**
  9817. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9818. * (eq to shadow prjection matrix * light transform matrix)
  9819. * @returns The transform matrix used to create the shadow map
  9820. */
  9821. getTransformMatrix(): Matrix;
  9822. /**
  9823. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9824. * Cube and 2D textures for instance.
  9825. */
  9826. recreateShadowMap(): void;
  9827. private _disposeBlurPostProcesses;
  9828. private _disposeRTTandPostProcesses;
  9829. /**
  9830. * Disposes the ShadowGenerator.
  9831. * Returns nothing.
  9832. */
  9833. dispose(): void;
  9834. /**
  9835. * Serializes the shadow generator setup to a json object.
  9836. * @returns The serialized JSON object
  9837. */
  9838. serialize(): any;
  9839. /**
  9840. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9841. * @param parsedShadowGenerator The JSON object to parse
  9842. * @param scene The scene to create the shadow map for
  9843. * @returns The parsed shadow generator
  9844. */
  9845. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9846. }
  9847. }
  9848. declare module BABYLON {
  9849. /**
  9850. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9851. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9852. * 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.
  9853. */
  9854. export abstract class Light extends Node {
  9855. /**
  9856. * Falloff Default: light is falling off following the material specification:
  9857. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9858. */
  9859. static readonly FALLOFF_DEFAULT: number;
  9860. /**
  9861. * Falloff Physical: light is falling off following the inverse squared distance law.
  9862. */
  9863. static readonly FALLOFF_PHYSICAL: number;
  9864. /**
  9865. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9866. * to enhance interoperability with other engines.
  9867. */
  9868. static readonly FALLOFF_GLTF: number;
  9869. /**
  9870. * Falloff Standard: light is falling off like in the standard material
  9871. * to enhance interoperability with other materials.
  9872. */
  9873. static readonly FALLOFF_STANDARD: number;
  9874. /**
  9875. * If every light affecting the material is in this lightmapMode,
  9876. * material.lightmapTexture adds or multiplies
  9877. * (depends on material.useLightmapAsShadowmap)
  9878. * after every other light calculations.
  9879. */
  9880. static readonly LIGHTMAP_DEFAULT: number;
  9881. /**
  9882. * material.lightmapTexture as only diffuse lighting from this light
  9883. * adds only specular lighting from this light
  9884. * adds dynamic shadows
  9885. */
  9886. static readonly LIGHTMAP_SPECULAR: number;
  9887. /**
  9888. * material.lightmapTexture as only lighting
  9889. * no light calculation from this light
  9890. * only adds dynamic shadows from this light
  9891. */
  9892. static readonly LIGHTMAP_SHADOWSONLY: number;
  9893. /**
  9894. * Each light type uses the default quantity according to its type:
  9895. * point/spot lights use luminous intensity
  9896. * directional lights use illuminance
  9897. */
  9898. static readonly INTENSITYMODE_AUTOMATIC: number;
  9899. /**
  9900. * lumen (lm)
  9901. */
  9902. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9903. /**
  9904. * candela (lm/sr)
  9905. */
  9906. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9907. /**
  9908. * lux (lm/m^2)
  9909. */
  9910. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9911. /**
  9912. * nit (cd/m^2)
  9913. */
  9914. static readonly INTENSITYMODE_LUMINANCE: number;
  9915. /**
  9916. * Light type const id of the point light.
  9917. */
  9918. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9919. /**
  9920. * Light type const id of the directional light.
  9921. */
  9922. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9923. /**
  9924. * Light type const id of the spot light.
  9925. */
  9926. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9927. /**
  9928. * Light type const id of the hemispheric light.
  9929. */
  9930. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9931. /**
  9932. * Diffuse gives the basic color to an object.
  9933. */
  9934. diffuse: Color3;
  9935. /**
  9936. * Specular produces a highlight color on an object.
  9937. * Note: This is note affecting PBR materials.
  9938. */
  9939. specular: Color3;
  9940. /**
  9941. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9942. * falling off base on range or angle.
  9943. * This can be set to any values in Light.FALLOFF_x.
  9944. *
  9945. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9946. * other types of materials.
  9947. */
  9948. falloffType: number;
  9949. /**
  9950. * Strength of the light.
  9951. * Note: By default it is define in the framework own unit.
  9952. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9953. */
  9954. intensity: number;
  9955. private _range;
  9956. protected _inverseSquaredRange: number;
  9957. /**
  9958. * Defines how far from the source the light is impacting in scene units.
  9959. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9960. */
  9961. /**
  9962. * Defines how far from the source the light is impacting in scene units.
  9963. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9964. */
  9965. range: number;
  9966. /**
  9967. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9968. * of light.
  9969. */
  9970. private _photometricScale;
  9971. private _intensityMode;
  9972. /**
  9973. * Gets the photometric scale used to interpret the intensity.
  9974. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9975. */
  9976. /**
  9977. * Sets the photometric scale used to interpret the intensity.
  9978. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9979. */
  9980. intensityMode: number;
  9981. private _radius;
  9982. /**
  9983. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9984. */
  9985. /**
  9986. * sets the light radius used by PBR Materials to simulate soft area lights.
  9987. */
  9988. radius: number;
  9989. private _renderPriority;
  9990. /**
  9991. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9992. * exceeding the number allowed of the materials.
  9993. */
  9994. renderPriority: number;
  9995. private _shadowEnabled;
  9996. /**
  9997. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9998. * the current shadow generator.
  9999. */
  10000. /**
  10001. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10002. * the current shadow generator.
  10003. */
  10004. shadowEnabled: boolean;
  10005. private _includedOnlyMeshes;
  10006. /**
  10007. * Gets the only meshes impacted by this light.
  10008. */
  10009. /**
  10010. * Sets the only meshes impacted by this light.
  10011. */
  10012. includedOnlyMeshes: AbstractMesh[];
  10013. private _excludedMeshes;
  10014. /**
  10015. * Gets the meshes not impacted by this light.
  10016. */
  10017. /**
  10018. * Sets the meshes not impacted by this light.
  10019. */
  10020. excludedMeshes: AbstractMesh[];
  10021. private _excludeWithLayerMask;
  10022. /**
  10023. * Gets the layer id use to find what meshes are not impacted by the light.
  10024. * Inactive if 0
  10025. */
  10026. /**
  10027. * Sets the layer id use to find what meshes are not impacted by the light.
  10028. * Inactive if 0
  10029. */
  10030. excludeWithLayerMask: number;
  10031. private _includeOnlyWithLayerMask;
  10032. /**
  10033. * Gets the layer id use to find what meshes are impacted by the light.
  10034. * Inactive if 0
  10035. */
  10036. /**
  10037. * Sets the layer id use to find what meshes are impacted by the light.
  10038. * Inactive if 0
  10039. */
  10040. includeOnlyWithLayerMask: number;
  10041. private _lightmapMode;
  10042. /**
  10043. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10044. */
  10045. /**
  10046. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10047. */
  10048. lightmapMode: number;
  10049. /**
  10050. * Shadow generator associted to the light.
  10051. * @hidden Internal use only.
  10052. */
  10053. _shadowGenerator: Nullable<IShadowGenerator>;
  10054. /**
  10055. * @hidden Internal use only.
  10056. */
  10057. _excludedMeshesIds: string[];
  10058. /**
  10059. * @hidden Internal use only.
  10060. */
  10061. _includedOnlyMeshesIds: string[];
  10062. /**
  10063. * The current light unifom buffer.
  10064. * @hidden Internal use only.
  10065. */
  10066. _uniformBuffer: UniformBuffer;
  10067. /**
  10068. * Creates a Light object in the scene.
  10069. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10070. * @param name The firendly name of the light
  10071. * @param scene The scene the light belongs too
  10072. */
  10073. constructor(name: string, scene: Scene);
  10074. protected abstract _buildUniformLayout(): void;
  10075. /**
  10076. * Sets the passed Effect "effect" with the Light information.
  10077. * @param effect The effect to update
  10078. * @param lightIndex The index of the light in the effect to update
  10079. * @returns The light
  10080. */
  10081. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10082. /**
  10083. * Returns the string "Light".
  10084. * @returns the class name
  10085. */
  10086. getClassName(): string;
  10087. /** @hidden */
  10088. readonly _isLight: boolean;
  10089. /**
  10090. * Converts the light information to a readable string for debug purpose.
  10091. * @param fullDetails Supports for multiple levels of logging within scene loading
  10092. * @returns the human readable light info
  10093. */
  10094. toString(fullDetails?: boolean): string;
  10095. /** @hidden */
  10096. protected _syncParentEnabledState(): void;
  10097. /**
  10098. * Set the enabled state of this node.
  10099. * @param value - the new enabled state
  10100. */
  10101. setEnabled(value: boolean): void;
  10102. /**
  10103. * Returns the Light associated shadow generator if any.
  10104. * @return the associated shadow generator.
  10105. */
  10106. getShadowGenerator(): Nullable<IShadowGenerator>;
  10107. /**
  10108. * Returns a Vector3, the absolute light position in the World.
  10109. * @returns the world space position of the light
  10110. */
  10111. getAbsolutePosition(): Vector3;
  10112. /**
  10113. * Specifies if the light will affect the passed mesh.
  10114. * @param mesh The mesh to test against the light
  10115. * @return true the mesh is affected otherwise, false.
  10116. */
  10117. canAffectMesh(mesh: AbstractMesh): boolean;
  10118. /**
  10119. * Sort function to order lights for rendering.
  10120. * @param a First Light object to compare to second.
  10121. * @param b Second Light object to compare first.
  10122. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10123. */
  10124. static CompareLightsPriority(a: Light, b: Light): number;
  10125. /**
  10126. * Releases resources associated with this node.
  10127. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10128. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10129. */
  10130. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10131. /**
  10132. * Returns the light type ID (integer).
  10133. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10134. */
  10135. getTypeID(): number;
  10136. /**
  10137. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10138. * @returns the scaled intensity in intensity mode unit
  10139. */
  10140. getScaledIntensity(): number;
  10141. /**
  10142. * Returns a new Light object, named "name", from the current one.
  10143. * @param name The name of the cloned light
  10144. * @returns the new created light
  10145. */
  10146. clone(name: string): Nullable<Light>;
  10147. /**
  10148. * Serializes the current light into a Serialization object.
  10149. * @returns the serialized object.
  10150. */
  10151. serialize(): any;
  10152. /**
  10153. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10154. * This new light is named "name" and added to the passed scene.
  10155. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10156. * @param name The friendly name of the light
  10157. * @param scene The scene the new light will belong to
  10158. * @returns the constructor function
  10159. */
  10160. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10161. /**
  10162. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10163. * @param parsedLight The JSON representation of the light
  10164. * @param scene The scene to create the parsed light in
  10165. * @returns the created light after parsing
  10166. */
  10167. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10168. private _hookArrayForExcluded;
  10169. private _hookArrayForIncludedOnly;
  10170. private _resyncMeshes;
  10171. /**
  10172. * Forces the meshes to update their light related information in their rendering used effects
  10173. * @hidden Internal Use Only
  10174. */
  10175. _markMeshesAsLightDirty(): void;
  10176. /**
  10177. * Recomputes the cached photometric scale if needed.
  10178. */
  10179. private _computePhotometricScale;
  10180. /**
  10181. * Returns the Photometric Scale according to the light type and intensity mode.
  10182. */
  10183. private _getPhotometricScale;
  10184. /**
  10185. * Reorder the light in the scene according to their defined priority.
  10186. * @hidden Internal Use Only
  10187. */
  10188. _reorderLightsInScene(): void;
  10189. /**
  10190. * Prepares the list of defines specific to the light type.
  10191. * @param defines the list of defines
  10192. * @param lightIndex defines the index of the light for the effect
  10193. */
  10194. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10195. }
  10196. }
  10197. declare module BABYLON {
  10198. /**
  10199. * Interface used to define Action
  10200. */
  10201. export interface IAction {
  10202. /**
  10203. * Trigger for the action
  10204. */
  10205. trigger: number;
  10206. /** Options of the trigger */
  10207. triggerOptions: any;
  10208. /**
  10209. * Gets the trigger parameters
  10210. * @returns the trigger parameters
  10211. */
  10212. getTriggerParameter(): any;
  10213. /**
  10214. * Internal only - executes current action event
  10215. * @hidden
  10216. */
  10217. _executeCurrent(evt?: ActionEvent): void;
  10218. /**
  10219. * Serialize placeholder for child classes
  10220. * @param parent of child
  10221. * @returns the serialized object
  10222. */
  10223. serialize(parent: any): any;
  10224. }
  10225. /**
  10226. * The action to be carried out following a trigger
  10227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10228. */
  10229. export class Action implements IAction {
  10230. /** the trigger, with or without parameters, for the action */
  10231. triggerOptions: any;
  10232. /**
  10233. * Trigger for the action
  10234. */
  10235. trigger: number;
  10236. /**
  10237. * Internal only - manager for action
  10238. * @hidden
  10239. */
  10240. _actionManager: ActionManager;
  10241. private _nextActiveAction;
  10242. private _child;
  10243. private _condition?;
  10244. private _triggerParameter;
  10245. /**
  10246. * An event triggered prior to action being executed.
  10247. */
  10248. onBeforeExecuteObservable: Observable<Action>;
  10249. /**
  10250. * Creates a new Action
  10251. * @param triggerOptions the trigger, with or without parameters, for the action
  10252. * @param condition an optional determinant of action
  10253. */
  10254. constructor(
  10255. /** the trigger, with or without parameters, for the action */
  10256. triggerOptions: any, condition?: Condition);
  10257. /**
  10258. * Internal only
  10259. * @hidden
  10260. */
  10261. _prepare(): void;
  10262. /**
  10263. * Gets the trigger parameters
  10264. * @returns the trigger parameters
  10265. */
  10266. getTriggerParameter(): any;
  10267. /**
  10268. * Internal only - executes current action event
  10269. * @hidden
  10270. */
  10271. _executeCurrent(evt?: ActionEvent): void;
  10272. /**
  10273. * Execute placeholder for child classes
  10274. * @param evt optional action event
  10275. */
  10276. execute(evt?: ActionEvent): void;
  10277. /**
  10278. * Skips to next active action
  10279. */
  10280. skipToNextActiveAction(): void;
  10281. /**
  10282. * Adds action to chain of actions, may be a DoNothingAction
  10283. * @param action defines the next action to execute
  10284. * @returns The action passed in
  10285. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10286. */
  10287. then(action: Action): Action;
  10288. /**
  10289. * Internal only
  10290. * @hidden
  10291. */
  10292. _getProperty(propertyPath: string): string;
  10293. /**
  10294. * Internal only
  10295. * @hidden
  10296. */
  10297. _getEffectiveTarget(target: any, propertyPath: string): any;
  10298. /**
  10299. * Serialize placeholder for child classes
  10300. * @param parent of child
  10301. * @returns the serialized object
  10302. */
  10303. serialize(parent: any): any;
  10304. /**
  10305. * Internal only called by serialize
  10306. * @hidden
  10307. */
  10308. protected _serialize(serializedAction: any, parent?: any): any;
  10309. /**
  10310. * Internal only
  10311. * @hidden
  10312. */
  10313. static _SerializeValueAsString: (value: any) => string;
  10314. /**
  10315. * Internal only
  10316. * @hidden
  10317. */
  10318. static _GetTargetProperty: (target: Scene | Node) => {
  10319. name: string;
  10320. targetType: string;
  10321. value: string;
  10322. };
  10323. }
  10324. }
  10325. declare module BABYLON {
  10326. /**
  10327. * A Condition applied to an Action
  10328. */
  10329. export class Condition {
  10330. /**
  10331. * Internal only - manager for action
  10332. * @hidden
  10333. */
  10334. _actionManager: ActionManager;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. _evaluationId: number;
  10340. /**
  10341. * Internal only
  10342. * @hidden
  10343. */
  10344. _currentResult: boolean;
  10345. /**
  10346. * Creates a new Condition
  10347. * @param actionManager the manager of the action the condition is applied to
  10348. */
  10349. constructor(actionManager: ActionManager);
  10350. /**
  10351. * Check if the current condition is valid
  10352. * @returns a boolean
  10353. */
  10354. isValid(): boolean;
  10355. /**
  10356. * Internal only
  10357. * @hidden
  10358. */
  10359. _getProperty(propertyPath: string): string;
  10360. /**
  10361. * Internal only
  10362. * @hidden
  10363. */
  10364. _getEffectiveTarget(target: any, propertyPath: string): any;
  10365. /**
  10366. * Serialize placeholder for child classes
  10367. * @returns the serialized object
  10368. */
  10369. serialize(): any;
  10370. /**
  10371. * Internal only
  10372. * @hidden
  10373. */
  10374. protected _serialize(serializedCondition: any): any;
  10375. }
  10376. /**
  10377. * Defines specific conditional operators as extensions of Condition
  10378. */
  10379. export class ValueCondition extends Condition {
  10380. /** path to specify the property of the target the conditional operator uses */
  10381. propertyPath: string;
  10382. /** the value compared by the conditional operator against the current value of the property */
  10383. value: any;
  10384. /** the conditional operator, default ValueCondition.IsEqual */
  10385. operator: number;
  10386. /**
  10387. * Internal only
  10388. * @hidden
  10389. */
  10390. private static _IsEqual;
  10391. /**
  10392. * Internal only
  10393. * @hidden
  10394. */
  10395. private static _IsDifferent;
  10396. /**
  10397. * Internal only
  10398. * @hidden
  10399. */
  10400. private static _IsGreater;
  10401. /**
  10402. * Internal only
  10403. * @hidden
  10404. */
  10405. private static _IsLesser;
  10406. /**
  10407. * returns the number for IsEqual
  10408. */
  10409. static readonly IsEqual: number;
  10410. /**
  10411. * Returns the number for IsDifferent
  10412. */
  10413. static readonly IsDifferent: number;
  10414. /**
  10415. * Returns the number for IsGreater
  10416. */
  10417. static readonly IsGreater: number;
  10418. /**
  10419. * Returns the number for IsLesser
  10420. */
  10421. static readonly IsLesser: number;
  10422. /**
  10423. * Internal only The action manager for the condition
  10424. * @hidden
  10425. */
  10426. _actionManager: ActionManager;
  10427. /**
  10428. * Internal only
  10429. * @hidden
  10430. */
  10431. private _target;
  10432. /**
  10433. * Internal only
  10434. * @hidden
  10435. */
  10436. private _effectiveTarget;
  10437. /**
  10438. * Internal only
  10439. * @hidden
  10440. */
  10441. private _property;
  10442. /**
  10443. * Creates a new ValueCondition
  10444. * @param actionManager manager for the action the condition applies to
  10445. * @param target for the action
  10446. * @param propertyPath path to specify the property of the target the conditional operator uses
  10447. * @param value the value compared by the conditional operator against the current value of the property
  10448. * @param operator the conditional operator, default ValueCondition.IsEqual
  10449. */
  10450. constructor(actionManager: ActionManager, target: any,
  10451. /** path to specify the property of the target the conditional operator uses */
  10452. propertyPath: string,
  10453. /** the value compared by the conditional operator against the current value of the property */
  10454. value: any,
  10455. /** the conditional operator, default ValueCondition.IsEqual */
  10456. operator?: number);
  10457. /**
  10458. * Compares the given value with the property value for the specified conditional operator
  10459. * @returns the result of the comparison
  10460. */
  10461. isValid(): boolean;
  10462. /**
  10463. * Serialize the ValueCondition into a JSON compatible object
  10464. * @returns serialization object
  10465. */
  10466. serialize(): any;
  10467. /**
  10468. * Gets the name of the conditional operator for the ValueCondition
  10469. * @param operator the conditional operator
  10470. * @returns the name
  10471. */
  10472. static GetOperatorName(operator: number): string;
  10473. }
  10474. /**
  10475. * Defines a predicate condition as an extension of Condition
  10476. */
  10477. export class PredicateCondition extends Condition {
  10478. /** defines the predicate function used to validate the condition */
  10479. predicate: () => boolean;
  10480. /**
  10481. * Internal only - manager for action
  10482. * @hidden
  10483. */
  10484. _actionManager: ActionManager;
  10485. /**
  10486. * Creates a new PredicateCondition
  10487. * @param actionManager manager for the action the condition applies to
  10488. * @param predicate defines the predicate function used to validate the condition
  10489. */
  10490. constructor(actionManager: ActionManager,
  10491. /** defines the predicate function used to validate the condition */
  10492. predicate: () => boolean);
  10493. /**
  10494. * @returns the validity of the predicate condition
  10495. */
  10496. isValid(): boolean;
  10497. }
  10498. /**
  10499. * Defines a state condition as an extension of Condition
  10500. */
  10501. export class StateCondition extends Condition {
  10502. /** Value to compare with target state */
  10503. value: string;
  10504. /**
  10505. * Internal only - manager for action
  10506. * @hidden
  10507. */
  10508. _actionManager: ActionManager;
  10509. /**
  10510. * Internal only
  10511. * @hidden
  10512. */
  10513. private _target;
  10514. /**
  10515. * Creates a new StateCondition
  10516. * @param actionManager manager for the action the condition applies to
  10517. * @param target of the condition
  10518. * @param value to compare with target state
  10519. */
  10520. constructor(actionManager: ActionManager, target: any,
  10521. /** Value to compare with target state */
  10522. value: string);
  10523. /**
  10524. * Gets a boolean indicating if the current condition is met
  10525. * @returns the validity of the state
  10526. */
  10527. isValid(): boolean;
  10528. /**
  10529. * Serialize the StateCondition into a JSON compatible object
  10530. * @returns serialization object
  10531. */
  10532. serialize(): any;
  10533. }
  10534. }
  10535. declare module BABYLON {
  10536. /**
  10537. * This defines an action responsible to toggle a boolean once triggered.
  10538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10539. */
  10540. export class SwitchBooleanAction extends Action {
  10541. /**
  10542. * The path to the boolean property in the target object
  10543. */
  10544. propertyPath: string;
  10545. private _target;
  10546. private _effectiveTarget;
  10547. private _property;
  10548. /**
  10549. * Instantiate the action
  10550. * @param triggerOptions defines the trigger options
  10551. * @param target defines the object containing the boolean
  10552. * @param propertyPath defines the path to the boolean property in the target object
  10553. * @param condition defines the trigger related conditions
  10554. */
  10555. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10556. /** @hidden */
  10557. _prepare(): void;
  10558. /**
  10559. * Execute the action toggle the boolean value.
  10560. */
  10561. execute(): void;
  10562. /**
  10563. * Serializes the actions and its related information.
  10564. * @param parent defines the object to serialize in
  10565. * @returns the serialized object
  10566. */
  10567. serialize(parent: any): any;
  10568. }
  10569. /**
  10570. * This defines an action responsible to set a the state field of the target
  10571. * to a desired value once triggered.
  10572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10573. */
  10574. export class SetStateAction extends Action {
  10575. /**
  10576. * The value to store in the state field.
  10577. */
  10578. value: string;
  10579. private _target;
  10580. /**
  10581. * Instantiate the action
  10582. * @param triggerOptions defines the trigger options
  10583. * @param target defines the object containing the state property
  10584. * @param value defines the value to store in the state field
  10585. * @param condition defines the trigger related conditions
  10586. */
  10587. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10588. /**
  10589. * Execute the action and store the value on the target state property.
  10590. */
  10591. execute(): void;
  10592. /**
  10593. * Serializes the actions and its related information.
  10594. * @param parent defines the object to serialize in
  10595. * @returns the serialized object
  10596. */
  10597. serialize(parent: any): any;
  10598. }
  10599. /**
  10600. * This defines an action responsible to set a property of the target
  10601. * to a desired value once triggered.
  10602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10603. */
  10604. export class SetValueAction extends Action {
  10605. /**
  10606. * The path of the property to set in the target.
  10607. */
  10608. propertyPath: string;
  10609. /**
  10610. * The value to set in the property
  10611. */
  10612. value: any;
  10613. private _target;
  10614. private _effectiveTarget;
  10615. private _property;
  10616. /**
  10617. * Instantiate the action
  10618. * @param triggerOptions defines the trigger options
  10619. * @param target defines the object containing the property
  10620. * @param propertyPath defines the path of the property to set in the target
  10621. * @param value defines the value to set in the property
  10622. * @param condition defines the trigger related conditions
  10623. */
  10624. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10625. /** @hidden */
  10626. _prepare(): void;
  10627. /**
  10628. * Execute the action and set the targetted property to the desired value.
  10629. */
  10630. execute(): void;
  10631. /**
  10632. * Serializes the actions and its related information.
  10633. * @param parent defines the object to serialize in
  10634. * @returns the serialized object
  10635. */
  10636. serialize(parent: any): any;
  10637. }
  10638. /**
  10639. * This defines an action responsible to increment the target value
  10640. * to a desired value once triggered.
  10641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10642. */
  10643. export class IncrementValueAction extends Action {
  10644. /**
  10645. * The path of the property to increment in the target.
  10646. */
  10647. propertyPath: string;
  10648. /**
  10649. * The value we should increment the property by.
  10650. */
  10651. value: any;
  10652. private _target;
  10653. private _effectiveTarget;
  10654. private _property;
  10655. /**
  10656. * Instantiate the action
  10657. * @param triggerOptions defines the trigger options
  10658. * @param target defines the object containing the property
  10659. * @param propertyPath defines the path of the property to increment in the target
  10660. * @param value defines the value value we should increment the property by
  10661. * @param condition defines the trigger related conditions
  10662. */
  10663. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10664. /** @hidden */
  10665. _prepare(): void;
  10666. /**
  10667. * Execute the action and increment the target of the value amount.
  10668. */
  10669. execute(): void;
  10670. /**
  10671. * Serializes the actions and its related information.
  10672. * @param parent defines the object to serialize in
  10673. * @returns the serialized object
  10674. */
  10675. serialize(parent: any): any;
  10676. }
  10677. /**
  10678. * This defines an action responsible to start an animation once triggered.
  10679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10680. */
  10681. export class PlayAnimationAction extends Action {
  10682. /**
  10683. * Where the animation should start (animation frame)
  10684. */
  10685. from: number;
  10686. /**
  10687. * Where the animation should stop (animation frame)
  10688. */
  10689. to: number;
  10690. /**
  10691. * Define if the animation should loop or stop after the first play.
  10692. */
  10693. loop?: boolean;
  10694. private _target;
  10695. /**
  10696. * Instantiate the action
  10697. * @param triggerOptions defines the trigger options
  10698. * @param target defines the target animation or animation name
  10699. * @param from defines from where the animation should start (animation frame)
  10700. * @param end defines where the animation should stop (animation frame)
  10701. * @param loop defines if the animation should loop or stop after the first play
  10702. * @param condition defines the trigger related conditions
  10703. */
  10704. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10705. /** @hidden */
  10706. _prepare(): void;
  10707. /**
  10708. * Execute the action and play the animation.
  10709. */
  10710. execute(): void;
  10711. /**
  10712. * Serializes the actions and its related information.
  10713. * @param parent defines the object to serialize in
  10714. * @returns the serialized object
  10715. */
  10716. serialize(parent: any): any;
  10717. }
  10718. /**
  10719. * This defines an action responsible to stop an animation once triggered.
  10720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10721. */
  10722. export class StopAnimationAction extends Action {
  10723. private _target;
  10724. /**
  10725. * Instantiate the action
  10726. * @param triggerOptions defines the trigger options
  10727. * @param target defines the target animation or animation name
  10728. * @param condition defines the trigger related conditions
  10729. */
  10730. constructor(triggerOptions: any, target: any, condition?: Condition);
  10731. /** @hidden */
  10732. _prepare(): void;
  10733. /**
  10734. * Execute the action and stop the animation.
  10735. */
  10736. execute(): void;
  10737. /**
  10738. * Serializes the actions and its related information.
  10739. * @param parent defines the object to serialize in
  10740. * @returns the serialized object
  10741. */
  10742. serialize(parent: any): any;
  10743. }
  10744. /**
  10745. * This defines an action responsible that does nothing once triggered.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class DoNothingAction extends Action {
  10749. /**
  10750. * Instantiate the action
  10751. * @param triggerOptions defines the trigger options
  10752. * @param condition defines the trigger related conditions
  10753. */
  10754. constructor(triggerOptions?: any, condition?: Condition);
  10755. /**
  10756. * Execute the action and do nothing.
  10757. */
  10758. execute(): void;
  10759. /**
  10760. * Serializes the actions and its related information.
  10761. * @param parent defines the object to serialize in
  10762. * @returns the serialized object
  10763. */
  10764. serialize(parent: any): any;
  10765. }
  10766. /**
  10767. * This defines an action responsible to trigger several actions once triggered.
  10768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10769. */
  10770. export class CombineAction extends Action {
  10771. /**
  10772. * The list of aggregated animations to run.
  10773. */
  10774. children: Action[];
  10775. /**
  10776. * Instantiate the action
  10777. * @param triggerOptions defines the trigger options
  10778. * @param children defines the list of aggregated animations to run
  10779. * @param condition defines the trigger related conditions
  10780. */
  10781. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10782. /** @hidden */
  10783. _prepare(): void;
  10784. /**
  10785. * Execute the action and executes all the aggregated actions.
  10786. */
  10787. execute(evt: ActionEvent): void;
  10788. /**
  10789. * Serializes the actions and its related information.
  10790. * @param parent defines the object to serialize in
  10791. * @returns the serialized object
  10792. */
  10793. serialize(parent: any): any;
  10794. }
  10795. /**
  10796. * This defines an action responsible to run code (external event) once triggered.
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10798. */
  10799. export class ExecuteCodeAction extends Action {
  10800. /**
  10801. * The callback function to run.
  10802. */
  10803. func: (evt: ActionEvent) => void;
  10804. /**
  10805. * Instantiate the action
  10806. * @param triggerOptions defines the trigger options
  10807. * @param func defines the callback function to run
  10808. * @param condition defines the trigger related conditions
  10809. */
  10810. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10811. /**
  10812. * Execute the action and run the attached code.
  10813. */
  10814. execute(evt: ActionEvent): void;
  10815. }
  10816. /**
  10817. * This defines an action responsible to set the parent property of the target once triggered.
  10818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10819. */
  10820. export class SetParentAction extends Action {
  10821. private _parent;
  10822. private _target;
  10823. /**
  10824. * Instantiate the action
  10825. * @param triggerOptions defines the trigger options
  10826. * @param target defines the target containing the parent property
  10827. * @param parent defines from where the animation should start (animation frame)
  10828. * @param condition defines the trigger related conditions
  10829. */
  10830. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10831. /** @hidden */
  10832. _prepare(): void;
  10833. /**
  10834. * Execute the action and set the parent property.
  10835. */
  10836. execute(): void;
  10837. /**
  10838. * Serializes the actions and its related information.
  10839. * @param parent defines the object to serialize in
  10840. * @returns the serialized object
  10841. */
  10842. serialize(parent: any): any;
  10843. }
  10844. }
  10845. declare module BABYLON {
  10846. /**
  10847. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10848. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10850. */
  10851. export class ActionManager extends AbstractActionManager {
  10852. /**
  10853. * Nothing
  10854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10855. */
  10856. static readonly NothingTrigger: number;
  10857. /**
  10858. * On pick
  10859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10860. */
  10861. static readonly OnPickTrigger: number;
  10862. /**
  10863. * On left pick
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10865. */
  10866. static readonly OnLeftPickTrigger: number;
  10867. /**
  10868. * On right pick
  10869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10870. */
  10871. static readonly OnRightPickTrigger: number;
  10872. /**
  10873. * On center pick
  10874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10875. */
  10876. static readonly OnCenterPickTrigger: number;
  10877. /**
  10878. * On pick down
  10879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10880. */
  10881. static readonly OnPickDownTrigger: number;
  10882. /**
  10883. * On double pick
  10884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10885. */
  10886. static readonly OnDoublePickTrigger: number;
  10887. /**
  10888. * On pick up
  10889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10890. */
  10891. static readonly OnPickUpTrigger: number;
  10892. /**
  10893. * On pick out.
  10894. * This trigger will only be raised if you also declared a OnPickDown
  10895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10896. */
  10897. static readonly OnPickOutTrigger: number;
  10898. /**
  10899. * On long press
  10900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10901. */
  10902. static readonly OnLongPressTrigger: number;
  10903. /**
  10904. * On pointer over
  10905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10906. */
  10907. static readonly OnPointerOverTrigger: number;
  10908. /**
  10909. * On pointer out
  10910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10911. */
  10912. static readonly OnPointerOutTrigger: number;
  10913. /**
  10914. * On every frame
  10915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10916. */
  10917. static readonly OnEveryFrameTrigger: number;
  10918. /**
  10919. * On intersection enter
  10920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10921. */
  10922. static readonly OnIntersectionEnterTrigger: number;
  10923. /**
  10924. * On intersection exit
  10925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10926. */
  10927. static readonly OnIntersectionExitTrigger: number;
  10928. /**
  10929. * On key down
  10930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10931. */
  10932. static readonly OnKeyDownTrigger: number;
  10933. /**
  10934. * On key up
  10935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10936. */
  10937. static readonly OnKeyUpTrigger: number;
  10938. private _scene;
  10939. /**
  10940. * Creates a new action manager
  10941. * @param scene defines the hosting scene
  10942. */
  10943. constructor(scene: Scene);
  10944. /**
  10945. * Releases all associated resources
  10946. */
  10947. dispose(): void;
  10948. /**
  10949. * Gets hosting scene
  10950. * @returns the hosting scene
  10951. */
  10952. getScene(): Scene;
  10953. /**
  10954. * Does this action manager handles actions of any of the given triggers
  10955. * @param triggers defines the triggers to be tested
  10956. * @return a boolean indicating whether one (or more) of the triggers is handled
  10957. */
  10958. hasSpecificTriggers(triggers: number[]): boolean;
  10959. /**
  10960. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10961. * speed.
  10962. * @param triggerA defines the trigger to be tested
  10963. * @param triggerB defines the trigger to be tested
  10964. * @return a boolean indicating whether one (or more) of the triggers is handled
  10965. */
  10966. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10967. /**
  10968. * Does this action manager handles actions of a given trigger
  10969. * @param trigger defines the trigger to be tested
  10970. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10971. * @return whether the trigger is handled
  10972. */
  10973. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10974. /**
  10975. * Does this action manager has pointer triggers
  10976. */
  10977. readonly hasPointerTriggers: boolean;
  10978. /**
  10979. * Does this action manager has pick triggers
  10980. */
  10981. readonly hasPickTriggers: boolean;
  10982. /**
  10983. * Registers an action to this action manager
  10984. * @param action defines the action to be registered
  10985. * @return the action amended (prepared) after registration
  10986. */
  10987. registerAction(action: Action): Nullable<Action>;
  10988. /**
  10989. * Unregisters an action to this action manager
  10990. * @param action defines the action to be unregistered
  10991. * @return a boolean indicating whether the action has been unregistered
  10992. */
  10993. unregisterAction(action: Action): Boolean;
  10994. /**
  10995. * Process a specific trigger
  10996. * @param trigger defines the trigger to process
  10997. * @param evt defines the event details to be processed
  10998. */
  10999. processTrigger(trigger: number, evt?: IActionEvent): void;
  11000. /** @hidden */
  11001. _getEffectiveTarget(target: any, propertyPath: string): any;
  11002. /** @hidden */
  11003. _getProperty(propertyPath: string): string;
  11004. /**
  11005. * Serialize this manager to a JSON object
  11006. * @param name defines the property name to store this manager
  11007. * @returns a JSON representation of this manager
  11008. */
  11009. serialize(name: string): any;
  11010. /**
  11011. * Creates a new ActionManager from a JSON data
  11012. * @param parsedActions defines the JSON data to read from
  11013. * @param object defines the hosting mesh
  11014. * @param scene defines the hosting scene
  11015. */
  11016. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11017. /**
  11018. * Get a trigger name by index
  11019. * @param trigger defines the trigger index
  11020. * @returns a trigger name
  11021. */
  11022. static GetTriggerName(trigger: number): string;
  11023. }
  11024. }
  11025. declare module BABYLON {
  11026. /**
  11027. * Class representing a ray with position and direction
  11028. */
  11029. export class Ray {
  11030. /** origin point */
  11031. origin: Vector3;
  11032. /** direction */
  11033. direction: Vector3;
  11034. /** length of the ray */
  11035. length: number;
  11036. private static readonly TmpVector3;
  11037. private _tmpRay;
  11038. /**
  11039. * Creates a new ray
  11040. * @param origin origin point
  11041. * @param direction direction
  11042. * @param length length of the ray
  11043. */
  11044. constructor(
  11045. /** origin point */
  11046. origin: Vector3,
  11047. /** direction */
  11048. direction: Vector3,
  11049. /** length of the ray */
  11050. length?: number);
  11051. /**
  11052. * Checks if the ray intersects a box
  11053. * @param minimum bound of the box
  11054. * @param maximum bound of the box
  11055. * @param intersectionTreshold extra extend to be added to the box in all direction
  11056. * @returns if the box was hit
  11057. */
  11058. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11059. /**
  11060. * Checks if the ray intersects a box
  11061. * @param box the bounding box to check
  11062. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11063. * @returns if the box was hit
  11064. */
  11065. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11066. /**
  11067. * If the ray hits a sphere
  11068. * @param sphere the bounding sphere to check
  11069. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11070. * @returns true if it hits the sphere
  11071. */
  11072. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11073. /**
  11074. * If the ray hits a triange
  11075. * @param vertex0 triangle vertex
  11076. * @param vertex1 triangle vertex
  11077. * @param vertex2 triangle vertex
  11078. * @returns intersection information if hit
  11079. */
  11080. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11081. /**
  11082. * Checks if ray intersects a plane
  11083. * @param plane the plane to check
  11084. * @returns the distance away it was hit
  11085. */
  11086. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11087. /**
  11088. * Checks if ray intersects a mesh
  11089. * @param mesh the mesh to check
  11090. * @param fastCheck if only the bounding box should checked
  11091. * @returns picking info of the intersecton
  11092. */
  11093. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11094. /**
  11095. * Checks if ray intersects a mesh
  11096. * @param meshes the meshes to check
  11097. * @param fastCheck if only the bounding box should checked
  11098. * @param results array to store result in
  11099. * @returns Array of picking infos
  11100. */
  11101. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11102. private _comparePickingInfo;
  11103. private static smallnum;
  11104. private static rayl;
  11105. /**
  11106. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11107. * @param sega the first point of the segment to test the intersection against
  11108. * @param segb the second point of the segment to test the intersection against
  11109. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11110. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11111. */
  11112. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11113. /**
  11114. * Update the ray from viewport position
  11115. * @param x position
  11116. * @param y y position
  11117. * @param viewportWidth viewport width
  11118. * @param viewportHeight viewport height
  11119. * @param world world matrix
  11120. * @param view view matrix
  11121. * @param projection projection matrix
  11122. * @returns this ray updated
  11123. */
  11124. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11125. /**
  11126. * Creates a ray with origin and direction of 0,0,0
  11127. * @returns the new ray
  11128. */
  11129. static Zero(): Ray;
  11130. /**
  11131. * Creates a new ray from screen space and viewport
  11132. * @param x position
  11133. * @param y y position
  11134. * @param viewportWidth viewport width
  11135. * @param viewportHeight viewport height
  11136. * @param world world matrix
  11137. * @param view view matrix
  11138. * @param projection projection matrix
  11139. * @returns new ray
  11140. */
  11141. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11142. /**
  11143. * 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
  11144. * transformed to the given world matrix.
  11145. * @param origin The origin point
  11146. * @param end The end point
  11147. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11148. * @returns the new ray
  11149. */
  11150. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11151. /**
  11152. * Transforms a ray by a matrix
  11153. * @param ray ray to transform
  11154. * @param matrix matrix to apply
  11155. * @returns the resulting new ray
  11156. */
  11157. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11158. /**
  11159. * Transforms a ray by a matrix
  11160. * @param ray ray to transform
  11161. * @param matrix matrix to apply
  11162. * @param result ray to store result in
  11163. */
  11164. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11165. /**
  11166. * Unproject a ray from screen space to object space
  11167. * @param sourceX defines the screen space x coordinate to use
  11168. * @param sourceY defines the screen space y coordinate to use
  11169. * @param viewportWidth defines the current width of the viewport
  11170. * @param viewportHeight defines the current height of the viewport
  11171. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11172. * @param view defines the view matrix to use
  11173. * @param projection defines the projection matrix to use
  11174. */
  11175. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11176. }
  11177. interface Scene {
  11178. /** @hidden */
  11179. _tempPickingRay: Nullable<Ray>;
  11180. /** @hidden */
  11181. _cachedRayForTransform: Ray;
  11182. /** @hidden */
  11183. _pickWithRayInverseMatrix: Matrix;
  11184. /** @hidden */
  11185. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11186. /** @hidden */
  11187. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  11188. }
  11189. }
  11190. declare module BABYLON {
  11191. /**
  11192. * Groups all the scene component constants in one place to ease maintenance.
  11193. * @hidden
  11194. */
  11195. export class SceneComponentConstants {
  11196. static readonly NAME_EFFECTLAYER: string;
  11197. static readonly NAME_LAYER: string;
  11198. static readonly NAME_LENSFLARESYSTEM: string;
  11199. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11200. static readonly NAME_PARTICLESYSTEM: string;
  11201. static readonly NAME_GAMEPAD: string;
  11202. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11203. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11204. static readonly NAME_DEPTHRENDERER: string;
  11205. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11206. static readonly NAME_SPRITE: string;
  11207. static readonly NAME_OUTLINERENDERER: string;
  11208. static readonly NAME_PROCEDURALTEXTURE: string;
  11209. static readonly NAME_SHADOWGENERATOR: string;
  11210. static readonly NAME_OCTREE: string;
  11211. static readonly NAME_PHYSICSENGINE: string;
  11212. static readonly NAME_AUDIO: string;
  11213. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11214. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11215. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11216. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11217. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11218. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11219. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11220. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11221. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11222. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11223. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11224. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11225. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11226. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11227. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11228. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11229. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11230. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11231. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11232. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11233. static readonly STEP_AFTERRENDER_AUDIO: number;
  11234. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11235. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11236. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11237. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11238. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11239. static readonly STEP_POINTERMOVE_SPRITE: number;
  11240. static readonly STEP_POINTERDOWN_SPRITE: number;
  11241. static readonly STEP_POINTERUP_SPRITE: number;
  11242. }
  11243. /**
  11244. * This represents a scene component.
  11245. *
  11246. * This is used to decouple the dependency the scene is having on the different workloads like
  11247. * layers, post processes...
  11248. */
  11249. export interface ISceneComponent {
  11250. /**
  11251. * The name of the component. Each component must have a unique name.
  11252. */
  11253. name: string;
  11254. /**
  11255. * The scene the component belongs to.
  11256. */
  11257. scene: Scene;
  11258. /**
  11259. * Register the component to one instance of a scene.
  11260. */
  11261. register(): void;
  11262. /**
  11263. * Rebuilds the elements related to this component in case of
  11264. * context lost for instance.
  11265. */
  11266. rebuild(): void;
  11267. /**
  11268. * Disposes the component and the associated ressources.
  11269. */
  11270. dispose(): void;
  11271. }
  11272. /**
  11273. * This represents a SERIALIZABLE scene component.
  11274. *
  11275. * This extends Scene Component to add Serialization methods on top.
  11276. */
  11277. export interface ISceneSerializableComponent extends ISceneComponent {
  11278. /**
  11279. * Adds all the element from the container to the scene
  11280. * @param container the container holding the elements
  11281. */
  11282. addFromContainer(container: AbstractScene): void;
  11283. /**
  11284. * Removes all the elements in the container from the scene
  11285. * @param container contains the elements to remove
  11286. */
  11287. removeFromContainer(container: AbstractScene): void;
  11288. /**
  11289. * Serializes the component data to the specified json object
  11290. * @param serializationObject The object to serialize to
  11291. */
  11292. serialize(serializationObject: any): void;
  11293. }
  11294. /**
  11295. * Strong typing of a Mesh related stage step action
  11296. */
  11297. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11298. /**
  11299. * Strong typing of a Evaluate Sub Mesh related stage step action
  11300. */
  11301. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11302. /**
  11303. * Strong typing of a Active Mesh related stage step action
  11304. */
  11305. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11306. /**
  11307. * Strong typing of a Camera related stage step action
  11308. */
  11309. export type CameraStageAction = (camera: Camera) => void;
  11310. /**
  11311. * Strong typing of a Render Target related stage step action
  11312. */
  11313. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11314. /**
  11315. * Strong typing of a RenderingGroup related stage step action
  11316. */
  11317. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11318. /**
  11319. * Strong typing of a Mesh Render related stage step action
  11320. */
  11321. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11322. /**
  11323. * Strong typing of a simple stage step action
  11324. */
  11325. export type SimpleStageAction = () => void;
  11326. /**
  11327. * Strong typing of a render target action.
  11328. */
  11329. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11330. /**
  11331. * Strong typing of a pointer move action.
  11332. */
  11333. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11334. /**
  11335. * Strong typing of a pointer up/down action.
  11336. */
  11337. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11338. /**
  11339. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11340. * @hidden
  11341. */
  11342. export class Stage<T extends Function> extends Array<{
  11343. index: number;
  11344. component: ISceneComponent;
  11345. action: T;
  11346. }> {
  11347. /**
  11348. * Hide ctor from the rest of the world.
  11349. * @param items The items to add.
  11350. */
  11351. private constructor();
  11352. /**
  11353. * Creates a new Stage.
  11354. * @returns A new instance of a Stage
  11355. */
  11356. static Create<T extends Function>(): Stage<T>;
  11357. /**
  11358. * Registers a step in an ordered way in the targeted stage.
  11359. * @param index Defines the position to register the step in
  11360. * @param component Defines the component attached to the step
  11361. * @param action Defines the action to launch during the step
  11362. */
  11363. registerStep(index: number, component: ISceneComponent, action: T): void;
  11364. /**
  11365. * Clears all the steps from the stage.
  11366. */
  11367. clear(): void;
  11368. }
  11369. }
  11370. declare module BABYLON {
  11371. interface Scene {
  11372. /** @hidden */
  11373. _pointerOverSprite: Nullable<Sprite>;
  11374. /** @hidden */
  11375. _pickedDownSprite: Nullable<Sprite>;
  11376. /** @hidden */
  11377. _tempSpritePickingRay: Nullable<Ray>;
  11378. /**
  11379. * All of the sprite managers added to this scene
  11380. * @see http://doc.babylonjs.com/babylon101/sprites
  11381. */
  11382. spriteManagers: Array<ISpriteManager>;
  11383. /**
  11384. * An event triggered when sprites rendering is about to start
  11385. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11386. */
  11387. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11388. /**
  11389. * An event triggered when sprites rendering is done
  11390. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11391. */
  11392. onAfterSpritesRenderingObservable: Observable<Scene>;
  11393. /** @hidden */
  11394. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11395. /** Launch a ray to try to pick a sprite in the scene
  11396. * @param x position on screen
  11397. * @param y position on screen
  11398. * @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
  11399. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11400. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11401. * @returns a PickingInfo
  11402. */
  11403. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11404. /** Use the given ray to pick a sprite in the scene
  11405. * @param ray The ray (in world space) to use to pick meshes
  11406. * @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
  11407. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11408. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11409. * @returns a PickingInfo
  11410. */
  11411. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11412. /**
  11413. * Force the sprite under the pointer
  11414. * @param sprite defines the sprite to use
  11415. */
  11416. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11417. /**
  11418. * Gets the sprite under the pointer
  11419. * @returns a Sprite or null if no sprite is under the pointer
  11420. */
  11421. getPointerOverSprite(): Nullable<Sprite>;
  11422. }
  11423. /**
  11424. * Defines the sprite scene component responsible to manage sprites
  11425. * in a given scene.
  11426. */
  11427. export class SpriteSceneComponent implements ISceneComponent {
  11428. /**
  11429. * The component name helpfull to identify the component in the list of scene components.
  11430. */
  11431. readonly name: string;
  11432. /**
  11433. * The scene the component belongs to.
  11434. */
  11435. scene: Scene;
  11436. /** @hidden */
  11437. private _spritePredicate;
  11438. /**
  11439. * Creates a new instance of the component for the given scene
  11440. * @param scene Defines the scene to register the component in
  11441. */
  11442. constructor(scene: Scene);
  11443. /**
  11444. * Registers the component in a given scene
  11445. */
  11446. register(): void;
  11447. /**
  11448. * Rebuilds the elements related to this component in case of
  11449. * context lost for instance.
  11450. */
  11451. rebuild(): void;
  11452. /**
  11453. * Disposes the component and the associated ressources.
  11454. */
  11455. dispose(): void;
  11456. private _pickSpriteButKeepRay;
  11457. private _pointerMove;
  11458. private _pointerDown;
  11459. private _pointerUp;
  11460. }
  11461. }
  11462. declare module BABYLON {
  11463. /** @hidden */
  11464. export var fogFragmentDeclaration: {
  11465. name: string;
  11466. shader: string;
  11467. };
  11468. }
  11469. declare module BABYLON {
  11470. /** @hidden */
  11471. export var fogFragment: {
  11472. name: string;
  11473. shader: string;
  11474. };
  11475. }
  11476. declare module BABYLON {
  11477. /** @hidden */
  11478. export var spritesPixelShader: {
  11479. name: string;
  11480. shader: string;
  11481. };
  11482. }
  11483. declare module BABYLON {
  11484. /** @hidden */
  11485. export var fogVertexDeclaration: {
  11486. name: string;
  11487. shader: string;
  11488. };
  11489. }
  11490. declare module BABYLON {
  11491. /** @hidden */
  11492. export var spritesVertexShader: {
  11493. name: string;
  11494. shader: string;
  11495. };
  11496. }
  11497. declare module BABYLON {
  11498. /**
  11499. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11500. */
  11501. export interface ISpriteManager extends IDisposable {
  11502. /**
  11503. * Restricts the camera to viewing objects with the same layerMask.
  11504. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11505. */
  11506. layerMask: number;
  11507. /**
  11508. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11509. */
  11510. isPickable: boolean;
  11511. /**
  11512. * Specifies the rendering group id for this mesh (0 by default)
  11513. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11514. */
  11515. renderingGroupId: number;
  11516. /**
  11517. * Defines the list of sprites managed by the manager.
  11518. */
  11519. sprites: Array<Sprite>;
  11520. /**
  11521. * Tests the intersection of a sprite with a specific ray.
  11522. * @param ray The ray we are sending to test the collision
  11523. * @param camera The camera space we are sending rays in
  11524. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11525. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11526. * @returns picking info or null.
  11527. */
  11528. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11529. /**
  11530. * Renders the list of sprites on screen.
  11531. */
  11532. render(): void;
  11533. }
  11534. /**
  11535. * Class used to manage multiple sprites on the same spritesheet
  11536. * @see http://doc.babylonjs.com/babylon101/sprites
  11537. */
  11538. export class SpriteManager implements ISpriteManager {
  11539. /** defines the manager's name */
  11540. name: string;
  11541. /** Gets the list of sprites */
  11542. sprites: Sprite[];
  11543. /** Gets or sets the rendering group id (0 by default) */
  11544. renderingGroupId: number;
  11545. /** Gets or sets camera layer mask */
  11546. layerMask: number;
  11547. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11548. fogEnabled: boolean;
  11549. /** Gets or sets a boolean indicating if the sprites are pickable */
  11550. isPickable: boolean;
  11551. /** Defines the default width of a cell in the spritesheet */
  11552. cellWidth: number;
  11553. /** Defines the default height of a cell in the spritesheet */
  11554. cellHeight: number;
  11555. /**
  11556. * An event triggered when the manager is disposed.
  11557. */
  11558. onDisposeObservable: Observable<SpriteManager>;
  11559. private _onDisposeObserver;
  11560. /**
  11561. * Callback called when the manager is disposed
  11562. */
  11563. onDispose: () => void;
  11564. private _capacity;
  11565. private _spriteTexture;
  11566. private _epsilon;
  11567. private _scene;
  11568. private _vertexData;
  11569. private _buffer;
  11570. private _vertexBuffers;
  11571. private _indexBuffer;
  11572. private _effectBase;
  11573. private _effectFog;
  11574. /**
  11575. * Gets or sets the spritesheet texture
  11576. */
  11577. texture: Texture;
  11578. /**
  11579. * Creates a new sprite manager
  11580. * @param name defines the manager's name
  11581. * @param imgUrl defines the sprite sheet url
  11582. * @param capacity defines the maximum allowed number of sprites
  11583. * @param cellSize defines the size of a sprite cell
  11584. * @param scene defines the hosting scene
  11585. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11586. * @param samplingMode defines the smapling mode to use with spritesheet
  11587. */
  11588. constructor(
  11589. /** defines the manager's name */
  11590. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11591. private _appendSpriteVertex;
  11592. /**
  11593. * Intersects the sprites with a ray
  11594. * @param ray defines the ray to intersect with
  11595. * @param camera defines the current active camera
  11596. * @param predicate defines a predicate used to select candidate sprites
  11597. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11598. * @returns null if no hit or a PickingInfo
  11599. */
  11600. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11601. /**
  11602. * Render all child sprites
  11603. */
  11604. render(): void;
  11605. /**
  11606. * Release associated resources
  11607. */
  11608. dispose(): void;
  11609. }
  11610. }
  11611. declare module BABYLON {
  11612. /**
  11613. * Class used to represent a sprite
  11614. * @see http://doc.babylonjs.com/babylon101/sprites
  11615. */
  11616. export class Sprite {
  11617. /** defines the name */
  11618. name: string;
  11619. /** Gets or sets the current world position */
  11620. position: Vector3;
  11621. /** Gets or sets the main color */
  11622. color: Color4;
  11623. /** Gets or sets the width */
  11624. width: number;
  11625. /** Gets or sets the height */
  11626. height: number;
  11627. /** Gets or sets rotation angle */
  11628. angle: number;
  11629. /** Gets or sets the cell index in the sprite sheet */
  11630. cellIndex: number;
  11631. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11632. invertU: number;
  11633. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11634. invertV: number;
  11635. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11636. disposeWhenFinishedAnimating: boolean;
  11637. /** Gets the list of attached animations */
  11638. animations: Animation[];
  11639. /** Gets or sets a boolean indicating if the sprite can be picked */
  11640. isPickable: boolean;
  11641. /**
  11642. * Gets or sets the associated action manager
  11643. */
  11644. actionManager: Nullable<ActionManager>;
  11645. private _animationStarted;
  11646. private _loopAnimation;
  11647. private _fromIndex;
  11648. private _toIndex;
  11649. private _delay;
  11650. private _direction;
  11651. private _manager;
  11652. private _time;
  11653. private _onAnimationEnd;
  11654. /**
  11655. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11656. */
  11657. isVisible: boolean;
  11658. /**
  11659. * Gets or sets the sprite size
  11660. */
  11661. size: number;
  11662. /**
  11663. * Creates a new Sprite
  11664. * @param name defines the name
  11665. * @param manager defines the manager
  11666. */
  11667. constructor(
  11668. /** defines the name */
  11669. name: string, manager: ISpriteManager);
  11670. /**
  11671. * Starts an animation
  11672. * @param from defines the initial key
  11673. * @param to defines the end key
  11674. * @param loop defines if the animation must loop
  11675. * @param delay defines the start delay (in ms)
  11676. * @param onAnimationEnd defines a callback to call when animation ends
  11677. */
  11678. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11679. /** Stops current animation (if any) */
  11680. stopAnimation(): void;
  11681. /** @hidden */
  11682. _animate(deltaTime: number): void;
  11683. /** Release associated resources */
  11684. dispose(): void;
  11685. }
  11686. }
  11687. declare module BABYLON {
  11688. /**
  11689. * Information about the result of picking within a scene
  11690. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11691. */
  11692. export class PickingInfo {
  11693. /** @hidden */
  11694. _pickingUnavailable: boolean;
  11695. /**
  11696. * If the pick collided with an object
  11697. */
  11698. hit: boolean;
  11699. /**
  11700. * Distance away where the pick collided
  11701. */
  11702. distance: number;
  11703. /**
  11704. * The location of pick collision
  11705. */
  11706. pickedPoint: Nullable<Vector3>;
  11707. /**
  11708. * The mesh corresponding the the pick collision
  11709. */
  11710. pickedMesh: Nullable<AbstractMesh>;
  11711. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11712. bu: number;
  11713. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11714. bv: number;
  11715. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11716. faceId: number;
  11717. /** Id of the the submesh that was picked */
  11718. subMeshId: number;
  11719. /** If a sprite was picked, this will be the sprite the pick collided with */
  11720. pickedSprite: Nullable<Sprite>;
  11721. /**
  11722. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11723. */
  11724. originMesh: Nullable<AbstractMesh>;
  11725. /**
  11726. * The ray that was used to perform the picking.
  11727. */
  11728. ray: Nullable<Ray>;
  11729. /**
  11730. * Gets the normal correspodning to the face the pick collided with
  11731. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11732. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11733. * @returns The normal correspodning to the face the pick collided with
  11734. */
  11735. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11736. /**
  11737. * Gets the texture coordinates of where the pick occured
  11738. * @returns the vector containing the coordnates of the texture
  11739. */
  11740. getTextureCoordinates(): Nullable<Vector2>;
  11741. }
  11742. }
  11743. declare module BABYLON {
  11744. /**
  11745. * Gather the list of pointer event types as constants.
  11746. */
  11747. export class PointerEventTypes {
  11748. /**
  11749. * 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.
  11750. */
  11751. static readonly POINTERDOWN: number;
  11752. /**
  11753. * The pointerup event is fired when a pointer is no longer active.
  11754. */
  11755. static readonly POINTERUP: number;
  11756. /**
  11757. * The pointermove event is fired when a pointer changes coordinates.
  11758. */
  11759. static readonly POINTERMOVE: number;
  11760. /**
  11761. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11762. */
  11763. static readonly POINTERWHEEL: number;
  11764. /**
  11765. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11766. */
  11767. static readonly POINTERPICK: number;
  11768. /**
  11769. * The pointertap event is fired when a the object has been touched and released without drag.
  11770. */
  11771. static readonly POINTERTAP: number;
  11772. /**
  11773. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11774. */
  11775. static readonly POINTERDOUBLETAP: number;
  11776. }
  11777. /**
  11778. * Base class of pointer info types.
  11779. */
  11780. export class PointerInfoBase {
  11781. /**
  11782. * Defines the type of event (PointerEventTypes)
  11783. */
  11784. type: number;
  11785. /**
  11786. * Defines the related dom event
  11787. */
  11788. event: PointerEvent | MouseWheelEvent;
  11789. /**
  11790. * Instantiates the base class of pointers info.
  11791. * @param type Defines the type of event (PointerEventTypes)
  11792. * @param event Defines the related dom event
  11793. */
  11794. constructor(
  11795. /**
  11796. * Defines the type of event (PointerEventTypes)
  11797. */
  11798. type: number,
  11799. /**
  11800. * Defines the related dom event
  11801. */
  11802. event: PointerEvent | MouseWheelEvent);
  11803. }
  11804. /**
  11805. * This class is used to store pointer related info for the onPrePointerObservable event.
  11806. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11807. */
  11808. export class PointerInfoPre extends PointerInfoBase {
  11809. /**
  11810. * Ray from a pointer if availible (eg. 6dof controller)
  11811. */
  11812. ray: Nullable<Ray>;
  11813. /**
  11814. * Defines the local position of the pointer on the canvas.
  11815. */
  11816. localPosition: Vector2;
  11817. /**
  11818. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11819. */
  11820. skipOnPointerObservable: boolean;
  11821. /**
  11822. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11823. * @param type Defines the type of event (PointerEventTypes)
  11824. * @param event Defines the related dom event
  11825. * @param localX Defines the local x coordinates of the pointer when the event occured
  11826. * @param localY Defines the local y coordinates of the pointer when the event occured
  11827. */
  11828. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11829. }
  11830. /**
  11831. * This type contains all the data related to a pointer event in Babylon.js.
  11832. * 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.
  11833. */
  11834. export class PointerInfo extends PointerInfoBase {
  11835. /**
  11836. * Defines the picking info associated to the info (if any)\
  11837. */
  11838. pickInfo: Nullable<PickingInfo>;
  11839. /**
  11840. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11841. * @param type Defines the type of event (PointerEventTypes)
  11842. * @param event Defines the related dom event
  11843. * @param pickInfo Defines the picking info associated to the info (if any)\
  11844. */
  11845. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11846. /**
  11847. * Defines the picking info associated to the info (if any)\
  11848. */
  11849. pickInfo: Nullable<PickingInfo>);
  11850. }
  11851. }
  11852. declare module BABYLON {
  11853. /**
  11854. * Manage the mouse inputs to control the movement of a free camera.
  11855. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11856. */
  11857. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11858. /**
  11859. * Define if touch is enabled in the mouse input
  11860. */
  11861. touchEnabled: boolean;
  11862. /**
  11863. * Defines the camera the input is attached to.
  11864. */
  11865. camera: FreeCamera;
  11866. /**
  11867. * Defines the buttons associated with the input to handle camera move.
  11868. */
  11869. buttons: number[];
  11870. /**
  11871. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11872. */
  11873. angularSensibility: number;
  11874. private _pointerInput;
  11875. private _onMouseMove;
  11876. private _observer;
  11877. private previousPosition;
  11878. /**
  11879. * Manage the mouse inputs to control the movement of a free camera.
  11880. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11881. * @param touchEnabled Defines if touch is enabled or not
  11882. */
  11883. constructor(
  11884. /**
  11885. * Define if touch is enabled in the mouse input
  11886. */
  11887. touchEnabled?: boolean);
  11888. /**
  11889. * Attach the input controls to a specific dom element to get the input from.
  11890. * @param element Defines the element the controls should be listened from
  11891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11892. */
  11893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11894. /**
  11895. * Detach the current controls from the specified dom element.
  11896. * @param element Defines the element to stop listening the inputs from
  11897. */
  11898. detachControl(element: Nullable<HTMLElement>): void;
  11899. /**
  11900. * Gets the class name of the current intput.
  11901. * @returns the class name
  11902. */
  11903. getClassName(): string;
  11904. /**
  11905. * Get the friendly name associated with the input class.
  11906. * @returns the input friendly name
  11907. */
  11908. getSimpleName(): string;
  11909. }
  11910. }
  11911. declare module BABYLON {
  11912. /**
  11913. * Manage the touch inputs to control the movement of a free camera.
  11914. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11915. */
  11916. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11917. /**
  11918. * Defines the camera the input is attached to.
  11919. */
  11920. camera: FreeCamera;
  11921. /**
  11922. * Defines the touch sensibility for rotation.
  11923. * The higher the faster.
  11924. */
  11925. touchAngularSensibility: number;
  11926. /**
  11927. * Defines the touch sensibility for move.
  11928. * The higher the faster.
  11929. */
  11930. touchMoveSensibility: number;
  11931. private _offsetX;
  11932. private _offsetY;
  11933. private _pointerPressed;
  11934. private _pointerInput;
  11935. private _observer;
  11936. private _onLostFocus;
  11937. /**
  11938. * Attach the input controls to a specific dom element to get the input from.
  11939. * @param element Defines the element the controls should be listened from
  11940. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11941. */
  11942. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11943. /**
  11944. * Detach the current controls from the specified dom element.
  11945. * @param element Defines the element to stop listening the inputs from
  11946. */
  11947. detachControl(element: Nullable<HTMLElement>): void;
  11948. /**
  11949. * Update the current camera state depending on the inputs that have been used this frame.
  11950. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11951. */
  11952. checkInputs(): void;
  11953. /**
  11954. * Gets the class name of the current intput.
  11955. * @returns the class name
  11956. */
  11957. getClassName(): string;
  11958. /**
  11959. * Get the friendly name associated with the input class.
  11960. * @returns the input friendly name
  11961. */
  11962. getSimpleName(): string;
  11963. }
  11964. }
  11965. declare module BABYLON {
  11966. /**
  11967. * Default Inputs manager for the FreeCamera.
  11968. * It groups all the default supported inputs for ease of use.
  11969. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11970. */
  11971. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11972. /**
  11973. * Instantiates a new FreeCameraInputsManager.
  11974. * @param camera Defines the camera the inputs belong to
  11975. */
  11976. constructor(camera: FreeCamera);
  11977. /**
  11978. * Add keyboard input support to the input manager.
  11979. * @returns the current input manager
  11980. */
  11981. addKeyboard(): FreeCameraInputsManager;
  11982. /**
  11983. * Add mouse input support to the input manager.
  11984. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11985. * @returns the current input manager
  11986. */
  11987. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11988. /**
  11989. * Add touch input support to the input manager.
  11990. * @returns the current input manager
  11991. */
  11992. addTouch(): FreeCameraInputsManager;
  11993. }
  11994. }
  11995. declare module BABYLON {
  11996. /**
  11997. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11998. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11999. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12000. */
  12001. export class FreeCamera extends TargetCamera {
  12002. /**
  12003. * Define the collision ellipsoid of the camera.
  12004. * This is helpful to simulate a camera body like the player body around the camera
  12005. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12006. */
  12007. ellipsoid: Vector3;
  12008. /**
  12009. * Define an offset for the position of the ellipsoid around the camera.
  12010. * This can be helpful to determine the center of the body near the gravity center of the body
  12011. * instead of its head.
  12012. */
  12013. ellipsoidOffset: Vector3;
  12014. /**
  12015. * Enable or disable collisions of the camera with the rest of the scene objects.
  12016. */
  12017. checkCollisions: boolean;
  12018. /**
  12019. * Enable or disable gravity on the camera.
  12020. */
  12021. applyGravity: boolean;
  12022. /**
  12023. * Define the input manager associated to the camera.
  12024. */
  12025. inputs: FreeCameraInputsManager;
  12026. /**
  12027. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12028. * Higher values reduce sensitivity.
  12029. */
  12030. /**
  12031. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12032. * Higher values reduce sensitivity.
  12033. */
  12034. angularSensibility: number;
  12035. /**
  12036. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12037. */
  12038. keysUp: number[];
  12039. /**
  12040. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12041. */
  12042. keysDown: number[];
  12043. /**
  12044. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12045. */
  12046. keysLeft: number[];
  12047. /**
  12048. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12049. */
  12050. keysRight: number[];
  12051. /**
  12052. * Event raised when the camera collide with a mesh in the scene.
  12053. */
  12054. onCollide: (collidedMesh: AbstractMesh) => void;
  12055. private _collider;
  12056. private _needMoveForGravity;
  12057. private _oldPosition;
  12058. private _diffPosition;
  12059. private _newPosition;
  12060. /** @hidden */
  12061. _localDirection: Vector3;
  12062. /** @hidden */
  12063. _transformedDirection: Vector3;
  12064. /**
  12065. * Instantiates a Free Camera.
  12066. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12067. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12068. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12069. * @param name Define the name of the camera in the scene
  12070. * @param position Define the start position of the camera in the scene
  12071. * @param scene Define the scene the camera belongs to
  12072. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12073. */
  12074. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12075. /**
  12076. * Attached controls to the current camera.
  12077. * @param element Defines the element the controls should be listened from
  12078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12079. */
  12080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12081. /**
  12082. * Detach the current controls from the camera.
  12083. * The camera will stop reacting to inputs.
  12084. * @param element Defines the element to stop listening the inputs from
  12085. */
  12086. detachControl(element: HTMLElement): void;
  12087. private _collisionMask;
  12088. /**
  12089. * Define a collision mask to limit the list of object the camera can collide with
  12090. */
  12091. collisionMask: number;
  12092. /** @hidden */
  12093. _collideWithWorld(displacement: Vector3): void;
  12094. private _onCollisionPositionChange;
  12095. /** @hidden */
  12096. _checkInputs(): void;
  12097. /** @hidden */
  12098. _decideIfNeedsToMove(): boolean;
  12099. /** @hidden */
  12100. _updatePosition(): void;
  12101. /**
  12102. * Destroy the camera and release the current resources hold by it.
  12103. */
  12104. dispose(): void;
  12105. /**
  12106. * Gets the current object class name.
  12107. * @return the class name
  12108. */
  12109. getClassName(): string;
  12110. }
  12111. }
  12112. declare module BABYLON {
  12113. /**
  12114. * Represents a gamepad control stick position
  12115. */
  12116. export class StickValues {
  12117. /**
  12118. * The x component of the control stick
  12119. */
  12120. x: number;
  12121. /**
  12122. * The y component of the control stick
  12123. */
  12124. y: number;
  12125. /**
  12126. * Initializes the gamepad x and y control stick values
  12127. * @param x The x component of the gamepad control stick value
  12128. * @param y The y component of the gamepad control stick value
  12129. */
  12130. constructor(
  12131. /**
  12132. * The x component of the control stick
  12133. */
  12134. x: number,
  12135. /**
  12136. * The y component of the control stick
  12137. */
  12138. y: number);
  12139. }
  12140. /**
  12141. * An interface which manages callbacks for gamepad button changes
  12142. */
  12143. export interface GamepadButtonChanges {
  12144. /**
  12145. * Called when a gamepad has been changed
  12146. */
  12147. changed: boolean;
  12148. /**
  12149. * Called when a gamepad press event has been triggered
  12150. */
  12151. pressChanged: boolean;
  12152. /**
  12153. * Called when a touch event has been triggered
  12154. */
  12155. touchChanged: boolean;
  12156. /**
  12157. * Called when a value has changed
  12158. */
  12159. valueChanged: boolean;
  12160. }
  12161. /**
  12162. * Represents a gamepad
  12163. */
  12164. export class Gamepad {
  12165. /**
  12166. * The id of the gamepad
  12167. */
  12168. id: string;
  12169. /**
  12170. * The index of the gamepad
  12171. */
  12172. index: number;
  12173. /**
  12174. * The browser gamepad
  12175. */
  12176. browserGamepad: any;
  12177. /**
  12178. * Specifies what type of gamepad this represents
  12179. */
  12180. type: number;
  12181. private _leftStick;
  12182. private _rightStick;
  12183. /** @hidden */
  12184. _isConnected: boolean;
  12185. private _leftStickAxisX;
  12186. private _leftStickAxisY;
  12187. private _rightStickAxisX;
  12188. private _rightStickAxisY;
  12189. /**
  12190. * Triggered when the left control stick has been changed
  12191. */
  12192. private _onleftstickchanged;
  12193. /**
  12194. * Triggered when the right control stick has been changed
  12195. */
  12196. private _onrightstickchanged;
  12197. /**
  12198. * Represents a gamepad controller
  12199. */
  12200. static GAMEPAD: number;
  12201. /**
  12202. * Represents a generic controller
  12203. */
  12204. static GENERIC: number;
  12205. /**
  12206. * Represents an XBox controller
  12207. */
  12208. static XBOX: number;
  12209. /**
  12210. * Represents a pose-enabled controller
  12211. */
  12212. static POSE_ENABLED: number;
  12213. /**
  12214. * Specifies whether the left control stick should be Y-inverted
  12215. */
  12216. protected _invertLeftStickY: boolean;
  12217. /**
  12218. * Specifies if the gamepad has been connected
  12219. */
  12220. readonly isConnected: boolean;
  12221. /**
  12222. * Initializes the gamepad
  12223. * @param id The id of the gamepad
  12224. * @param index The index of the gamepad
  12225. * @param browserGamepad The browser gamepad
  12226. * @param leftStickX The x component of the left joystick
  12227. * @param leftStickY The y component of the left joystick
  12228. * @param rightStickX The x component of the right joystick
  12229. * @param rightStickY The y component of the right joystick
  12230. */
  12231. constructor(
  12232. /**
  12233. * The id of the gamepad
  12234. */
  12235. id: string,
  12236. /**
  12237. * The index of the gamepad
  12238. */
  12239. index: number,
  12240. /**
  12241. * The browser gamepad
  12242. */
  12243. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12244. /**
  12245. * Callback triggered when the left joystick has changed
  12246. * @param callback
  12247. */
  12248. onleftstickchanged(callback: (values: StickValues) => void): void;
  12249. /**
  12250. * Callback triggered when the right joystick has changed
  12251. * @param callback
  12252. */
  12253. onrightstickchanged(callback: (values: StickValues) => void): void;
  12254. /**
  12255. * Gets the left joystick
  12256. */
  12257. /**
  12258. * Sets the left joystick values
  12259. */
  12260. leftStick: StickValues;
  12261. /**
  12262. * Gets the right joystick
  12263. */
  12264. /**
  12265. * Sets the right joystick value
  12266. */
  12267. rightStick: StickValues;
  12268. /**
  12269. * Updates the gamepad joystick positions
  12270. */
  12271. update(): void;
  12272. /**
  12273. * Disposes the gamepad
  12274. */
  12275. dispose(): void;
  12276. }
  12277. /**
  12278. * Represents a generic gamepad
  12279. */
  12280. export class GenericPad extends Gamepad {
  12281. private _buttons;
  12282. private _onbuttondown;
  12283. private _onbuttonup;
  12284. /**
  12285. * Observable triggered when a button has been pressed
  12286. */
  12287. onButtonDownObservable: Observable<number>;
  12288. /**
  12289. * Observable triggered when a button has been released
  12290. */
  12291. onButtonUpObservable: Observable<number>;
  12292. /**
  12293. * Callback triggered when a button has been pressed
  12294. * @param callback Called when a button has been pressed
  12295. */
  12296. onbuttondown(callback: (buttonPressed: number) => void): void;
  12297. /**
  12298. * Callback triggered when a button has been released
  12299. * @param callback Called when a button has been released
  12300. */
  12301. onbuttonup(callback: (buttonReleased: number) => void): void;
  12302. /**
  12303. * Initializes the generic gamepad
  12304. * @param id The id of the generic gamepad
  12305. * @param index The index of the generic gamepad
  12306. * @param browserGamepad The browser gamepad
  12307. */
  12308. constructor(id: string, index: number, browserGamepad: any);
  12309. private _setButtonValue;
  12310. /**
  12311. * Updates the generic gamepad
  12312. */
  12313. update(): void;
  12314. /**
  12315. * Disposes the generic gamepad
  12316. */
  12317. dispose(): void;
  12318. }
  12319. }
  12320. declare module BABYLON {
  12321. /**
  12322. * Defines the types of pose enabled controllers that are supported
  12323. */
  12324. export enum PoseEnabledControllerType {
  12325. /**
  12326. * HTC Vive
  12327. */
  12328. VIVE = 0,
  12329. /**
  12330. * Oculus Rift
  12331. */
  12332. OCULUS = 1,
  12333. /**
  12334. * Windows mixed reality
  12335. */
  12336. WINDOWS = 2,
  12337. /**
  12338. * Samsung gear VR
  12339. */
  12340. GEAR_VR = 3,
  12341. /**
  12342. * Google Daydream
  12343. */
  12344. DAYDREAM = 4,
  12345. /**
  12346. * Generic
  12347. */
  12348. GENERIC = 5
  12349. }
  12350. /**
  12351. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12352. */
  12353. export interface MutableGamepadButton {
  12354. /**
  12355. * Value of the button/trigger
  12356. */
  12357. value: number;
  12358. /**
  12359. * If the button/trigger is currently touched
  12360. */
  12361. touched: boolean;
  12362. /**
  12363. * If the button/trigger is currently pressed
  12364. */
  12365. pressed: boolean;
  12366. }
  12367. /**
  12368. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12369. * @hidden
  12370. */
  12371. export interface ExtendedGamepadButton extends GamepadButton {
  12372. /**
  12373. * If the button/trigger is currently pressed
  12374. */
  12375. readonly pressed: boolean;
  12376. /**
  12377. * If the button/trigger is currently touched
  12378. */
  12379. readonly touched: boolean;
  12380. /**
  12381. * Value of the button/trigger
  12382. */
  12383. readonly value: number;
  12384. }
  12385. /** @hidden */
  12386. export interface _GamePadFactory {
  12387. /**
  12388. * Returns wether or not the current gamepad can be created for this type of controller.
  12389. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12390. * @returns true if it can be created, otherwise false
  12391. */
  12392. canCreate(gamepadInfo: any): boolean;
  12393. /**
  12394. * Creates a new instance of the Gamepad.
  12395. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12396. * @returns the new gamepad instance
  12397. */
  12398. create(gamepadInfo: any): Gamepad;
  12399. }
  12400. /**
  12401. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12402. */
  12403. export class PoseEnabledControllerHelper {
  12404. /** @hidden */
  12405. static _ControllerFactories: _GamePadFactory[];
  12406. /** @hidden */
  12407. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12408. /**
  12409. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12410. * @param vrGamepad the gamepad to initialized
  12411. * @returns a vr controller of the type the gamepad identified as
  12412. */
  12413. static InitiateController(vrGamepad: any): Gamepad;
  12414. }
  12415. /**
  12416. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12417. */
  12418. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12419. private _deviceRoomPosition;
  12420. private _deviceRoomRotationQuaternion;
  12421. /**
  12422. * The device position in babylon space
  12423. */
  12424. devicePosition: Vector3;
  12425. /**
  12426. * The device rotation in babylon space
  12427. */
  12428. deviceRotationQuaternion: Quaternion;
  12429. /**
  12430. * The scale factor of the device in babylon space
  12431. */
  12432. deviceScaleFactor: number;
  12433. /**
  12434. * (Likely devicePosition should be used instead) The device position in its room space
  12435. */
  12436. position: Vector3;
  12437. /**
  12438. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12439. */
  12440. rotationQuaternion: Quaternion;
  12441. /**
  12442. * The type of controller (Eg. Windows mixed reality)
  12443. */
  12444. controllerType: PoseEnabledControllerType;
  12445. protected _calculatedPosition: Vector3;
  12446. private _calculatedRotation;
  12447. /**
  12448. * The raw pose from the device
  12449. */
  12450. rawPose: DevicePose;
  12451. private _trackPosition;
  12452. private _maxRotationDistFromHeadset;
  12453. private _draggedRoomRotation;
  12454. /**
  12455. * @hidden
  12456. */
  12457. _disableTrackPosition(fixedPosition: Vector3): void;
  12458. /**
  12459. * Internal, the mesh attached to the controller
  12460. * @hidden
  12461. */
  12462. _mesh: Nullable<AbstractMesh>;
  12463. private _poseControlledCamera;
  12464. private _leftHandSystemQuaternion;
  12465. /**
  12466. * Internal, matrix used to convert room space to babylon space
  12467. * @hidden
  12468. */
  12469. _deviceToWorld: Matrix;
  12470. /**
  12471. * Node to be used when casting a ray from the controller
  12472. * @hidden
  12473. */
  12474. _pointingPoseNode: Nullable<TransformNode>;
  12475. /**
  12476. * Name of the child mesh that can be used to cast a ray from the controller
  12477. */
  12478. static readonly POINTING_POSE: string;
  12479. /**
  12480. * Creates a new PoseEnabledController from a gamepad
  12481. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12482. */
  12483. constructor(browserGamepad: any);
  12484. private _workingMatrix;
  12485. /**
  12486. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12487. */
  12488. update(): void;
  12489. /**
  12490. * Updates only the pose device and mesh without doing any button event checking
  12491. */
  12492. protected _updatePoseAndMesh(): void;
  12493. /**
  12494. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12495. * @param poseData raw pose fromthe device
  12496. */
  12497. updateFromDevice(poseData: DevicePose): void;
  12498. /**
  12499. * @hidden
  12500. */
  12501. _meshAttachedObservable: Observable<AbstractMesh>;
  12502. /**
  12503. * Attaches a mesh to the controller
  12504. * @param mesh the mesh to be attached
  12505. */
  12506. attachToMesh(mesh: AbstractMesh): void;
  12507. /**
  12508. * Attaches the controllers mesh to a camera
  12509. * @param camera the camera the mesh should be attached to
  12510. */
  12511. attachToPoseControlledCamera(camera: TargetCamera): void;
  12512. /**
  12513. * Disposes of the controller
  12514. */
  12515. dispose(): void;
  12516. /**
  12517. * The mesh that is attached to the controller
  12518. */
  12519. readonly mesh: Nullable<AbstractMesh>;
  12520. /**
  12521. * Gets the ray of the controller in the direction the controller is pointing
  12522. * @param length the length the resulting ray should be
  12523. * @returns a ray in the direction the controller is pointing
  12524. */
  12525. getForwardRay(length?: number): Ray;
  12526. }
  12527. }
  12528. declare module BABYLON {
  12529. /**
  12530. * Defines the WebVRController object that represents controllers tracked in 3D space
  12531. */
  12532. export abstract class WebVRController extends PoseEnabledController {
  12533. /**
  12534. * Internal, the default controller model for the controller
  12535. */
  12536. protected _defaultModel: AbstractMesh;
  12537. /**
  12538. * Fired when the trigger state has changed
  12539. */
  12540. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12541. /**
  12542. * Fired when the main button state has changed
  12543. */
  12544. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12545. /**
  12546. * Fired when the secondary button state has changed
  12547. */
  12548. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12549. /**
  12550. * Fired when the pad state has changed
  12551. */
  12552. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12553. /**
  12554. * Fired when controllers stick values have changed
  12555. */
  12556. onPadValuesChangedObservable: Observable<StickValues>;
  12557. /**
  12558. * Array of button availible on the controller
  12559. */
  12560. protected _buttons: Array<MutableGamepadButton>;
  12561. private _onButtonStateChange;
  12562. /**
  12563. * Fired when a controller button's state has changed
  12564. * @param callback the callback containing the button that was modified
  12565. */
  12566. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12567. /**
  12568. * X and Y axis corrisponding to the controllers joystick
  12569. */
  12570. pad: StickValues;
  12571. /**
  12572. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12573. */
  12574. hand: string;
  12575. /**
  12576. * The default controller model for the controller
  12577. */
  12578. readonly defaultModel: AbstractMesh;
  12579. /**
  12580. * Creates a new WebVRController from a gamepad
  12581. * @param vrGamepad the gamepad that the WebVRController should be created from
  12582. */
  12583. constructor(vrGamepad: any);
  12584. /**
  12585. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12586. */
  12587. update(): void;
  12588. /**
  12589. * Function to be called when a button is modified
  12590. */
  12591. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12592. /**
  12593. * Loads a mesh and attaches it to the controller
  12594. * @param scene the scene the mesh should be added to
  12595. * @param meshLoaded callback for when the mesh has been loaded
  12596. */
  12597. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12598. private _setButtonValue;
  12599. private _changes;
  12600. private _checkChanges;
  12601. /**
  12602. * Disposes of th webVRCOntroller
  12603. */
  12604. dispose(): void;
  12605. }
  12606. }
  12607. declare module BABYLON {
  12608. /**
  12609. * The HemisphericLight simulates the ambient environment light,
  12610. * so the passed direction is the light reflection direction, not the incoming direction.
  12611. */
  12612. export class HemisphericLight extends Light {
  12613. /**
  12614. * The groundColor is the light in the opposite direction to the one specified during creation.
  12615. * 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.
  12616. */
  12617. groundColor: Color3;
  12618. /**
  12619. * The light reflection direction, not the incoming direction.
  12620. */
  12621. direction: Vector3;
  12622. /**
  12623. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12624. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12625. * The HemisphericLight can't cast shadows.
  12626. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12627. * @param name The friendly name of the light
  12628. * @param direction The direction of the light reflection
  12629. * @param scene The scene the light belongs to
  12630. */
  12631. constructor(name: string, direction: Vector3, scene: Scene);
  12632. protected _buildUniformLayout(): void;
  12633. /**
  12634. * Returns the string "HemisphericLight".
  12635. * @return The class name
  12636. */
  12637. getClassName(): string;
  12638. /**
  12639. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12640. * Returns the updated direction.
  12641. * @param target The target the direction should point to
  12642. * @return The computed direction
  12643. */
  12644. setDirectionToTarget(target: Vector3): Vector3;
  12645. /**
  12646. * Returns the shadow generator associated to the light.
  12647. * @returns Always null for hemispheric lights because it does not support shadows.
  12648. */
  12649. getShadowGenerator(): Nullable<IShadowGenerator>;
  12650. /**
  12651. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12652. * @param effect The effect to update
  12653. * @param lightIndex The index of the light in the effect to update
  12654. * @returns The hemispheric light
  12655. */
  12656. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12657. /**
  12658. * Computes the world matrix of the node
  12659. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12660. * @param useWasUpdatedFlag defines a reserved property
  12661. * @returns the world matrix
  12662. */
  12663. computeWorldMatrix(): Matrix;
  12664. /**
  12665. * Returns the integer 3.
  12666. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12667. */
  12668. getTypeID(): number;
  12669. /**
  12670. * Prepares the list of defines specific to the light type.
  12671. * @param defines the list of defines
  12672. * @param lightIndex defines the index of the light for the effect
  12673. */
  12674. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12675. }
  12676. }
  12677. declare module BABYLON {
  12678. /**
  12679. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12680. * IMPORTANT!! The data is right-hand data.
  12681. * @export
  12682. * @interface DevicePose
  12683. */
  12684. export interface DevicePose {
  12685. /**
  12686. * The position of the device, values in array are [x,y,z].
  12687. */
  12688. readonly position: Nullable<Float32Array>;
  12689. /**
  12690. * The linearVelocity of the device, values in array are [x,y,z].
  12691. */
  12692. readonly linearVelocity: Nullable<Float32Array>;
  12693. /**
  12694. * The linearAcceleration of the device, values in array are [x,y,z].
  12695. */
  12696. readonly linearAcceleration: Nullable<Float32Array>;
  12697. /**
  12698. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  12699. */
  12700. readonly orientation: Nullable<Float32Array>;
  12701. /**
  12702. * The angularVelocity of the device, values in array are [x,y,z].
  12703. */
  12704. readonly angularVelocity: Nullable<Float32Array>;
  12705. /**
  12706. * The angularAcceleration of the device, values in array are [x,y,z].
  12707. */
  12708. readonly angularAcceleration: Nullable<Float32Array>;
  12709. }
  12710. /**
  12711. * Interface representing a pose controlled object in Babylon.
  12712. * A pose controlled object has both regular pose values as well as pose values
  12713. * from an external device such as a VR head mounted display
  12714. */
  12715. export interface PoseControlled {
  12716. /**
  12717. * The position of the object in babylon space.
  12718. */
  12719. position: Vector3;
  12720. /**
  12721. * The rotation quaternion of the object in babylon space.
  12722. */
  12723. rotationQuaternion: Quaternion;
  12724. /**
  12725. * The position of the device in babylon space.
  12726. */
  12727. devicePosition?: Vector3;
  12728. /**
  12729. * The rotation quaternion of the device in babylon space.
  12730. */
  12731. deviceRotationQuaternion: Quaternion;
  12732. /**
  12733. * The raw pose coming from the device.
  12734. */
  12735. rawPose: Nullable<DevicePose>;
  12736. /**
  12737. * The scale of the device to be used when translating from device space to babylon space.
  12738. */
  12739. deviceScaleFactor: number;
  12740. /**
  12741. * Updates the poseControlled values based on the input device pose.
  12742. * @param poseData the pose data to update the object with
  12743. */
  12744. updateFromDevice(poseData: DevicePose): void;
  12745. }
  12746. /**
  12747. * Set of options to customize the webVRCamera
  12748. */
  12749. export interface WebVROptions {
  12750. /**
  12751. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  12752. */
  12753. trackPosition?: boolean;
  12754. /**
  12755. * Sets the scale of the vrDevice in babylon space. (default: 1)
  12756. */
  12757. positionScale?: number;
  12758. /**
  12759. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  12760. */
  12761. displayName?: string;
  12762. /**
  12763. * Should the native controller meshes be initialized. (default: true)
  12764. */
  12765. controllerMeshes?: boolean;
  12766. /**
  12767. * Creating a default HemiLight only on controllers. (default: true)
  12768. */
  12769. defaultLightingOnControllers?: boolean;
  12770. /**
  12771. * If you don't want to use the default VR button of the helper. (default: false)
  12772. */
  12773. useCustomVRButton?: boolean;
  12774. /**
  12775. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  12776. */
  12777. customVRButton?: HTMLButtonElement;
  12778. /**
  12779. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  12780. */
  12781. rayLength?: number;
  12782. /**
  12783. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  12784. */
  12785. defaultHeight?: number;
  12786. }
  12787. /**
  12788. * This represents a WebVR camera.
  12789. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  12790. * @example http://doc.babylonjs.com/how_to/webvr_camera
  12791. */
  12792. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  12793. private webVROptions;
  12794. /**
  12795. * @hidden
  12796. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  12797. */
  12798. _vrDevice: any;
  12799. /**
  12800. * The rawPose of the vrDevice.
  12801. */
  12802. rawPose: Nullable<DevicePose>;
  12803. private _onVREnabled;
  12804. private _specsVersion;
  12805. private _attached;
  12806. private _frameData;
  12807. protected _descendants: Array<Node>;
  12808. private _deviceRoomPosition;
  12809. /** @hidden */
  12810. _deviceRoomRotationQuaternion: Quaternion;
  12811. private _standingMatrix;
  12812. /**
  12813. * Represents device position in babylon space.
  12814. */
  12815. devicePosition: Vector3;
  12816. /**
  12817. * Represents device rotation in babylon space.
  12818. */
  12819. deviceRotationQuaternion: Quaternion;
  12820. /**
  12821. * The scale of the device to be used when translating from device space to babylon space.
  12822. */
  12823. deviceScaleFactor: number;
  12824. private _deviceToWorld;
  12825. private _worldToDevice;
  12826. /**
  12827. * References to the webVR controllers for the vrDevice.
  12828. */
  12829. controllers: Array<WebVRController>;
  12830. /**
  12831. * Emits an event when a controller is attached.
  12832. */
  12833. onControllersAttachedObservable: Observable<WebVRController[]>;
  12834. /**
  12835. * Emits an event when a controller's mesh has been loaded;
  12836. */
  12837. onControllerMeshLoadedObservable: Observable<WebVRController>;
  12838. /**
  12839. * Emits an event when the HMD's pose has been updated.
  12840. */
  12841. onPoseUpdatedFromDeviceObservable: Observable<any>;
  12842. private _poseSet;
  12843. /**
  12844. * If the rig cameras be used as parent instead of this camera.
  12845. */
  12846. rigParenting: boolean;
  12847. private _lightOnControllers;
  12848. private _defaultHeight?;
  12849. /**
  12850. * Instantiates a WebVRFreeCamera.
  12851. * @param name The name of the WebVRFreeCamera
  12852. * @param position The starting anchor position for the camera
  12853. * @param scene The scene the camera belongs to
  12854. * @param webVROptions a set of customizable options for the webVRCamera
  12855. */
  12856. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  12857. /**
  12858. * Gets the device distance from the ground in meters.
  12859. * @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.
  12860. */
  12861. deviceDistanceToRoomGround(): number;
  12862. /**
  12863. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  12864. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  12865. */
  12866. useStandingMatrix(callback?: (bool: boolean) => void): void;
  12867. /**
  12868. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  12869. * @returns A promise with a boolean set to if the standing matrix is supported.
  12870. */
  12871. useStandingMatrixAsync(): Promise<boolean>;
  12872. /**
  12873. * Disposes the camera
  12874. */
  12875. dispose(): void;
  12876. /**
  12877. * Gets a vrController by name.
  12878. * @param name The name of the controller to retreive
  12879. * @returns the controller matching the name specified or null if not found
  12880. */
  12881. getControllerByName(name: string): Nullable<WebVRController>;
  12882. private _leftController;
  12883. /**
  12884. * The controller corrisponding to the users left hand.
  12885. */
  12886. readonly leftController: Nullable<WebVRController>;
  12887. private _rightController;
  12888. /**
  12889. * The controller corrisponding to the users right hand.
  12890. */
  12891. readonly rightController: Nullable<WebVRController>;
  12892. /**
  12893. * Casts a ray forward from the vrCamera's gaze.
  12894. * @param length Length of the ray (default: 100)
  12895. * @returns the ray corrisponding to the gaze
  12896. */
  12897. getForwardRay(length?: number): Ray;
  12898. /**
  12899. * @hidden
  12900. * Updates the camera based on device's frame data
  12901. */
  12902. _checkInputs(): void;
  12903. /**
  12904. * Updates the poseControlled values based on the input device pose.
  12905. * @param poseData Pose coming from the device
  12906. */
  12907. updateFromDevice(poseData: DevicePose): void;
  12908. private _htmlElementAttached;
  12909. private _detachIfAttached;
  12910. /**
  12911. * WebVR's attach control will start broadcasting frames to the device.
  12912. * Note that in certain browsers (chrome for example) this function must be called
  12913. * within a user-interaction callback. Example:
  12914. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  12915. *
  12916. * @param element html element to attach the vrDevice to
  12917. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  12918. */
  12919. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12920. /**
  12921. * Detaches the camera from the html element and disables VR
  12922. *
  12923. * @param element html element to detach from
  12924. */
  12925. detachControl(element: HTMLElement): void;
  12926. /**
  12927. * @returns the name of this class
  12928. */
  12929. getClassName(): string;
  12930. /**
  12931. * Calls resetPose on the vrDisplay
  12932. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  12933. */
  12934. resetToCurrentRotation(): void;
  12935. /**
  12936. * @hidden
  12937. * Updates the rig cameras (left and right eye)
  12938. */
  12939. _updateRigCameras(): void;
  12940. private _workingVector;
  12941. private _oneVector;
  12942. private _workingMatrix;
  12943. private updateCacheCalled;
  12944. private _correctPositionIfNotTrackPosition;
  12945. /**
  12946. * @hidden
  12947. * Updates the cached values of the camera
  12948. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  12949. */
  12950. _updateCache(ignoreParentClass?: boolean): void;
  12951. /**
  12952. * @hidden
  12953. * Get current device position in babylon world
  12954. */
  12955. _computeDevicePosition(): void;
  12956. /**
  12957. * Updates the current device position and rotation in the babylon world
  12958. */
  12959. update(): void;
  12960. /**
  12961. * @hidden
  12962. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  12963. * @returns an identity matrix
  12964. */
  12965. _getViewMatrix(): Matrix;
  12966. private _tmpMatrix;
  12967. /**
  12968. * This function is called by the two RIG cameras.
  12969. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  12970. * @hidden
  12971. */
  12972. _getWebVRViewMatrix(): Matrix;
  12973. /** @hidden */
  12974. _getWebVRProjectionMatrix(): Matrix;
  12975. private _onGamepadConnectedObserver;
  12976. private _onGamepadDisconnectedObserver;
  12977. private _updateCacheWhenTrackingDisabledObserver;
  12978. /**
  12979. * Initializes the controllers and their meshes
  12980. */
  12981. initControllers(): void;
  12982. }
  12983. }
  12984. declare module BABYLON {
  12985. /**
  12986. * Size options for a post process
  12987. */
  12988. export type PostProcessOptions = {
  12989. width: number;
  12990. height: number;
  12991. };
  12992. /**
  12993. * PostProcess can be used to apply a shader to a texture after it has been rendered
  12994. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  12995. */
  12996. export class PostProcess {
  12997. /** Name of the PostProcess. */
  12998. name: string;
  12999. /**
  13000. * Gets or sets the unique id of the post process
  13001. */
  13002. uniqueId: number;
  13003. /**
  13004. * Width of the texture to apply the post process on
  13005. */
  13006. width: number;
  13007. /**
  13008. * Height of the texture to apply the post process on
  13009. */
  13010. height: number;
  13011. /**
  13012. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13013. * @hidden
  13014. */
  13015. _outputTexture: Nullable<InternalTexture>;
  13016. /**
  13017. * Sampling mode used by the shader
  13018. * See https://doc.babylonjs.com/classes/3.1/texture
  13019. */
  13020. renderTargetSamplingMode: number;
  13021. /**
  13022. * Clear color to use when screen clearing
  13023. */
  13024. clearColor: Color4;
  13025. /**
  13026. * If the buffer needs to be cleared before applying the post process. (default: true)
  13027. * Should be set to false if shader will overwrite all previous pixels.
  13028. */
  13029. autoClear: boolean;
  13030. /**
  13031. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13032. */
  13033. alphaMode: number;
  13034. /**
  13035. * Sets the setAlphaBlendConstants of the babylon engine
  13036. */
  13037. alphaConstants: Color4;
  13038. /**
  13039. * Animations to be used for the post processing
  13040. */
  13041. animations: Animation[];
  13042. /**
  13043. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13044. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13045. */
  13046. enablePixelPerfectMode: boolean;
  13047. /**
  13048. * Force the postprocess to be applied without taking in account viewport
  13049. */
  13050. forceFullscreenViewport: boolean;
  13051. /**
  13052. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13053. *
  13054. * | Value | Type | Description |
  13055. * | ----- | ----------------------------------- | ----------- |
  13056. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13057. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13058. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13059. *
  13060. */
  13061. scaleMode: number;
  13062. /**
  13063. * Force textures to be a power of two (default: false)
  13064. */
  13065. alwaysForcePOT: boolean;
  13066. private _samples;
  13067. /**
  13068. * Number of sample textures (default: 1)
  13069. */
  13070. samples: number;
  13071. /**
  13072. * Modify the scale of the post process to be the same as the viewport (default: false)
  13073. */
  13074. adaptScaleToCurrentViewport: boolean;
  13075. private _camera;
  13076. private _scene;
  13077. private _engine;
  13078. private _options;
  13079. private _reusable;
  13080. private _textureType;
  13081. /**
  13082. * Smart array of input and output textures for the post process.
  13083. * @hidden
  13084. */
  13085. _textures: SmartArray<InternalTexture>;
  13086. /**
  13087. * The index in _textures that corresponds to the output texture.
  13088. * @hidden
  13089. */
  13090. _currentRenderTextureInd: number;
  13091. private _effect;
  13092. private _samplers;
  13093. private _fragmentUrl;
  13094. private _vertexUrl;
  13095. private _parameters;
  13096. private _scaleRatio;
  13097. protected _indexParameters: any;
  13098. private _shareOutputWithPostProcess;
  13099. private _texelSize;
  13100. private _forcedOutputTexture;
  13101. /**
  13102. * Returns the fragment url or shader name used in the post process.
  13103. * @returns the fragment url or name in the shader store.
  13104. */
  13105. getEffectName(): string;
  13106. /**
  13107. * An event triggered when the postprocess is activated.
  13108. */
  13109. onActivateObservable: Observable<Camera>;
  13110. private _onActivateObserver;
  13111. /**
  13112. * A function that is added to the onActivateObservable
  13113. */
  13114. onActivate: Nullable<(camera: Camera) => void>;
  13115. /**
  13116. * An event triggered when the postprocess changes its size.
  13117. */
  13118. onSizeChangedObservable: Observable<PostProcess>;
  13119. private _onSizeChangedObserver;
  13120. /**
  13121. * A function that is added to the onSizeChangedObservable
  13122. */
  13123. onSizeChanged: (postProcess: PostProcess) => void;
  13124. /**
  13125. * An event triggered when the postprocess applies its effect.
  13126. */
  13127. onApplyObservable: Observable<Effect>;
  13128. private _onApplyObserver;
  13129. /**
  13130. * A function that is added to the onApplyObservable
  13131. */
  13132. onApply: (effect: Effect) => void;
  13133. /**
  13134. * An event triggered before rendering the postprocess
  13135. */
  13136. onBeforeRenderObservable: Observable<Effect>;
  13137. private _onBeforeRenderObserver;
  13138. /**
  13139. * A function that is added to the onBeforeRenderObservable
  13140. */
  13141. onBeforeRender: (effect: Effect) => void;
  13142. /**
  13143. * An event triggered after rendering the postprocess
  13144. */
  13145. onAfterRenderObservable: Observable<Effect>;
  13146. private _onAfterRenderObserver;
  13147. /**
  13148. * A function that is added to the onAfterRenderObservable
  13149. */
  13150. onAfterRender: (efect: Effect) => void;
  13151. /**
  13152. * 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
  13153. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13154. */
  13155. inputTexture: InternalTexture;
  13156. /**
  13157. * Gets the camera which post process is applied to.
  13158. * @returns The camera the post process is applied to.
  13159. */
  13160. getCamera(): Camera;
  13161. /**
  13162. * Gets the texel size of the postprocess.
  13163. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13164. */
  13165. readonly texelSize: Vector2;
  13166. /**
  13167. * Creates a new instance PostProcess
  13168. * @param name The name of the PostProcess.
  13169. * @param fragmentUrl The url of the fragment shader to be used.
  13170. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13171. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13172. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13173. * @param camera The camera to apply the render pass to.
  13174. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13175. * @param engine The engine which the post process will be applied. (default: current engine)
  13176. * @param reusable If the post process can be reused on the same frame. (default: false)
  13177. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13178. * @param textureType Type of textures used when performing the post process. (default: 0)
  13179. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13180. * @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
  13181. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13182. */
  13183. constructor(
  13184. /** Name of the PostProcess. */
  13185. 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);
  13186. /**
  13187. * Gets a string idenfifying the name of the class
  13188. * @returns "PostProcess" string
  13189. */
  13190. getClassName(): string;
  13191. /**
  13192. * Gets the engine which this post process belongs to.
  13193. * @returns The engine the post process was enabled with.
  13194. */
  13195. getEngine(): Engine;
  13196. /**
  13197. * The effect that is created when initializing the post process.
  13198. * @returns The created effect corrisponding the the postprocess.
  13199. */
  13200. getEffect(): Effect;
  13201. /**
  13202. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13203. * @param postProcess The post process to share the output with.
  13204. * @returns This post process.
  13205. */
  13206. shareOutputWith(postProcess: PostProcess): PostProcess;
  13207. /**
  13208. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13209. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13210. */
  13211. useOwnOutput(): void;
  13212. /**
  13213. * Updates the effect with the current post process compile time values and recompiles the shader.
  13214. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13215. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13216. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13217. * @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
  13218. * @param onCompiled Called when the shader has been compiled.
  13219. * @param onError Called if there is an error when compiling a shader.
  13220. */
  13221. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13222. /**
  13223. * The post process is reusable if it can be used multiple times within one frame.
  13224. * @returns If the post process is reusable
  13225. */
  13226. isReusable(): boolean;
  13227. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13228. markTextureDirty(): void;
  13229. /**
  13230. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13231. * 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.
  13232. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13233. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13234. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13235. * @returns The target texture that was bound to be written to.
  13236. */
  13237. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13238. /**
  13239. * If the post process is supported.
  13240. */
  13241. readonly isSupported: boolean;
  13242. /**
  13243. * The aspect ratio of the output texture.
  13244. */
  13245. readonly aspectRatio: number;
  13246. /**
  13247. * Get a value indicating if the post-process is ready to be used
  13248. * @returns true if the post-process is ready (shader is compiled)
  13249. */
  13250. isReady(): boolean;
  13251. /**
  13252. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13253. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13254. */
  13255. apply(): Nullable<Effect>;
  13256. private _disposeTextures;
  13257. /**
  13258. * Disposes the post process.
  13259. * @param camera The camera to dispose the post process on.
  13260. */
  13261. dispose(camera?: Camera): void;
  13262. }
  13263. }
  13264. declare module BABYLON {
  13265. /**
  13266. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13267. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13268. */
  13269. export class PostProcessManager {
  13270. private _scene;
  13271. private _indexBuffer;
  13272. private _vertexBuffers;
  13273. /**
  13274. * Creates a new instance PostProcess
  13275. * @param scene The scene that the post process is associated with.
  13276. */
  13277. constructor(scene: Scene);
  13278. private _prepareBuffers;
  13279. private _buildIndexBuffer;
  13280. /**
  13281. * Rebuilds the vertex buffers of the manager.
  13282. * @hidden
  13283. */
  13284. _rebuild(): void;
  13285. /**
  13286. * Prepares a frame to be run through a post process.
  13287. * @param sourceTexture The input texture to the post procesess. (default: null)
  13288. * @param postProcesses An array of post processes to be run. (default: null)
  13289. * @returns True if the post processes were able to be run.
  13290. * @hidden
  13291. */
  13292. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13293. /**
  13294. * Manually render a set of post processes to a texture.
  13295. * @param postProcesses An array of post processes to be run.
  13296. * @param targetTexture The target texture to render to.
  13297. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13298. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13299. * @param lodLevel defines which lod of the texture to render to
  13300. */
  13301. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13302. /**
  13303. * Finalize the result of the output of the postprocesses.
  13304. * @param doNotPresent If true the result will not be displayed to the screen.
  13305. * @param targetTexture The target texture to render to.
  13306. * @param faceIndex The index of the face to bind the target texture to.
  13307. * @param postProcesses The array of post processes to render.
  13308. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13309. * @hidden
  13310. */
  13311. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13312. /**
  13313. * Disposes of the post process manager.
  13314. */
  13315. dispose(): void;
  13316. }
  13317. }
  13318. declare module BABYLON {
  13319. interface AbstractScene {
  13320. /**
  13321. * The list of layers (background and foreground) of the scene
  13322. */
  13323. layers: Array<Layer>;
  13324. }
  13325. /**
  13326. * Defines the layer scene component responsible to manage any layers
  13327. * in a given scene.
  13328. */
  13329. export class LayerSceneComponent implements ISceneComponent {
  13330. /**
  13331. * The component name helpfull to identify the component in the list of scene components.
  13332. */
  13333. readonly name: string;
  13334. /**
  13335. * The scene the component belongs to.
  13336. */
  13337. scene: Scene;
  13338. private _engine;
  13339. /**
  13340. * Creates a new instance of the component for the given scene
  13341. * @param scene Defines the scene to register the component in
  13342. */
  13343. constructor(scene: Scene);
  13344. /**
  13345. * Registers the component in a given scene
  13346. */
  13347. register(): void;
  13348. /**
  13349. * Rebuilds the elements related to this component in case of
  13350. * context lost for instance.
  13351. */
  13352. rebuild(): void;
  13353. /**
  13354. * Disposes the component and the associated ressources.
  13355. */
  13356. dispose(): void;
  13357. private _draw;
  13358. private _drawCameraPredicate;
  13359. private _drawCameraBackground;
  13360. private _drawCameraForeground;
  13361. private _drawRenderTargetPredicate;
  13362. private _drawRenderTargetBackground;
  13363. private _drawRenderTargetForeground;
  13364. }
  13365. }
  13366. declare module BABYLON {
  13367. /** @hidden */
  13368. export var layerPixelShader: {
  13369. name: string;
  13370. shader: string;
  13371. };
  13372. }
  13373. declare module BABYLON {
  13374. /** @hidden */
  13375. export var layerVertexShader: {
  13376. name: string;
  13377. shader: string;
  13378. };
  13379. }
  13380. declare module BABYLON {
  13381. /**
  13382. * This represents a full screen 2d layer.
  13383. * This can be useful to display a picture in the background of your scene for instance.
  13384. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13385. */
  13386. export class Layer {
  13387. /**
  13388. * Define the name of the layer.
  13389. */
  13390. name: string;
  13391. /**
  13392. * Define the texture the layer should display.
  13393. */
  13394. texture: Nullable<Texture>;
  13395. /**
  13396. * Is the layer in background or foreground.
  13397. */
  13398. isBackground: boolean;
  13399. /**
  13400. * Define the color of the layer (instead of texture).
  13401. */
  13402. color: Color4;
  13403. /**
  13404. * Define the scale of the layer in order to zoom in out of the texture.
  13405. */
  13406. scale: Vector2;
  13407. /**
  13408. * Define an offset for the layer in order to shift the texture.
  13409. */
  13410. offset: Vector2;
  13411. /**
  13412. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13413. */
  13414. alphaBlendingMode: number;
  13415. /**
  13416. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13417. * Alpha test will not mix with the background color in case of transparency.
  13418. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13419. */
  13420. alphaTest: boolean;
  13421. /**
  13422. * Define a mask to restrict the layer to only some of the scene cameras.
  13423. */
  13424. layerMask: number;
  13425. /**
  13426. * Define the list of render target the layer is visible into.
  13427. */
  13428. renderTargetTextures: RenderTargetTexture[];
  13429. /**
  13430. * Define if the layer is only used in renderTarget or if it also
  13431. * renders in the main frame buffer of the canvas.
  13432. */
  13433. renderOnlyInRenderTargetTextures: boolean;
  13434. private _scene;
  13435. private _vertexBuffers;
  13436. private _indexBuffer;
  13437. private _effect;
  13438. private _alphaTestEffect;
  13439. /**
  13440. * An event triggered when the layer is disposed.
  13441. */
  13442. onDisposeObservable: Observable<Layer>;
  13443. private _onDisposeObserver;
  13444. /**
  13445. * Back compatibility with callback before the onDisposeObservable existed.
  13446. * The set callback will be triggered when the layer has been disposed.
  13447. */
  13448. onDispose: () => void;
  13449. /**
  13450. * An event triggered before rendering the scene
  13451. */
  13452. onBeforeRenderObservable: Observable<Layer>;
  13453. private _onBeforeRenderObserver;
  13454. /**
  13455. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13456. * The set callback will be triggered just before rendering the layer.
  13457. */
  13458. onBeforeRender: () => void;
  13459. /**
  13460. * An event triggered after rendering the scene
  13461. */
  13462. onAfterRenderObservable: Observable<Layer>;
  13463. private _onAfterRenderObserver;
  13464. /**
  13465. * Back compatibility with callback before the onAfterRenderObservable existed.
  13466. * The set callback will be triggered just after rendering the layer.
  13467. */
  13468. onAfterRender: () => void;
  13469. /**
  13470. * Instantiates a new layer.
  13471. * This represents a full screen 2d layer.
  13472. * This can be useful to display a picture in the background of your scene for instance.
  13473. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13474. * @param name Define the name of the layer in the scene
  13475. * @param imgUrl Define the url of the texture to display in the layer
  13476. * @param scene Define the scene the layer belongs to
  13477. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13478. * @param color Defines a color for the layer
  13479. */
  13480. constructor(
  13481. /**
  13482. * Define the name of the layer.
  13483. */
  13484. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13485. private _createIndexBuffer;
  13486. /** @hidden */
  13487. _rebuild(): void;
  13488. /**
  13489. * Renders the layer in the scene.
  13490. */
  13491. render(): void;
  13492. /**
  13493. * Disposes and releases the associated ressources.
  13494. */
  13495. dispose(): void;
  13496. }
  13497. }
  13498. declare module BABYLON {
  13499. interface AbstractScene {
  13500. /**
  13501. * The list of procedural textures added to the scene
  13502. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13503. */
  13504. proceduralTextures: Array<ProceduralTexture>;
  13505. }
  13506. /**
  13507. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13508. * in a given scene.
  13509. */
  13510. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13511. /**
  13512. * The component name helpfull to identify the component in the list of scene components.
  13513. */
  13514. readonly name: string;
  13515. /**
  13516. * The scene the component belongs to.
  13517. */
  13518. scene: Scene;
  13519. /**
  13520. * Creates a new instance of the component for the given scene
  13521. * @param scene Defines the scene to register the component in
  13522. */
  13523. constructor(scene: Scene);
  13524. /**
  13525. * Registers the component in a given scene
  13526. */
  13527. register(): void;
  13528. /**
  13529. * Rebuilds the elements related to this component in case of
  13530. * context lost for instance.
  13531. */
  13532. rebuild(): void;
  13533. /**
  13534. * Disposes the component and the associated ressources.
  13535. */
  13536. dispose(): void;
  13537. private _beforeClear;
  13538. }
  13539. }
  13540. declare module BABYLON {
  13541. /** @hidden */
  13542. export var proceduralVertexShader: {
  13543. name: string;
  13544. shader: string;
  13545. };
  13546. }
  13547. declare module BABYLON {
  13548. /**
  13549. * 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.
  13550. * This is the base class of any Procedural texture and contains most of the shareable code.
  13551. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13552. */
  13553. export class ProceduralTexture extends Texture {
  13554. isCube: boolean;
  13555. /**
  13556. * Define if the texture is enabled or not (disabled texture will not render)
  13557. */
  13558. isEnabled: boolean;
  13559. /**
  13560. * Define if the texture must be cleared before rendering (default is true)
  13561. */
  13562. autoClear: boolean;
  13563. /**
  13564. * Callback called when the texture is generated
  13565. */
  13566. onGenerated: () => void;
  13567. /**
  13568. * Event raised when the texture is generated
  13569. */
  13570. onGeneratedObservable: Observable<ProceduralTexture>;
  13571. /** @hidden */
  13572. _generateMipMaps: boolean;
  13573. /** @hidden **/
  13574. _effect: Effect;
  13575. /** @hidden */
  13576. _textures: {
  13577. [key: string]: Texture;
  13578. };
  13579. private _size;
  13580. private _currentRefreshId;
  13581. private _refreshRate;
  13582. private _vertexBuffers;
  13583. private _indexBuffer;
  13584. private _uniforms;
  13585. private _samplers;
  13586. private _fragment;
  13587. private _floats;
  13588. private _ints;
  13589. private _floatsArrays;
  13590. private _colors3;
  13591. private _colors4;
  13592. private _vectors2;
  13593. private _vectors3;
  13594. private _matrices;
  13595. private _fallbackTexture;
  13596. private _fallbackTextureUsed;
  13597. private _engine;
  13598. private _cachedDefines;
  13599. private _contentUpdateId;
  13600. private _contentData;
  13601. /**
  13602. * Instantiates a new procedural texture.
  13603. * 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.
  13604. * This is the base class of any Procedural texture and contains most of the shareable code.
  13605. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13606. * @param name Define the name of the texture
  13607. * @param size Define the size of the texture to create
  13608. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13609. * @param scene Define the scene the texture belongs to
  13610. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13611. * @param generateMipMaps Define if the texture should creates mip maps or not
  13612. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13613. */
  13614. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13615. /**
  13616. * The effect that is created when initializing the post process.
  13617. * @returns The created effect corrisponding the the postprocess.
  13618. */
  13619. getEffect(): Effect;
  13620. /**
  13621. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13622. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13623. */
  13624. getContent(): Nullable<ArrayBufferView>;
  13625. private _createIndexBuffer;
  13626. /** @hidden */
  13627. _rebuild(): void;
  13628. /**
  13629. * Resets the texture in order to recreate its associated resources.
  13630. * This can be called in case of context loss
  13631. */
  13632. reset(): void;
  13633. protected _getDefines(): string;
  13634. /**
  13635. * Is the texture ready to be used ? (rendered at least once)
  13636. * @returns true if ready, otherwise, false.
  13637. */
  13638. isReady(): boolean;
  13639. /**
  13640. * Resets the refresh counter of the texture and start bak from scratch.
  13641. * Could be useful to regenerate the texture if it is setup to render only once.
  13642. */
  13643. resetRefreshCounter(): void;
  13644. /**
  13645. * Set the fragment shader to use in order to render the texture.
  13646. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13647. */
  13648. setFragment(fragment: any): void;
  13649. /**
  13650. * Define the refresh rate of the texture or the rendering frequency.
  13651. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13652. */
  13653. refreshRate: number;
  13654. /** @hidden */
  13655. _shouldRender(): boolean;
  13656. /**
  13657. * Get the size the texture is rendering at.
  13658. * @returns the size (texture is always squared)
  13659. */
  13660. getRenderSize(): number;
  13661. /**
  13662. * Resize the texture to new value.
  13663. * @param size Define the new size the texture should have
  13664. * @param generateMipMaps Define whether the new texture should create mip maps
  13665. */
  13666. resize(size: number, generateMipMaps: boolean): void;
  13667. private _checkUniform;
  13668. /**
  13669. * Set a texture in the shader program used to render.
  13670. * @param name Define the name of the uniform samplers as defined in the shader
  13671. * @param texture Define the texture to bind to this sampler
  13672. * @return the texture itself allowing "fluent" like uniform updates
  13673. */
  13674. setTexture(name: string, texture: Texture): ProceduralTexture;
  13675. /**
  13676. * Set a float in the shader.
  13677. * @param name Define the name of the uniform as defined in the shader
  13678. * @param value Define the value to give to the uniform
  13679. * @return the texture itself allowing "fluent" like uniform updates
  13680. */
  13681. setFloat(name: string, value: number): ProceduralTexture;
  13682. /**
  13683. * Set a int in the shader.
  13684. * @param name Define the name of the uniform as defined in the shader
  13685. * @param value Define the value to give to the uniform
  13686. * @return the texture itself allowing "fluent" like uniform updates
  13687. */
  13688. setInt(name: string, value: number): ProceduralTexture;
  13689. /**
  13690. * Set an array of floats in the shader.
  13691. * @param name Define the name of the uniform as defined in the shader
  13692. * @param value Define the value to give to the uniform
  13693. * @return the texture itself allowing "fluent" like uniform updates
  13694. */
  13695. setFloats(name: string, value: number[]): ProceduralTexture;
  13696. /**
  13697. * Set a vec3 in the shader from a Color3.
  13698. * @param name Define the name of the uniform as defined in the shader
  13699. * @param value Define the value to give to the uniform
  13700. * @return the texture itself allowing "fluent" like uniform updates
  13701. */
  13702. setColor3(name: string, value: Color3): ProceduralTexture;
  13703. /**
  13704. * Set a vec4 in the shader from a Color4.
  13705. * @param name Define the name of the uniform as defined in the shader
  13706. * @param value Define the value to give to the uniform
  13707. * @return the texture itself allowing "fluent" like uniform updates
  13708. */
  13709. setColor4(name: string, value: Color4): ProceduralTexture;
  13710. /**
  13711. * Set a vec2 in the shader from a Vector2.
  13712. * @param name Define the name of the uniform as defined in the shader
  13713. * @param value Define the value to give to the uniform
  13714. * @return the texture itself allowing "fluent" like uniform updates
  13715. */
  13716. setVector2(name: string, value: Vector2): ProceduralTexture;
  13717. /**
  13718. * Set a vec3 in the shader from a Vector3.
  13719. * @param name Define the name of the uniform as defined in the shader
  13720. * @param value Define the value to give to the uniform
  13721. * @return the texture itself allowing "fluent" like uniform updates
  13722. */
  13723. setVector3(name: string, value: Vector3): ProceduralTexture;
  13724. /**
  13725. * Set a mat4 in the shader from a MAtrix.
  13726. * @param name Define the name of the uniform as defined in the shader
  13727. * @param value Define the value to give to the uniform
  13728. * @return the texture itself allowing "fluent" like uniform updates
  13729. */
  13730. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13731. /**
  13732. * Render the texture to its associated render target.
  13733. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  13734. */
  13735. render(useCameraPostProcess?: boolean): void;
  13736. /**
  13737. * Clone the texture.
  13738. * @returns the cloned texture
  13739. */
  13740. clone(): ProceduralTexture;
  13741. /**
  13742. * Dispose the texture and release its asoociated resources.
  13743. */
  13744. dispose(): void;
  13745. }
  13746. }
  13747. declare module BABYLON {
  13748. /**
  13749. * This represents the base class for particle system in Babylon.
  13750. * 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.
  13751. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13752. * @example https://doc.babylonjs.com/babylon101/particles
  13753. */
  13754. export class BaseParticleSystem {
  13755. /**
  13756. * Source color is added to the destination color without alpha affecting the result
  13757. */
  13758. static BLENDMODE_ONEONE: number;
  13759. /**
  13760. * Blend current color and particle color using particle’s alpha
  13761. */
  13762. static BLENDMODE_STANDARD: number;
  13763. /**
  13764. * Add current color and particle color multiplied by particle’s alpha
  13765. */
  13766. static BLENDMODE_ADD: number;
  13767. /**
  13768. * Multiply current color with particle color
  13769. */
  13770. static BLENDMODE_MULTIPLY: number;
  13771. /**
  13772. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  13773. */
  13774. static BLENDMODE_MULTIPLYADD: number;
  13775. /**
  13776. * List of animations used by the particle system.
  13777. */
  13778. animations: Animation[];
  13779. /**
  13780. * The id of the Particle system.
  13781. */
  13782. id: string;
  13783. /**
  13784. * The friendly name of the Particle system.
  13785. */
  13786. name: string;
  13787. /**
  13788. * The rendering group used by the Particle system to chose when to render.
  13789. */
  13790. renderingGroupId: number;
  13791. /**
  13792. * The emitter represents the Mesh or position we are attaching the particle system to.
  13793. */
  13794. emitter: Nullable<AbstractMesh | Vector3>;
  13795. /**
  13796. * The maximum number of particles to emit per frame
  13797. */
  13798. emitRate: number;
  13799. /**
  13800. * If you want to launch only a few particles at once, that can be done, as well.
  13801. */
  13802. manualEmitCount: number;
  13803. /**
  13804. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13805. */
  13806. updateSpeed: number;
  13807. /**
  13808. * The amount of time the particle system is running (depends of the overall update speed).
  13809. */
  13810. targetStopDuration: number;
  13811. /**
  13812. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13813. */
  13814. disposeOnStop: boolean;
  13815. /**
  13816. * Minimum power of emitting particles.
  13817. */
  13818. minEmitPower: number;
  13819. /**
  13820. * Maximum power of emitting particles.
  13821. */
  13822. maxEmitPower: number;
  13823. /**
  13824. * Minimum life time of emitting particles.
  13825. */
  13826. minLifeTime: number;
  13827. /**
  13828. * Maximum life time of emitting particles.
  13829. */
  13830. maxLifeTime: number;
  13831. /**
  13832. * Minimum Size of emitting particles.
  13833. */
  13834. minSize: number;
  13835. /**
  13836. * Maximum Size of emitting particles.
  13837. */
  13838. maxSize: number;
  13839. /**
  13840. * Minimum scale of emitting particles on X axis.
  13841. */
  13842. minScaleX: number;
  13843. /**
  13844. * Maximum scale of emitting particles on X axis.
  13845. */
  13846. maxScaleX: number;
  13847. /**
  13848. * Minimum scale of emitting particles on Y axis.
  13849. */
  13850. minScaleY: number;
  13851. /**
  13852. * Maximum scale of emitting particles on Y axis.
  13853. */
  13854. maxScaleY: number;
  13855. /**
  13856. * Gets or sets the minimal initial rotation in radians.
  13857. */
  13858. minInitialRotation: number;
  13859. /**
  13860. * Gets or sets the maximal initial rotation in radians.
  13861. */
  13862. maxInitialRotation: number;
  13863. /**
  13864. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13865. */
  13866. minAngularSpeed: number;
  13867. /**
  13868. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13869. */
  13870. maxAngularSpeed: number;
  13871. /**
  13872. * The texture used to render each particle. (this can be a spritesheet)
  13873. */
  13874. particleTexture: Nullable<Texture>;
  13875. /**
  13876. * The layer mask we are rendering the particles through.
  13877. */
  13878. layerMask: number;
  13879. /**
  13880. * This can help using your own shader to render the particle system.
  13881. * The according effect will be created
  13882. */
  13883. customShader: any;
  13884. /**
  13885. * By default particle system starts as soon as they are created. This prevents the
  13886. * automatic start to happen and let you decide when to start emitting particles.
  13887. */
  13888. preventAutoStart: boolean;
  13889. private _noiseTexture;
  13890. /**
  13891. * Gets or sets a texture used to add random noise to particle positions
  13892. */
  13893. noiseTexture: Nullable<ProceduralTexture>;
  13894. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13895. noiseStrength: Vector3;
  13896. /**
  13897. * Callback triggered when the particle animation is ending.
  13898. */
  13899. onAnimationEnd: Nullable<() => void>;
  13900. /**
  13901. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  13902. */
  13903. blendMode: number;
  13904. /**
  13905. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  13906. * to override the particles.
  13907. */
  13908. forceDepthWrite: boolean;
  13909. /** 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 */
  13910. preWarmCycles: number;
  13911. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  13912. preWarmStepOffset: number;
  13913. /**
  13914. * 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)
  13915. */
  13916. spriteCellChangeSpeed: number;
  13917. /**
  13918. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13919. */
  13920. startSpriteCellID: number;
  13921. /**
  13922. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13923. */
  13924. endSpriteCellID: number;
  13925. /**
  13926. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13927. */
  13928. spriteCellWidth: number;
  13929. /**
  13930. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13931. */
  13932. spriteCellHeight: number;
  13933. /**
  13934. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13935. */
  13936. spriteRandomStartCell: boolean;
  13937. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13938. translationPivot: Vector2;
  13939. /** @hidden */
  13940. protected _isAnimationSheetEnabled: boolean;
  13941. /**
  13942. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13943. */
  13944. beginAnimationOnStart: boolean;
  13945. /**
  13946. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13947. */
  13948. beginAnimationFrom: number;
  13949. /**
  13950. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13951. */
  13952. beginAnimationTo: number;
  13953. /**
  13954. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13955. */
  13956. beginAnimationLoop: boolean;
  13957. /**
  13958. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  13959. */
  13960. isAnimationSheetEnabled: boolean;
  13961. /**
  13962. * Get hosting scene
  13963. * @returns the scene
  13964. */
  13965. getScene(): Scene;
  13966. /**
  13967. * You can use gravity if you want to give an orientation to your particles.
  13968. */
  13969. gravity: Vector3;
  13970. protected _colorGradients: Nullable<Array<ColorGradient>>;
  13971. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  13972. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  13973. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  13974. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  13975. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  13976. protected _dragGradients: Nullable<Array<FactorGradient>>;
  13977. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  13978. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  13979. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  13980. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  13981. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  13982. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  13983. /**
  13984. * Defines the delay in milliseconds before starting the system (0 by default)
  13985. */
  13986. startDelay: number;
  13987. /**
  13988. * Gets the current list of drag gradients.
  13989. * You must use addDragGradient and removeDragGradient to udpate this list
  13990. * @returns the list of drag gradients
  13991. */
  13992. getDragGradients(): Nullable<Array<FactorGradient>>;
  13993. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13994. limitVelocityDamping: number;
  13995. /**
  13996. * Gets the current list of limit velocity gradients.
  13997. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13998. * @returns the list of limit velocity gradients
  13999. */
  14000. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14001. /**
  14002. * Gets the current list of color gradients.
  14003. * You must use addColorGradient and removeColorGradient to udpate this list
  14004. * @returns the list of color gradients
  14005. */
  14006. getColorGradients(): Nullable<Array<ColorGradient>>;
  14007. /**
  14008. * Gets the current list of size gradients.
  14009. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14010. * @returns the list of size gradients
  14011. */
  14012. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14013. /**
  14014. * Gets the current list of color remap gradients.
  14015. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14016. * @returns the list of color remap gradients
  14017. */
  14018. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14019. /**
  14020. * Gets the current list of alpha remap gradients.
  14021. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14022. * @returns the list of alpha remap gradients
  14023. */
  14024. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14025. /**
  14026. * Gets the current list of life time gradients.
  14027. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14028. * @returns the list of life time gradients
  14029. */
  14030. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14031. /**
  14032. * Gets the current list of angular speed gradients.
  14033. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14034. * @returns the list of angular speed gradients
  14035. */
  14036. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14037. /**
  14038. * Gets the current list of velocity gradients.
  14039. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14040. * @returns the list of velocity gradients
  14041. */
  14042. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14043. /**
  14044. * Gets the current list of start size gradients.
  14045. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14046. * @returns the list of start size gradients
  14047. */
  14048. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14049. /**
  14050. * Gets the current list of emit rate gradients.
  14051. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14052. * @returns the list of emit rate gradients
  14053. */
  14054. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14055. /**
  14056. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14057. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14058. */
  14059. direction1: Vector3;
  14060. /**
  14061. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14062. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14063. */
  14064. direction2: Vector3;
  14065. /**
  14066. * 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.
  14067. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14068. */
  14069. minEmitBox: Vector3;
  14070. /**
  14071. * 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.
  14072. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14073. */
  14074. maxEmitBox: Vector3;
  14075. /**
  14076. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14077. */
  14078. color1: Color4;
  14079. /**
  14080. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14081. */
  14082. color2: Color4;
  14083. /**
  14084. * Color the particle will have at the end of its lifetime
  14085. */
  14086. colorDead: Color4;
  14087. /**
  14088. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14089. */
  14090. textureMask: Color4;
  14091. /**
  14092. * The particle emitter type defines the emitter used by the particle system.
  14093. * It can be for example box, sphere, or cone...
  14094. */
  14095. particleEmitterType: IParticleEmitterType;
  14096. /** @hidden */
  14097. _isSubEmitter: boolean;
  14098. /**
  14099. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14100. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14101. */
  14102. billboardMode: number;
  14103. protected _isBillboardBased: boolean;
  14104. /**
  14105. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14106. */
  14107. isBillboardBased: boolean;
  14108. /**
  14109. * The scene the particle system belongs to.
  14110. */
  14111. protected _scene: Scene;
  14112. /**
  14113. * Local cache of defines for image processing.
  14114. */
  14115. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14116. /**
  14117. * Default configuration related to image processing available in the standard Material.
  14118. */
  14119. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14120. /**
  14121. * Gets the image processing configuration used either in this material.
  14122. */
  14123. /**
  14124. * Sets the Default image processing configuration used either in the this material.
  14125. *
  14126. * If sets to null, the scene one is in use.
  14127. */
  14128. imageProcessingConfiguration: ImageProcessingConfiguration;
  14129. /**
  14130. * Attaches a new image processing configuration to the Standard Material.
  14131. * @param configuration
  14132. */
  14133. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14134. /** @hidden */
  14135. protected _reset(): void;
  14136. /** @hidden */
  14137. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14138. /**
  14139. * Instantiates a particle system.
  14140. * 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.
  14141. * @param name The name of the particle system
  14142. */
  14143. constructor(name: string);
  14144. /**
  14145. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14146. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14147. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14148. * @returns the emitter
  14149. */
  14150. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14151. /**
  14152. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14153. * @param radius The radius of the hemisphere to emit from
  14154. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14155. * @returns the emitter
  14156. */
  14157. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14158. /**
  14159. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14160. * @param radius The radius of the sphere to emit from
  14161. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14162. * @returns the emitter
  14163. */
  14164. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14165. /**
  14166. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14167. * @param radius The radius of the sphere to emit from
  14168. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14169. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14170. * @returns the emitter
  14171. */
  14172. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14173. /**
  14174. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14175. * @param radius The radius of the emission cylinder
  14176. * @param height The height of the emission cylinder
  14177. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14178. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14179. * @returns the emitter
  14180. */
  14181. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14182. /**
  14183. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14184. * @param radius The radius of the cylinder to emit from
  14185. * @param height The height of the emission cylinder
  14186. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14187. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14188. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14189. * @returns the emitter
  14190. */
  14191. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14192. /**
  14193. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14194. * @param radius The radius of the cone to emit from
  14195. * @param angle The base angle of the cone
  14196. * @returns the emitter
  14197. */
  14198. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14199. /**
  14200. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14201. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14202. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14203. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14204. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14205. * @returns the emitter
  14206. */
  14207. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14208. }
  14209. }
  14210. declare module BABYLON {
  14211. /**
  14212. * Type of sub emitter
  14213. */
  14214. export enum SubEmitterType {
  14215. /**
  14216. * Attached to the particle over it's lifetime
  14217. */
  14218. ATTACHED = 0,
  14219. /**
  14220. * Created when the particle dies
  14221. */
  14222. END = 1
  14223. }
  14224. /**
  14225. * Sub emitter class used to emit particles from an existing particle
  14226. */
  14227. export class SubEmitter {
  14228. /**
  14229. * the particle system to be used by the sub emitter
  14230. */
  14231. particleSystem: ParticleSystem;
  14232. /**
  14233. * Type of the submitter (Default: END)
  14234. */
  14235. type: SubEmitterType;
  14236. /**
  14237. * 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)
  14238. * Note: This only is supported when using an emitter of type Mesh
  14239. */
  14240. inheritDirection: boolean;
  14241. /**
  14242. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14243. */
  14244. inheritedVelocityAmount: number;
  14245. /**
  14246. * Creates a sub emitter
  14247. * @param particleSystem the particle system to be used by the sub emitter
  14248. */
  14249. constructor(
  14250. /**
  14251. * the particle system to be used by the sub emitter
  14252. */
  14253. particleSystem: ParticleSystem);
  14254. /**
  14255. * Clones the sub emitter
  14256. * @returns the cloned sub emitter
  14257. */
  14258. clone(): SubEmitter;
  14259. /**
  14260. * Serialize current object to a JSON object
  14261. * @returns the serialized object
  14262. */
  14263. serialize(): any;
  14264. /** @hidden */
  14265. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14266. /**
  14267. * Creates a new SubEmitter from a serialized JSON version
  14268. * @param serializationObject defines the JSON object to read from
  14269. * @param scene defines the hosting scene
  14270. * @param rootUrl defines the rootUrl for data loading
  14271. * @returns a new SubEmitter
  14272. */
  14273. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14274. /** Release associated resources */
  14275. dispose(): void;
  14276. }
  14277. }
  14278. declare module BABYLON {
  14279. /** @hidden */
  14280. export var clipPlaneFragmentDeclaration: {
  14281. name: string;
  14282. shader: string;
  14283. };
  14284. }
  14285. declare module BABYLON {
  14286. /** @hidden */
  14287. export var imageProcessingDeclaration: {
  14288. name: string;
  14289. shader: string;
  14290. };
  14291. }
  14292. declare module BABYLON {
  14293. /** @hidden */
  14294. export var imageProcessingFunctions: {
  14295. name: string;
  14296. shader: string;
  14297. };
  14298. }
  14299. declare module BABYLON {
  14300. /** @hidden */
  14301. export var clipPlaneFragment: {
  14302. name: string;
  14303. shader: string;
  14304. };
  14305. }
  14306. declare module BABYLON {
  14307. /** @hidden */
  14308. export var particlesPixelShader: {
  14309. name: string;
  14310. shader: string;
  14311. };
  14312. }
  14313. declare module BABYLON {
  14314. /** @hidden */
  14315. export var clipPlaneVertexDeclaration: {
  14316. name: string;
  14317. shader: string;
  14318. };
  14319. }
  14320. declare module BABYLON {
  14321. /** @hidden */
  14322. export var clipPlaneVertex: {
  14323. name: string;
  14324. shader: string;
  14325. };
  14326. }
  14327. declare module BABYLON {
  14328. /** @hidden */
  14329. export var particlesVertexShader: {
  14330. name: string;
  14331. shader: string;
  14332. };
  14333. }
  14334. declare module BABYLON {
  14335. /**
  14336. * This represents a particle system in Babylon.
  14337. * 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.
  14338. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14339. * @example https://doc.babylonjs.com/babylon101/particles
  14340. */
  14341. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14342. /**
  14343. * Billboard mode will only apply to Y axis
  14344. */
  14345. static readonly BILLBOARDMODE_Y: number;
  14346. /**
  14347. * Billboard mode will apply to all axes
  14348. */
  14349. static readonly BILLBOARDMODE_ALL: number;
  14350. /**
  14351. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14352. */
  14353. static readonly BILLBOARDMODE_STRETCHED: number;
  14354. /**
  14355. * This function can be defined to provide custom update for active particles.
  14356. * This function will be called instead of regular update (age, position, color, etc.).
  14357. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14358. */
  14359. updateFunction: (particles: Particle[]) => void;
  14360. private _emitterWorldMatrix;
  14361. /**
  14362. * This function can be defined to specify initial direction for every new particle.
  14363. * It by default use the emitterType defined function
  14364. */
  14365. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14366. /**
  14367. * This function can be defined to specify initial position for every new particle.
  14368. * It by default use the emitterType defined function
  14369. */
  14370. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14371. /**
  14372. * @hidden
  14373. */
  14374. _inheritedVelocityOffset: Vector3;
  14375. /**
  14376. * An event triggered when the system is disposed
  14377. */
  14378. onDisposeObservable: Observable<ParticleSystem>;
  14379. private _onDisposeObserver;
  14380. /**
  14381. * Sets a callback that will be triggered when the system is disposed
  14382. */
  14383. onDispose: () => void;
  14384. private _particles;
  14385. private _epsilon;
  14386. private _capacity;
  14387. private _stockParticles;
  14388. private _newPartsExcess;
  14389. private _vertexData;
  14390. private _vertexBuffer;
  14391. private _vertexBuffers;
  14392. private _spriteBuffer;
  14393. private _indexBuffer;
  14394. private _effect;
  14395. private _customEffect;
  14396. private _cachedDefines;
  14397. private _scaledColorStep;
  14398. private _colorDiff;
  14399. private _scaledDirection;
  14400. private _scaledGravity;
  14401. private _currentRenderId;
  14402. private _alive;
  14403. private _useInstancing;
  14404. private _started;
  14405. private _stopped;
  14406. private _actualFrame;
  14407. private _scaledUpdateSpeed;
  14408. private _vertexBufferSize;
  14409. /** @hidden */
  14410. _currentEmitRateGradient: Nullable<FactorGradient>;
  14411. /** @hidden */
  14412. _currentEmitRate1: number;
  14413. /** @hidden */
  14414. _currentEmitRate2: number;
  14415. /** @hidden */
  14416. _currentStartSizeGradient: Nullable<FactorGradient>;
  14417. /** @hidden */
  14418. _currentStartSize1: number;
  14419. /** @hidden */
  14420. _currentStartSize2: number;
  14421. private readonly _rawTextureWidth;
  14422. private _rampGradientsTexture;
  14423. private _useRampGradients;
  14424. /** Gets or sets a boolean indicating that ramp gradients must be used
  14425. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14426. */
  14427. useRampGradients: boolean;
  14428. /**
  14429. * 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.
  14430. * 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: [])
  14431. */
  14432. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14433. private _subEmitters;
  14434. /**
  14435. * @hidden
  14436. * If the particle systems emitter should be disposed when the particle system is disposed
  14437. */
  14438. _disposeEmitterOnDispose: boolean;
  14439. /**
  14440. * The current active Sub-systems, this property is used by the root particle system only.
  14441. */
  14442. activeSubSystems: Array<ParticleSystem>;
  14443. private _rootParticleSystem;
  14444. /**
  14445. * Gets the current list of active particles
  14446. */
  14447. readonly particles: Particle[];
  14448. /**
  14449. * Returns the string "ParticleSystem"
  14450. * @returns a string containing the class name
  14451. */
  14452. getClassName(): string;
  14453. /**
  14454. * Instantiates a particle system.
  14455. * 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.
  14456. * @param name The name of the particle system
  14457. * @param capacity The max number of particles alive at the same time
  14458. * @param scene The scene the particle system belongs to
  14459. * @param customEffect a custom effect used to change the way particles are rendered by default
  14460. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14461. * @param epsilon Offset used to render the particles
  14462. */
  14463. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14464. private _addFactorGradient;
  14465. private _removeFactorGradient;
  14466. /**
  14467. * Adds a new life time gradient
  14468. * @param gradient defines the gradient to use (between 0 and 1)
  14469. * @param factor defines the life time factor to affect to the specified gradient
  14470. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14471. * @returns the current particle system
  14472. */
  14473. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14474. /**
  14475. * Remove a specific life time gradient
  14476. * @param gradient defines the gradient to remove
  14477. * @returns the current particle system
  14478. */
  14479. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14480. /**
  14481. * Adds a new size gradient
  14482. * @param gradient defines the gradient to use (between 0 and 1)
  14483. * @param factor defines the size factor to affect to the specified gradient
  14484. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14485. * @returns the current particle system
  14486. */
  14487. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14488. /**
  14489. * Remove a specific size gradient
  14490. * @param gradient defines the gradient to remove
  14491. * @returns the current particle system
  14492. */
  14493. removeSizeGradient(gradient: number): IParticleSystem;
  14494. /**
  14495. * Adds a new color remap gradient
  14496. * @param gradient defines the gradient to use (between 0 and 1)
  14497. * @param min defines the color remap minimal range
  14498. * @param max defines the color remap maximal range
  14499. * @returns the current particle system
  14500. */
  14501. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14502. /**
  14503. * Remove a specific color remap gradient
  14504. * @param gradient defines the gradient to remove
  14505. * @returns the current particle system
  14506. */
  14507. removeColorRemapGradient(gradient: number): IParticleSystem;
  14508. /**
  14509. * Adds a new alpha remap gradient
  14510. * @param gradient defines the gradient to use (between 0 and 1)
  14511. * @param min defines the alpha remap minimal range
  14512. * @param max defines the alpha remap maximal range
  14513. * @returns the current particle system
  14514. */
  14515. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14516. /**
  14517. * Remove a specific alpha remap gradient
  14518. * @param gradient defines the gradient to remove
  14519. * @returns the current particle system
  14520. */
  14521. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14522. /**
  14523. * Adds a new angular speed gradient
  14524. * @param gradient defines the gradient to use (between 0 and 1)
  14525. * @param factor defines the angular speed to affect to the specified gradient
  14526. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14527. * @returns the current particle system
  14528. */
  14529. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14530. /**
  14531. * Remove a specific angular speed gradient
  14532. * @param gradient defines the gradient to remove
  14533. * @returns the current particle system
  14534. */
  14535. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14536. /**
  14537. * Adds a new velocity gradient
  14538. * @param gradient defines the gradient to use (between 0 and 1)
  14539. * @param factor defines the velocity to affect to the specified gradient
  14540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14541. * @returns the current particle system
  14542. */
  14543. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14544. /**
  14545. * Remove a specific velocity gradient
  14546. * @param gradient defines the gradient to remove
  14547. * @returns the current particle system
  14548. */
  14549. removeVelocityGradient(gradient: number): IParticleSystem;
  14550. /**
  14551. * Adds a new limit velocity gradient
  14552. * @param gradient defines the gradient to use (between 0 and 1)
  14553. * @param factor defines the limit velocity value to affect to the specified gradient
  14554. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14555. * @returns the current particle system
  14556. */
  14557. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14558. /**
  14559. * Remove a specific limit velocity gradient
  14560. * @param gradient defines the gradient to remove
  14561. * @returns the current particle system
  14562. */
  14563. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14564. /**
  14565. * Adds a new drag gradient
  14566. * @param gradient defines the gradient to use (between 0 and 1)
  14567. * @param factor defines the drag value to affect to the specified gradient
  14568. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14569. * @returns the current particle system
  14570. */
  14571. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14572. /**
  14573. * Remove a specific drag gradient
  14574. * @param gradient defines the gradient to remove
  14575. * @returns the current particle system
  14576. */
  14577. removeDragGradient(gradient: number): IParticleSystem;
  14578. /**
  14579. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14580. * @param gradient defines the gradient to use (between 0 and 1)
  14581. * @param factor defines the emit rate value to affect to the specified gradient
  14582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14583. * @returns the current particle system
  14584. */
  14585. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14586. /**
  14587. * Remove a specific emit rate gradient
  14588. * @param gradient defines the gradient to remove
  14589. * @returns the current particle system
  14590. */
  14591. removeEmitRateGradient(gradient: number): IParticleSystem;
  14592. /**
  14593. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14594. * @param gradient defines the gradient to use (between 0 and 1)
  14595. * @param factor defines the start size value to affect to the specified gradient
  14596. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14597. * @returns the current particle system
  14598. */
  14599. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14600. /**
  14601. * Remove a specific start size gradient
  14602. * @param gradient defines the gradient to remove
  14603. * @returns the current particle system
  14604. */
  14605. removeStartSizeGradient(gradient: number): IParticleSystem;
  14606. private _createRampGradientTexture;
  14607. /**
  14608. * Gets the current list of ramp gradients.
  14609. * You must use addRampGradient and removeRampGradient to udpate this list
  14610. * @returns the list of ramp gradients
  14611. */
  14612. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14613. /**
  14614. * Adds a new ramp gradient used to remap particle colors
  14615. * @param gradient defines the gradient to use (between 0 and 1)
  14616. * @param color defines the color to affect to the specified gradient
  14617. * @returns the current particle system
  14618. */
  14619. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14620. /**
  14621. * Remove a specific ramp gradient
  14622. * @param gradient defines the gradient to remove
  14623. * @returns the current particle system
  14624. */
  14625. removeRampGradient(gradient: number): ParticleSystem;
  14626. /**
  14627. * Adds a new color gradient
  14628. * @param gradient defines the gradient to use (between 0 and 1)
  14629. * @param color1 defines the color to affect to the specified gradient
  14630. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14631. * @returns this particle system
  14632. */
  14633. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14634. /**
  14635. * Remove a specific color gradient
  14636. * @param gradient defines the gradient to remove
  14637. * @returns this particle system
  14638. */
  14639. removeColorGradient(gradient: number): IParticleSystem;
  14640. private _fetchR;
  14641. protected _reset(): void;
  14642. private _resetEffect;
  14643. private _createVertexBuffers;
  14644. private _createIndexBuffer;
  14645. /**
  14646. * Gets the maximum number of particles active at the same time.
  14647. * @returns The max number of active particles.
  14648. */
  14649. getCapacity(): number;
  14650. /**
  14651. * Gets whether there are still active particles in the system.
  14652. * @returns True if it is alive, otherwise false.
  14653. */
  14654. isAlive(): boolean;
  14655. /**
  14656. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14657. * @returns True if it has been started, otherwise false.
  14658. */
  14659. isStarted(): boolean;
  14660. private _prepareSubEmitterInternalArray;
  14661. /**
  14662. * Starts the particle system and begins to emit
  14663. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14664. */
  14665. start(delay?: number): void;
  14666. /**
  14667. * Stops the particle system.
  14668. * @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.
  14669. */
  14670. stop(stopSubEmitters?: boolean): void;
  14671. /**
  14672. * Remove all active particles
  14673. */
  14674. reset(): void;
  14675. /**
  14676. * @hidden (for internal use only)
  14677. */
  14678. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14679. /**
  14680. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14681. * Its lifetime will start back at 0.
  14682. */
  14683. recycleParticle: (particle: Particle) => void;
  14684. private _stopSubEmitters;
  14685. private _createParticle;
  14686. private _removeFromRoot;
  14687. private _emitFromParticle;
  14688. private _update;
  14689. /** @hidden */
  14690. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14691. /** @hidden */
  14692. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14693. /** @hidden */
  14694. private _getEffect;
  14695. /**
  14696. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14697. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14698. */
  14699. animate(preWarmOnly?: boolean): void;
  14700. private _appendParticleVertices;
  14701. /**
  14702. * Rebuilds the particle system.
  14703. */
  14704. rebuild(): void;
  14705. /**
  14706. * Is this system ready to be used/rendered
  14707. * @return true if the system is ready
  14708. */
  14709. isReady(): boolean;
  14710. private _render;
  14711. /**
  14712. * Renders the particle system in its current state.
  14713. * @returns the current number of particles
  14714. */
  14715. render(): number;
  14716. /**
  14717. * Disposes the particle system and free the associated resources
  14718. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14719. */
  14720. dispose(disposeTexture?: boolean): void;
  14721. /**
  14722. * Clones the particle system.
  14723. * @param name The name of the cloned object
  14724. * @param newEmitter The new emitter to use
  14725. * @returns the cloned particle system
  14726. */
  14727. clone(name: string, newEmitter: any): ParticleSystem;
  14728. /**
  14729. * Serializes the particle system to a JSON object.
  14730. * @returns the JSON object
  14731. */
  14732. serialize(): any;
  14733. /** @hidden */
  14734. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  14735. /** @hidden */
  14736. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  14737. /**
  14738. * Parses a JSON object to create a particle system.
  14739. * @param parsedParticleSystem The JSON object to parse
  14740. * @param scene The scene to create the particle system in
  14741. * @param rootUrl The root url to use to load external dependencies like texture
  14742. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  14743. * @returns the Parsed particle system
  14744. */
  14745. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  14746. }
  14747. }
  14748. declare module BABYLON {
  14749. /**
  14750. * A particle represents one of the element emitted by a particle system.
  14751. * This is mainly define by its coordinates, direction, velocity and age.
  14752. */
  14753. export class Particle {
  14754. /**
  14755. * The particle system the particle belongs to.
  14756. */
  14757. particleSystem: ParticleSystem;
  14758. private static _Count;
  14759. /**
  14760. * Unique ID of the particle
  14761. */
  14762. id: number;
  14763. /**
  14764. * The world position of the particle in the scene.
  14765. */
  14766. position: Vector3;
  14767. /**
  14768. * The world direction of the particle in the scene.
  14769. */
  14770. direction: Vector3;
  14771. /**
  14772. * The color of the particle.
  14773. */
  14774. color: Color4;
  14775. /**
  14776. * The color change of the particle per step.
  14777. */
  14778. colorStep: Color4;
  14779. /**
  14780. * Defines how long will the life of the particle be.
  14781. */
  14782. lifeTime: number;
  14783. /**
  14784. * The current age of the particle.
  14785. */
  14786. age: number;
  14787. /**
  14788. * The current size of the particle.
  14789. */
  14790. size: number;
  14791. /**
  14792. * The current scale of the particle.
  14793. */
  14794. scale: Vector2;
  14795. /**
  14796. * The current angle of the particle.
  14797. */
  14798. angle: number;
  14799. /**
  14800. * Defines how fast is the angle changing.
  14801. */
  14802. angularSpeed: number;
  14803. /**
  14804. * Defines the cell index used by the particle to be rendered from a sprite.
  14805. */
  14806. cellIndex: number;
  14807. /**
  14808. * The information required to support color remapping
  14809. */
  14810. remapData: Vector4;
  14811. /** @hidden */
  14812. _randomCellOffset?: number;
  14813. /** @hidden */
  14814. _initialDirection: Nullable<Vector3>;
  14815. /** @hidden */
  14816. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  14817. /** @hidden */
  14818. _initialStartSpriteCellID: number;
  14819. /** @hidden */
  14820. _initialEndSpriteCellID: number;
  14821. /** @hidden */
  14822. _currentColorGradient: Nullable<ColorGradient>;
  14823. /** @hidden */
  14824. _currentColor1: Color4;
  14825. /** @hidden */
  14826. _currentColor2: Color4;
  14827. /** @hidden */
  14828. _currentSizeGradient: Nullable<FactorGradient>;
  14829. /** @hidden */
  14830. _currentSize1: number;
  14831. /** @hidden */
  14832. _currentSize2: number;
  14833. /** @hidden */
  14834. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  14835. /** @hidden */
  14836. _currentAngularSpeed1: number;
  14837. /** @hidden */
  14838. _currentAngularSpeed2: number;
  14839. /** @hidden */
  14840. _currentVelocityGradient: Nullable<FactorGradient>;
  14841. /** @hidden */
  14842. _currentVelocity1: number;
  14843. /** @hidden */
  14844. _currentVelocity2: number;
  14845. /** @hidden */
  14846. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  14847. /** @hidden */
  14848. _currentLimitVelocity1: number;
  14849. /** @hidden */
  14850. _currentLimitVelocity2: number;
  14851. /** @hidden */
  14852. _currentDragGradient: Nullable<FactorGradient>;
  14853. /** @hidden */
  14854. _currentDrag1: number;
  14855. /** @hidden */
  14856. _currentDrag2: number;
  14857. /** @hidden */
  14858. _randomNoiseCoordinates1: Vector3;
  14859. /** @hidden */
  14860. _randomNoiseCoordinates2: Vector3;
  14861. /**
  14862. * Creates a new instance Particle
  14863. * @param particleSystem the particle system the particle belongs to
  14864. */
  14865. constructor(
  14866. /**
  14867. * The particle system the particle belongs to.
  14868. */
  14869. particleSystem: ParticleSystem);
  14870. private updateCellInfoFromSystem;
  14871. /**
  14872. * Defines how the sprite cell index is updated for the particle
  14873. */
  14874. updateCellIndex(): void;
  14875. /** @hidden */
  14876. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  14877. /** @hidden */
  14878. _inheritParticleInfoToSubEmitters(): void;
  14879. /** @hidden */
  14880. _reset(): void;
  14881. /**
  14882. * Copy the properties of particle to another one.
  14883. * @param other the particle to copy the information to.
  14884. */
  14885. copyTo(other: Particle): void;
  14886. }
  14887. }
  14888. declare module BABYLON {
  14889. /**
  14890. * Particle emitter represents a volume emitting particles.
  14891. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  14892. */
  14893. export interface IParticleEmitterType {
  14894. /**
  14895. * Called by the particle System when the direction is computed for the created particle.
  14896. * @param worldMatrix is the world matrix of the particle system
  14897. * @param directionToUpdate is the direction vector to update with the result
  14898. * @param particle is the particle we are computed the direction for
  14899. */
  14900. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14901. /**
  14902. * Called by the particle System when the position is computed for the created particle.
  14903. * @param worldMatrix is the world matrix of the particle system
  14904. * @param positionToUpdate is the position vector to update with the result
  14905. * @param particle is the particle we are computed the position for
  14906. */
  14907. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14908. /**
  14909. * Clones the current emitter and returns a copy of it
  14910. * @returns the new emitter
  14911. */
  14912. clone(): IParticleEmitterType;
  14913. /**
  14914. * Called by the GPUParticleSystem to setup the update shader
  14915. * @param effect defines the update shader
  14916. */
  14917. applyToShader(effect: Effect): void;
  14918. /**
  14919. * Returns a string to use to update the GPU particles update shader
  14920. * @returns the effect defines string
  14921. */
  14922. getEffectDefines(): string;
  14923. /**
  14924. * Returns a string representing the class name
  14925. * @returns a string containing the class name
  14926. */
  14927. getClassName(): string;
  14928. /**
  14929. * Serializes the particle system to a JSON object.
  14930. * @returns the JSON object
  14931. */
  14932. serialize(): any;
  14933. /**
  14934. * Parse properties from a JSON object
  14935. * @param serializationObject defines the JSON object
  14936. */
  14937. parse(serializationObject: any): void;
  14938. }
  14939. }
  14940. declare module BABYLON {
  14941. /**
  14942. * Particle emitter emitting particles from the inside of a box.
  14943. * It emits the particles randomly between 2 given directions.
  14944. */
  14945. export class BoxParticleEmitter implements IParticleEmitterType {
  14946. /**
  14947. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14948. */
  14949. direction1: Vector3;
  14950. /**
  14951. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14952. */
  14953. direction2: Vector3;
  14954. /**
  14955. * 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.
  14956. */
  14957. minEmitBox: Vector3;
  14958. /**
  14959. * 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.
  14960. */
  14961. maxEmitBox: Vector3;
  14962. /**
  14963. * Creates a new instance BoxParticleEmitter
  14964. */
  14965. constructor();
  14966. /**
  14967. * Called by the particle System when the direction is computed for the created particle.
  14968. * @param worldMatrix is the world matrix of the particle system
  14969. * @param directionToUpdate is the direction vector to update with the result
  14970. * @param particle is the particle we are computed the direction for
  14971. */
  14972. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14973. /**
  14974. * Called by the particle System when the position is computed for the created particle.
  14975. * @param worldMatrix is the world matrix of the particle system
  14976. * @param positionToUpdate is the position vector to update with the result
  14977. * @param particle is the particle we are computed the position for
  14978. */
  14979. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14980. /**
  14981. * Clones the current emitter and returns a copy of it
  14982. * @returns the new emitter
  14983. */
  14984. clone(): BoxParticleEmitter;
  14985. /**
  14986. * Called by the GPUParticleSystem to setup the update shader
  14987. * @param effect defines the update shader
  14988. */
  14989. applyToShader(effect: Effect): void;
  14990. /**
  14991. * Returns a string to use to update the GPU particles update shader
  14992. * @returns a string containng the defines string
  14993. */
  14994. getEffectDefines(): string;
  14995. /**
  14996. * Returns the string "BoxParticleEmitter"
  14997. * @returns a string containing the class name
  14998. */
  14999. getClassName(): string;
  15000. /**
  15001. * Serializes the particle system to a JSON object.
  15002. * @returns the JSON object
  15003. */
  15004. serialize(): any;
  15005. /**
  15006. * Parse properties from a JSON object
  15007. * @param serializationObject defines the JSON object
  15008. */
  15009. parse(serializationObject: any): void;
  15010. }
  15011. }
  15012. declare module BABYLON {
  15013. /**
  15014. * Particle emitter emitting particles from the inside of a cone.
  15015. * It emits the particles alongside the cone volume from the base to the particle.
  15016. * The emission direction might be randomized.
  15017. */
  15018. export class ConeParticleEmitter implements IParticleEmitterType {
  15019. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15020. directionRandomizer: number;
  15021. private _radius;
  15022. private _angle;
  15023. private _height;
  15024. /**
  15025. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15026. */
  15027. radiusRange: number;
  15028. /**
  15029. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15030. */
  15031. heightRange: number;
  15032. /**
  15033. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15034. */
  15035. emitFromSpawnPointOnly: boolean;
  15036. /**
  15037. * Gets or sets the radius of the emission cone
  15038. */
  15039. radius: number;
  15040. /**
  15041. * Gets or sets the angle of the emission cone
  15042. */
  15043. angle: number;
  15044. private _buildHeight;
  15045. /**
  15046. * Creates a new instance ConeParticleEmitter
  15047. * @param radius the radius of the emission cone (1 by default)
  15048. * @param angle the cone base angle (PI by default)
  15049. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15050. */
  15051. constructor(radius?: number, angle?: number,
  15052. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15053. directionRandomizer?: number);
  15054. /**
  15055. * Called by the particle System when the direction is computed for the created particle.
  15056. * @param worldMatrix is the world matrix of the particle system
  15057. * @param directionToUpdate is the direction vector to update with the result
  15058. * @param particle is the particle we are computed the direction for
  15059. */
  15060. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15061. /**
  15062. * Called by the particle System when the position is computed for the created particle.
  15063. * @param worldMatrix is the world matrix of the particle system
  15064. * @param positionToUpdate is the position vector to update with the result
  15065. * @param particle is the particle we are computed the position for
  15066. */
  15067. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15068. /**
  15069. * Clones the current emitter and returns a copy of it
  15070. * @returns the new emitter
  15071. */
  15072. clone(): ConeParticleEmitter;
  15073. /**
  15074. * Called by the GPUParticleSystem to setup the update shader
  15075. * @param effect defines the update shader
  15076. */
  15077. applyToShader(effect: Effect): void;
  15078. /**
  15079. * Returns a string to use to update the GPU particles update shader
  15080. * @returns a string containng the defines string
  15081. */
  15082. getEffectDefines(): string;
  15083. /**
  15084. * Returns the string "ConeParticleEmitter"
  15085. * @returns a string containing the class name
  15086. */
  15087. getClassName(): string;
  15088. /**
  15089. * Serializes the particle system to a JSON object.
  15090. * @returns the JSON object
  15091. */
  15092. serialize(): any;
  15093. /**
  15094. * Parse properties from a JSON object
  15095. * @param serializationObject defines the JSON object
  15096. */
  15097. parse(serializationObject: any): void;
  15098. }
  15099. }
  15100. declare module BABYLON {
  15101. /**
  15102. * Particle emitter emitting particles from the inside of a cylinder.
  15103. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15104. */
  15105. export class CylinderParticleEmitter implements IParticleEmitterType {
  15106. /**
  15107. * The radius of the emission cylinder.
  15108. */
  15109. radius: number;
  15110. /**
  15111. * The height of the emission cylinder.
  15112. */
  15113. height: number;
  15114. /**
  15115. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15116. */
  15117. radiusRange: number;
  15118. /**
  15119. * How much to randomize the particle direction [0-1].
  15120. */
  15121. directionRandomizer: number;
  15122. /**
  15123. * Creates a new instance CylinderParticleEmitter
  15124. * @param radius the radius of the emission cylinder (1 by default)
  15125. * @param height the height of the emission cylinder (1 by default)
  15126. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15127. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15128. */
  15129. constructor(
  15130. /**
  15131. * The radius of the emission cylinder.
  15132. */
  15133. radius?: number,
  15134. /**
  15135. * The height of the emission cylinder.
  15136. */
  15137. height?: number,
  15138. /**
  15139. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15140. */
  15141. radiusRange?: number,
  15142. /**
  15143. * How much to randomize the particle direction [0-1].
  15144. */
  15145. directionRandomizer?: number);
  15146. /**
  15147. * Called by the particle System when the direction is computed for the created particle.
  15148. * @param worldMatrix is the world matrix of the particle system
  15149. * @param directionToUpdate is the direction vector to update with the result
  15150. * @param particle is the particle we are computed the direction for
  15151. */
  15152. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15153. /**
  15154. * Called by the particle System when the position is computed for the created particle.
  15155. * @param worldMatrix is the world matrix of the particle system
  15156. * @param positionToUpdate is the position vector to update with the result
  15157. * @param particle is the particle we are computed the position for
  15158. */
  15159. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15160. /**
  15161. * Clones the current emitter and returns a copy of it
  15162. * @returns the new emitter
  15163. */
  15164. clone(): CylinderParticleEmitter;
  15165. /**
  15166. * Called by the GPUParticleSystem to setup the update shader
  15167. * @param effect defines the update shader
  15168. */
  15169. applyToShader(effect: Effect): void;
  15170. /**
  15171. * Returns a string to use to update the GPU particles update shader
  15172. * @returns a string containng the defines string
  15173. */
  15174. getEffectDefines(): string;
  15175. /**
  15176. * Returns the string "CylinderParticleEmitter"
  15177. * @returns a string containing the class name
  15178. */
  15179. getClassName(): string;
  15180. /**
  15181. * Serializes the particle system to a JSON object.
  15182. * @returns the JSON object
  15183. */
  15184. serialize(): any;
  15185. /**
  15186. * Parse properties from a JSON object
  15187. * @param serializationObject defines the JSON object
  15188. */
  15189. parse(serializationObject: any): void;
  15190. }
  15191. /**
  15192. * Particle emitter emitting particles from the inside of a cylinder.
  15193. * It emits the particles randomly between two vectors.
  15194. */
  15195. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15196. /**
  15197. * The min limit of the emission direction.
  15198. */
  15199. direction1: Vector3;
  15200. /**
  15201. * The max limit of the emission direction.
  15202. */
  15203. direction2: Vector3;
  15204. /**
  15205. * Creates a new instance CylinderDirectedParticleEmitter
  15206. * @param radius the radius of the emission cylinder (1 by default)
  15207. * @param height the height of the emission cylinder (1 by default)
  15208. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15209. * @param direction1 the min limit of the emission direction (up vector by default)
  15210. * @param direction2 the max limit of the emission direction (up vector by default)
  15211. */
  15212. constructor(radius?: number, height?: number, radiusRange?: number,
  15213. /**
  15214. * The min limit of the emission direction.
  15215. */
  15216. direction1?: Vector3,
  15217. /**
  15218. * The max limit of the emission direction.
  15219. */
  15220. direction2?: Vector3);
  15221. /**
  15222. * Called by the particle System when the direction is computed for the created particle.
  15223. * @param worldMatrix is the world matrix of the particle system
  15224. * @param directionToUpdate is the direction vector to update with the result
  15225. * @param particle is the particle we are computed the direction for
  15226. */
  15227. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15228. /**
  15229. * Clones the current emitter and returns a copy of it
  15230. * @returns the new emitter
  15231. */
  15232. clone(): CylinderDirectedParticleEmitter;
  15233. /**
  15234. * Called by the GPUParticleSystem to setup the update shader
  15235. * @param effect defines the update shader
  15236. */
  15237. applyToShader(effect: Effect): void;
  15238. /**
  15239. * Returns a string to use to update the GPU particles update shader
  15240. * @returns a string containng the defines string
  15241. */
  15242. getEffectDefines(): string;
  15243. /**
  15244. * Returns the string "CylinderDirectedParticleEmitter"
  15245. * @returns a string containing the class name
  15246. */
  15247. getClassName(): string;
  15248. /**
  15249. * Serializes the particle system to a JSON object.
  15250. * @returns the JSON object
  15251. */
  15252. serialize(): any;
  15253. /**
  15254. * Parse properties from a JSON object
  15255. * @param serializationObject defines the JSON object
  15256. */
  15257. parse(serializationObject: any): void;
  15258. }
  15259. }
  15260. declare module BABYLON {
  15261. /**
  15262. * Particle emitter emitting particles from the inside of a hemisphere.
  15263. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15264. */
  15265. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15266. /**
  15267. * The radius of the emission hemisphere.
  15268. */
  15269. radius: number;
  15270. /**
  15271. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15272. */
  15273. radiusRange: number;
  15274. /**
  15275. * How much to randomize the particle direction [0-1].
  15276. */
  15277. directionRandomizer: number;
  15278. /**
  15279. * Creates a new instance HemisphericParticleEmitter
  15280. * @param radius the radius of the emission hemisphere (1 by default)
  15281. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15282. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15283. */
  15284. constructor(
  15285. /**
  15286. * The radius of the emission hemisphere.
  15287. */
  15288. radius?: number,
  15289. /**
  15290. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15291. */
  15292. radiusRange?: number,
  15293. /**
  15294. * How much to randomize the particle direction [0-1].
  15295. */
  15296. directionRandomizer?: number);
  15297. /**
  15298. * Called by the particle System when the direction is computed for the created particle.
  15299. * @param worldMatrix is the world matrix of the particle system
  15300. * @param directionToUpdate is the direction vector to update with the result
  15301. * @param particle is the particle we are computed the direction for
  15302. */
  15303. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15304. /**
  15305. * Called by the particle System when the position is computed for the created particle.
  15306. * @param worldMatrix is the world matrix of the particle system
  15307. * @param positionToUpdate is the position vector to update with the result
  15308. * @param particle is the particle we are computed the position for
  15309. */
  15310. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15311. /**
  15312. * Clones the current emitter and returns a copy of it
  15313. * @returns the new emitter
  15314. */
  15315. clone(): HemisphericParticleEmitter;
  15316. /**
  15317. * Called by the GPUParticleSystem to setup the update shader
  15318. * @param effect defines the update shader
  15319. */
  15320. applyToShader(effect: Effect): void;
  15321. /**
  15322. * Returns a string to use to update the GPU particles update shader
  15323. * @returns a string containng the defines string
  15324. */
  15325. getEffectDefines(): string;
  15326. /**
  15327. * Returns the string "HemisphericParticleEmitter"
  15328. * @returns a string containing the class name
  15329. */
  15330. getClassName(): string;
  15331. /**
  15332. * Serializes the particle system to a JSON object.
  15333. * @returns the JSON object
  15334. */
  15335. serialize(): any;
  15336. /**
  15337. * Parse properties from a JSON object
  15338. * @param serializationObject defines the JSON object
  15339. */
  15340. parse(serializationObject: any): void;
  15341. }
  15342. }
  15343. declare module BABYLON {
  15344. /**
  15345. * Particle emitter emitting particles from a point.
  15346. * It emits the particles randomly between 2 given directions.
  15347. */
  15348. export class PointParticleEmitter implements IParticleEmitterType {
  15349. /**
  15350. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15351. */
  15352. direction1: Vector3;
  15353. /**
  15354. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15355. */
  15356. direction2: Vector3;
  15357. /**
  15358. * Creates a new instance PointParticleEmitter
  15359. */
  15360. constructor();
  15361. /**
  15362. * Called by the particle System when the direction is computed for the created particle.
  15363. * @param worldMatrix is the world matrix of the particle system
  15364. * @param directionToUpdate is the direction vector to update with the result
  15365. * @param particle is the particle we are computed the direction for
  15366. */
  15367. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15368. /**
  15369. * Called by the particle System when the position is computed for the created particle.
  15370. * @param worldMatrix is the world matrix of the particle system
  15371. * @param positionToUpdate is the position vector to update with the result
  15372. * @param particle is the particle we are computed the position for
  15373. */
  15374. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15375. /**
  15376. * Clones the current emitter and returns a copy of it
  15377. * @returns the new emitter
  15378. */
  15379. clone(): PointParticleEmitter;
  15380. /**
  15381. * Called by the GPUParticleSystem to setup the update shader
  15382. * @param effect defines the update shader
  15383. */
  15384. applyToShader(effect: Effect): void;
  15385. /**
  15386. * Returns a string to use to update the GPU particles update shader
  15387. * @returns a string containng the defines string
  15388. */
  15389. getEffectDefines(): string;
  15390. /**
  15391. * Returns the string "PointParticleEmitter"
  15392. * @returns a string containing the class name
  15393. */
  15394. getClassName(): string;
  15395. /**
  15396. * Serializes the particle system to a JSON object.
  15397. * @returns the JSON object
  15398. */
  15399. serialize(): any;
  15400. /**
  15401. * Parse properties from a JSON object
  15402. * @param serializationObject defines the JSON object
  15403. */
  15404. parse(serializationObject: any): void;
  15405. }
  15406. }
  15407. declare module BABYLON {
  15408. /**
  15409. * Particle emitter emitting particles from the inside of a sphere.
  15410. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15411. */
  15412. export class SphereParticleEmitter implements IParticleEmitterType {
  15413. /**
  15414. * The radius of the emission sphere.
  15415. */
  15416. radius: number;
  15417. /**
  15418. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15419. */
  15420. radiusRange: number;
  15421. /**
  15422. * How much to randomize the particle direction [0-1].
  15423. */
  15424. directionRandomizer: number;
  15425. /**
  15426. * Creates a new instance SphereParticleEmitter
  15427. * @param radius the radius of the emission sphere (1 by default)
  15428. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15429. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15430. */
  15431. constructor(
  15432. /**
  15433. * The radius of the emission sphere.
  15434. */
  15435. radius?: number,
  15436. /**
  15437. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15438. */
  15439. radiusRange?: number,
  15440. /**
  15441. * How much to randomize the particle direction [0-1].
  15442. */
  15443. directionRandomizer?: number);
  15444. /**
  15445. * Called by the particle System when the direction is computed for the created particle.
  15446. * @param worldMatrix is the world matrix of the particle system
  15447. * @param directionToUpdate is the direction vector to update with the result
  15448. * @param particle is the particle we are computed the direction for
  15449. */
  15450. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15451. /**
  15452. * Called by the particle System when the position is computed for the created particle.
  15453. * @param worldMatrix is the world matrix of the particle system
  15454. * @param positionToUpdate is the position vector to update with the result
  15455. * @param particle is the particle we are computed the position for
  15456. */
  15457. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15458. /**
  15459. * Clones the current emitter and returns a copy of it
  15460. * @returns the new emitter
  15461. */
  15462. clone(): SphereParticleEmitter;
  15463. /**
  15464. * Called by the GPUParticleSystem to setup the update shader
  15465. * @param effect defines the update shader
  15466. */
  15467. applyToShader(effect: Effect): void;
  15468. /**
  15469. * Returns a string to use to update the GPU particles update shader
  15470. * @returns a string containng the defines string
  15471. */
  15472. getEffectDefines(): string;
  15473. /**
  15474. * Returns the string "SphereParticleEmitter"
  15475. * @returns a string containing the class name
  15476. */
  15477. getClassName(): string;
  15478. /**
  15479. * Serializes the particle system to a JSON object.
  15480. * @returns the JSON object
  15481. */
  15482. serialize(): any;
  15483. /**
  15484. * Parse properties from a JSON object
  15485. * @param serializationObject defines the JSON object
  15486. */
  15487. parse(serializationObject: any): void;
  15488. }
  15489. /**
  15490. * Particle emitter emitting particles from the inside of a sphere.
  15491. * It emits the particles randomly between two vectors.
  15492. */
  15493. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15494. /**
  15495. * The min limit of the emission direction.
  15496. */
  15497. direction1: Vector3;
  15498. /**
  15499. * The max limit of the emission direction.
  15500. */
  15501. direction2: Vector3;
  15502. /**
  15503. * Creates a new instance SphereDirectedParticleEmitter
  15504. * @param radius the radius of the emission sphere (1 by default)
  15505. * @param direction1 the min limit of the emission direction (up vector by default)
  15506. * @param direction2 the max limit of the emission direction (up vector by default)
  15507. */
  15508. constructor(radius?: number,
  15509. /**
  15510. * The min limit of the emission direction.
  15511. */
  15512. direction1?: Vector3,
  15513. /**
  15514. * The max limit of the emission direction.
  15515. */
  15516. direction2?: Vector3);
  15517. /**
  15518. * Called by the particle System when the direction is computed for the created particle.
  15519. * @param worldMatrix is the world matrix of the particle system
  15520. * @param directionToUpdate is the direction vector to update with the result
  15521. * @param particle is the particle we are computed the direction for
  15522. */
  15523. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15524. /**
  15525. * Clones the current emitter and returns a copy of it
  15526. * @returns the new emitter
  15527. */
  15528. clone(): SphereDirectedParticleEmitter;
  15529. /**
  15530. * Called by the GPUParticleSystem to setup the update shader
  15531. * @param effect defines the update shader
  15532. */
  15533. applyToShader(effect: Effect): void;
  15534. /**
  15535. * Returns a string to use to update the GPU particles update shader
  15536. * @returns a string containng the defines string
  15537. */
  15538. getEffectDefines(): string;
  15539. /**
  15540. * Returns the string "SphereDirectedParticleEmitter"
  15541. * @returns a string containing the class name
  15542. */
  15543. getClassName(): string;
  15544. /**
  15545. * Serializes the particle system to a JSON object.
  15546. * @returns the JSON object
  15547. */
  15548. serialize(): any;
  15549. /**
  15550. * Parse properties from a JSON object
  15551. * @param serializationObject defines the JSON object
  15552. */
  15553. parse(serializationObject: any): void;
  15554. }
  15555. }
  15556. declare module BABYLON {
  15557. /**
  15558. * Interface representing a particle system in Babylon.js.
  15559. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15560. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15561. */
  15562. export interface IParticleSystem {
  15563. /**
  15564. * List of animations used by the particle system.
  15565. */
  15566. animations: Animation[];
  15567. /**
  15568. * The id of the Particle system.
  15569. */
  15570. id: string;
  15571. /**
  15572. * The name of the Particle system.
  15573. */
  15574. name: string;
  15575. /**
  15576. * The emitter represents the Mesh or position we are attaching the particle system to.
  15577. */
  15578. emitter: Nullable<AbstractMesh | Vector3>;
  15579. /**
  15580. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15581. */
  15582. isBillboardBased: boolean;
  15583. /**
  15584. * The rendering group used by the Particle system to chose when to render.
  15585. */
  15586. renderingGroupId: number;
  15587. /**
  15588. * The layer mask we are rendering the particles through.
  15589. */
  15590. layerMask: number;
  15591. /**
  15592. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15593. */
  15594. updateSpeed: number;
  15595. /**
  15596. * The amount of time the particle system is running (depends of the overall update speed).
  15597. */
  15598. targetStopDuration: number;
  15599. /**
  15600. * The texture used to render each particle. (this can be a spritesheet)
  15601. */
  15602. particleTexture: Nullable<Texture>;
  15603. /**
  15604. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15605. */
  15606. blendMode: number;
  15607. /**
  15608. * Minimum life time of emitting particles.
  15609. */
  15610. minLifeTime: number;
  15611. /**
  15612. * Maximum life time of emitting particles.
  15613. */
  15614. maxLifeTime: number;
  15615. /**
  15616. * Minimum Size of emitting particles.
  15617. */
  15618. minSize: number;
  15619. /**
  15620. * Maximum Size of emitting particles.
  15621. */
  15622. maxSize: number;
  15623. /**
  15624. * Minimum scale of emitting particles on X axis.
  15625. */
  15626. minScaleX: number;
  15627. /**
  15628. * Maximum scale of emitting particles on X axis.
  15629. */
  15630. maxScaleX: number;
  15631. /**
  15632. * Minimum scale of emitting particles on Y axis.
  15633. */
  15634. minScaleY: number;
  15635. /**
  15636. * Maximum scale of emitting particles on Y axis.
  15637. */
  15638. maxScaleY: number;
  15639. /**
  15640. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15641. */
  15642. color1: Color4;
  15643. /**
  15644. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15645. */
  15646. color2: Color4;
  15647. /**
  15648. * Color the particle will have at the end of its lifetime.
  15649. */
  15650. colorDead: Color4;
  15651. /**
  15652. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15653. */
  15654. emitRate: number;
  15655. /**
  15656. * You can use gravity if you want to give an orientation to your particles.
  15657. */
  15658. gravity: Vector3;
  15659. /**
  15660. * Minimum power of emitting particles.
  15661. */
  15662. minEmitPower: number;
  15663. /**
  15664. * Maximum power of emitting particles.
  15665. */
  15666. maxEmitPower: number;
  15667. /**
  15668. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15669. */
  15670. minAngularSpeed: number;
  15671. /**
  15672. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15673. */
  15674. maxAngularSpeed: number;
  15675. /**
  15676. * Gets or sets the minimal initial rotation in radians.
  15677. */
  15678. minInitialRotation: number;
  15679. /**
  15680. * Gets or sets the maximal initial rotation in radians.
  15681. */
  15682. maxInitialRotation: number;
  15683. /**
  15684. * The particle emitter type defines the emitter used by the particle system.
  15685. * It can be for example box, sphere, or cone...
  15686. */
  15687. particleEmitterType: Nullable<IParticleEmitterType>;
  15688. /**
  15689. * Defines the delay in milliseconds before starting the system (0 by default)
  15690. */
  15691. startDelay: number;
  15692. /**
  15693. * 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
  15694. */
  15695. preWarmCycles: number;
  15696. /**
  15697. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15698. */
  15699. preWarmStepOffset: number;
  15700. /**
  15701. * 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)
  15702. */
  15703. spriteCellChangeSpeed: number;
  15704. /**
  15705. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15706. */
  15707. startSpriteCellID: number;
  15708. /**
  15709. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15710. */
  15711. endSpriteCellID: number;
  15712. /**
  15713. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15714. */
  15715. spriteCellWidth: number;
  15716. /**
  15717. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15718. */
  15719. spriteCellHeight: number;
  15720. /**
  15721. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15722. */
  15723. spriteRandomStartCell: boolean;
  15724. /**
  15725. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15726. */
  15727. isAnimationSheetEnabled: boolean;
  15728. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15729. translationPivot: Vector2;
  15730. /**
  15731. * Gets or sets a texture used to add random noise to particle positions
  15732. */
  15733. noiseTexture: Nullable<BaseTexture>;
  15734. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15735. noiseStrength: Vector3;
  15736. /**
  15737. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15738. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15739. */
  15740. billboardMode: number;
  15741. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15742. limitVelocityDamping: number;
  15743. /**
  15744. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15745. */
  15746. beginAnimationOnStart: boolean;
  15747. /**
  15748. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15749. */
  15750. beginAnimationFrom: number;
  15751. /**
  15752. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15753. */
  15754. beginAnimationTo: number;
  15755. /**
  15756. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15757. */
  15758. beginAnimationLoop: boolean;
  15759. /**
  15760. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15761. */
  15762. disposeOnStop: boolean;
  15763. /**
  15764. * Gets the maximum number of particles active at the same time.
  15765. * @returns The max number of active particles.
  15766. */
  15767. getCapacity(): number;
  15768. /**
  15769. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15770. * @returns True if it has been started, otherwise false.
  15771. */
  15772. isStarted(): boolean;
  15773. /**
  15774. * Animates the particle system for this frame.
  15775. */
  15776. animate(): void;
  15777. /**
  15778. * Renders the particle system in its current state.
  15779. * @returns the current number of particles
  15780. */
  15781. render(): number;
  15782. /**
  15783. * Dispose the particle system and frees its associated resources.
  15784. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15785. */
  15786. dispose(disposeTexture?: boolean): void;
  15787. /**
  15788. * Clones the particle system.
  15789. * @param name The name of the cloned object
  15790. * @param newEmitter The new emitter to use
  15791. * @returns the cloned particle system
  15792. */
  15793. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  15794. /**
  15795. * Serializes the particle system to a JSON object.
  15796. * @returns the JSON object
  15797. */
  15798. serialize(): any;
  15799. /**
  15800. * Rebuild the particle system
  15801. */
  15802. rebuild(): void;
  15803. /**
  15804. * Starts the particle system and begins to emit
  15805. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  15806. */
  15807. start(delay?: number): void;
  15808. /**
  15809. * Stops the particle system.
  15810. */
  15811. stop(): void;
  15812. /**
  15813. * Remove all active particles
  15814. */
  15815. reset(): void;
  15816. /**
  15817. * Is this system ready to be used/rendered
  15818. * @return true if the system is ready
  15819. */
  15820. isReady(): boolean;
  15821. /**
  15822. * Adds a new color gradient
  15823. * @param gradient defines the gradient to use (between 0 and 1)
  15824. * @param color1 defines the color to affect to the specified gradient
  15825. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15826. * @returns the current particle system
  15827. */
  15828. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15829. /**
  15830. * Remove a specific color gradient
  15831. * @param gradient defines the gradient to remove
  15832. * @returns the current particle system
  15833. */
  15834. removeColorGradient(gradient: number): IParticleSystem;
  15835. /**
  15836. * Adds a new size gradient
  15837. * @param gradient defines the gradient to use (between 0 and 1)
  15838. * @param factor defines the size factor to affect to the specified gradient
  15839. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15840. * @returns the current particle system
  15841. */
  15842. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15843. /**
  15844. * Remove a specific size gradient
  15845. * @param gradient defines the gradient to remove
  15846. * @returns the current particle system
  15847. */
  15848. removeSizeGradient(gradient: number): IParticleSystem;
  15849. /**
  15850. * Gets the current list of color gradients.
  15851. * You must use addColorGradient and removeColorGradient to udpate this list
  15852. * @returns the list of color gradients
  15853. */
  15854. getColorGradients(): Nullable<Array<ColorGradient>>;
  15855. /**
  15856. * Gets the current list of size gradients.
  15857. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15858. * @returns the list of size gradients
  15859. */
  15860. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15861. /**
  15862. * Gets the current list of angular speed gradients.
  15863. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15864. * @returns the list of angular speed gradients
  15865. */
  15866. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15867. /**
  15868. * Adds a new angular speed gradient
  15869. * @param gradient defines the gradient to use (between 0 and 1)
  15870. * @param factor defines the angular speed to affect to the specified gradient
  15871. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15872. * @returns the current particle system
  15873. */
  15874. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15875. /**
  15876. * Remove a specific angular speed gradient
  15877. * @param gradient defines the gradient to remove
  15878. * @returns the current particle system
  15879. */
  15880. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15881. /**
  15882. * Gets the current list of velocity gradients.
  15883. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15884. * @returns the list of velocity gradients
  15885. */
  15886. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15887. /**
  15888. * Adds a new velocity gradient
  15889. * @param gradient defines the gradient to use (between 0 and 1)
  15890. * @param factor defines the velocity to affect to the specified gradient
  15891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15892. * @returns the current particle system
  15893. */
  15894. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15895. /**
  15896. * Remove a specific velocity gradient
  15897. * @param gradient defines the gradient to remove
  15898. * @returns the current particle system
  15899. */
  15900. removeVelocityGradient(gradient: number): IParticleSystem;
  15901. /**
  15902. * Gets the current list of limit velocity gradients.
  15903. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15904. * @returns the list of limit velocity gradients
  15905. */
  15906. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15907. /**
  15908. * Adds a new limit velocity gradient
  15909. * @param gradient defines the gradient to use (between 0 and 1)
  15910. * @param factor defines the limit velocity to affect to the specified gradient
  15911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15912. * @returns the current particle system
  15913. */
  15914. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15915. /**
  15916. * Remove a specific limit velocity gradient
  15917. * @param gradient defines the gradient to remove
  15918. * @returns the current particle system
  15919. */
  15920. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15921. /**
  15922. * Adds a new drag gradient
  15923. * @param gradient defines the gradient to use (between 0 and 1)
  15924. * @param factor defines the drag to affect to the specified gradient
  15925. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15926. * @returns the current particle system
  15927. */
  15928. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15929. /**
  15930. * Remove a specific drag gradient
  15931. * @param gradient defines the gradient to remove
  15932. * @returns the current particle system
  15933. */
  15934. removeDragGradient(gradient: number): IParticleSystem;
  15935. /**
  15936. * Gets the current list of drag gradients.
  15937. * You must use addDragGradient and removeDragGradient to udpate this list
  15938. * @returns the list of drag gradients
  15939. */
  15940. getDragGradients(): Nullable<Array<FactorGradient>>;
  15941. /**
  15942. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15943. * @param gradient defines the gradient to use (between 0 and 1)
  15944. * @param factor defines the emit rate to affect to the specified gradient
  15945. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15946. * @returns the current particle system
  15947. */
  15948. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15949. /**
  15950. * Remove a specific emit rate gradient
  15951. * @param gradient defines the gradient to remove
  15952. * @returns the current particle system
  15953. */
  15954. removeEmitRateGradient(gradient: number): IParticleSystem;
  15955. /**
  15956. * Gets the current list of emit rate gradients.
  15957. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15958. * @returns the list of emit rate gradients
  15959. */
  15960. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15961. /**
  15962. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15963. * @param gradient defines the gradient to use (between 0 and 1)
  15964. * @param factor defines the start size to affect to the specified gradient
  15965. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15966. * @returns the current particle system
  15967. */
  15968. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15969. /**
  15970. * Remove a specific start size gradient
  15971. * @param gradient defines the gradient to remove
  15972. * @returns the current particle system
  15973. */
  15974. removeStartSizeGradient(gradient: number): IParticleSystem;
  15975. /**
  15976. * Gets the current list of start size gradients.
  15977. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15978. * @returns the list of start size gradients
  15979. */
  15980. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15981. /**
  15982. * Adds a new life time gradient
  15983. * @param gradient defines the gradient to use (between 0 and 1)
  15984. * @param factor defines the life time factor to affect to the specified gradient
  15985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15986. * @returns the current particle system
  15987. */
  15988. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15989. /**
  15990. * Remove a specific life time gradient
  15991. * @param gradient defines the gradient to remove
  15992. * @returns the current particle system
  15993. */
  15994. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15995. /**
  15996. * Gets the current list of life time gradients.
  15997. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15998. * @returns the list of life time gradients
  15999. */
  16000. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16001. /**
  16002. * Gets the current list of color gradients.
  16003. * You must use addColorGradient and removeColorGradient to udpate this list
  16004. * @returns the list of color gradients
  16005. */
  16006. getColorGradients(): Nullable<Array<ColorGradient>>;
  16007. /**
  16008. * Adds a new ramp gradient used to remap particle colors
  16009. * @param gradient defines the gradient to use (between 0 and 1)
  16010. * @param color defines the color to affect to the specified gradient
  16011. * @returns the current particle system
  16012. */
  16013. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16014. /**
  16015. * Gets the current list of ramp gradients.
  16016. * You must use addRampGradient and removeRampGradient to udpate this list
  16017. * @returns the list of ramp gradients
  16018. */
  16019. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16020. /** Gets or sets a boolean indicating that ramp gradients must be used
  16021. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16022. */
  16023. useRampGradients: boolean;
  16024. /**
  16025. * Adds a new color remap gradient
  16026. * @param gradient defines the gradient to use (between 0 and 1)
  16027. * @param min defines the color remap minimal range
  16028. * @param max defines the color remap maximal range
  16029. * @returns the current particle system
  16030. */
  16031. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16032. /**
  16033. * Gets the current list of color remap gradients.
  16034. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16035. * @returns the list of color remap gradients
  16036. */
  16037. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16038. /**
  16039. * Adds a new alpha remap gradient
  16040. * @param gradient defines the gradient to use (between 0 and 1)
  16041. * @param min defines the alpha remap minimal range
  16042. * @param max defines the alpha remap maximal range
  16043. * @returns the current particle system
  16044. */
  16045. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16046. /**
  16047. * Gets the current list of alpha remap gradients.
  16048. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16049. * @returns the list of alpha remap gradients
  16050. */
  16051. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16052. /**
  16053. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16054. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16055. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16056. * @returns the emitter
  16057. */
  16058. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16059. /**
  16060. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16061. * @param radius The radius of the hemisphere to emit from
  16062. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16063. * @returns the emitter
  16064. */
  16065. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16066. /**
  16067. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16068. * @param radius The radius of the sphere to emit from
  16069. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16070. * @returns the emitter
  16071. */
  16072. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16073. /**
  16074. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16075. * @param radius The radius of the sphere to emit from
  16076. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16077. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16078. * @returns the emitter
  16079. */
  16080. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16081. /**
  16082. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16083. * @param radius The radius of the emission cylinder
  16084. * @param height The height of the emission cylinder
  16085. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16086. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16087. * @returns the emitter
  16088. */
  16089. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16090. /**
  16091. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16092. * @param radius The radius of the cylinder to emit from
  16093. * @param height The height of the emission cylinder
  16094. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16095. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16096. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16097. * @returns the emitter
  16098. */
  16099. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16100. /**
  16101. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16102. * @param radius The radius of the cone to emit from
  16103. * @param angle The base angle of the cone
  16104. * @returns the emitter
  16105. */
  16106. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16107. /**
  16108. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16109. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16110. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16111. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16112. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16113. * @returns the emitter
  16114. */
  16115. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16116. /**
  16117. * Get hosting scene
  16118. * @returns the scene
  16119. */
  16120. getScene(): Scene;
  16121. }
  16122. }
  16123. declare module BABYLON {
  16124. /**
  16125. * Creates an instance based on a source mesh.
  16126. */
  16127. export class InstancedMesh extends AbstractMesh {
  16128. private _sourceMesh;
  16129. private _currentLOD;
  16130. /** @hidden */
  16131. _indexInSourceMeshInstanceArray: number;
  16132. constructor(name: string, source: Mesh);
  16133. /**
  16134. * Returns the string "InstancedMesh".
  16135. */
  16136. getClassName(): string;
  16137. /**
  16138. * If the source mesh receives shadows
  16139. */
  16140. readonly receiveShadows: boolean;
  16141. /**
  16142. * The material of the source mesh
  16143. */
  16144. readonly material: Nullable<Material>;
  16145. /**
  16146. * Visibility of the source mesh
  16147. */
  16148. readonly visibility: number;
  16149. /**
  16150. * Skeleton of the source mesh
  16151. */
  16152. readonly skeleton: Nullable<Skeleton>;
  16153. /**
  16154. * Rendering ground id of the source mesh
  16155. */
  16156. renderingGroupId: number;
  16157. /**
  16158. * Returns the total number of vertices (integer).
  16159. */
  16160. getTotalVertices(): number;
  16161. /**
  16162. * Returns a positive integer : the total number of indices in this mesh geometry.
  16163. * @returns the numner of indices or zero if the mesh has no geometry.
  16164. */
  16165. getTotalIndices(): number;
  16166. /**
  16167. * The source mesh of the instance
  16168. */
  16169. readonly sourceMesh: Mesh;
  16170. /**
  16171. * Is this node ready to be used/rendered
  16172. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16173. * @return {boolean} is it ready
  16174. */
  16175. isReady(completeCheck?: boolean): boolean;
  16176. /**
  16177. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16178. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16179. * @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.
  16180. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16181. */
  16182. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16183. /**
  16184. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16185. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16186. * The `data` are either a numeric array either a Float32Array.
  16187. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16188. * 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).
  16189. * Note that a new underlying VertexBuffer object is created each call.
  16190. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16191. *
  16192. * Possible `kind` values :
  16193. * - VertexBuffer.PositionKind
  16194. * - VertexBuffer.UVKind
  16195. * - VertexBuffer.UV2Kind
  16196. * - VertexBuffer.UV3Kind
  16197. * - VertexBuffer.UV4Kind
  16198. * - VertexBuffer.UV5Kind
  16199. * - VertexBuffer.UV6Kind
  16200. * - VertexBuffer.ColorKind
  16201. * - VertexBuffer.MatricesIndicesKind
  16202. * - VertexBuffer.MatricesIndicesExtraKind
  16203. * - VertexBuffer.MatricesWeightsKind
  16204. * - VertexBuffer.MatricesWeightsExtraKind
  16205. *
  16206. * Returns the Mesh.
  16207. */
  16208. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16209. /**
  16210. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16211. * If the mesh has no geometry, it is simply returned as it is.
  16212. * The `data` are either a numeric array either a Float32Array.
  16213. * No new underlying VertexBuffer object is created.
  16214. * 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.
  16215. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16216. *
  16217. * Possible `kind` values :
  16218. * - VertexBuffer.PositionKind
  16219. * - VertexBuffer.UVKind
  16220. * - VertexBuffer.UV2Kind
  16221. * - VertexBuffer.UV3Kind
  16222. * - VertexBuffer.UV4Kind
  16223. * - VertexBuffer.UV5Kind
  16224. * - VertexBuffer.UV6Kind
  16225. * - VertexBuffer.ColorKind
  16226. * - VertexBuffer.MatricesIndicesKind
  16227. * - VertexBuffer.MatricesIndicesExtraKind
  16228. * - VertexBuffer.MatricesWeightsKind
  16229. * - VertexBuffer.MatricesWeightsExtraKind
  16230. *
  16231. * Returns the Mesh.
  16232. */
  16233. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16234. /**
  16235. * Sets the mesh indices.
  16236. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16237. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16238. * This method creates a new index buffer each call.
  16239. * Returns the Mesh.
  16240. */
  16241. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16242. /**
  16243. * Boolean : True if the mesh owns the requested kind of data.
  16244. */
  16245. isVerticesDataPresent(kind: string): boolean;
  16246. /**
  16247. * Returns an array of indices (IndicesArray).
  16248. */
  16249. getIndices(): Nullable<IndicesArray>;
  16250. readonly _positions: Nullable<Vector3[]>;
  16251. /**
  16252. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16253. * This means the mesh underlying bounding box and sphere are recomputed.
  16254. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16255. * @returns the current mesh
  16256. */
  16257. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16258. /** @hidden */
  16259. _preActivate(): InstancedMesh;
  16260. /** @hidden */
  16261. _activate(renderId: number): InstancedMesh;
  16262. /**
  16263. * Returns the current associated LOD AbstractMesh.
  16264. */
  16265. getLOD(camera: Camera): AbstractMesh;
  16266. /** @hidden */
  16267. _syncSubMeshes(): InstancedMesh;
  16268. /** @hidden */
  16269. _generatePointsArray(): boolean;
  16270. /**
  16271. * Creates a new InstancedMesh from the current mesh.
  16272. * - name (string) : the cloned mesh name
  16273. * - newParent (optional Node) : the optional Node to parent the clone to.
  16274. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16275. *
  16276. * Returns the clone.
  16277. */
  16278. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16279. /**
  16280. * Disposes the InstancedMesh.
  16281. * Returns nothing.
  16282. */
  16283. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16284. }
  16285. }
  16286. declare module BABYLON {
  16287. /**
  16288. * Defines the options associated with the creation of a shader material.
  16289. */
  16290. export interface IShaderMaterialOptions {
  16291. /**
  16292. * Does the material work in alpha blend mode
  16293. */
  16294. needAlphaBlending: boolean;
  16295. /**
  16296. * Does the material work in alpha test mode
  16297. */
  16298. needAlphaTesting: boolean;
  16299. /**
  16300. * The list of attribute names used in the shader
  16301. */
  16302. attributes: string[];
  16303. /**
  16304. * The list of unifrom names used in the shader
  16305. */
  16306. uniforms: string[];
  16307. /**
  16308. * The list of UBO names used in the shader
  16309. */
  16310. uniformBuffers: string[];
  16311. /**
  16312. * The list of sampler names used in the shader
  16313. */
  16314. samplers: string[];
  16315. /**
  16316. * The list of defines used in the shader
  16317. */
  16318. defines: string[];
  16319. }
  16320. /**
  16321. * 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.
  16322. *
  16323. * This returned material effects how the mesh will look based on the code in the shaders.
  16324. *
  16325. * @see http://doc.babylonjs.com/how_to/shader_material
  16326. */
  16327. export class ShaderMaterial extends Material {
  16328. private _shaderPath;
  16329. private _options;
  16330. private _textures;
  16331. private _textureArrays;
  16332. private _floats;
  16333. private _ints;
  16334. private _floatsArrays;
  16335. private _colors3;
  16336. private _colors3Arrays;
  16337. private _colors4;
  16338. private _vectors2;
  16339. private _vectors3;
  16340. private _vectors4;
  16341. private _matrices;
  16342. private _matrices3x3;
  16343. private _matrices2x2;
  16344. private _vectors2Arrays;
  16345. private _vectors3Arrays;
  16346. private _cachedWorldViewMatrix;
  16347. private _renderId;
  16348. /**
  16349. * Instantiate a new shader material.
  16350. * 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.
  16351. * This returned material effects how the mesh will look based on the code in the shaders.
  16352. * @see http://doc.babylonjs.com/how_to/shader_material
  16353. * @param name Define the name of the material in the scene
  16354. * @param scene Define the scene the material belongs to
  16355. * @param shaderPath Defines the route to the shader code in one of three ways:
  16356. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16357. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16358. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16359. * @param options Define the options used to create the shader
  16360. */
  16361. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16362. /**
  16363. * Gets the current class name of the material e.g. "ShaderMaterial"
  16364. * Mainly use in serialization.
  16365. * @returns the class name
  16366. */
  16367. getClassName(): string;
  16368. /**
  16369. * Specifies if the material will require alpha blending
  16370. * @returns a boolean specifying if alpha blending is needed
  16371. */
  16372. needAlphaBlending(): boolean;
  16373. /**
  16374. * Specifies if this material should be rendered in alpha test mode
  16375. * @returns a boolean specifying if an alpha test is needed.
  16376. */
  16377. needAlphaTesting(): boolean;
  16378. private _checkUniform;
  16379. /**
  16380. * Set a texture in the shader.
  16381. * @param name Define the name of the uniform samplers as defined in the shader
  16382. * @param texture Define the texture to bind to this sampler
  16383. * @return the material itself allowing "fluent" like uniform updates
  16384. */
  16385. setTexture(name: string, texture: Texture): ShaderMaterial;
  16386. /**
  16387. * Set a texture array in the shader.
  16388. * @param name Define the name of the uniform sampler array as defined in the shader
  16389. * @param textures Define the list of textures to bind to this sampler
  16390. * @return the material itself allowing "fluent" like uniform updates
  16391. */
  16392. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16393. /**
  16394. * Set a float in the shader.
  16395. * @param name Define the name of the uniform as defined in the shader
  16396. * @param value Define the value to give to the uniform
  16397. * @return the material itself allowing "fluent" like uniform updates
  16398. */
  16399. setFloat(name: string, value: number): ShaderMaterial;
  16400. /**
  16401. * Set a int in the shader.
  16402. * @param name Define the name of the uniform as defined in the shader
  16403. * @param value Define the value to give to the uniform
  16404. * @return the material itself allowing "fluent" like uniform updates
  16405. */
  16406. setInt(name: string, value: number): ShaderMaterial;
  16407. /**
  16408. * Set an array of floats in the shader.
  16409. * @param name Define the name of the uniform as defined in the shader
  16410. * @param value Define the value to give to the uniform
  16411. * @return the material itself allowing "fluent" like uniform updates
  16412. */
  16413. setFloats(name: string, value: number[]): ShaderMaterial;
  16414. /**
  16415. * Set a vec3 in the shader from a Color3.
  16416. * @param name Define the name of the uniform as defined in the shader
  16417. * @param value Define the value to give to the uniform
  16418. * @return the material itself allowing "fluent" like uniform updates
  16419. */
  16420. setColor3(name: string, value: Color3): ShaderMaterial;
  16421. /**
  16422. * Set a vec3 array in the shader from a Color3 array.
  16423. * @param name Define the name of the uniform as defined in the shader
  16424. * @param value Define the value to give to the uniform
  16425. * @return the material itself allowing "fluent" like uniform updates
  16426. */
  16427. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16428. /**
  16429. * Set a vec4 in the shader from a Color4.
  16430. * @param name Define the name of the uniform as defined in the shader
  16431. * @param value Define the value to give to the uniform
  16432. * @return the material itself allowing "fluent" like uniform updates
  16433. */
  16434. setColor4(name: string, value: Color4): ShaderMaterial;
  16435. /**
  16436. * Set a vec2 in the shader from a Vector2.
  16437. * @param name Define the name of the uniform as defined in the shader
  16438. * @param value Define the value to give to the uniform
  16439. * @return the material itself allowing "fluent" like uniform updates
  16440. */
  16441. setVector2(name: string, value: Vector2): ShaderMaterial;
  16442. /**
  16443. * Set a vec3 in the shader from a Vector3.
  16444. * @param name Define the name of the uniform as defined in the shader
  16445. * @param value Define the value to give to the uniform
  16446. * @return the material itself allowing "fluent" like uniform updates
  16447. */
  16448. setVector3(name: string, value: Vector3): ShaderMaterial;
  16449. /**
  16450. * Set a vec4 in the shader from a Vector4.
  16451. * @param name Define the name of the uniform as defined in the shader
  16452. * @param value Define the value to give to the uniform
  16453. * @return the material itself allowing "fluent" like uniform updates
  16454. */
  16455. setVector4(name: string, value: Vector4): ShaderMaterial;
  16456. /**
  16457. * Set a mat4 in the shader from a Matrix.
  16458. * @param name Define the name of the uniform as defined in the shader
  16459. * @param value Define the value to give to the uniform
  16460. * @return the material itself allowing "fluent" like uniform updates
  16461. */
  16462. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16463. /**
  16464. * Set a mat3 in the shader from a Float32Array.
  16465. * @param name Define the name of the uniform as defined in the shader
  16466. * @param value Define the value to give to the uniform
  16467. * @return the material itself allowing "fluent" like uniform updates
  16468. */
  16469. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16470. /**
  16471. * Set a mat2 in the shader from a Float32Array.
  16472. * @param name Define the name of the uniform as defined in the shader
  16473. * @param value Define the value to give to the uniform
  16474. * @return the material itself allowing "fluent" like uniform updates
  16475. */
  16476. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16477. /**
  16478. * Set a vec2 array in the shader from a number array.
  16479. * @param name Define the name of the uniform as defined in the shader
  16480. * @param value Define the value to give to the uniform
  16481. * @return the material itself allowing "fluent" like uniform updates
  16482. */
  16483. setArray2(name: string, value: number[]): ShaderMaterial;
  16484. /**
  16485. * Set a vec3 array in the shader from a number array.
  16486. * @param name Define the name of the uniform as defined in the shader
  16487. * @param value Define the value to give to the uniform
  16488. * @return the material itself allowing "fluent" like uniform updates
  16489. */
  16490. setArray3(name: string, value: number[]): ShaderMaterial;
  16491. private _checkCache;
  16492. /**
  16493. * Checks if the material is ready to render the requested mesh
  16494. * @param mesh Define the mesh to render
  16495. * @param useInstances Define whether or not the material is used with instances
  16496. * @returns true if ready, otherwise false
  16497. */
  16498. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16499. /**
  16500. * Binds the world matrix to the material
  16501. * @param world defines the world transformation matrix
  16502. */
  16503. bindOnlyWorldMatrix(world: Matrix): void;
  16504. /**
  16505. * Binds the material to the mesh
  16506. * @param world defines the world transformation matrix
  16507. * @param mesh defines the mesh to bind the material to
  16508. */
  16509. bind(world: Matrix, mesh?: Mesh): void;
  16510. /**
  16511. * Gets the active textures from the material
  16512. * @returns an array of textures
  16513. */
  16514. getActiveTextures(): BaseTexture[];
  16515. /**
  16516. * Specifies if the material uses a texture
  16517. * @param texture defines the texture to check against the material
  16518. * @returns a boolean specifying if the material uses the texture
  16519. */
  16520. hasTexture(texture: BaseTexture): boolean;
  16521. /**
  16522. * Makes a duplicate of the material, and gives it a new name
  16523. * @param name defines the new name for the duplicated material
  16524. * @returns the cloned material
  16525. */
  16526. clone(name: string): ShaderMaterial;
  16527. /**
  16528. * Disposes the material
  16529. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16530. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16531. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16532. */
  16533. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16534. /**
  16535. * Serializes this material in a JSON representation
  16536. * @returns the serialized material object
  16537. */
  16538. serialize(): any;
  16539. /**
  16540. * Creates a shader material from parsed shader material data
  16541. * @param source defines the JSON represnetation of the material
  16542. * @param scene defines the hosting scene
  16543. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16544. * @returns a new material
  16545. */
  16546. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16547. }
  16548. }
  16549. declare module BABYLON {
  16550. /** @hidden */
  16551. export var colorPixelShader: {
  16552. name: string;
  16553. shader: string;
  16554. };
  16555. }
  16556. declare module BABYLON {
  16557. /** @hidden */
  16558. export var colorVertexShader: {
  16559. name: string;
  16560. shader: string;
  16561. };
  16562. }
  16563. declare module BABYLON {
  16564. /**
  16565. * Line mesh
  16566. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16567. */
  16568. export class LinesMesh extends Mesh {
  16569. /**
  16570. * If vertex color should be applied to the mesh
  16571. */
  16572. useVertexColor?: boolean | undefined;
  16573. /**
  16574. * If vertex alpha should be applied to the mesh
  16575. */
  16576. useVertexAlpha?: boolean | undefined;
  16577. /**
  16578. * Color of the line (Default: White)
  16579. */
  16580. color: Color3;
  16581. /**
  16582. * Alpha of the line (Default: 1)
  16583. */
  16584. alpha: number;
  16585. /**
  16586. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16587. * This margin is expressed in world space coordinates, so its value may vary.
  16588. * Default value is 0.1
  16589. */
  16590. intersectionThreshold: number;
  16591. private _colorShader;
  16592. /**
  16593. * Creates a new LinesMesh
  16594. * @param name defines the name
  16595. * @param scene defines the hosting scene
  16596. * @param parent defines the parent mesh if any
  16597. * @param source defines the optional source LinesMesh used to clone data from
  16598. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16599. * When false, achieved by calling a clone(), also passing False.
  16600. * This will make creation of children, recursive.
  16601. * @param useVertexColor defines if this LinesMesh supports vertex color
  16602. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16603. */
  16604. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16605. /**
  16606. * If vertex color should be applied to the mesh
  16607. */
  16608. useVertexColor?: boolean | undefined,
  16609. /**
  16610. * If vertex alpha should be applied to the mesh
  16611. */
  16612. useVertexAlpha?: boolean | undefined);
  16613. /**
  16614. * Returns the string "LineMesh"
  16615. */
  16616. getClassName(): string;
  16617. /**
  16618. * @hidden
  16619. */
  16620. /**
  16621. * @hidden
  16622. */
  16623. material: Material;
  16624. /**
  16625. * @hidden
  16626. */
  16627. readonly checkCollisions: boolean;
  16628. /** @hidden */
  16629. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16630. /** @hidden */
  16631. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16632. /**
  16633. * Disposes of the line mesh
  16634. * @param doNotRecurse If children should be disposed
  16635. */
  16636. dispose(doNotRecurse?: boolean): void;
  16637. /**
  16638. * Returns a new LineMesh object cloned from the current one.
  16639. */
  16640. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16641. /**
  16642. * Creates a new InstancedLinesMesh object from the mesh model.
  16643. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16644. * @param name defines the name of the new instance
  16645. * @returns a new InstancedLinesMesh
  16646. */
  16647. createInstance(name: string): InstancedLinesMesh;
  16648. }
  16649. /**
  16650. * Creates an instance based on a source LinesMesh
  16651. */
  16652. export class InstancedLinesMesh extends InstancedMesh {
  16653. /**
  16654. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16655. * This margin is expressed in world space coordinates, so its value may vary.
  16656. * Initilized with the intersectionThreshold value of the source LinesMesh
  16657. */
  16658. intersectionThreshold: number;
  16659. constructor(name: string, source: LinesMesh);
  16660. /**
  16661. * Returns the string "InstancedLinesMesh".
  16662. */
  16663. getClassName(): string;
  16664. }
  16665. }
  16666. declare module BABYLON {
  16667. /** @hidden */
  16668. export var linePixelShader: {
  16669. name: string;
  16670. shader: string;
  16671. };
  16672. }
  16673. declare module BABYLON {
  16674. /** @hidden */
  16675. export var lineVertexShader: {
  16676. name: string;
  16677. shader: string;
  16678. };
  16679. }
  16680. declare module BABYLON {
  16681. interface AbstractMesh {
  16682. /**
  16683. * Disables the mesh edge rendering mode
  16684. * @returns the currentAbstractMesh
  16685. */
  16686. disableEdgesRendering(): AbstractMesh;
  16687. /**
  16688. * Enables the edge rendering mode on the mesh.
  16689. * This mode makes the mesh edges visible
  16690. * @param epsilon defines the maximal distance between two angles to detect a face
  16691. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16692. * @returns the currentAbstractMesh
  16693. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16694. */
  16695. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16696. /**
  16697. * Gets the edgesRenderer associated with the mesh
  16698. */
  16699. edgesRenderer: Nullable<EdgesRenderer>;
  16700. }
  16701. interface LinesMesh {
  16702. /**
  16703. * Enables the edge rendering mode on the mesh.
  16704. * This mode makes the mesh edges visible
  16705. * @param epsilon defines the maximal distance between two angles to detect a face
  16706. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16707. * @returns the currentAbstractMesh
  16708. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16709. */
  16710. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16711. }
  16712. interface InstancedLinesMesh {
  16713. /**
  16714. * Enables the edge rendering mode on the mesh.
  16715. * This mode makes the mesh edges visible
  16716. * @param epsilon defines the maximal distance between two angles to detect a face
  16717. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16718. * @returns the current InstancedLinesMesh
  16719. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16720. */
  16721. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16722. }
  16723. /**
  16724. * Defines the minimum contract an Edges renderer should follow.
  16725. */
  16726. export interface IEdgesRenderer extends IDisposable {
  16727. /**
  16728. * Gets or sets a boolean indicating if the edgesRenderer is active
  16729. */
  16730. isEnabled: boolean;
  16731. /**
  16732. * Renders the edges of the attached mesh,
  16733. */
  16734. render(): void;
  16735. /**
  16736. * Checks wether or not the edges renderer is ready to render.
  16737. * @return true if ready, otherwise false.
  16738. */
  16739. isReady(): boolean;
  16740. }
  16741. /**
  16742. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16743. */
  16744. export class EdgesRenderer implements IEdgesRenderer {
  16745. /**
  16746. * Define the size of the edges with an orthographic camera
  16747. */
  16748. edgesWidthScalerForOrthographic: number;
  16749. /**
  16750. * Define the size of the edges with a perspective camera
  16751. */
  16752. edgesWidthScalerForPerspective: number;
  16753. protected _source: AbstractMesh;
  16754. protected _linesPositions: number[];
  16755. protected _linesNormals: number[];
  16756. protected _linesIndices: number[];
  16757. protected _epsilon: number;
  16758. protected _indicesCount: number;
  16759. protected _lineShader: ShaderMaterial;
  16760. protected _ib: WebGLBuffer;
  16761. protected _buffers: {
  16762. [key: string]: Nullable<VertexBuffer>;
  16763. };
  16764. protected _checkVerticesInsteadOfIndices: boolean;
  16765. private _meshRebuildObserver;
  16766. private _meshDisposeObserver;
  16767. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16768. isEnabled: boolean;
  16769. /**
  16770. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16771. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16772. * @param source Mesh used to create edges
  16773. * @param epsilon sum of angles in adjacency to check for edge
  16774. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16775. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16776. */
  16777. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16778. protected _prepareRessources(): void;
  16779. /** @hidden */
  16780. _rebuild(): void;
  16781. /**
  16782. * Releases the required resources for the edges renderer
  16783. */
  16784. dispose(): void;
  16785. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16786. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16787. /**
  16788. * Checks if the pair of p0 and p1 is en edge
  16789. * @param faceIndex
  16790. * @param edge
  16791. * @param faceNormals
  16792. * @param p0
  16793. * @param p1
  16794. * @private
  16795. */
  16796. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16797. /**
  16798. * push line into the position, normal and index buffer
  16799. * @protected
  16800. */
  16801. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16802. /**
  16803. * Generates lines edges from adjacencjes
  16804. * @private
  16805. */
  16806. _generateEdgesLines(): void;
  16807. /**
  16808. * Checks wether or not the edges renderer is ready to render.
  16809. * @return true if ready, otherwise false.
  16810. */
  16811. isReady(): boolean;
  16812. /**
  16813. * Renders the edges of the attached mesh,
  16814. */
  16815. render(): void;
  16816. }
  16817. /**
  16818. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16819. */
  16820. export class LineEdgesRenderer extends EdgesRenderer {
  16821. /**
  16822. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16823. * @param source LineMesh used to generate edges
  16824. * @param epsilon not important (specified angle for edge detection)
  16825. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16826. */
  16827. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16828. /**
  16829. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16830. */
  16831. _generateEdgesLines(): void;
  16832. }
  16833. }
  16834. declare module BABYLON {
  16835. /**
  16836. * This represents the object necessary to create a rendering group.
  16837. * This is exclusively used and created by the rendering manager.
  16838. * To modify the behavior, you use the available helpers in your scene or meshes.
  16839. * @hidden
  16840. */
  16841. export class RenderingGroup {
  16842. index: number;
  16843. private _scene;
  16844. private _opaqueSubMeshes;
  16845. private _transparentSubMeshes;
  16846. private _alphaTestSubMeshes;
  16847. private _depthOnlySubMeshes;
  16848. private _particleSystems;
  16849. private _spriteManagers;
  16850. private _opaqueSortCompareFn;
  16851. private _alphaTestSortCompareFn;
  16852. private _transparentSortCompareFn;
  16853. private _renderOpaque;
  16854. private _renderAlphaTest;
  16855. private _renderTransparent;
  16856. private _edgesRenderers;
  16857. onBeforeTransparentRendering: () => void;
  16858. /**
  16859. * Set the opaque sort comparison function.
  16860. * If null the sub meshes will be render in the order they were created
  16861. */
  16862. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16863. /**
  16864. * Set the alpha test sort comparison function.
  16865. * If null the sub meshes will be render in the order they were created
  16866. */
  16867. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16868. /**
  16869. * Set the transparent sort comparison function.
  16870. * If null the sub meshes will be render in the order they were created
  16871. */
  16872. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16873. /**
  16874. * Creates a new rendering group.
  16875. * @param index The rendering group index
  16876. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16877. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16878. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16879. */
  16880. 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>);
  16881. /**
  16882. * Render all the sub meshes contained in the group.
  16883. * @param customRenderFunction Used to override the default render behaviour of the group.
  16884. * @returns true if rendered some submeshes.
  16885. */
  16886. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16887. /**
  16888. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16889. * @param subMeshes The submeshes to render
  16890. */
  16891. private renderOpaqueSorted;
  16892. /**
  16893. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16894. * @param subMeshes The submeshes to render
  16895. */
  16896. private renderAlphaTestSorted;
  16897. /**
  16898. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16899. * @param subMeshes The submeshes to render
  16900. */
  16901. private renderTransparentSorted;
  16902. /**
  16903. * Renders the submeshes in a specified order.
  16904. * @param subMeshes The submeshes to sort before render
  16905. * @param sortCompareFn The comparison function use to sort
  16906. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16907. * @param transparent Specifies to activate blending if true
  16908. */
  16909. private static renderSorted;
  16910. /**
  16911. * Renders the submeshes in the order they were dispatched (no sort applied).
  16912. * @param subMeshes The submeshes to render
  16913. */
  16914. private static renderUnsorted;
  16915. /**
  16916. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16917. * are rendered back to front if in the same alpha index.
  16918. *
  16919. * @param a The first submesh
  16920. * @param b The second submesh
  16921. * @returns The result of the comparison
  16922. */
  16923. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16924. /**
  16925. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16926. * are rendered back to front.
  16927. *
  16928. * @param a The first submesh
  16929. * @param b The second submesh
  16930. * @returns The result of the comparison
  16931. */
  16932. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16933. /**
  16934. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16935. * are rendered front to back (prevent overdraw).
  16936. *
  16937. * @param a The first submesh
  16938. * @param b The second submesh
  16939. * @returns The result of the comparison
  16940. */
  16941. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16942. /**
  16943. * Resets the different lists of submeshes to prepare a new frame.
  16944. */
  16945. prepare(): void;
  16946. dispose(): void;
  16947. /**
  16948. * Inserts the submesh in its correct queue depending on its material.
  16949. * @param subMesh The submesh to dispatch
  16950. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16951. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16952. */
  16953. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16954. dispatchSprites(spriteManager: ISpriteManager): void;
  16955. dispatchParticles(particleSystem: IParticleSystem): void;
  16956. private _renderParticles;
  16957. private _renderSprites;
  16958. }
  16959. }
  16960. declare module BABYLON {
  16961. /**
  16962. * Interface describing the different options available in the rendering manager
  16963. * regarding Auto Clear between groups.
  16964. */
  16965. export interface IRenderingManagerAutoClearSetup {
  16966. /**
  16967. * Defines whether or not autoclear is enable.
  16968. */
  16969. autoClear: boolean;
  16970. /**
  16971. * Defines whether or not to autoclear the depth buffer.
  16972. */
  16973. depth: boolean;
  16974. /**
  16975. * Defines whether or not to autoclear the stencil buffer.
  16976. */
  16977. stencil: boolean;
  16978. }
  16979. /**
  16980. * This class is used by the onRenderingGroupObservable
  16981. */
  16982. export class RenderingGroupInfo {
  16983. /**
  16984. * The Scene that being rendered
  16985. */
  16986. scene: Scene;
  16987. /**
  16988. * The camera currently used for the rendering pass
  16989. */
  16990. camera: Nullable<Camera>;
  16991. /**
  16992. * The ID of the renderingGroup being processed
  16993. */
  16994. renderingGroupId: number;
  16995. }
  16996. /**
  16997. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16998. * It is enable to manage the different groups as well as the different necessary sort functions.
  16999. * This should not be used directly aside of the few static configurations
  17000. */
  17001. export class RenderingManager {
  17002. /**
  17003. * The max id used for rendering groups (not included)
  17004. */
  17005. static MAX_RENDERINGGROUPS: number;
  17006. /**
  17007. * The min id used for rendering groups (included)
  17008. */
  17009. static MIN_RENDERINGGROUPS: number;
  17010. /**
  17011. * Used to globally prevent autoclearing scenes.
  17012. */
  17013. static AUTOCLEAR: boolean;
  17014. /**
  17015. * @hidden
  17016. */
  17017. _useSceneAutoClearSetup: boolean;
  17018. private _scene;
  17019. private _renderingGroups;
  17020. private _depthStencilBufferAlreadyCleaned;
  17021. private _autoClearDepthStencil;
  17022. private _customOpaqueSortCompareFn;
  17023. private _customAlphaTestSortCompareFn;
  17024. private _customTransparentSortCompareFn;
  17025. private _renderingGroupInfo;
  17026. /**
  17027. * Instantiates a new rendering group for a particular scene
  17028. * @param scene Defines the scene the groups belongs to
  17029. */
  17030. constructor(scene: Scene);
  17031. private _clearDepthStencilBuffer;
  17032. /**
  17033. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17034. * @hidden
  17035. */
  17036. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17037. /**
  17038. * Resets the different information of the group to prepare a new frame
  17039. * @hidden
  17040. */
  17041. reset(): void;
  17042. /**
  17043. * Dispose and release the group and its associated resources.
  17044. * @hidden
  17045. */
  17046. dispose(): void;
  17047. /**
  17048. * Clear the info related to rendering groups preventing retention points during dispose.
  17049. */
  17050. freeRenderingGroups(): void;
  17051. private _prepareRenderingGroup;
  17052. /**
  17053. * Add a sprite manager to the rendering manager in order to render it this frame.
  17054. * @param spriteManager Define the sprite manager to render
  17055. */
  17056. dispatchSprites(spriteManager: ISpriteManager): void;
  17057. /**
  17058. * Add a particle system to the rendering manager in order to render it this frame.
  17059. * @param particleSystem Define the particle system to render
  17060. */
  17061. dispatchParticles(particleSystem: IParticleSystem): void;
  17062. /**
  17063. * Add a submesh to the manager in order to render it this frame
  17064. * @param subMesh The submesh to dispatch
  17065. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17066. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17067. */
  17068. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17069. /**
  17070. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17071. * This allowed control for front to back rendering or reversly depending of the special needs.
  17072. *
  17073. * @param renderingGroupId The rendering group id corresponding to its index
  17074. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17075. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17076. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17077. */
  17078. 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;
  17079. /**
  17080. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17081. *
  17082. * @param renderingGroupId The rendering group id corresponding to its index
  17083. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17084. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17085. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17086. */
  17087. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17088. /**
  17089. * Gets the current auto clear configuration for one rendering group of the rendering
  17090. * manager.
  17091. * @param index the rendering group index to get the information for
  17092. * @returns The auto clear setup for the requested rendering group
  17093. */
  17094. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17095. }
  17096. }
  17097. declare module BABYLON {
  17098. /**
  17099. * This Helps creating a texture that will be created from a camera in your scene.
  17100. * It is basically a dynamic texture that could be used to create special effects for instance.
  17101. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17102. */
  17103. export class RenderTargetTexture extends Texture {
  17104. isCube: boolean;
  17105. /**
  17106. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17107. */
  17108. static readonly REFRESHRATE_RENDER_ONCE: number;
  17109. /**
  17110. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17111. */
  17112. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17113. /**
  17114. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17115. * the central point of your effect and can save a lot of performances.
  17116. */
  17117. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17118. /**
  17119. * Use this predicate to dynamically define the list of mesh you want to render.
  17120. * If set, the renderList property will be overwritten.
  17121. */
  17122. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17123. private _renderList;
  17124. /**
  17125. * Use this list to define the list of mesh you want to render.
  17126. */
  17127. renderList: Nullable<Array<AbstractMesh>>;
  17128. private _hookArray;
  17129. /**
  17130. * Define if particles should be rendered in your texture.
  17131. */
  17132. renderParticles: boolean;
  17133. /**
  17134. * Define if sprites should be rendered in your texture.
  17135. */
  17136. renderSprites: boolean;
  17137. /**
  17138. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17139. */
  17140. coordinatesMode: number;
  17141. /**
  17142. * Define the camera used to render the texture.
  17143. */
  17144. activeCamera: Nullable<Camera>;
  17145. /**
  17146. * Override the render function of the texture with your own one.
  17147. */
  17148. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17149. /**
  17150. * Define if camera post processes should be use while rendering the texture.
  17151. */
  17152. useCameraPostProcesses: boolean;
  17153. /**
  17154. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17155. */
  17156. ignoreCameraViewport: boolean;
  17157. private _postProcessManager;
  17158. private _postProcesses;
  17159. private _resizeObserver;
  17160. /**
  17161. * An event triggered when the texture is unbind.
  17162. */
  17163. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17164. /**
  17165. * An event triggered when the texture is unbind.
  17166. */
  17167. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17168. private _onAfterUnbindObserver;
  17169. /**
  17170. * Set a after unbind callback in the texture.
  17171. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17172. */
  17173. onAfterUnbind: () => void;
  17174. /**
  17175. * An event triggered before rendering the texture
  17176. */
  17177. onBeforeRenderObservable: Observable<number>;
  17178. private _onBeforeRenderObserver;
  17179. /**
  17180. * Set a before render callback in the texture.
  17181. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17182. */
  17183. onBeforeRender: (faceIndex: number) => void;
  17184. /**
  17185. * An event triggered after rendering the texture
  17186. */
  17187. onAfterRenderObservable: Observable<number>;
  17188. private _onAfterRenderObserver;
  17189. /**
  17190. * Set a after render callback in the texture.
  17191. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17192. */
  17193. onAfterRender: (faceIndex: number) => void;
  17194. /**
  17195. * An event triggered after the texture clear
  17196. */
  17197. onClearObservable: Observable<Engine>;
  17198. private _onClearObserver;
  17199. /**
  17200. * Set a clear callback in the texture.
  17201. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17202. */
  17203. onClear: (Engine: Engine) => void;
  17204. /**
  17205. * Define the clear color of the Render Target if it should be different from the scene.
  17206. */
  17207. clearColor: Color4;
  17208. protected _size: number | {
  17209. width: number;
  17210. height: number;
  17211. };
  17212. protected _initialSizeParameter: number | {
  17213. width: number;
  17214. height: number;
  17215. } | {
  17216. ratio: number;
  17217. };
  17218. protected _sizeRatio: Nullable<number>;
  17219. /** @hidden */
  17220. _generateMipMaps: boolean;
  17221. protected _renderingManager: RenderingManager;
  17222. /** @hidden */
  17223. _waitingRenderList: string[];
  17224. protected _doNotChangeAspectRatio: boolean;
  17225. protected _currentRefreshId: number;
  17226. protected _refreshRate: number;
  17227. protected _textureMatrix: Matrix;
  17228. protected _samples: number;
  17229. protected _renderTargetOptions: RenderTargetCreationOptions;
  17230. /**
  17231. * Gets render target creation options that were used.
  17232. */
  17233. readonly renderTargetOptions: RenderTargetCreationOptions;
  17234. protected _engine: Engine;
  17235. protected _onRatioRescale(): void;
  17236. /**
  17237. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17238. * It must define where the camera used to render the texture is set
  17239. */
  17240. boundingBoxPosition: Vector3;
  17241. private _boundingBoxSize;
  17242. /**
  17243. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17244. * When defined, the cubemap will switch to local mode
  17245. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17246. * @example https://www.babylonjs-playground.com/#RNASML
  17247. */
  17248. boundingBoxSize: Vector3;
  17249. /**
  17250. * In case the RTT has been created with a depth texture, get the associated
  17251. * depth texture.
  17252. * Otherwise, return null.
  17253. */
  17254. depthStencilTexture: Nullable<InternalTexture>;
  17255. /**
  17256. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17257. * or used a shadow, depth texture...
  17258. * @param name The friendly name of the texture
  17259. * @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)
  17260. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17261. * @param generateMipMaps True if mip maps need to be generated after render.
  17262. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17263. * @param type The type of the buffer in the RTT (int, half float, float...)
  17264. * @param isCube True if a cube texture needs to be created
  17265. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17266. * @param generateDepthBuffer True to generate a depth buffer
  17267. * @param generateStencilBuffer True to generate a stencil buffer
  17268. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17269. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17270. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17271. */
  17272. constructor(name: string, size: number | {
  17273. width: number;
  17274. height: number;
  17275. } | {
  17276. ratio: number;
  17277. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17278. /**
  17279. * Creates a depth stencil texture.
  17280. * This is only available in WebGL 2 or with the depth texture extension available.
  17281. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17282. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17283. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17284. */
  17285. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17286. private _processSizeParameter;
  17287. /**
  17288. * Define the number of samples to use in case of MSAA.
  17289. * It defaults to one meaning no MSAA has been enabled.
  17290. */
  17291. samples: number;
  17292. /**
  17293. * Resets the refresh counter of the texture and start bak from scratch.
  17294. * Could be useful to regenerate the texture if it is setup to render only once.
  17295. */
  17296. resetRefreshCounter(): void;
  17297. /**
  17298. * Define the refresh rate of the texture or the rendering frequency.
  17299. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17300. */
  17301. refreshRate: number;
  17302. /**
  17303. * Adds a post process to the render target rendering passes.
  17304. * @param postProcess define the post process to add
  17305. */
  17306. addPostProcess(postProcess: PostProcess): void;
  17307. /**
  17308. * Clear all the post processes attached to the render target
  17309. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17310. */
  17311. clearPostProcesses(dispose?: boolean): void;
  17312. /**
  17313. * Remove one of the post process from the list of attached post processes to the texture
  17314. * @param postProcess define the post process to remove from the list
  17315. */
  17316. removePostProcess(postProcess: PostProcess): void;
  17317. /** @hidden */
  17318. _shouldRender(): boolean;
  17319. /**
  17320. * Gets the actual render size of the texture.
  17321. * @returns the width of the render size
  17322. */
  17323. getRenderSize(): number;
  17324. /**
  17325. * Gets the actual render width of the texture.
  17326. * @returns the width of the render size
  17327. */
  17328. getRenderWidth(): number;
  17329. /**
  17330. * Gets the actual render height of the texture.
  17331. * @returns the height of the render size
  17332. */
  17333. getRenderHeight(): number;
  17334. /**
  17335. * Get if the texture can be rescaled or not.
  17336. */
  17337. readonly canRescale: boolean;
  17338. /**
  17339. * Resize the texture using a ratio.
  17340. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17341. */
  17342. scale(ratio: number): void;
  17343. /**
  17344. * Get the texture reflection matrix used to rotate/transform the reflection.
  17345. * @returns the reflection matrix
  17346. */
  17347. getReflectionTextureMatrix(): Matrix;
  17348. /**
  17349. * Resize the texture to a new desired size.
  17350. * Be carrefull as it will recreate all the data in the new texture.
  17351. * @param size Define the new size. It can be:
  17352. * - a number for squared texture,
  17353. * - an object containing { width: number, height: number }
  17354. * - or an object containing a ratio { ratio: number }
  17355. */
  17356. resize(size: number | {
  17357. width: number;
  17358. height: number;
  17359. } | {
  17360. ratio: number;
  17361. }): void;
  17362. /**
  17363. * Renders all the objects from the render list into the texture.
  17364. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17365. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17366. */
  17367. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17368. private _bestReflectionRenderTargetDimension;
  17369. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17370. private renderToTarget;
  17371. /**
  17372. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17373. * This allowed control for front to back rendering or reversly depending of the special needs.
  17374. *
  17375. * @param renderingGroupId The rendering group id corresponding to its index
  17376. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17377. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17378. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17379. */
  17380. 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;
  17381. /**
  17382. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17383. *
  17384. * @param renderingGroupId The rendering group id corresponding to its index
  17385. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17386. */
  17387. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17388. /**
  17389. * Clones the texture.
  17390. * @returns the cloned texture
  17391. */
  17392. clone(): RenderTargetTexture;
  17393. /**
  17394. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17395. * @returns The JSON representation of the texture
  17396. */
  17397. serialize(): any;
  17398. /**
  17399. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17400. */
  17401. disposeFramebufferObjects(): void;
  17402. /**
  17403. * Dispose the texture and release its associated resources.
  17404. */
  17405. dispose(): void;
  17406. /** @hidden */
  17407. _rebuild(): void;
  17408. /**
  17409. * Clear the info related to rendering groups preventing retention point in material dispose.
  17410. */
  17411. freeRenderingGroups(): void;
  17412. }
  17413. }
  17414. declare module BABYLON {
  17415. /**
  17416. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17417. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17418. * You can then easily use it as a reflectionTexture on a flat surface.
  17419. * In case the surface is not a plane, please consider relying on reflection probes.
  17420. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17421. */
  17422. export class MirrorTexture extends RenderTargetTexture {
  17423. private scene;
  17424. /**
  17425. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17426. * 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.
  17427. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17428. */
  17429. mirrorPlane: Plane;
  17430. /**
  17431. * Define the blur ratio used to blur the reflection if needed.
  17432. */
  17433. blurRatio: number;
  17434. /**
  17435. * Define the adaptive blur kernel used to blur the reflection if needed.
  17436. * This will autocompute the closest best match for the `blurKernel`
  17437. */
  17438. adaptiveBlurKernel: number;
  17439. /**
  17440. * Define the blur kernel used to blur the reflection if needed.
  17441. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17442. */
  17443. blurKernel: number;
  17444. /**
  17445. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17446. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17447. */
  17448. blurKernelX: number;
  17449. /**
  17450. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17451. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17452. */
  17453. blurKernelY: number;
  17454. private _autoComputeBlurKernel;
  17455. protected _onRatioRescale(): void;
  17456. private _updateGammaSpace;
  17457. private _imageProcessingConfigChangeObserver;
  17458. private _transformMatrix;
  17459. private _mirrorMatrix;
  17460. private _savedViewMatrix;
  17461. private _blurX;
  17462. private _blurY;
  17463. private _adaptiveBlurKernel;
  17464. private _blurKernelX;
  17465. private _blurKernelY;
  17466. private _blurRatio;
  17467. /**
  17468. * Instantiates a Mirror Texture.
  17469. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17470. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17471. * You can then easily use it as a reflectionTexture on a flat surface.
  17472. * In case the surface is not a plane, please consider relying on reflection probes.
  17473. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17474. * @param name
  17475. * @param size
  17476. * @param scene
  17477. * @param generateMipMaps
  17478. * @param type
  17479. * @param samplingMode
  17480. * @param generateDepthBuffer
  17481. */
  17482. constructor(name: string, size: number | {
  17483. width: number;
  17484. height: number;
  17485. } | {
  17486. ratio: number;
  17487. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17488. private _preparePostProcesses;
  17489. /**
  17490. * Clone the mirror texture.
  17491. * @returns the cloned texture
  17492. */
  17493. clone(): MirrorTexture;
  17494. /**
  17495. * Serialize the texture to a JSON representation you could use in Parse later on
  17496. * @returns the serialized JSON representation
  17497. */
  17498. serialize(): any;
  17499. /**
  17500. * Dispose the texture and release its associated resources.
  17501. */
  17502. dispose(): void;
  17503. }
  17504. }
  17505. declare module BABYLON {
  17506. /**
  17507. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17508. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17509. */
  17510. export class Texture extends BaseTexture {
  17511. /** @hidden */
  17512. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17513. /** @hidden */
  17514. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17515. /** @hidden */
  17516. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17517. /** nearest is mag = nearest and min = nearest and mip = linear */
  17518. static readonly NEAREST_SAMPLINGMODE: number;
  17519. /** nearest is mag = nearest and min = nearest and mip = linear */
  17520. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17521. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17522. static readonly BILINEAR_SAMPLINGMODE: number;
  17523. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17524. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17525. /** Trilinear is mag = linear and min = linear and mip = linear */
  17526. static readonly TRILINEAR_SAMPLINGMODE: number;
  17527. /** Trilinear is mag = linear and min = linear and mip = linear */
  17528. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17529. /** mag = nearest and min = nearest and mip = nearest */
  17530. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17531. /** mag = nearest and min = linear and mip = nearest */
  17532. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17533. /** mag = nearest and min = linear and mip = linear */
  17534. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17535. /** mag = nearest and min = linear and mip = none */
  17536. static readonly NEAREST_LINEAR: number;
  17537. /** mag = nearest and min = nearest and mip = none */
  17538. static readonly NEAREST_NEAREST: number;
  17539. /** mag = linear and min = nearest and mip = nearest */
  17540. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17541. /** mag = linear and min = nearest and mip = linear */
  17542. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17543. /** mag = linear and min = linear and mip = none */
  17544. static readonly LINEAR_LINEAR: number;
  17545. /** mag = linear and min = nearest and mip = none */
  17546. static readonly LINEAR_NEAREST: number;
  17547. /** Explicit coordinates mode */
  17548. static readonly EXPLICIT_MODE: number;
  17549. /** Spherical coordinates mode */
  17550. static readonly SPHERICAL_MODE: number;
  17551. /** Planar coordinates mode */
  17552. static readonly PLANAR_MODE: number;
  17553. /** Cubic coordinates mode */
  17554. static readonly CUBIC_MODE: number;
  17555. /** Projection coordinates mode */
  17556. static readonly PROJECTION_MODE: number;
  17557. /** Inverse Cubic coordinates mode */
  17558. static readonly SKYBOX_MODE: number;
  17559. /** Inverse Cubic coordinates mode */
  17560. static readonly INVCUBIC_MODE: number;
  17561. /** Equirectangular coordinates mode */
  17562. static readonly EQUIRECTANGULAR_MODE: number;
  17563. /** Equirectangular Fixed coordinates mode */
  17564. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17565. /** Equirectangular Fixed Mirrored coordinates mode */
  17566. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17567. /** Texture is not repeating outside of 0..1 UVs */
  17568. static readonly CLAMP_ADDRESSMODE: number;
  17569. /** Texture is repeating outside of 0..1 UVs */
  17570. static readonly WRAP_ADDRESSMODE: number;
  17571. /** Texture is repeating and mirrored */
  17572. static readonly MIRROR_ADDRESSMODE: number;
  17573. /**
  17574. * 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
  17575. */
  17576. static UseSerializedUrlIfAny: boolean;
  17577. /**
  17578. * Define the url of the texture.
  17579. */
  17580. url: Nullable<string>;
  17581. /**
  17582. * Define an offset on the texture to offset the u coordinates of the UVs
  17583. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17584. */
  17585. uOffset: number;
  17586. /**
  17587. * Define an offset on the texture to offset the v coordinates of the UVs
  17588. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17589. */
  17590. vOffset: number;
  17591. /**
  17592. * Define an offset on the texture to scale the u coordinates of the UVs
  17593. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17594. */
  17595. uScale: number;
  17596. /**
  17597. * Define an offset on the texture to scale the v coordinates of the UVs
  17598. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17599. */
  17600. vScale: number;
  17601. /**
  17602. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17603. * @see http://doc.babylonjs.com/how_to/more_materials
  17604. */
  17605. uAng: number;
  17606. /**
  17607. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17608. * @see http://doc.babylonjs.com/how_to/more_materials
  17609. */
  17610. vAng: number;
  17611. /**
  17612. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17613. * @see http://doc.babylonjs.com/how_to/more_materials
  17614. */
  17615. wAng: number;
  17616. /**
  17617. * Defines the center of rotation (U)
  17618. */
  17619. uRotationCenter: number;
  17620. /**
  17621. * Defines the center of rotation (V)
  17622. */
  17623. vRotationCenter: number;
  17624. /**
  17625. * Defines the center of rotation (W)
  17626. */
  17627. wRotationCenter: number;
  17628. /**
  17629. * Are mip maps generated for this texture or not.
  17630. */
  17631. readonly noMipmap: boolean;
  17632. private _noMipmap;
  17633. /** @hidden */
  17634. _invertY: boolean;
  17635. private _rowGenerationMatrix;
  17636. private _cachedTextureMatrix;
  17637. private _projectionModeMatrix;
  17638. private _t0;
  17639. private _t1;
  17640. private _t2;
  17641. private _cachedUOffset;
  17642. private _cachedVOffset;
  17643. private _cachedUScale;
  17644. private _cachedVScale;
  17645. private _cachedUAng;
  17646. private _cachedVAng;
  17647. private _cachedWAng;
  17648. private _cachedProjectionMatrixId;
  17649. private _cachedCoordinatesMode;
  17650. /** @hidden */
  17651. protected _initialSamplingMode: number;
  17652. /** @hidden */
  17653. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  17654. private _deleteBuffer;
  17655. protected _format: Nullable<number>;
  17656. private _delayedOnLoad;
  17657. private _delayedOnError;
  17658. /**
  17659. * Observable triggered once the texture has been loaded.
  17660. */
  17661. onLoadObservable: Observable<Texture>;
  17662. protected _isBlocking: boolean;
  17663. /**
  17664. * Is the texture preventing material to render while loading.
  17665. * If false, a default texture will be used instead of the loading one during the preparation step.
  17666. */
  17667. isBlocking: boolean;
  17668. /**
  17669. * Get the current sampling mode associated with the texture.
  17670. */
  17671. readonly samplingMode: number;
  17672. /**
  17673. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  17674. */
  17675. readonly invertY: boolean;
  17676. /**
  17677. * Instantiates a new texture.
  17678. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17679. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17680. * @param url define the url of the picture to load as a texture
  17681. * @param scene define the scene the texture will belong to
  17682. * @param noMipmap define if the texture will require mip maps or not
  17683. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17684. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17685. * @param onLoad define a callback triggered when the texture has been loaded
  17686. * @param onError define a callback triggered when an error occurred during the loading session
  17687. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17688. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17689. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17690. */
  17691. 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);
  17692. /**
  17693. * Update the url (and optional buffer) of this texture if url was null during construction.
  17694. * @param url the url of the texture
  17695. * @param buffer the buffer of the texture (defaults to null)
  17696. * @param onLoad callback called when the texture is loaded (defaults to null)
  17697. */
  17698. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  17699. /**
  17700. * Finish the loading sequence of a texture flagged as delayed load.
  17701. * @hidden
  17702. */
  17703. delayLoad(): void;
  17704. private _prepareRowForTextureGeneration;
  17705. /**
  17706. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  17707. * @returns the transform matrix of the texture.
  17708. */
  17709. getTextureMatrix(): Matrix;
  17710. /**
  17711. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  17712. * @returns The reflection texture transform
  17713. */
  17714. getReflectionTextureMatrix(): Matrix;
  17715. /**
  17716. * Clones the texture.
  17717. * @returns the cloned texture
  17718. */
  17719. clone(): Texture;
  17720. /**
  17721. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17722. * @returns The JSON representation of the texture
  17723. */
  17724. serialize(): any;
  17725. /**
  17726. * Get the current class name of the texture useful for serialization or dynamic coding.
  17727. * @returns "Texture"
  17728. */
  17729. getClassName(): string;
  17730. /**
  17731. * Dispose the texture and release its associated resources.
  17732. */
  17733. dispose(): void;
  17734. /**
  17735. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  17736. * @param parsedTexture Define the JSON representation of the texture
  17737. * @param scene Define the scene the parsed texture should be instantiated in
  17738. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  17739. * @returns The parsed texture if successful
  17740. */
  17741. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  17742. /**
  17743. * Creates a texture from its base 64 representation.
  17744. * @param data Define the base64 payload without the data: prefix
  17745. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17746. * @param scene Define the scene the texture should belong to
  17747. * @param noMipmap Forces the texture to not create mip map information if true
  17748. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17749. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17750. * @param onLoad define a callback triggered when the texture has been loaded
  17751. * @param onError define a callback triggered when an error occurred during the loading session
  17752. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17753. * @returns the created texture
  17754. */
  17755. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  17756. /**
  17757. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  17758. * @param data Define the base64 payload without the data: prefix
  17759. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17760. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17761. * @param scene Define the scene the texture should belong to
  17762. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17763. * @param noMipmap Forces the texture to not create mip map information if true
  17764. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17765. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17766. * @param onLoad define a callback triggered when the texture has been loaded
  17767. * @param onError define a callback triggered when an error occurred during the loading session
  17768. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17769. * @returns the created texture
  17770. */
  17771. 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;
  17772. }
  17773. }
  17774. declare module BABYLON {
  17775. /**
  17776. * Raw texture can help creating a texture directly from an array of data.
  17777. * This can be super useful if you either get the data from an uncompressed source or
  17778. * if you wish to create your texture pixel by pixel.
  17779. */
  17780. export class RawTexture extends Texture {
  17781. /**
  17782. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  17783. */
  17784. format: number;
  17785. private _engine;
  17786. /**
  17787. * Instantiates a new RawTexture.
  17788. * Raw texture can help creating a texture directly from an array of data.
  17789. * This can be super useful if you either get the data from an uncompressed source or
  17790. * if you wish to create your texture pixel by pixel.
  17791. * @param data define the array of data to use to create the texture
  17792. * @param width define the width of the texture
  17793. * @param height define the height of the texture
  17794. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  17795. * @param scene define the scene the texture belongs to
  17796. * @param generateMipMaps define whether mip maps should be generated or not
  17797. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17798. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17799. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17800. */
  17801. constructor(data: ArrayBufferView, width: number, height: number,
  17802. /**
  17803. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  17804. */
  17805. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  17806. /**
  17807. * Updates the texture underlying data.
  17808. * @param data Define the new data of the texture
  17809. */
  17810. update(data: ArrayBufferView): void;
  17811. /**
  17812. * Creates a luminance texture from some data.
  17813. * @param data Define the texture data
  17814. * @param width Define the width of the texture
  17815. * @param height Define the height of the texture
  17816. * @param scene Define the scene the texture belongs to
  17817. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17818. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17819. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17820. * @returns the luminance texture
  17821. */
  17822. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  17823. /**
  17824. * Creates a luminance alpha texture from some data.
  17825. * @param data Define the texture data
  17826. * @param width Define the width of the texture
  17827. * @param height Define the height of the texture
  17828. * @param scene Define the scene the texture belongs to
  17829. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17830. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17831. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17832. * @returns the luminance alpha texture
  17833. */
  17834. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  17835. /**
  17836. * Creates an alpha texture from some data.
  17837. * @param data Define the texture data
  17838. * @param width Define the width of the texture
  17839. * @param height Define the height of the texture
  17840. * @param scene Define the scene the texture belongs to
  17841. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17842. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17843. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17844. * @returns the alpha texture
  17845. */
  17846. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  17847. /**
  17848. * Creates a RGB texture from some data.
  17849. * @param data Define the texture data
  17850. * @param width Define the width of the texture
  17851. * @param height Define the height of the texture
  17852. * @param scene Define the scene the texture belongs to
  17853. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17854. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17855. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17856. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17857. * @returns the RGB alpha texture
  17858. */
  17859. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  17860. /**
  17861. * Creates a RGBA texture from some data.
  17862. * @param data Define the texture data
  17863. * @param width Define the width of the texture
  17864. * @param height Define the height of the texture
  17865. * @param scene Define the scene the texture belongs to
  17866. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17867. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17868. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17869. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17870. * @returns the RGBA texture
  17871. */
  17872. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  17873. /**
  17874. * Creates a R texture from some data.
  17875. * @param data Define the texture data
  17876. * @param width Define the width of the texture
  17877. * @param height Define the height of the texture
  17878. * @param scene Define the scene the texture belongs to
  17879. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17880. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17881. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17882. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17883. * @returns the R texture
  17884. */
  17885. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  17886. }
  17887. }
  17888. declare module BABYLON {
  17889. /**
  17890. * Defines a runtime animation
  17891. */
  17892. export class RuntimeAnimation {
  17893. private _events;
  17894. /**
  17895. * The current frame of the runtime animation
  17896. */
  17897. private _currentFrame;
  17898. /**
  17899. * The animation used by the runtime animation
  17900. */
  17901. private _animation;
  17902. /**
  17903. * The target of the runtime animation
  17904. */
  17905. private _target;
  17906. /**
  17907. * The initiating animatable
  17908. */
  17909. private _host;
  17910. /**
  17911. * The original value of the runtime animation
  17912. */
  17913. private _originalValue;
  17914. /**
  17915. * The original blend value of the runtime animation
  17916. */
  17917. private _originalBlendValue;
  17918. /**
  17919. * The offsets cache of the runtime animation
  17920. */
  17921. private _offsetsCache;
  17922. /**
  17923. * The high limits cache of the runtime animation
  17924. */
  17925. private _highLimitsCache;
  17926. /**
  17927. * Specifies if the runtime animation has been stopped
  17928. */
  17929. private _stopped;
  17930. /**
  17931. * The blending factor of the runtime animation
  17932. */
  17933. private _blendingFactor;
  17934. /**
  17935. * The BabylonJS scene
  17936. */
  17937. private _scene;
  17938. /**
  17939. * The current value of the runtime animation
  17940. */
  17941. private _currentValue;
  17942. /** @hidden */
  17943. _workValue: any;
  17944. /**
  17945. * The active target of the runtime animation
  17946. */
  17947. private _activeTarget;
  17948. /**
  17949. * The target path of the runtime animation
  17950. */
  17951. private _targetPath;
  17952. /**
  17953. * The weight of the runtime animation
  17954. */
  17955. private _weight;
  17956. /**
  17957. * The ratio offset of the runtime animation
  17958. */
  17959. private _ratioOffset;
  17960. /**
  17961. * The previous delay of the runtime animation
  17962. */
  17963. private _previousDelay;
  17964. /**
  17965. * The previous ratio of the runtime animation
  17966. */
  17967. private _previousRatio;
  17968. /**
  17969. * Gets the current frame of the runtime animation
  17970. */
  17971. readonly currentFrame: number;
  17972. /**
  17973. * Gets the weight of the runtime animation
  17974. */
  17975. readonly weight: number;
  17976. /**
  17977. * Gets the current value of the runtime animation
  17978. */
  17979. readonly currentValue: any;
  17980. /**
  17981. * Gets the target path of the runtime animation
  17982. */
  17983. readonly targetPath: string;
  17984. /**
  17985. * Gets the actual target of the runtime animation
  17986. */
  17987. readonly target: any;
  17988. /**
  17989. * Create a new RuntimeAnimation object
  17990. * @param target defines the target of the animation
  17991. * @param animation defines the source animation object
  17992. * @param scene defines the hosting scene
  17993. * @param host defines the initiating Animatable
  17994. */
  17995. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  17996. /**
  17997. * Gets the animation from the runtime animation
  17998. */
  17999. readonly animation: Animation;
  18000. /**
  18001. * Resets the runtime animation to the beginning
  18002. * @param restoreOriginal defines whether to restore the target property to the original value
  18003. */
  18004. reset(restoreOriginal?: boolean): void;
  18005. /**
  18006. * Specifies if the runtime animation is stopped
  18007. * @returns Boolean specifying if the runtime animation is stopped
  18008. */
  18009. isStopped(): boolean;
  18010. /**
  18011. * Disposes of the runtime animation
  18012. */
  18013. dispose(): void;
  18014. /**
  18015. * Interpolates the animation from the current frame
  18016. * @param currentFrame The frame to interpolate the animation to
  18017. * @param repeatCount The number of times that the animation should loop
  18018. * @param loopMode The type of looping mode to use
  18019. * @param offsetValue Animation offset value
  18020. * @param highLimitValue The high limit value
  18021. * @returns The interpolated value
  18022. */
  18023. private _interpolate;
  18024. /**
  18025. * Apply the interpolated value to the target
  18026. * @param currentValue defines the value computed by the animation
  18027. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18028. */
  18029. setValue(currentValue: any, weight?: number): void;
  18030. private _setValue;
  18031. /**
  18032. * Gets the loop pmode of the runtime animation
  18033. * @returns Loop Mode
  18034. */
  18035. private _getCorrectLoopMode;
  18036. /**
  18037. * Move the current animation to a given frame
  18038. * @param frame defines the frame to move to
  18039. */
  18040. goToFrame(frame: number): void;
  18041. /**
  18042. * @hidden Internal use only
  18043. */
  18044. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18045. /**
  18046. * Execute the current animation
  18047. * @param delay defines the delay to add to the current frame
  18048. * @param from defines the lower bound of the animation range
  18049. * @param to defines the upper bound of the animation range
  18050. * @param loop defines if the current animation must loop
  18051. * @param speedRatio defines the current speed ratio
  18052. * @param weight defines the weight of the animation (default is -1 so no weight)
  18053. * @param onLoop optional callback called when animation loops
  18054. * @returns a boolean indicating if the animation is running
  18055. */
  18056. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18057. }
  18058. }
  18059. declare module BABYLON {
  18060. /**
  18061. * Class used to store an actual running animation
  18062. */
  18063. export class Animatable {
  18064. /** defines the target object */
  18065. target: any;
  18066. /** defines the starting frame number (default is 0) */
  18067. fromFrame: number;
  18068. /** defines the ending frame number (default is 100) */
  18069. toFrame: number;
  18070. /** defines if the animation must loop (default is false) */
  18071. loopAnimation: boolean;
  18072. /** defines a callback to call when animation ends if it is not looping */
  18073. onAnimationEnd?: (() => void) | null | undefined;
  18074. /** defines a callback to call when animation loops */
  18075. onAnimationLoop?: (() => void) | null | undefined;
  18076. private _localDelayOffset;
  18077. private _pausedDelay;
  18078. private _runtimeAnimations;
  18079. private _paused;
  18080. private _scene;
  18081. private _speedRatio;
  18082. private _weight;
  18083. private _syncRoot;
  18084. /**
  18085. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18086. * This will only apply for non looping animation (default is true)
  18087. */
  18088. disposeOnEnd: boolean;
  18089. /**
  18090. * Gets a boolean indicating if the animation has started
  18091. */
  18092. animationStarted: boolean;
  18093. /**
  18094. * Observer raised when the animation ends
  18095. */
  18096. onAnimationEndObservable: Observable<Animatable>;
  18097. /**
  18098. * Observer raised when the animation loops
  18099. */
  18100. onAnimationLoopObservable: Observable<Animatable>;
  18101. /**
  18102. * Gets the root Animatable used to synchronize and normalize animations
  18103. */
  18104. readonly syncRoot: Animatable;
  18105. /**
  18106. * Gets the current frame of the first RuntimeAnimation
  18107. * Used to synchronize Animatables
  18108. */
  18109. readonly masterFrame: number;
  18110. /**
  18111. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18112. */
  18113. weight: number;
  18114. /**
  18115. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18116. */
  18117. speedRatio: number;
  18118. /**
  18119. * Creates a new Animatable
  18120. * @param scene defines the hosting scene
  18121. * @param target defines the target object
  18122. * @param fromFrame defines the starting frame number (default is 0)
  18123. * @param toFrame defines the ending frame number (default is 100)
  18124. * @param loopAnimation defines if the animation must loop (default is false)
  18125. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18126. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18127. * @param animations defines a group of animation to add to the new Animatable
  18128. * @param onAnimationLoop defines a callback to call when animation loops
  18129. */
  18130. constructor(scene: Scene,
  18131. /** defines the target object */
  18132. target: any,
  18133. /** defines the starting frame number (default is 0) */
  18134. fromFrame?: number,
  18135. /** defines the ending frame number (default is 100) */
  18136. toFrame?: number,
  18137. /** defines if the animation must loop (default is false) */
  18138. loopAnimation?: boolean, speedRatio?: number,
  18139. /** defines a callback to call when animation ends if it is not looping */
  18140. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18141. /** defines a callback to call when animation loops */
  18142. onAnimationLoop?: (() => void) | null | undefined);
  18143. /**
  18144. * Synchronize and normalize current Animatable with a source Animatable
  18145. * This is useful when using animation weights and when animations are not of the same length
  18146. * @param root defines the root Animatable to synchronize with
  18147. * @returns the current Animatable
  18148. */
  18149. syncWith(root: Animatable): Animatable;
  18150. /**
  18151. * Gets the list of runtime animations
  18152. * @returns an array of RuntimeAnimation
  18153. */
  18154. getAnimations(): RuntimeAnimation[];
  18155. /**
  18156. * Adds more animations to the current animatable
  18157. * @param target defines the target of the animations
  18158. * @param animations defines the new animations to add
  18159. */
  18160. appendAnimations(target: any, animations: Animation[]): void;
  18161. /**
  18162. * Gets the source animation for a specific property
  18163. * @param property defines the propertyu to look for
  18164. * @returns null or the source animation for the given property
  18165. */
  18166. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18167. /**
  18168. * Gets the runtime animation for a specific property
  18169. * @param property defines the propertyu to look for
  18170. * @returns null or the runtime animation for the given property
  18171. */
  18172. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18173. /**
  18174. * Resets the animatable to its original state
  18175. */
  18176. reset(): void;
  18177. /**
  18178. * Allows the animatable to blend with current running animations
  18179. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18180. * @param blendingSpeed defines the blending speed to use
  18181. */
  18182. enableBlending(blendingSpeed: number): void;
  18183. /**
  18184. * Disable animation blending
  18185. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18186. */
  18187. disableBlending(): void;
  18188. /**
  18189. * Jump directly to a given frame
  18190. * @param frame defines the frame to jump to
  18191. */
  18192. goToFrame(frame: number): void;
  18193. /**
  18194. * Pause the animation
  18195. */
  18196. pause(): void;
  18197. /**
  18198. * Restart the animation
  18199. */
  18200. restart(): void;
  18201. private _raiseOnAnimationEnd;
  18202. /**
  18203. * Stop and delete the current animation
  18204. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18205. * @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)
  18206. */
  18207. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18208. /**
  18209. * Wait asynchronously for the animation to end
  18210. * @returns a promise which will be fullfilled when the animation ends
  18211. */
  18212. waitAsync(): Promise<Animatable>;
  18213. /** @hidden */
  18214. _animate(delay: number): boolean;
  18215. }
  18216. interface Scene {
  18217. /** @hidden */
  18218. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18219. /** @hidden */
  18220. _processLateAnimationBindingsForMatrices(holder: {
  18221. totalWeight: number;
  18222. animations: RuntimeAnimation[];
  18223. originalValue: Matrix;
  18224. }): any;
  18225. /** @hidden */
  18226. _processLateAnimationBindingsForQuaternions(holder: {
  18227. totalWeight: number;
  18228. animations: RuntimeAnimation[];
  18229. originalValue: Quaternion;
  18230. }, refQuaternion: Quaternion): Quaternion;
  18231. /** @hidden */
  18232. _processLateAnimationBindings(): void;
  18233. /**
  18234. * Will start the animation sequence of a given target
  18235. * @param target defines the target
  18236. * @param from defines from which frame should animation start
  18237. * @param to defines until which frame should animation run.
  18238. * @param weight defines the weight to apply to the animation (1.0 by default)
  18239. * @param loop defines if the animation loops
  18240. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18241. * @param onAnimationEnd defines the function to be executed when the animation ends
  18242. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18243. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18244. * @param onAnimationLoop defines the callback to call when an animation loops
  18245. * @returns the animatable object created for this animation
  18246. */
  18247. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18248. /**
  18249. * Will start the animation sequence of a given target
  18250. * @param target defines the target
  18251. * @param from defines from which frame should animation start
  18252. * @param to defines until which frame should animation run.
  18253. * @param loop defines if the animation loops
  18254. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18255. * @param onAnimationEnd defines the function to be executed when the animation ends
  18256. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18257. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18258. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18259. * @param onAnimationLoop defines the callback to call when an animation loops
  18260. * @returns the animatable object created for this animation
  18261. */
  18262. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18263. /**
  18264. * Will start the animation sequence of a given target and its hierarchy
  18265. * @param target defines the target
  18266. * @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.
  18267. * @param from defines from which frame should animation start
  18268. * @param to defines until which frame should animation run.
  18269. * @param loop defines if the animation loops
  18270. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18271. * @param onAnimationEnd defines the function to be executed when the animation ends
  18272. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18273. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18274. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18275. * @param onAnimationLoop defines the callback to call when an animation loops
  18276. * @returns the list of created animatables
  18277. */
  18278. 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[];
  18279. /**
  18280. * Begin a new animation on a given node
  18281. * @param target defines the target where the animation will take place
  18282. * @param animations defines the list of animations to start
  18283. * @param from defines the initial value
  18284. * @param to defines the final value
  18285. * @param loop defines if you want animation to loop (off by default)
  18286. * @param speedRatio defines the speed ratio to apply to all animations
  18287. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18288. * @param onAnimationLoop defines the callback to call when an animation loops
  18289. * @returns the list of created animatables
  18290. */
  18291. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18292. /**
  18293. * Begin a new animation on a given node and its hierarchy
  18294. * @param target defines the root node where the animation will take place
  18295. * @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.
  18296. * @param animations defines the list of animations to start
  18297. * @param from defines the initial value
  18298. * @param to defines the final value
  18299. * @param loop defines if you want animation to loop (off by default)
  18300. * @param speedRatio defines the speed ratio to apply to all animations
  18301. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18302. * @param onAnimationLoop defines the callback to call when an animation loops
  18303. * @returns the list of animatables created for all nodes
  18304. */
  18305. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18306. /**
  18307. * Gets the animatable associated with a specific target
  18308. * @param target defines the target of the animatable
  18309. * @returns the required animatable if found
  18310. */
  18311. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18312. /**
  18313. * Gets all animatables associated with a given target
  18314. * @param target defines the target to look animatables for
  18315. * @returns an array of Animatables
  18316. */
  18317. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18318. /**
  18319. * Will stop the animation of the given target
  18320. * @param target - the target
  18321. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18322. * @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)
  18323. */
  18324. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18325. /**
  18326. * Stops and removes all animations that have been applied to the scene
  18327. */
  18328. stopAllAnimations(): void;
  18329. }
  18330. interface Bone {
  18331. /**
  18332. * Copy an animation range from another bone
  18333. * @param source defines the source bone
  18334. * @param rangeName defines the range name to copy
  18335. * @param frameOffset defines the frame offset
  18336. * @param rescaleAsRequired defines if rescaling must be applied if required
  18337. * @param skelDimensionsRatio defines the scaling ratio
  18338. * @returns true if operation was successful
  18339. */
  18340. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18341. }
  18342. }
  18343. declare module BABYLON {
  18344. /**
  18345. * Class used to handle skinning animations
  18346. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18347. */
  18348. export class Skeleton implements IAnimatable {
  18349. /** defines the skeleton name */
  18350. name: string;
  18351. /** defines the skeleton Id */
  18352. id: string;
  18353. /**
  18354. * Defines the list of child bones
  18355. */
  18356. bones: Bone[];
  18357. /**
  18358. * Defines an estimate of the dimension of the skeleton at rest
  18359. */
  18360. dimensionsAtRest: Vector3;
  18361. /**
  18362. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18363. */
  18364. needInitialSkinMatrix: boolean;
  18365. /**
  18366. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18367. */
  18368. overrideMesh: Nullable<AbstractMesh>;
  18369. /**
  18370. * Gets the list of animations attached to this skeleton
  18371. */
  18372. animations: Array<Animation>;
  18373. private _scene;
  18374. private _isDirty;
  18375. private _transformMatrices;
  18376. private _transformMatrixTexture;
  18377. private _meshesWithPoseMatrix;
  18378. private _animatables;
  18379. private _identity;
  18380. private _synchronizedWithMesh;
  18381. private _ranges;
  18382. private _lastAbsoluteTransformsUpdateId;
  18383. private _canUseTextureForBones;
  18384. /** @hidden */
  18385. _numBonesWithLinkedTransformNode: number;
  18386. /**
  18387. * Specifies if the skeleton should be serialized
  18388. */
  18389. doNotSerialize: boolean;
  18390. /**
  18391. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18392. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18393. */
  18394. useTextureToStoreBoneMatrices: boolean;
  18395. private _animationPropertiesOverride;
  18396. /**
  18397. * Gets or sets the animation properties override
  18398. */
  18399. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18400. /**
  18401. * An observable triggered before computing the skeleton's matrices
  18402. */
  18403. onBeforeComputeObservable: Observable<Skeleton>;
  18404. /**
  18405. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18406. */
  18407. readonly isUsingTextureForMatrices: boolean;
  18408. /**
  18409. * Creates a new skeleton
  18410. * @param name defines the skeleton name
  18411. * @param id defines the skeleton Id
  18412. * @param scene defines the hosting scene
  18413. */
  18414. constructor(
  18415. /** defines the skeleton name */
  18416. name: string,
  18417. /** defines the skeleton Id */
  18418. id: string, scene: Scene);
  18419. /**
  18420. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18421. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18422. * @returns a Float32Array containing matrices data
  18423. */
  18424. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18425. /**
  18426. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18427. * @returns a raw texture containing the data
  18428. */
  18429. getTransformMatrixTexture(): Nullable<RawTexture>;
  18430. /**
  18431. * Gets the current hosting scene
  18432. * @returns a scene object
  18433. */
  18434. getScene(): Scene;
  18435. /**
  18436. * Gets a string representing the current skeleton data
  18437. * @param fullDetails defines a boolean indicating if we want a verbose version
  18438. * @returns a string representing the current skeleton data
  18439. */
  18440. toString(fullDetails?: boolean): string;
  18441. /**
  18442. * Get bone's index searching by name
  18443. * @param name defines bone's name to search for
  18444. * @return the indice of the bone. Returns -1 if not found
  18445. */
  18446. getBoneIndexByName(name: string): number;
  18447. /**
  18448. * Creater a new animation range
  18449. * @param name defines the name of the range
  18450. * @param from defines the start key
  18451. * @param to defines the end key
  18452. */
  18453. createAnimationRange(name: string, from: number, to: number): void;
  18454. /**
  18455. * Delete a specific animation range
  18456. * @param name defines the name of the range
  18457. * @param deleteFrames defines if frames must be removed as well
  18458. */
  18459. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18460. /**
  18461. * Gets a specific animation range
  18462. * @param name defines the name of the range to look for
  18463. * @returns the requested animation range or null if not found
  18464. */
  18465. getAnimationRange(name: string): Nullable<AnimationRange>;
  18466. /**
  18467. * Gets the list of all animation ranges defined on this skeleton
  18468. * @returns an array
  18469. */
  18470. getAnimationRanges(): Nullable<AnimationRange>[];
  18471. /**
  18472. * Copy animation range from a source skeleton.
  18473. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18474. * @param source defines the source skeleton
  18475. * @param name defines the name of the range to copy
  18476. * @param rescaleAsRequired defines if rescaling must be applied if required
  18477. * @returns true if operation was successful
  18478. */
  18479. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18480. /**
  18481. * Forces the skeleton to go to rest pose
  18482. */
  18483. returnToRest(): void;
  18484. private _getHighestAnimationFrame;
  18485. /**
  18486. * Begin a specific animation range
  18487. * @param name defines the name of the range to start
  18488. * @param loop defines if looping must be turned on (false by default)
  18489. * @param speedRatio defines the speed ratio to apply (1 by default)
  18490. * @param onAnimationEnd defines a callback which will be called when animation will end
  18491. * @returns a new animatable
  18492. */
  18493. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18494. /** @hidden */
  18495. _markAsDirty(): void;
  18496. /** @hidden */
  18497. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18498. /** @hidden */
  18499. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18500. private _computeTransformMatrices;
  18501. /**
  18502. * Build all resources required to render a skeleton
  18503. */
  18504. prepare(): void;
  18505. /**
  18506. * Gets the list of animatables currently running for this skeleton
  18507. * @returns an array of animatables
  18508. */
  18509. getAnimatables(): IAnimatable[];
  18510. /**
  18511. * Clone the current skeleton
  18512. * @param name defines the name of the new skeleton
  18513. * @param id defines the id of the enw skeleton
  18514. * @returns the new skeleton
  18515. */
  18516. clone(name: string, id: string): Skeleton;
  18517. /**
  18518. * Enable animation blending for this skeleton
  18519. * @param blendingSpeed defines the blending speed to apply
  18520. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18521. */
  18522. enableBlending(blendingSpeed?: number): void;
  18523. /**
  18524. * Releases all resources associated with the current skeleton
  18525. */
  18526. dispose(): void;
  18527. /**
  18528. * Serialize the skeleton in a JSON object
  18529. * @returns a JSON object
  18530. */
  18531. serialize(): any;
  18532. /**
  18533. * Creates a new skeleton from serialized data
  18534. * @param parsedSkeleton defines the serialized data
  18535. * @param scene defines the hosting scene
  18536. * @returns a new skeleton
  18537. */
  18538. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  18539. /**
  18540. * Compute all node absolute transforms
  18541. * @param forceUpdate defines if computation must be done even if cache is up to date
  18542. */
  18543. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  18544. /**
  18545. * Gets the root pose matrix
  18546. * @returns a matrix
  18547. */
  18548. getPoseMatrix(): Nullable<Matrix>;
  18549. /**
  18550. * Sorts bones per internal index
  18551. */
  18552. sortBones(): void;
  18553. private _sortBones;
  18554. }
  18555. }
  18556. declare module BABYLON {
  18557. /**
  18558. * Defines a target to use with MorphTargetManager
  18559. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18560. */
  18561. export class MorphTarget implements IAnimatable {
  18562. /** defines the name of the target */
  18563. name: string;
  18564. /**
  18565. * Gets or sets the list of animations
  18566. */
  18567. animations: Animation[];
  18568. private _scene;
  18569. private _positions;
  18570. private _normals;
  18571. private _tangents;
  18572. private _influence;
  18573. /**
  18574. * Observable raised when the influence changes
  18575. */
  18576. onInfluenceChanged: Observable<boolean>;
  18577. /** @hidden */
  18578. _onDataLayoutChanged: Observable<void>;
  18579. /**
  18580. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18581. */
  18582. influence: number;
  18583. /**
  18584. * Gets or sets the id of the morph Target
  18585. */
  18586. id: string;
  18587. private _animationPropertiesOverride;
  18588. /**
  18589. * Gets or sets the animation properties override
  18590. */
  18591. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18592. /**
  18593. * Creates a new MorphTarget
  18594. * @param name defines the name of the target
  18595. * @param influence defines the influence to use
  18596. * @param scene defines the scene the morphtarget belongs to
  18597. */
  18598. constructor(
  18599. /** defines the name of the target */
  18600. name: string, influence?: number, scene?: Nullable<Scene>);
  18601. /**
  18602. * Gets a boolean defining if the target contains position data
  18603. */
  18604. readonly hasPositions: boolean;
  18605. /**
  18606. * Gets a boolean defining if the target contains normal data
  18607. */
  18608. readonly hasNormals: boolean;
  18609. /**
  18610. * Gets a boolean defining if the target contains tangent data
  18611. */
  18612. readonly hasTangents: boolean;
  18613. /**
  18614. * Affects position data to this target
  18615. * @param data defines the position data to use
  18616. */
  18617. setPositions(data: Nullable<FloatArray>): void;
  18618. /**
  18619. * Gets the position data stored in this target
  18620. * @returns a FloatArray containing the position data (or null if not present)
  18621. */
  18622. getPositions(): Nullable<FloatArray>;
  18623. /**
  18624. * Affects normal data to this target
  18625. * @param data defines the normal data to use
  18626. */
  18627. setNormals(data: Nullable<FloatArray>): void;
  18628. /**
  18629. * Gets the normal data stored in this target
  18630. * @returns a FloatArray containing the normal data (or null if not present)
  18631. */
  18632. getNormals(): Nullable<FloatArray>;
  18633. /**
  18634. * Affects tangent data to this target
  18635. * @param data defines the tangent data to use
  18636. */
  18637. setTangents(data: Nullable<FloatArray>): void;
  18638. /**
  18639. * Gets the tangent data stored in this target
  18640. * @returns a FloatArray containing the tangent data (or null if not present)
  18641. */
  18642. getTangents(): Nullable<FloatArray>;
  18643. /**
  18644. * Serializes the current target into a Serialization object
  18645. * @returns the serialized object
  18646. */
  18647. serialize(): any;
  18648. /**
  18649. * Returns the string "MorphTarget"
  18650. * @returns "MorphTarget"
  18651. */
  18652. getClassName(): string;
  18653. /**
  18654. * Creates a new target from serialized data
  18655. * @param serializationObject defines the serialized data to use
  18656. * @returns a new MorphTarget
  18657. */
  18658. static Parse(serializationObject: any): MorphTarget;
  18659. /**
  18660. * Creates a MorphTarget from mesh data
  18661. * @param mesh defines the source mesh
  18662. * @param name defines the name to use for the new target
  18663. * @param influence defines the influence to attach to the target
  18664. * @returns a new MorphTarget
  18665. */
  18666. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18667. }
  18668. }
  18669. declare module BABYLON {
  18670. /**
  18671. * This class is used to deform meshes using morphing between different targets
  18672. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18673. */
  18674. export class MorphTargetManager {
  18675. private _targets;
  18676. private _targetInfluenceChangedObservers;
  18677. private _targetDataLayoutChangedObservers;
  18678. private _activeTargets;
  18679. private _scene;
  18680. private _influences;
  18681. private _supportsNormals;
  18682. private _supportsTangents;
  18683. private _vertexCount;
  18684. private _uniqueId;
  18685. private _tempInfluences;
  18686. /**
  18687. * Creates a new MorphTargetManager
  18688. * @param scene defines the current scene
  18689. */
  18690. constructor(scene?: Nullable<Scene>);
  18691. /**
  18692. * Gets the unique ID of this manager
  18693. */
  18694. readonly uniqueId: number;
  18695. /**
  18696. * Gets the number of vertices handled by this manager
  18697. */
  18698. readonly vertexCount: number;
  18699. /**
  18700. * Gets a boolean indicating if this manager supports morphing of normals
  18701. */
  18702. readonly supportsNormals: boolean;
  18703. /**
  18704. * Gets a boolean indicating if this manager supports morphing of tangents
  18705. */
  18706. readonly supportsTangents: boolean;
  18707. /**
  18708. * Gets the number of targets stored in this manager
  18709. */
  18710. readonly numTargets: number;
  18711. /**
  18712. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18713. */
  18714. readonly numInfluencers: number;
  18715. /**
  18716. * Gets the list of influences (one per target)
  18717. */
  18718. readonly influences: Float32Array;
  18719. /**
  18720. * Gets the active target at specified index. An active target is a target with an influence > 0
  18721. * @param index defines the index to check
  18722. * @returns the requested target
  18723. */
  18724. getActiveTarget(index: number): MorphTarget;
  18725. /**
  18726. * Gets the target at specified index
  18727. * @param index defines the index to check
  18728. * @returns the requested target
  18729. */
  18730. getTarget(index: number): MorphTarget;
  18731. /**
  18732. * Add a new target to this manager
  18733. * @param target defines the target to add
  18734. */
  18735. addTarget(target: MorphTarget): void;
  18736. /**
  18737. * Removes a target from the manager
  18738. * @param target defines the target to remove
  18739. */
  18740. removeTarget(target: MorphTarget): void;
  18741. /**
  18742. * Serializes the current manager into a Serialization object
  18743. * @returns the serialized object
  18744. */
  18745. serialize(): any;
  18746. private _syncActiveTargets;
  18747. /**
  18748. * Syncrhonize the targets with all the meshes using this morph target manager
  18749. */
  18750. synchronize(): void;
  18751. /**
  18752. * Creates a new MorphTargetManager from serialized data
  18753. * @param serializationObject defines the serialized data
  18754. * @param scene defines the hosting scene
  18755. * @returns the new MorphTargetManager
  18756. */
  18757. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18758. }
  18759. }
  18760. declare module BABYLON {
  18761. /**
  18762. * Mesh representing the gorund
  18763. */
  18764. export class GroundMesh extends Mesh {
  18765. /** If octree should be generated */
  18766. generateOctree: boolean;
  18767. private _heightQuads;
  18768. /** @hidden */
  18769. _subdivisionsX: number;
  18770. /** @hidden */
  18771. _subdivisionsY: number;
  18772. /** @hidden */
  18773. _width: number;
  18774. /** @hidden */
  18775. _height: number;
  18776. /** @hidden */
  18777. _minX: number;
  18778. /** @hidden */
  18779. _maxX: number;
  18780. /** @hidden */
  18781. _minZ: number;
  18782. /** @hidden */
  18783. _maxZ: number;
  18784. constructor(name: string, scene: Scene);
  18785. /**
  18786. * "GroundMesh"
  18787. * @returns "GroundMesh"
  18788. */
  18789. getClassName(): string;
  18790. /**
  18791. * The minimum of x and y subdivisions
  18792. */
  18793. readonly subdivisions: number;
  18794. /**
  18795. * X subdivisions
  18796. */
  18797. readonly subdivisionsX: number;
  18798. /**
  18799. * Y subdivisions
  18800. */
  18801. readonly subdivisionsY: number;
  18802. /**
  18803. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  18804. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18805. * @param chunksCount the number of subdivisions for x and y
  18806. * @param octreeBlocksSize (Default: 32)
  18807. */
  18808. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  18809. /**
  18810. * Returns a height (y) value in the Worl system :
  18811. * the ground altitude at the coordinates (x, z) expressed in the World system.
  18812. * @param x x coordinate
  18813. * @param z z coordinate
  18814. * @returns the ground y position if (x, z) are outside the ground surface.
  18815. */
  18816. getHeightAtCoordinates(x: number, z: number): number;
  18817. /**
  18818. * Returns a normalized vector (Vector3) orthogonal to the ground
  18819. * at the ground coordinates (x, z) expressed in the World system.
  18820. * @param x x coordinate
  18821. * @param z z coordinate
  18822. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  18823. */
  18824. getNormalAtCoordinates(x: number, z: number): Vector3;
  18825. /**
  18826. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  18827. * at the ground coordinates (x, z) expressed in the World system.
  18828. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  18829. * @param x x coordinate
  18830. * @param z z coordinate
  18831. * @param ref vector to store the result
  18832. * @returns the GroundMesh.
  18833. */
  18834. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  18835. /**
  18836. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  18837. * if the ground has been updated.
  18838. * This can be used in the render loop.
  18839. * @returns the GroundMesh.
  18840. */
  18841. updateCoordinateHeights(): GroundMesh;
  18842. private _getFacetAt;
  18843. private _initHeightQuads;
  18844. private _computeHeightQuads;
  18845. /**
  18846. * Serializes this ground mesh
  18847. * @param serializationObject object to write serialization to
  18848. */
  18849. serialize(serializationObject: any): void;
  18850. /**
  18851. * Parses a serialized ground mesh
  18852. * @param parsedMesh the serialized mesh
  18853. * @param scene the scene to create the ground mesh in
  18854. * @returns the created ground mesh
  18855. */
  18856. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  18857. }
  18858. }
  18859. declare module BABYLON {
  18860. /**
  18861. * Interface for Physics-Joint data
  18862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18863. */
  18864. export interface PhysicsJointData {
  18865. /**
  18866. * The main pivot of the joint
  18867. */
  18868. mainPivot?: Vector3;
  18869. /**
  18870. * The connected pivot of the joint
  18871. */
  18872. connectedPivot?: Vector3;
  18873. /**
  18874. * The main axis of the joint
  18875. */
  18876. mainAxis?: Vector3;
  18877. /**
  18878. * The connected axis of the joint
  18879. */
  18880. connectedAxis?: Vector3;
  18881. /**
  18882. * The collision of the joint
  18883. */
  18884. collision?: boolean;
  18885. /**
  18886. * Native Oimo/Cannon/Energy data
  18887. */
  18888. nativeParams?: any;
  18889. }
  18890. /**
  18891. * This is a holder class for the physics joint created by the physics plugin
  18892. * It holds a set of functions to control the underlying joint
  18893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18894. */
  18895. export class PhysicsJoint {
  18896. /**
  18897. * The type of the physics joint
  18898. */
  18899. type: number;
  18900. /**
  18901. * The data for the physics joint
  18902. */
  18903. jointData: PhysicsJointData;
  18904. private _physicsJoint;
  18905. protected _physicsPlugin: IPhysicsEnginePlugin;
  18906. /**
  18907. * Initializes the physics joint
  18908. * @param type The type of the physics joint
  18909. * @param jointData The data for the physics joint
  18910. */
  18911. constructor(
  18912. /**
  18913. * The type of the physics joint
  18914. */
  18915. type: number,
  18916. /**
  18917. * The data for the physics joint
  18918. */
  18919. jointData: PhysicsJointData);
  18920. /**
  18921. * Gets the physics joint
  18922. */
  18923. /**
  18924. * Sets the physics joint
  18925. */
  18926. physicsJoint: any;
  18927. /**
  18928. * Sets the physics plugin
  18929. */
  18930. physicsPlugin: IPhysicsEnginePlugin;
  18931. /**
  18932. * Execute a function that is physics-plugin specific.
  18933. * @param {Function} func the function that will be executed.
  18934. * It accepts two parameters: the physics world and the physics joint
  18935. */
  18936. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  18937. /**
  18938. * Distance-Joint type
  18939. */
  18940. static DistanceJoint: number;
  18941. /**
  18942. * Hinge-Joint type
  18943. */
  18944. static HingeJoint: number;
  18945. /**
  18946. * Ball-and-Socket joint type
  18947. */
  18948. static BallAndSocketJoint: number;
  18949. /**
  18950. * Wheel-Joint type
  18951. */
  18952. static WheelJoint: number;
  18953. /**
  18954. * Slider-Joint type
  18955. */
  18956. static SliderJoint: number;
  18957. /**
  18958. * Prismatic-Joint type
  18959. */
  18960. static PrismaticJoint: number;
  18961. /**
  18962. * Universal-Joint type
  18963. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  18964. */
  18965. static UniversalJoint: number;
  18966. /**
  18967. * Hinge-Joint 2 type
  18968. */
  18969. static Hinge2Joint: number;
  18970. /**
  18971. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  18972. */
  18973. static PointToPointJoint: number;
  18974. /**
  18975. * Spring-Joint type
  18976. */
  18977. static SpringJoint: number;
  18978. /**
  18979. * Lock-Joint type
  18980. */
  18981. static LockJoint: number;
  18982. }
  18983. /**
  18984. * A class representing a physics distance joint
  18985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18986. */
  18987. export class DistanceJoint extends PhysicsJoint {
  18988. /**
  18989. *
  18990. * @param jointData The data for the Distance-Joint
  18991. */
  18992. constructor(jointData: DistanceJointData);
  18993. /**
  18994. * Update the predefined distance.
  18995. * @param maxDistance The maximum preferred distance
  18996. * @param minDistance The minimum preferred distance
  18997. */
  18998. updateDistance(maxDistance: number, minDistance?: number): void;
  18999. }
  19000. /**
  19001. * Represents a Motor-Enabled Joint
  19002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19003. */
  19004. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19005. /**
  19006. * Initializes the Motor-Enabled Joint
  19007. * @param type The type of the joint
  19008. * @param jointData The physica joint data for the joint
  19009. */
  19010. constructor(type: number, jointData: PhysicsJointData);
  19011. /**
  19012. * Set the motor values.
  19013. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19014. * @param force the force to apply
  19015. * @param maxForce max force for this motor.
  19016. */
  19017. setMotor(force?: number, maxForce?: number): void;
  19018. /**
  19019. * Set the motor's limits.
  19020. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19021. * @param upperLimit The upper limit of the motor
  19022. * @param lowerLimit The lower limit of the motor
  19023. */
  19024. setLimit(upperLimit: number, lowerLimit?: number): void;
  19025. }
  19026. /**
  19027. * This class represents a single physics Hinge-Joint
  19028. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19029. */
  19030. export class HingeJoint extends MotorEnabledJoint {
  19031. /**
  19032. * Initializes the Hinge-Joint
  19033. * @param jointData The joint data for the Hinge-Joint
  19034. */
  19035. constructor(jointData: PhysicsJointData);
  19036. /**
  19037. * Set the motor values.
  19038. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19039. * @param {number} force the force to apply
  19040. * @param {number} maxForce max force for this motor.
  19041. */
  19042. setMotor(force?: number, maxForce?: number): void;
  19043. /**
  19044. * Set the motor's limits.
  19045. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19046. * @param upperLimit The upper limit of the motor
  19047. * @param lowerLimit The lower limit of the motor
  19048. */
  19049. setLimit(upperLimit: number, lowerLimit?: number): void;
  19050. }
  19051. /**
  19052. * This class represents a dual hinge physics joint (same as wheel joint)
  19053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19054. */
  19055. export class Hinge2Joint extends MotorEnabledJoint {
  19056. /**
  19057. * Initializes the Hinge2-Joint
  19058. * @param jointData The joint data for the Hinge2-Joint
  19059. */
  19060. constructor(jointData: PhysicsJointData);
  19061. /**
  19062. * Set the motor values.
  19063. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19064. * @param {number} targetSpeed the speed the motor is to reach
  19065. * @param {number} maxForce max force for this motor.
  19066. * @param {motorIndex} the motor's index, 0 or 1.
  19067. */
  19068. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19069. /**
  19070. * Set the motor limits.
  19071. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19072. * @param {number} upperLimit the upper limit
  19073. * @param {number} lowerLimit lower limit
  19074. * @param {motorIndex} the motor's index, 0 or 1.
  19075. */
  19076. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19077. }
  19078. /**
  19079. * Interface for a motor enabled joint
  19080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19081. */
  19082. export interface IMotorEnabledJoint {
  19083. /**
  19084. * Physics joint
  19085. */
  19086. physicsJoint: any;
  19087. /**
  19088. * Sets the motor of the motor-enabled joint
  19089. * @param force The force of the motor
  19090. * @param maxForce The maximum force of the motor
  19091. * @param motorIndex The index of the motor
  19092. */
  19093. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19094. /**
  19095. * Sets the limit of the motor
  19096. * @param upperLimit The upper limit of the motor
  19097. * @param lowerLimit The lower limit of the motor
  19098. * @param motorIndex The index of the motor
  19099. */
  19100. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19101. }
  19102. /**
  19103. * Joint data for a Distance-Joint
  19104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19105. */
  19106. export interface DistanceJointData extends PhysicsJointData {
  19107. /**
  19108. * Max distance the 2 joint objects can be apart
  19109. */
  19110. maxDistance: number;
  19111. }
  19112. /**
  19113. * Joint data from a spring joint
  19114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19115. */
  19116. export interface SpringJointData extends PhysicsJointData {
  19117. /**
  19118. * Length of the spring
  19119. */
  19120. length: number;
  19121. /**
  19122. * Stiffness of the spring
  19123. */
  19124. stiffness: number;
  19125. /**
  19126. * Damping of the spring
  19127. */
  19128. damping: number;
  19129. /** this callback will be called when applying the force to the impostors. */
  19130. forceApplicationCallback: () => void;
  19131. }
  19132. }
  19133. declare module BABYLON {
  19134. /**
  19135. * Interface used to describe a physics joint
  19136. */
  19137. export interface PhysicsImpostorJoint {
  19138. /** Defines the main impostor to which the joint is linked */
  19139. mainImpostor: PhysicsImpostor;
  19140. /** Defines the impostor that is connected to the main impostor using this joint */
  19141. connectedImpostor: PhysicsImpostor;
  19142. /** Defines the joint itself */
  19143. joint: PhysicsJoint;
  19144. }
  19145. /** @hidden */
  19146. export interface IPhysicsEnginePlugin {
  19147. world: any;
  19148. name: string;
  19149. setGravity(gravity: Vector3): void;
  19150. setTimeStep(timeStep: number): void;
  19151. getTimeStep(): number;
  19152. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19153. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19154. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19155. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19156. removePhysicsBody(impostor: PhysicsImpostor): void;
  19157. generateJoint(joint: PhysicsImpostorJoint): void;
  19158. removeJoint(joint: PhysicsImpostorJoint): void;
  19159. isSupported(): boolean;
  19160. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19161. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19162. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19163. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19164. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19165. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19166. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19167. getBodyMass(impostor: PhysicsImpostor): number;
  19168. getBodyFriction(impostor: PhysicsImpostor): number;
  19169. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19170. getBodyRestitution(impostor: PhysicsImpostor): number;
  19171. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19172. sleepBody(impostor: PhysicsImpostor): void;
  19173. wakeUpBody(impostor: PhysicsImpostor): void;
  19174. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19175. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19176. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19177. getRadius(impostor: PhysicsImpostor): number;
  19178. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19179. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19180. dispose(): void;
  19181. }
  19182. /**
  19183. * Interface used to define a physics engine
  19184. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19185. */
  19186. export interface IPhysicsEngine {
  19187. /**
  19188. * Gets the gravity vector used by the simulation
  19189. */
  19190. gravity: Vector3;
  19191. /**
  19192. * Sets the gravity vector used by the simulation
  19193. * @param gravity defines the gravity vector to use
  19194. */
  19195. setGravity(gravity: Vector3): void;
  19196. /**
  19197. * Set the time step of the physics engine.
  19198. * Default is 1/60.
  19199. * To slow it down, enter 1/600 for example.
  19200. * To speed it up, 1/30
  19201. * @param newTimeStep the new timestep to apply to this world.
  19202. */
  19203. setTimeStep(newTimeStep: number): void;
  19204. /**
  19205. * Get the time step of the physics engine.
  19206. * @returns the current time step
  19207. */
  19208. getTimeStep(): number;
  19209. /**
  19210. * Release all resources
  19211. */
  19212. dispose(): void;
  19213. /**
  19214. * Gets the name of the current physics plugin
  19215. * @returns the name of the plugin
  19216. */
  19217. getPhysicsPluginName(): string;
  19218. /**
  19219. * Adding a new impostor for the impostor tracking.
  19220. * This will be done by the impostor itself.
  19221. * @param impostor the impostor to add
  19222. */
  19223. addImpostor(impostor: PhysicsImpostor): void;
  19224. /**
  19225. * Remove an impostor from the engine.
  19226. * This impostor and its mesh will not longer be updated by the physics engine.
  19227. * @param impostor the impostor to remove
  19228. */
  19229. removeImpostor(impostor: PhysicsImpostor): void;
  19230. /**
  19231. * Add a joint to the physics engine
  19232. * @param mainImpostor defines the main impostor to which the joint is added.
  19233. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19234. * @param joint defines the joint that will connect both impostors.
  19235. */
  19236. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19237. /**
  19238. * Removes a joint from the simulation
  19239. * @param mainImpostor defines the impostor used with the joint
  19240. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19241. * @param joint defines the joint to remove
  19242. */
  19243. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19244. /**
  19245. * Gets the current plugin used to run the simulation
  19246. * @returns current plugin
  19247. */
  19248. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19249. /**
  19250. * Gets the list of physic impostors
  19251. * @returns an array of PhysicsImpostor
  19252. */
  19253. getImpostors(): Array<PhysicsImpostor>;
  19254. /**
  19255. * Gets the impostor for a physics enabled object
  19256. * @param object defines the object impersonated by the impostor
  19257. * @returns the PhysicsImpostor or null if not found
  19258. */
  19259. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19260. /**
  19261. * Gets the impostor for a physics body object
  19262. * @param body defines physics body used by the impostor
  19263. * @returns the PhysicsImpostor or null if not found
  19264. */
  19265. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19266. /**
  19267. * Called by the scene. No need to call it.
  19268. * @param delta defines the timespam between frames
  19269. */
  19270. _step(delta: number): void;
  19271. }
  19272. }
  19273. declare module BABYLON {
  19274. /**
  19275. * The interface for the physics imposter parameters
  19276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19277. */
  19278. export interface PhysicsImpostorParameters {
  19279. /**
  19280. * The mass of the physics imposter
  19281. */
  19282. mass: number;
  19283. /**
  19284. * The friction of the physics imposter
  19285. */
  19286. friction?: number;
  19287. /**
  19288. * The coefficient of restitution of the physics imposter
  19289. */
  19290. restitution?: number;
  19291. /**
  19292. * The native options of the physics imposter
  19293. */
  19294. nativeOptions?: any;
  19295. /**
  19296. * Specifies if the parent should be ignored
  19297. */
  19298. ignoreParent?: boolean;
  19299. /**
  19300. * Specifies if bi-directional transformations should be disabled
  19301. */
  19302. disableBidirectionalTransformation?: boolean;
  19303. }
  19304. /**
  19305. * Interface for a physics-enabled object
  19306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19307. */
  19308. export interface IPhysicsEnabledObject {
  19309. /**
  19310. * The position of the physics-enabled object
  19311. */
  19312. position: Vector3;
  19313. /**
  19314. * The rotation of the physics-enabled object
  19315. */
  19316. rotationQuaternion: Nullable<Quaternion>;
  19317. /**
  19318. * The scale of the physics-enabled object
  19319. */
  19320. scaling: Vector3;
  19321. /**
  19322. * The rotation of the physics-enabled object
  19323. */
  19324. rotation?: Vector3;
  19325. /**
  19326. * The parent of the physics-enabled object
  19327. */
  19328. parent?: any;
  19329. /**
  19330. * The bounding info of the physics-enabled object
  19331. * @returns The bounding info of the physics-enabled object
  19332. */
  19333. getBoundingInfo(): BoundingInfo;
  19334. /**
  19335. * Computes the world matrix
  19336. * @param force Specifies if the world matrix should be computed by force
  19337. * @returns A world matrix
  19338. */
  19339. computeWorldMatrix(force: boolean): Matrix;
  19340. /**
  19341. * Gets the world matrix
  19342. * @returns A world matrix
  19343. */
  19344. getWorldMatrix?(): Matrix;
  19345. /**
  19346. * Gets the child meshes
  19347. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19348. * @returns An array of abstract meshes
  19349. */
  19350. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19351. /**
  19352. * Gets the vertex data
  19353. * @param kind The type of vertex data
  19354. * @returns A nullable array of numbers, or a float32 array
  19355. */
  19356. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19357. /**
  19358. * Gets the indices from the mesh
  19359. * @returns A nullable array of index arrays
  19360. */
  19361. getIndices?(): Nullable<IndicesArray>;
  19362. /**
  19363. * Gets the scene from the mesh
  19364. * @returns the indices array or null
  19365. */
  19366. getScene?(): Scene;
  19367. /**
  19368. * Gets the absolute position from the mesh
  19369. * @returns the absolute position
  19370. */
  19371. getAbsolutePosition(): Vector3;
  19372. /**
  19373. * Gets the absolute pivot point from the mesh
  19374. * @returns the absolute pivot point
  19375. */
  19376. getAbsolutePivotPoint(): Vector3;
  19377. /**
  19378. * Rotates the mesh
  19379. * @param axis The axis of rotation
  19380. * @param amount The amount of rotation
  19381. * @param space The space of the rotation
  19382. * @returns The rotation transform node
  19383. */
  19384. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19385. /**
  19386. * Translates the mesh
  19387. * @param axis The axis of translation
  19388. * @param distance The distance of translation
  19389. * @param space The space of the translation
  19390. * @returns The transform node
  19391. */
  19392. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19393. /**
  19394. * Sets the absolute position of the mesh
  19395. * @param absolutePosition The absolute position of the mesh
  19396. * @returns The transform node
  19397. */
  19398. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19399. /**
  19400. * Gets the class name of the mesh
  19401. * @returns The class name
  19402. */
  19403. getClassName(): string;
  19404. }
  19405. /**
  19406. * Represents a physics imposter
  19407. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19408. */
  19409. export class PhysicsImpostor {
  19410. /**
  19411. * The physics-enabled object used as the physics imposter
  19412. */
  19413. object: IPhysicsEnabledObject;
  19414. /**
  19415. * The type of the physics imposter
  19416. */
  19417. type: number;
  19418. private _options;
  19419. private _scene?;
  19420. /**
  19421. * The default object size of the imposter
  19422. */
  19423. static DEFAULT_OBJECT_SIZE: Vector3;
  19424. /**
  19425. * The identity quaternion of the imposter
  19426. */
  19427. static IDENTITY_QUATERNION: Quaternion;
  19428. /** @hidden */
  19429. _pluginData: any;
  19430. private _physicsEngine;
  19431. private _physicsBody;
  19432. private _bodyUpdateRequired;
  19433. private _onBeforePhysicsStepCallbacks;
  19434. private _onAfterPhysicsStepCallbacks;
  19435. /** @hidden */
  19436. _onPhysicsCollideCallbacks: Array<{
  19437. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19438. otherImpostors: Array<PhysicsImpostor>;
  19439. }>;
  19440. private _deltaPosition;
  19441. private _deltaRotation;
  19442. private _deltaRotationConjugated;
  19443. private _parent;
  19444. private _isDisposed;
  19445. private static _tmpVecs;
  19446. private static _tmpQuat;
  19447. /**
  19448. * Specifies if the physics imposter is disposed
  19449. */
  19450. readonly isDisposed: boolean;
  19451. /**
  19452. * Gets the mass of the physics imposter
  19453. */
  19454. mass: number;
  19455. /**
  19456. * Gets the coefficient of friction
  19457. */
  19458. /**
  19459. * Sets the coefficient of friction
  19460. */
  19461. friction: number;
  19462. /**
  19463. * Gets the coefficient of restitution
  19464. */
  19465. /**
  19466. * Sets the coefficient of restitution
  19467. */
  19468. restitution: number;
  19469. /**
  19470. * The unique id of the physics imposter
  19471. * set by the physics engine when adding this impostor to the array
  19472. */
  19473. uniqueId: number;
  19474. private _joints;
  19475. /**
  19476. * Initializes the physics imposter
  19477. * @param object The physics-enabled object used as the physics imposter
  19478. * @param type The type of the physics imposter
  19479. * @param _options The options for the physics imposter
  19480. * @param _scene The Babylon scene
  19481. */
  19482. constructor(
  19483. /**
  19484. * The physics-enabled object used as the physics imposter
  19485. */
  19486. object: IPhysicsEnabledObject,
  19487. /**
  19488. * The type of the physics imposter
  19489. */
  19490. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19491. /**
  19492. * This function will completly initialize this impostor.
  19493. * It will create a new body - but only if this mesh has no parent.
  19494. * If it has, this impostor will not be used other than to define the impostor
  19495. * of the child mesh.
  19496. * @hidden
  19497. */
  19498. _init(): void;
  19499. private _getPhysicsParent;
  19500. /**
  19501. * Should a new body be generated.
  19502. * @returns boolean specifying if body initialization is required
  19503. */
  19504. isBodyInitRequired(): boolean;
  19505. /**
  19506. * Sets the updated scaling
  19507. * @param updated Specifies if the scaling is updated
  19508. */
  19509. setScalingUpdated(): void;
  19510. /**
  19511. * Force a regeneration of this or the parent's impostor's body.
  19512. * Use under cautious - This will remove all joints already implemented.
  19513. */
  19514. forceUpdate(): void;
  19515. /**
  19516. * Gets the body that holds this impostor. Either its own, or its parent.
  19517. */
  19518. /**
  19519. * Set the physics body. Used mainly by the physics engine/plugin
  19520. */
  19521. physicsBody: any;
  19522. /**
  19523. * Get the parent of the physics imposter
  19524. * @returns Physics imposter or null
  19525. */
  19526. /**
  19527. * Sets the parent of the physics imposter
  19528. */
  19529. parent: Nullable<PhysicsImpostor>;
  19530. /**
  19531. * Resets the update flags
  19532. */
  19533. resetUpdateFlags(): void;
  19534. /**
  19535. * Gets the object extend size
  19536. * @returns the object extend size
  19537. */
  19538. getObjectExtendSize(): Vector3;
  19539. /**
  19540. * Gets the object center
  19541. * @returns The object center
  19542. */
  19543. getObjectCenter(): Vector3;
  19544. /**
  19545. * Get a specific parametes from the options parameter
  19546. * @param paramName The object parameter name
  19547. * @returns The object parameter
  19548. */
  19549. getParam(paramName: string): any;
  19550. /**
  19551. * Sets a specific parameter in the options given to the physics plugin
  19552. * @param paramName The parameter name
  19553. * @param value The value of the parameter
  19554. */
  19555. setParam(paramName: string, value: number): void;
  19556. /**
  19557. * Specifically change the body's mass option. Won't recreate the physics body object
  19558. * @param mass The mass of the physics imposter
  19559. */
  19560. setMass(mass: number): void;
  19561. /**
  19562. * Gets the linear velocity
  19563. * @returns linear velocity or null
  19564. */
  19565. getLinearVelocity(): Nullable<Vector3>;
  19566. /**
  19567. * Sets the linear velocity
  19568. * @param velocity linear velocity or null
  19569. */
  19570. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19571. /**
  19572. * Gets the angular velocity
  19573. * @returns angular velocity or null
  19574. */
  19575. getAngularVelocity(): Nullable<Vector3>;
  19576. /**
  19577. * Sets the angular velocity
  19578. * @param velocity The velocity or null
  19579. */
  19580. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19581. /**
  19582. * Execute a function with the physics plugin native code
  19583. * Provide a function the will have two variables - the world object and the physics body object
  19584. * @param func The function to execute with the physics plugin native code
  19585. */
  19586. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19587. /**
  19588. * Register a function that will be executed before the physics world is stepping forward
  19589. * @param func The function to execute before the physics world is stepped forward
  19590. */
  19591. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19592. /**
  19593. * Unregister a function that will be executed before the physics world is stepping forward
  19594. * @param func The function to execute before the physics world is stepped forward
  19595. */
  19596. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19597. /**
  19598. * Register a function that will be executed after the physics step
  19599. * @param func The function to execute after physics step
  19600. */
  19601. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19602. /**
  19603. * Unregisters a function that will be executed after the physics step
  19604. * @param func The function to execute after physics step
  19605. */
  19606. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19607. /**
  19608. * register a function that will be executed when this impostor collides against a different body
  19609. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  19610. * @param func Callback that is executed on collision
  19611. */
  19612. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19613. /**
  19614. * Unregisters the physics imposter on contact
  19615. * @param collideAgainst The physics object to collide against
  19616. * @param func Callback to execute on collision
  19617. */
  19618. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19619. private _tmpQuat;
  19620. private _tmpQuat2;
  19621. /**
  19622. * Get the parent rotation
  19623. * @returns The parent rotation
  19624. */
  19625. getParentsRotation(): Quaternion;
  19626. /**
  19627. * this function is executed by the physics engine.
  19628. */
  19629. beforeStep: () => void;
  19630. /**
  19631. * this function is executed by the physics engine
  19632. */
  19633. afterStep: () => void;
  19634. /**
  19635. * Legacy collision detection event support
  19636. */
  19637. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19638. /**
  19639. * event and body object due to cannon's event-based architecture.
  19640. */
  19641. onCollide: (e: {
  19642. body: any;
  19643. }) => void;
  19644. /**
  19645. * Apply a force
  19646. * @param force The force to apply
  19647. * @param contactPoint The contact point for the force
  19648. * @returns The physics imposter
  19649. */
  19650. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19651. /**
  19652. * Apply an impulse
  19653. * @param force The impulse force
  19654. * @param contactPoint The contact point for the impulse force
  19655. * @returns The physics imposter
  19656. */
  19657. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19658. /**
  19659. * A help function to create a joint
  19660. * @param otherImpostor A physics imposter used to create a joint
  19661. * @param jointType The type of joint
  19662. * @param jointData The data for the joint
  19663. * @returns The physics imposter
  19664. */
  19665. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19666. /**
  19667. * Add a joint to this impostor with a different impostor
  19668. * @param otherImpostor A physics imposter used to add a joint
  19669. * @param joint The joint to add
  19670. * @returns The physics imposter
  19671. */
  19672. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19673. /**
  19674. * Will keep this body still, in a sleep mode.
  19675. * @returns the physics imposter
  19676. */
  19677. sleep(): PhysicsImpostor;
  19678. /**
  19679. * Wake the body up.
  19680. * @returns The physics imposter
  19681. */
  19682. wakeUp(): PhysicsImpostor;
  19683. /**
  19684. * Clones the physics imposter
  19685. * @param newObject The physics imposter clones to this physics-enabled object
  19686. * @returns A nullable physics imposter
  19687. */
  19688. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19689. /**
  19690. * Disposes the physics imposter
  19691. */
  19692. dispose(): void;
  19693. /**
  19694. * Sets the delta position
  19695. * @param position The delta position amount
  19696. */
  19697. setDeltaPosition(position: Vector3): void;
  19698. /**
  19699. * Sets the delta rotation
  19700. * @param rotation The delta rotation amount
  19701. */
  19702. setDeltaRotation(rotation: Quaternion): void;
  19703. /**
  19704. * Gets the box size of the physics imposter and stores the result in the input parameter
  19705. * @param result Stores the box size
  19706. * @returns The physics imposter
  19707. */
  19708. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19709. /**
  19710. * Gets the radius of the physics imposter
  19711. * @returns Radius of the physics imposter
  19712. */
  19713. getRadius(): number;
  19714. /**
  19715. * Sync a bone with this impostor
  19716. * @param bone The bone to sync to the impostor.
  19717. * @param boneMesh The mesh that the bone is influencing.
  19718. * @param jointPivot The pivot of the joint / bone in local space.
  19719. * @param distToJoint Optional distance from the impostor to the joint.
  19720. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19721. */
  19722. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19723. /**
  19724. * Sync impostor to a bone
  19725. * @param bone The bone that the impostor will be synced to.
  19726. * @param boneMesh The mesh that the bone is influencing.
  19727. * @param jointPivot The pivot of the joint / bone in local space.
  19728. * @param distToJoint Optional distance from the impostor to the joint.
  19729. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19730. * @param boneAxis Optional vector3 axis the bone is aligned with
  19731. */
  19732. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19733. /**
  19734. * No-Imposter type
  19735. */
  19736. static NoImpostor: number;
  19737. /**
  19738. * Sphere-Imposter type
  19739. */
  19740. static SphereImpostor: number;
  19741. /**
  19742. * Box-Imposter type
  19743. */
  19744. static BoxImpostor: number;
  19745. /**
  19746. * Plane-Imposter type
  19747. */
  19748. static PlaneImpostor: number;
  19749. /**
  19750. * Mesh-imposter type
  19751. */
  19752. static MeshImpostor: number;
  19753. /**
  19754. * Cylinder-Imposter type
  19755. */
  19756. static CylinderImpostor: number;
  19757. /**
  19758. * Particle-Imposter type
  19759. */
  19760. static ParticleImpostor: number;
  19761. /**
  19762. * Heightmap-Imposter type
  19763. */
  19764. static HeightmapImpostor: number;
  19765. }
  19766. }
  19767. declare module BABYLON {
  19768. /**
  19769. * Class used to represent a specific level of detail of a mesh
  19770. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19771. */
  19772. export class MeshLODLevel {
  19773. /** Defines the distance where this level should star being displayed */
  19774. distance: number;
  19775. /** Defines the mesh to use to render this level */
  19776. mesh: Nullable<Mesh>;
  19777. /**
  19778. * Creates a new LOD level
  19779. * @param distance defines the distance where this level should star being displayed
  19780. * @param mesh defines the mesh to use to render this level
  19781. */
  19782. constructor(
  19783. /** Defines the distance where this level should star being displayed */
  19784. distance: number,
  19785. /** Defines the mesh to use to render this level */
  19786. mesh: Nullable<Mesh>);
  19787. }
  19788. /**
  19789. * @hidden
  19790. **/
  19791. export class _CreationDataStorage {
  19792. closePath?: boolean;
  19793. closeArray?: boolean;
  19794. idx: number[];
  19795. dashSize: number;
  19796. gapSize: number;
  19797. path3D: Path3D;
  19798. pathArray: Vector3[][];
  19799. arc: number;
  19800. radius: number;
  19801. cap: number;
  19802. tessellation: number;
  19803. }
  19804. /**
  19805. * @hidden
  19806. **/
  19807. class _InstanceDataStorage {
  19808. visibleInstances: any;
  19809. renderIdForInstances: number[];
  19810. batchCache: _InstancesBatch;
  19811. instancesBufferSize: number;
  19812. instancesBuffer: Nullable<Buffer>;
  19813. instancesData: Float32Array;
  19814. overridenInstanceCount: number;
  19815. }
  19816. /**
  19817. * @hidden
  19818. **/
  19819. export class _InstancesBatch {
  19820. mustReturn: boolean;
  19821. visibleInstances: Nullable<InstancedMesh[]>[];
  19822. renderSelf: boolean[];
  19823. }
  19824. /**
  19825. * Class used to represent renderable models
  19826. */
  19827. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19828. /**
  19829. * Mesh side orientation : usually the external or front surface
  19830. */
  19831. static readonly FRONTSIDE: number;
  19832. /**
  19833. * Mesh side orientation : usually the internal or back surface
  19834. */
  19835. static readonly BACKSIDE: number;
  19836. /**
  19837. * Mesh side orientation : both internal and external or front and back surfaces
  19838. */
  19839. static readonly DOUBLESIDE: number;
  19840. /**
  19841. * Mesh side orientation : by default, `FRONTSIDE`
  19842. */
  19843. static readonly DEFAULTSIDE: number;
  19844. /**
  19845. * Mesh cap setting : no cap
  19846. */
  19847. static readonly NO_CAP: number;
  19848. /**
  19849. * Mesh cap setting : one cap at the beginning of the mesh
  19850. */
  19851. static readonly CAP_START: number;
  19852. /**
  19853. * Mesh cap setting : one cap at the end of the mesh
  19854. */
  19855. static readonly CAP_END: number;
  19856. /**
  19857. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19858. */
  19859. static readonly CAP_ALL: number;
  19860. /**
  19861. * Gets the default side orientation.
  19862. * @param orientation the orientation to value to attempt to get
  19863. * @returns the default orientation
  19864. * @hidden
  19865. */
  19866. static _GetDefaultSideOrientation(orientation?: number): number;
  19867. private _onBeforeRenderObservable;
  19868. private _onBeforeBindObservable;
  19869. private _onAfterRenderObservable;
  19870. private _onBeforeDrawObservable;
  19871. /**
  19872. * An event triggered before rendering the mesh
  19873. */
  19874. readonly onBeforeRenderObservable: Observable<Mesh>;
  19875. /**
  19876. * An event triggered before binding the mesh
  19877. */
  19878. readonly onBeforeBindObservable: Observable<Mesh>;
  19879. /**
  19880. * An event triggered after rendering the mesh
  19881. */
  19882. readonly onAfterRenderObservable: Observable<Mesh>;
  19883. /**
  19884. * An event triggered before drawing the mesh
  19885. */
  19886. readonly onBeforeDrawObservable: Observable<Mesh>;
  19887. private _onBeforeDrawObserver;
  19888. /**
  19889. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  19890. */
  19891. onBeforeDraw: () => void;
  19892. /**
  19893. * Gets the delay loading state of the mesh (when delay loading is turned on)
  19894. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  19895. */
  19896. delayLoadState: number;
  19897. /**
  19898. * Gets the list of instances created from this mesh
  19899. * it is not supposed to be modified manually.
  19900. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  19901. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19902. */
  19903. instances: InstancedMesh[];
  19904. /**
  19905. * Gets the file containing delay loading data for this mesh
  19906. */
  19907. delayLoadingFile: string;
  19908. /** @hidden */
  19909. _binaryInfo: any;
  19910. private _LODLevels;
  19911. /**
  19912. * User defined function used to change how LOD level selection is done
  19913. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19914. */
  19915. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  19916. private _morphTargetManager;
  19917. /**
  19918. * Gets or sets the morph target manager
  19919. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19920. */
  19921. morphTargetManager: Nullable<MorphTargetManager>;
  19922. /** @hidden */
  19923. _creationDataStorage: Nullable<_CreationDataStorage>;
  19924. /** @hidden */
  19925. _geometry: Nullable<Geometry>;
  19926. /** @hidden */
  19927. _delayInfo: Array<string>;
  19928. /** @hidden */
  19929. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19930. /** @hidden */
  19931. _instanceDataStorage: _InstanceDataStorage;
  19932. private _effectiveMaterial;
  19933. /** @hidden */
  19934. _shouldGenerateFlatShading: boolean;
  19935. private _preActivateId;
  19936. /** @hidden */
  19937. _originalBuilderSideOrientation: number;
  19938. /**
  19939. * Use this property to change the original side orientation defined at construction time
  19940. */
  19941. overrideMaterialSideOrientation: Nullable<number>;
  19942. private _areNormalsFrozen;
  19943. private _sourcePositions;
  19944. private _sourceNormals;
  19945. private _source;
  19946. private meshMap;
  19947. /**
  19948. * Gets the source mesh (the one used to clone this one from)
  19949. */
  19950. readonly source: Nullable<Mesh>;
  19951. /**
  19952. * Gets or sets a boolean indicating that this mesh does not use index buffer
  19953. */
  19954. isUnIndexed: boolean;
  19955. /**
  19956. * @constructor
  19957. * @param name The value used by scene.getMeshByName() to do a lookup.
  19958. * @param scene The scene to add this mesh to.
  19959. * @param parent The parent of this mesh, if it has one
  19960. * @param source An optional Mesh from which geometry is shared, cloned.
  19961. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19962. * When false, achieved by calling a clone(), also passing False.
  19963. * This will make creation of children, recursive.
  19964. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19965. */
  19966. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19967. /**
  19968. * Gets the class name
  19969. * @returns the string "Mesh".
  19970. */
  19971. getClassName(): string;
  19972. /** @hidden */
  19973. readonly _isMesh: boolean;
  19974. /**
  19975. * Returns a description of this mesh
  19976. * @param fullDetails define if full details about this mesh must be used
  19977. * @returns a descriptive string representing this mesh
  19978. */
  19979. toString(fullDetails?: boolean): string;
  19980. /** @hidden */
  19981. _unBindEffect(): void;
  19982. /**
  19983. * Gets a boolean indicating if this mesh has LOD
  19984. */
  19985. readonly hasLODLevels: boolean;
  19986. /**
  19987. * Gets the list of MeshLODLevel associated with the current mesh
  19988. * @returns an array of MeshLODLevel
  19989. */
  19990. getLODLevels(): MeshLODLevel[];
  19991. private _sortLODLevels;
  19992. /**
  19993. * Add a mesh as LOD level triggered at the given distance.
  19994. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19995. * @param distance The distance from the center of the object to show this level
  19996. * @param mesh The mesh to be added as LOD level (can be null)
  19997. * @return This mesh (for chaining)
  19998. */
  19999. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20000. /**
  20001. * Returns the LOD level mesh at the passed distance or null if not found.
  20002. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20003. * @param distance The distance from the center of the object to show this level
  20004. * @returns a Mesh or `null`
  20005. */
  20006. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20007. /**
  20008. * Remove a mesh from the LOD array
  20009. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20010. * @param mesh defines the mesh to be removed
  20011. * @return This mesh (for chaining)
  20012. */
  20013. removeLODLevel(mesh: Mesh): Mesh;
  20014. /**
  20015. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20016. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20017. * @param camera defines the camera to use to compute distance
  20018. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20019. * @return This mesh (for chaining)
  20020. */
  20021. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20022. /**
  20023. * Gets the mesh internal Geometry object
  20024. */
  20025. readonly geometry: Nullable<Geometry>;
  20026. /**
  20027. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20028. * @returns the total number of vertices
  20029. */
  20030. getTotalVertices(): number;
  20031. /**
  20032. * Returns the content of an associated vertex buffer
  20033. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20034. * - VertexBuffer.PositionKind
  20035. * - VertexBuffer.UVKind
  20036. * - VertexBuffer.UV2Kind
  20037. * - VertexBuffer.UV3Kind
  20038. * - VertexBuffer.UV4Kind
  20039. * - VertexBuffer.UV5Kind
  20040. * - VertexBuffer.UV6Kind
  20041. * - VertexBuffer.ColorKind
  20042. * - VertexBuffer.MatricesIndicesKind
  20043. * - VertexBuffer.MatricesIndicesExtraKind
  20044. * - VertexBuffer.MatricesWeightsKind
  20045. * - VertexBuffer.MatricesWeightsExtraKind
  20046. * @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
  20047. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20048. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20049. */
  20050. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20051. /**
  20052. * Returns the mesh VertexBuffer object from the requested `kind`
  20053. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20054. * - VertexBuffer.PositionKind
  20055. * - VertexBuffer.UVKind
  20056. * - VertexBuffer.UV2Kind
  20057. * - VertexBuffer.UV3Kind
  20058. * - VertexBuffer.UV4Kind
  20059. * - VertexBuffer.UV5Kind
  20060. * - VertexBuffer.UV6Kind
  20061. * - VertexBuffer.ColorKind
  20062. * - VertexBuffer.MatricesIndicesKind
  20063. * - VertexBuffer.MatricesIndicesExtraKind
  20064. * - VertexBuffer.MatricesWeightsKind
  20065. * - VertexBuffer.MatricesWeightsExtraKind
  20066. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20067. */
  20068. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20069. /**
  20070. * Tests if a specific vertex buffer is associated with this mesh
  20071. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20072. * - VertexBuffer.PositionKind
  20073. * - VertexBuffer.UVKind
  20074. * - VertexBuffer.UV2Kind
  20075. * - VertexBuffer.UV3Kind
  20076. * - VertexBuffer.UV4Kind
  20077. * - VertexBuffer.UV5Kind
  20078. * - VertexBuffer.UV6Kind
  20079. * - VertexBuffer.ColorKind
  20080. * - VertexBuffer.MatricesIndicesKind
  20081. * - VertexBuffer.MatricesIndicesExtraKind
  20082. * - VertexBuffer.MatricesWeightsKind
  20083. * - VertexBuffer.MatricesWeightsExtraKind
  20084. * @returns a boolean
  20085. */
  20086. isVerticesDataPresent(kind: string): boolean;
  20087. /**
  20088. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20089. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20090. * - VertexBuffer.PositionKind
  20091. * - VertexBuffer.UVKind
  20092. * - VertexBuffer.UV2Kind
  20093. * - VertexBuffer.UV3Kind
  20094. * - VertexBuffer.UV4Kind
  20095. * - VertexBuffer.UV5Kind
  20096. * - VertexBuffer.UV6Kind
  20097. * - VertexBuffer.ColorKind
  20098. * - VertexBuffer.MatricesIndicesKind
  20099. * - VertexBuffer.MatricesIndicesExtraKind
  20100. * - VertexBuffer.MatricesWeightsKind
  20101. * - VertexBuffer.MatricesWeightsExtraKind
  20102. * @returns a boolean
  20103. */
  20104. isVertexBufferUpdatable(kind: string): boolean;
  20105. /**
  20106. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20107. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20108. * - VertexBuffer.PositionKind
  20109. * - VertexBuffer.UVKind
  20110. * - VertexBuffer.UV2Kind
  20111. * - VertexBuffer.UV3Kind
  20112. * - VertexBuffer.UV4Kind
  20113. * - VertexBuffer.UV5Kind
  20114. * - VertexBuffer.UV6Kind
  20115. * - VertexBuffer.ColorKind
  20116. * - VertexBuffer.MatricesIndicesKind
  20117. * - VertexBuffer.MatricesIndicesExtraKind
  20118. * - VertexBuffer.MatricesWeightsKind
  20119. * - VertexBuffer.MatricesWeightsExtraKind
  20120. * @returns an array of strings
  20121. */
  20122. getVerticesDataKinds(): string[];
  20123. /**
  20124. * Returns a positive integer : the total number of indices in this mesh geometry.
  20125. * @returns the numner of indices or zero if the mesh has no geometry.
  20126. */
  20127. getTotalIndices(): number;
  20128. /**
  20129. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20130. * @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.
  20131. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20132. * @returns the indices array or an empty array if the mesh has no geometry
  20133. */
  20134. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20135. readonly isBlocked: boolean;
  20136. /**
  20137. * Determine if the current mesh is ready to be rendered
  20138. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20139. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20140. * @returns true if all associated assets are ready (material, textures, shaders)
  20141. */
  20142. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20143. /**
  20144. * 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.
  20145. */
  20146. readonly areNormalsFrozen: boolean;
  20147. /**
  20148. * 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.
  20149. * @returns the current mesh
  20150. */
  20151. freezeNormals(): Mesh;
  20152. /**
  20153. * 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
  20154. * @returns the current mesh
  20155. */
  20156. unfreezeNormals(): Mesh;
  20157. /**
  20158. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20159. */
  20160. overridenInstanceCount: number;
  20161. /** @hidden */
  20162. _preActivate(): Mesh;
  20163. /** @hidden */
  20164. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20165. /** @hidden */
  20166. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20167. /**
  20168. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20169. * This means the mesh underlying bounding box and sphere are recomputed.
  20170. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20171. * @returns the current mesh
  20172. */
  20173. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20174. /** @hidden */
  20175. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20176. /**
  20177. * This function will subdivide the mesh into multiple submeshes
  20178. * @param count defines the expected number of submeshes
  20179. */
  20180. subdivide(count: number): void;
  20181. /**
  20182. * Copy a FloatArray into a specific associated vertex buffer
  20183. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20184. * - VertexBuffer.PositionKind
  20185. * - VertexBuffer.UVKind
  20186. * - VertexBuffer.UV2Kind
  20187. * - VertexBuffer.UV3Kind
  20188. * - VertexBuffer.UV4Kind
  20189. * - VertexBuffer.UV5Kind
  20190. * - VertexBuffer.UV6Kind
  20191. * - VertexBuffer.ColorKind
  20192. * - VertexBuffer.MatricesIndicesKind
  20193. * - VertexBuffer.MatricesIndicesExtraKind
  20194. * - VertexBuffer.MatricesWeightsKind
  20195. * - VertexBuffer.MatricesWeightsExtraKind
  20196. * @param data defines the data source
  20197. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20198. * @param stride defines the data stride size (can be null)
  20199. * @returns the current mesh
  20200. */
  20201. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20202. /**
  20203. * Flags an associated vertex buffer as updatable
  20204. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20205. * - VertexBuffer.PositionKind
  20206. * - VertexBuffer.UVKind
  20207. * - VertexBuffer.UV2Kind
  20208. * - VertexBuffer.UV3Kind
  20209. * - VertexBuffer.UV4Kind
  20210. * - VertexBuffer.UV5Kind
  20211. * - VertexBuffer.UV6Kind
  20212. * - VertexBuffer.ColorKind
  20213. * - VertexBuffer.MatricesIndicesKind
  20214. * - VertexBuffer.MatricesIndicesExtraKind
  20215. * - VertexBuffer.MatricesWeightsKind
  20216. * - VertexBuffer.MatricesWeightsExtraKind
  20217. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20218. */
  20219. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20220. /**
  20221. * Sets the mesh global Vertex Buffer
  20222. * @param buffer defines the buffer to use
  20223. * @returns the current mesh
  20224. */
  20225. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20226. /**
  20227. * Update a specific associated vertex buffer
  20228. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20229. * - VertexBuffer.PositionKind
  20230. * - VertexBuffer.UVKind
  20231. * - VertexBuffer.UV2Kind
  20232. * - VertexBuffer.UV3Kind
  20233. * - VertexBuffer.UV4Kind
  20234. * - VertexBuffer.UV5Kind
  20235. * - VertexBuffer.UV6Kind
  20236. * - VertexBuffer.ColorKind
  20237. * - VertexBuffer.MatricesIndicesKind
  20238. * - VertexBuffer.MatricesIndicesExtraKind
  20239. * - VertexBuffer.MatricesWeightsKind
  20240. * - VertexBuffer.MatricesWeightsExtraKind
  20241. * @param data defines the data source
  20242. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20243. * @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)
  20244. * @returns the current mesh
  20245. */
  20246. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20247. /**
  20248. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20249. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20250. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20251. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20252. * @returns the current mesh
  20253. */
  20254. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20255. /**
  20256. * Creates a un-shared specific occurence of the geometry for the mesh.
  20257. * @returns the current mesh
  20258. */
  20259. makeGeometryUnique(): Mesh;
  20260. /**
  20261. * Set the index buffer of this mesh
  20262. * @param indices defines the source data
  20263. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20264. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20265. * @returns the current mesh
  20266. */
  20267. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20268. /**
  20269. * Update the current index buffer
  20270. * @param indices defines the source data
  20271. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20272. * @returns the current mesh
  20273. */
  20274. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20275. /**
  20276. * Invert the geometry to move from a right handed system to a left handed one.
  20277. * @returns the current mesh
  20278. */
  20279. toLeftHanded(): Mesh;
  20280. /** @hidden */
  20281. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20282. /** @hidden */
  20283. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20284. /**
  20285. * Registers for this mesh a javascript function called just before the rendering process
  20286. * @param func defines the function to call before rendering this mesh
  20287. * @returns the current mesh
  20288. */
  20289. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20290. /**
  20291. * Disposes a previously registered javascript function called before the rendering
  20292. * @param func defines the function to remove
  20293. * @returns the current mesh
  20294. */
  20295. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20296. /**
  20297. * Registers for this mesh a javascript function called just after the rendering is complete
  20298. * @param func defines the function to call after rendering this mesh
  20299. * @returns the current mesh
  20300. */
  20301. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20302. /**
  20303. * Disposes a previously registered javascript function called after the rendering.
  20304. * @param func defines the function to remove
  20305. * @returns the current mesh
  20306. */
  20307. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20308. /** @hidden */
  20309. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20310. /** @hidden */
  20311. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20312. /** @hidden */
  20313. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20314. /**
  20315. * 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
  20316. * @param subMesh defines the subMesh to render
  20317. * @param enableAlphaMode defines if alpha mode can be changed
  20318. * @returns the current mesh
  20319. */
  20320. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20321. private _onBeforeDraw;
  20322. /**
  20323. * Renormalize the mesh and patch it up if there are no weights
  20324. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20325. * However in the case of zero weights then we set just a single influence to 1.
  20326. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20327. */
  20328. cleanMatrixWeights(): void;
  20329. private normalizeSkinFourWeights;
  20330. private normalizeSkinWeightsAndExtra;
  20331. /**
  20332. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20333. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20334. * the user know there was an issue with importing the mesh
  20335. * @returns a validation object with skinned, valid and report string
  20336. */
  20337. validateSkinning(): {
  20338. skinned: boolean;
  20339. valid: boolean;
  20340. report: string;
  20341. };
  20342. /** @hidden */
  20343. _checkDelayState(): Mesh;
  20344. private _queueLoad;
  20345. /**
  20346. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20347. * A mesh is in the frustum if its bounding box intersects the frustum
  20348. * @param frustumPlanes defines the frustum to test
  20349. * @returns true if the mesh is in the frustum planes
  20350. */
  20351. isInFrustum(frustumPlanes: Plane[]): boolean;
  20352. /**
  20353. * Sets the mesh material by the material or multiMaterial `id` property
  20354. * @param id is a string identifying the material or the multiMaterial
  20355. * @returns the current mesh
  20356. */
  20357. setMaterialByID(id: string): Mesh;
  20358. /**
  20359. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20360. * @returns an array of IAnimatable
  20361. */
  20362. getAnimatables(): IAnimatable[];
  20363. /**
  20364. * Modifies the mesh geometry according to the passed transformation matrix.
  20365. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20366. * The mesh normals are modified using the same transformation.
  20367. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20368. * @param transform defines the transform matrix to use
  20369. * @see http://doc.babylonjs.com/resources/baking_transformations
  20370. * @returns the current mesh
  20371. */
  20372. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20373. /**
  20374. * Modifies the mesh geometry according to its own current World Matrix.
  20375. * The mesh World Matrix is then reset.
  20376. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20377. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20378. * @see http://doc.babylonjs.com/resources/baking_transformations
  20379. * @returns the current mesh
  20380. */
  20381. bakeCurrentTransformIntoVertices(): Mesh;
  20382. /** @hidden */
  20383. readonly _positions: Nullable<Vector3[]>;
  20384. /** @hidden */
  20385. _resetPointsArrayCache(): Mesh;
  20386. /** @hidden */
  20387. _generatePointsArray(): boolean;
  20388. /**
  20389. * Returns a new Mesh object generated from the current mesh properties.
  20390. * This method must not get confused with createInstance()
  20391. * @param name is a string, the name given to the new mesh
  20392. * @param newParent can be any Node object (default `null`)
  20393. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20394. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20395. * @returns a new mesh
  20396. */
  20397. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20398. /**
  20399. * Releases resources associated with this mesh.
  20400. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20401. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20402. */
  20403. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20404. /**
  20405. * Modifies the mesh geometry according to a displacement map.
  20406. * 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.
  20407. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20408. * @param url is a string, the URL from the image file is to be downloaded.
  20409. * @param minHeight is the lower limit of the displacement.
  20410. * @param maxHeight is the upper limit of the displacement.
  20411. * @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.
  20412. * @param uvOffset is an optional vector2 used to offset UV.
  20413. * @param uvScale is an optional vector2 used to scale UV.
  20414. * @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.
  20415. * @returns the Mesh.
  20416. */
  20417. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20418. /**
  20419. * Modifies the mesh geometry according to a displacementMap buffer.
  20420. * 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.
  20421. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20422. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20423. * @param heightMapWidth is the width of the buffer image.
  20424. * @param heightMapHeight is the height of the buffer image.
  20425. * @param minHeight is the lower limit of the displacement.
  20426. * @param maxHeight is the upper limit of the displacement.
  20427. * @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.
  20428. * @param uvOffset is an optional vector2 used to offset UV.
  20429. * @param uvScale is an optional vector2 used to scale UV.
  20430. * @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.
  20431. * @returns the Mesh.
  20432. */
  20433. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20434. /**
  20435. * Modify the mesh to get a flat shading rendering.
  20436. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20437. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20438. * @returns current mesh
  20439. */
  20440. convertToFlatShadedMesh(): Mesh;
  20441. /**
  20442. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20443. * In other words, more vertices, no more indices and a single bigger VBO.
  20444. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20445. * @returns current mesh
  20446. */
  20447. convertToUnIndexedMesh(): Mesh;
  20448. /**
  20449. * Inverses facet orientations.
  20450. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20451. * @param flipNormals will also inverts the normals
  20452. * @returns current mesh
  20453. */
  20454. flipFaces(flipNormals?: boolean): Mesh;
  20455. /** @hidden */
  20456. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  20457. /** @hidden */
  20458. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  20459. /**
  20460. * Creates a new InstancedMesh object from the mesh model.
  20461. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20462. * @param name defines the name of the new instance
  20463. * @returns a new InstancedMesh
  20464. */
  20465. createInstance(name: string): InstancedMesh;
  20466. /**
  20467. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20468. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20469. * @returns the current mesh
  20470. */
  20471. synchronizeInstances(): Mesh;
  20472. /**
  20473. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20474. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20475. * This should be used together with the simplification to avoid disappearing triangles.
  20476. * @param successCallback an optional success callback to be called after the optimization finished.
  20477. * @returns the current mesh
  20478. */
  20479. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20480. /**
  20481. * Serialize current mesh
  20482. * @param serializationObject defines the object which will receive the serialization data
  20483. */
  20484. serialize(serializationObject: any): void;
  20485. /** @hidden */
  20486. _syncGeometryWithMorphTargetManager(): void;
  20487. /** @hidden */
  20488. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  20489. /**
  20490. * Returns a new Mesh object parsed from the source provided.
  20491. * @param parsedMesh is the source
  20492. * @param scene defines the hosting scene
  20493. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  20494. * @returns a new Mesh
  20495. */
  20496. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20497. /**
  20498. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  20499. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20500. * @param name defines the name of the mesh to create
  20501. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20502. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  20503. * @param closePath creates a seam between the first and the last points of each path of the path array
  20504. * @param offset is taken in account only if the `pathArray` is containing a single path
  20505. * @param scene defines the hosting scene
  20506. * @param updatable defines if the mesh must be flagged as updatable
  20507. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20508. * @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)
  20509. * @returns a new Mesh
  20510. */
  20511. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20512. /**
  20513. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  20514. * @param name defines the name of the mesh to create
  20515. * @param radius sets the radius size (float) of the polygon (default 0.5)
  20516. * @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
  20517. * @param scene defines the hosting scene
  20518. * @param updatable defines if the mesh must be flagged as updatable
  20519. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20520. * @returns a new Mesh
  20521. */
  20522. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20523. /**
  20524. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  20525. * @param name defines the name of the mesh to create
  20526. * @param size sets the size (float) of each box side (default 1)
  20527. * @param scene defines the hosting scene
  20528. * @param updatable defines if the mesh must be flagged as updatable
  20529. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20530. * @returns a new Mesh
  20531. */
  20532. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20533. /**
  20534. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  20535. * @param name defines the name of the mesh to create
  20536. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  20537. * @param diameter sets the diameter size (float) of the sphere (default 1)
  20538. * @param scene defines the hosting scene
  20539. * @param updatable defines if the mesh must be flagged as updatable
  20540. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20541. * @returns a new Mesh
  20542. */
  20543. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20544. /**
  20545. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  20546. * @param name defines the name of the mesh to create
  20547. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  20548. * @param diameterTop set the top cap diameter (floats, default 1)
  20549. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  20550. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  20551. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  20552. * @param scene defines the hosting scene
  20553. * @param updatable defines if the mesh must be flagged as updatable
  20554. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20555. * @returns a new Mesh
  20556. */
  20557. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20558. /**
  20559. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  20560. * @param name defines the name of the mesh to create
  20561. * @param diameter sets the diameter size (float) of the torus (default 1)
  20562. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  20563. * @param tessellation sets the number of torus sides (postive integer, default 16)
  20564. * @param scene defines the hosting scene
  20565. * @param updatable defines if the mesh must be flagged as updatable
  20566. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20567. * @returns a new Mesh
  20568. */
  20569. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20570. /**
  20571. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  20572. * @param name defines the name of the mesh to create
  20573. * @param radius sets the global radius size (float) of the torus knot (default 2)
  20574. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  20575. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  20576. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  20577. * @param p the number of windings on X axis (positive integers, default 2)
  20578. * @param q the number of windings on Y axis (positive integers, default 3)
  20579. * @param scene defines the hosting scene
  20580. * @param updatable defines if the mesh must be flagged as updatable
  20581. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20582. * @returns a new Mesh
  20583. */
  20584. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20585. /**
  20586. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  20587. * @param name defines the name of the mesh to create
  20588. * @param points is an array successive Vector3
  20589. * @param scene defines the hosting scene
  20590. * @param updatable defines if the mesh must be flagged as updatable
  20591. * @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).
  20592. * @returns a new Mesh
  20593. */
  20594. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20595. /**
  20596. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  20597. * @param name defines the name of the mesh to create
  20598. * @param points is an array successive Vector3
  20599. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  20600. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  20601. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  20602. * @param scene defines the hosting scene
  20603. * @param updatable defines if the mesh must be flagged as updatable
  20604. * @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)
  20605. * @returns a new Mesh
  20606. */
  20607. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20608. /**
  20609. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  20610. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20611. * 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.
  20612. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20613. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20614. * Remember you can only change the shape positions, not their number when updating a polygon.
  20615. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  20616. * @param name defines the name of the mesh to create
  20617. * @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
  20618. * @param scene defines the hosting scene
  20619. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20620. * @param updatable defines if the mesh must be flagged as updatable
  20621. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20622. * @param earcutInjection can be used to inject your own earcut reference
  20623. * @returns a new Mesh
  20624. */
  20625. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20626. /**
  20627. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  20628. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  20629. * @param name defines the name of the mesh to create
  20630. * @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
  20631. * @param depth defines the height of extrusion
  20632. * @param scene defines the hosting scene
  20633. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20634. * @param updatable defines if the mesh must be flagged as updatable
  20635. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20636. * @param earcutInjection can be used to inject your own earcut reference
  20637. * @returns a new Mesh
  20638. */
  20639. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20640. /**
  20641. * Creates an extruded shape mesh.
  20642. * 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
  20643. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20644. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20645. * @param name defines the name of the mesh to create
  20646. * @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
  20647. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20648. * @param scale is the value to scale the shape
  20649. * @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
  20650. * @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
  20651. * @param scene defines the hosting scene
  20652. * @param updatable defines if the mesh must be flagged as updatable
  20653. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20654. * @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)
  20655. * @returns a new Mesh
  20656. */
  20657. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20658. /**
  20659. * Creates an custom extruded shape mesh.
  20660. * The custom extrusion is a parametric shape.
  20661. * It has no predefined shape. Its final shape will depend on the input parameters.
  20662. * Please consider using the same method from the MeshBuilder class instead
  20663. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20664. * @param name defines the name of the mesh to create
  20665. * @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
  20666. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20667. * @param scaleFunction is a custom Javascript function called on each path point
  20668. * @param rotationFunction is a custom Javascript function called on each path point
  20669. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  20670. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  20671. * @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
  20672. * @param scene defines the hosting scene
  20673. * @param updatable defines if the mesh must be flagged as updatable
  20674. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20675. * @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)
  20676. * @returns a new Mesh
  20677. */
  20678. 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;
  20679. /**
  20680. * Creates lathe mesh.
  20681. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20682. * Please consider using the same method from the MeshBuilder class instead
  20683. * @param name defines the name of the mesh to create
  20684. * @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
  20685. * @param radius is the radius value of the lathe
  20686. * @param tessellation is the side number of the lathe.
  20687. * @param scene defines the hosting scene
  20688. * @param updatable defines if the mesh must be flagged as updatable
  20689. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20690. * @returns a new Mesh
  20691. */
  20692. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20693. /**
  20694. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  20695. * @param name defines the name of the mesh to create
  20696. * @param size sets the size (float) of both sides of the plane at once (default 1)
  20697. * @param scene defines the hosting scene
  20698. * @param updatable defines if the mesh must be flagged as updatable
  20699. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20700. * @returns a new Mesh
  20701. */
  20702. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20703. /**
  20704. * Creates a ground mesh.
  20705. * Please consider using the same method from the MeshBuilder class instead
  20706. * @param name defines the name of the mesh to create
  20707. * @param width set the width of the ground
  20708. * @param height set the height of the ground
  20709. * @param subdivisions sets the number of subdivisions per side
  20710. * @param scene defines the hosting scene
  20711. * @param updatable defines if the mesh must be flagged as updatable
  20712. * @returns a new Mesh
  20713. */
  20714. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  20715. /**
  20716. * Creates a tiled ground mesh.
  20717. * Please consider using the same method from the MeshBuilder class instead
  20718. * @param name defines the name of the mesh to create
  20719. * @param xmin set the ground minimum X coordinate
  20720. * @param zmin set the ground minimum Y coordinate
  20721. * @param xmax set the ground maximum X coordinate
  20722. * @param zmax set the ground maximum Z coordinate
  20723. * @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
  20724. * @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
  20725. * @param scene defines the hosting scene
  20726. * @param updatable defines if the mesh must be flagged as updatable
  20727. * @returns a new Mesh
  20728. */
  20729. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  20730. w: number;
  20731. h: number;
  20732. }, precision: {
  20733. w: number;
  20734. h: number;
  20735. }, scene: Scene, updatable?: boolean): Mesh;
  20736. /**
  20737. * Creates a ground mesh from a height map.
  20738. * Please consider using the same method from the MeshBuilder class instead
  20739. * @see http://doc.babylonjs.com/babylon101/height_map
  20740. * @param name defines the name of the mesh to create
  20741. * @param url sets the URL of the height map image resource
  20742. * @param width set the ground width size
  20743. * @param height set the ground height size
  20744. * @param subdivisions sets the number of subdivision per side
  20745. * @param minHeight is the minimum altitude on the ground
  20746. * @param maxHeight is the maximum altitude on the ground
  20747. * @param scene defines the hosting scene
  20748. * @param updatable defines if the mesh must be flagged as updatable
  20749. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  20750. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  20751. * @returns a new Mesh
  20752. */
  20753. 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;
  20754. /**
  20755. * Creates a tube mesh.
  20756. * The tube is a parametric shape.
  20757. * It has no predefined shape. Its final shape will depend on the input parameters.
  20758. * Please consider using the same method from the MeshBuilder class instead
  20759. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20760. * @param name defines the name of the mesh to create
  20761. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  20762. * @param radius sets the tube radius size
  20763. * @param tessellation is the number of sides on the tubular surface
  20764. * @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
  20765. * @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
  20766. * @param scene defines the hosting scene
  20767. * @param updatable defines if the mesh must be flagged as updatable
  20768. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20769. * @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)
  20770. * @returns a new Mesh
  20771. */
  20772. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  20773. (i: number, distance: number): number;
  20774. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20775. /**
  20776. * Creates a polyhedron mesh.
  20777. * Please consider using the same method from the MeshBuilder class instead.
  20778. * * 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
  20779. * * The parameter `size` (positive float, default 1) sets the polygon size
  20780. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  20781. * * 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`
  20782. * * 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
  20783. * * 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)`)
  20784. * * 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
  20785. * * 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
  20786. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20787. * * 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
  20788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20789. * @param name defines the name of the mesh to create
  20790. * @param options defines the options used to create the mesh
  20791. * @param scene defines the hosting scene
  20792. * @returns a new Mesh
  20793. */
  20794. static CreatePolyhedron(name: string, options: {
  20795. type?: number;
  20796. size?: number;
  20797. sizeX?: number;
  20798. sizeY?: number;
  20799. sizeZ?: number;
  20800. custom?: any;
  20801. faceUV?: Vector4[];
  20802. faceColors?: Color4[];
  20803. updatable?: boolean;
  20804. sideOrientation?: number;
  20805. }, scene: Scene): Mesh;
  20806. /**
  20807. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  20808. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  20809. * * 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`)
  20810. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  20811. * * 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
  20812. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20813. * * 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
  20814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20815. * @param name defines the name of the mesh
  20816. * @param options defines the options used to create the mesh
  20817. * @param scene defines the hosting scene
  20818. * @returns a new Mesh
  20819. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  20820. */
  20821. static CreateIcoSphere(name: string, options: {
  20822. radius?: number;
  20823. flat?: boolean;
  20824. subdivisions?: number;
  20825. sideOrientation?: number;
  20826. updatable?: boolean;
  20827. }, scene: Scene): Mesh;
  20828. /**
  20829. * Creates a decal mesh.
  20830. * Please consider using the same method from the MeshBuilder class instead.
  20831. * A decal is a mesh usually applied as a model onto the surface of another mesh
  20832. * @param name defines the name of the mesh
  20833. * @param sourceMesh defines the mesh receiving the decal
  20834. * @param position sets the position of the decal in world coordinates
  20835. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  20836. * @param size sets the decal scaling
  20837. * @param angle sets the angle to rotate the decal
  20838. * @returns a new Mesh
  20839. */
  20840. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20841. /**
  20842. * Prepare internal position array for software CPU skinning
  20843. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  20844. */
  20845. setPositionsForCPUSkinning(): Float32Array;
  20846. /**
  20847. * Prepare internal normal array for software CPU skinning
  20848. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20849. */
  20850. setNormalsForCPUSkinning(): Float32Array;
  20851. /**
  20852. * Updates the vertex buffer by applying transformation from the bones
  20853. * @param skeleton defines the skeleton to apply to current mesh
  20854. * @returns the current mesh
  20855. */
  20856. applySkeleton(skeleton: Skeleton): Mesh;
  20857. /**
  20858. * 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
  20859. * @param meshes defines the list of meshes to scan
  20860. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  20861. */
  20862. static MinMax(meshes: AbstractMesh[]): {
  20863. min: Vector3;
  20864. max: Vector3;
  20865. };
  20866. /**
  20867. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  20868. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  20869. * @returns a vector3
  20870. */
  20871. static Center(meshesOrMinMaxVector: {
  20872. min: Vector3;
  20873. max: Vector3;
  20874. } | AbstractMesh[]): Vector3;
  20875. /**
  20876. * Merge the array of meshes into a single mesh for performance reasons.
  20877. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  20878. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  20879. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  20880. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20881. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  20882. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  20883. * @returns a new mesh
  20884. */
  20885. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  20886. /** @hidden */
  20887. addInstance(instance: InstancedMesh): void;
  20888. /** @hidden */
  20889. removeInstance(instance: InstancedMesh): void;
  20890. }
  20891. }
  20892. declare module BABYLON {
  20893. /**
  20894. * Base class for the main features of a material in Babylon.js
  20895. */
  20896. export class Material implements IAnimatable {
  20897. /**
  20898. * Returns the triangle fill mode
  20899. */
  20900. static readonly TriangleFillMode: number;
  20901. /**
  20902. * Returns the wireframe mode
  20903. */
  20904. static readonly WireFrameFillMode: number;
  20905. /**
  20906. * Returns the point fill mode
  20907. */
  20908. static readonly PointFillMode: number;
  20909. /**
  20910. * Returns the point list draw mode
  20911. */
  20912. static readonly PointListDrawMode: number;
  20913. /**
  20914. * Returns the line list draw mode
  20915. */
  20916. static readonly LineListDrawMode: number;
  20917. /**
  20918. * Returns the line loop draw mode
  20919. */
  20920. static readonly LineLoopDrawMode: number;
  20921. /**
  20922. * Returns the line strip draw mode
  20923. */
  20924. static readonly LineStripDrawMode: number;
  20925. /**
  20926. * Returns the triangle strip draw mode
  20927. */
  20928. static readonly TriangleStripDrawMode: number;
  20929. /**
  20930. * Returns the triangle fan draw mode
  20931. */
  20932. static readonly TriangleFanDrawMode: number;
  20933. /**
  20934. * Stores the clock-wise side orientation
  20935. */
  20936. static readonly ClockWiseSideOrientation: number;
  20937. /**
  20938. * Stores the counter clock-wise side orientation
  20939. */
  20940. static readonly CounterClockWiseSideOrientation: number;
  20941. /**
  20942. * The dirty texture flag value
  20943. */
  20944. static readonly TextureDirtyFlag: number;
  20945. /**
  20946. * The dirty light flag value
  20947. */
  20948. static readonly LightDirtyFlag: number;
  20949. /**
  20950. * The dirty fresnel flag value
  20951. */
  20952. static readonly FresnelDirtyFlag: number;
  20953. /**
  20954. * The dirty attribute flag value
  20955. */
  20956. static readonly AttributesDirtyFlag: number;
  20957. /**
  20958. * The dirty misc flag value
  20959. */
  20960. static readonly MiscDirtyFlag: number;
  20961. /**
  20962. * The all dirty flag value
  20963. */
  20964. static readonly AllDirtyFlag: number;
  20965. /**
  20966. * The ID of the material
  20967. */
  20968. id: string;
  20969. /**
  20970. * Gets or sets the unique id of the material
  20971. */
  20972. uniqueId: number;
  20973. /**
  20974. * The name of the material
  20975. */
  20976. name: string;
  20977. /**
  20978. * Gets or sets user defined metadata
  20979. */
  20980. metadata: any;
  20981. /**
  20982. * For internal use only. Please do not use.
  20983. */
  20984. reservedDataStore: any;
  20985. /**
  20986. * Specifies if the ready state should be checked on each call
  20987. */
  20988. checkReadyOnEveryCall: boolean;
  20989. /**
  20990. * Specifies if the ready state should be checked once
  20991. */
  20992. checkReadyOnlyOnce: boolean;
  20993. /**
  20994. * The state of the material
  20995. */
  20996. state: string;
  20997. /**
  20998. * The alpha value of the material
  20999. */
  21000. protected _alpha: number;
  21001. /**
  21002. * Sets the alpha value of the material
  21003. */
  21004. /**
  21005. * Gets the alpha value of the material
  21006. */
  21007. alpha: number;
  21008. /**
  21009. * Specifies if back face culling is enabled
  21010. */
  21011. protected _backFaceCulling: boolean;
  21012. /**
  21013. * Sets the back-face culling state
  21014. */
  21015. /**
  21016. * Gets the back-face culling state
  21017. */
  21018. backFaceCulling: boolean;
  21019. /**
  21020. * Stores the value for side orientation
  21021. */
  21022. sideOrientation: number;
  21023. /**
  21024. * Callback triggered when the material is compiled
  21025. */
  21026. onCompiled: (effect: Effect) => void;
  21027. /**
  21028. * Callback triggered when an error occurs
  21029. */
  21030. onError: (effect: Effect, errors: string) => void;
  21031. /**
  21032. * Callback triggered to get the render target textures
  21033. */
  21034. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21035. /**
  21036. * Gets a boolean indicating that current material needs to register RTT
  21037. */
  21038. readonly hasRenderTargetTextures: boolean;
  21039. /**
  21040. * Specifies if the material should be serialized
  21041. */
  21042. doNotSerialize: boolean;
  21043. /**
  21044. * @hidden
  21045. */
  21046. _storeEffectOnSubMeshes: boolean;
  21047. /**
  21048. * Stores the animations for the material
  21049. */
  21050. animations: Array<Animation>;
  21051. /**
  21052. * An event triggered when the material is disposed
  21053. */
  21054. onDisposeObservable: Observable<Material>;
  21055. /**
  21056. * An observer which watches for dispose events
  21057. */
  21058. private _onDisposeObserver;
  21059. private _onUnBindObservable;
  21060. /**
  21061. * Called during a dispose event
  21062. */
  21063. onDispose: () => void;
  21064. private _onBindObservable;
  21065. /**
  21066. * An event triggered when the material is bound
  21067. */
  21068. readonly onBindObservable: Observable<AbstractMesh>;
  21069. /**
  21070. * An observer which watches for bind events
  21071. */
  21072. private _onBindObserver;
  21073. /**
  21074. * Called during a bind event
  21075. */
  21076. onBind: (Mesh: AbstractMesh) => void;
  21077. /**
  21078. * An event triggered when the material is unbound
  21079. */
  21080. readonly onUnBindObservable: Observable<Material>;
  21081. /**
  21082. * Stores the value of the alpha mode
  21083. */
  21084. private _alphaMode;
  21085. /**
  21086. * Sets the value of the alpha mode.
  21087. *
  21088. * | Value | Type | Description |
  21089. * | --- | --- | --- |
  21090. * | 0 | ALPHA_DISABLE | |
  21091. * | 1 | ALPHA_ADD | |
  21092. * | 2 | ALPHA_COMBINE | |
  21093. * | 3 | ALPHA_SUBTRACT | |
  21094. * | 4 | ALPHA_MULTIPLY | |
  21095. * | 5 | ALPHA_MAXIMIZED | |
  21096. * | 6 | ALPHA_ONEONE | |
  21097. * | 7 | ALPHA_PREMULTIPLIED | |
  21098. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21099. * | 9 | ALPHA_INTERPOLATE | |
  21100. * | 10 | ALPHA_SCREENMODE | |
  21101. *
  21102. */
  21103. /**
  21104. * Gets the value of the alpha mode
  21105. */
  21106. alphaMode: number;
  21107. /**
  21108. * Stores the state of the need depth pre-pass value
  21109. */
  21110. private _needDepthPrePass;
  21111. /**
  21112. * Sets the need depth pre-pass value
  21113. */
  21114. /**
  21115. * Gets the depth pre-pass value
  21116. */
  21117. needDepthPrePass: boolean;
  21118. /**
  21119. * Specifies if depth writing should be disabled
  21120. */
  21121. disableDepthWrite: boolean;
  21122. /**
  21123. * Specifies if depth writing should be forced
  21124. */
  21125. forceDepthWrite: boolean;
  21126. /**
  21127. * Specifies if there should be a separate pass for culling
  21128. */
  21129. separateCullingPass: boolean;
  21130. /**
  21131. * Stores the state specifing if fog should be enabled
  21132. */
  21133. private _fogEnabled;
  21134. /**
  21135. * Sets the state for enabling fog
  21136. */
  21137. /**
  21138. * Gets the value of the fog enabled state
  21139. */
  21140. fogEnabled: boolean;
  21141. /**
  21142. * Stores the size of points
  21143. */
  21144. pointSize: number;
  21145. /**
  21146. * Stores the z offset value
  21147. */
  21148. zOffset: number;
  21149. /**
  21150. * Gets a value specifying if wireframe mode is enabled
  21151. */
  21152. /**
  21153. * Sets the state of wireframe mode
  21154. */
  21155. wireframe: boolean;
  21156. /**
  21157. * Gets the value specifying if point clouds are enabled
  21158. */
  21159. /**
  21160. * Sets the state of point cloud mode
  21161. */
  21162. pointsCloud: boolean;
  21163. /**
  21164. * Gets the material fill mode
  21165. */
  21166. /**
  21167. * Sets the material fill mode
  21168. */
  21169. fillMode: number;
  21170. /**
  21171. * @hidden
  21172. * Stores the effects for the material
  21173. */
  21174. _effect: Nullable<Effect>;
  21175. /**
  21176. * @hidden
  21177. * Specifies if the material was previously ready
  21178. */
  21179. _wasPreviouslyReady: boolean;
  21180. /**
  21181. * Specifies if uniform buffers should be used
  21182. */
  21183. private _useUBO;
  21184. /**
  21185. * Stores a reference to the scene
  21186. */
  21187. private _scene;
  21188. /**
  21189. * Stores the fill mode state
  21190. */
  21191. private _fillMode;
  21192. /**
  21193. * Specifies if the depth write state should be cached
  21194. */
  21195. private _cachedDepthWriteState;
  21196. /**
  21197. * Stores the uniform buffer
  21198. */
  21199. protected _uniformBuffer: UniformBuffer;
  21200. /** @hidden */
  21201. _indexInSceneMaterialArray: number;
  21202. /** @hidden */
  21203. meshMap: Nullable<{
  21204. [id: string]: AbstractMesh | undefined;
  21205. }>;
  21206. /**
  21207. * Creates a material instance
  21208. * @param name defines the name of the material
  21209. * @param scene defines the scene to reference
  21210. * @param doNotAdd specifies if the material should be added to the scene
  21211. */
  21212. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21213. /**
  21214. * Returns a string representation of the current material
  21215. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21216. * @returns a string with material information
  21217. */
  21218. toString(fullDetails?: boolean): string;
  21219. /**
  21220. * Gets the class name of the material
  21221. * @returns a string with the class name of the material
  21222. */
  21223. getClassName(): string;
  21224. /**
  21225. * Specifies if updates for the material been locked
  21226. */
  21227. readonly isFrozen: boolean;
  21228. /**
  21229. * Locks updates for the material
  21230. */
  21231. freeze(): void;
  21232. /**
  21233. * Unlocks updates for the material
  21234. */
  21235. unfreeze(): void;
  21236. /**
  21237. * Specifies if the material is ready to be used
  21238. * @param mesh defines the mesh to check
  21239. * @param useInstances specifies if instances should be used
  21240. * @returns a boolean indicating if the material is ready to be used
  21241. */
  21242. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21243. /**
  21244. * Specifies that the submesh is ready to be used
  21245. * @param mesh defines the mesh to check
  21246. * @param subMesh defines which submesh to check
  21247. * @param useInstances specifies that instances should be used
  21248. * @returns a boolean indicating that the submesh is ready or not
  21249. */
  21250. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21251. /**
  21252. * Returns the material effect
  21253. * @returns the effect associated with the material
  21254. */
  21255. getEffect(): Nullable<Effect>;
  21256. /**
  21257. * Returns the current scene
  21258. * @returns a Scene
  21259. */
  21260. getScene(): Scene;
  21261. /**
  21262. * Specifies if the material will require alpha blending
  21263. * @returns a boolean specifying if alpha blending is needed
  21264. */
  21265. needAlphaBlending(): boolean;
  21266. /**
  21267. * Specifies if the mesh will require alpha blending
  21268. * @param mesh defines the mesh to check
  21269. * @returns a boolean specifying if alpha blending is needed for the mesh
  21270. */
  21271. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21272. /**
  21273. * Specifies if this material should be rendered in alpha test mode
  21274. * @returns a boolean specifying if an alpha test is needed.
  21275. */
  21276. needAlphaTesting(): boolean;
  21277. /**
  21278. * Gets the texture used for the alpha test
  21279. * @returns the texture to use for alpha testing
  21280. */
  21281. getAlphaTestTexture(): Nullable<BaseTexture>;
  21282. /**
  21283. * Marks the material to indicate that it needs to be re-calculated
  21284. */
  21285. markDirty(): void;
  21286. /** @hidden */
  21287. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21288. /**
  21289. * Binds the material to the mesh
  21290. * @param world defines the world transformation matrix
  21291. * @param mesh defines the mesh to bind the material to
  21292. */
  21293. bind(world: Matrix, mesh?: Mesh): void;
  21294. /**
  21295. * Binds the submesh to the material
  21296. * @param world defines the world transformation matrix
  21297. * @param mesh defines the mesh containing the submesh
  21298. * @param subMesh defines the submesh to bind the material to
  21299. */
  21300. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21301. /**
  21302. * Binds the world matrix to the material
  21303. * @param world defines the world transformation matrix
  21304. */
  21305. bindOnlyWorldMatrix(world: Matrix): void;
  21306. /**
  21307. * Binds the scene's uniform buffer to the effect.
  21308. * @param effect defines the effect to bind to the scene uniform buffer
  21309. * @param sceneUbo defines the uniform buffer storing scene data
  21310. */
  21311. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21312. /**
  21313. * Binds the view matrix to the effect
  21314. * @param effect defines the effect to bind the view matrix to
  21315. */
  21316. bindView(effect: Effect): void;
  21317. /**
  21318. * Binds the view projection matrix to the effect
  21319. * @param effect defines the effect to bind the view projection matrix to
  21320. */
  21321. bindViewProjection(effect: Effect): void;
  21322. /**
  21323. * Specifies if material alpha testing should be turned on for the mesh
  21324. * @param mesh defines the mesh to check
  21325. */
  21326. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21327. /**
  21328. * Processes to execute after binding the material to a mesh
  21329. * @param mesh defines the rendered mesh
  21330. */
  21331. protected _afterBind(mesh?: Mesh): void;
  21332. /**
  21333. * Unbinds the material from the mesh
  21334. */
  21335. unbind(): void;
  21336. /**
  21337. * Gets the active textures from the material
  21338. * @returns an array of textures
  21339. */
  21340. getActiveTextures(): BaseTexture[];
  21341. /**
  21342. * Specifies if the material uses a texture
  21343. * @param texture defines the texture to check against the material
  21344. * @returns a boolean specifying if the material uses the texture
  21345. */
  21346. hasTexture(texture: BaseTexture): boolean;
  21347. /**
  21348. * Makes a duplicate of the material, and gives it a new name
  21349. * @param name defines the new name for the duplicated material
  21350. * @returns the cloned material
  21351. */
  21352. clone(name: string): Nullable<Material>;
  21353. /**
  21354. * Gets the meshes bound to the material
  21355. * @returns an array of meshes bound to the material
  21356. */
  21357. getBindedMeshes(): AbstractMesh[];
  21358. /**
  21359. * Force shader compilation
  21360. * @param mesh defines the mesh associated with this material
  21361. * @param onCompiled defines a function to execute once the material is compiled
  21362. * @param options defines the options to configure the compilation
  21363. */
  21364. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21365. clipPlane: boolean;
  21366. }>): void;
  21367. /**
  21368. * Force shader compilation
  21369. * @param mesh defines the mesh that will use this material
  21370. * @param options defines additional options for compiling the shaders
  21371. * @returns a promise that resolves when the compilation completes
  21372. */
  21373. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21374. clipPlane: boolean;
  21375. }>): Promise<void>;
  21376. private static readonly _ImageProcessingDirtyCallBack;
  21377. private static readonly _TextureDirtyCallBack;
  21378. private static readonly _FresnelDirtyCallBack;
  21379. private static readonly _MiscDirtyCallBack;
  21380. private static readonly _LightsDirtyCallBack;
  21381. private static readonly _AttributeDirtyCallBack;
  21382. private static _FresnelAndMiscDirtyCallBack;
  21383. private static _TextureAndMiscDirtyCallBack;
  21384. private static readonly _DirtyCallbackArray;
  21385. private static readonly _RunDirtyCallBacks;
  21386. /**
  21387. * Marks a define in the material to indicate that it needs to be re-computed
  21388. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21389. */
  21390. markAsDirty(flag: number): void;
  21391. /**
  21392. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21393. * @param func defines a function which checks material defines against the submeshes
  21394. */
  21395. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21396. /**
  21397. * Indicates that image processing needs to be re-calculated for all submeshes
  21398. */
  21399. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21400. /**
  21401. * Indicates that textures need to be re-calculated for all submeshes
  21402. */
  21403. protected _markAllSubMeshesAsTexturesDirty(): void;
  21404. /**
  21405. * Indicates that fresnel needs to be re-calculated for all submeshes
  21406. */
  21407. protected _markAllSubMeshesAsFresnelDirty(): void;
  21408. /**
  21409. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21410. */
  21411. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21412. /**
  21413. * Indicates that lights need to be re-calculated for all submeshes
  21414. */
  21415. protected _markAllSubMeshesAsLightsDirty(): void;
  21416. /**
  21417. * Indicates that attributes need to be re-calculated for all submeshes
  21418. */
  21419. protected _markAllSubMeshesAsAttributesDirty(): void;
  21420. /**
  21421. * Indicates that misc needs to be re-calculated for all submeshes
  21422. */
  21423. protected _markAllSubMeshesAsMiscDirty(): void;
  21424. /**
  21425. * Indicates that textures and misc need to be re-calculated for all submeshes
  21426. */
  21427. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21428. /**
  21429. * Disposes the material
  21430. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21431. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21432. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21433. */
  21434. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21435. /** @hidden */
  21436. private releaseVertexArrayObject;
  21437. /**
  21438. * Serializes this material
  21439. * @returns the serialized material object
  21440. */
  21441. serialize(): any;
  21442. /**
  21443. * Creates a material from parsed material data
  21444. * @param parsedMaterial defines parsed material data
  21445. * @param scene defines the hosting scene
  21446. * @param rootUrl defines the root URL to use to load textures
  21447. * @returns a new material
  21448. */
  21449. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  21450. }
  21451. }
  21452. declare module BABYLON {
  21453. /**
  21454. * Base class for submeshes
  21455. */
  21456. export class BaseSubMesh {
  21457. /** @hidden */
  21458. _materialDefines: Nullable<MaterialDefines>;
  21459. /** @hidden */
  21460. _materialEffect: Nullable<Effect>;
  21461. /**
  21462. * Gets associated effect
  21463. */
  21464. readonly effect: Nullable<Effect>;
  21465. /**
  21466. * Sets associated effect (effect used to render this submesh)
  21467. * @param effect defines the effect to associate with
  21468. * @param defines defines the set of defines used to compile this effect
  21469. */
  21470. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21471. }
  21472. /**
  21473. * Defines a subdivision inside a mesh
  21474. */
  21475. export class SubMesh extends BaseSubMesh implements ICullable {
  21476. /** the material index to use */
  21477. materialIndex: number;
  21478. /** vertex index start */
  21479. verticesStart: number;
  21480. /** vertices count */
  21481. verticesCount: number;
  21482. /** index start */
  21483. indexStart: number;
  21484. /** indices count */
  21485. indexCount: number;
  21486. /** @hidden */
  21487. _linesIndexCount: number;
  21488. private _mesh;
  21489. private _renderingMesh;
  21490. private _boundingInfo;
  21491. private _linesIndexBuffer;
  21492. /** @hidden */
  21493. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21494. /** @hidden */
  21495. _trianglePlanes: Plane[];
  21496. /** @hidden */
  21497. _lastColliderTransformMatrix: Matrix;
  21498. /** @hidden */
  21499. _renderId: number;
  21500. /** @hidden */
  21501. _alphaIndex: number;
  21502. /** @hidden */
  21503. _distanceToCamera: number;
  21504. /** @hidden */
  21505. _id: number;
  21506. private _currentMaterial;
  21507. /**
  21508. * Add a new submesh to a mesh
  21509. * @param materialIndex defines the material index to use
  21510. * @param verticesStart defines vertex index start
  21511. * @param verticesCount defines vertices count
  21512. * @param indexStart defines index start
  21513. * @param indexCount defines indices count
  21514. * @param mesh defines the parent mesh
  21515. * @param renderingMesh defines an optional rendering mesh
  21516. * @param createBoundingBox defines if bounding box should be created for this submesh
  21517. * @returns the new submesh
  21518. */
  21519. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21520. /**
  21521. * Creates a new submesh
  21522. * @param materialIndex defines the material index to use
  21523. * @param verticesStart defines vertex index start
  21524. * @param verticesCount defines vertices count
  21525. * @param indexStart defines index start
  21526. * @param indexCount defines indices count
  21527. * @param mesh defines the parent mesh
  21528. * @param renderingMesh defines an optional rendering mesh
  21529. * @param createBoundingBox defines if bounding box should be created for this submesh
  21530. */
  21531. constructor(
  21532. /** the material index to use */
  21533. materialIndex: number,
  21534. /** vertex index start */
  21535. verticesStart: number,
  21536. /** vertices count */
  21537. verticesCount: number,
  21538. /** index start */
  21539. indexStart: number,
  21540. /** indices count */
  21541. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21542. /**
  21543. * Returns true if this submesh covers the entire parent mesh
  21544. * @ignorenaming
  21545. */
  21546. readonly IsGlobal: boolean;
  21547. /**
  21548. * Returns the submesh BoudingInfo object
  21549. * @returns current bounding info (or mesh's one if the submesh is global)
  21550. */
  21551. getBoundingInfo(): BoundingInfo;
  21552. /**
  21553. * Sets the submesh BoundingInfo
  21554. * @param boundingInfo defines the new bounding info to use
  21555. * @returns the SubMesh
  21556. */
  21557. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21558. /**
  21559. * Returns the mesh of the current submesh
  21560. * @return the parent mesh
  21561. */
  21562. getMesh(): AbstractMesh;
  21563. /**
  21564. * Returns the rendering mesh of the submesh
  21565. * @returns the rendering mesh (could be different from parent mesh)
  21566. */
  21567. getRenderingMesh(): Mesh;
  21568. /**
  21569. * Returns the submesh material
  21570. * @returns null or the current material
  21571. */
  21572. getMaterial(): Nullable<Material>;
  21573. /**
  21574. * Sets a new updated BoundingInfo object to the submesh
  21575. * @returns the SubMesh
  21576. */
  21577. refreshBoundingInfo(): SubMesh;
  21578. /** @hidden */
  21579. _checkCollision(collider: Collider): boolean;
  21580. /**
  21581. * Updates the submesh BoundingInfo
  21582. * @param world defines the world matrix to use to update the bounding info
  21583. * @returns the submesh
  21584. */
  21585. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21586. /**
  21587. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21588. * @param frustumPlanes defines the frustum planes
  21589. * @returns true if the submesh is intersecting with the frustum
  21590. */
  21591. isInFrustum(frustumPlanes: Plane[]): boolean;
  21592. /**
  21593. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21594. * @param frustumPlanes defines the frustum planes
  21595. * @returns true if the submesh is inside the frustum
  21596. */
  21597. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21598. /**
  21599. * Renders the submesh
  21600. * @param enableAlphaMode defines if alpha needs to be used
  21601. * @returns the submesh
  21602. */
  21603. render(enableAlphaMode: boolean): SubMesh;
  21604. /**
  21605. * @hidden
  21606. */
  21607. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  21608. /**
  21609. * Checks if the submesh intersects with a ray
  21610. * @param ray defines the ray to test
  21611. * @returns true is the passed ray intersects the submesh bounding box
  21612. */
  21613. canIntersects(ray: Ray): boolean;
  21614. /**
  21615. * Intersects current submesh with a ray
  21616. * @param ray defines the ray to test
  21617. * @param positions defines mesh's positions array
  21618. * @param indices defines mesh's indices array
  21619. * @param fastCheck defines if only bounding info should be used
  21620. * @returns intersection info or null if no intersection
  21621. */
  21622. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  21623. /** @hidden */
  21624. private _intersectLines;
  21625. /** @hidden */
  21626. private _intersectTriangles;
  21627. /** @hidden */
  21628. _rebuild(): void;
  21629. /**
  21630. * Creates a new submesh from the passed mesh
  21631. * @param newMesh defines the new hosting mesh
  21632. * @param newRenderingMesh defines an optional rendering mesh
  21633. * @returns the new submesh
  21634. */
  21635. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21636. /**
  21637. * Release associated resources
  21638. */
  21639. dispose(): void;
  21640. /**
  21641. * Gets the class name
  21642. * @returns the string "SubMesh".
  21643. */
  21644. getClassName(): string;
  21645. /**
  21646. * Creates a new submesh from indices data
  21647. * @param materialIndex the index of the main mesh material
  21648. * @param startIndex the index where to start the copy in the mesh indices array
  21649. * @param indexCount the number of indices to copy then from the startIndex
  21650. * @param mesh the main mesh to create the submesh from
  21651. * @param renderingMesh the optional rendering mesh
  21652. * @returns a new submesh
  21653. */
  21654. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21655. }
  21656. }
  21657. declare module BABYLON {
  21658. /**
  21659. * Class used to store geometry data (vertex buffers + index buffer)
  21660. */
  21661. export class Geometry implements IGetSetVerticesData {
  21662. /**
  21663. * Gets or sets the ID of the geometry
  21664. */
  21665. id: string;
  21666. /**
  21667. * Gets or sets the unique ID of the geometry
  21668. */
  21669. uniqueId: number;
  21670. /**
  21671. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21672. */
  21673. delayLoadState: number;
  21674. /**
  21675. * Gets the file containing the data to load when running in delay load state
  21676. */
  21677. delayLoadingFile: Nullable<string>;
  21678. /**
  21679. * Callback called when the geometry is updated
  21680. */
  21681. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21682. private _scene;
  21683. private _engine;
  21684. private _meshes;
  21685. private _totalVertices;
  21686. /** @hidden */
  21687. _indices: IndicesArray;
  21688. /** @hidden */
  21689. _vertexBuffers: {
  21690. [key: string]: VertexBuffer;
  21691. };
  21692. private _isDisposed;
  21693. private _extend;
  21694. private _boundingBias;
  21695. /** @hidden */
  21696. _delayInfo: Array<string>;
  21697. private _indexBuffer;
  21698. private _indexBufferIsUpdatable;
  21699. /** @hidden */
  21700. _boundingInfo: Nullable<BoundingInfo>;
  21701. /** @hidden */
  21702. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21703. /** @hidden */
  21704. _softwareSkinningFrameId: number;
  21705. private _vertexArrayObjects;
  21706. private _updatable;
  21707. /** @hidden */
  21708. _positions: Nullable<Vector3[]>;
  21709. /**
  21710. * 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
  21711. */
  21712. /**
  21713. * 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
  21714. */
  21715. boundingBias: Vector2;
  21716. /**
  21717. * Static function used to attach a new empty geometry to a mesh
  21718. * @param mesh defines the mesh to attach the geometry to
  21719. * @returns the new Geometry
  21720. */
  21721. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21722. /**
  21723. * Creates a new geometry
  21724. * @param id defines the unique ID
  21725. * @param scene defines the hosting scene
  21726. * @param vertexData defines the VertexData used to get geometry data
  21727. * @param updatable defines if geometry must be updatable (false by default)
  21728. * @param mesh defines the mesh that will be associated with the geometry
  21729. */
  21730. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21731. /**
  21732. * Gets the current extend of the geometry
  21733. */
  21734. readonly extend: {
  21735. minimum: Vector3;
  21736. maximum: Vector3;
  21737. };
  21738. /**
  21739. * Gets the hosting scene
  21740. * @returns the hosting Scene
  21741. */
  21742. getScene(): Scene;
  21743. /**
  21744. * Gets the hosting engine
  21745. * @returns the hosting Engine
  21746. */
  21747. getEngine(): Engine;
  21748. /**
  21749. * Defines if the geometry is ready to use
  21750. * @returns true if the geometry is ready to be used
  21751. */
  21752. isReady(): boolean;
  21753. /**
  21754. * Gets a value indicating that the geometry should not be serialized
  21755. */
  21756. readonly doNotSerialize: boolean;
  21757. /** @hidden */
  21758. _rebuild(): void;
  21759. /**
  21760. * Affects all geometry data in one call
  21761. * @param vertexData defines the geometry data
  21762. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21763. */
  21764. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21765. /**
  21766. * Set specific vertex data
  21767. * @param kind defines the data kind (Position, normal, etc...)
  21768. * @param data defines the vertex data to use
  21769. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21770. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21771. */
  21772. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21773. /**
  21774. * Removes a specific vertex data
  21775. * @param kind defines the data kind (Position, normal, etc...)
  21776. */
  21777. removeVerticesData(kind: string): void;
  21778. /**
  21779. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21780. * @param buffer defines the vertex buffer to use
  21781. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21782. */
  21783. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21784. /**
  21785. * Update a specific vertex buffer
  21786. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  21787. * It will do nothing if the buffer is not updatable
  21788. * @param kind defines the data kind (Position, normal, etc...)
  21789. * @param data defines the data to use
  21790. * @param offset defines the offset in the target buffer where to store the data
  21791. * @param useBytes set to true if the offset is in bytes
  21792. */
  21793. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21794. /**
  21795. * Update a specific vertex buffer
  21796. * This function will create a new buffer if the current one is not updatable
  21797. * @param kind defines the data kind (Position, normal, etc...)
  21798. * @param data defines the data to use
  21799. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21800. */
  21801. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21802. private _updateBoundingInfo;
  21803. /** @hidden */
  21804. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  21805. /**
  21806. * Gets total number of vertices
  21807. * @returns the total number of vertices
  21808. */
  21809. getTotalVertices(): number;
  21810. /**
  21811. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21812. * @param kind defines the data kind (Position, normal, etc...)
  21813. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21814. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21815. * @returns a float array containing vertex data
  21816. */
  21817. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21818. /**
  21819. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21820. * @param kind defines the data kind (Position, normal, etc...)
  21821. * @returns true if the vertex buffer with the specified kind is updatable
  21822. */
  21823. isVertexBufferUpdatable(kind: string): boolean;
  21824. /**
  21825. * Gets a specific vertex buffer
  21826. * @param kind defines the data kind (Position, normal, etc...)
  21827. * @returns a VertexBuffer
  21828. */
  21829. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21830. /**
  21831. * Returns all vertex buffers
  21832. * @return an object holding all vertex buffers indexed by kind
  21833. */
  21834. getVertexBuffers(): Nullable<{
  21835. [key: string]: VertexBuffer;
  21836. }>;
  21837. /**
  21838. * Gets a boolean indicating if specific vertex buffer is present
  21839. * @param kind defines the data kind (Position, normal, etc...)
  21840. * @returns true if data is present
  21841. */
  21842. isVerticesDataPresent(kind: string): boolean;
  21843. /**
  21844. * Gets a list of all attached data kinds (Position, normal, etc...)
  21845. * @returns a list of string containing all kinds
  21846. */
  21847. getVerticesDataKinds(): string[];
  21848. /**
  21849. * Update index buffer
  21850. * @param indices defines the indices to store in the index buffer
  21851. * @param offset defines the offset in the target buffer where to store the data
  21852. */
  21853. updateIndices(indices: IndicesArray, offset?: number): void;
  21854. /**
  21855. * Creates a new index buffer
  21856. * @param indices defines the indices to store in the index buffer
  21857. * @param totalVertices defines the total number of vertices (could be null)
  21858. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21859. */
  21860. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21861. /**
  21862. * Return the total number of indices
  21863. * @returns the total number of indices
  21864. */
  21865. getTotalIndices(): number;
  21866. /**
  21867. * Gets the index buffer array
  21868. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21869. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21870. * @returns the index buffer array
  21871. */
  21872. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21873. /**
  21874. * Gets the index buffer
  21875. * @return the index buffer
  21876. */
  21877. getIndexBuffer(): Nullable<WebGLBuffer>;
  21878. /** @hidden */
  21879. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21880. /**
  21881. * Release the associated resources for a specific mesh
  21882. * @param mesh defines the source mesh
  21883. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21884. */
  21885. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21886. /**
  21887. * Apply current geometry to a given mesh
  21888. * @param mesh defines the mesh to apply geometry to
  21889. */
  21890. applyToMesh(mesh: Mesh): void;
  21891. private _updateExtend;
  21892. private _applyToMesh;
  21893. private notifyUpdate;
  21894. /**
  21895. * Load the geometry if it was flagged as delay loaded
  21896. * @param scene defines the hosting scene
  21897. * @param onLoaded defines a callback called when the geometry is loaded
  21898. */
  21899. load(scene: Scene, onLoaded?: () => void): void;
  21900. private _queueLoad;
  21901. /**
  21902. * Invert the geometry to move from a right handed system to a left handed one.
  21903. */
  21904. toLeftHanded(): void;
  21905. /** @hidden */
  21906. _resetPointsArrayCache(): void;
  21907. /** @hidden */
  21908. _generatePointsArray(): boolean;
  21909. /**
  21910. * Gets a value indicating if the geometry is disposed
  21911. * @returns true if the geometry was disposed
  21912. */
  21913. isDisposed(): boolean;
  21914. private _disposeVertexArrayObjects;
  21915. /**
  21916. * Free all associated resources
  21917. */
  21918. dispose(): void;
  21919. /**
  21920. * Clone the current geometry into a new geometry
  21921. * @param id defines the unique ID of the new geometry
  21922. * @returns a new geometry object
  21923. */
  21924. copy(id: string): Geometry;
  21925. /**
  21926. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21927. * @return a JSON representation of the current geometry data (without the vertices data)
  21928. */
  21929. serialize(): any;
  21930. private toNumberArray;
  21931. /**
  21932. * Serialize all vertices data into a JSON oject
  21933. * @returns a JSON representation of the current geometry data
  21934. */
  21935. serializeVerticeData(): any;
  21936. /**
  21937. * Extracts a clone of a mesh geometry
  21938. * @param mesh defines the source mesh
  21939. * @param id defines the unique ID of the new geometry object
  21940. * @returns the new geometry object
  21941. */
  21942. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21943. /**
  21944. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21945. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21946. * Be aware Math.random() could cause collisions, but:
  21947. * "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"
  21948. * @returns a string containing a new GUID
  21949. */
  21950. static RandomId(): string;
  21951. /** @hidden */
  21952. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21953. private static _CleanMatricesWeights;
  21954. /**
  21955. * Create a new geometry from persisted data (Using .babylon file format)
  21956. * @param parsedVertexData defines the persisted data
  21957. * @param scene defines the hosting scene
  21958. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21959. * @returns the new geometry object
  21960. */
  21961. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21962. }
  21963. }
  21964. declare module BABYLON {
  21965. /**
  21966. * Define an interface for all classes that will get and set the data on vertices
  21967. */
  21968. export interface IGetSetVerticesData {
  21969. /**
  21970. * Gets a boolean indicating if specific vertex data is present
  21971. * @param kind defines the vertex data kind to use
  21972. * @returns true is data kind is present
  21973. */
  21974. isVerticesDataPresent(kind: string): boolean;
  21975. /**
  21976. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21977. * @param kind defines the data kind (Position, normal, etc...)
  21978. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21979. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21980. * @returns a float array containing vertex data
  21981. */
  21982. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21983. /**
  21984. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21985. * @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.
  21986. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21987. * @returns the indices array or an empty array if the mesh has no geometry
  21988. */
  21989. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21990. /**
  21991. * Set specific vertex data
  21992. * @param kind defines the data kind (Position, normal, etc...)
  21993. * @param data defines the vertex data to use
  21994. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21995. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21996. */
  21997. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21998. /**
  21999. * Update a specific associated vertex buffer
  22000. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22001. * - VertexBuffer.PositionKind
  22002. * - VertexBuffer.UVKind
  22003. * - VertexBuffer.UV2Kind
  22004. * - VertexBuffer.UV3Kind
  22005. * - VertexBuffer.UV4Kind
  22006. * - VertexBuffer.UV5Kind
  22007. * - VertexBuffer.UV6Kind
  22008. * - VertexBuffer.ColorKind
  22009. * - VertexBuffer.MatricesIndicesKind
  22010. * - VertexBuffer.MatricesIndicesExtraKind
  22011. * - VertexBuffer.MatricesWeightsKind
  22012. * - VertexBuffer.MatricesWeightsExtraKind
  22013. * @param data defines the data source
  22014. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22015. * @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)
  22016. */
  22017. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22018. /**
  22019. * Creates a new index buffer
  22020. * @param indices defines the indices to store in the index buffer
  22021. * @param totalVertices defines the total number of vertices (could be null)
  22022. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22023. */
  22024. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22025. }
  22026. /**
  22027. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22028. */
  22029. export class VertexData {
  22030. /**
  22031. * Mesh side orientation : usually the external or front surface
  22032. */
  22033. static readonly FRONTSIDE: number;
  22034. /**
  22035. * Mesh side orientation : usually the internal or back surface
  22036. */
  22037. static readonly BACKSIDE: number;
  22038. /**
  22039. * Mesh side orientation : both internal and external or front and back surfaces
  22040. */
  22041. static readonly DOUBLESIDE: number;
  22042. /**
  22043. * Mesh side orientation : by default, `FRONTSIDE`
  22044. */
  22045. static readonly DEFAULTSIDE: number;
  22046. /**
  22047. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22048. */
  22049. positions: Nullable<FloatArray>;
  22050. /**
  22051. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22052. */
  22053. normals: Nullable<FloatArray>;
  22054. /**
  22055. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22056. */
  22057. tangents: Nullable<FloatArray>;
  22058. /**
  22059. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22060. */
  22061. uvs: Nullable<FloatArray>;
  22062. /**
  22063. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22064. */
  22065. uvs2: Nullable<FloatArray>;
  22066. /**
  22067. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22068. */
  22069. uvs3: Nullable<FloatArray>;
  22070. /**
  22071. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22072. */
  22073. uvs4: Nullable<FloatArray>;
  22074. /**
  22075. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22076. */
  22077. uvs5: Nullable<FloatArray>;
  22078. /**
  22079. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22080. */
  22081. uvs6: Nullable<FloatArray>;
  22082. /**
  22083. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22084. */
  22085. colors: Nullable<FloatArray>;
  22086. /**
  22087. * 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).
  22088. */
  22089. matricesIndices: Nullable<FloatArray>;
  22090. /**
  22091. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22092. */
  22093. matricesWeights: Nullable<FloatArray>;
  22094. /**
  22095. * An array extending the number of possible indices
  22096. */
  22097. matricesIndicesExtra: Nullable<FloatArray>;
  22098. /**
  22099. * An array extending the number of possible weights when the number of indices is extended
  22100. */
  22101. matricesWeightsExtra: Nullable<FloatArray>;
  22102. /**
  22103. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22104. */
  22105. indices: Nullable<IndicesArray>;
  22106. /**
  22107. * Uses the passed data array to set the set the values for the specified kind of data
  22108. * @param data a linear array of floating numbers
  22109. * @param kind the type of data that is being set, eg positions, colors etc
  22110. */
  22111. set(data: FloatArray, kind: string): void;
  22112. /**
  22113. * Associates the vertexData to the passed Mesh.
  22114. * Sets it as updatable or not (default `false`)
  22115. * @param mesh the mesh the vertexData is applied to
  22116. * @param updatable when used and having the value true allows new data to update the vertexData
  22117. * @returns the VertexData
  22118. */
  22119. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22120. /**
  22121. * Associates the vertexData to the passed Geometry.
  22122. * Sets it as updatable or not (default `false`)
  22123. * @param geometry the geometry the vertexData is applied to
  22124. * @param updatable when used and having the value true allows new data to update the vertexData
  22125. * @returns VertexData
  22126. */
  22127. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22128. /**
  22129. * Updates the associated mesh
  22130. * @param mesh the mesh to be updated
  22131. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22132. * @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
  22133. * @returns VertexData
  22134. */
  22135. updateMesh(mesh: Mesh): VertexData;
  22136. /**
  22137. * Updates the associated geometry
  22138. * @param geometry the geometry to be updated
  22139. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22140. * @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
  22141. * @returns VertexData.
  22142. */
  22143. updateGeometry(geometry: Geometry): VertexData;
  22144. private _applyTo;
  22145. private _update;
  22146. /**
  22147. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22148. * @param matrix the transforming matrix
  22149. * @returns the VertexData
  22150. */
  22151. transform(matrix: Matrix): VertexData;
  22152. /**
  22153. * Merges the passed VertexData into the current one
  22154. * @param other the VertexData to be merged into the current one
  22155. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22156. * @returns the modified VertexData
  22157. */
  22158. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22159. private _mergeElement;
  22160. private _validate;
  22161. /**
  22162. * Serializes the VertexData
  22163. * @returns a serialized object
  22164. */
  22165. serialize(): any;
  22166. /**
  22167. * Extracts the vertexData from a mesh
  22168. * @param mesh the mesh from which to extract the VertexData
  22169. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22170. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22171. * @returns the object VertexData associated to the passed mesh
  22172. */
  22173. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22174. /**
  22175. * Extracts the vertexData from the geometry
  22176. * @param geometry the geometry from which to extract the VertexData
  22177. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22178. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22179. * @returns the object VertexData associated to the passed mesh
  22180. */
  22181. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22182. private static _ExtractFrom;
  22183. /**
  22184. * Creates the VertexData for a Ribbon
  22185. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22186. * * pathArray array of paths, each of which an array of successive Vector3
  22187. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22188. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22189. * * 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
  22190. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22191. * * 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)
  22192. * * 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)
  22193. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22194. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22195. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22196. * @returns the VertexData of the ribbon
  22197. */
  22198. static CreateRibbon(options: {
  22199. pathArray: Vector3[][];
  22200. closeArray?: boolean;
  22201. closePath?: boolean;
  22202. offset?: number;
  22203. sideOrientation?: number;
  22204. frontUVs?: Vector4;
  22205. backUVs?: Vector4;
  22206. invertUV?: boolean;
  22207. uvs?: Vector2[];
  22208. colors?: Color4[];
  22209. }): VertexData;
  22210. /**
  22211. * Creates the VertexData for a box
  22212. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22213. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22214. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22215. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22216. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22217. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22218. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22219. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22220. * * 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)
  22221. * * 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)
  22222. * @returns the VertexData of the box
  22223. */
  22224. static CreateBox(options: {
  22225. size?: number;
  22226. width?: number;
  22227. height?: number;
  22228. depth?: number;
  22229. faceUV?: Vector4[];
  22230. faceColors?: Color4[];
  22231. sideOrientation?: number;
  22232. frontUVs?: Vector4;
  22233. backUVs?: Vector4;
  22234. }): VertexData;
  22235. /**
  22236. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22237. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22238. * * segments sets the number of horizontal strips optional, default 32
  22239. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22240. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22241. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22242. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22243. * * 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
  22244. * * 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
  22245. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22246. * * 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)
  22247. * * 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)
  22248. * @returns the VertexData of the ellipsoid
  22249. */
  22250. static CreateSphere(options: {
  22251. segments?: number;
  22252. diameter?: number;
  22253. diameterX?: number;
  22254. diameterY?: number;
  22255. diameterZ?: number;
  22256. arc?: number;
  22257. slice?: number;
  22258. sideOrientation?: number;
  22259. frontUVs?: Vector4;
  22260. backUVs?: Vector4;
  22261. }): VertexData;
  22262. /**
  22263. * Creates the VertexData for a cylinder, cone or prism
  22264. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22265. * * height sets the height (y direction) of the cylinder, optional, default 2
  22266. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22267. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22268. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22269. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22270. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22271. * * 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
  22272. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22273. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22274. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22275. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22276. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22277. * * 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)
  22278. * * 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)
  22279. * @returns the VertexData of the cylinder, cone or prism
  22280. */
  22281. static CreateCylinder(options: {
  22282. height?: number;
  22283. diameterTop?: number;
  22284. diameterBottom?: number;
  22285. diameter?: number;
  22286. tessellation?: number;
  22287. subdivisions?: number;
  22288. arc?: number;
  22289. faceColors?: Color4[];
  22290. faceUV?: Vector4[];
  22291. hasRings?: boolean;
  22292. enclose?: boolean;
  22293. sideOrientation?: number;
  22294. frontUVs?: Vector4;
  22295. backUVs?: Vector4;
  22296. }): VertexData;
  22297. /**
  22298. * Creates the VertexData for a torus
  22299. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22300. * * diameter the diameter of the torus, optional default 1
  22301. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22302. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22303. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22304. * * 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)
  22305. * * 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)
  22306. * @returns the VertexData of the torus
  22307. */
  22308. static CreateTorus(options: {
  22309. diameter?: number;
  22310. thickness?: number;
  22311. tessellation?: number;
  22312. sideOrientation?: number;
  22313. frontUVs?: Vector4;
  22314. backUVs?: Vector4;
  22315. }): VertexData;
  22316. /**
  22317. * Creates the VertexData of the LineSystem
  22318. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22319. * - lines an array of lines, each line being an array of successive Vector3
  22320. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22321. * @returns the VertexData of the LineSystem
  22322. */
  22323. static CreateLineSystem(options: {
  22324. lines: Vector3[][];
  22325. colors?: Nullable<Color4[][]>;
  22326. }): VertexData;
  22327. /**
  22328. * Create the VertexData for a DashedLines
  22329. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22330. * - points an array successive Vector3
  22331. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22332. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22333. * - dashNb the intended total number of dashes, optional, default 200
  22334. * @returns the VertexData for the DashedLines
  22335. */
  22336. static CreateDashedLines(options: {
  22337. points: Vector3[];
  22338. dashSize?: number;
  22339. gapSize?: number;
  22340. dashNb?: number;
  22341. }): VertexData;
  22342. /**
  22343. * Creates the VertexData for a Ground
  22344. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22345. * - width the width (x direction) of the ground, optional, default 1
  22346. * - height the height (z direction) of the ground, optional, default 1
  22347. * - subdivisions the number of subdivisions per side, optional, default 1
  22348. * @returns the VertexData of the Ground
  22349. */
  22350. static CreateGround(options: {
  22351. width?: number;
  22352. height?: number;
  22353. subdivisions?: number;
  22354. subdivisionsX?: number;
  22355. subdivisionsY?: number;
  22356. }): VertexData;
  22357. /**
  22358. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22359. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22360. * * xmin the ground minimum X coordinate, optional, default -1
  22361. * * zmin the ground minimum Z coordinate, optional, default -1
  22362. * * xmax the ground maximum X coordinate, optional, default 1
  22363. * * zmax the ground maximum Z coordinate, optional, default 1
  22364. * * 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}
  22365. * * 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}
  22366. * @returns the VertexData of the TiledGround
  22367. */
  22368. static CreateTiledGround(options: {
  22369. xmin: number;
  22370. zmin: number;
  22371. xmax: number;
  22372. zmax: number;
  22373. subdivisions?: {
  22374. w: number;
  22375. h: number;
  22376. };
  22377. precision?: {
  22378. w: number;
  22379. h: number;
  22380. };
  22381. }): VertexData;
  22382. /**
  22383. * Creates the VertexData of the Ground designed from a heightmap
  22384. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22385. * * width the width (x direction) of the ground
  22386. * * height the height (z direction) of the ground
  22387. * * subdivisions the number of subdivisions per side
  22388. * * minHeight the minimum altitude on the ground, optional, default 0
  22389. * * maxHeight the maximum altitude on the ground, optional default 1
  22390. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22391. * * buffer the array holding the image color data
  22392. * * bufferWidth the width of image
  22393. * * bufferHeight the height of image
  22394. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22395. * @returns the VertexData of the Ground designed from a heightmap
  22396. */
  22397. static CreateGroundFromHeightMap(options: {
  22398. width: number;
  22399. height: number;
  22400. subdivisions: number;
  22401. minHeight: number;
  22402. maxHeight: number;
  22403. colorFilter: Color3;
  22404. buffer: Uint8Array;
  22405. bufferWidth: number;
  22406. bufferHeight: number;
  22407. alphaFilter: number;
  22408. }): VertexData;
  22409. /**
  22410. * Creates the VertexData for a Plane
  22411. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22412. * * size sets the width and height of the plane to the value of size, optional default 1
  22413. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22414. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22415. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22416. * * 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)
  22417. * * 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)
  22418. * @returns the VertexData of the box
  22419. */
  22420. static CreatePlane(options: {
  22421. size?: number;
  22422. width?: number;
  22423. height?: number;
  22424. sideOrientation?: number;
  22425. frontUVs?: Vector4;
  22426. backUVs?: Vector4;
  22427. }): VertexData;
  22428. /**
  22429. * Creates the VertexData of the Disc or regular Polygon
  22430. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22431. * * radius the radius of the disc, optional default 0.5
  22432. * * tessellation the number of polygon sides, optional, default 64
  22433. * * 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
  22434. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22435. * * 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)
  22436. * * 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)
  22437. * @returns the VertexData of the box
  22438. */
  22439. static CreateDisc(options: {
  22440. radius?: number;
  22441. tessellation?: number;
  22442. arc?: number;
  22443. sideOrientation?: number;
  22444. frontUVs?: Vector4;
  22445. backUVs?: Vector4;
  22446. }): VertexData;
  22447. /**
  22448. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22449. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22450. * @param polygon a mesh built from polygonTriangulation.build()
  22451. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22452. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22453. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22454. * @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)
  22455. * @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)
  22456. * @returns the VertexData of the Polygon
  22457. */
  22458. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22459. /**
  22460. * Creates the VertexData of the IcoSphere
  22461. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22462. * * radius the radius of the IcoSphere, optional default 1
  22463. * * radiusX allows stretching in the x direction, optional, default radius
  22464. * * radiusY allows stretching in the y direction, optional, default radius
  22465. * * radiusZ allows stretching in the z direction, optional, default radius
  22466. * * flat when true creates a flat shaded mesh, optional, default true
  22467. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22468. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22469. * * 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)
  22470. * * 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)
  22471. * @returns the VertexData of the IcoSphere
  22472. */
  22473. static CreateIcoSphere(options: {
  22474. radius?: number;
  22475. radiusX?: number;
  22476. radiusY?: number;
  22477. radiusZ?: number;
  22478. flat?: boolean;
  22479. subdivisions?: number;
  22480. sideOrientation?: number;
  22481. frontUVs?: Vector4;
  22482. backUVs?: Vector4;
  22483. }): VertexData;
  22484. /**
  22485. * Creates the VertexData for a Polyhedron
  22486. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22487. * * type provided types are:
  22488. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22489. * * 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)
  22490. * * size the size of the IcoSphere, optional default 1
  22491. * * sizeX allows stretching in the x direction, optional, default size
  22492. * * sizeY allows stretching in the y direction, optional, default size
  22493. * * sizeZ allows stretching in the z direction, optional, default size
  22494. * * 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
  22495. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22496. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22497. * * flat when true creates a flat shaded mesh, optional, default true
  22498. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22499. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22500. * * 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)
  22501. * * 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)
  22502. * @returns the VertexData of the Polyhedron
  22503. */
  22504. static CreatePolyhedron(options: {
  22505. type?: number;
  22506. size?: number;
  22507. sizeX?: number;
  22508. sizeY?: number;
  22509. sizeZ?: number;
  22510. custom?: any;
  22511. faceUV?: Vector4[];
  22512. faceColors?: Color4[];
  22513. flat?: boolean;
  22514. sideOrientation?: number;
  22515. frontUVs?: Vector4;
  22516. backUVs?: Vector4;
  22517. }): VertexData;
  22518. /**
  22519. * Creates the VertexData for a TorusKnot
  22520. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22521. * * radius the radius of the torus knot, optional, default 2
  22522. * * tube the thickness of the tube, optional, default 0.5
  22523. * * radialSegments the number of sides on each tube segments, optional, default 32
  22524. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22525. * * p the number of windings around the z axis, optional, default 2
  22526. * * q the number of windings around the x axis, optional, default 3
  22527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22528. * * 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)
  22529. * * 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)
  22530. * @returns the VertexData of the Torus Knot
  22531. */
  22532. static CreateTorusKnot(options: {
  22533. radius?: number;
  22534. tube?: number;
  22535. radialSegments?: number;
  22536. tubularSegments?: number;
  22537. p?: number;
  22538. q?: number;
  22539. sideOrientation?: number;
  22540. frontUVs?: Vector4;
  22541. backUVs?: Vector4;
  22542. }): VertexData;
  22543. /**
  22544. * Compute normals for given positions and indices
  22545. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22546. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22547. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22548. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22549. * * facetNormals : optional array of facet normals (vector3)
  22550. * * facetPositions : optional array of facet positions (vector3)
  22551. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22552. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22553. * * bInfo : optional bounding info, required for facetPartitioning computation
  22554. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22555. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22556. * * useRightHandedSystem: optional boolean to for right handed system computation
  22557. * * depthSort : optional boolean to enable the facet depth sort computation
  22558. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22559. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22560. */
  22561. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22562. facetNormals?: any;
  22563. facetPositions?: any;
  22564. facetPartitioning?: any;
  22565. ratio?: number;
  22566. bInfo?: any;
  22567. bbSize?: Vector3;
  22568. subDiv?: any;
  22569. useRightHandedSystem?: boolean;
  22570. depthSort?: boolean;
  22571. distanceTo?: Vector3;
  22572. depthSortedFacets?: any;
  22573. }): void;
  22574. /** @hidden */
  22575. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22576. /**
  22577. * Applies VertexData created from the imported parameters to the geometry
  22578. * @param parsedVertexData the parsed data from an imported file
  22579. * @param geometry the geometry to apply the VertexData to
  22580. */
  22581. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22582. }
  22583. }
  22584. declare module BABYLON {
  22585. /**
  22586. * Class containing static functions to help procedurally build meshes
  22587. */
  22588. export class DiscBuilder {
  22589. /**
  22590. * Creates a plane polygonal mesh. By default, this is a disc
  22591. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22592. * * 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
  22593. * * 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
  22594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22595. * * 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
  22596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22597. * @param name defines the name of the mesh
  22598. * @param options defines the options used to create the mesh
  22599. * @param scene defines the hosting scene
  22600. * @returns the plane polygonal mesh
  22601. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22602. */
  22603. static CreateDisc(name: string, options: {
  22604. radius?: number;
  22605. tessellation?: number;
  22606. arc?: number;
  22607. updatable?: boolean;
  22608. sideOrientation?: number;
  22609. frontUVs?: Vector4;
  22610. backUVs?: Vector4;
  22611. }, scene?: Nullable<Scene>): Mesh;
  22612. }
  22613. }
  22614. declare module BABYLON {
  22615. /**
  22616. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  22617. *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.
  22618. * The SPS is also a particle system. It provides some methods to manage the particles.
  22619. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  22620. *
  22621. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  22622. */
  22623. export class SolidParticleSystem implements IDisposable {
  22624. /**
  22625. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  22626. * Example : var p = SPS.particles[i];
  22627. */
  22628. particles: SolidParticle[];
  22629. /**
  22630. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  22631. */
  22632. nbParticles: number;
  22633. /**
  22634. * If the particles must ever face the camera (default false). Useful for planar particles.
  22635. */
  22636. billboard: boolean;
  22637. /**
  22638. * Recompute normals when adding a shape
  22639. */
  22640. recomputeNormals: boolean;
  22641. /**
  22642. * This a counter ofr your own usage. It's not set by any SPS functions.
  22643. */
  22644. counter: number;
  22645. /**
  22646. * The SPS name. This name is also given to the underlying mesh.
  22647. */
  22648. name: string;
  22649. /**
  22650. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  22651. */
  22652. mesh: Mesh;
  22653. /**
  22654. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  22655. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  22656. */
  22657. vars: any;
  22658. /**
  22659. * This array is populated when the SPS is set as 'pickable'.
  22660. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  22661. * Each element of this array is an object `{idx: int, faceId: int}`.
  22662. * `idx` is the picked particle index in the `SPS.particles` array
  22663. * `faceId` is the picked face index counted within this particle.
  22664. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  22665. */
  22666. pickedParticles: {
  22667. idx: number;
  22668. faceId: number;
  22669. }[];
  22670. /**
  22671. * This array is populated when `enableDepthSort` is set to true.
  22672. * Each element of this array is an instance of the class DepthSortedParticle.
  22673. */
  22674. depthSortedParticles: DepthSortedParticle[];
  22675. /**
  22676. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  22677. * @hidden
  22678. */
  22679. _bSphereOnly: boolean;
  22680. /**
  22681. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  22682. * @hidden
  22683. */
  22684. _bSphereRadiusFactor: number;
  22685. private _scene;
  22686. private _positions;
  22687. private _indices;
  22688. private _normals;
  22689. private _colors;
  22690. private _uvs;
  22691. private _indices32;
  22692. private _positions32;
  22693. private _normals32;
  22694. private _fixedNormal32;
  22695. private _colors32;
  22696. private _uvs32;
  22697. private _index;
  22698. private _updatable;
  22699. private _pickable;
  22700. private _isVisibilityBoxLocked;
  22701. private _alwaysVisible;
  22702. private _depthSort;
  22703. private _shapeCounter;
  22704. private _copy;
  22705. private _color;
  22706. private _computeParticleColor;
  22707. private _computeParticleTexture;
  22708. private _computeParticleRotation;
  22709. private _computeParticleVertex;
  22710. private _computeBoundingBox;
  22711. private _depthSortParticles;
  22712. private _camera;
  22713. private _mustUnrotateFixedNormals;
  22714. private _particlesIntersect;
  22715. private _needs32Bits;
  22716. /**
  22717. * Creates a SPS (Solid Particle System) object.
  22718. * @param name (String) is the SPS name, this will be the underlying mesh name.
  22719. * @param scene (Scene) is the scene in which the SPS is added.
  22720. * @param options defines the options of the sps e.g.
  22721. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  22722. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  22723. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  22724. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  22725. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  22726. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  22727. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  22728. */
  22729. constructor(name: string, scene: Scene, options?: {
  22730. updatable?: boolean;
  22731. isPickable?: boolean;
  22732. enableDepthSort?: boolean;
  22733. particleIntersection?: boolean;
  22734. boundingSphereOnly?: boolean;
  22735. bSphereRadiusFactor?: number;
  22736. });
  22737. /**
  22738. * Builds the SPS underlying mesh. Returns a standard Mesh.
  22739. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  22740. * @returns the created mesh
  22741. */
  22742. buildMesh(): Mesh;
  22743. /**
  22744. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  22745. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  22746. * Thus the particles generated from `digest()` have their property `position` set yet.
  22747. * @param mesh ( Mesh ) is the mesh to be digested
  22748. * @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
  22749. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  22750. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  22751. * @returns the current SPS
  22752. */
  22753. digest(mesh: Mesh, options?: {
  22754. facetNb?: number;
  22755. number?: number;
  22756. delta?: number;
  22757. }): SolidParticleSystem;
  22758. private _unrotateFixedNormals;
  22759. private _resetCopy;
  22760. private _meshBuilder;
  22761. private _posToShape;
  22762. private _uvsToShapeUV;
  22763. private _addParticle;
  22764. /**
  22765. * Adds some particles to the SPS from the model shape. Returns the shape id.
  22766. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  22767. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  22768. * @param nb (positive integer) the number of particles to be created from this model
  22769. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  22770. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  22771. * @returns the number of shapes in the system
  22772. */
  22773. addShape(mesh: Mesh, nb: number, options?: {
  22774. positionFunction?: any;
  22775. vertexFunction?: any;
  22776. }): number;
  22777. private _rebuildParticle;
  22778. /**
  22779. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  22780. * @returns the SPS.
  22781. */
  22782. rebuildMesh(): SolidParticleSystem;
  22783. /**
  22784. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  22785. * This method calls `updateParticle()` for each particle of the SPS.
  22786. * For an animated SPS, it is usually called within the render loop.
  22787. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  22788. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  22789. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  22790. * @returns the SPS.
  22791. */
  22792. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  22793. /**
  22794. * Disposes the SPS.
  22795. */
  22796. dispose(): void;
  22797. /**
  22798. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  22799. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22800. * @returns the SPS.
  22801. */
  22802. refreshVisibleSize(): SolidParticleSystem;
  22803. /**
  22804. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  22805. * @param size the size (float) of the visibility box
  22806. * note : this doesn't lock the SPS mesh bounding box.
  22807. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22808. */
  22809. setVisibilityBox(size: number): void;
  22810. /**
  22811. * Gets whether the SPS as always visible or not
  22812. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22813. */
  22814. /**
  22815. * Sets the SPS as always visible or not
  22816. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22817. */
  22818. isAlwaysVisible: boolean;
  22819. /**
  22820. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22821. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22822. */
  22823. /**
  22824. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22825. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22826. */
  22827. isVisibilityBoxLocked: boolean;
  22828. /**
  22829. * Tells to `setParticles()` to compute the particle rotations or not.
  22830. * Default value : true. The SPS is faster when it's set to false.
  22831. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22832. */
  22833. /**
  22834. * Gets if `setParticles()` computes the particle rotations or not.
  22835. * Default value : true. The SPS is faster when it's set to false.
  22836. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22837. */
  22838. computeParticleRotation: boolean;
  22839. /**
  22840. * Tells to `setParticles()` to compute the particle colors or not.
  22841. * Default value : true. The SPS is faster when it's set to false.
  22842. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22843. */
  22844. /**
  22845. * Gets if `setParticles()` computes the particle colors or not.
  22846. * Default value : true. The SPS is faster when it's set to false.
  22847. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22848. */
  22849. computeParticleColor: boolean;
  22850. /**
  22851. * Gets if `setParticles()` computes the particle textures or not.
  22852. * Default value : true. The SPS is faster when it's set to false.
  22853. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  22854. */
  22855. computeParticleTexture: boolean;
  22856. /**
  22857. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  22858. * Default value : false. The SPS is faster when it's set to false.
  22859. * Note : the particle custom vertex positions aren't stored values.
  22860. */
  22861. /**
  22862. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  22863. * Default value : false. The SPS is faster when it's set to false.
  22864. * Note : the particle custom vertex positions aren't stored values.
  22865. */
  22866. computeParticleVertex: boolean;
  22867. /**
  22868. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  22869. */
  22870. /**
  22871. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  22872. */
  22873. computeBoundingBox: boolean;
  22874. /**
  22875. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  22876. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22877. * Default : `true`
  22878. */
  22879. /**
  22880. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  22881. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22882. * Default : `true`
  22883. */
  22884. depthSortParticles: boolean;
  22885. /**
  22886. * This function does nothing. It may be overwritten to set all the particle first values.
  22887. * The SPS doesn't call this function, you may have to call it by your own.
  22888. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22889. */
  22890. initParticles(): void;
  22891. /**
  22892. * This function does nothing. It may be overwritten to recycle a particle.
  22893. * The SPS doesn't call this function, you may have to call it by your own.
  22894. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22895. * @param particle The particle to recycle
  22896. * @returns the recycled particle
  22897. */
  22898. recycleParticle(particle: SolidParticle): SolidParticle;
  22899. /**
  22900. * Updates a particle : this function should be overwritten by the user.
  22901. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  22902. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22903. * @example : just set a particle position or velocity and recycle conditions
  22904. * @param particle The particle to update
  22905. * @returns the updated particle
  22906. */
  22907. updateParticle(particle: SolidParticle): SolidParticle;
  22908. /**
  22909. * Updates a vertex of a particle : it can be overwritten by the user.
  22910. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  22911. * @param particle the current particle
  22912. * @param vertex the current index of the current particle
  22913. * @param pt the index of the current vertex in the particle shape
  22914. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  22915. * @example : just set a vertex particle position
  22916. * @returns the updated vertex
  22917. */
  22918. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  22919. /**
  22920. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  22921. * This does nothing and may be overwritten by the user.
  22922. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22923. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22924. * @param update the boolean update value actually passed to setParticles()
  22925. */
  22926. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22927. /**
  22928. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  22929. * This will be passed three parameters.
  22930. * This does nothing and may be overwritten by the user.
  22931. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22932. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22933. * @param update the boolean update value actually passed to setParticles()
  22934. */
  22935. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22936. }
  22937. }
  22938. declare module BABYLON {
  22939. /**
  22940. * Represents one particle of a solid particle system.
  22941. */
  22942. export class SolidParticle {
  22943. /**
  22944. * particle global index
  22945. */
  22946. idx: number;
  22947. /**
  22948. * The color of the particle
  22949. */
  22950. color: Nullable<Color4>;
  22951. /**
  22952. * The world space position of the particle.
  22953. */
  22954. position: Vector3;
  22955. /**
  22956. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  22957. */
  22958. rotation: Vector3;
  22959. /**
  22960. * The world space rotation quaternion of the particle.
  22961. */
  22962. rotationQuaternion: Nullable<Quaternion>;
  22963. /**
  22964. * The scaling of the particle.
  22965. */
  22966. scaling: Vector3;
  22967. /**
  22968. * The uvs of the particle.
  22969. */
  22970. uvs: Vector4;
  22971. /**
  22972. * The current speed of the particle.
  22973. */
  22974. velocity: Vector3;
  22975. /**
  22976. * The pivot point in the particle local space.
  22977. */
  22978. pivot: Vector3;
  22979. /**
  22980. * Must the particle be translated from its pivot point in its local space ?
  22981. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  22982. * Default : false
  22983. */
  22984. translateFromPivot: boolean;
  22985. /**
  22986. * Is the particle active or not ?
  22987. */
  22988. alive: boolean;
  22989. /**
  22990. * Is the particle visible or not ?
  22991. */
  22992. isVisible: boolean;
  22993. /**
  22994. * Index of this particle in the global "positions" array (Internal use)
  22995. * @hidden
  22996. */
  22997. _pos: number;
  22998. /**
  22999. * @hidden Index of this particle in the global "indices" array (Internal use)
  23000. */
  23001. _ind: number;
  23002. /**
  23003. * @hidden ModelShape of this particle (Internal use)
  23004. */
  23005. _model: ModelShape;
  23006. /**
  23007. * ModelShape id of this particle
  23008. */
  23009. shapeId: number;
  23010. /**
  23011. * Index of the particle in its shape id (Internal use)
  23012. */
  23013. idxInShape: number;
  23014. /**
  23015. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23016. */
  23017. _modelBoundingInfo: BoundingInfo;
  23018. /**
  23019. * @hidden Particle BoundingInfo object (Internal use)
  23020. */
  23021. _boundingInfo: BoundingInfo;
  23022. /**
  23023. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23024. */
  23025. _sps: SolidParticleSystem;
  23026. /**
  23027. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23028. */
  23029. _stillInvisible: boolean;
  23030. /**
  23031. * @hidden Last computed particle rotation matrix
  23032. */
  23033. _rotationMatrix: number[];
  23034. /**
  23035. * Parent particle Id, if any.
  23036. * Default null.
  23037. */
  23038. parentId: Nullable<number>;
  23039. /**
  23040. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23041. * The possible values are :
  23042. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23043. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23044. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23045. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23046. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23047. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23048. * */
  23049. cullingStrategy: number;
  23050. /**
  23051. * @hidden Internal global position in the SPS.
  23052. */
  23053. _globalPosition: Vector3;
  23054. /**
  23055. * Creates a Solid Particle object.
  23056. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23057. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23058. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23059. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23060. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23061. * @param shapeId (integer) is the model shape identifier in the SPS.
  23062. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23063. * @param sps defines the sps it is associated to
  23064. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23065. */
  23066. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23067. /**
  23068. * Legacy support, changed scale to scaling
  23069. */
  23070. /**
  23071. * Legacy support, changed scale to scaling
  23072. */
  23073. scale: Vector3;
  23074. /**
  23075. * Legacy support, changed quaternion to rotationQuaternion
  23076. */
  23077. /**
  23078. * Legacy support, changed quaternion to rotationQuaternion
  23079. */
  23080. quaternion: Nullable<Quaternion>;
  23081. /**
  23082. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23083. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23084. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23085. * @returns true if it intersects
  23086. */
  23087. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23088. /**
  23089. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23090. * A particle is in the frustum if its bounding box intersects the frustum
  23091. * @param frustumPlanes defines the frustum to test
  23092. * @returns true if the particle is in the frustum planes
  23093. */
  23094. isInFrustum(frustumPlanes: Plane[]): boolean;
  23095. /**
  23096. * get the rotation matrix of the particle
  23097. * @hidden
  23098. */
  23099. getRotationMatrix(m: Matrix): void;
  23100. }
  23101. /**
  23102. * Represents the shape of the model used by one particle of a solid particle system.
  23103. * SPS internal tool, don't use it manually.
  23104. */
  23105. export class ModelShape {
  23106. /**
  23107. * The shape id
  23108. * @hidden
  23109. */
  23110. shapeID: number;
  23111. /**
  23112. * flat array of model positions (internal use)
  23113. * @hidden
  23114. */
  23115. _shape: Vector3[];
  23116. /**
  23117. * flat array of model UVs (internal use)
  23118. * @hidden
  23119. */
  23120. _shapeUV: number[];
  23121. /**
  23122. * length of the shape in the model indices array (internal use)
  23123. * @hidden
  23124. */
  23125. _indicesLength: number;
  23126. /**
  23127. * Custom position function (internal use)
  23128. * @hidden
  23129. */
  23130. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23131. /**
  23132. * Custom vertex function (internal use)
  23133. * @hidden
  23134. */
  23135. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23136. /**
  23137. * 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.
  23138. * SPS internal tool, don't use it manually.
  23139. * @hidden
  23140. */
  23141. 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>);
  23142. }
  23143. /**
  23144. * Represents a Depth Sorted Particle in the solid particle system.
  23145. */
  23146. export class DepthSortedParticle {
  23147. /**
  23148. * Index of the particle in the "indices" array
  23149. */
  23150. ind: number;
  23151. /**
  23152. * Length of the particle shape in the "indices" array
  23153. */
  23154. indicesLength: number;
  23155. /**
  23156. * Squared distance from the particle to the camera
  23157. */
  23158. sqDistance: number;
  23159. }
  23160. }
  23161. declare module BABYLON {
  23162. /**
  23163. * Class used to store all common mesh properties
  23164. */
  23165. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23166. /** No occlusion */
  23167. static OCCLUSION_TYPE_NONE: number;
  23168. /** Occlusion set to optimisitic */
  23169. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23170. /** Occlusion set to strict */
  23171. static OCCLUSION_TYPE_STRICT: number;
  23172. /** Use an accurante occlusion algorithm */
  23173. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23174. /** Use a conservative occlusion algorithm */
  23175. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23176. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23177. * Test order :
  23178. * Is the bounding sphere outside the frustum ?
  23179. * If not, are the bounding box vertices outside the frustum ?
  23180. * It not, then the cullable object is in the frustum.
  23181. */
  23182. static readonly CULLINGSTRATEGY_STANDARD: number;
  23183. /** Culling strategy : Bounding Sphere Only.
  23184. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23185. * It's also less accurate than the standard because some not visible objects can still be selected.
  23186. * Test : is the bounding sphere outside the frustum ?
  23187. * If not, then the cullable object is in the frustum.
  23188. */
  23189. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23190. /** Culling strategy : Optimistic Inclusion.
  23191. * This in an inclusion test first, then the standard exclusion test.
  23192. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23193. * 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.
  23194. * Anyway, it's as accurate as the standard strategy.
  23195. * Test :
  23196. * Is the cullable object bounding sphere center in the frustum ?
  23197. * If not, apply the default culling strategy.
  23198. */
  23199. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23200. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23201. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23202. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23203. * 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.
  23204. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23205. * Test :
  23206. * Is the cullable object bounding sphere center in the frustum ?
  23207. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23208. */
  23209. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23210. /**
  23211. * No billboard
  23212. */
  23213. static readonly BILLBOARDMODE_NONE: number;
  23214. /** Billboard on X axis */
  23215. static readonly BILLBOARDMODE_X: number;
  23216. /** Billboard on Y axis */
  23217. static readonly BILLBOARDMODE_Y: number;
  23218. /** Billboard on Z axis */
  23219. static readonly BILLBOARDMODE_Z: number;
  23220. /** Billboard on all axes */
  23221. static readonly BILLBOARDMODE_ALL: number;
  23222. private _facetData;
  23223. /**
  23224. * The culling strategy to use to check whether the mesh must be rendered or not.
  23225. * This value can be changed at any time and will be used on the next render mesh selection.
  23226. * The possible values are :
  23227. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23228. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23229. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23230. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23231. * Please read each static variable documentation to get details about the culling process.
  23232. * */
  23233. cullingStrategy: number;
  23234. /**
  23235. * Gets the number of facets in the mesh
  23236. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23237. */
  23238. readonly facetNb: number;
  23239. /**
  23240. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23242. */
  23243. partitioningSubdivisions: number;
  23244. /**
  23245. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23246. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23247. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23248. */
  23249. partitioningBBoxRatio: number;
  23250. /**
  23251. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23252. * Works only for updatable meshes.
  23253. * Doesn't work with multi-materials
  23254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23255. */
  23256. mustDepthSortFacets: boolean;
  23257. /**
  23258. * The location (Vector3) where the facet depth sort must be computed from.
  23259. * By default, the active camera position.
  23260. * Used only when facet depth sort is enabled
  23261. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23262. */
  23263. facetDepthSortFrom: Vector3;
  23264. /**
  23265. * gets a boolean indicating if facetData is enabled
  23266. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23267. */
  23268. readonly isFacetDataEnabled: boolean;
  23269. /** @hidden */
  23270. _updateNonUniformScalingState(value: boolean): boolean;
  23271. /**
  23272. * An event triggered when this mesh collides with another one
  23273. */
  23274. onCollideObservable: Observable<AbstractMesh>;
  23275. private _onCollideObserver;
  23276. /** Set a function to call when this mesh collides with another one */
  23277. onCollide: () => void;
  23278. /**
  23279. * An event triggered when the collision's position changes
  23280. */
  23281. onCollisionPositionChangeObservable: Observable<Vector3>;
  23282. private _onCollisionPositionChangeObserver;
  23283. /** Set a function to call when the collision's position changes */
  23284. onCollisionPositionChange: () => void;
  23285. /**
  23286. * An event triggered when material is changed
  23287. */
  23288. onMaterialChangedObservable: Observable<AbstractMesh>;
  23289. /**
  23290. * Gets or sets the orientation for POV movement & rotation
  23291. */
  23292. definedFacingForward: boolean;
  23293. /** @hidden */
  23294. _occlusionQuery: Nullable<WebGLQuery>;
  23295. private _visibility;
  23296. /**
  23297. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23298. */
  23299. /**
  23300. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23301. */
  23302. visibility: number;
  23303. /** Gets or sets the alpha index used to sort transparent meshes
  23304. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23305. */
  23306. alphaIndex: number;
  23307. /**
  23308. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23309. */
  23310. isVisible: boolean;
  23311. /**
  23312. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23313. */
  23314. isPickable: boolean;
  23315. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23316. showSubMeshesBoundingBox: boolean;
  23317. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23318. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23319. */
  23320. isBlocker: boolean;
  23321. /**
  23322. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23323. */
  23324. enablePointerMoveEvents: boolean;
  23325. /**
  23326. * Specifies the rendering group id for this mesh (0 by default)
  23327. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23328. */
  23329. renderingGroupId: number;
  23330. private _material;
  23331. /** Gets or sets current material */
  23332. material: Nullable<Material>;
  23333. private _receiveShadows;
  23334. /**
  23335. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23336. * @see http://doc.babylonjs.com/babylon101/shadows
  23337. */
  23338. receiveShadows: boolean;
  23339. /** Defines color to use when rendering outline */
  23340. outlineColor: Color3;
  23341. /** Define width to use when rendering outline */
  23342. outlineWidth: number;
  23343. /** Defines color to use when rendering overlay */
  23344. overlayColor: Color3;
  23345. /** Defines alpha to use when rendering overlay */
  23346. overlayAlpha: number;
  23347. private _hasVertexAlpha;
  23348. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23349. hasVertexAlpha: boolean;
  23350. private _useVertexColors;
  23351. /** 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) */
  23352. useVertexColors: boolean;
  23353. private _computeBonesUsingShaders;
  23354. /**
  23355. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23356. */
  23357. computeBonesUsingShaders: boolean;
  23358. private _numBoneInfluencers;
  23359. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23360. numBoneInfluencers: number;
  23361. private _applyFog;
  23362. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23363. applyFog: boolean;
  23364. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23365. useOctreeForRenderingSelection: boolean;
  23366. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23367. useOctreeForPicking: boolean;
  23368. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23369. useOctreeForCollisions: boolean;
  23370. private _layerMask;
  23371. /**
  23372. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23373. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23374. */
  23375. layerMask: number;
  23376. /**
  23377. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23378. */
  23379. alwaysSelectAsActiveMesh: boolean;
  23380. /**
  23381. * Gets or sets the current action manager
  23382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23383. */
  23384. actionManager: Nullable<AbstractActionManager>;
  23385. private _checkCollisions;
  23386. private _collisionMask;
  23387. private _collisionGroup;
  23388. /**
  23389. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23390. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23391. */
  23392. ellipsoid: Vector3;
  23393. /**
  23394. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23395. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23396. */
  23397. ellipsoidOffset: Vector3;
  23398. private _collider;
  23399. private _oldPositionForCollisions;
  23400. private _diffPositionForCollisions;
  23401. /**
  23402. * Gets or sets a collision mask used to mask collisions (default is -1).
  23403. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23404. */
  23405. collisionMask: number;
  23406. /**
  23407. * Gets or sets the current collision group mask (-1 by default).
  23408. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23409. */
  23410. collisionGroup: number;
  23411. /**
  23412. * Defines edge width used when edgesRenderer is enabled
  23413. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23414. */
  23415. edgesWidth: number;
  23416. /**
  23417. * Defines edge color used when edgesRenderer is enabled
  23418. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23419. */
  23420. edgesColor: Color4;
  23421. /** @hidden */
  23422. _edgesRenderer: Nullable<IEdgesRenderer>;
  23423. /** @hidden */
  23424. _masterMesh: Nullable<AbstractMesh>;
  23425. /** @hidden */
  23426. _boundingInfo: Nullable<BoundingInfo>;
  23427. /** @hidden */
  23428. _renderId: number;
  23429. /**
  23430. * Gets or sets the list of subMeshes
  23431. * @see http://doc.babylonjs.com/how_to/multi_materials
  23432. */
  23433. subMeshes: SubMesh[];
  23434. /** @hidden */
  23435. _intersectionsInProgress: AbstractMesh[];
  23436. /** @hidden */
  23437. _unIndexed: boolean;
  23438. /** @hidden */
  23439. _lightSources: Light[];
  23440. /** @hidden */
  23441. readonly _positions: Nullable<Vector3[]>;
  23442. /** @hidden */
  23443. _waitingActions: any;
  23444. /** @hidden */
  23445. _waitingFreezeWorldMatrix: Nullable<boolean>;
  23446. private _skeleton;
  23447. /** @hidden */
  23448. _bonesTransformMatrices: Nullable<Float32Array>;
  23449. /**
  23450. * Gets or sets a skeleton to apply skining transformations
  23451. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23452. */
  23453. skeleton: Nullable<Skeleton>;
  23454. /**
  23455. * An event triggered when the mesh is rebuilt.
  23456. */
  23457. onRebuildObservable: Observable<AbstractMesh>;
  23458. /**
  23459. * Creates a new AbstractMesh
  23460. * @param name defines the name of the mesh
  23461. * @param scene defines the hosting scene
  23462. */
  23463. constructor(name: string, scene?: Nullable<Scene>);
  23464. /**
  23465. * Returns the string "AbstractMesh"
  23466. * @returns "AbstractMesh"
  23467. */
  23468. getClassName(): string;
  23469. /**
  23470. * Gets a string representation of the current mesh
  23471. * @param fullDetails defines a boolean indicating if full details must be included
  23472. * @returns a string representation of the current mesh
  23473. */
  23474. toString(fullDetails?: boolean): string;
  23475. /** @hidden */
  23476. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  23477. /** @hidden */
  23478. _rebuild(): void;
  23479. /** @hidden */
  23480. _resyncLightSources(): void;
  23481. /** @hidden */
  23482. _resyncLighSource(light: Light): void;
  23483. /** @hidden */
  23484. _unBindEffect(): void;
  23485. /** @hidden */
  23486. _removeLightSource(light: Light): void;
  23487. private _markSubMeshesAsDirty;
  23488. /** @hidden */
  23489. _markSubMeshesAsLightDirty(): void;
  23490. /** @hidden */
  23491. _markSubMeshesAsAttributesDirty(): void;
  23492. /** @hidden */
  23493. _markSubMeshesAsMiscDirty(): void;
  23494. /**
  23495. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  23496. */
  23497. scaling: Vector3;
  23498. /**
  23499. * Returns true if the mesh is blocked. Implemented by child classes
  23500. */
  23501. readonly isBlocked: boolean;
  23502. /**
  23503. * Returns the mesh itself by default. Implemented by child classes
  23504. * @param camera defines the camera to use to pick the right LOD level
  23505. * @returns the currentAbstractMesh
  23506. */
  23507. getLOD(camera: Camera): Nullable<AbstractMesh>;
  23508. /**
  23509. * Returns 0 by default. Implemented by child classes
  23510. * @returns an integer
  23511. */
  23512. getTotalVertices(): number;
  23513. /**
  23514. * Returns a positive integer : the total number of indices in this mesh geometry.
  23515. * @returns the numner of indices or zero if the mesh has no geometry.
  23516. */
  23517. getTotalIndices(): number;
  23518. /**
  23519. * Returns null by default. Implemented by child classes
  23520. * @returns null
  23521. */
  23522. getIndices(): Nullable<IndicesArray>;
  23523. /**
  23524. * Returns the array of the requested vertex data kind. Implemented by child classes
  23525. * @param kind defines the vertex data kind to use
  23526. * @returns null
  23527. */
  23528. getVerticesData(kind: string): Nullable<FloatArray>;
  23529. /**
  23530. * Sets the vertex data of the mesh geometry for the requested `kind`.
  23531. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  23532. * Note that a new underlying VertexBuffer object is created each call.
  23533. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  23534. * @param kind defines vertex data kind:
  23535. * * VertexBuffer.PositionKind
  23536. * * VertexBuffer.UVKind
  23537. * * VertexBuffer.UV2Kind
  23538. * * VertexBuffer.UV3Kind
  23539. * * VertexBuffer.UV4Kind
  23540. * * VertexBuffer.UV5Kind
  23541. * * VertexBuffer.UV6Kind
  23542. * * VertexBuffer.ColorKind
  23543. * * VertexBuffer.MatricesIndicesKind
  23544. * * VertexBuffer.MatricesIndicesExtraKind
  23545. * * VertexBuffer.MatricesWeightsKind
  23546. * * VertexBuffer.MatricesWeightsExtraKind
  23547. * @param data defines the data source
  23548. * @param updatable defines if the data must be flagged as updatable (or static)
  23549. * @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
  23550. * @returns the current mesh
  23551. */
  23552. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23553. /**
  23554. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  23555. * If the mesh has no geometry, it is simply returned as it is.
  23556. * @param kind defines vertex data kind:
  23557. * * VertexBuffer.PositionKind
  23558. * * VertexBuffer.UVKind
  23559. * * VertexBuffer.UV2Kind
  23560. * * VertexBuffer.UV3Kind
  23561. * * VertexBuffer.UV4Kind
  23562. * * VertexBuffer.UV5Kind
  23563. * * VertexBuffer.UV6Kind
  23564. * * VertexBuffer.ColorKind
  23565. * * VertexBuffer.MatricesIndicesKind
  23566. * * VertexBuffer.MatricesIndicesExtraKind
  23567. * * VertexBuffer.MatricesWeightsKind
  23568. * * VertexBuffer.MatricesWeightsExtraKind
  23569. * @param data defines the data source
  23570. * @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
  23571. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  23572. * @returns the current mesh
  23573. */
  23574. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23575. /**
  23576. * Sets the mesh indices,
  23577. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  23578. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  23579. * @param totalVertices Defines the total number of vertices
  23580. * @returns the current mesh
  23581. */
  23582. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  23583. /**
  23584. * Gets a boolean indicating if specific vertex data is present
  23585. * @param kind defines the vertex data kind to use
  23586. * @returns true is data kind is present
  23587. */
  23588. isVerticesDataPresent(kind: string): boolean;
  23589. /**
  23590. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  23591. * @returns a BoundingInfo
  23592. */
  23593. getBoundingInfo(): BoundingInfo;
  23594. /**
  23595. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  23596. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  23597. * @returns the current mesh
  23598. */
  23599. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  23600. /**
  23601. * Overwrite the current bounding info
  23602. * @param boundingInfo defines the new bounding info
  23603. * @returns the current mesh
  23604. */
  23605. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  23606. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  23607. readonly useBones: boolean;
  23608. /** @hidden */
  23609. _preActivate(): void;
  23610. /** @hidden */
  23611. _preActivateForIntermediateRendering(renderId: number): void;
  23612. /** @hidden */
  23613. _activate(renderId: number): void;
  23614. /**
  23615. * Gets the current world matrix
  23616. * @returns a Matrix
  23617. */
  23618. getWorldMatrix(): Matrix;
  23619. /** @hidden */
  23620. _getWorldMatrixDeterminant(): number;
  23621. /**
  23622. * Perform relative position change from the point of view of behind the front of the mesh.
  23623. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23624. * Supports definition of mesh facing forward or backward
  23625. * @param amountRight defines the distance on the right axis
  23626. * @param amountUp defines the distance on the up axis
  23627. * @param amountForward defines the distance on the forward axis
  23628. * @returns the current mesh
  23629. */
  23630. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  23631. /**
  23632. * Calculate relative position change from the point of view of behind the front of the mesh.
  23633. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23634. * Supports definition of mesh facing forward or backward
  23635. * @param amountRight defines the distance on the right axis
  23636. * @param amountUp defines the distance on the up axis
  23637. * @param amountForward defines the distance on the forward axis
  23638. * @returns the new displacement vector
  23639. */
  23640. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  23641. /**
  23642. * Perform relative rotation change from the point of view of behind the front of the mesh.
  23643. * Supports definition of mesh facing forward or backward
  23644. * @param flipBack defines the flip
  23645. * @param twirlClockwise defines the twirl
  23646. * @param tiltRight defines the tilt
  23647. * @returns the current mesh
  23648. */
  23649. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  23650. /**
  23651. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  23652. * Supports definition of mesh facing forward or backward.
  23653. * @param flipBack defines the flip
  23654. * @param twirlClockwise defines the twirl
  23655. * @param tiltRight defines the tilt
  23656. * @returns the new rotation vector
  23657. */
  23658. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  23659. /**
  23660. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  23661. * @param includeDescendants Include bounding info from descendants as well (true by default)
  23662. * @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
  23663. * @returns the new bounding vectors
  23664. */
  23665. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  23666. min: Vector3;
  23667. max: Vector3;
  23668. };
  23669. /**
  23670. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23671. * This means the mesh underlying bounding box and sphere are recomputed.
  23672. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23673. * @returns the current mesh
  23674. */
  23675. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  23676. /** @hidden */
  23677. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  23678. /** @hidden */
  23679. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  23680. /** @hidden */
  23681. _updateBoundingInfo(): AbstractMesh;
  23682. /** @hidden */
  23683. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  23684. /** @hidden */
  23685. protected _afterComputeWorldMatrix(): void;
  23686. /**
  23687. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23688. * A mesh is in the frustum if its bounding box intersects the frustum
  23689. * @param frustumPlanes defines the frustum to test
  23690. * @returns true if the mesh is in the frustum planes
  23691. */
  23692. isInFrustum(frustumPlanes: Plane[]): boolean;
  23693. /**
  23694. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  23695. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  23696. * @param frustumPlanes defines the frustum to test
  23697. * @returns true if the mesh is completely in the frustum planes
  23698. */
  23699. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23700. /**
  23701. * True if the mesh intersects another mesh or a SolidParticle object
  23702. * @param mesh defines a target mesh or SolidParticle to test
  23703. * @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)
  23704. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  23705. * @returns true if there is an intersection
  23706. */
  23707. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  23708. /**
  23709. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  23710. * @param point defines the point to test
  23711. * @returns true if there is an intersection
  23712. */
  23713. intersectsPoint(point: Vector3): boolean;
  23714. /**
  23715. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  23716. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23717. */
  23718. checkCollisions: boolean;
  23719. /**
  23720. * Gets Collider object used to compute collisions (not physics)
  23721. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23722. */
  23723. readonly collider: Collider;
  23724. /**
  23725. * Move the mesh using collision engine
  23726. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23727. * @param displacement defines the requested displacement vector
  23728. * @returns the current mesh
  23729. */
  23730. moveWithCollisions(displacement: Vector3): AbstractMesh;
  23731. private _onCollisionPositionChange;
  23732. /** @hidden */
  23733. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  23734. /** @hidden */
  23735. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  23736. /** @hidden */
  23737. _checkCollision(collider: Collider): AbstractMesh;
  23738. /** @hidden */
  23739. _generatePointsArray(): boolean;
  23740. /**
  23741. * Checks if the passed Ray intersects with the mesh
  23742. * @param ray defines the ray to use
  23743. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  23744. * @returns the picking info
  23745. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  23746. */
  23747. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  23748. /**
  23749. * Clones the current mesh
  23750. * @param name defines the mesh name
  23751. * @param newParent defines the new mesh parent
  23752. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  23753. * @returns the new mesh
  23754. */
  23755. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  23756. /**
  23757. * Disposes all the submeshes of the current meshnp
  23758. * @returns the current mesh
  23759. */
  23760. releaseSubMeshes(): AbstractMesh;
  23761. /**
  23762. * Releases resources associated with this abstract mesh.
  23763. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23764. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23765. */
  23766. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23767. /**
  23768. * Adds the passed mesh as a child to the current mesh
  23769. * @param mesh defines the child mesh
  23770. * @returns the current mesh
  23771. */
  23772. addChild(mesh: AbstractMesh): AbstractMesh;
  23773. /**
  23774. * Removes the passed mesh from the current mesh children list
  23775. * @param mesh defines the child mesh
  23776. * @returns the current mesh
  23777. */
  23778. removeChild(mesh: AbstractMesh): AbstractMesh;
  23779. /** @hidden */
  23780. private _initFacetData;
  23781. /**
  23782. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  23783. * This method can be called within the render loop.
  23784. * 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
  23785. * @returns the current mesh
  23786. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23787. */
  23788. updateFacetData(): AbstractMesh;
  23789. /**
  23790. * Returns the facetLocalNormals array.
  23791. * The normals are expressed in the mesh local spac
  23792. * @returns an array of Vector3
  23793. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23794. */
  23795. getFacetLocalNormals(): Vector3[];
  23796. /**
  23797. * Returns the facetLocalPositions array.
  23798. * The facet positions are expressed in the mesh local space
  23799. * @returns an array of Vector3
  23800. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23801. */
  23802. getFacetLocalPositions(): Vector3[];
  23803. /**
  23804. * Returns the facetLocalPartioning array
  23805. * @returns an array of array of numbers
  23806. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23807. */
  23808. getFacetLocalPartitioning(): number[][];
  23809. /**
  23810. * Returns the i-th facet position in the world system.
  23811. * This method allocates a new Vector3 per call
  23812. * @param i defines the facet index
  23813. * @returns a new Vector3
  23814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23815. */
  23816. getFacetPosition(i: number): Vector3;
  23817. /**
  23818. * Sets the reference Vector3 with the i-th facet position in the world system
  23819. * @param i defines the facet index
  23820. * @param ref defines the target vector
  23821. * @returns the current mesh
  23822. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23823. */
  23824. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  23825. /**
  23826. * Returns the i-th facet normal in the world system.
  23827. * This method allocates a new Vector3 per call
  23828. * @param i defines the facet index
  23829. * @returns a new Vector3
  23830. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23831. */
  23832. getFacetNormal(i: number): Vector3;
  23833. /**
  23834. * Sets the reference Vector3 with the i-th facet normal in the world system
  23835. * @param i defines the facet index
  23836. * @param ref defines the target vector
  23837. * @returns the current mesh
  23838. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23839. */
  23840. getFacetNormalToRef(i: number, ref: Vector3): this;
  23841. /**
  23842. * 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)
  23843. * @param x defines x coordinate
  23844. * @param y defines y coordinate
  23845. * @param z defines z coordinate
  23846. * @returns the array of facet indexes
  23847. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23848. */
  23849. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  23850. /**
  23851. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  23852. * @param projected sets as the (x,y,z) world projection on the facet
  23853. * @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
  23854. * @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
  23855. * @param x defines x coordinate
  23856. * @param y defines y coordinate
  23857. * @param z defines z coordinate
  23858. * @returns the face index if found (or null instead)
  23859. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23860. */
  23861. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23862. /**
  23863. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  23864. * @param projected sets as the (x,y,z) local projection on the facet
  23865. * @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
  23866. * @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
  23867. * @param x defines x coordinate
  23868. * @param y defines y coordinate
  23869. * @param z defines z coordinate
  23870. * @returns the face index if found (or null instead)
  23871. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23872. */
  23873. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23874. /**
  23875. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  23876. * @returns the parameters
  23877. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23878. */
  23879. getFacetDataParameters(): any;
  23880. /**
  23881. * Disables the feature FacetData and frees the related memory
  23882. * @returns the current mesh
  23883. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23884. */
  23885. disableFacetData(): AbstractMesh;
  23886. /**
  23887. * Updates the AbstractMesh indices array
  23888. * @param indices defines the data source
  23889. * @returns the current mesh
  23890. */
  23891. updateIndices(indices: IndicesArray): AbstractMesh;
  23892. /**
  23893. * Creates new normals data for the mesh
  23894. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  23895. * @returns the current mesh
  23896. */
  23897. createNormals(updatable: boolean): AbstractMesh;
  23898. /**
  23899. * Align the mesh with a normal
  23900. * @param normal defines the normal to use
  23901. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  23902. * @returns the current mesh
  23903. */
  23904. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  23905. /** @hidden */
  23906. _checkOcclusionQuery(): boolean;
  23907. }
  23908. }
  23909. declare module BABYLON {
  23910. /**
  23911. * Interface used to define ActionEvent
  23912. */
  23913. export interface IActionEvent {
  23914. /** The mesh or sprite that triggered the action */
  23915. source: any;
  23916. /** The X mouse cursor position at the time of the event */
  23917. pointerX: number;
  23918. /** The Y mouse cursor position at the time of the event */
  23919. pointerY: number;
  23920. /** The mesh that is currently pointed at (can be null) */
  23921. meshUnderPointer: Nullable<AbstractMesh>;
  23922. /** the original (browser) event that triggered the ActionEvent */
  23923. sourceEvent?: any;
  23924. /** additional data for the event */
  23925. additionalData?: any;
  23926. }
  23927. /**
  23928. * ActionEvent is the event being sent when an action is triggered.
  23929. */
  23930. export class ActionEvent implements IActionEvent {
  23931. /** The mesh or sprite that triggered the action */
  23932. source: any;
  23933. /** The X mouse cursor position at the time of the event */
  23934. pointerX: number;
  23935. /** The Y mouse cursor position at the time of the event */
  23936. pointerY: number;
  23937. /** The mesh that is currently pointed at (can be null) */
  23938. meshUnderPointer: Nullable<AbstractMesh>;
  23939. /** the original (browser) event that triggered the ActionEvent */
  23940. sourceEvent?: any;
  23941. /** additional data for the event */
  23942. additionalData?: any;
  23943. /**
  23944. * Creates a new ActionEvent
  23945. * @param source The mesh or sprite that triggered the action
  23946. * @param pointerX The X mouse cursor position at the time of the event
  23947. * @param pointerY The Y mouse cursor position at the time of the event
  23948. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  23949. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  23950. * @param additionalData additional data for the event
  23951. */
  23952. constructor(
  23953. /** The mesh or sprite that triggered the action */
  23954. source: any,
  23955. /** The X mouse cursor position at the time of the event */
  23956. pointerX: number,
  23957. /** The Y mouse cursor position at the time of the event */
  23958. pointerY: number,
  23959. /** The mesh that is currently pointed at (can be null) */
  23960. meshUnderPointer: Nullable<AbstractMesh>,
  23961. /** the original (browser) event that triggered the ActionEvent */
  23962. sourceEvent?: any,
  23963. /** additional data for the event */
  23964. additionalData?: any);
  23965. /**
  23966. * Helper function to auto-create an ActionEvent from a source mesh.
  23967. * @param source The source mesh that triggered the event
  23968. * @param evt The original (browser) event
  23969. * @param additionalData additional data for the event
  23970. * @returns the new ActionEvent
  23971. */
  23972. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  23973. /**
  23974. * Helper function to auto-create an ActionEvent from a source sprite
  23975. * @param source The source sprite that triggered the event
  23976. * @param scene Scene associated with the sprite
  23977. * @param evt The original (browser) event
  23978. * @param additionalData additional data for the event
  23979. * @returns the new ActionEvent
  23980. */
  23981. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  23982. /**
  23983. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  23984. * @param scene the scene where the event occurred
  23985. * @param evt The original (browser) event
  23986. * @returns the new ActionEvent
  23987. */
  23988. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  23989. /**
  23990. * Helper function to auto-create an ActionEvent from a primitive
  23991. * @param prim defines the target primitive
  23992. * @param pointerPos defines the pointer position
  23993. * @param evt The original (browser) event
  23994. * @param additionalData additional data for the event
  23995. * @returns the new ActionEvent
  23996. */
  23997. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  23998. }
  23999. }
  24000. declare module BABYLON {
  24001. /**
  24002. * Abstract class used to decouple action Manager from scene and meshes.
  24003. * Do not instantiate.
  24004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24005. */
  24006. export abstract class AbstractActionManager implements IDisposable {
  24007. /** Gets the list of active triggers */
  24008. static Triggers: {
  24009. [key: string]: number;
  24010. };
  24011. /** Gets the cursor to use when hovering items */
  24012. hoverCursor: string;
  24013. /** Gets the list of actions */
  24014. actions: IAction[];
  24015. /**
  24016. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24017. */
  24018. isRecursive: boolean;
  24019. /**
  24020. * Releases all associated resources
  24021. */
  24022. abstract dispose(): void;
  24023. /**
  24024. * Does this action manager has pointer triggers
  24025. */
  24026. abstract readonly hasPointerTriggers: boolean;
  24027. /**
  24028. * Does this action manager has pick triggers
  24029. */
  24030. abstract readonly hasPickTriggers: boolean;
  24031. /**
  24032. * Process a specific trigger
  24033. * @param trigger defines the trigger to process
  24034. * @param evt defines the event details to be processed
  24035. */
  24036. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24037. /**
  24038. * Does this action manager handles actions of any of the given triggers
  24039. * @param triggers defines the triggers to be tested
  24040. * @return a boolean indicating whether one (or more) of the triggers is handled
  24041. */
  24042. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24043. /**
  24044. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24045. * speed.
  24046. * @param triggerA defines the trigger to be tested
  24047. * @param triggerB defines the trigger to be tested
  24048. * @return a boolean indicating whether one (or more) of the triggers is handled
  24049. */
  24050. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24051. /**
  24052. * Does this action manager handles actions of a given trigger
  24053. * @param trigger defines the trigger to be tested
  24054. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24055. * @return whether the trigger is handled
  24056. */
  24057. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24058. /**
  24059. * Serialize this manager to a JSON object
  24060. * @param name defines the property name to store this manager
  24061. * @returns a JSON representation of this manager
  24062. */
  24063. abstract serialize(name: string): any;
  24064. /**
  24065. * Does exist one action manager with at least one trigger
  24066. **/
  24067. static readonly HasTriggers: boolean;
  24068. /**
  24069. * Does exist one action manager with at least one pick trigger
  24070. **/
  24071. static readonly HasPickTriggers: boolean;
  24072. /**
  24073. * Does exist one action manager that handles actions of a given trigger
  24074. * @param trigger defines the trigger to be tested
  24075. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24076. **/
  24077. static HasSpecificTrigger(trigger: number): boolean;
  24078. }
  24079. }
  24080. declare module BABYLON {
  24081. /**
  24082. * Defines how a node can be built from a string name.
  24083. */
  24084. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24085. /**
  24086. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24087. */
  24088. export class Node implements IBehaviorAware<Node> {
  24089. /** @hidden */
  24090. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24091. private static _NodeConstructors;
  24092. /**
  24093. * Add a new node constructor
  24094. * @param type defines the type name of the node to construct
  24095. * @param constructorFunc defines the constructor function
  24096. */
  24097. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24098. /**
  24099. * Returns a node constructor based on type name
  24100. * @param type defines the type name
  24101. * @param name defines the new node name
  24102. * @param scene defines the hosting scene
  24103. * @param options defines optional options to transmit to constructors
  24104. * @returns the new constructor or null
  24105. */
  24106. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24107. /**
  24108. * Gets or sets the name of the node
  24109. */
  24110. name: string;
  24111. /**
  24112. * Gets or sets the id of the node
  24113. */
  24114. id: string;
  24115. /**
  24116. * Gets or sets the unique id of the node
  24117. */
  24118. uniqueId: number;
  24119. /**
  24120. * Gets or sets a string used to store user defined state for the node
  24121. */
  24122. state: string;
  24123. /**
  24124. * Gets or sets an object used to store user defined information for the node
  24125. */
  24126. metadata: any;
  24127. /**
  24128. * For internal use only. Please do not use.
  24129. */
  24130. reservedDataStore: any;
  24131. /**
  24132. * Gets or sets a boolean used to define if the node must be serialized
  24133. */
  24134. doNotSerialize: boolean;
  24135. /** @hidden */
  24136. _isDisposed: boolean;
  24137. /**
  24138. * Gets a list of Animations associated with the node
  24139. */
  24140. animations: Animation[];
  24141. protected _ranges: {
  24142. [name: string]: Nullable<AnimationRange>;
  24143. };
  24144. /**
  24145. * Callback raised when the node is ready to be used
  24146. */
  24147. onReady: (node: Node) => void;
  24148. private _isEnabled;
  24149. private _isParentEnabled;
  24150. private _isReady;
  24151. /** @hidden */
  24152. _currentRenderId: number;
  24153. private _parentRenderId;
  24154. protected _childRenderId: number;
  24155. /** @hidden */
  24156. _waitingParentId: Nullable<string>;
  24157. /** @hidden */
  24158. _scene: Scene;
  24159. /** @hidden */
  24160. _cache: any;
  24161. private _parentNode;
  24162. private _children;
  24163. /** @hidden */
  24164. _worldMatrix: Matrix;
  24165. /** @hidden */
  24166. _worldMatrixDeterminant: number;
  24167. /** @hidden */
  24168. private _sceneRootNodesIndex;
  24169. /**
  24170. * Gets a boolean indicating if the node has been disposed
  24171. * @returns true if the node was disposed
  24172. */
  24173. isDisposed(): boolean;
  24174. /**
  24175. * Gets or sets the parent of the node
  24176. */
  24177. parent: Nullable<Node>;
  24178. private addToSceneRootNodes;
  24179. private removeFromSceneRootNodes;
  24180. private _animationPropertiesOverride;
  24181. /**
  24182. * Gets or sets the animation properties override
  24183. */
  24184. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24185. /**
  24186. * Gets a string idenfifying the name of the class
  24187. * @returns "Node" string
  24188. */
  24189. getClassName(): string;
  24190. /** @hidden */
  24191. readonly _isNode: boolean;
  24192. /**
  24193. * An event triggered when the mesh is disposed
  24194. */
  24195. onDisposeObservable: Observable<Node>;
  24196. private _onDisposeObserver;
  24197. /**
  24198. * Sets a callback that will be raised when the node will be disposed
  24199. */
  24200. onDispose: () => void;
  24201. /**
  24202. * Creates a new Node
  24203. * @param name the name and id to be given to this node
  24204. * @param scene the scene this node will be added to
  24205. * @param addToRootNodes the node will be added to scene.rootNodes
  24206. */
  24207. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24208. /**
  24209. * Gets the scene of the node
  24210. * @returns a scene
  24211. */
  24212. getScene(): Scene;
  24213. /**
  24214. * Gets the engine of the node
  24215. * @returns a Engine
  24216. */
  24217. getEngine(): Engine;
  24218. private _behaviors;
  24219. /**
  24220. * Attach a behavior to the node
  24221. * @see http://doc.babylonjs.com/features/behaviour
  24222. * @param behavior defines the behavior to attach
  24223. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24224. * @returns the current Node
  24225. */
  24226. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24227. /**
  24228. * Remove an attached behavior
  24229. * @see http://doc.babylonjs.com/features/behaviour
  24230. * @param behavior defines the behavior to attach
  24231. * @returns the current Node
  24232. */
  24233. removeBehavior(behavior: Behavior<Node>): Node;
  24234. /**
  24235. * Gets the list of attached behaviors
  24236. * @see http://doc.babylonjs.com/features/behaviour
  24237. */
  24238. readonly behaviors: Behavior<Node>[];
  24239. /**
  24240. * Gets an attached behavior by name
  24241. * @param name defines the name of the behavior to look for
  24242. * @see http://doc.babylonjs.com/features/behaviour
  24243. * @returns null if behavior was not found else the requested behavior
  24244. */
  24245. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24246. /**
  24247. * Returns the latest update of the World matrix
  24248. * @returns a Matrix
  24249. */
  24250. getWorldMatrix(): Matrix;
  24251. /** @hidden */
  24252. _getWorldMatrixDeterminant(): number;
  24253. /**
  24254. * Returns directly the latest state of the mesh World matrix.
  24255. * A Matrix is returned.
  24256. */
  24257. readonly worldMatrixFromCache: Matrix;
  24258. /** @hidden */
  24259. _initCache(): void;
  24260. /** @hidden */
  24261. updateCache(force?: boolean): void;
  24262. /** @hidden */
  24263. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24264. /** @hidden */
  24265. _updateCache(ignoreParentClass?: boolean): void;
  24266. /** @hidden */
  24267. _isSynchronized(): boolean;
  24268. /** @hidden */
  24269. _markSyncedWithParent(): void;
  24270. /** @hidden */
  24271. isSynchronizedWithParent(): boolean;
  24272. /** @hidden */
  24273. isSynchronized(): boolean;
  24274. /**
  24275. * Is this node ready to be used/rendered
  24276. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24277. * @return true if the node is ready
  24278. */
  24279. isReady(completeCheck?: boolean): boolean;
  24280. /**
  24281. * Is this node enabled?
  24282. * 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
  24283. * @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
  24284. * @return whether this node (and its parent) is enabled
  24285. */
  24286. isEnabled(checkAncestors?: boolean): boolean;
  24287. /** @hidden */
  24288. protected _syncParentEnabledState(): void;
  24289. /**
  24290. * Set the enabled state of this node
  24291. * @param value defines the new enabled state
  24292. */
  24293. setEnabled(value: boolean): void;
  24294. /**
  24295. * Is this node a descendant of the given node?
  24296. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24297. * @param ancestor defines the parent node to inspect
  24298. * @returns a boolean indicating if this node is a descendant of the given node
  24299. */
  24300. isDescendantOf(ancestor: Node): boolean;
  24301. /** @hidden */
  24302. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24303. /**
  24304. * Will return all nodes that have this node as ascendant
  24305. * @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
  24306. * @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
  24307. * @return all children nodes of all types
  24308. */
  24309. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24310. /**
  24311. * Get all child-meshes of this node
  24312. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  24313. * @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
  24314. * @returns an array of AbstractMesh
  24315. */
  24316. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24317. /**
  24318. * Get all direct children of this node
  24319. * @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
  24320. * @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)
  24321. * @returns an array of Node
  24322. */
  24323. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24324. /** @hidden */
  24325. _setReady(state: boolean): void;
  24326. /**
  24327. * Get an animation by name
  24328. * @param name defines the name of the animation to look for
  24329. * @returns null if not found else the requested animation
  24330. */
  24331. getAnimationByName(name: string): Nullable<Animation>;
  24332. /**
  24333. * Creates an animation range for this node
  24334. * @param name defines the name of the range
  24335. * @param from defines the starting key
  24336. * @param to defines the end key
  24337. */
  24338. createAnimationRange(name: string, from: number, to: number): void;
  24339. /**
  24340. * Delete a specific animation range
  24341. * @param name defines the name of the range to delete
  24342. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24343. */
  24344. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24345. /**
  24346. * Get an animation range by name
  24347. * @param name defines the name of the animation range to look for
  24348. * @returns null if not found else the requested animation range
  24349. */
  24350. getAnimationRange(name: string): Nullable<AnimationRange>;
  24351. /**
  24352. * Will start the animation sequence
  24353. * @param name defines the range frames for animation sequence
  24354. * @param loop defines if the animation should loop (false by default)
  24355. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24356. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24357. * @returns the object created for this animation. If range does not exist, it will return null
  24358. */
  24359. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24360. /**
  24361. * Serialize animation ranges into a JSON compatible object
  24362. * @returns serialization object
  24363. */
  24364. serializeAnimationRanges(): any;
  24365. /**
  24366. * Computes the world matrix of the node
  24367. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24368. * @returns the world matrix
  24369. */
  24370. computeWorldMatrix(force?: boolean): Matrix;
  24371. /**
  24372. * Releases resources associated with this node.
  24373. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24374. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24375. */
  24376. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24377. /**
  24378. * Parse animation range data from a serialization object and store them into a given node
  24379. * @param node defines where to store the animation ranges
  24380. * @param parsedNode defines the serialization object to read data from
  24381. * @param scene defines the hosting scene
  24382. */
  24383. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  24384. }
  24385. }
  24386. declare module BABYLON {
  24387. /**
  24388. * Class used to store any kind of animation
  24389. */
  24390. export class Animation {
  24391. /**Name of the animation */
  24392. name: string;
  24393. /**Property to animate */
  24394. targetProperty: string;
  24395. /**The frames per second of the animation */
  24396. framePerSecond: number;
  24397. /**The data type of the animation */
  24398. dataType: number;
  24399. /**The loop mode of the animation */
  24400. loopMode?: number | undefined;
  24401. /**Specifies if blending should be enabled */
  24402. enableBlending?: boolean | undefined;
  24403. /**
  24404. * Use matrix interpolation instead of using direct key value when animating matrices
  24405. */
  24406. static AllowMatricesInterpolation: boolean;
  24407. /**
  24408. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  24409. */
  24410. static AllowMatrixDecomposeForInterpolation: boolean;
  24411. /**
  24412. * Stores the key frames of the animation
  24413. */
  24414. private _keys;
  24415. /**
  24416. * Stores the easing function of the animation
  24417. */
  24418. private _easingFunction;
  24419. /**
  24420. * @hidden Internal use only
  24421. */
  24422. _runtimeAnimations: RuntimeAnimation[];
  24423. /**
  24424. * The set of event that will be linked to this animation
  24425. */
  24426. private _events;
  24427. /**
  24428. * Stores an array of target property paths
  24429. */
  24430. targetPropertyPath: string[];
  24431. /**
  24432. * Stores the blending speed of the animation
  24433. */
  24434. blendingSpeed: number;
  24435. /**
  24436. * Stores the animation ranges for the animation
  24437. */
  24438. private _ranges;
  24439. /**
  24440. * @hidden Internal use
  24441. */
  24442. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  24443. /**
  24444. * Sets up an animation
  24445. * @param property The property to animate
  24446. * @param animationType The animation type to apply
  24447. * @param framePerSecond The frames per second of the animation
  24448. * @param easingFunction The easing function used in the animation
  24449. * @returns The created animation
  24450. */
  24451. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  24452. /**
  24453. * Create and start an animation on a node
  24454. * @param name defines the name of the global animation that will be run on all nodes
  24455. * @param node defines the root node where the animation will take place
  24456. * @param targetProperty defines property to animate
  24457. * @param framePerSecond defines the number of frame per second yo use
  24458. * @param totalFrame defines the number of frames in total
  24459. * @param from defines the initial value
  24460. * @param to defines the final value
  24461. * @param loopMode defines which loop mode you want to use (off by default)
  24462. * @param easingFunction defines the easing function to use (linear by default)
  24463. * @param onAnimationEnd defines the callback to call when animation end
  24464. * @returns the animatable created for this animation
  24465. */
  24466. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24467. /**
  24468. * Create and start an animation on a node and its descendants
  24469. * @param name defines the name of the global animation that will be run on all nodes
  24470. * @param node defines the root node where the animation will take place
  24471. * @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
  24472. * @param targetProperty defines property to animate
  24473. * @param framePerSecond defines the number of frame per second to use
  24474. * @param totalFrame defines the number of frames in total
  24475. * @param from defines the initial value
  24476. * @param to defines the final value
  24477. * @param loopMode defines which loop mode you want to use (off by default)
  24478. * @param easingFunction defines the easing function to use (linear by default)
  24479. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24480. * @returns the list of animatables created for all nodes
  24481. * @example https://www.babylonjs-playground.com/#MH0VLI
  24482. */
  24483. 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[]>;
  24484. /**
  24485. * Creates a new animation, merges it with the existing animations and starts it
  24486. * @param name Name of the animation
  24487. * @param node Node which contains the scene that begins the animations
  24488. * @param targetProperty Specifies which property to animate
  24489. * @param framePerSecond The frames per second of the animation
  24490. * @param totalFrame The total number of frames
  24491. * @param from The frame at the beginning of the animation
  24492. * @param to The frame at the end of the animation
  24493. * @param loopMode Specifies the loop mode of the animation
  24494. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  24495. * @param onAnimationEnd Callback to run once the animation is complete
  24496. * @returns Nullable animation
  24497. */
  24498. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24499. /**
  24500. * Transition property of an host to the target Value
  24501. * @param property The property to transition
  24502. * @param targetValue The target Value of the property
  24503. * @param host The object where the property to animate belongs
  24504. * @param scene Scene used to run the animation
  24505. * @param frameRate Framerate (in frame/s) to use
  24506. * @param transition The transition type we want to use
  24507. * @param duration The duration of the animation, in milliseconds
  24508. * @param onAnimationEnd Callback trigger at the end of the animation
  24509. * @returns Nullable animation
  24510. */
  24511. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  24512. /**
  24513. * Return the array of runtime animations currently using this animation
  24514. */
  24515. readonly runtimeAnimations: RuntimeAnimation[];
  24516. /**
  24517. * Specifies if any of the runtime animations are currently running
  24518. */
  24519. readonly hasRunningRuntimeAnimations: boolean;
  24520. /**
  24521. * Initializes the animation
  24522. * @param name Name of the animation
  24523. * @param targetProperty Property to animate
  24524. * @param framePerSecond The frames per second of the animation
  24525. * @param dataType The data type of the animation
  24526. * @param loopMode The loop mode of the animation
  24527. * @param enableBlending Specifies if blending should be enabled
  24528. */
  24529. constructor(
  24530. /**Name of the animation */
  24531. name: string,
  24532. /**Property to animate */
  24533. targetProperty: string,
  24534. /**The frames per second of the animation */
  24535. framePerSecond: number,
  24536. /**The data type of the animation */
  24537. dataType: number,
  24538. /**The loop mode of the animation */
  24539. loopMode?: number | undefined,
  24540. /**Specifies if blending should be enabled */
  24541. enableBlending?: boolean | undefined);
  24542. /**
  24543. * Converts the animation to a string
  24544. * @param fullDetails support for multiple levels of logging within scene loading
  24545. * @returns String form of the animation
  24546. */
  24547. toString(fullDetails?: boolean): string;
  24548. /**
  24549. * Add an event to this animation
  24550. * @param event Event to add
  24551. */
  24552. addEvent(event: AnimationEvent): void;
  24553. /**
  24554. * Remove all events found at the given frame
  24555. * @param frame The frame to remove events from
  24556. */
  24557. removeEvents(frame: number): void;
  24558. /**
  24559. * Retrieves all the events from the animation
  24560. * @returns Events from the animation
  24561. */
  24562. getEvents(): AnimationEvent[];
  24563. /**
  24564. * Creates an animation range
  24565. * @param name Name of the animation range
  24566. * @param from Starting frame of the animation range
  24567. * @param to Ending frame of the animation
  24568. */
  24569. createRange(name: string, from: number, to: number): void;
  24570. /**
  24571. * Deletes an animation range by name
  24572. * @param name Name of the animation range to delete
  24573. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  24574. */
  24575. deleteRange(name: string, deleteFrames?: boolean): void;
  24576. /**
  24577. * Gets the animation range by name, or null if not defined
  24578. * @param name Name of the animation range
  24579. * @returns Nullable animation range
  24580. */
  24581. getRange(name: string): Nullable<AnimationRange>;
  24582. /**
  24583. * Gets the key frames from the animation
  24584. * @returns The key frames of the animation
  24585. */
  24586. getKeys(): Array<IAnimationKey>;
  24587. /**
  24588. * Gets the highest frame rate of the animation
  24589. * @returns Highest frame rate of the animation
  24590. */
  24591. getHighestFrame(): number;
  24592. /**
  24593. * Gets the easing function of the animation
  24594. * @returns Easing function of the animation
  24595. */
  24596. getEasingFunction(): IEasingFunction;
  24597. /**
  24598. * Sets the easing function of the animation
  24599. * @param easingFunction A custom mathematical formula for animation
  24600. */
  24601. setEasingFunction(easingFunction: EasingFunction): void;
  24602. /**
  24603. * Interpolates a scalar linearly
  24604. * @param startValue Start value of the animation curve
  24605. * @param endValue End value of the animation curve
  24606. * @param gradient Scalar amount to interpolate
  24607. * @returns Interpolated scalar value
  24608. */
  24609. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  24610. /**
  24611. * Interpolates a scalar cubically
  24612. * @param startValue Start value of the animation curve
  24613. * @param outTangent End tangent of the animation
  24614. * @param endValue End value of the animation curve
  24615. * @param inTangent Start tangent of the animation curve
  24616. * @param gradient Scalar amount to interpolate
  24617. * @returns Interpolated scalar value
  24618. */
  24619. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  24620. /**
  24621. * Interpolates a quaternion using a spherical linear interpolation
  24622. * @param startValue Start value of the animation curve
  24623. * @param endValue End value of the animation curve
  24624. * @param gradient Scalar amount to interpolate
  24625. * @returns Interpolated quaternion value
  24626. */
  24627. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  24628. /**
  24629. * Interpolates a quaternion cubically
  24630. * @param startValue Start value of the animation curve
  24631. * @param outTangent End tangent of the animation curve
  24632. * @param endValue End value of the animation curve
  24633. * @param inTangent Start tangent of the animation curve
  24634. * @param gradient Scalar amount to interpolate
  24635. * @returns Interpolated quaternion value
  24636. */
  24637. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  24638. /**
  24639. * Interpolates a Vector3 linearl
  24640. * @param startValue Start value of the animation curve
  24641. * @param endValue End value of the animation curve
  24642. * @param gradient Scalar amount to interpolate
  24643. * @returns Interpolated scalar value
  24644. */
  24645. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  24646. /**
  24647. * Interpolates a Vector3 cubically
  24648. * @param startValue Start value of the animation curve
  24649. * @param outTangent End tangent of the animation
  24650. * @param endValue End value of the animation curve
  24651. * @param inTangent Start tangent of the animation curve
  24652. * @param gradient Scalar amount to interpolate
  24653. * @returns InterpolatedVector3 value
  24654. */
  24655. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  24656. /**
  24657. * Interpolates a Vector2 linearly
  24658. * @param startValue Start value of the animation curve
  24659. * @param endValue End value of the animation curve
  24660. * @param gradient Scalar amount to interpolate
  24661. * @returns Interpolated Vector2 value
  24662. */
  24663. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  24664. /**
  24665. * Interpolates a Vector2 cubically
  24666. * @param startValue Start value of the animation curve
  24667. * @param outTangent End tangent of the animation
  24668. * @param endValue End value of the animation curve
  24669. * @param inTangent Start tangent of the animation curve
  24670. * @param gradient Scalar amount to interpolate
  24671. * @returns Interpolated Vector2 value
  24672. */
  24673. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  24674. /**
  24675. * Interpolates a size linearly
  24676. * @param startValue Start value of the animation curve
  24677. * @param endValue End value of the animation curve
  24678. * @param gradient Scalar amount to interpolate
  24679. * @returns Interpolated Size value
  24680. */
  24681. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  24682. /**
  24683. * Interpolates a Color3 linearly
  24684. * @param startValue Start value of the animation curve
  24685. * @param endValue End value of the animation curve
  24686. * @param gradient Scalar amount to interpolate
  24687. * @returns Interpolated Color3 value
  24688. */
  24689. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  24690. /**
  24691. * @hidden Internal use only
  24692. */
  24693. _getKeyValue(value: any): any;
  24694. /**
  24695. * @hidden Internal use only
  24696. */
  24697. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  24698. /**
  24699. * Defines the function to use to interpolate matrices
  24700. * @param startValue defines the start matrix
  24701. * @param endValue defines the end matrix
  24702. * @param gradient defines the gradient between both matrices
  24703. * @param result defines an optional target matrix where to store the interpolation
  24704. * @returns the interpolated matrix
  24705. */
  24706. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  24707. /**
  24708. * Makes a copy of the animation
  24709. * @returns Cloned animation
  24710. */
  24711. clone(): Animation;
  24712. /**
  24713. * Sets the key frames of the animation
  24714. * @param values The animation key frames to set
  24715. */
  24716. setKeys(values: Array<IAnimationKey>): void;
  24717. /**
  24718. * Serializes the animation to an object
  24719. * @returns Serialized object
  24720. */
  24721. serialize(): any;
  24722. /**
  24723. * Float animation type
  24724. */
  24725. private static _ANIMATIONTYPE_FLOAT;
  24726. /**
  24727. * Vector3 animation type
  24728. */
  24729. private static _ANIMATIONTYPE_VECTOR3;
  24730. /**
  24731. * Quaternion animation type
  24732. */
  24733. private static _ANIMATIONTYPE_QUATERNION;
  24734. /**
  24735. * Matrix animation type
  24736. */
  24737. private static _ANIMATIONTYPE_MATRIX;
  24738. /**
  24739. * Color3 animation type
  24740. */
  24741. private static _ANIMATIONTYPE_COLOR3;
  24742. /**
  24743. * Vector2 animation type
  24744. */
  24745. private static _ANIMATIONTYPE_VECTOR2;
  24746. /**
  24747. * Size animation type
  24748. */
  24749. private static _ANIMATIONTYPE_SIZE;
  24750. /**
  24751. * Relative Loop Mode
  24752. */
  24753. private static _ANIMATIONLOOPMODE_RELATIVE;
  24754. /**
  24755. * Cycle Loop Mode
  24756. */
  24757. private static _ANIMATIONLOOPMODE_CYCLE;
  24758. /**
  24759. * Constant Loop Mode
  24760. */
  24761. private static _ANIMATIONLOOPMODE_CONSTANT;
  24762. /**
  24763. * Get the float animation type
  24764. */
  24765. static readonly ANIMATIONTYPE_FLOAT: number;
  24766. /**
  24767. * Get the Vector3 animation type
  24768. */
  24769. static readonly ANIMATIONTYPE_VECTOR3: number;
  24770. /**
  24771. * Get the Vector2 animation type
  24772. */
  24773. static readonly ANIMATIONTYPE_VECTOR2: number;
  24774. /**
  24775. * Get the Size animation type
  24776. */
  24777. static readonly ANIMATIONTYPE_SIZE: number;
  24778. /**
  24779. * Get the Quaternion animation type
  24780. */
  24781. static readonly ANIMATIONTYPE_QUATERNION: number;
  24782. /**
  24783. * Get the Matrix animation type
  24784. */
  24785. static readonly ANIMATIONTYPE_MATRIX: number;
  24786. /**
  24787. * Get the Color3 animation type
  24788. */
  24789. static readonly ANIMATIONTYPE_COLOR3: number;
  24790. /**
  24791. * Get the Relative Loop Mode
  24792. */
  24793. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  24794. /**
  24795. * Get the Cycle Loop Mode
  24796. */
  24797. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  24798. /**
  24799. * Get the Constant Loop Mode
  24800. */
  24801. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  24802. /** @hidden */
  24803. static _UniversalLerp(left: any, right: any, amount: number): any;
  24804. /**
  24805. * Parses an animation object and creates an animation
  24806. * @param parsedAnimation Parsed animation object
  24807. * @returns Animation object
  24808. */
  24809. static Parse(parsedAnimation: any): Animation;
  24810. /**
  24811. * Appends the serialized animations from the source animations
  24812. * @param source Source containing the animations
  24813. * @param destination Target to store the animations
  24814. */
  24815. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  24816. }
  24817. }
  24818. declare module BABYLON {
  24819. /**
  24820. * Base class of all the textures in babylon.
  24821. * It groups all the common properties the materials, post process, lights... might need
  24822. * in order to make a correct use of the texture.
  24823. */
  24824. export class BaseTexture implements IAnimatable {
  24825. /**
  24826. * Default anisotropic filtering level for the application.
  24827. * It is set to 4 as a good tradeoff between perf and quality.
  24828. */
  24829. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  24830. /**
  24831. * Gets or sets the unique id of the texture
  24832. */
  24833. uniqueId: number;
  24834. /**
  24835. * Define the name of the texture.
  24836. */
  24837. name: string;
  24838. /**
  24839. * Gets or sets an object used to store user defined information.
  24840. */
  24841. metadata: any;
  24842. /**
  24843. * For internal use only. Please do not use.
  24844. */
  24845. reservedDataStore: any;
  24846. private _hasAlpha;
  24847. /**
  24848. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  24849. */
  24850. hasAlpha: boolean;
  24851. /**
  24852. * Defines if the alpha value should be determined via the rgb values.
  24853. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  24854. */
  24855. getAlphaFromRGB: boolean;
  24856. /**
  24857. * Intensity or strength of the texture.
  24858. * It is commonly used by materials to fine tune the intensity of the texture
  24859. */
  24860. level: number;
  24861. /**
  24862. * Define the UV chanel to use starting from 0 and defaulting to 0.
  24863. * This is part of the texture as textures usually maps to one uv set.
  24864. */
  24865. coordinatesIndex: number;
  24866. private _coordinatesMode;
  24867. /**
  24868. * How a texture is mapped.
  24869. *
  24870. * | Value | Type | Description |
  24871. * | ----- | ----------------------------------- | ----------- |
  24872. * | 0 | EXPLICIT_MODE | |
  24873. * | 1 | SPHERICAL_MODE | |
  24874. * | 2 | PLANAR_MODE | |
  24875. * | 3 | CUBIC_MODE | |
  24876. * | 4 | PROJECTION_MODE | |
  24877. * | 5 | SKYBOX_MODE | |
  24878. * | 6 | INVCUBIC_MODE | |
  24879. * | 7 | EQUIRECTANGULAR_MODE | |
  24880. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  24881. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  24882. */
  24883. coordinatesMode: number;
  24884. /**
  24885. * | Value | Type | Description |
  24886. * | ----- | ------------------ | ----------- |
  24887. * | 0 | CLAMP_ADDRESSMODE | |
  24888. * | 1 | WRAP_ADDRESSMODE | |
  24889. * | 2 | MIRROR_ADDRESSMODE | |
  24890. */
  24891. wrapU: number;
  24892. /**
  24893. * | Value | Type | Description |
  24894. * | ----- | ------------------ | ----------- |
  24895. * | 0 | CLAMP_ADDRESSMODE | |
  24896. * | 1 | WRAP_ADDRESSMODE | |
  24897. * | 2 | MIRROR_ADDRESSMODE | |
  24898. */
  24899. wrapV: number;
  24900. /**
  24901. * | Value | Type | Description |
  24902. * | ----- | ------------------ | ----------- |
  24903. * | 0 | CLAMP_ADDRESSMODE | |
  24904. * | 1 | WRAP_ADDRESSMODE | |
  24905. * | 2 | MIRROR_ADDRESSMODE | |
  24906. */
  24907. wrapR: number;
  24908. /**
  24909. * With compliant hardware and browser (supporting anisotropic filtering)
  24910. * this defines the level of anisotropic filtering in the texture.
  24911. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  24912. */
  24913. anisotropicFilteringLevel: number;
  24914. /**
  24915. * Define if the texture is a cube texture or if false a 2d texture.
  24916. */
  24917. isCube: boolean;
  24918. /**
  24919. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  24920. */
  24921. is3D: boolean;
  24922. /**
  24923. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  24924. * HDR texture are usually stored in linear space.
  24925. * This only impacts the PBR and Background materials
  24926. */
  24927. gammaSpace: boolean;
  24928. /**
  24929. * Gets whether or not the texture contains RGBD data.
  24930. */
  24931. readonly isRGBD: boolean;
  24932. /**
  24933. * Is Z inverted in the texture (useful in a cube texture).
  24934. */
  24935. invertZ: boolean;
  24936. /**
  24937. * Are mip maps generated for this texture or not.
  24938. */
  24939. readonly noMipmap: boolean;
  24940. /**
  24941. * @hidden
  24942. */
  24943. lodLevelInAlpha: boolean;
  24944. /**
  24945. * With prefiltered texture, defined the offset used during the prefiltering steps.
  24946. */
  24947. lodGenerationOffset: number;
  24948. /**
  24949. * With prefiltered texture, defined the scale used during the prefiltering steps.
  24950. */
  24951. lodGenerationScale: number;
  24952. /**
  24953. * Define if the texture is a render target.
  24954. */
  24955. isRenderTarget: boolean;
  24956. /**
  24957. * Define the unique id of the texture in the scene.
  24958. */
  24959. readonly uid: string;
  24960. /**
  24961. * Return a string representation of the texture.
  24962. * @returns the texture as a string
  24963. */
  24964. toString(): string;
  24965. /**
  24966. * Get the class name of the texture.
  24967. * @returns "BaseTexture"
  24968. */
  24969. getClassName(): string;
  24970. /**
  24971. * Define the list of animation attached to the texture.
  24972. */
  24973. animations: Animation[];
  24974. /**
  24975. * An event triggered when the texture is disposed.
  24976. */
  24977. onDisposeObservable: Observable<BaseTexture>;
  24978. private _onDisposeObserver;
  24979. /**
  24980. * Callback triggered when the texture has been disposed.
  24981. * Kept for back compatibility, you can use the onDisposeObservable instead.
  24982. */
  24983. onDispose: () => void;
  24984. /**
  24985. * Define the current state of the loading sequence when in delayed load mode.
  24986. */
  24987. delayLoadState: number;
  24988. private _scene;
  24989. /** @hidden */
  24990. _texture: Nullable<InternalTexture>;
  24991. private _uid;
  24992. /**
  24993. * Define if the texture is preventinga material to render or not.
  24994. * If not and the texture is not ready, the engine will use a default black texture instead.
  24995. */
  24996. readonly isBlocking: boolean;
  24997. /**
  24998. * Instantiates a new BaseTexture.
  24999. * Base class of all the textures in babylon.
  25000. * It groups all the common properties the materials, post process, lights... might need
  25001. * in order to make a correct use of the texture.
  25002. * @param scene Define the scene the texture blongs to
  25003. */
  25004. constructor(scene: Nullable<Scene>);
  25005. /**
  25006. * Get the scene the texture belongs to.
  25007. * @returns the scene or null if undefined
  25008. */
  25009. getScene(): Nullable<Scene>;
  25010. /**
  25011. * Get the texture transform matrix used to offset tile the texture for istance.
  25012. * @returns the transformation matrix
  25013. */
  25014. getTextureMatrix(): Matrix;
  25015. /**
  25016. * Get the texture reflection matrix used to rotate/transform the reflection.
  25017. * @returns the reflection matrix
  25018. */
  25019. getReflectionTextureMatrix(): Matrix;
  25020. /**
  25021. * Get the underlying lower level texture from Babylon.
  25022. * @returns the insternal texture
  25023. */
  25024. getInternalTexture(): Nullable<InternalTexture>;
  25025. /**
  25026. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25027. * @returns true if ready or not blocking
  25028. */
  25029. isReadyOrNotBlocking(): boolean;
  25030. /**
  25031. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25032. * @returns true if fully ready
  25033. */
  25034. isReady(): boolean;
  25035. private _cachedSize;
  25036. /**
  25037. * Get the size of the texture.
  25038. * @returns the texture size.
  25039. */
  25040. getSize(): ISize;
  25041. /**
  25042. * Get the base size of the texture.
  25043. * It can be different from the size if the texture has been resized for POT for instance
  25044. * @returns the base size
  25045. */
  25046. getBaseSize(): ISize;
  25047. /**
  25048. * Update the sampling mode of the texture.
  25049. * Default is Trilinear mode.
  25050. *
  25051. * | Value | Type | Description |
  25052. * | ----- | ------------------ | ----------- |
  25053. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25054. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25055. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25056. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25057. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25058. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25059. * | 7 | NEAREST_LINEAR | |
  25060. * | 8 | NEAREST_NEAREST | |
  25061. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25062. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25063. * | 11 | LINEAR_LINEAR | |
  25064. * | 12 | LINEAR_NEAREST | |
  25065. *
  25066. * > _mag_: magnification filter (close to the viewer)
  25067. * > _min_: minification filter (far from the viewer)
  25068. * > _mip_: filter used between mip map levels
  25069. *@param samplingMode Define the new sampling mode of the texture
  25070. */
  25071. updateSamplingMode(samplingMode: number): void;
  25072. /**
  25073. * Scales the texture if is `canRescale()`
  25074. * @param ratio the resize factor we want to use to rescale
  25075. */
  25076. scale(ratio: number): void;
  25077. /**
  25078. * Get if the texture can rescale.
  25079. */
  25080. readonly canRescale: boolean;
  25081. /** @hidden */
  25082. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  25083. /** @hidden */
  25084. _rebuild(): void;
  25085. /**
  25086. * Triggers the load sequence in delayed load mode.
  25087. */
  25088. delayLoad(): void;
  25089. /**
  25090. * Clones the texture.
  25091. * @returns the cloned texture
  25092. */
  25093. clone(): Nullable<BaseTexture>;
  25094. /**
  25095. * Get the texture underlying type (INT, FLOAT...)
  25096. */
  25097. readonly textureType: number;
  25098. /**
  25099. * Get the texture underlying format (RGB, RGBA...)
  25100. */
  25101. readonly textureFormat: number;
  25102. /**
  25103. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25104. * This will returns an RGBA array buffer containing either in values (0-255) or
  25105. * float values (0-1) depending of the underlying buffer type.
  25106. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25107. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25108. * @param buffer defines a user defined buffer to fill with data (can be null)
  25109. * @returns The Array buffer containing the pixels data.
  25110. */
  25111. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25112. /**
  25113. * Release and destroy the underlying lower level texture aka internalTexture.
  25114. */
  25115. releaseInternalTexture(): void;
  25116. /**
  25117. * Get the polynomial representation of the texture data.
  25118. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25119. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25120. */
  25121. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25122. /** @hidden */
  25123. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25124. /** @hidden */
  25125. readonly _lodTextureMid: Nullable<BaseTexture>;
  25126. /** @hidden */
  25127. readonly _lodTextureLow: Nullable<BaseTexture>;
  25128. /**
  25129. * Dispose the texture and release its associated resources.
  25130. */
  25131. dispose(): void;
  25132. /**
  25133. * Serialize the texture into a JSON representation that can be parsed later on.
  25134. * @returns the JSON representation of the texture
  25135. */
  25136. serialize(): any;
  25137. /**
  25138. * Helper function to be called back once a list of texture contains only ready textures.
  25139. * @param textures Define the list of textures to wait for
  25140. * @param callback Define the callback triggered once the entire list will be ready
  25141. */
  25142. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25143. }
  25144. }
  25145. declare module BABYLON {
  25146. /**
  25147. * Uniform buffer objects.
  25148. *
  25149. * Handles blocks of uniform on the GPU.
  25150. *
  25151. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25152. *
  25153. * For more information, please refer to :
  25154. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25155. */
  25156. export class UniformBuffer {
  25157. private _engine;
  25158. private _buffer;
  25159. private _data;
  25160. private _bufferData;
  25161. private _dynamic?;
  25162. private _uniformLocations;
  25163. private _uniformSizes;
  25164. private _uniformLocationPointer;
  25165. private _needSync;
  25166. private _noUBO;
  25167. private _currentEffect;
  25168. private static _MAX_UNIFORM_SIZE;
  25169. private static _tempBuffer;
  25170. /**
  25171. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25172. * This is dynamic to allow compat with webgl 1 and 2.
  25173. * You will need to pass the name of the uniform as well as the value.
  25174. */
  25175. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25176. /**
  25177. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25178. * This is dynamic to allow compat with webgl 1 and 2.
  25179. * You will need to pass the name of the uniform as well as the value.
  25180. */
  25181. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25182. /**
  25183. * Lambda to Update a single float in a uniform buffer.
  25184. * This is dynamic to allow compat with webgl 1 and 2.
  25185. * You will need to pass the name of the uniform as well as the value.
  25186. */
  25187. updateFloat: (name: string, x: number) => void;
  25188. /**
  25189. * Lambda to Update a vec2 of float in a uniform buffer.
  25190. * This is dynamic to allow compat with webgl 1 and 2.
  25191. * You will need to pass the name of the uniform as well as the value.
  25192. */
  25193. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25194. /**
  25195. * Lambda to Update a vec3 of float in a uniform buffer.
  25196. * This is dynamic to allow compat with webgl 1 and 2.
  25197. * You will need to pass the name of the uniform as well as the value.
  25198. */
  25199. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25200. /**
  25201. * Lambda to Update a vec4 of float in a uniform buffer.
  25202. * This is dynamic to allow compat with webgl 1 and 2.
  25203. * You will need to pass the name of the uniform as well as the value.
  25204. */
  25205. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25206. /**
  25207. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25208. * This is dynamic to allow compat with webgl 1 and 2.
  25209. * You will need to pass the name of the uniform as well as the value.
  25210. */
  25211. updateMatrix: (name: string, mat: Matrix) => void;
  25212. /**
  25213. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25214. * This is dynamic to allow compat with webgl 1 and 2.
  25215. * You will need to pass the name of the uniform as well as the value.
  25216. */
  25217. updateVector3: (name: string, vector: Vector3) => void;
  25218. /**
  25219. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25220. * This is dynamic to allow compat with webgl 1 and 2.
  25221. * You will need to pass the name of the uniform as well as the value.
  25222. */
  25223. updateVector4: (name: string, vector: Vector4) => void;
  25224. /**
  25225. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25226. * This is dynamic to allow compat with webgl 1 and 2.
  25227. * You will need to pass the name of the uniform as well as the value.
  25228. */
  25229. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25230. /**
  25231. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25232. * This is dynamic to allow compat with webgl 1 and 2.
  25233. * You will need to pass the name of the uniform as well as the value.
  25234. */
  25235. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25236. /**
  25237. * Instantiates a new Uniform buffer objects.
  25238. *
  25239. * Handles blocks of uniform on the GPU.
  25240. *
  25241. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25242. *
  25243. * For more information, please refer to :
  25244. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25245. * @param engine Define the engine the buffer is associated with
  25246. * @param data Define the data contained in the buffer
  25247. * @param dynamic Define if the buffer is updatable
  25248. */
  25249. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25250. /**
  25251. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25252. * or just falling back on setUniformXXX calls.
  25253. */
  25254. readonly useUbo: boolean;
  25255. /**
  25256. * Indicates if the WebGL underlying uniform buffer is in sync
  25257. * with the javascript cache data.
  25258. */
  25259. readonly isSync: boolean;
  25260. /**
  25261. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25262. * Also, a dynamic UniformBuffer will disable cache verification and always
  25263. * update the underlying WebGL uniform buffer to the GPU.
  25264. * @returns if Dynamic, otherwise false
  25265. */
  25266. isDynamic(): boolean;
  25267. /**
  25268. * The data cache on JS side.
  25269. * @returns the underlying data as a float array
  25270. */
  25271. getData(): Float32Array;
  25272. /**
  25273. * The underlying WebGL Uniform buffer.
  25274. * @returns the webgl buffer
  25275. */
  25276. getBuffer(): Nullable<WebGLBuffer>;
  25277. /**
  25278. * std140 layout specifies how to align data within an UBO structure.
  25279. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25280. * for specs.
  25281. */
  25282. private _fillAlignment;
  25283. /**
  25284. * Adds an uniform in the buffer.
  25285. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25286. * for the layout to be correct !
  25287. * @param name Name of the uniform, as used in the uniform block in the shader.
  25288. * @param size Data size, or data directly.
  25289. */
  25290. addUniform(name: string, size: number | number[]): void;
  25291. /**
  25292. * Adds a Matrix 4x4 to the uniform buffer.
  25293. * @param name Name of the uniform, as used in the uniform block in the shader.
  25294. * @param mat A 4x4 matrix.
  25295. */
  25296. addMatrix(name: string, mat: Matrix): void;
  25297. /**
  25298. * Adds a vec2 to the uniform buffer.
  25299. * @param name Name of the uniform, as used in the uniform block in the shader.
  25300. * @param x Define the x component value of the vec2
  25301. * @param y Define the y component value of the vec2
  25302. */
  25303. addFloat2(name: string, x: number, y: number): void;
  25304. /**
  25305. * Adds a vec3 to the uniform buffer.
  25306. * @param name Name of the uniform, as used in the uniform block in the shader.
  25307. * @param x Define the x component value of the vec3
  25308. * @param y Define the y component value of the vec3
  25309. * @param z Define the z component value of the vec3
  25310. */
  25311. addFloat3(name: string, x: number, y: number, z: number): void;
  25312. /**
  25313. * Adds a vec3 to the uniform buffer.
  25314. * @param name Name of the uniform, as used in the uniform block in the shader.
  25315. * @param color Define the vec3 from a Color
  25316. */
  25317. addColor3(name: string, color: Color3): void;
  25318. /**
  25319. * Adds a vec4 to the uniform buffer.
  25320. * @param name Name of the uniform, as used in the uniform block in the shader.
  25321. * @param color Define the rgb components from a Color
  25322. * @param alpha Define the a component of the vec4
  25323. */
  25324. addColor4(name: string, color: Color3, alpha: number): void;
  25325. /**
  25326. * Adds a vec3 to the uniform buffer.
  25327. * @param name Name of the uniform, as used in the uniform block in the shader.
  25328. * @param vector Define the vec3 components from a Vector
  25329. */
  25330. addVector3(name: string, vector: Vector3): void;
  25331. /**
  25332. * Adds a Matrix 3x3 to the uniform buffer.
  25333. * @param name Name of the uniform, as used in the uniform block in the shader.
  25334. */
  25335. addMatrix3x3(name: string): void;
  25336. /**
  25337. * Adds a Matrix 2x2 to the uniform buffer.
  25338. * @param name Name of the uniform, as used in the uniform block in the shader.
  25339. */
  25340. addMatrix2x2(name: string): void;
  25341. /**
  25342. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25343. */
  25344. create(): void;
  25345. /** @hidden */
  25346. _rebuild(): void;
  25347. /**
  25348. * Updates the WebGL Uniform Buffer on the GPU.
  25349. * If the `dynamic` flag is set to true, no cache comparison is done.
  25350. * Otherwise, the buffer will be updated only if the cache differs.
  25351. */
  25352. update(): void;
  25353. /**
  25354. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25355. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25356. * @param data Define the flattened data
  25357. * @param size Define the size of the data.
  25358. */
  25359. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25360. private _updateMatrix3x3ForUniform;
  25361. private _updateMatrix3x3ForEffect;
  25362. private _updateMatrix2x2ForEffect;
  25363. private _updateMatrix2x2ForUniform;
  25364. private _updateFloatForEffect;
  25365. private _updateFloatForUniform;
  25366. private _updateFloat2ForEffect;
  25367. private _updateFloat2ForUniform;
  25368. private _updateFloat3ForEffect;
  25369. private _updateFloat3ForUniform;
  25370. private _updateFloat4ForEffect;
  25371. private _updateFloat4ForUniform;
  25372. private _updateMatrixForEffect;
  25373. private _updateMatrixForUniform;
  25374. private _updateVector3ForEffect;
  25375. private _updateVector3ForUniform;
  25376. private _updateVector4ForEffect;
  25377. private _updateVector4ForUniform;
  25378. private _updateColor3ForEffect;
  25379. private _updateColor3ForUniform;
  25380. private _updateColor4ForEffect;
  25381. private _updateColor4ForUniform;
  25382. /**
  25383. * Sets a sampler uniform on the effect.
  25384. * @param name Define the name of the sampler.
  25385. * @param texture Define the texture to set in the sampler
  25386. */
  25387. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  25388. /**
  25389. * Directly updates the value of the uniform in the cache AND on the GPU.
  25390. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25391. * @param data Define the flattened data
  25392. */
  25393. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  25394. /**
  25395. * Binds this uniform buffer to an effect.
  25396. * @param effect Define the effect to bind the buffer to
  25397. * @param name Name of the uniform block in the shader.
  25398. */
  25399. bindToEffect(effect: Effect, name: string): void;
  25400. /**
  25401. * Disposes the uniform buffer.
  25402. */
  25403. dispose(): void;
  25404. }
  25405. }
  25406. declare module BABYLON {
  25407. /**
  25408. * This represents the required contract to create a new type of texture loader.
  25409. */
  25410. export interface IInternalTextureLoader {
  25411. /**
  25412. * Defines wether the loader supports cascade loading the different faces.
  25413. */
  25414. supportCascades: boolean;
  25415. /**
  25416. * This returns if the loader support the current file information.
  25417. * @param extension defines the file extension of the file being loaded
  25418. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25419. * @param fallback defines the fallback internal texture if any
  25420. * @param isBase64 defines whether the texture is encoded as a base64
  25421. * @param isBuffer defines whether the texture data are stored as a buffer
  25422. * @returns true if the loader can load the specified file
  25423. */
  25424. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  25425. /**
  25426. * Transform the url before loading if required.
  25427. * @param rootUrl the url of the texture
  25428. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25429. * @returns the transformed texture
  25430. */
  25431. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  25432. /**
  25433. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  25434. * @param rootUrl the url of the texture
  25435. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25436. * @returns the fallback texture
  25437. */
  25438. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  25439. /**
  25440. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  25441. * @param data contains the texture data
  25442. * @param texture defines the BabylonJS internal texture
  25443. * @param createPolynomials will be true if polynomials have been requested
  25444. * @param onLoad defines the callback to trigger once the texture is ready
  25445. * @param onError defines the callback to trigger in case of error
  25446. */
  25447. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  25448. /**
  25449. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  25450. * @param data contains the texture data
  25451. * @param texture defines the BabylonJS internal texture
  25452. * @param callback defines the method to call once ready to upload
  25453. */
  25454. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  25455. }
  25456. }
  25457. declare module BABYLON {
  25458. /**
  25459. * Creation options of the multi render target texture.
  25460. */
  25461. export interface IMultiRenderTargetOptions {
  25462. /**
  25463. * Define if the texture needs to create mip maps after render.
  25464. */
  25465. generateMipMaps?: boolean;
  25466. /**
  25467. * Define the types of all the draw buffers we want to create
  25468. */
  25469. types?: number[];
  25470. /**
  25471. * Define the sampling modes of all the draw buffers we want to create
  25472. */
  25473. samplingModes?: number[];
  25474. /**
  25475. * Define if a depth buffer is required
  25476. */
  25477. generateDepthBuffer?: boolean;
  25478. /**
  25479. * Define if a stencil buffer is required
  25480. */
  25481. generateStencilBuffer?: boolean;
  25482. /**
  25483. * Define if a depth texture is required instead of a depth buffer
  25484. */
  25485. generateDepthTexture?: boolean;
  25486. /**
  25487. * Define the number of desired draw buffers
  25488. */
  25489. textureCount?: number;
  25490. /**
  25491. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25492. */
  25493. doNotChangeAspectRatio?: boolean;
  25494. /**
  25495. * Define the default type of the buffers we are creating
  25496. */
  25497. defaultType?: number;
  25498. }
  25499. /**
  25500. * A multi render target, like a render target provides the ability to render to a texture.
  25501. * Unlike the render target, it can render to several draw buffers in one draw.
  25502. * This is specially interesting in deferred rendering or for any effects requiring more than
  25503. * just one color from a single pass.
  25504. */
  25505. export class MultiRenderTarget extends RenderTargetTexture {
  25506. private _internalTextures;
  25507. private _textures;
  25508. private _multiRenderTargetOptions;
  25509. /**
  25510. * Get if draw buffers are currently supported by the used hardware and browser.
  25511. */
  25512. readonly isSupported: boolean;
  25513. /**
  25514. * Get the list of textures generated by the multi render target.
  25515. */
  25516. readonly textures: Texture[];
  25517. /**
  25518. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25519. */
  25520. readonly depthTexture: Texture;
  25521. /**
  25522. * Set the wrapping mode on U of all the textures we are rendering to.
  25523. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25524. */
  25525. wrapU: number;
  25526. /**
  25527. * Set the wrapping mode on V of all the textures we are rendering to.
  25528. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25529. */
  25530. wrapV: number;
  25531. /**
  25532. * Instantiate a new multi render target texture.
  25533. * A multi render target, like a render target provides the ability to render to a texture.
  25534. * Unlike the render target, it can render to several draw buffers in one draw.
  25535. * This is specially interesting in deferred rendering or for any effects requiring more than
  25536. * just one color from a single pass.
  25537. * @param name Define the name of the texture
  25538. * @param size Define the size of the buffers to render to
  25539. * @param count Define the number of target we are rendering into
  25540. * @param scene Define the scene the texture belongs to
  25541. * @param options Define the options used to create the multi render target
  25542. */
  25543. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25544. /** @hidden */
  25545. _rebuild(): void;
  25546. private _createInternalTextures;
  25547. private _createTextures;
  25548. /**
  25549. * Define the number of samples used if MSAA is enabled.
  25550. */
  25551. samples: number;
  25552. /**
  25553. * Resize all the textures in the multi render target.
  25554. * Be carrefull as it will recreate all the data in the new texture.
  25555. * @param size Define the new size
  25556. */
  25557. resize(size: any): void;
  25558. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25559. /**
  25560. * Dispose the render targets and their associated resources
  25561. */
  25562. dispose(): void;
  25563. /**
  25564. * Release all the underlying texture used as draw buffers.
  25565. */
  25566. releaseInternalTextures(): void;
  25567. }
  25568. }
  25569. declare module BABYLON {
  25570. /**
  25571. * Class used to work with sound analyzer using fast fourier transform (FFT)
  25572. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25573. */
  25574. export class Analyser {
  25575. /**
  25576. * Gets or sets the smoothing
  25577. * @ignorenaming
  25578. */
  25579. SMOOTHING: number;
  25580. /**
  25581. * Gets or sets the FFT table size
  25582. * @ignorenaming
  25583. */
  25584. FFT_SIZE: number;
  25585. /**
  25586. * Gets or sets the bar graph amplitude
  25587. * @ignorenaming
  25588. */
  25589. BARGRAPHAMPLITUDE: number;
  25590. /**
  25591. * Gets or sets the position of the debug canvas
  25592. * @ignorenaming
  25593. */
  25594. DEBUGCANVASPOS: {
  25595. x: number;
  25596. y: number;
  25597. };
  25598. /**
  25599. * Gets or sets the debug canvas size
  25600. * @ignorenaming
  25601. */
  25602. DEBUGCANVASSIZE: {
  25603. width: number;
  25604. height: number;
  25605. };
  25606. private _byteFreqs;
  25607. private _byteTime;
  25608. private _floatFreqs;
  25609. private _webAudioAnalyser;
  25610. private _debugCanvas;
  25611. private _debugCanvasContext;
  25612. private _scene;
  25613. private _registerFunc;
  25614. private _audioEngine;
  25615. /**
  25616. * Creates a new analyser
  25617. * @param scene defines hosting scene
  25618. */
  25619. constructor(scene: Scene);
  25620. /**
  25621. * Get the number of data values you will have to play with for the visualization
  25622. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  25623. * @returns a number
  25624. */
  25625. getFrequencyBinCount(): number;
  25626. /**
  25627. * Gets the current frequency data as a byte array
  25628. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25629. * @returns a Uint8Array
  25630. */
  25631. getByteFrequencyData(): Uint8Array;
  25632. /**
  25633. * Gets the current waveform as a byte array
  25634. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  25635. * @returns a Uint8Array
  25636. */
  25637. getByteTimeDomainData(): Uint8Array;
  25638. /**
  25639. * Gets the current frequency data as a float array
  25640. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25641. * @returns a Float32Array
  25642. */
  25643. getFloatFrequencyData(): Float32Array;
  25644. /**
  25645. * Renders the debug canvas
  25646. */
  25647. drawDebugCanvas(): void;
  25648. /**
  25649. * Stops rendering the debug canvas and removes it
  25650. */
  25651. stopDebugCanvas(): void;
  25652. /**
  25653. * Connects two audio nodes
  25654. * @param inputAudioNode defines first node to connect
  25655. * @param outputAudioNode defines second node to connect
  25656. */
  25657. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  25658. /**
  25659. * Releases all associated resources
  25660. */
  25661. dispose(): void;
  25662. }
  25663. }
  25664. declare module BABYLON {
  25665. /**
  25666. * This represents an audio engine and it is responsible
  25667. * to play, synchronize and analyse sounds throughout the application.
  25668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25669. */
  25670. export interface IAudioEngine extends IDisposable {
  25671. /**
  25672. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25673. */
  25674. readonly canUseWebAudio: boolean;
  25675. /**
  25676. * Gets the current AudioContext if available.
  25677. */
  25678. readonly audioContext: Nullable<AudioContext>;
  25679. /**
  25680. * The master gain node defines the global audio volume of your audio engine.
  25681. */
  25682. readonly masterGain: GainNode;
  25683. /**
  25684. * Gets whether or not mp3 are supported by your browser.
  25685. */
  25686. readonly isMP3supported: boolean;
  25687. /**
  25688. * Gets whether or not ogg are supported by your browser.
  25689. */
  25690. readonly isOGGsupported: boolean;
  25691. /**
  25692. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25693. * @ignoreNaming
  25694. */
  25695. WarnedWebAudioUnsupported: boolean;
  25696. /**
  25697. * Defines if the audio engine relies on a custom unlocked button.
  25698. * In this case, the embedded button will not be displayed.
  25699. */
  25700. useCustomUnlockedButton: boolean;
  25701. /**
  25702. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  25703. */
  25704. readonly unlocked: boolean;
  25705. /**
  25706. * Event raised when audio has been unlocked on the browser.
  25707. */
  25708. onAudioUnlockedObservable: Observable<AudioEngine>;
  25709. /**
  25710. * Event raised when audio has been locked on the browser.
  25711. */
  25712. onAudioLockedObservable: Observable<AudioEngine>;
  25713. /**
  25714. * Flags the audio engine in Locked state.
  25715. * This happens due to new browser policies preventing audio to autoplay.
  25716. */
  25717. lock(): void;
  25718. /**
  25719. * Unlocks the audio engine once a user action has been done on the dom.
  25720. * This is helpful to resume play once browser policies have been satisfied.
  25721. */
  25722. unlock(): void;
  25723. }
  25724. /**
  25725. * This represents the default audio engine used in babylon.
  25726. * It is responsible to play, synchronize and analyse sounds throughout the application.
  25727. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25728. */
  25729. export class AudioEngine implements IAudioEngine {
  25730. private _audioContext;
  25731. private _audioContextInitialized;
  25732. private _muteButton;
  25733. private _hostElement;
  25734. /**
  25735. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25736. */
  25737. canUseWebAudio: boolean;
  25738. /**
  25739. * The master gain node defines the global audio volume of your audio engine.
  25740. */
  25741. masterGain: GainNode;
  25742. /**
  25743. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25744. * @ignoreNaming
  25745. */
  25746. WarnedWebAudioUnsupported: boolean;
  25747. /**
  25748. * Gets whether or not mp3 are supported by your browser.
  25749. */
  25750. isMP3supported: boolean;
  25751. /**
  25752. * Gets whether or not ogg are supported by your browser.
  25753. */
  25754. isOGGsupported: boolean;
  25755. /**
  25756. * Gets whether audio has been unlocked on the device.
  25757. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  25758. * a user interaction has happened.
  25759. */
  25760. unlocked: boolean;
  25761. /**
  25762. * Defines if the audio engine relies on a custom unlocked button.
  25763. * In this case, the embedded button will not be displayed.
  25764. */
  25765. useCustomUnlockedButton: boolean;
  25766. /**
  25767. * Event raised when audio has been unlocked on the browser.
  25768. */
  25769. onAudioUnlockedObservable: Observable<AudioEngine>;
  25770. /**
  25771. * Event raised when audio has been locked on the browser.
  25772. */
  25773. onAudioLockedObservable: Observable<AudioEngine>;
  25774. /**
  25775. * Gets the current AudioContext if available.
  25776. */
  25777. readonly audioContext: Nullable<AudioContext>;
  25778. private _connectedAnalyser;
  25779. /**
  25780. * Instantiates a new audio engine.
  25781. *
  25782. * There should be only one per page as some browsers restrict the number
  25783. * of audio contexts you can create.
  25784. * @param hostElement defines the host element where to display the mute icon if necessary
  25785. */
  25786. constructor(hostElement?: Nullable<HTMLElement>);
  25787. /**
  25788. * Flags the audio engine in Locked state.
  25789. * This happens due to new browser policies preventing audio to autoplay.
  25790. */
  25791. lock(): void;
  25792. /**
  25793. * Unlocks the audio engine once a user action has been done on the dom.
  25794. * This is helpful to resume play once browser policies have been satisfied.
  25795. */
  25796. unlock(): void;
  25797. private _resumeAudioContext;
  25798. private _initializeAudioContext;
  25799. private _tryToRun;
  25800. private _triggerRunningState;
  25801. private _triggerSuspendedState;
  25802. private _displayMuteButton;
  25803. private _moveButtonToTopLeft;
  25804. private _onResize;
  25805. private _hideMuteButton;
  25806. /**
  25807. * Destroy and release the resources associated with the audio ccontext.
  25808. */
  25809. dispose(): void;
  25810. /**
  25811. * Gets the global volume sets on the master gain.
  25812. * @returns the global volume if set or -1 otherwise
  25813. */
  25814. getGlobalVolume(): number;
  25815. /**
  25816. * Sets the global volume of your experience (sets on the master gain).
  25817. * @param newVolume Defines the new global volume of the application
  25818. */
  25819. setGlobalVolume(newVolume: number): void;
  25820. /**
  25821. * Connect the audio engine to an audio analyser allowing some amazing
  25822. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  25823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  25824. * @param analyser The analyser to connect to the engine
  25825. */
  25826. connectToAnalyser(analyser: Analyser): void;
  25827. }
  25828. }
  25829. declare module BABYLON {
  25830. /**
  25831. * Interface used to present a loading screen while loading a scene
  25832. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  25833. */
  25834. export interface ILoadingScreen {
  25835. /**
  25836. * Function called to display the loading screen
  25837. */
  25838. displayLoadingUI: () => void;
  25839. /**
  25840. * Function called to hide the loading screen
  25841. */
  25842. hideLoadingUI: () => void;
  25843. /**
  25844. * Gets or sets the color to use for the background
  25845. */
  25846. loadingUIBackgroundColor: string;
  25847. /**
  25848. * Gets or sets the text to display while loading
  25849. */
  25850. loadingUIText: string;
  25851. }
  25852. /**
  25853. * Class used for the default loading screen
  25854. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  25855. */
  25856. export class DefaultLoadingScreen implements ILoadingScreen {
  25857. private _renderingCanvas;
  25858. private _loadingText;
  25859. private _loadingDivBackgroundColor;
  25860. private _loadingDiv;
  25861. private _loadingTextDiv;
  25862. /**
  25863. * Creates a new default loading screen
  25864. * @param _renderingCanvas defines the canvas used to render the scene
  25865. * @param _loadingText defines the default text to display
  25866. * @param _loadingDivBackgroundColor defines the default background color
  25867. */
  25868. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  25869. /**
  25870. * Function called to display the loading screen
  25871. */
  25872. displayLoadingUI(): void;
  25873. /**
  25874. * Function called to hide the loading screen
  25875. */
  25876. hideLoadingUI(): void;
  25877. /**
  25878. * Gets or sets the text to display while loading
  25879. */
  25880. loadingUIText: string;
  25881. /**
  25882. * Gets or sets the color to use for the background
  25883. */
  25884. loadingUIBackgroundColor: string;
  25885. private _resizeLoadingUI;
  25886. }
  25887. }
  25888. declare module BABYLON {
  25889. /**
  25890. * Settings for finer control over video usage
  25891. */
  25892. export interface VideoTextureSettings {
  25893. /**
  25894. * Applies `autoplay` to video, if specified
  25895. */
  25896. autoPlay?: boolean;
  25897. /**
  25898. * Applies `loop` to video, if specified
  25899. */
  25900. loop?: boolean;
  25901. /**
  25902. * Automatically updates internal texture from video at every frame in the render loop
  25903. */
  25904. autoUpdateTexture: boolean;
  25905. /**
  25906. * Image src displayed during the video loading or until the user interacts with the video.
  25907. */
  25908. poster?: string;
  25909. }
  25910. /**
  25911. * If you want to display a video in your scene, this is the special texture for that.
  25912. * This special texture works similar to other textures, with the exception of a few parameters.
  25913. * @see https://doc.babylonjs.com/how_to/video_texture
  25914. */
  25915. export class VideoTexture extends Texture {
  25916. /**
  25917. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  25918. */
  25919. readonly autoUpdateTexture: boolean;
  25920. /**
  25921. * The video instance used by the texture internally
  25922. */
  25923. readonly video: HTMLVideoElement;
  25924. private _onUserActionRequestedObservable;
  25925. /**
  25926. * Event triggerd when a dom action is required by the user to play the video.
  25927. * This happens due to recent changes in browser policies preventing video to auto start.
  25928. */
  25929. readonly onUserActionRequestedObservable: Observable<Texture>;
  25930. private _generateMipMaps;
  25931. private _engine;
  25932. private _stillImageCaptured;
  25933. private _displayingPosterTexture;
  25934. private _settings;
  25935. private _createInternalTextureOnEvent;
  25936. /**
  25937. * Creates a video texture.
  25938. * If you want to display a video in your scene, this is the special texture for that.
  25939. * This special texture works similar to other textures, with the exception of a few parameters.
  25940. * @see https://doc.babylonjs.com/how_to/video_texture
  25941. * @param name optional name, will detect from video source, if not defined
  25942. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  25943. * @param scene is obviously the current scene.
  25944. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  25945. * @param invertY is false by default but can be used to invert video on Y axis
  25946. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  25947. * @param settings allows finer control over video usage
  25948. */
  25949. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  25950. private _getName;
  25951. private _getVideo;
  25952. private _createInternalTexture;
  25953. private reset;
  25954. /**
  25955. * @hidden Internal method to initiate `update`.
  25956. */
  25957. _rebuild(): void;
  25958. /**
  25959. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  25960. */
  25961. update(): void;
  25962. /**
  25963. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  25964. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  25965. */
  25966. updateTexture(isVisible: boolean): void;
  25967. protected _updateInternalTexture: () => void;
  25968. /**
  25969. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  25970. * @param url New url.
  25971. */
  25972. updateURL(url: string): void;
  25973. /**
  25974. * Dispose the texture and release its associated resources.
  25975. */
  25976. dispose(): void;
  25977. /**
  25978. * Creates a video texture straight from a stream.
  25979. * @param scene Define the scene the texture should be created in
  25980. * @param stream Define the stream the texture should be created from
  25981. * @returns The created video texture as a promise
  25982. */
  25983. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  25984. /**
  25985. * Creates a video texture straight from your WebCam video feed.
  25986. * @param scene Define the scene the texture should be created in
  25987. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  25988. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  25989. * @returns The created video texture as a promise
  25990. */
  25991. static CreateFromWebCamAsync(scene: Scene, constraints: {
  25992. minWidth: number;
  25993. maxWidth: number;
  25994. minHeight: number;
  25995. maxHeight: number;
  25996. deviceId: string;
  25997. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  25998. /**
  25999. * Creates a video texture straight from your WebCam video feed.
  26000. * @param scene Define the scene the texture should be created in
  26001. * @param onReady Define a callback to triggered once the texture will be ready
  26002. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26003. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26004. */
  26005. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26006. minWidth: number;
  26007. maxWidth: number;
  26008. minHeight: number;
  26009. maxHeight: number;
  26010. deviceId: string;
  26011. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26012. }
  26013. }
  26014. declare module BABYLON {
  26015. /**
  26016. * Interface for attribute information associated with buffer instanciation
  26017. */
  26018. export class InstancingAttributeInfo {
  26019. /**
  26020. * Index/offset of the attribute in the vertex shader
  26021. */
  26022. index: number;
  26023. /**
  26024. * size of the attribute, 1, 2, 3 or 4
  26025. */
  26026. attributeSize: number;
  26027. /**
  26028. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26029. * default is FLOAT
  26030. */
  26031. attribyteType: number;
  26032. /**
  26033. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26034. */
  26035. normalized: boolean;
  26036. /**
  26037. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26038. */
  26039. offset: number;
  26040. /**
  26041. * Name of the GLSL attribute, for debugging purpose only
  26042. */
  26043. attributeName: string;
  26044. }
  26045. /**
  26046. * Define options used to create a depth texture
  26047. */
  26048. export class DepthTextureCreationOptions {
  26049. /** Specifies whether or not a stencil should be allocated in the texture */
  26050. generateStencil?: boolean;
  26051. /** Specifies whether or not bilinear filtering is enable on the texture */
  26052. bilinearFiltering?: boolean;
  26053. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26054. comparisonFunction?: number;
  26055. /** Specifies if the created texture is a cube texture */
  26056. isCube?: boolean;
  26057. }
  26058. /**
  26059. * Class used to describe the capabilities of the engine relatively to the current browser
  26060. */
  26061. export class EngineCapabilities {
  26062. /** Maximum textures units per fragment shader */
  26063. maxTexturesImageUnits: number;
  26064. /** Maximum texture units per vertex shader */
  26065. maxVertexTextureImageUnits: number;
  26066. /** Maximum textures units in the entire pipeline */
  26067. maxCombinedTexturesImageUnits: number;
  26068. /** Maximum texture size */
  26069. maxTextureSize: number;
  26070. /** Maximum cube texture size */
  26071. maxCubemapTextureSize: number;
  26072. /** Maximum render texture size */
  26073. maxRenderTextureSize: number;
  26074. /** Maximum number of vertex attributes */
  26075. maxVertexAttribs: number;
  26076. /** Maximum number of varyings */
  26077. maxVaryingVectors: number;
  26078. /** Maximum number of uniforms per vertex shader */
  26079. maxVertexUniformVectors: number;
  26080. /** Maximum number of uniforms per fragment shader */
  26081. maxFragmentUniformVectors: number;
  26082. /** Defines if standard derivates (dx/dy) are supported */
  26083. standardDerivatives: boolean;
  26084. /** Defines if s3tc texture compression is supported */
  26085. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26086. /** Defines if pvrtc texture compression is supported */
  26087. pvrtc: any;
  26088. /** Defines if etc1 texture compression is supported */
  26089. etc1: any;
  26090. /** Defines if etc2 texture compression is supported */
  26091. etc2: any;
  26092. /** Defines if astc texture compression is supported */
  26093. astc: any;
  26094. /** Defines if float textures are supported */
  26095. textureFloat: boolean;
  26096. /** Defines if vertex array objects are supported */
  26097. vertexArrayObject: boolean;
  26098. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26099. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26100. /** Gets the maximum level of anisotropy supported */
  26101. maxAnisotropy: number;
  26102. /** Defines if instancing is supported */
  26103. instancedArrays: boolean;
  26104. /** Defines if 32 bits indices are supported */
  26105. uintIndices: boolean;
  26106. /** Defines if high precision shaders are supported */
  26107. highPrecisionShaderSupported: boolean;
  26108. /** Defines if depth reading in the fragment shader is supported */
  26109. fragmentDepthSupported: boolean;
  26110. /** Defines if float texture linear filtering is supported*/
  26111. textureFloatLinearFiltering: boolean;
  26112. /** Defines if rendering to float textures is supported */
  26113. textureFloatRender: boolean;
  26114. /** Defines if half float textures are supported*/
  26115. textureHalfFloat: boolean;
  26116. /** Defines if half float texture linear filtering is supported*/
  26117. textureHalfFloatLinearFiltering: boolean;
  26118. /** Defines if rendering to half float textures is supported */
  26119. textureHalfFloatRender: boolean;
  26120. /** Defines if textureLOD shader command is supported */
  26121. textureLOD: boolean;
  26122. /** Defines if draw buffers extension is supported */
  26123. drawBuffersExtension: boolean;
  26124. /** Defines if depth textures are supported */
  26125. depthTextureExtension: boolean;
  26126. /** Defines if float color buffer are supported */
  26127. colorBufferFloat: boolean;
  26128. /** Gets disjoint timer query extension (null if not supported) */
  26129. timerQuery: EXT_disjoint_timer_query;
  26130. /** Defines if timestamp can be used with timer query */
  26131. canUseTimestampForTimerQuery: boolean;
  26132. /** Function used to let the system compiles shaders in background */
  26133. parallelShaderCompile: {
  26134. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26135. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26136. COMPLETION_STATUS_KHR: number;
  26137. };
  26138. }
  26139. /** Interface defining initialization parameters for Engine class */
  26140. export interface EngineOptions extends WebGLContextAttributes {
  26141. /**
  26142. * Defines if the engine should no exceed a specified device ratio
  26143. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26144. */
  26145. limitDeviceRatio?: number;
  26146. /**
  26147. * Defines if webvr should be enabled automatically
  26148. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26149. */
  26150. autoEnableWebVR?: boolean;
  26151. /**
  26152. * Defines if webgl2 should be turned off even if supported
  26153. * @see http://doc.babylonjs.com/features/webgl2
  26154. */
  26155. disableWebGL2Support?: boolean;
  26156. /**
  26157. * Defines if webaudio should be initialized as well
  26158. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26159. */
  26160. audioEngine?: boolean;
  26161. /**
  26162. * Defines if animations should run using a deterministic lock step
  26163. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26164. */
  26165. deterministicLockstep?: boolean;
  26166. /** Defines the maximum steps to use with deterministic lock step mode */
  26167. lockstepMaxSteps?: number;
  26168. /**
  26169. * Defines that engine should ignore context lost events
  26170. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26171. */
  26172. doNotHandleContextLost?: boolean;
  26173. /**
  26174. * Defines that engine should ignore modifying touch action attribute and style
  26175. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26176. */
  26177. doNotHandleTouchAction?: boolean;
  26178. }
  26179. /**
  26180. * Defines the interface used by display changed events
  26181. */
  26182. export interface IDisplayChangedEventArgs {
  26183. /** Gets the vrDisplay object (if any) */
  26184. vrDisplay: Nullable<any>;
  26185. /** Gets a boolean indicating if webVR is supported */
  26186. vrSupported: boolean;
  26187. }
  26188. /**
  26189. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26190. */
  26191. export class Engine {
  26192. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26193. static ExceptionList: ({
  26194. key: string;
  26195. capture: string;
  26196. captureConstraint: number;
  26197. targets: string[];
  26198. } | {
  26199. key: string;
  26200. capture: null;
  26201. captureConstraint: null;
  26202. targets: string[];
  26203. })[];
  26204. /** Gets the list of created engines */
  26205. static readonly Instances: Engine[];
  26206. /**
  26207. * Gets the latest created engine
  26208. */
  26209. static readonly LastCreatedEngine: Nullable<Engine>;
  26210. /**
  26211. * Gets the latest created scene
  26212. */
  26213. static readonly LastCreatedScene: Nullable<Scene>;
  26214. /**
  26215. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26216. * @param flag defines which part of the materials must be marked as dirty
  26217. * @param predicate defines a predicate used to filter which materials should be affected
  26218. */
  26219. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26220. /**
  26221. * Hidden
  26222. */
  26223. static _TextureLoaders: IInternalTextureLoader[];
  26224. /** Defines that alpha blending is disabled */
  26225. static readonly ALPHA_DISABLE: number;
  26226. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26227. static readonly ALPHA_ADD: number;
  26228. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26229. static readonly ALPHA_COMBINE: number;
  26230. /** Defines that alpha blending to DEST - SRC * DEST */
  26231. static readonly ALPHA_SUBTRACT: number;
  26232. /** Defines that alpha blending to SRC * DEST */
  26233. static readonly ALPHA_MULTIPLY: number;
  26234. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26235. static readonly ALPHA_MAXIMIZED: number;
  26236. /** Defines that alpha blending to SRC + DEST */
  26237. static readonly ALPHA_ONEONE: number;
  26238. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26239. static readonly ALPHA_PREMULTIPLIED: number;
  26240. /**
  26241. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26242. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26243. */
  26244. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26245. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26246. static readonly ALPHA_INTERPOLATE: number;
  26247. /**
  26248. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26249. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26250. */
  26251. static readonly ALPHA_SCREENMODE: number;
  26252. /** Defines that the ressource is not delayed*/
  26253. static readonly DELAYLOADSTATE_NONE: number;
  26254. /** Defines that the ressource was successfully delay loaded */
  26255. static readonly DELAYLOADSTATE_LOADED: number;
  26256. /** Defines that the ressource is currently delay loading */
  26257. static readonly DELAYLOADSTATE_LOADING: number;
  26258. /** Defines that the ressource is delayed and has not started loading */
  26259. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26260. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26261. static readonly NEVER: number;
  26262. /** 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 */
  26263. static readonly ALWAYS: number;
  26264. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26265. static readonly LESS: number;
  26266. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26267. static readonly EQUAL: number;
  26268. /** 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 */
  26269. static readonly LEQUAL: number;
  26270. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26271. static readonly GREATER: number;
  26272. /** 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 */
  26273. static readonly GEQUAL: number;
  26274. /** 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 */
  26275. static readonly NOTEQUAL: number;
  26276. /** Passed to stencilOperation to specify that stencil value must be kept */
  26277. static readonly KEEP: number;
  26278. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26279. static readonly REPLACE: number;
  26280. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26281. static readonly INCR: number;
  26282. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26283. static readonly DECR: number;
  26284. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26285. static readonly INVERT: number;
  26286. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26287. static readonly INCR_WRAP: number;
  26288. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26289. static readonly DECR_WRAP: number;
  26290. /** Texture is not repeating outside of 0..1 UVs */
  26291. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26292. /** Texture is repeating outside of 0..1 UVs */
  26293. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26294. /** Texture is repeating and mirrored */
  26295. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26296. /** ALPHA */
  26297. static readonly TEXTUREFORMAT_ALPHA: number;
  26298. /** LUMINANCE */
  26299. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26300. /** LUMINANCE_ALPHA */
  26301. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26302. /** RGB */
  26303. static readonly TEXTUREFORMAT_RGB: number;
  26304. /** RGBA */
  26305. static readonly TEXTUREFORMAT_RGBA: number;
  26306. /** RED */
  26307. static readonly TEXTUREFORMAT_RED: number;
  26308. /** RED (2nd reference) */
  26309. static readonly TEXTUREFORMAT_R: number;
  26310. /** RG */
  26311. static readonly TEXTUREFORMAT_RG: number;
  26312. /** RED_INTEGER */
  26313. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26314. /** RED_INTEGER (2nd reference) */
  26315. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26316. /** RG_INTEGER */
  26317. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26318. /** RGB_INTEGER */
  26319. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26320. /** RGBA_INTEGER */
  26321. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26322. /** UNSIGNED_BYTE */
  26323. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26324. /** UNSIGNED_BYTE (2nd reference) */
  26325. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26326. /** FLOAT */
  26327. static readonly TEXTURETYPE_FLOAT: number;
  26328. /** HALF_FLOAT */
  26329. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26330. /** BYTE */
  26331. static readonly TEXTURETYPE_BYTE: number;
  26332. /** SHORT */
  26333. static readonly TEXTURETYPE_SHORT: number;
  26334. /** UNSIGNED_SHORT */
  26335. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26336. /** INT */
  26337. static readonly TEXTURETYPE_INT: number;
  26338. /** UNSIGNED_INT */
  26339. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26340. /** UNSIGNED_SHORT_4_4_4_4 */
  26341. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26342. /** UNSIGNED_SHORT_5_5_5_1 */
  26343. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26344. /** UNSIGNED_SHORT_5_6_5 */
  26345. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26346. /** UNSIGNED_INT_2_10_10_10_REV */
  26347. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26348. /** UNSIGNED_INT_24_8 */
  26349. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26350. /** UNSIGNED_INT_10F_11F_11F_REV */
  26351. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26352. /** UNSIGNED_INT_5_9_9_9_REV */
  26353. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26354. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26355. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26356. /** nearest is mag = nearest and min = nearest and mip = linear */
  26357. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26358. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26359. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26360. /** Trilinear is mag = linear and min = linear and mip = linear */
  26361. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26362. /** nearest is mag = nearest and min = nearest and mip = linear */
  26363. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26364. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26365. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26366. /** Trilinear is mag = linear and min = linear and mip = linear */
  26367. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26368. /** mag = nearest and min = nearest and mip = nearest */
  26369. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26370. /** mag = nearest and min = linear and mip = nearest */
  26371. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26372. /** mag = nearest and min = linear and mip = linear */
  26373. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26374. /** mag = nearest and min = linear and mip = none */
  26375. static readonly TEXTURE_NEAREST_LINEAR: number;
  26376. /** mag = nearest and min = nearest and mip = none */
  26377. static readonly TEXTURE_NEAREST_NEAREST: number;
  26378. /** mag = linear and min = nearest and mip = nearest */
  26379. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26380. /** mag = linear and min = nearest and mip = linear */
  26381. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26382. /** mag = linear and min = linear and mip = none */
  26383. static readonly TEXTURE_LINEAR_LINEAR: number;
  26384. /** mag = linear and min = nearest and mip = none */
  26385. static readonly TEXTURE_LINEAR_NEAREST: number;
  26386. /** Explicit coordinates mode */
  26387. static readonly TEXTURE_EXPLICIT_MODE: number;
  26388. /** Spherical coordinates mode */
  26389. static readonly TEXTURE_SPHERICAL_MODE: number;
  26390. /** Planar coordinates mode */
  26391. static readonly TEXTURE_PLANAR_MODE: number;
  26392. /** Cubic coordinates mode */
  26393. static readonly TEXTURE_CUBIC_MODE: number;
  26394. /** Projection coordinates mode */
  26395. static readonly TEXTURE_PROJECTION_MODE: number;
  26396. /** Skybox coordinates mode */
  26397. static readonly TEXTURE_SKYBOX_MODE: number;
  26398. /** Inverse Cubic coordinates mode */
  26399. static readonly TEXTURE_INVCUBIC_MODE: number;
  26400. /** Equirectangular coordinates mode */
  26401. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26402. /** Equirectangular Fixed coordinates mode */
  26403. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26404. /** Equirectangular Fixed Mirrored coordinates mode */
  26405. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26406. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26407. static readonly SCALEMODE_FLOOR: number;
  26408. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26409. static readonly SCALEMODE_NEAREST: number;
  26410. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26411. static readonly SCALEMODE_CEILING: number;
  26412. /**
  26413. * Returns the current version of the framework
  26414. */
  26415. static readonly Version: string;
  26416. /**
  26417. * Returns a string describing the current engine
  26418. */
  26419. readonly description: string;
  26420. /**
  26421. * Gets or sets the epsilon value used by collision engine
  26422. */
  26423. static CollisionsEpsilon: number;
  26424. /**
  26425. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26426. */
  26427. static ShadersRepository: string;
  26428. /**
  26429. * Method called to create the default loading screen.
  26430. * This can be overriden in your own app.
  26431. * @param canvas The rendering canvas element
  26432. * @returns The loading screen
  26433. */
  26434. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26435. /**
  26436. * Method called to create the default rescale post process on each engine.
  26437. */
  26438. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26439. /**
  26440. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26441. */
  26442. forcePOTTextures: boolean;
  26443. /**
  26444. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26445. */
  26446. isFullscreen: boolean;
  26447. /**
  26448. * Gets a boolean indicating if the pointer is currently locked
  26449. */
  26450. isPointerLock: boolean;
  26451. /**
  26452. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26453. */
  26454. cullBackFaces: boolean;
  26455. /**
  26456. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26457. */
  26458. renderEvenInBackground: boolean;
  26459. /**
  26460. * Gets or sets a boolean indicating that cache can be kept between frames
  26461. */
  26462. preventCacheWipeBetweenFrames: boolean;
  26463. /**
  26464. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26465. **/
  26466. enableOfflineSupport: boolean;
  26467. /**
  26468. * 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)
  26469. **/
  26470. disableManifestCheck: boolean;
  26471. /**
  26472. * Gets the list of created scenes
  26473. */
  26474. scenes: Scene[];
  26475. /**
  26476. * Event raised when a new scene is created
  26477. */
  26478. onNewSceneAddedObservable: Observable<Scene>;
  26479. /**
  26480. * Gets the list of created postprocesses
  26481. */
  26482. postProcesses: PostProcess[];
  26483. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26484. validateShaderPrograms: boolean;
  26485. /**
  26486. * Observable event triggered each time the rendering canvas is resized
  26487. */
  26488. onResizeObservable: Observable<Engine>;
  26489. /**
  26490. * Observable event triggered each time the canvas loses focus
  26491. */
  26492. onCanvasBlurObservable: Observable<Engine>;
  26493. /**
  26494. * Observable event triggered each time the canvas gains focus
  26495. */
  26496. onCanvasFocusObservable: Observable<Engine>;
  26497. /**
  26498. * Observable event triggered each time the canvas receives pointerout event
  26499. */
  26500. onCanvasPointerOutObservable: Observable<PointerEvent>;
  26501. /**
  26502. * Observable event triggered before each texture is initialized
  26503. */
  26504. onBeforeTextureInitObservable: Observable<Texture>;
  26505. private _vrDisplay;
  26506. private _vrSupported;
  26507. private _oldSize;
  26508. private _oldHardwareScaleFactor;
  26509. private _vrExclusivePointerMode;
  26510. private _webVRInitPromise;
  26511. /**
  26512. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26513. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26514. */
  26515. readonly isInVRExclusivePointerMode: boolean;
  26516. /**
  26517. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  26518. */
  26519. disableUniformBuffers: boolean;
  26520. /** @hidden */
  26521. _uniformBuffers: UniformBuffer[];
  26522. /**
  26523. * Gets a boolean indicating that the engine supports uniform buffers
  26524. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26525. */
  26526. readonly supportsUniformBuffers: boolean;
  26527. /**
  26528. * Observable raised when the engine begins a new frame
  26529. */
  26530. onBeginFrameObservable: Observable<Engine>;
  26531. /**
  26532. * If set, will be used to request the next animation frame for the render loop
  26533. */
  26534. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  26535. /**
  26536. * Observable raised when the engine ends the current frame
  26537. */
  26538. onEndFrameObservable: Observable<Engine>;
  26539. /**
  26540. * Observable raised when the engine is about to compile a shader
  26541. */
  26542. onBeforeShaderCompilationObservable: Observable<Engine>;
  26543. /**
  26544. * Observable raised when the engine has jsut compiled a shader
  26545. */
  26546. onAfterShaderCompilationObservable: Observable<Engine>;
  26547. /** @hidden */
  26548. _gl: WebGLRenderingContext;
  26549. private _renderingCanvas;
  26550. private _windowIsBackground;
  26551. private _webGLVersion;
  26552. /**
  26553. * Gets a boolean indicating that only power of 2 textures are supported
  26554. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  26555. */
  26556. readonly needPOTTextures: boolean;
  26557. /** @hidden */
  26558. _badOS: boolean;
  26559. /** @hidden */
  26560. _badDesktopOS: boolean;
  26561. /**
  26562. * Gets or sets a value indicating if we want to disable texture binding optimization.
  26563. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  26564. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  26565. */
  26566. disableTextureBindingOptimization: boolean;
  26567. /**
  26568. * Gets the audio engine
  26569. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26570. * @ignorenaming
  26571. */
  26572. static audioEngine: IAudioEngine;
  26573. /**
  26574. * Default AudioEngine factory responsible of creating the Audio Engine.
  26575. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  26576. */
  26577. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  26578. /**
  26579. * Default offline support factory responsible of creating a tool used to store data locally.
  26580. * By default, this will create a Database object if the workload has been embedded.
  26581. */
  26582. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  26583. private _onFocus;
  26584. private _onBlur;
  26585. private _onCanvasPointerOut;
  26586. private _onCanvasBlur;
  26587. private _onCanvasFocus;
  26588. private _onFullscreenChange;
  26589. private _onPointerLockChange;
  26590. private _onVRDisplayPointerRestricted;
  26591. private _onVRDisplayPointerUnrestricted;
  26592. private _onVrDisplayConnect;
  26593. private _onVrDisplayDisconnect;
  26594. private _onVrDisplayPresentChange;
  26595. /**
  26596. * Observable signaled when VR display mode changes
  26597. */
  26598. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26599. /**
  26600. * Observable signaled when VR request present is complete
  26601. */
  26602. onVRRequestPresentComplete: Observable<boolean>;
  26603. /**
  26604. * Observable signaled when VR request present starts
  26605. */
  26606. onVRRequestPresentStart: Observable<Engine>;
  26607. private _hardwareScalingLevel;
  26608. /** @hidden */
  26609. protected _caps: EngineCapabilities;
  26610. private _pointerLockRequested;
  26611. private _isStencilEnable;
  26612. private _colorWrite;
  26613. private _loadingScreen;
  26614. /** @hidden */
  26615. _drawCalls: PerfCounter;
  26616. /** @hidden */
  26617. _textureCollisions: PerfCounter;
  26618. private _glVersion;
  26619. private _glRenderer;
  26620. private _glVendor;
  26621. private _videoTextureSupported;
  26622. private _renderingQueueLaunched;
  26623. private _activeRenderLoops;
  26624. private _deterministicLockstep;
  26625. private _lockstepMaxSteps;
  26626. /**
  26627. * Observable signaled when a context lost event is raised
  26628. */
  26629. onContextLostObservable: Observable<Engine>;
  26630. /**
  26631. * Observable signaled when a context restored event is raised
  26632. */
  26633. onContextRestoredObservable: Observable<Engine>;
  26634. private _onContextLost;
  26635. private _onContextRestored;
  26636. private _contextWasLost;
  26637. private _doNotHandleContextLost;
  26638. /**
  26639. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  26640. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  26641. */
  26642. doNotHandleContextLost: boolean;
  26643. private _performanceMonitor;
  26644. private _fps;
  26645. private _deltaTime;
  26646. /**
  26647. * Turn this value on if you want to pause FPS computation when in background
  26648. */
  26649. disablePerformanceMonitorInBackground: boolean;
  26650. /**
  26651. * Gets the performance monitor attached to this engine
  26652. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  26653. */
  26654. readonly performanceMonitor: PerformanceMonitor;
  26655. /** @hidden */
  26656. protected _depthCullingState: _DepthCullingState;
  26657. /** @hidden */
  26658. protected _stencilState: _StencilState;
  26659. /** @hidden */
  26660. protected _alphaState: _AlphaState;
  26661. /** @hidden */
  26662. protected _alphaMode: number;
  26663. protected _internalTexturesCache: InternalTexture[];
  26664. /** @hidden */
  26665. protected _activeChannel: number;
  26666. private _currentTextureChannel;
  26667. /** @hidden */
  26668. protected _boundTexturesCache: {
  26669. [key: string]: Nullable<InternalTexture>;
  26670. };
  26671. /** @hidden */
  26672. protected _currentEffect: Nullable<Effect>;
  26673. /** @hidden */
  26674. protected _currentProgram: Nullable<WebGLProgram>;
  26675. private _compiledEffects;
  26676. private _vertexAttribArraysEnabled;
  26677. /** @hidden */
  26678. protected _cachedViewport: Nullable<Viewport>;
  26679. private _cachedVertexArrayObject;
  26680. /** @hidden */
  26681. protected _cachedVertexBuffers: any;
  26682. /** @hidden */
  26683. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  26684. /** @hidden */
  26685. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  26686. /** @hidden */
  26687. protected _currentRenderTarget: Nullable<InternalTexture>;
  26688. private _uintIndicesCurrentlySet;
  26689. private _currentBoundBuffer;
  26690. /** @hidden */
  26691. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  26692. private _currentBufferPointers;
  26693. private _currentInstanceLocations;
  26694. private _currentInstanceBuffers;
  26695. private _textureUnits;
  26696. private _firstBoundInternalTextureTracker;
  26697. private _lastBoundInternalTextureTracker;
  26698. private _workingCanvas;
  26699. private _workingContext;
  26700. private _rescalePostProcess;
  26701. private _dummyFramebuffer;
  26702. private _externalData;
  26703. private _bindedRenderFunction;
  26704. private _vaoRecordInProgress;
  26705. private _mustWipeVertexAttributes;
  26706. private _emptyTexture;
  26707. private _emptyCubeTexture;
  26708. private _emptyTexture3D;
  26709. /** @hidden */
  26710. _frameHandler: number;
  26711. private _nextFreeTextureSlots;
  26712. private _maxSimultaneousTextures;
  26713. private _activeRequests;
  26714. private _texturesSupported;
  26715. private _textureFormatInUse;
  26716. /**
  26717. * Gets the list of texture formats supported
  26718. */
  26719. readonly texturesSupported: Array<string>;
  26720. /**
  26721. * Gets the list of texture formats in use
  26722. */
  26723. readonly textureFormatInUse: Nullable<string>;
  26724. /**
  26725. * Gets the current viewport
  26726. */
  26727. readonly currentViewport: Nullable<Viewport>;
  26728. /**
  26729. * Gets the default empty texture
  26730. */
  26731. readonly emptyTexture: InternalTexture;
  26732. /**
  26733. * Gets the default empty 3D texture
  26734. */
  26735. readonly emptyTexture3D: InternalTexture;
  26736. /**
  26737. * Gets the default empty cube texture
  26738. */
  26739. readonly emptyCubeTexture: InternalTexture;
  26740. /**
  26741. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  26742. */
  26743. readonly premultipliedAlpha: boolean;
  26744. /**
  26745. * Creates a new engine
  26746. * @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
  26747. * @param antialias defines enable antialiasing (default: false)
  26748. * @param options defines further options to be sent to the getContext() function
  26749. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  26750. */
  26751. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  26752. private _disableTouchAction;
  26753. private _rebuildInternalTextures;
  26754. private _rebuildEffects;
  26755. /**
  26756. * Gets a boolean indicating if all created effects are ready
  26757. * @returns true if all effects are ready
  26758. */
  26759. areAllEffectsReady(): boolean;
  26760. private _rebuildBuffers;
  26761. private _initGLContext;
  26762. /**
  26763. * Gets version of the current webGL context
  26764. */
  26765. readonly webGLVersion: number;
  26766. /**
  26767. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  26768. */
  26769. readonly isStencilEnable: boolean;
  26770. private _prepareWorkingCanvas;
  26771. /**
  26772. * Reset the texture cache to empty state
  26773. */
  26774. resetTextureCache(): void;
  26775. /**
  26776. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  26777. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26778. * @returns true if engine is in deterministic lock step mode
  26779. */
  26780. isDeterministicLockStep(): boolean;
  26781. /**
  26782. * Gets the max steps when engine is running in deterministic lock step
  26783. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26784. * @returns the max steps
  26785. */
  26786. getLockstepMaxSteps(): number;
  26787. /**
  26788. * Gets an object containing information about the current webGL context
  26789. * @returns an object containing the vender, the renderer and the version of the current webGL context
  26790. */
  26791. getGlInfo(): {
  26792. vendor: string;
  26793. renderer: string;
  26794. version: string;
  26795. };
  26796. /**
  26797. * Gets current aspect ratio
  26798. * @param camera defines the camera to use to get the aspect ratio
  26799. * @param useScreen defines if screen size must be used (or the current render target if any)
  26800. * @returns a number defining the aspect ratio
  26801. */
  26802. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  26803. /**
  26804. * Gets current screen aspect ratio
  26805. * @returns a number defining the aspect ratio
  26806. */
  26807. getScreenAspectRatio(): number;
  26808. /**
  26809. * Gets the current render width
  26810. * @param useScreen defines if screen size must be used (or the current render target if any)
  26811. * @returns a number defining the current render width
  26812. */
  26813. getRenderWidth(useScreen?: boolean): number;
  26814. /**
  26815. * Gets the current render height
  26816. * @param useScreen defines if screen size must be used (or the current render target if any)
  26817. * @returns a number defining the current render height
  26818. */
  26819. getRenderHeight(useScreen?: boolean): number;
  26820. /**
  26821. * Gets the HTML canvas attached with the current webGL context
  26822. * @returns a HTML canvas
  26823. */
  26824. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  26825. /**
  26826. * Gets the client rect of the HTML canvas attached with the current webGL context
  26827. * @returns a client rectanglee
  26828. */
  26829. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  26830. /**
  26831. * Defines the hardware scaling level.
  26832. * By default the hardware scaling level is computed from the window device ratio.
  26833. * 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.
  26834. * @param level defines the level to use
  26835. */
  26836. setHardwareScalingLevel(level: number): void;
  26837. /**
  26838. * Gets the current hardware scaling level.
  26839. * By default the hardware scaling level is computed from the window device ratio.
  26840. * 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.
  26841. * @returns a number indicating the current hardware scaling level
  26842. */
  26843. getHardwareScalingLevel(): number;
  26844. /**
  26845. * Gets the list of loaded textures
  26846. * @returns an array containing all loaded textures
  26847. */
  26848. getLoadedTexturesCache(): InternalTexture[];
  26849. /**
  26850. * Gets the object containing all engine capabilities
  26851. * @returns the EngineCapabilities object
  26852. */
  26853. getCaps(): EngineCapabilities;
  26854. /**
  26855. * Gets the current depth function
  26856. * @returns a number defining the depth function
  26857. */
  26858. getDepthFunction(): Nullable<number>;
  26859. /**
  26860. * Sets the current depth function
  26861. * @param depthFunc defines the function to use
  26862. */
  26863. setDepthFunction(depthFunc: number): void;
  26864. /**
  26865. * Sets the current depth function to GREATER
  26866. */
  26867. setDepthFunctionToGreater(): void;
  26868. /**
  26869. * Sets the current depth function to GEQUAL
  26870. */
  26871. setDepthFunctionToGreaterOrEqual(): void;
  26872. /**
  26873. * Sets the current depth function to LESS
  26874. */
  26875. setDepthFunctionToLess(): void;
  26876. /**
  26877. * Sets the current depth function to LEQUAL
  26878. */
  26879. setDepthFunctionToLessOrEqual(): void;
  26880. /**
  26881. * Gets a boolean indicating if stencil buffer is enabled
  26882. * @returns the current stencil buffer state
  26883. */
  26884. getStencilBuffer(): boolean;
  26885. /**
  26886. * Enable or disable the stencil buffer
  26887. * @param enable defines if the stencil buffer must be enabled or disabled
  26888. */
  26889. setStencilBuffer(enable: boolean): void;
  26890. /**
  26891. * Gets the current stencil mask
  26892. * @returns a number defining the new stencil mask to use
  26893. */
  26894. getStencilMask(): number;
  26895. /**
  26896. * Sets the current stencil mask
  26897. * @param mask defines the new stencil mask to use
  26898. */
  26899. setStencilMask(mask: number): void;
  26900. /**
  26901. * Gets the current stencil function
  26902. * @returns a number defining the stencil function to use
  26903. */
  26904. getStencilFunction(): number;
  26905. /**
  26906. * Gets the current stencil reference value
  26907. * @returns a number defining the stencil reference value to use
  26908. */
  26909. getStencilFunctionReference(): number;
  26910. /**
  26911. * Gets the current stencil mask
  26912. * @returns a number defining the stencil mask to use
  26913. */
  26914. getStencilFunctionMask(): number;
  26915. /**
  26916. * Sets the current stencil function
  26917. * @param stencilFunc defines the new stencil function to use
  26918. */
  26919. setStencilFunction(stencilFunc: number): void;
  26920. /**
  26921. * Sets the current stencil reference
  26922. * @param reference defines the new stencil reference to use
  26923. */
  26924. setStencilFunctionReference(reference: number): void;
  26925. /**
  26926. * Sets the current stencil mask
  26927. * @param mask defines the new stencil mask to use
  26928. */
  26929. setStencilFunctionMask(mask: number): void;
  26930. /**
  26931. * Gets the current stencil operation when stencil fails
  26932. * @returns a number defining stencil operation to use when stencil fails
  26933. */
  26934. getStencilOperationFail(): number;
  26935. /**
  26936. * Gets the current stencil operation when depth fails
  26937. * @returns a number defining stencil operation to use when depth fails
  26938. */
  26939. getStencilOperationDepthFail(): number;
  26940. /**
  26941. * Gets the current stencil operation when stencil passes
  26942. * @returns a number defining stencil operation to use when stencil passes
  26943. */
  26944. getStencilOperationPass(): number;
  26945. /**
  26946. * Sets the stencil operation to use when stencil fails
  26947. * @param operation defines the stencil operation to use when stencil fails
  26948. */
  26949. setStencilOperationFail(operation: number): void;
  26950. /**
  26951. * Sets the stencil operation to use when depth fails
  26952. * @param operation defines the stencil operation to use when depth fails
  26953. */
  26954. setStencilOperationDepthFail(operation: number): void;
  26955. /**
  26956. * Sets the stencil operation to use when stencil passes
  26957. * @param operation defines the stencil operation to use when stencil passes
  26958. */
  26959. setStencilOperationPass(operation: number): void;
  26960. /**
  26961. * Sets a boolean indicating if the dithering state is enabled or disabled
  26962. * @param value defines the dithering state
  26963. */
  26964. setDitheringState(value: boolean): void;
  26965. /**
  26966. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  26967. * @param value defines the rasterizer state
  26968. */
  26969. setRasterizerState(value: boolean): void;
  26970. /**
  26971. * stop executing a render loop function and remove it from the execution array
  26972. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  26973. */
  26974. stopRenderLoop(renderFunction?: () => void): void;
  26975. /** @hidden */
  26976. _renderLoop(): void;
  26977. /**
  26978. * Register and execute a render loop. The engine can have more than one render function
  26979. * @param renderFunction defines the function to continuously execute
  26980. */
  26981. runRenderLoop(renderFunction: () => void): void;
  26982. /**
  26983. * Toggle full screen mode
  26984. * @param requestPointerLock defines if a pointer lock should be requested from the user
  26985. */
  26986. switchFullscreen(requestPointerLock: boolean): void;
  26987. /**
  26988. * Enters full screen mode
  26989. * @param requestPointerLock defines if a pointer lock should be requested from the user
  26990. */
  26991. enterFullscreen(requestPointerLock: boolean): void;
  26992. /**
  26993. * Exits full screen mode
  26994. */
  26995. exitFullscreen(): void;
  26996. /**
  26997. * Clear the current render buffer or the current render target (if any is set up)
  26998. * @param color defines the color to use
  26999. * @param backBuffer defines if the back buffer must be cleared
  27000. * @param depth defines if the depth buffer must be cleared
  27001. * @param stencil defines if the stencil buffer must be cleared
  27002. */
  27003. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27004. /**
  27005. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27006. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27007. * @param y defines the y-coordinate of the corner of the clear rectangle
  27008. * @param width defines the width of the clear rectangle
  27009. * @param height defines the height of the clear rectangle
  27010. * @param clearColor defines the clear color
  27011. */
  27012. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27013. /**
  27014. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27015. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27016. * @param y defines the y-coordinate of the corner of the clear rectangle
  27017. * @param width defines the width of the clear rectangle
  27018. * @param height defines the height of the clear rectangle
  27019. */
  27020. enableScissor(x: number, y: number, width: number, height: number): void;
  27021. /**
  27022. * Disable previously set scissor test rectangle
  27023. */
  27024. disableScissor(): void;
  27025. private _viewportCached;
  27026. /** @hidden */
  27027. _viewport(x: number, y: number, width: number, height: number): void;
  27028. /**
  27029. * Set the WebGL's viewport
  27030. * @param viewport defines the viewport element to be used
  27031. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27032. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27033. */
  27034. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27035. /**
  27036. * Directly set the WebGL Viewport
  27037. * @param x defines the x coordinate of the viewport (in screen space)
  27038. * @param y defines the y coordinate of the viewport (in screen space)
  27039. * @param width defines the width of the viewport (in screen space)
  27040. * @param height defines the height of the viewport (in screen space)
  27041. * @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
  27042. */
  27043. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27044. /**
  27045. * Begin a new frame
  27046. */
  27047. beginFrame(): void;
  27048. /**
  27049. * Enf the current frame
  27050. */
  27051. endFrame(): void;
  27052. /**
  27053. * Resize the view according to the canvas' size
  27054. */
  27055. resize(): void;
  27056. /**
  27057. * Force a specific size of the canvas
  27058. * @param width defines the new canvas' width
  27059. * @param height defines the new canvas' height
  27060. */
  27061. setSize(width: number, height: number): void;
  27062. /**
  27063. * Gets a boolean indicating if a webVR device was detected
  27064. * @returns true if a webVR device was detected
  27065. */
  27066. isVRDevicePresent(): boolean;
  27067. /**
  27068. * Gets the current webVR device
  27069. * @returns the current webVR device (or null)
  27070. */
  27071. getVRDevice(): any;
  27072. /**
  27073. * Initializes a webVR display and starts listening to display change events
  27074. * The onVRDisplayChangedObservable will be notified upon these changes
  27075. * @returns The onVRDisplayChangedObservable
  27076. */
  27077. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27078. /**
  27079. * Initializes a webVR display and starts listening to display change events
  27080. * The onVRDisplayChangedObservable will be notified upon these changes
  27081. * @returns A promise containing a VRDisplay and if vr is supported
  27082. */
  27083. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27084. /**
  27085. * Call this function to switch to webVR mode
  27086. * Will do nothing if webVR is not supported or if there is no webVR device
  27087. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27088. */
  27089. enableVR(): void;
  27090. /**
  27091. * Call this function to leave webVR mode
  27092. * Will do nothing if webVR is not supported or if there is no webVR device
  27093. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27094. */
  27095. disableVR(): void;
  27096. private _onVRFullScreenTriggered;
  27097. private _getVRDisplaysAsync;
  27098. /**
  27099. * Binds the frame buffer to the specified texture.
  27100. * @param texture The texture to render to or null for the default canvas
  27101. * @param faceIndex The face of the texture to render to in case of cube texture
  27102. * @param requiredWidth The width of the target to render to
  27103. * @param requiredHeight The height of the target to render to
  27104. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27105. * @param depthStencilTexture The depth stencil texture to use to render
  27106. * @param lodLevel defines le lod level to bind to the frame buffer
  27107. */
  27108. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27109. private bindUnboundFramebuffer;
  27110. /**
  27111. * Unbind the current render target texture from the webGL context
  27112. * @param texture defines the render target texture to unbind
  27113. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27114. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27115. */
  27116. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27117. /**
  27118. * Unbind a list of render target textures from the webGL context
  27119. * This is used only when drawBuffer extension or webGL2 are active
  27120. * @param textures defines the render target textures to unbind
  27121. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27122. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27123. */
  27124. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27125. /**
  27126. * Force the mipmap generation for the given render target texture
  27127. * @param texture defines the render target texture to use
  27128. */
  27129. generateMipMapsForCubemap(texture: InternalTexture): void;
  27130. /**
  27131. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27132. */
  27133. flushFramebuffer(): void;
  27134. /**
  27135. * Unbind the current render target and bind the default framebuffer
  27136. */
  27137. restoreDefaultFramebuffer(): void;
  27138. /**
  27139. * Create an uniform buffer
  27140. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27141. * @param elements defines the content of the uniform buffer
  27142. * @returns the webGL uniform buffer
  27143. */
  27144. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27145. /**
  27146. * Create a dynamic uniform buffer
  27147. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27148. * @param elements defines the content of the uniform buffer
  27149. * @returns the webGL uniform buffer
  27150. */
  27151. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27152. /**
  27153. * Update an existing uniform buffer
  27154. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27155. * @param uniformBuffer defines the target uniform buffer
  27156. * @param elements defines the content to update
  27157. * @param offset defines the offset in the uniform buffer where update should start
  27158. * @param count defines the size of the data to update
  27159. */
  27160. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27161. private _resetVertexBufferBinding;
  27162. /**
  27163. * Creates a vertex buffer
  27164. * @param data the data for the vertex buffer
  27165. * @returns the new WebGL static buffer
  27166. */
  27167. createVertexBuffer(data: DataArray): WebGLBuffer;
  27168. /**
  27169. * Creates a dynamic vertex buffer
  27170. * @param data the data for the dynamic vertex buffer
  27171. * @returns the new WebGL dynamic buffer
  27172. */
  27173. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27174. /**
  27175. * Update a dynamic index buffer
  27176. * @param indexBuffer defines the target index buffer
  27177. * @param indices defines the data to update
  27178. * @param offset defines the offset in the target index buffer where update should start
  27179. */
  27180. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27181. /**
  27182. * Updates a dynamic vertex buffer.
  27183. * @param vertexBuffer the vertex buffer to update
  27184. * @param data the data used to update the vertex buffer
  27185. * @param byteOffset the byte offset of the data
  27186. * @param byteLength the byte length of the data
  27187. */
  27188. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27189. private _resetIndexBufferBinding;
  27190. /**
  27191. * Creates a new index buffer
  27192. * @param indices defines the content of the index buffer
  27193. * @param updatable defines if the index buffer must be updatable
  27194. * @returns a new webGL buffer
  27195. */
  27196. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27197. /**
  27198. * Bind a webGL buffer to the webGL context
  27199. * @param buffer defines the buffer to bind
  27200. */
  27201. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27202. /**
  27203. * Bind an uniform buffer to the current webGL context
  27204. * @param buffer defines the buffer to bind
  27205. */
  27206. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27207. /**
  27208. * Bind a buffer to the current webGL context at a given location
  27209. * @param buffer defines the buffer to bind
  27210. * @param location defines the index where to bind the buffer
  27211. */
  27212. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27213. /**
  27214. * Bind a specific block at a given index in a specific shader program
  27215. * @param shaderProgram defines the shader program
  27216. * @param blockName defines the block name
  27217. * @param index defines the index where to bind the block
  27218. */
  27219. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27220. private bindIndexBuffer;
  27221. private bindBuffer;
  27222. /**
  27223. * update the bound buffer with the given data
  27224. * @param data defines the data to update
  27225. */
  27226. updateArrayBuffer(data: Float32Array): void;
  27227. private _vertexAttribPointer;
  27228. private _bindIndexBufferWithCache;
  27229. private _bindVertexBuffersAttributes;
  27230. /**
  27231. * Records a vertex array object
  27232. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27233. * @param vertexBuffers defines the list of vertex buffers to store
  27234. * @param indexBuffer defines the index buffer to store
  27235. * @param effect defines the effect to store
  27236. * @returns the new vertex array object
  27237. */
  27238. recordVertexArrayObject(vertexBuffers: {
  27239. [key: string]: VertexBuffer;
  27240. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27241. /**
  27242. * Bind a specific vertex array object
  27243. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27244. * @param vertexArrayObject defines the vertex array object to bind
  27245. * @param indexBuffer defines the index buffer to bind
  27246. */
  27247. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27248. /**
  27249. * Bind webGl buffers directly to the webGL context
  27250. * @param vertexBuffer defines the vertex buffer to bind
  27251. * @param indexBuffer defines the index buffer to bind
  27252. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27253. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27254. * @param effect defines the effect associated with the vertex buffer
  27255. */
  27256. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27257. private _unbindVertexArrayObject;
  27258. /**
  27259. * Bind a list of vertex buffers to the webGL context
  27260. * @param vertexBuffers defines the list of vertex buffers to bind
  27261. * @param indexBuffer defines the index buffer to bind
  27262. * @param effect defines the effect associated with the vertex buffers
  27263. */
  27264. bindBuffers(vertexBuffers: {
  27265. [key: string]: Nullable<VertexBuffer>;
  27266. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27267. /**
  27268. * Unbind all instance attributes
  27269. */
  27270. unbindInstanceAttributes(): void;
  27271. /**
  27272. * Release and free the memory of a vertex array object
  27273. * @param vao defines the vertex array object to delete
  27274. */
  27275. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27276. /** @hidden */
  27277. _releaseBuffer(buffer: WebGLBuffer): boolean;
  27278. /**
  27279. * Creates a webGL buffer to use with instanciation
  27280. * @param capacity defines the size of the buffer
  27281. * @returns the webGL buffer
  27282. */
  27283. createInstancesBuffer(capacity: number): WebGLBuffer;
  27284. /**
  27285. * Delete a webGL buffer used with instanciation
  27286. * @param buffer defines the webGL buffer to delete
  27287. */
  27288. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27289. /**
  27290. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27291. * @param instancesBuffer defines the webGL buffer to update and bind
  27292. * @param data defines the data to store in the buffer
  27293. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27294. */
  27295. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27296. /**
  27297. * Apply all cached states (depth, culling, stencil and alpha)
  27298. */
  27299. applyStates(): void;
  27300. /**
  27301. * Send a draw order
  27302. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27303. * @param indexStart defines the starting index
  27304. * @param indexCount defines the number of index to draw
  27305. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27306. */
  27307. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27308. /**
  27309. * Draw a list of points
  27310. * @param verticesStart defines the index of first vertex to draw
  27311. * @param verticesCount defines the count of vertices to draw
  27312. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27313. */
  27314. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27315. /**
  27316. * Draw a list of unindexed primitives
  27317. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27318. * @param verticesStart defines the index of first vertex to draw
  27319. * @param verticesCount defines the count of vertices to draw
  27320. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27321. */
  27322. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27323. /**
  27324. * Draw a list of indexed primitives
  27325. * @param fillMode defines the primitive to use
  27326. * @param indexStart defines the starting index
  27327. * @param indexCount defines the number of index to draw
  27328. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27329. */
  27330. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27331. /**
  27332. * Draw a list of unindexed primitives
  27333. * @param fillMode defines the primitive to use
  27334. * @param verticesStart defines the index of first vertex to draw
  27335. * @param verticesCount defines the count of vertices to draw
  27336. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27337. */
  27338. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27339. private _drawMode;
  27340. /** @hidden */
  27341. _releaseEffect(effect: Effect): void;
  27342. /** @hidden */
  27343. _deleteProgram(program: WebGLProgram): void;
  27344. /**
  27345. * Create a new effect (used to store vertex/fragment shaders)
  27346. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27347. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27348. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27349. * @param samplers defines an array of string used to represent textures
  27350. * @param defines defines the string containing the defines to use to compile the shaders
  27351. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27352. * @param onCompiled defines a function to call when the effect creation is successful
  27353. * @param onError defines a function to call when the effect creation has failed
  27354. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27355. * @returns the new Effect
  27356. */
  27357. 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;
  27358. private _compileShader;
  27359. private _compileRawShader;
  27360. /**
  27361. * Directly creates a webGL program
  27362. * @param vertexCode defines the vertex shader code to use
  27363. * @param fragmentCode defines the fragment shader code to use
  27364. * @param context defines the webGL context to use (if not set, the current one will be used)
  27365. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27366. * @returns the new webGL program
  27367. */
  27368. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27369. /**
  27370. * Creates a webGL program
  27371. * @param vertexCode defines the vertex shader code to use
  27372. * @param fragmentCode defines the fragment shader code to use
  27373. * @param defines defines the string containing the defines to use to compile the shaders
  27374. * @param context defines the webGL context to use (if not set, the current one will be used)
  27375. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27376. * @returns the new webGL program
  27377. */
  27378. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27379. private _createShaderProgram;
  27380. private _finalizeProgram;
  27381. /** @hidden */
  27382. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  27383. /** @hidden */
  27384. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  27385. /**
  27386. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27387. * @param shaderProgram defines the webGL program to use
  27388. * @param uniformsNames defines the list of uniform names
  27389. * @returns an array of webGL uniform locations
  27390. */
  27391. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27392. /**
  27393. * Gets the lsit of active attributes for a given webGL program
  27394. * @param shaderProgram defines the webGL program to use
  27395. * @param attributesNames defines the list of attribute names to get
  27396. * @returns an array of indices indicating the offset of each attribute
  27397. */
  27398. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  27399. /**
  27400. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27401. * @param effect defines the effect to activate
  27402. */
  27403. enableEffect(effect: Nullable<Effect>): void;
  27404. /**
  27405. * Set the value of an uniform to an array of int32
  27406. * @param uniform defines the webGL uniform location where to store the value
  27407. * @param array defines the array of int32 to store
  27408. */
  27409. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27410. /**
  27411. * Set the value of an uniform to an array of int32 (stored as vec2)
  27412. * @param uniform defines the webGL uniform location where to store the value
  27413. * @param array defines the array of int32 to store
  27414. */
  27415. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27416. /**
  27417. * Set the value of an uniform to an array of int32 (stored as vec3)
  27418. * @param uniform defines the webGL uniform location where to store the value
  27419. * @param array defines the array of int32 to store
  27420. */
  27421. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27422. /**
  27423. * Set the value of an uniform to an array of int32 (stored as vec4)
  27424. * @param uniform defines the webGL uniform location where to store the value
  27425. * @param array defines the array of int32 to store
  27426. */
  27427. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27428. /**
  27429. * Set the value of an uniform to an array of float32
  27430. * @param uniform defines the webGL uniform location where to store the value
  27431. * @param array defines the array of float32 to store
  27432. */
  27433. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27434. /**
  27435. * Set the value of an uniform to an array of float32 (stored as vec2)
  27436. * @param uniform defines the webGL uniform location where to store the value
  27437. * @param array defines the array of float32 to store
  27438. */
  27439. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27440. /**
  27441. * Set the value of an uniform to an array of float32 (stored as vec3)
  27442. * @param uniform defines the webGL uniform location where to store the value
  27443. * @param array defines the array of float32 to store
  27444. */
  27445. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27446. /**
  27447. * Set the value of an uniform to an array of float32 (stored as vec4)
  27448. * @param uniform defines the webGL uniform location where to store the value
  27449. * @param array defines the array of float32 to store
  27450. */
  27451. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27452. /**
  27453. * Set the value of an uniform to an array of number
  27454. * @param uniform defines the webGL uniform location where to store the value
  27455. * @param array defines the array of number to store
  27456. */
  27457. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27458. /**
  27459. * Set the value of an uniform to an array of number (stored as vec2)
  27460. * @param uniform defines the webGL uniform location where to store the value
  27461. * @param array defines the array of number to store
  27462. */
  27463. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27464. /**
  27465. * Set the value of an uniform to an array of number (stored as vec3)
  27466. * @param uniform defines the webGL uniform location where to store the value
  27467. * @param array defines the array of number to store
  27468. */
  27469. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27470. /**
  27471. * Set the value of an uniform to an array of number (stored as vec4)
  27472. * @param uniform defines the webGL uniform location where to store the value
  27473. * @param array defines the array of number to store
  27474. */
  27475. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27476. /**
  27477. * Set the value of an uniform to an array of float32 (stored as matrices)
  27478. * @param uniform defines the webGL uniform location where to store the value
  27479. * @param matrices defines the array of float32 to store
  27480. */
  27481. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27482. /**
  27483. * Set the value of an uniform to a matrix
  27484. * @param uniform defines the webGL uniform location where to store the value
  27485. * @param matrix defines the matrix to store
  27486. */
  27487. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27488. /**
  27489. * Set the value of an uniform to a matrix (3x3)
  27490. * @param uniform defines the webGL uniform location where to store the value
  27491. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27492. */
  27493. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27494. /**
  27495. * Set the value of an uniform to a matrix (2x2)
  27496. * @param uniform defines the webGL uniform location where to store the value
  27497. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27498. */
  27499. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27500. /**
  27501. * Set the value of an uniform to a number (int)
  27502. * @param uniform defines the webGL uniform location where to store the value
  27503. * @param value defines the int number to store
  27504. */
  27505. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27506. /**
  27507. * Set the value of an uniform to a number (float)
  27508. * @param uniform defines the webGL uniform location where to store the value
  27509. * @param value defines the float number to store
  27510. */
  27511. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27512. /**
  27513. * Set the value of an uniform to a vec2
  27514. * @param uniform defines the webGL uniform location where to store the value
  27515. * @param x defines the 1st component of the value
  27516. * @param y defines the 2nd component of the value
  27517. */
  27518. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  27519. /**
  27520. * Set the value of an uniform to a vec3
  27521. * @param uniform defines the webGL uniform location where to store the value
  27522. * @param x defines the 1st component of the value
  27523. * @param y defines the 2nd component of the value
  27524. * @param z defines the 3rd component of the value
  27525. */
  27526. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  27527. /**
  27528. * Set the value of an uniform to a boolean
  27529. * @param uniform defines the webGL uniform location where to store the value
  27530. * @param bool defines the boolean to store
  27531. */
  27532. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  27533. /**
  27534. * Set the value of an uniform to a vec4
  27535. * @param uniform defines the webGL uniform location where to store the value
  27536. * @param x defines the 1st component of the value
  27537. * @param y defines the 2nd component of the value
  27538. * @param z defines the 3rd component of the value
  27539. * @param w defines the 4th component of the value
  27540. */
  27541. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  27542. /**
  27543. * Set the value of an uniform to a Color3
  27544. * @param uniform defines the webGL uniform location where to store the value
  27545. * @param color3 defines the color to store
  27546. */
  27547. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  27548. /**
  27549. * Set the value of an uniform to a Color3 and an alpha value
  27550. * @param uniform defines the webGL uniform location where to store the value
  27551. * @param color3 defines the color to store
  27552. * @param alpha defines the alpha component to store
  27553. */
  27554. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  27555. /**
  27556. * Sets a Color4 on a uniform variable
  27557. * @param uniform defines the uniform location
  27558. * @param color4 defines the value to be set
  27559. */
  27560. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  27561. /**
  27562. * Set various states to the webGL context
  27563. * @param culling defines backface culling state
  27564. * @param zOffset defines the value to apply to zOffset (0 by default)
  27565. * @param force defines if states must be applied even if cache is up to date
  27566. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  27567. */
  27568. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  27569. /**
  27570. * Set the z offset to apply to current rendering
  27571. * @param value defines the offset to apply
  27572. */
  27573. setZOffset(value: number): void;
  27574. /**
  27575. * Gets the current value of the zOffset
  27576. * @returns the current zOffset state
  27577. */
  27578. getZOffset(): number;
  27579. /**
  27580. * Enable or disable depth buffering
  27581. * @param enable defines the state to set
  27582. */
  27583. setDepthBuffer(enable: boolean): void;
  27584. /**
  27585. * Gets a boolean indicating if depth writing is enabled
  27586. * @returns the current depth writing state
  27587. */
  27588. getDepthWrite(): boolean;
  27589. /**
  27590. * Enable or disable depth writing
  27591. * @param enable defines the state to set
  27592. */
  27593. setDepthWrite(enable: boolean): void;
  27594. /**
  27595. * Enable or disable color writing
  27596. * @param enable defines the state to set
  27597. */
  27598. setColorWrite(enable: boolean): void;
  27599. /**
  27600. * Gets a boolean indicating if color writing is enabled
  27601. * @returns the current color writing state
  27602. */
  27603. getColorWrite(): boolean;
  27604. /**
  27605. * Sets alpha constants used by some alpha blending modes
  27606. * @param r defines the red component
  27607. * @param g defines the green component
  27608. * @param b defines the blue component
  27609. * @param a defines the alpha component
  27610. */
  27611. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  27612. /**
  27613. * Sets the current alpha mode
  27614. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  27615. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  27616. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27617. */
  27618. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  27619. /**
  27620. * Gets the current alpha mode
  27621. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27622. * @returns the current alpha mode
  27623. */
  27624. getAlphaMode(): number;
  27625. /**
  27626. * Clears the list of texture accessible through engine.
  27627. * This can help preventing texture load conflict due to name collision.
  27628. */
  27629. clearInternalTexturesCache(): void;
  27630. /**
  27631. * Force the entire cache to be cleared
  27632. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  27633. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  27634. */
  27635. wipeCaches(bruteForce?: boolean): void;
  27636. /**
  27637. * Set the compressed texture format to use, based on the formats you have, and the formats
  27638. * supported by the hardware / browser.
  27639. *
  27640. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  27641. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  27642. * to API arguments needed to compressed textures. This puts the burden on the container
  27643. * generator to house the arcane code for determining these for current & future formats.
  27644. *
  27645. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27646. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27647. *
  27648. * Note: The result of this call is not taken into account when a texture is base64.
  27649. *
  27650. * @param formatsAvailable defines the list of those format families you have created
  27651. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  27652. *
  27653. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  27654. * @returns The extension selected.
  27655. */
  27656. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  27657. private _getSamplingParameters;
  27658. private _partialLoadImg;
  27659. private _cascadeLoadImgs;
  27660. /** @hidden */
  27661. _createTexture(): WebGLTexture;
  27662. /**
  27663. * Usually called from Texture.ts.
  27664. * Passed information to create a WebGLTexture
  27665. * @param urlArg defines a value which contains one of the following:
  27666. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  27667. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  27668. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  27669. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  27670. * @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)
  27671. * @param scene needed for loading to the correct scene
  27672. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  27673. * @param onLoad optional callback to be called upon successful completion
  27674. * @param onError optional callback to be called upon failure
  27675. * @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
  27676. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  27677. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  27678. * @param forcedExtension defines the extension to use to pick the right loader
  27679. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  27680. * @returns a InternalTexture for assignment back into BABYLON.Texture
  27681. */
  27682. 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;
  27683. private _rescaleTexture;
  27684. /**
  27685. * Update a raw texture
  27686. * @param texture defines the texture to update
  27687. * @param data defines the data to store in the texture
  27688. * @param format defines the format of the data
  27689. * @param invertY defines if data must be stored with Y axis inverted
  27690. * @param compression defines the compression used (null by default)
  27691. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27692. */
  27693. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  27694. /**
  27695. * Creates a raw texture
  27696. * @param data defines the data to store in the texture
  27697. * @param width defines the width of the texture
  27698. * @param height defines the height of the texture
  27699. * @param format defines the format of the data
  27700. * @param generateMipMaps defines if the engine should generate the mip levels
  27701. * @param invertY defines if data must be stored with Y axis inverted
  27702. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27703. * @param compression defines the compression used (null by default)
  27704. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27705. * @returns the raw texture inside an InternalTexture
  27706. */
  27707. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  27708. private _unpackFlipYCached;
  27709. /**
  27710. * In case you are sharing the context with other applications, it might
  27711. * be interested to not cache the unpack flip y state to ensure a consistent
  27712. * value would be set.
  27713. */
  27714. enableUnpackFlipYCached: boolean;
  27715. /** @hidden */
  27716. _unpackFlipY(value: boolean): void;
  27717. /** @hidden */
  27718. _getUnpackAlignement(): number;
  27719. /**
  27720. * Creates a dynamic texture
  27721. * @param width defines the width of the texture
  27722. * @param height defines the height of the texture
  27723. * @param generateMipMaps defines if the engine should generate the mip levels
  27724. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27725. * @returns the dynamic texture inside an InternalTexture
  27726. */
  27727. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  27728. /**
  27729. * Update the sampling mode of a given texture
  27730. * @param samplingMode defines the required sampling mode
  27731. * @param texture defines the texture to update
  27732. */
  27733. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  27734. /**
  27735. * Update the content of a dynamic texture
  27736. * @param texture defines the texture to update
  27737. * @param canvas defines the canvas containing the source
  27738. * @param invertY defines if data must be stored with Y axis inverted
  27739. * @param premulAlpha defines if alpha is stored as premultiplied
  27740. * @param format defines the format of the data
  27741. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  27742. */
  27743. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  27744. /**
  27745. * Update a video texture
  27746. * @param texture defines the texture to update
  27747. * @param video defines the video element to use
  27748. * @param invertY defines if data must be stored with Y axis inverted
  27749. */
  27750. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  27751. /**
  27752. * Updates a depth texture Comparison Mode and Function.
  27753. * If the comparison Function is equal to 0, the mode will be set to none.
  27754. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  27755. * @param texture The texture to set the comparison function for
  27756. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  27757. */
  27758. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  27759. private _setupDepthStencilTexture;
  27760. /**
  27761. * Creates a depth stencil texture.
  27762. * This is only available in WebGL 2 or with the depth texture extension available.
  27763. * @param size The size of face edge in the texture.
  27764. * @param options The options defining the texture.
  27765. * @returns The texture
  27766. */
  27767. createDepthStencilTexture(size: number | {
  27768. width: number;
  27769. height: number;
  27770. }, options: DepthTextureCreationOptions): InternalTexture;
  27771. /**
  27772. * Creates a depth stencil texture.
  27773. * This is only available in WebGL 2 or with the depth texture extension available.
  27774. * @param size The size of face edge in the texture.
  27775. * @param options The options defining the texture.
  27776. * @returns The texture
  27777. */
  27778. private _createDepthStencilTexture;
  27779. /**
  27780. * Creates a depth stencil cube texture.
  27781. * This is only available in WebGL 2.
  27782. * @param size The size of face edge in the cube texture.
  27783. * @param options The options defining the cube texture.
  27784. * @returns The cube texture
  27785. */
  27786. private _createDepthStencilCubeTexture;
  27787. /**
  27788. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  27789. * @param renderTarget The render target to set the frame buffer for
  27790. */
  27791. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  27792. /**
  27793. * Creates a new render target texture
  27794. * @param size defines the size of the texture
  27795. * @param options defines the options used to create the texture
  27796. * @returns a new render target texture stored in an InternalTexture
  27797. */
  27798. createRenderTargetTexture(size: number | {
  27799. width: number;
  27800. height: number;
  27801. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  27802. /**
  27803. * Create a multi render target texture
  27804. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  27805. * @param size defines the size of the texture
  27806. * @param options defines the creation options
  27807. * @returns the cube texture as an InternalTexture
  27808. */
  27809. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  27810. private _setupFramebufferDepthAttachments;
  27811. /**
  27812. * Updates the sample count of a render target texture
  27813. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  27814. * @param texture defines the texture to update
  27815. * @param samples defines the sample count to set
  27816. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  27817. */
  27818. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  27819. /**
  27820. * Update the sample count for a given multiple render target texture
  27821. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  27822. * @param textures defines the textures to update
  27823. * @param samples defines the sample count to set
  27824. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  27825. */
  27826. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  27827. /** @hidden */
  27828. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27829. /** @hidden */
  27830. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27831. /** @hidden */
  27832. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27833. /** @hidden */
  27834. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  27835. /**
  27836. * Creates a new render target cube texture
  27837. * @param size defines the size of the texture
  27838. * @param options defines the options used to create the texture
  27839. * @returns a new render target cube texture stored in an InternalTexture
  27840. */
  27841. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  27842. /**
  27843. * Creates a cube texture
  27844. * @param rootUrl defines the url where the files to load is located
  27845. * @param scene defines the current scene
  27846. * @param files defines the list of files to load (1 per face)
  27847. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  27848. * @param onLoad defines an optional callback raised when the texture is loaded
  27849. * @param onError defines an optional callback raised if there is an issue to load the texture
  27850. * @param format defines the format of the data
  27851. * @param forcedExtension defines the extension to use to pick the right loader
  27852. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  27853. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  27854. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  27855. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  27856. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  27857. * @returns the cube texture as an InternalTexture
  27858. */
  27859. 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;
  27860. /**
  27861. * @hidden
  27862. */
  27863. _setCubeMapTextureParams(loadMipmap: boolean): void;
  27864. /**
  27865. * Update a raw cube texture
  27866. * @param texture defines the texture to udpdate
  27867. * @param data defines the data to store
  27868. * @param format defines the data format
  27869. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27870. * @param invertY defines if data must be stored with Y axis inverted
  27871. * @param compression defines the compression used (null by default)
  27872. * @param level defines which level of the texture to update
  27873. */
  27874. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  27875. /**
  27876. * Creates a new raw cube texture
  27877. * @param data defines the array of data to use to create each face
  27878. * @param size defines the size of the textures
  27879. * @param format defines the format of the data
  27880. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  27881. * @param generateMipMaps defines if the engine should generate the mip levels
  27882. * @param invertY defines if data must be stored with Y axis inverted
  27883. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27884. * @param compression defines the compression used (null by default)
  27885. * @returns the cube texture as an InternalTexture
  27886. */
  27887. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  27888. /**
  27889. * Creates a new raw cube texture from a specified url
  27890. * @param url defines the url where the data is located
  27891. * @param scene defines the current scene
  27892. * @param size defines the size of the textures
  27893. * @param format defines the format of the data
  27894. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  27895. * @param noMipmap defines if the engine should avoid generating the mip levels
  27896. * @param callback defines a callback used to extract texture data from loaded data
  27897. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  27898. * @param onLoad defines a callback called when texture is loaded
  27899. * @param onError defines a callback called if there is an error
  27900. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27901. * @param invertY defines if data must be stored with Y axis inverted
  27902. * @returns the cube texture as an InternalTexture
  27903. */
  27904. 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;
  27905. /**
  27906. * Update a raw 3D texture
  27907. * @param texture defines the texture to update
  27908. * @param data defines the data to store
  27909. * @param format defines the data format
  27910. * @param invertY defines if data must be stored with Y axis inverted
  27911. * @param compression defines the used compression (can be null)
  27912. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  27913. */
  27914. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  27915. /**
  27916. * Creates a new raw 3D texture
  27917. * @param data defines the data used to create the texture
  27918. * @param width defines the width of the texture
  27919. * @param height defines the height of the texture
  27920. * @param depth defines the depth of the texture
  27921. * @param format defines the format of the texture
  27922. * @param generateMipMaps defines if the engine must generate mip levels
  27923. * @param invertY defines if data must be stored with Y axis inverted
  27924. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27925. * @param compression defines the compressed used (can be null)
  27926. * @param textureType defines the compressed used (can be null)
  27927. * @returns a new raw 3D texture (stored in an InternalTexture)
  27928. */
  27929. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  27930. private _prepareWebGLTextureContinuation;
  27931. private _prepareWebGLTexture;
  27932. private _convertRGBtoRGBATextureData;
  27933. /** @hidden */
  27934. _releaseFramebufferObjects(texture: InternalTexture): void;
  27935. /** @hidden */
  27936. _releaseTexture(texture: InternalTexture): void;
  27937. private setProgram;
  27938. private _boundUniforms;
  27939. /**
  27940. * Binds an effect to the webGL context
  27941. * @param effect defines the effect to bind
  27942. */
  27943. bindSamplers(effect: Effect): void;
  27944. private _moveBoundTextureOnTop;
  27945. private _getCorrectTextureChannel;
  27946. private _linkTrackers;
  27947. private _removeDesignatedSlot;
  27948. private _activateCurrentTexture;
  27949. /** @hidden */
  27950. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  27951. /** @hidden */
  27952. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  27953. /**
  27954. * Sets a texture to the webGL context from a postprocess
  27955. * @param channel defines the channel to use
  27956. * @param postProcess defines the source postprocess
  27957. */
  27958. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  27959. /**
  27960. * Binds the output of the passed in post process to the texture channel specified
  27961. * @param channel The channel the texture should be bound to
  27962. * @param postProcess The post process which's output should be bound
  27963. */
  27964. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  27965. /**
  27966. * Unbind all textures from the webGL context
  27967. */
  27968. unbindAllTextures(): void;
  27969. /**
  27970. * Sets a texture to the according uniform.
  27971. * @param channel The texture channel
  27972. * @param uniform The uniform to set
  27973. * @param texture The texture to apply
  27974. */
  27975. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  27976. /**
  27977. * Sets a depth stencil texture from a render target to the according uniform.
  27978. * @param channel The texture channel
  27979. * @param uniform The uniform to set
  27980. * @param texture The render target texture containing the depth stencil texture to apply
  27981. */
  27982. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  27983. private _bindSamplerUniformToChannel;
  27984. private _getTextureWrapMode;
  27985. private _setTexture;
  27986. /**
  27987. * Sets an array of texture to the webGL context
  27988. * @param channel defines the channel where the texture array must be set
  27989. * @param uniform defines the associated uniform location
  27990. * @param textures defines the array of textures to bind
  27991. */
  27992. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  27993. /** @hidden */
  27994. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  27995. private _setTextureParameterFloat;
  27996. private _setTextureParameterInteger;
  27997. /**
  27998. * Reads pixels from the current frame buffer. Please note that this function can be slow
  27999. * @param x defines the x coordinate of the rectangle where pixels must be read
  28000. * @param y defines the y coordinate of the rectangle where pixels must be read
  28001. * @param width defines the width of the rectangle where pixels must be read
  28002. * @param height defines the height of the rectangle where pixels must be read
  28003. * @returns a Uint8Array containing RGBA colors
  28004. */
  28005. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28006. /**
  28007. * Add an externaly attached data from its key.
  28008. * This method call will fail and return false, if such key already exists.
  28009. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28010. * @param key the unique key that identifies the data
  28011. * @param data the data object to associate to the key for this Engine instance
  28012. * @return true if no such key were already present and the data was added successfully, false otherwise
  28013. */
  28014. addExternalData<T>(key: string, data: T): boolean;
  28015. /**
  28016. * Get an externaly attached data from its key
  28017. * @param key the unique key that identifies the data
  28018. * @return the associated data, if present (can be null), or undefined if not present
  28019. */
  28020. getExternalData<T>(key: string): T;
  28021. /**
  28022. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28023. * @param key the unique key that identifies the data
  28024. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28025. * @return the associated data, can be null if the factory returned null.
  28026. */
  28027. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28028. /**
  28029. * Remove an externaly attached data from the Engine instance
  28030. * @param key the unique key that identifies the data
  28031. * @return true if the data was successfully removed, false if it doesn't exist
  28032. */
  28033. removeExternalData(key: string): boolean;
  28034. /**
  28035. * Unbind all vertex attributes from the webGL context
  28036. */
  28037. unbindAllAttributes(): void;
  28038. /**
  28039. * 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
  28040. */
  28041. releaseEffects(): void;
  28042. /**
  28043. * Dispose and release all associated resources
  28044. */
  28045. dispose(): void;
  28046. /**
  28047. * Display the loading screen
  28048. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28049. */
  28050. displayLoadingUI(): void;
  28051. /**
  28052. * Hide the loading screen
  28053. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28054. */
  28055. hideLoadingUI(): void;
  28056. /**
  28057. * Gets the current loading screen object
  28058. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28059. */
  28060. /**
  28061. * Sets the current loading screen object
  28062. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28063. */
  28064. loadingScreen: ILoadingScreen;
  28065. /**
  28066. * Sets the current loading screen text
  28067. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28068. */
  28069. loadingUIText: string;
  28070. /**
  28071. * Sets the current loading screen background color
  28072. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28073. */
  28074. loadingUIBackgroundColor: string;
  28075. /**
  28076. * Attach a new callback raised when context lost event is fired
  28077. * @param callback defines the callback to call
  28078. */
  28079. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28080. /**
  28081. * Attach a new callback raised when context restored event is fired
  28082. * @param callback defines the callback to call
  28083. */
  28084. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28085. /**
  28086. * Gets the source code of the vertex shader associated with a specific webGL program
  28087. * @param program defines the program to use
  28088. * @returns a string containing the source code of the vertex shader associated with the program
  28089. */
  28090. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28091. /**
  28092. * Gets the source code of the fragment shader associated with a specific webGL program
  28093. * @param program defines the program to use
  28094. * @returns a string containing the source code of the fragment shader associated with the program
  28095. */
  28096. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28097. /**
  28098. * Get the current error code of the webGL context
  28099. * @returns the error code
  28100. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28101. */
  28102. getError(): number;
  28103. /**
  28104. * Gets the current framerate
  28105. * @returns a number representing the framerate
  28106. */
  28107. getFps(): number;
  28108. /**
  28109. * Gets the time spent between current and previous frame
  28110. * @returns a number representing the delta time in ms
  28111. */
  28112. getDeltaTime(): number;
  28113. private _measureFps;
  28114. /** @hidden */
  28115. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28116. private _canRenderToFloatFramebuffer;
  28117. private _canRenderToHalfFloatFramebuffer;
  28118. private _canRenderToFramebuffer;
  28119. /** @hidden */
  28120. _getWebGLTextureType(type: number): number;
  28121. private _getInternalFormat;
  28122. /** @hidden */
  28123. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28124. /** @hidden */
  28125. _getRGBAMultiSampleBufferFormat(type: number): number;
  28126. /** @hidden */
  28127. _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;
  28128. /** @hidden */
  28129. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28130. private _partialLoadFile;
  28131. private _cascadeLoadFiles;
  28132. /**
  28133. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28134. * @returns true if the engine can be created
  28135. * @ignorenaming
  28136. */
  28137. static isSupported(): boolean;
  28138. }
  28139. }
  28140. declare module BABYLON {
  28141. /**
  28142. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28143. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28144. */
  28145. export class EffectFallbacks {
  28146. private _defines;
  28147. private _currentRank;
  28148. private _maxRank;
  28149. private _mesh;
  28150. /**
  28151. * Removes the fallback from the bound mesh.
  28152. */
  28153. unBindMesh(): void;
  28154. /**
  28155. * Adds a fallback on the specified property.
  28156. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28157. * @param define The name of the define in the shader
  28158. */
  28159. addFallback(rank: number, define: string): void;
  28160. /**
  28161. * Sets the mesh to use CPU skinning when needing to fallback.
  28162. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28163. * @param mesh The mesh to use the fallbacks.
  28164. */
  28165. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28166. /**
  28167. * Checks to see if more fallbacks are still availible.
  28168. */
  28169. readonly isMoreFallbacks: boolean;
  28170. /**
  28171. * Removes the defines that shoould be removed when falling back.
  28172. * @param currentDefines defines the current define statements for the shader.
  28173. * @param effect defines the current effect we try to compile
  28174. * @returns The resulting defines with defines of the current rank removed.
  28175. */
  28176. reduce(currentDefines: string, effect: Effect): string;
  28177. }
  28178. /**
  28179. * Options to be used when creating an effect.
  28180. */
  28181. export class EffectCreationOptions {
  28182. /**
  28183. * Atrributes that will be used in the shader.
  28184. */
  28185. attributes: string[];
  28186. /**
  28187. * Uniform varible names that will be set in the shader.
  28188. */
  28189. uniformsNames: string[];
  28190. /**
  28191. * Uniform buffer varible names that will be set in the shader.
  28192. */
  28193. uniformBuffersNames: string[];
  28194. /**
  28195. * Sampler texture variable names that will be set in the shader.
  28196. */
  28197. samplers: string[];
  28198. /**
  28199. * Define statements that will be set in the shader.
  28200. */
  28201. defines: any;
  28202. /**
  28203. * Possible fallbacks for this effect to improve performance when needed.
  28204. */
  28205. fallbacks: Nullable<EffectFallbacks>;
  28206. /**
  28207. * Callback that will be called when the shader is compiled.
  28208. */
  28209. onCompiled: Nullable<(effect: Effect) => void>;
  28210. /**
  28211. * Callback that will be called if an error occurs during shader compilation.
  28212. */
  28213. onError: Nullable<(effect: Effect, errors: string) => void>;
  28214. /**
  28215. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28216. */
  28217. indexParameters: any;
  28218. /**
  28219. * Max number of lights that can be used in the shader.
  28220. */
  28221. maxSimultaneousLights: number;
  28222. /**
  28223. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28224. */
  28225. transformFeedbackVaryings: Nullable<string[]>;
  28226. }
  28227. /**
  28228. * Effect containing vertex and fragment shader that can be executed on an object.
  28229. */
  28230. export class Effect {
  28231. /**
  28232. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28233. */
  28234. static ShadersRepository: string;
  28235. /**
  28236. * Name of the effect.
  28237. */
  28238. name: any;
  28239. /**
  28240. * String container all the define statements that should be set on the shader.
  28241. */
  28242. defines: string;
  28243. /**
  28244. * Callback that will be called when the shader is compiled.
  28245. */
  28246. onCompiled: Nullable<(effect: Effect) => void>;
  28247. /**
  28248. * Callback that will be called if an error occurs during shader compilation.
  28249. */
  28250. onError: Nullable<(effect: Effect, errors: string) => void>;
  28251. /**
  28252. * Callback that will be called when effect is bound.
  28253. */
  28254. onBind: Nullable<(effect: Effect) => void>;
  28255. /**
  28256. * Unique ID of the effect.
  28257. */
  28258. uniqueId: number;
  28259. /**
  28260. * Observable that will be called when the shader is compiled.
  28261. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28262. */
  28263. onCompileObservable: Observable<Effect>;
  28264. /**
  28265. * Observable that will be called if an error occurs during shader compilation.
  28266. */
  28267. onErrorObservable: Observable<Effect>;
  28268. /** @hidden */
  28269. _onBindObservable: Nullable<Observable<Effect>>;
  28270. /**
  28271. * Observable that will be called when effect is bound.
  28272. */
  28273. readonly onBindObservable: Observable<Effect>;
  28274. /** @hidden */
  28275. _bonesComputationForcedToCPU: boolean;
  28276. private static _uniqueIdSeed;
  28277. private _engine;
  28278. private _uniformBuffersNames;
  28279. private _uniformsNames;
  28280. private _samplers;
  28281. private _isReady;
  28282. private _compilationError;
  28283. private _attributesNames;
  28284. private _attributes;
  28285. private _uniforms;
  28286. /**
  28287. * Key for the effect.
  28288. * @hidden
  28289. */
  28290. _key: string;
  28291. private _indexParameters;
  28292. private _fallbacks;
  28293. private _vertexSourceCode;
  28294. private _fragmentSourceCode;
  28295. private _vertexSourceCodeOverride;
  28296. private _fragmentSourceCodeOverride;
  28297. private _transformFeedbackVaryings;
  28298. /**
  28299. * Compiled shader to webGL program.
  28300. * @hidden
  28301. */
  28302. _program: WebGLProgram;
  28303. private _valueCache;
  28304. private static _baseCache;
  28305. /**
  28306. * Instantiates an effect.
  28307. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28308. * @param baseName Name of the effect.
  28309. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28310. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28311. * @param samplers List of sampler variables that will be passed to the shader.
  28312. * @param engine Engine to be used to render the effect
  28313. * @param defines Define statements to be added to the shader.
  28314. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28315. * @param onCompiled Callback that will be called when the shader is compiled.
  28316. * @param onError Callback that will be called if an error occurs during shader compilation.
  28317. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28318. */
  28319. 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);
  28320. /**
  28321. * Unique key for this effect
  28322. */
  28323. readonly key: string;
  28324. /**
  28325. * If the effect has been compiled and prepared.
  28326. * @returns if the effect is compiled and prepared.
  28327. */
  28328. isReady(): boolean;
  28329. /**
  28330. * The engine the effect was initialized with.
  28331. * @returns the engine.
  28332. */
  28333. getEngine(): Engine;
  28334. /**
  28335. * The compiled webGL program for the effect
  28336. * @returns the webGL program.
  28337. */
  28338. getProgram(): WebGLProgram;
  28339. /**
  28340. * The set of names of attribute variables for the shader.
  28341. * @returns An array of attribute names.
  28342. */
  28343. getAttributesNames(): string[];
  28344. /**
  28345. * Returns the attribute at the given index.
  28346. * @param index The index of the attribute.
  28347. * @returns The location of the attribute.
  28348. */
  28349. getAttributeLocation(index: number): number;
  28350. /**
  28351. * Returns the attribute based on the name of the variable.
  28352. * @param name of the attribute to look up.
  28353. * @returns the attribute location.
  28354. */
  28355. getAttributeLocationByName(name: string): number;
  28356. /**
  28357. * The number of attributes.
  28358. * @returns the numnber of attributes.
  28359. */
  28360. getAttributesCount(): number;
  28361. /**
  28362. * Gets the index of a uniform variable.
  28363. * @param uniformName of the uniform to look up.
  28364. * @returns the index.
  28365. */
  28366. getUniformIndex(uniformName: string): number;
  28367. /**
  28368. * Returns the attribute based on the name of the variable.
  28369. * @param uniformName of the uniform to look up.
  28370. * @returns the location of the uniform.
  28371. */
  28372. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28373. /**
  28374. * Returns an array of sampler variable names
  28375. * @returns The array of sampler variable neames.
  28376. */
  28377. getSamplers(): string[];
  28378. /**
  28379. * The error from the last compilation.
  28380. * @returns the error string.
  28381. */
  28382. getCompilationError(): string;
  28383. /**
  28384. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28385. * @param func The callback to be used.
  28386. */
  28387. executeWhenCompiled(func: (effect: Effect) => void): void;
  28388. private _checkIsReady;
  28389. /** @hidden */
  28390. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28391. /** @hidden */
  28392. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28393. /** @hidden */
  28394. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28395. private _processShaderConversion;
  28396. private _processIncludes;
  28397. private _processPrecision;
  28398. /**
  28399. * Recompiles the webGL program
  28400. * @param vertexSourceCode The source code for the vertex shader.
  28401. * @param fragmentSourceCode The source code for the fragment shader.
  28402. * @param onCompiled Callback called when completed.
  28403. * @param onError Callback called on error.
  28404. * @hidden
  28405. */
  28406. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  28407. /**
  28408. * Gets the uniform locations of the the specified variable names
  28409. * @param names THe names of the variables to lookup.
  28410. * @returns Array of locations in the same order as variable names.
  28411. */
  28412. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  28413. /**
  28414. * Prepares the effect
  28415. * @hidden
  28416. */
  28417. _prepareEffect(): void;
  28418. /**
  28419. * Checks if the effect is supported. (Must be called after compilation)
  28420. */
  28421. readonly isSupported: boolean;
  28422. /**
  28423. * Binds a texture to the engine to be used as output of the shader.
  28424. * @param channel Name of the output variable.
  28425. * @param texture Texture to bind.
  28426. * @hidden
  28427. */
  28428. _bindTexture(channel: string, texture: InternalTexture): void;
  28429. /**
  28430. * Sets a texture on the engine to be used in the shader.
  28431. * @param channel Name of the sampler variable.
  28432. * @param texture Texture to set.
  28433. */
  28434. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28435. /**
  28436. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28437. * @param channel Name of the sampler variable.
  28438. * @param texture Texture to set.
  28439. */
  28440. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28441. /**
  28442. * Sets an array of textures on the engine to be used in the shader.
  28443. * @param channel Name of the variable.
  28444. * @param textures Textures to set.
  28445. */
  28446. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28447. /**
  28448. * 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)
  28449. * @param channel Name of the sampler variable.
  28450. * @param postProcess Post process to get the input texture from.
  28451. */
  28452. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28453. /**
  28454. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28455. * 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)
  28456. * @param channel Name of the sampler variable.
  28457. * @param postProcess Post process to get the output texture from.
  28458. */
  28459. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28460. /** @hidden */
  28461. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28462. /** @hidden */
  28463. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28464. /** @hidden */
  28465. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28466. /** @hidden */
  28467. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28468. /**
  28469. * Binds a buffer to a uniform.
  28470. * @param buffer Buffer to bind.
  28471. * @param name Name of the uniform variable to bind to.
  28472. */
  28473. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  28474. /**
  28475. * Binds block to a uniform.
  28476. * @param blockName Name of the block to bind.
  28477. * @param index Index to bind.
  28478. */
  28479. bindUniformBlock(blockName: string, index: number): void;
  28480. /**
  28481. * Sets an interger value on a uniform variable.
  28482. * @param uniformName Name of the variable.
  28483. * @param value Value to be set.
  28484. * @returns this effect.
  28485. */
  28486. setInt(uniformName: string, value: number): Effect;
  28487. /**
  28488. * Sets an int array on a uniform variable.
  28489. * @param uniformName Name of the variable.
  28490. * @param array array to be set.
  28491. * @returns this effect.
  28492. */
  28493. setIntArray(uniformName: string, array: Int32Array): Effect;
  28494. /**
  28495. * 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)
  28496. * @param uniformName Name of the variable.
  28497. * @param array array to be set.
  28498. * @returns this effect.
  28499. */
  28500. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28501. /**
  28502. * 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)
  28503. * @param uniformName Name of the variable.
  28504. * @param array array to be set.
  28505. * @returns this effect.
  28506. */
  28507. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28508. /**
  28509. * 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)
  28510. * @param uniformName Name of the variable.
  28511. * @param array array to be set.
  28512. * @returns this effect.
  28513. */
  28514. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28515. /**
  28516. * Sets an float array on a uniform variable.
  28517. * @param uniformName Name of the variable.
  28518. * @param array array to be set.
  28519. * @returns this effect.
  28520. */
  28521. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28522. /**
  28523. * 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)
  28524. * @param uniformName Name of the variable.
  28525. * @param array array to be set.
  28526. * @returns this effect.
  28527. */
  28528. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28529. /**
  28530. * 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)
  28531. * @param uniformName Name of the variable.
  28532. * @param array array to be set.
  28533. * @returns this effect.
  28534. */
  28535. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28536. /**
  28537. * 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)
  28538. * @param uniformName Name of the variable.
  28539. * @param array array to be set.
  28540. * @returns this effect.
  28541. */
  28542. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28543. /**
  28544. * Sets an array on a uniform variable.
  28545. * @param uniformName Name of the variable.
  28546. * @param array array to be set.
  28547. * @returns this effect.
  28548. */
  28549. setArray(uniformName: string, array: number[]): Effect;
  28550. /**
  28551. * 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)
  28552. * @param uniformName Name of the variable.
  28553. * @param array array to be set.
  28554. * @returns this effect.
  28555. */
  28556. setArray2(uniformName: string, array: number[]): Effect;
  28557. /**
  28558. * 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)
  28559. * @param uniformName Name of the variable.
  28560. * @param array array to be set.
  28561. * @returns this effect.
  28562. */
  28563. setArray3(uniformName: string, array: number[]): Effect;
  28564. /**
  28565. * 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)
  28566. * @param uniformName Name of the variable.
  28567. * @param array array to be set.
  28568. * @returns this effect.
  28569. */
  28570. setArray4(uniformName: string, array: number[]): Effect;
  28571. /**
  28572. * Sets matrices on a uniform variable.
  28573. * @param uniformName Name of the variable.
  28574. * @param matrices matrices to be set.
  28575. * @returns this effect.
  28576. */
  28577. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28578. /**
  28579. * Sets matrix on a uniform variable.
  28580. * @param uniformName Name of the variable.
  28581. * @param matrix matrix to be set.
  28582. * @returns this effect.
  28583. */
  28584. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28585. /**
  28586. * 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)
  28587. * @param uniformName Name of the variable.
  28588. * @param matrix matrix to be set.
  28589. * @returns this effect.
  28590. */
  28591. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28592. /**
  28593. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28594. * @param uniformName Name of the variable.
  28595. * @param matrix matrix to be set.
  28596. * @returns this effect.
  28597. */
  28598. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28599. /**
  28600. * Sets a float on a uniform variable.
  28601. * @param uniformName Name of the variable.
  28602. * @param value value to be set.
  28603. * @returns this effect.
  28604. */
  28605. setFloat(uniformName: string, value: number): Effect;
  28606. /**
  28607. * Sets a boolean on a uniform variable.
  28608. * @param uniformName Name of the variable.
  28609. * @param bool value to be set.
  28610. * @returns this effect.
  28611. */
  28612. setBool(uniformName: string, bool: boolean): Effect;
  28613. /**
  28614. * Sets a Vector2 on a uniform variable.
  28615. * @param uniformName Name of the variable.
  28616. * @param vector2 vector2 to be set.
  28617. * @returns this effect.
  28618. */
  28619. setVector2(uniformName: string, vector2: Vector2): Effect;
  28620. /**
  28621. * Sets a float2 on a uniform variable.
  28622. * @param uniformName Name of the variable.
  28623. * @param x First float in float2.
  28624. * @param y Second float in float2.
  28625. * @returns this effect.
  28626. */
  28627. setFloat2(uniformName: string, x: number, y: number): Effect;
  28628. /**
  28629. * Sets a Vector3 on a uniform variable.
  28630. * @param uniformName Name of the variable.
  28631. * @param vector3 Value to be set.
  28632. * @returns this effect.
  28633. */
  28634. setVector3(uniformName: string, vector3: Vector3): Effect;
  28635. /**
  28636. * Sets a float3 on a uniform variable.
  28637. * @param uniformName Name of the variable.
  28638. * @param x First float in float3.
  28639. * @param y Second float in float3.
  28640. * @param z Third float in float3.
  28641. * @returns this effect.
  28642. */
  28643. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28644. /**
  28645. * Sets a Vector4 on a uniform variable.
  28646. * @param uniformName Name of the variable.
  28647. * @param vector4 Value to be set.
  28648. * @returns this effect.
  28649. */
  28650. setVector4(uniformName: string, vector4: Vector4): Effect;
  28651. /**
  28652. * Sets a float4 on a uniform variable.
  28653. * @param uniformName Name of the variable.
  28654. * @param x First float in float4.
  28655. * @param y Second float in float4.
  28656. * @param z Third float in float4.
  28657. * @param w Fourth float in float4.
  28658. * @returns this effect.
  28659. */
  28660. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28661. /**
  28662. * Sets a Color3 on a uniform variable.
  28663. * @param uniformName Name of the variable.
  28664. * @param color3 Value to be set.
  28665. * @returns this effect.
  28666. */
  28667. setColor3(uniformName: string, color3: Color3): Effect;
  28668. /**
  28669. * Sets a Color4 on a uniform variable.
  28670. * @param uniformName Name of the variable.
  28671. * @param color3 Value to be set.
  28672. * @param alpha Alpha value to be set.
  28673. * @returns this effect.
  28674. */
  28675. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28676. /**
  28677. * Sets a Color4 on a uniform variable
  28678. * @param uniformName defines the name of the variable
  28679. * @param color4 defines the value to be set
  28680. * @returns this effect.
  28681. */
  28682. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28683. /**
  28684. * This function will add a new shader to the shader store
  28685. * @param name the name of the shader
  28686. * @param pixelShader optional pixel shader content
  28687. * @param vertexShader optional vertex shader content
  28688. */
  28689. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28690. /**
  28691. * Store of each shader (The can be looked up using effect.key)
  28692. */
  28693. static ShadersStore: {
  28694. [key: string]: string;
  28695. };
  28696. /**
  28697. * Store of each included file for a shader (The can be looked up using effect.key)
  28698. */
  28699. static IncludesShadersStore: {
  28700. [key: string]: string;
  28701. };
  28702. /**
  28703. * Resets the cache of effects.
  28704. */
  28705. static ResetCache(): void;
  28706. }
  28707. }
  28708. declare module BABYLON {
  28709. /**
  28710. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28711. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28712. * 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;
  28713. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28714. */
  28715. export class ColorCurves {
  28716. private _dirty;
  28717. private _tempColor;
  28718. private _globalCurve;
  28719. private _highlightsCurve;
  28720. private _midtonesCurve;
  28721. private _shadowsCurve;
  28722. private _positiveCurve;
  28723. private _negativeCurve;
  28724. private _globalHue;
  28725. private _globalDensity;
  28726. private _globalSaturation;
  28727. private _globalExposure;
  28728. /**
  28729. * Gets the global Hue value.
  28730. * 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).
  28731. */
  28732. /**
  28733. * Sets the global Hue value.
  28734. * 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).
  28735. */
  28736. globalHue: number;
  28737. /**
  28738. * Gets the global Density value.
  28739. * 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.
  28740. * Values less than zero provide a filter of opposite hue.
  28741. */
  28742. /**
  28743. * Sets the global Density value.
  28744. * 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.
  28745. * Values less than zero provide a filter of opposite hue.
  28746. */
  28747. globalDensity: number;
  28748. /**
  28749. * Gets the global Saturation value.
  28750. * 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.
  28751. */
  28752. /**
  28753. * Sets the global Saturation value.
  28754. * 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.
  28755. */
  28756. globalSaturation: number;
  28757. /**
  28758. * Gets the global Exposure value.
  28759. * 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.
  28760. */
  28761. /**
  28762. * Sets the global Exposure value.
  28763. * 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.
  28764. */
  28765. globalExposure: number;
  28766. private _highlightsHue;
  28767. private _highlightsDensity;
  28768. private _highlightsSaturation;
  28769. private _highlightsExposure;
  28770. /**
  28771. * Gets the highlights Hue value.
  28772. * 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).
  28773. */
  28774. /**
  28775. * Sets the highlights Hue value.
  28776. * 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).
  28777. */
  28778. highlightsHue: number;
  28779. /**
  28780. * Gets the highlights Density value.
  28781. * 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.
  28782. * Values less than zero provide a filter of opposite hue.
  28783. */
  28784. /**
  28785. * Sets the highlights Density value.
  28786. * 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.
  28787. * Values less than zero provide a filter of opposite hue.
  28788. */
  28789. highlightsDensity: number;
  28790. /**
  28791. * Gets the highlights Saturation value.
  28792. * 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.
  28793. */
  28794. /**
  28795. * Sets the highlights Saturation value.
  28796. * 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.
  28797. */
  28798. highlightsSaturation: number;
  28799. /**
  28800. * Gets the highlights Exposure value.
  28801. * 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.
  28802. */
  28803. /**
  28804. * Sets the highlights Exposure value.
  28805. * 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.
  28806. */
  28807. highlightsExposure: number;
  28808. private _midtonesHue;
  28809. private _midtonesDensity;
  28810. private _midtonesSaturation;
  28811. private _midtonesExposure;
  28812. /**
  28813. * Gets the midtones Hue value.
  28814. * 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).
  28815. */
  28816. /**
  28817. * Sets the midtones Hue value.
  28818. * 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).
  28819. */
  28820. midtonesHue: number;
  28821. /**
  28822. * Gets the midtones Density value.
  28823. * 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.
  28824. * Values less than zero provide a filter of opposite hue.
  28825. */
  28826. /**
  28827. * Sets the midtones Density value.
  28828. * 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.
  28829. * Values less than zero provide a filter of opposite hue.
  28830. */
  28831. midtonesDensity: number;
  28832. /**
  28833. * Gets the midtones Saturation value.
  28834. * 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.
  28835. */
  28836. /**
  28837. * Sets the midtones Saturation value.
  28838. * 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.
  28839. */
  28840. midtonesSaturation: number;
  28841. /**
  28842. * Gets the midtones Exposure value.
  28843. * 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.
  28844. */
  28845. /**
  28846. * Sets the midtones Exposure value.
  28847. * 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.
  28848. */
  28849. midtonesExposure: number;
  28850. private _shadowsHue;
  28851. private _shadowsDensity;
  28852. private _shadowsSaturation;
  28853. private _shadowsExposure;
  28854. /**
  28855. * Gets the shadows Hue value.
  28856. * 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).
  28857. */
  28858. /**
  28859. * Sets the shadows Hue value.
  28860. * 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).
  28861. */
  28862. shadowsHue: number;
  28863. /**
  28864. * Gets the shadows Density value.
  28865. * 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.
  28866. * Values less than zero provide a filter of opposite hue.
  28867. */
  28868. /**
  28869. * Sets the shadows Density value.
  28870. * 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.
  28871. * Values less than zero provide a filter of opposite hue.
  28872. */
  28873. shadowsDensity: number;
  28874. /**
  28875. * Gets the shadows Saturation value.
  28876. * 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.
  28877. */
  28878. /**
  28879. * Sets the shadows Saturation value.
  28880. * 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.
  28881. */
  28882. shadowsSaturation: number;
  28883. /**
  28884. * Gets the shadows Exposure value.
  28885. * 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.
  28886. */
  28887. /**
  28888. * Sets the shadows Exposure value.
  28889. * 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.
  28890. */
  28891. shadowsExposure: number;
  28892. /**
  28893. * Returns the class name
  28894. * @returns The class name
  28895. */
  28896. getClassName(): string;
  28897. /**
  28898. * Binds the color curves to the shader.
  28899. * @param colorCurves The color curve to bind
  28900. * @param effect The effect to bind to
  28901. * @param positiveUniform The positive uniform shader parameter
  28902. * @param neutralUniform The neutral uniform shader parameter
  28903. * @param negativeUniform The negative uniform shader parameter
  28904. */
  28905. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  28906. /**
  28907. * Prepare the list of uniforms associated with the ColorCurves effects.
  28908. * @param uniformsList The list of uniforms used in the effect
  28909. */
  28910. static PrepareUniforms(uniformsList: string[]): void;
  28911. /**
  28912. * Returns color grading data based on a hue, density, saturation and exposure value.
  28913. * @param filterHue The hue of the color filter.
  28914. * @param filterDensity The density of the color filter.
  28915. * @param saturation The saturation.
  28916. * @param exposure The exposure.
  28917. * @param result The result data container.
  28918. */
  28919. private getColorGradingDataToRef;
  28920. /**
  28921. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  28922. * @param value The input slider value in range [-100,100].
  28923. * @returns Adjusted value.
  28924. */
  28925. private static applyColorGradingSliderNonlinear;
  28926. /**
  28927. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  28928. * @param hue The hue (H) input.
  28929. * @param saturation The saturation (S) input.
  28930. * @param brightness The brightness (B) input.
  28931. * @result An RGBA color represented as Vector4.
  28932. */
  28933. private static fromHSBToRef;
  28934. /**
  28935. * Returns a value clamped between min and max
  28936. * @param value The value to clamp
  28937. * @param min The minimum of value
  28938. * @param max The maximum of value
  28939. * @returns The clamped value.
  28940. */
  28941. private static clamp;
  28942. /**
  28943. * Clones the current color curve instance.
  28944. * @return The cloned curves
  28945. */
  28946. clone(): ColorCurves;
  28947. /**
  28948. * Serializes the current color curve instance to a json representation.
  28949. * @return a JSON representation
  28950. */
  28951. serialize(): any;
  28952. /**
  28953. * Parses the color curve from a json representation.
  28954. * @param source the JSON source to parse
  28955. * @return The parsed curves
  28956. */
  28957. static Parse(source: any): ColorCurves;
  28958. }
  28959. }
  28960. declare module BABYLON {
  28961. /**
  28962. * Interface to follow in your material defines to integrate easily the
  28963. * Image proccessing functions.
  28964. * @hidden
  28965. */
  28966. export interface IImageProcessingConfigurationDefines {
  28967. IMAGEPROCESSING: boolean;
  28968. VIGNETTE: boolean;
  28969. VIGNETTEBLENDMODEMULTIPLY: boolean;
  28970. VIGNETTEBLENDMODEOPAQUE: boolean;
  28971. TONEMAPPING: boolean;
  28972. TONEMAPPING_ACES: boolean;
  28973. CONTRAST: boolean;
  28974. EXPOSURE: boolean;
  28975. COLORCURVES: boolean;
  28976. COLORGRADING: boolean;
  28977. COLORGRADING3D: boolean;
  28978. SAMPLER3DGREENDEPTH: boolean;
  28979. SAMPLER3DBGRMAP: boolean;
  28980. IMAGEPROCESSINGPOSTPROCESS: boolean;
  28981. }
  28982. /**
  28983. * @hidden
  28984. */
  28985. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  28986. IMAGEPROCESSING: boolean;
  28987. VIGNETTE: boolean;
  28988. VIGNETTEBLENDMODEMULTIPLY: boolean;
  28989. VIGNETTEBLENDMODEOPAQUE: boolean;
  28990. TONEMAPPING: boolean;
  28991. TONEMAPPING_ACES: boolean;
  28992. CONTRAST: boolean;
  28993. COLORCURVES: boolean;
  28994. COLORGRADING: boolean;
  28995. COLORGRADING3D: boolean;
  28996. SAMPLER3DGREENDEPTH: boolean;
  28997. SAMPLER3DBGRMAP: boolean;
  28998. IMAGEPROCESSINGPOSTPROCESS: boolean;
  28999. EXPOSURE: boolean;
  29000. constructor();
  29001. }
  29002. /**
  29003. * This groups together the common properties used for image processing either in direct forward pass
  29004. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29005. * or not.
  29006. */
  29007. export class ImageProcessingConfiguration {
  29008. /**
  29009. * Default tone mapping applied in BabylonJS.
  29010. */
  29011. static readonly TONEMAPPING_STANDARD: number;
  29012. /**
  29013. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29014. * to other engines rendering to increase portability.
  29015. */
  29016. static readonly TONEMAPPING_ACES: number;
  29017. /**
  29018. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29019. */
  29020. colorCurves: Nullable<ColorCurves>;
  29021. private _colorCurvesEnabled;
  29022. /**
  29023. * Gets wether the color curves effect is enabled.
  29024. */
  29025. /**
  29026. * Sets wether the color curves effect is enabled.
  29027. */
  29028. colorCurvesEnabled: boolean;
  29029. private _colorGradingTexture;
  29030. /**
  29031. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29032. */
  29033. /**
  29034. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29035. */
  29036. colorGradingTexture: Nullable<BaseTexture>;
  29037. private _colorGradingEnabled;
  29038. /**
  29039. * Gets wether the color grading effect is enabled.
  29040. */
  29041. /**
  29042. * Sets wether the color grading effect is enabled.
  29043. */
  29044. colorGradingEnabled: boolean;
  29045. private _colorGradingWithGreenDepth;
  29046. /**
  29047. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29048. */
  29049. /**
  29050. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29051. */
  29052. colorGradingWithGreenDepth: boolean;
  29053. private _colorGradingBGR;
  29054. /**
  29055. * Gets wether the color grading texture contains BGR values.
  29056. */
  29057. /**
  29058. * Sets wether the color grading texture contains BGR values.
  29059. */
  29060. colorGradingBGR: boolean;
  29061. /** @hidden */
  29062. _exposure: number;
  29063. /**
  29064. * Gets the Exposure used in the effect.
  29065. */
  29066. /**
  29067. * Sets the Exposure used in the effect.
  29068. */
  29069. exposure: number;
  29070. private _toneMappingEnabled;
  29071. /**
  29072. * Gets wether the tone mapping effect is enabled.
  29073. */
  29074. /**
  29075. * Sets wether the tone mapping effect is enabled.
  29076. */
  29077. toneMappingEnabled: boolean;
  29078. private _toneMappingType;
  29079. /**
  29080. * Gets the type of tone mapping effect.
  29081. */
  29082. /**
  29083. * Sets the type of tone mapping effect used in BabylonJS.
  29084. */
  29085. toneMappingType: number;
  29086. protected _contrast: number;
  29087. /**
  29088. * Gets the contrast used in the effect.
  29089. */
  29090. /**
  29091. * Sets the contrast used in the effect.
  29092. */
  29093. contrast: number;
  29094. /**
  29095. * Vignette stretch size.
  29096. */
  29097. vignetteStretch: number;
  29098. /**
  29099. * Vignette centre X Offset.
  29100. */
  29101. vignetteCentreX: number;
  29102. /**
  29103. * Vignette centre Y Offset.
  29104. */
  29105. vignetteCentreY: number;
  29106. /**
  29107. * Vignette weight or intensity of the vignette effect.
  29108. */
  29109. vignetteWeight: number;
  29110. /**
  29111. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29112. * if vignetteEnabled is set to true.
  29113. */
  29114. vignetteColor: Color4;
  29115. /**
  29116. * Camera field of view used by the Vignette effect.
  29117. */
  29118. vignetteCameraFov: number;
  29119. private _vignetteBlendMode;
  29120. /**
  29121. * Gets the vignette blend mode allowing different kind of effect.
  29122. */
  29123. /**
  29124. * Sets the vignette blend mode allowing different kind of effect.
  29125. */
  29126. vignetteBlendMode: number;
  29127. private _vignetteEnabled;
  29128. /**
  29129. * Gets wether the vignette effect is enabled.
  29130. */
  29131. /**
  29132. * Sets wether the vignette effect is enabled.
  29133. */
  29134. vignetteEnabled: boolean;
  29135. private _applyByPostProcess;
  29136. /**
  29137. * Gets wether the image processing is applied through a post process or not.
  29138. */
  29139. /**
  29140. * Sets wether the image processing is applied through a post process or not.
  29141. */
  29142. applyByPostProcess: boolean;
  29143. private _isEnabled;
  29144. /**
  29145. * Gets wether the image processing is enabled or not.
  29146. */
  29147. /**
  29148. * Sets wether the image processing is enabled or not.
  29149. */
  29150. isEnabled: boolean;
  29151. /**
  29152. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29153. */
  29154. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29155. /**
  29156. * Method called each time the image processing information changes requires to recompile the effect.
  29157. */
  29158. protected _updateParameters(): void;
  29159. /**
  29160. * Gets the current class name.
  29161. * @return "ImageProcessingConfiguration"
  29162. */
  29163. getClassName(): string;
  29164. /**
  29165. * Prepare the list of uniforms associated with the Image Processing effects.
  29166. * @param uniforms The list of uniforms used in the effect
  29167. * @param defines the list of defines currently in use
  29168. */
  29169. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29170. /**
  29171. * Prepare the list of samplers associated with the Image Processing effects.
  29172. * @param samplersList The list of uniforms used in the effect
  29173. * @param defines the list of defines currently in use
  29174. */
  29175. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29176. /**
  29177. * Prepare the list of defines associated to the shader.
  29178. * @param defines the list of defines to complete
  29179. * @param forPostProcess Define if we are currently in post process mode or not
  29180. */
  29181. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29182. /**
  29183. * Returns true if all the image processing information are ready.
  29184. * @returns True if ready, otherwise, false
  29185. */
  29186. isReady(): boolean;
  29187. /**
  29188. * Binds the image processing to the shader.
  29189. * @param effect The effect to bind to
  29190. * @param aspectRatio Define the current aspect ratio of the effect
  29191. */
  29192. bind(effect: Effect, aspectRatio?: number): void;
  29193. /**
  29194. * Clones the current image processing instance.
  29195. * @return The cloned image processing
  29196. */
  29197. clone(): ImageProcessingConfiguration;
  29198. /**
  29199. * Serializes the current image processing instance to a json representation.
  29200. * @return a JSON representation
  29201. */
  29202. serialize(): any;
  29203. /**
  29204. * Parses the image processing from a json representation.
  29205. * @param source the JSON source to parse
  29206. * @return The parsed image processing
  29207. */
  29208. static Parse(source: any): ImageProcessingConfiguration;
  29209. private static _VIGNETTEMODE_MULTIPLY;
  29210. private static _VIGNETTEMODE_OPAQUE;
  29211. /**
  29212. * Used to apply the vignette as a mix with the pixel color.
  29213. */
  29214. static readonly VIGNETTEMODE_MULTIPLY: number;
  29215. /**
  29216. * Used to apply the vignette as a replacement of the pixel color.
  29217. */
  29218. static readonly VIGNETTEMODE_OPAQUE: number;
  29219. }
  29220. }
  29221. declare module BABYLON {
  29222. /**
  29223. * This represents all the required information to add a fresnel effect on a material:
  29224. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29225. */
  29226. export class FresnelParameters {
  29227. private _isEnabled;
  29228. /**
  29229. * Define if the fresnel effect is enable or not.
  29230. */
  29231. isEnabled: boolean;
  29232. /**
  29233. * Define the color used on edges (grazing angle)
  29234. */
  29235. leftColor: Color3;
  29236. /**
  29237. * Define the color used on center
  29238. */
  29239. rightColor: Color3;
  29240. /**
  29241. * Define bias applied to computed fresnel term
  29242. */
  29243. bias: number;
  29244. /**
  29245. * Defined the power exponent applied to fresnel term
  29246. */
  29247. power: number;
  29248. /**
  29249. * Clones the current fresnel and its valuues
  29250. * @returns a clone fresnel configuration
  29251. */
  29252. clone(): FresnelParameters;
  29253. /**
  29254. * Serializes the current fresnel parameters to a JSON representation.
  29255. * @return the JSON serialization
  29256. */
  29257. serialize(): any;
  29258. /**
  29259. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29260. * @param parsedFresnelParameters Define the JSON representation
  29261. * @returns the parsed parameters
  29262. */
  29263. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29264. }
  29265. }
  29266. declare module BABYLON {
  29267. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29268. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29269. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29270. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29271. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29272. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29273. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29274. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29275. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29276. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29277. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29278. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29279. /**
  29280. * Decorator used to define property that can be serialized as reference to a camera
  29281. * @param sourceName defines the name of the property to decorate
  29282. */
  29283. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29284. /**
  29285. * Class used to help serialization objects
  29286. */
  29287. export class SerializationHelper {
  29288. /** hidden */
  29289. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29290. /** hidden */
  29291. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29292. /** hidden */
  29293. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29294. /** hidden */
  29295. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29296. /**
  29297. * Appends the serialized animations from the source animations
  29298. * @param source Source containing the animations
  29299. * @param destination Target to store the animations
  29300. */
  29301. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29302. /**
  29303. * Static function used to serialized a specific entity
  29304. * @param entity defines the entity to serialize
  29305. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29306. * @returns a JSON compatible object representing the serialization of the entity
  29307. */
  29308. static Serialize<T>(entity: T, serializationObject?: any): any;
  29309. /**
  29310. * Creates a new entity from a serialization data object
  29311. * @param creationFunction defines a function used to instanciated the new entity
  29312. * @param source defines the source serialization data
  29313. * @param scene defines the hosting scene
  29314. * @param rootUrl defines the root url for resources
  29315. * @returns a new entity
  29316. */
  29317. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29318. /**
  29319. * Clones an object
  29320. * @param creationFunction defines the function used to instanciate the new object
  29321. * @param source defines the source object
  29322. * @returns the cloned object
  29323. */
  29324. static Clone<T>(creationFunction: () => T, source: T): T;
  29325. /**
  29326. * Instanciates a new object based on a source one (some data will be shared between both object)
  29327. * @param creationFunction defines the function used to instanciate the new object
  29328. * @param source defines the source object
  29329. * @returns the new object
  29330. */
  29331. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29332. }
  29333. }
  29334. declare module BABYLON {
  29335. /**
  29336. * This is the base class of all the camera used in the application.
  29337. * @see http://doc.babylonjs.com/features/cameras
  29338. */
  29339. export class Camera extends Node {
  29340. /** @hidden */
  29341. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29342. /**
  29343. * This is the default projection mode used by the cameras.
  29344. * It helps recreating a feeling of perspective and better appreciate depth.
  29345. * This is the best way to simulate real life cameras.
  29346. */
  29347. static readonly PERSPECTIVE_CAMERA: number;
  29348. /**
  29349. * This helps creating camera with an orthographic mode.
  29350. * 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.
  29351. */
  29352. static readonly ORTHOGRAPHIC_CAMERA: number;
  29353. /**
  29354. * This is the default FOV mode for perspective cameras.
  29355. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29356. */
  29357. static readonly FOVMODE_VERTICAL_FIXED: number;
  29358. /**
  29359. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29360. */
  29361. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29362. /**
  29363. * This specifies ther is no need for a camera rig.
  29364. * Basically only one eye is rendered corresponding to the camera.
  29365. */
  29366. static readonly RIG_MODE_NONE: number;
  29367. /**
  29368. * Simulates a camera Rig with one blue eye and one red eye.
  29369. * This can be use with 3d blue and red glasses.
  29370. */
  29371. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29372. /**
  29373. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29374. */
  29375. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29376. /**
  29377. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29378. */
  29379. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29380. /**
  29381. * Defines that both eyes of the camera will be rendered over under each other.
  29382. */
  29383. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29384. /**
  29385. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29386. */
  29387. static readonly RIG_MODE_VR: number;
  29388. /**
  29389. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29390. */
  29391. static readonly RIG_MODE_WEBVR: number;
  29392. /**
  29393. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29394. */
  29395. static readonly RIG_MODE_CUSTOM: number;
  29396. /**
  29397. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29398. */
  29399. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29400. /**
  29401. * @hidden
  29402. * Might be removed once multiview will be a thing
  29403. */
  29404. static UseAlternateWebVRRendering: boolean;
  29405. /**
  29406. * Define the input manager associated with the camera.
  29407. */
  29408. inputs: CameraInputsManager<Camera>;
  29409. /** @hidden */
  29410. _position: Vector3;
  29411. /**
  29412. * Define the current local position of the camera in the scene
  29413. */
  29414. position: Vector3;
  29415. /**
  29416. * The vector the camera should consider as up.
  29417. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29418. */
  29419. upVector: Vector3;
  29420. /**
  29421. * Define the current limit on the left side for an orthographic camera
  29422. * In scene unit
  29423. */
  29424. orthoLeft: Nullable<number>;
  29425. /**
  29426. * Define the current limit on the right side for an orthographic camera
  29427. * In scene unit
  29428. */
  29429. orthoRight: Nullable<number>;
  29430. /**
  29431. * Define the current limit on the bottom side for an orthographic camera
  29432. * In scene unit
  29433. */
  29434. orthoBottom: Nullable<number>;
  29435. /**
  29436. * Define the current limit on the top side for an orthographic camera
  29437. * In scene unit
  29438. */
  29439. orthoTop: Nullable<number>;
  29440. /**
  29441. * Field Of View is set in Radians. (default is 0.8)
  29442. */
  29443. fov: number;
  29444. /**
  29445. * Define the minimum distance the camera can see from.
  29446. * This is important to note that the depth buffer are not infinite and the closer it starts
  29447. * the more your scene might encounter depth fighting issue.
  29448. */
  29449. minZ: number;
  29450. /**
  29451. * Define the maximum distance the camera can see to.
  29452. * This is important to note that the depth buffer are not infinite and the further it end
  29453. * the more your scene might encounter depth fighting issue.
  29454. */
  29455. maxZ: number;
  29456. /**
  29457. * Define the default inertia of the camera.
  29458. * This helps giving a smooth feeling to the camera movement.
  29459. */
  29460. inertia: number;
  29461. /**
  29462. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29463. */
  29464. mode: number;
  29465. /**
  29466. * Define wether the camera is intermediate.
  29467. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29468. */
  29469. isIntermediate: boolean;
  29470. /**
  29471. * Define the viewport of the camera.
  29472. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29473. */
  29474. viewport: Viewport;
  29475. /**
  29476. * Restricts the camera to viewing objects with the same layerMask.
  29477. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29478. */
  29479. layerMask: number;
  29480. /**
  29481. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29482. */
  29483. fovMode: number;
  29484. /**
  29485. * Rig mode of the camera.
  29486. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29487. * This is normally controlled byt the camera themselves as internal use.
  29488. */
  29489. cameraRigMode: number;
  29490. /**
  29491. * Defines the distance between both "eyes" in case of a RIG
  29492. */
  29493. interaxialDistance: number;
  29494. /**
  29495. * Defines if stereoscopic rendering is done side by side or over under.
  29496. */
  29497. isStereoscopicSideBySide: boolean;
  29498. /**
  29499. * 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
  29500. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29501. * else in the scene.
  29502. */
  29503. customRenderTargets: RenderTargetTexture[];
  29504. /**
  29505. * When set, the camera will render to this render target instead of the default canvas
  29506. */
  29507. outputRenderTarget: Nullable<RenderTargetTexture>;
  29508. /**
  29509. * Observable triggered when the camera view matrix has changed.
  29510. */
  29511. onViewMatrixChangedObservable: Observable<Camera>;
  29512. /**
  29513. * Observable triggered when the camera Projection matrix has changed.
  29514. */
  29515. onProjectionMatrixChangedObservable: Observable<Camera>;
  29516. /**
  29517. * Observable triggered when the inputs have been processed.
  29518. */
  29519. onAfterCheckInputsObservable: Observable<Camera>;
  29520. /**
  29521. * Observable triggered when reset has been called and applied to the camera.
  29522. */
  29523. onRestoreStateObservable: Observable<Camera>;
  29524. /** @hidden */
  29525. _cameraRigParams: any;
  29526. /** @hidden */
  29527. _rigCameras: Camera[];
  29528. /** @hidden */
  29529. _rigPostProcess: Nullable<PostProcess>;
  29530. protected _webvrViewMatrix: Matrix;
  29531. /** @hidden */
  29532. _skipRendering: boolean;
  29533. /** @hidden */
  29534. _alternateCamera: Camera;
  29535. /** @hidden */
  29536. _projectionMatrix: Matrix;
  29537. /** @hidden */
  29538. _postProcesses: Nullable<PostProcess>[];
  29539. /** @hidden */
  29540. _activeMeshes: SmartArray<AbstractMesh>;
  29541. protected _globalPosition: Vector3;
  29542. /** hidden */
  29543. _computedViewMatrix: Matrix;
  29544. private _doNotComputeProjectionMatrix;
  29545. private _transformMatrix;
  29546. private _frustumPlanes;
  29547. private _refreshFrustumPlanes;
  29548. private _storedFov;
  29549. private _stateStored;
  29550. /**
  29551. * Instantiates a new camera object.
  29552. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29553. * @see http://doc.babylonjs.com/features/cameras
  29554. * @param name Defines the name of the camera in the scene
  29555. * @param position Defines the position of the camera
  29556. * @param scene Defines the scene the camera belongs too
  29557. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29558. */
  29559. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29560. /**
  29561. * Store current camera state (fov, position, etc..)
  29562. * @returns the camera
  29563. */
  29564. storeState(): Camera;
  29565. /**
  29566. * Restores the camera state values if it has been stored. You must call storeState() first
  29567. */
  29568. protected _restoreStateValues(): boolean;
  29569. /**
  29570. * Restored camera state. You must call storeState() first.
  29571. * @returns true if restored and false otherwise
  29572. */
  29573. restoreState(): boolean;
  29574. /**
  29575. * Gets the class name of the camera.
  29576. * @returns the class name
  29577. */
  29578. getClassName(): string;
  29579. /** @hidden */
  29580. readonly _isCamera: boolean;
  29581. /**
  29582. * Gets a string representation of the camera useful for debug purpose.
  29583. * @param fullDetails Defines that a more verboe level of logging is required
  29584. * @returns the string representation
  29585. */
  29586. toString(fullDetails?: boolean): string;
  29587. /**
  29588. * Gets the current world space position of the camera.
  29589. */
  29590. readonly globalPosition: Vector3;
  29591. /**
  29592. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29593. * @returns the active meshe list
  29594. */
  29595. getActiveMeshes(): SmartArray<AbstractMesh>;
  29596. /**
  29597. * Check wether a mesh is part of the current active mesh list of the camera
  29598. * @param mesh Defines the mesh to check
  29599. * @returns true if active, false otherwise
  29600. */
  29601. isActiveMesh(mesh: Mesh): boolean;
  29602. /**
  29603. * Is this camera ready to be used/rendered
  29604. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29605. * @return true if the camera is ready
  29606. */
  29607. isReady(completeCheck?: boolean): boolean;
  29608. /** @hidden */
  29609. _initCache(): void;
  29610. /** @hidden */
  29611. _updateCache(ignoreParentClass?: boolean): void;
  29612. /** @hidden */
  29613. _isSynchronized(): boolean;
  29614. /** @hidden */
  29615. _isSynchronizedViewMatrix(): boolean;
  29616. /** @hidden */
  29617. _isSynchronizedProjectionMatrix(): boolean;
  29618. /**
  29619. * Attach the input controls to a specific dom element to get the input from.
  29620. * @param element Defines the element the controls should be listened from
  29621. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29622. */
  29623. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29624. /**
  29625. * Detach the current controls from the specified dom element.
  29626. * @param element Defines the element to stop listening the inputs from
  29627. */
  29628. detachControl(element: HTMLElement): void;
  29629. /**
  29630. * Update the camera state according to the different inputs gathered during the frame.
  29631. */
  29632. update(): void;
  29633. /** @hidden */
  29634. _checkInputs(): void;
  29635. /** @hidden */
  29636. readonly rigCameras: Camera[];
  29637. /**
  29638. * Gets the post process used by the rig cameras
  29639. */
  29640. readonly rigPostProcess: Nullable<PostProcess>;
  29641. /**
  29642. * Internal, gets the first post proces.
  29643. * @returns the first post process to be run on this camera.
  29644. */
  29645. _getFirstPostProcess(): Nullable<PostProcess>;
  29646. private _cascadePostProcessesToRigCams;
  29647. /**
  29648. * Attach a post process to the camera.
  29649. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29650. * @param postProcess The post process to attach to the camera
  29651. * @param insertAt The position of the post process in case several of them are in use in the scene
  29652. * @returns the position the post process has been inserted at
  29653. */
  29654. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29655. /**
  29656. * Detach a post process to the camera.
  29657. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29658. * @param postProcess The post process to detach from the camera
  29659. */
  29660. detachPostProcess(postProcess: PostProcess): void;
  29661. /**
  29662. * Gets the current world matrix of the camera
  29663. */
  29664. getWorldMatrix(): Matrix;
  29665. /** @hidden */
  29666. _getViewMatrix(): Matrix;
  29667. /**
  29668. * Gets the current view matrix of the camera.
  29669. * @param force forces the camera to recompute the matrix without looking at the cached state
  29670. * @returns the view matrix
  29671. */
  29672. getViewMatrix(force?: boolean): Matrix;
  29673. /**
  29674. * Freeze the projection matrix.
  29675. * It will prevent the cache check of the camera projection compute and can speed up perf
  29676. * if no parameter of the camera are meant to change
  29677. * @param projection Defines manually a projection if necessary
  29678. */
  29679. freezeProjectionMatrix(projection?: Matrix): void;
  29680. /**
  29681. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29682. */
  29683. unfreezeProjectionMatrix(): void;
  29684. /**
  29685. * Gets the current projection matrix of the camera.
  29686. * @param force forces the camera to recompute the matrix without looking at the cached state
  29687. * @returns the projection matrix
  29688. */
  29689. getProjectionMatrix(force?: boolean): Matrix;
  29690. /**
  29691. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29692. * @returns a Matrix
  29693. */
  29694. getTransformationMatrix(): Matrix;
  29695. private _updateFrustumPlanes;
  29696. /**
  29697. * Checks if a cullable object (mesh...) is in the camera frustum
  29698. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29699. * @param target The object to check
  29700. * @returns true if the object is in frustum otherwise false
  29701. */
  29702. isInFrustum(target: ICullable): boolean;
  29703. /**
  29704. * Checks if a cullable object (mesh...) is in the camera frustum
  29705. * Unlike isInFrustum this cheks the full bounding box
  29706. * @param target The object to check
  29707. * @returns true if the object is in frustum otherwise false
  29708. */
  29709. isCompletelyInFrustum(target: ICullable): boolean;
  29710. /**
  29711. * Gets a ray in the forward direction from the camera.
  29712. * @param length Defines the length of the ray to create
  29713. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29714. * @param origin Defines the start point of the ray which defaults to the camera position
  29715. * @returns the forward ray
  29716. */
  29717. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29718. /**
  29719. * Releases resources associated with this node.
  29720. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29721. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29722. */
  29723. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29724. /**
  29725. * Gets the left camera of a rig setup in case of Rigged Camera
  29726. */
  29727. readonly leftCamera: Nullable<FreeCamera>;
  29728. /**
  29729. * Gets the right camera of a rig setup in case of Rigged Camera
  29730. */
  29731. readonly rightCamera: Nullable<FreeCamera>;
  29732. /**
  29733. * Gets the left camera target of a rig setup in case of Rigged Camera
  29734. * @returns the target position
  29735. */
  29736. getLeftTarget(): Nullable<Vector3>;
  29737. /**
  29738. * Gets the right camera target of a rig setup in case of Rigged Camera
  29739. * @returns the target position
  29740. */
  29741. getRightTarget(): Nullable<Vector3>;
  29742. /**
  29743. * @hidden
  29744. */
  29745. setCameraRigMode(mode: number, rigParams: any): void;
  29746. /** @hidden */
  29747. static _setStereoscopicRigMode(camera: Camera): void;
  29748. /** @hidden */
  29749. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29750. /** @hidden */
  29751. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29752. /** @hidden */
  29753. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29754. /** @hidden */
  29755. _getVRProjectionMatrix(): Matrix;
  29756. protected _updateCameraRotationMatrix(): void;
  29757. protected _updateWebVRCameraRotationMatrix(): void;
  29758. /**
  29759. * This function MUST be overwritten by the different WebVR cameras available.
  29760. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29761. * @hidden
  29762. */
  29763. _getWebVRProjectionMatrix(): Matrix;
  29764. /**
  29765. * This function MUST be overwritten by the different WebVR cameras available.
  29766. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29767. * @hidden
  29768. */
  29769. _getWebVRViewMatrix(): Matrix;
  29770. /** @hidden */
  29771. setCameraRigParameter(name: string, value: any): void;
  29772. /**
  29773. * needs to be overridden by children so sub has required properties to be copied
  29774. * @hidden
  29775. */
  29776. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29777. /**
  29778. * May need to be overridden by children
  29779. * @hidden
  29780. */
  29781. _updateRigCameras(): void;
  29782. /** @hidden */
  29783. _setupInputs(): void;
  29784. /**
  29785. * Serialiaze the camera setup to a json represention
  29786. * @returns the JSON representation
  29787. */
  29788. serialize(): any;
  29789. /**
  29790. * Clones the current camera.
  29791. * @param name The cloned camera name
  29792. * @returns the cloned camera
  29793. */
  29794. clone(name: string): Camera;
  29795. /**
  29796. * Gets the direction of the camera relative to a given local axis.
  29797. * @param localAxis Defines the reference axis to provide a relative direction.
  29798. * @return the direction
  29799. */
  29800. getDirection(localAxis: Vector3): Vector3;
  29801. /**
  29802. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29803. * @param localAxis Defines the reference axis to provide a relative direction.
  29804. * @param result Defines the vector to store the result in
  29805. */
  29806. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29807. /**
  29808. * Gets a camera constructor for a given camera type
  29809. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29810. * @param name The name of the camera the result will be able to instantiate
  29811. * @param scene The scene the result will construct the camera in
  29812. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29813. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29814. * @returns a factory method to construc the camera
  29815. */
  29816. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29817. /**
  29818. * Compute the world matrix of the camera.
  29819. * @returns the camera workd matrix
  29820. */
  29821. computeWorldMatrix(): Matrix;
  29822. /**
  29823. * Parse a JSON and creates the camera from the parsed information
  29824. * @param parsedCamera The JSON to parse
  29825. * @param scene The scene to instantiate the camera in
  29826. * @returns the newly constructed camera
  29827. */
  29828. static Parse(parsedCamera: any, scene: Scene): Camera;
  29829. }
  29830. }
  29831. declare module BABYLON {
  29832. /**
  29833. * Interface for any object that can request an animation frame
  29834. */
  29835. export interface ICustomAnimationFrameRequester {
  29836. /**
  29837. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29838. */
  29839. renderFunction?: Function;
  29840. /**
  29841. * Called to request the next frame to render to
  29842. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29843. */
  29844. requestAnimationFrame: Function;
  29845. /**
  29846. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29847. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29848. */
  29849. requestID?: number;
  29850. }
  29851. /**
  29852. * Interface containing an array of animations
  29853. */
  29854. export interface IAnimatable {
  29855. /**
  29856. * Array of animations
  29857. */
  29858. animations: Array<Animation>;
  29859. }
  29860. /** Interface used by value gradients (color, factor, ...) */
  29861. export interface IValueGradient {
  29862. /**
  29863. * Gets or sets the gradient value (between 0 and 1)
  29864. */
  29865. gradient: number;
  29866. }
  29867. /** Class used to store color4 gradient */
  29868. export class ColorGradient implements IValueGradient {
  29869. /**
  29870. * Gets or sets the gradient value (between 0 and 1)
  29871. */
  29872. gradient: number;
  29873. /**
  29874. * Gets or sets first associated color
  29875. */
  29876. color1: Color4;
  29877. /**
  29878. * Gets or sets second associated color
  29879. */
  29880. color2?: Color4;
  29881. /**
  29882. * Will get a color picked randomly between color1 and color2.
  29883. * If color2 is undefined then color1 will be used
  29884. * @param result defines the target Color4 to store the result in
  29885. */
  29886. getColorToRef(result: Color4): void;
  29887. }
  29888. /** Class used to store color 3 gradient */
  29889. export class Color3Gradient implements IValueGradient {
  29890. /**
  29891. * Gets or sets the gradient value (between 0 and 1)
  29892. */
  29893. gradient: number;
  29894. /**
  29895. * Gets or sets the associated color
  29896. */
  29897. color: Color3;
  29898. }
  29899. /** Class used to store factor gradient */
  29900. export class FactorGradient implements IValueGradient {
  29901. /**
  29902. * Gets or sets the gradient value (between 0 and 1)
  29903. */
  29904. gradient: number;
  29905. /**
  29906. * Gets or sets first associated factor
  29907. */
  29908. factor1: number;
  29909. /**
  29910. * Gets or sets second associated factor
  29911. */
  29912. factor2?: number;
  29913. /**
  29914. * Will get a number picked randomly between factor1 and factor2.
  29915. * If factor2 is undefined then factor1 will be used
  29916. * @returns the picked number
  29917. */
  29918. getFactor(): number;
  29919. }
  29920. /**
  29921. * @ignore
  29922. * Application error to support additional information when loading a file
  29923. */
  29924. export class LoadFileError extends Error {
  29925. /** defines the optional XHR request */
  29926. request?: XMLHttpRequest | undefined;
  29927. private static _setPrototypeOf;
  29928. /**
  29929. * Creates a new LoadFileError
  29930. * @param message defines the message of the error
  29931. * @param request defines the optional XHR request
  29932. */
  29933. constructor(message: string,
  29934. /** defines the optional XHR request */
  29935. request?: XMLHttpRequest | undefined);
  29936. }
  29937. /**
  29938. * Class used to define a retry strategy when error happens while loading assets
  29939. */
  29940. export class RetryStrategy {
  29941. /**
  29942. * Function used to defines an exponential back off strategy
  29943. * @param maxRetries defines the maximum number of retries (3 by default)
  29944. * @param baseInterval defines the interval between retries
  29945. * @returns the strategy function to use
  29946. */
  29947. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29948. }
  29949. /**
  29950. * File request interface
  29951. */
  29952. export interface IFileRequest {
  29953. /**
  29954. * Raised when the request is complete (success or error).
  29955. */
  29956. onCompleteObservable: Observable<IFileRequest>;
  29957. /**
  29958. * Aborts the request for a file.
  29959. */
  29960. abort: () => void;
  29961. }
  29962. /**
  29963. * Class containing a set of static utilities functions
  29964. */
  29965. export class Tools {
  29966. /**
  29967. * Gets or sets the base URL to use to load assets
  29968. */
  29969. static BaseUrl: string;
  29970. /**
  29971. * Enable/Disable Custom HTTP Request Headers globally.
  29972. * default = false
  29973. * @see CustomRequestHeaders
  29974. */
  29975. static UseCustomRequestHeaders: boolean;
  29976. /**
  29977. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  29978. * i.e. when loading files, where the server/service expects an Authorization header.
  29979. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  29980. */
  29981. static CustomRequestHeaders: {
  29982. [key: string]: string;
  29983. };
  29984. /**
  29985. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  29986. */
  29987. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29988. /**
  29989. * Default behaviour for cors in the application.
  29990. * It can be a string if the expected behavior is identical in the entire app.
  29991. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  29992. */
  29993. static CorsBehavior: string | ((url: string | string[]) => string);
  29994. /**
  29995. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  29996. * @ignorenaming
  29997. */
  29998. static UseFallbackTexture: boolean;
  29999. /**
  30000. * Use this object to register external classes like custom textures or material
  30001. * to allow the laoders to instantiate them
  30002. */
  30003. static RegisteredExternalClasses: {
  30004. [key: string]: Object;
  30005. };
  30006. /**
  30007. * Texture content used if a texture cannot loaded
  30008. * @ignorenaming
  30009. */
  30010. static fallbackTexture: string;
  30011. /**
  30012. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30013. * @param u defines the coordinate on X axis
  30014. * @param v defines the coordinate on Y axis
  30015. * @param width defines the width of the source data
  30016. * @param height defines the height of the source data
  30017. * @param pixels defines the source byte array
  30018. * @param color defines the output color
  30019. */
  30020. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30021. /**
  30022. * Interpolates between a and b via alpha
  30023. * @param a The lower value (returned when alpha = 0)
  30024. * @param b The upper value (returned when alpha = 1)
  30025. * @param alpha The interpolation-factor
  30026. * @return The mixed value
  30027. */
  30028. static Mix(a: number, b: number, alpha: number): number;
  30029. /**
  30030. * Tries to instantiate a new object from a given class name
  30031. * @param className defines the class name to instantiate
  30032. * @returns the new object or null if the system was not able to do the instantiation
  30033. */
  30034. static Instantiate(className: string): any;
  30035. /**
  30036. * Provides a slice function that will work even on IE
  30037. * @param data defines the array to slice
  30038. * @param start defines the start of the data (optional)
  30039. * @param end defines the end of the data (optional)
  30040. * @returns the new sliced array
  30041. */
  30042. static Slice<T>(data: T, start?: number, end?: number): T;
  30043. /**
  30044. * Polyfill for setImmediate
  30045. * @param action defines the action to execute after the current execution block
  30046. */
  30047. static SetImmediate(action: () => void): void;
  30048. /**
  30049. * Function indicating if a number is an exponent of 2
  30050. * @param value defines the value to test
  30051. * @returns true if the value is an exponent of 2
  30052. */
  30053. static IsExponentOfTwo(value: number): boolean;
  30054. private static _tmpFloatArray;
  30055. /**
  30056. * Returns the nearest 32-bit single precision float representation of a Number
  30057. * @param value A Number. If the parameter is of a different type, it will get converted
  30058. * to a number or to NaN if it cannot be converted
  30059. * @returns number
  30060. */
  30061. static FloatRound(value: number): number;
  30062. /**
  30063. * Find the next highest power of two.
  30064. * @param x Number to start search from.
  30065. * @return Next highest power of two.
  30066. */
  30067. static CeilingPOT(x: number): number;
  30068. /**
  30069. * Find the next lowest power of two.
  30070. * @param x Number to start search from.
  30071. * @return Next lowest power of two.
  30072. */
  30073. static FloorPOT(x: number): number;
  30074. /**
  30075. * Find the nearest power of two.
  30076. * @param x Number to start search from.
  30077. * @return Next nearest power of two.
  30078. */
  30079. static NearestPOT(x: number): number;
  30080. /**
  30081. * Get the closest exponent of two
  30082. * @param value defines the value to approximate
  30083. * @param max defines the maximum value to return
  30084. * @param mode defines how to define the closest value
  30085. * @returns closest exponent of two of the given value
  30086. */
  30087. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30088. /**
  30089. * Extracts the filename from a path
  30090. * @param path defines the path to use
  30091. * @returns the filename
  30092. */
  30093. static GetFilename(path: string): string;
  30094. /**
  30095. * Extracts the "folder" part of a path (everything before the filename).
  30096. * @param uri The URI to extract the info from
  30097. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30098. * @returns The "folder" part of the path
  30099. */
  30100. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30101. /**
  30102. * Extracts text content from a DOM element hierarchy
  30103. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30104. */
  30105. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30106. /**
  30107. * Convert an angle in radians to degrees
  30108. * @param angle defines the angle to convert
  30109. * @returns the angle in degrees
  30110. */
  30111. static ToDegrees(angle: number): number;
  30112. /**
  30113. * Convert an angle in degrees to radians
  30114. * @param angle defines the angle to convert
  30115. * @returns the angle in radians
  30116. */
  30117. static ToRadians(angle: number): number;
  30118. /**
  30119. * Encode a buffer to a base64 string
  30120. * @param buffer defines the buffer to encode
  30121. * @returns the encoded string
  30122. */
  30123. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30124. /**
  30125. * Extracts minimum and maximum values from a list of indexed positions
  30126. * @param positions defines the positions to use
  30127. * @param indices defines the indices to the positions
  30128. * @param indexStart defines the start index
  30129. * @param indexCount defines the end index
  30130. * @param bias defines bias value to add to the result
  30131. * @return minimum and maximum values
  30132. */
  30133. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30134. minimum: Vector3;
  30135. maximum: Vector3;
  30136. };
  30137. /**
  30138. * Extracts minimum and maximum values from a list of positions
  30139. * @param positions defines the positions to use
  30140. * @param start defines the start index in the positions array
  30141. * @param count defines the number of positions to handle
  30142. * @param bias defines bias value to add to the result
  30143. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30144. * @return minimum and maximum values
  30145. */
  30146. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30147. minimum: Vector3;
  30148. maximum: Vector3;
  30149. };
  30150. /**
  30151. * Returns an array if obj is not an array
  30152. * @param obj defines the object to evaluate as an array
  30153. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30154. * @returns either obj directly if obj is an array or a new array containing obj
  30155. */
  30156. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30157. /**
  30158. * Gets the pointer prefix to use
  30159. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30160. */
  30161. static GetPointerPrefix(): string;
  30162. /**
  30163. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30164. * @param func - the function to be called
  30165. * @param requester - the object that will request the next frame. Falls back to window.
  30166. * @returns frame number
  30167. */
  30168. static QueueNewFrame(func: () => void, requester?: any): number;
  30169. /**
  30170. * Ask the browser to promote the current element to fullscreen rendering mode
  30171. * @param element defines the DOM element to promote
  30172. */
  30173. static RequestFullscreen(element: HTMLElement): void;
  30174. /**
  30175. * Asks the browser to exit fullscreen mode
  30176. */
  30177. static ExitFullscreen(): void;
  30178. /**
  30179. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30180. * @param url define the url we are trying
  30181. * @param element define the dom element where to configure the cors policy
  30182. */
  30183. static SetCorsBehavior(url: string | string[], element: {
  30184. crossOrigin: string | null;
  30185. }): void;
  30186. /**
  30187. * Removes unwanted characters from an url
  30188. * @param url defines the url to clean
  30189. * @returns the cleaned url
  30190. */
  30191. static CleanUrl(url: string): string;
  30192. /**
  30193. * Gets or sets a function used to pre-process url before using them to load assets
  30194. */
  30195. static PreprocessUrl: (url: string) => string;
  30196. /**
  30197. * Loads an image as an HTMLImageElement.
  30198. * @param input url string, ArrayBuffer, or Blob to load
  30199. * @param onLoad callback called when the image successfully loads
  30200. * @param onError callback called when the image fails to load
  30201. * @param offlineProvider offline provider for caching
  30202. * @returns the HTMLImageElement of the loaded image
  30203. */
  30204. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30205. /**
  30206. * Loads a file
  30207. * @param url url string, ArrayBuffer, or Blob to load
  30208. * @param onSuccess callback called when the file successfully loads
  30209. * @param onProgress callback called while file is loading (if the server supports this mode)
  30210. * @param offlineProvider defines the offline provider for caching
  30211. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30212. * @param onError callback called when the file fails to load
  30213. * @returns a file request object
  30214. */
  30215. 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;
  30216. /**
  30217. * Load a script (identified by an url). When the url returns, the
  30218. * content of this file is added into a new script element, attached to the DOM (body element)
  30219. * @param scriptUrl defines the url of the script to laod
  30220. * @param onSuccess defines the callback called when the script is loaded
  30221. * @param onError defines the callback to call if an error occurs
  30222. */
  30223. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30224. /**
  30225. * Loads a file from a blob
  30226. * @param fileToLoad defines the blob to use
  30227. * @param callback defines the callback to call when data is loaded
  30228. * @param progressCallback defines the callback to call during loading process
  30229. * @returns a file request object
  30230. */
  30231. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30232. /**
  30233. * Loads a file
  30234. * @param fileToLoad defines the file to load
  30235. * @param callback defines the callback to call when data is loaded
  30236. * @param progressCallBack defines the callback to call during loading process
  30237. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30238. * @returns a file request object
  30239. */
  30240. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30241. /**
  30242. * Creates a data url from a given string content
  30243. * @param content defines the content to convert
  30244. * @returns the new data url link
  30245. */
  30246. static FileAsURL(content: string): string;
  30247. /**
  30248. * Format the given number to a specific decimal format
  30249. * @param value defines the number to format
  30250. * @param decimals defines the number of decimals to use
  30251. * @returns the formatted string
  30252. */
  30253. static Format(value: number, decimals?: number): string;
  30254. /**
  30255. * Checks if a given vector is inside a specific range
  30256. * @param v defines the vector to test
  30257. * @param min defines the minimum range
  30258. * @param max defines the maximum range
  30259. */
  30260. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30261. /**
  30262. * Tries to copy an object by duplicating every property
  30263. * @param source defines the source object
  30264. * @param destination defines the target object
  30265. * @param doNotCopyList defines a list of properties to avoid
  30266. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30267. */
  30268. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30269. /**
  30270. * Gets a boolean indicating if the given object has no own property
  30271. * @param obj defines the object to test
  30272. * @returns true if object has no own property
  30273. */
  30274. static IsEmpty(obj: any): boolean;
  30275. /**
  30276. * Function used to register events at window level
  30277. * @param events defines the events to register
  30278. */
  30279. static RegisterTopRootEvents(events: {
  30280. name: string;
  30281. handler: Nullable<(e: FocusEvent) => any>;
  30282. }[]): void;
  30283. /**
  30284. * Function used to unregister events from window level
  30285. * @param events defines the events to unregister
  30286. */
  30287. static UnregisterTopRootEvents(events: {
  30288. name: string;
  30289. handler: Nullable<(e: FocusEvent) => any>;
  30290. }[]): void;
  30291. /**
  30292. * Dumps the current bound framebuffer
  30293. * @param width defines the rendering width
  30294. * @param height defines the rendering height
  30295. * @param engine defines the hosting engine
  30296. * @param successCallback defines the callback triggered once the data are available
  30297. * @param mimeType defines the mime type of the result
  30298. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30299. */
  30300. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30301. /**
  30302. * Converts the canvas data to blob.
  30303. * This acts as a polyfill for browsers not supporting the to blob function.
  30304. * @param canvas Defines the canvas to extract the data from
  30305. * @param successCallback Defines the callback triggered once the data are available
  30306. * @param mimeType Defines the mime type of the result
  30307. */
  30308. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30309. /**
  30310. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30311. * @param successCallback defines the callback triggered once the data are available
  30312. * @param mimeType defines the mime type of the result
  30313. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30314. */
  30315. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30316. /**
  30317. * Downloads a blob in the browser
  30318. * @param blob defines the blob to download
  30319. * @param fileName defines the name of the downloaded file
  30320. */
  30321. static Download(blob: Blob, fileName: string): void;
  30322. /**
  30323. * Captures a screenshot of the current rendering
  30324. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30325. * @param engine defines the rendering engine
  30326. * @param camera defines the source camera
  30327. * @param size This parameter can be set to a single number or to an object with the
  30328. * following (optional) properties: precision, width, height. If a single number is passed,
  30329. * it will be used for both width and height. If an object is passed, the screenshot size
  30330. * will be derived from the parameters. The precision property is a multiplier allowing
  30331. * rendering at a higher or lower resolution
  30332. * @param successCallback defines the callback receives a single parameter which contains the
  30333. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30334. * src parameter of an <img> to display it
  30335. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30336. * Check your browser for supported MIME types
  30337. */
  30338. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30339. /**
  30340. * Generates an image screenshot from the specified camera.
  30341. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30342. * @param engine The engine to use for rendering
  30343. * @param camera The camera to use for rendering
  30344. * @param size This parameter can be set to a single number or to an object with the
  30345. * following (optional) properties: precision, width, height. If a single number is passed,
  30346. * it will be used for both width and height. If an object is passed, the screenshot size
  30347. * will be derived from the parameters. The precision property is a multiplier allowing
  30348. * rendering at a higher or lower resolution
  30349. * @param successCallback The callback receives a single parameter which contains the
  30350. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30351. * src parameter of an <img> to display it
  30352. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30353. * Check your browser for supported MIME types
  30354. * @param samples Texture samples (default: 1)
  30355. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30356. * @param fileName A name for for the downloaded file.
  30357. */
  30358. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30359. /**
  30360. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30361. * Be aware Math.random() could cause collisions, but:
  30362. * "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"
  30363. * @returns a pseudo random id
  30364. */
  30365. static RandomId(): string;
  30366. /**
  30367. * Test if the given uri is a base64 string
  30368. * @param uri The uri to test
  30369. * @return True if the uri is a base64 string or false otherwise
  30370. */
  30371. static IsBase64(uri: string): boolean;
  30372. /**
  30373. * Decode the given base64 uri.
  30374. * @param uri The uri to decode
  30375. * @return The decoded base64 data.
  30376. */
  30377. static DecodeBase64(uri: string): ArrayBuffer;
  30378. /**
  30379. * No log
  30380. */
  30381. static readonly NoneLogLevel: number;
  30382. /**
  30383. * Only message logs
  30384. */
  30385. static readonly MessageLogLevel: number;
  30386. /**
  30387. * Only warning logs
  30388. */
  30389. static readonly WarningLogLevel: number;
  30390. /**
  30391. * Only error logs
  30392. */
  30393. static readonly ErrorLogLevel: number;
  30394. /**
  30395. * All logs
  30396. */
  30397. static readonly AllLogLevel: number;
  30398. /**
  30399. * Gets a value indicating the number of loading errors
  30400. * @ignorenaming
  30401. */
  30402. static readonly errorsCount: number;
  30403. /**
  30404. * Callback called when a new log is added
  30405. */
  30406. static OnNewCacheEntry: (entry: string) => void;
  30407. /**
  30408. * Log a message to the console
  30409. * @param message defines the message to log
  30410. */
  30411. static Log(message: string): void;
  30412. /**
  30413. * Write a warning message to the console
  30414. * @param message defines the message to log
  30415. */
  30416. static Warn(message: string): void;
  30417. /**
  30418. * Write an error message to the console
  30419. * @param message defines the message to log
  30420. */
  30421. static Error(message: string): void;
  30422. /**
  30423. * Gets current log cache (list of logs)
  30424. */
  30425. static readonly LogCache: string;
  30426. /**
  30427. * Clears the log cache
  30428. */
  30429. static ClearLogCache(): void;
  30430. /**
  30431. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30432. */
  30433. static LogLevels: number;
  30434. /**
  30435. * Checks if the loaded document was accessed via `file:`-Protocol.
  30436. * @returns boolean
  30437. */
  30438. static IsFileURL(): boolean;
  30439. /**
  30440. * Checks if the window object exists
  30441. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30442. */
  30443. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30444. /**
  30445. * No performance log
  30446. */
  30447. static readonly PerformanceNoneLogLevel: number;
  30448. /**
  30449. * Use user marks to log performance
  30450. */
  30451. static readonly PerformanceUserMarkLogLevel: number;
  30452. /**
  30453. * Log performance to the console
  30454. */
  30455. static readonly PerformanceConsoleLogLevel: number;
  30456. private static _performance;
  30457. /**
  30458. * Sets the current performance log level
  30459. */
  30460. static PerformanceLogLevel: number;
  30461. private static _StartPerformanceCounterDisabled;
  30462. private static _EndPerformanceCounterDisabled;
  30463. private static _StartUserMark;
  30464. private static _EndUserMark;
  30465. private static _StartPerformanceConsole;
  30466. private static _EndPerformanceConsole;
  30467. /**
  30468. * Injects the @see CustomRequestHeaders into the given request
  30469. * @param request the request that should be used for injection
  30470. */
  30471. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  30472. /**
  30473. * Starts a performance counter
  30474. */
  30475. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30476. /**
  30477. * Ends a specific performance coutner
  30478. */
  30479. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30480. /**
  30481. * Gets either window.performance.now() if supported or Date.now() else
  30482. */
  30483. static readonly Now: number;
  30484. /**
  30485. * This method will return the name of the class used to create the instance of the given object.
  30486. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30487. * @param object the object to get the class name from
  30488. * @param isType defines if the object is actually a type
  30489. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  30490. */
  30491. static GetClassName(object: any, isType?: boolean): string;
  30492. /**
  30493. * Gets the first element of an array satisfying a given predicate
  30494. * @param array defines the array to browse
  30495. * @param predicate defines the predicate to use
  30496. * @returns null if not found or the element
  30497. */
  30498. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30499. /**
  30500. * This method will return the name of the full name of the class, including its owning module (if any).
  30501. * 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).
  30502. * @param object the object to get the class name from
  30503. * @param isType defines if the object is actually a type
  30504. * @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.
  30505. * @ignorenaming
  30506. */
  30507. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30508. /**
  30509. * Returns a promise that resolves after the given amount of time.
  30510. * @param delay Number of milliseconds to delay
  30511. * @returns Promise that resolves after the given amount of time
  30512. */
  30513. static DelayAsync(delay: number): Promise<void>;
  30514. /**
  30515. * Gets the current gradient from an array of IValueGradient
  30516. * @param ratio defines the current ratio to get
  30517. * @param gradients defines the array of IValueGradient
  30518. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30519. */
  30520. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30521. }
  30522. /**
  30523. * This class is used to track a performance counter which is number based.
  30524. * The user has access to many properties which give statistics of different nature.
  30525. *
  30526. * The implementer can track two kinds of Performance Counter: time and count.
  30527. * 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.
  30528. * 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.
  30529. */
  30530. export class PerfCounter {
  30531. /**
  30532. * Gets or sets a global boolean to turn on and off all the counters
  30533. */
  30534. static Enabled: boolean;
  30535. /**
  30536. * Returns the smallest value ever
  30537. */
  30538. readonly min: number;
  30539. /**
  30540. * Returns the biggest value ever
  30541. */
  30542. readonly max: number;
  30543. /**
  30544. * Returns the average value since the performance counter is running
  30545. */
  30546. readonly average: number;
  30547. /**
  30548. * Returns the average value of the last second the counter was monitored
  30549. */
  30550. readonly lastSecAverage: number;
  30551. /**
  30552. * Returns the current value
  30553. */
  30554. readonly current: number;
  30555. /**
  30556. * Gets the accumulated total
  30557. */
  30558. readonly total: number;
  30559. /**
  30560. * Gets the total value count
  30561. */
  30562. readonly count: number;
  30563. /**
  30564. * Creates a new counter
  30565. */
  30566. constructor();
  30567. /**
  30568. * Call this method to start monitoring a new frame.
  30569. * 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.
  30570. */
  30571. fetchNewFrame(): void;
  30572. /**
  30573. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30574. * @param newCount the count value to add to the monitored count
  30575. * @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.
  30576. */
  30577. addCount(newCount: number, fetchResult: boolean): void;
  30578. /**
  30579. * Start monitoring this performance counter
  30580. */
  30581. beginMonitoring(): void;
  30582. /**
  30583. * Compute the time lapsed since the previous beginMonitoring() call.
  30584. * @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
  30585. */
  30586. endMonitoring(newFrame?: boolean): void;
  30587. private _fetchResult;
  30588. private _startMonitoringTime;
  30589. private _min;
  30590. private _max;
  30591. private _average;
  30592. private _current;
  30593. private _totalValueCount;
  30594. private _totalAccumulated;
  30595. private _lastSecAverage;
  30596. private _lastSecAccumulated;
  30597. private _lastSecTime;
  30598. private _lastSecValueCount;
  30599. }
  30600. /**
  30601. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30602. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30603. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30604. * @param name The name of the class, case should be preserved
  30605. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30606. */
  30607. export function className(name: string, module?: string): (target: Object) => void;
  30608. /**
  30609. * An implementation of a loop for asynchronous functions.
  30610. */
  30611. export class AsyncLoop {
  30612. /**
  30613. * Defines the number of iterations for the loop
  30614. */
  30615. iterations: number;
  30616. /**
  30617. * Defines the current index of the loop.
  30618. */
  30619. index: number;
  30620. private _done;
  30621. private _fn;
  30622. private _successCallback;
  30623. /**
  30624. * Constructor.
  30625. * @param iterations the number of iterations.
  30626. * @param func the function to run each iteration
  30627. * @param successCallback the callback that will be called upon succesful execution
  30628. * @param offset starting offset.
  30629. */
  30630. constructor(
  30631. /**
  30632. * Defines the number of iterations for the loop
  30633. */
  30634. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30635. /**
  30636. * Execute the next iteration. Must be called after the last iteration was finished.
  30637. */
  30638. executeNext(): void;
  30639. /**
  30640. * Break the loop and run the success callback.
  30641. */
  30642. breakLoop(): void;
  30643. /**
  30644. * Create and run an async loop.
  30645. * @param iterations the number of iterations.
  30646. * @param fn the function to run each iteration
  30647. * @param successCallback the callback that will be called upon succesful execution
  30648. * @param offset starting offset.
  30649. * @returns the created async loop object
  30650. */
  30651. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30652. /**
  30653. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30654. * @param iterations total number of iterations
  30655. * @param syncedIterations number of synchronous iterations in each async iteration.
  30656. * @param fn the function to call each iteration.
  30657. * @param callback a success call back that will be called when iterating stops.
  30658. * @param breakFunction a break condition (optional)
  30659. * @param timeout timeout settings for the setTimeout function. default - 0.
  30660. * @returns the created async loop object
  30661. */
  30662. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30663. }
  30664. }
  30665. declare module BABYLON {
  30666. /** @hidden */
  30667. export interface ICollisionCoordinator {
  30668. createCollider(): Collider;
  30669. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30670. init(scene: Scene): void;
  30671. }
  30672. /** @hidden */
  30673. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30674. private _scene;
  30675. private _scaledPosition;
  30676. private _scaledVelocity;
  30677. private _finalPosition;
  30678. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30679. createCollider(): Collider;
  30680. init(scene: Scene): void;
  30681. private _collideWithWorld;
  30682. }
  30683. }
  30684. declare module BABYLON {
  30685. /**
  30686. * This class defines the direct association between an animation and a target
  30687. */
  30688. export class TargetedAnimation {
  30689. /**
  30690. * Animation to perform
  30691. */
  30692. animation: Animation;
  30693. /**
  30694. * Target to animate
  30695. */
  30696. target: any;
  30697. }
  30698. /**
  30699. * Use this class to create coordinated animations on multiple targets
  30700. */
  30701. export class AnimationGroup implements IDisposable {
  30702. /** The name of the animation group */
  30703. name: string;
  30704. private _scene;
  30705. private _targetedAnimations;
  30706. private _animatables;
  30707. private _from;
  30708. private _to;
  30709. private _isStarted;
  30710. private _isPaused;
  30711. private _speedRatio;
  30712. /**
  30713. * Gets or sets the unique id of the node
  30714. */
  30715. uniqueId: number;
  30716. /**
  30717. * This observable will notify when one animation have ended
  30718. */
  30719. onAnimationEndObservable: Observable<TargetedAnimation>;
  30720. /**
  30721. * Observer raised when one animation loops
  30722. */
  30723. onAnimationLoopObservable: Observable<TargetedAnimation>;
  30724. /**
  30725. * This observable will notify when all animations have ended.
  30726. */
  30727. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  30728. /**
  30729. * This observable will notify when all animations have paused.
  30730. */
  30731. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  30732. /**
  30733. * This observable will notify when all animations are playing.
  30734. */
  30735. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  30736. /**
  30737. * Gets the first frame
  30738. */
  30739. readonly from: number;
  30740. /**
  30741. * Gets the last frame
  30742. */
  30743. readonly to: number;
  30744. /**
  30745. * Define if the animations are started
  30746. */
  30747. readonly isStarted: boolean;
  30748. /**
  30749. * Gets a value indicating that the current group is playing
  30750. */
  30751. readonly isPlaying: boolean;
  30752. /**
  30753. * Gets or sets the speed ratio to use for all animations
  30754. */
  30755. /**
  30756. * Gets or sets the speed ratio to use for all animations
  30757. */
  30758. speedRatio: number;
  30759. /**
  30760. * Gets the targeted animations for this animation group
  30761. */
  30762. readonly targetedAnimations: Array<TargetedAnimation>;
  30763. /**
  30764. * returning the list of animatables controlled by this animation group.
  30765. */
  30766. readonly animatables: Array<Animatable>;
  30767. /**
  30768. * Instantiates a new Animation Group.
  30769. * This helps managing several animations at once.
  30770. * @see http://doc.babylonjs.com/how_to/group
  30771. * @param name Defines the name of the group
  30772. * @param scene Defines the scene the group belongs to
  30773. */
  30774. constructor(
  30775. /** The name of the animation group */
  30776. name: string, scene?: Nullable<Scene>);
  30777. /**
  30778. * Add an animation (with its target) in the group
  30779. * @param animation defines the animation we want to add
  30780. * @param target defines the target of the animation
  30781. * @returns the TargetedAnimation object
  30782. */
  30783. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  30784. /**
  30785. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  30786. * It can add constant keys at begin or end
  30787. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  30788. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  30789. * @returns the animation group
  30790. */
  30791. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  30792. /**
  30793. * Start all animations on given targets
  30794. * @param loop defines if animations must loop
  30795. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  30796. * @param from defines the from key (optional)
  30797. * @param to defines the to key (optional)
  30798. * @returns the current animation group
  30799. */
  30800. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  30801. /**
  30802. * Pause all animations
  30803. * @returns the animation group
  30804. */
  30805. pause(): AnimationGroup;
  30806. /**
  30807. * Play all animations to initial state
  30808. * This function will start() the animations if they were not started or will restart() them if they were paused
  30809. * @param loop defines if animations must loop
  30810. * @returns the animation group
  30811. */
  30812. play(loop?: boolean): AnimationGroup;
  30813. /**
  30814. * Reset all animations to initial state
  30815. * @returns the animation group
  30816. */
  30817. reset(): AnimationGroup;
  30818. /**
  30819. * Restart animations from key 0
  30820. * @returns the animation group
  30821. */
  30822. restart(): AnimationGroup;
  30823. /**
  30824. * Stop all animations
  30825. * @returns the animation group
  30826. */
  30827. stop(): AnimationGroup;
  30828. /**
  30829. * Set animation weight for all animatables
  30830. * @param weight defines the weight to use
  30831. * @return the animationGroup
  30832. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  30833. */
  30834. setWeightForAllAnimatables(weight: number): AnimationGroup;
  30835. /**
  30836. * Synchronize and normalize all animatables with a source animatable
  30837. * @param root defines the root animatable to synchronize with
  30838. * @return the animationGroup
  30839. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  30840. */
  30841. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  30842. /**
  30843. * Goes to a specific frame in this animation group
  30844. * @param frame the frame number to go to
  30845. * @return the animationGroup
  30846. */
  30847. goToFrame(frame: number): AnimationGroup;
  30848. /**
  30849. * Dispose all associated resources
  30850. */
  30851. dispose(): void;
  30852. private _checkAnimationGroupEnded;
  30853. /**
  30854. * Clone the current animation group and returns a copy
  30855. * @param newName defines the name of the new group
  30856. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  30857. * @returns the new aniamtion group
  30858. */
  30859. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  30860. /**
  30861. * Returns a new AnimationGroup object parsed from the source provided.
  30862. * @param parsedAnimationGroup defines the source
  30863. * @param scene defines the scene that will receive the animationGroup
  30864. * @returns a new AnimationGroup
  30865. */
  30866. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  30867. /**
  30868. * Returns the string "AnimationGroup"
  30869. * @returns "AnimationGroup"
  30870. */
  30871. getClassName(): string;
  30872. /**
  30873. * Creates a detailled string about the object
  30874. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  30875. * @returns a string representing the object
  30876. */
  30877. toString(fullDetails?: boolean): string;
  30878. }
  30879. }
  30880. declare module BABYLON {
  30881. /**
  30882. * Define an interface for all classes that will hold resources
  30883. */
  30884. export interface IDisposable {
  30885. /**
  30886. * Releases all held resources
  30887. */
  30888. dispose(): void;
  30889. }
  30890. /** Interface defining initialization parameters for Scene class */
  30891. export interface SceneOptions {
  30892. /**
  30893. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  30894. * It will improve performance when the number of geometries becomes important.
  30895. */
  30896. useGeometryUniqueIdsMap?: boolean;
  30897. /**
  30898. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  30899. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  30900. */
  30901. useMaterialMeshMap?: boolean;
  30902. /**
  30903. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  30904. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  30905. */
  30906. useClonedMeshhMap?: boolean;
  30907. }
  30908. /**
  30909. * Represents a scene to be rendered by the engine.
  30910. * @see http://doc.babylonjs.com/features/scene
  30911. */
  30912. export class Scene extends AbstractScene implements IAnimatable {
  30913. private static _uniqueIdCounter;
  30914. /** The fog is deactivated */
  30915. static readonly FOGMODE_NONE: number;
  30916. /** The fog density is following an exponential function */
  30917. static readonly FOGMODE_EXP: number;
  30918. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  30919. static readonly FOGMODE_EXP2: number;
  30920. /** The fog density is following a linear function. */
  30921. static readonly FOGMODE_LINEAR: number;
  30922. /**
  30923. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  30924. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30925. */
  30926. static MinDeltaTime: number;
  30927. /**
  30928. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  30929. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30930. */
  30931. static MaxDeltaTime: number;
  30932. /**
  30933. * Factory used to create the default material.
  30934. * @param name The name of the material to create
  30935. * @param scene The scene to create the material for
  30936. * @returns The default material
  30937. */
  30938. static DefaultMaterialFactory(scene: Scene): Material;
  30939. /**
  30940. * Factory used to create the a collision coordinator.
  30941. * @returns The collision coordinator
  30942. */
  30943. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  30944. /** @hidden */
  30945. readonly _isScene: boolean;
  30946. /**
  30947. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  30948. */
  30949. autoClear: boolean;
  30950. /**
  30951. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  30952. */
  30953. autoClearDepthAndStencil: boolean;
  30954. /**
  30955. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  30956. */
  30957. clearColor: Color4;
  30958. /**
  30959. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  30960. */
  30961. ambientColor: Color3;
  30962. /** @hidden */
  30963. _environmentBRDFTexture: BaseTexture;
  30964. /** @hidden */
  30965. protected _environmentTexture: Nullable<BaseTexture>;
  30966. /**
  30967. * Texture used in all pbr material as the reflection texture.
  30968. * As in the majority of the scene they are the same (exception for multi room and so on),
  30969. * this is easier to reference from here than from all the materials.
  30970. */
  30971. /**
  30972. * Texture used in all pbr material as the reflection texture.
  30973. * As in the majority of the scene they are the same (exception for multi room and so on),
  30974. * this is easier to set here than in all the materials.
  30975. */
  30976. environmentTexture: Nullable<BaseTexture>;
  30977. /** @hidden */
  30978. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30979. /**
  30980. * Default image processing configuration used either in the rendering
  30981. * Forward main pass or through the imageProcessingPostProcess if present.
  30982. * As in the majority of the scene they are the same (exception for multi camera),
  30983. * this is easier to reference from here than from all the materials and post process.
  30984. *
  30985. * No setter as we it is a shared configuration, you can set the values instead.
  30986. */
  30987. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  30988. private _forceWireframe;
  30989. /**
  30990. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  30991. */
  30992. forceWireframe: boolean;
  30993. private _forcePointsCloud;
  30994. /**
  30995. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  30996. */
  30997. forcePointsCloud: boolean;
  30998. /**
  30999. * Gets or sets the active clipplane 1
  31000. */
  31001. clipPlane: Nullable<Plane>;
  31002. /**
  31003. * Gets or sets the active clipplane 2
  31004. */
  31005. clipPlane2: Nullable<Plane>;
  31006. /**
  31007. * Gets or sets the active clipplane 3
  31008. */
  31009. clipPlane3: Nullable<Plane>;
  31010. /**
  31011. * Gets or sets the active clipplane 4
  31012. */
  31013. clipPlane4: Nullable<Plane>;
  31014. /**
  31015. * Gets or sets a boolean indicating if animations are enabled
  31016. */
  31017. animationsEnabled: boolean;
  31018. private _animationPropertiesOverride;
  31019. /**
  31020. * Gets or sets the animation properties override
  31021. */
  31022. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31023. /**
  31024. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31025. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31026. */
  31027. useConstantAnimationDeltaTime: boolean;
  31028. /**
  31029. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31030. * Please note that it requires to run a ray cast through the scene on every frame
  31031. */
  31032. constantlyUpdateMeshUnderPointer: boolean;
  31033. /**
  31034. * Defines the HTML cursor to use when hovering over interactive elements
  31035. */
  31036. hoverCursor: string;
  31037. /**
  31038. * Defines the HTML default cursor to use (empty by default)
  31039. */
  31040. defaultCursor: string;
  31041. /**
  31042. * This is used to call preventDefault() on pointer down
  31043. * in order to block unwanted artifacts like system double clicks
  31044. */
  31045. preventDefaultOnPointerDown: boolean;
  31046. /**
  31047. * This is used to call preventDefault() on pointer up
  31048. * in order to block unwanted artifacts like system double clicks
  31049. */
  31050. preventDefaultOnPointerUp: boolean;
  31051. /**
  31052. * Gets or sets user defined metadata
  31053. */
  31054. metadata: any;
  31055. /**
  31056. * For internal use only. Please do not use.
  31057. */
  31058. reservedDataStore: any;
  31059. /**
  31060. * Gets the name of the plugin used to load this scene (null by default)
  31061. */
  31062. loadingPluginName: string;
  31063. /**
  31064. * Use this array to add regular expressions used to disable offline support for specific urls
  31065. */
  31066. disableOfflineSupportExceptionRules: RegExp[];
  31067. /**
  31068. * An event triggered when the scene is disposed.
  31069. */
  31070. onDisposeObservable: Observable<Scene>;
  31071. private _onDisposeObserver;
  31072. /** Sets a function to be executed when this scene is disposed. */
  31073. onDispose: () => void;
  31074. /**
  31075. * An event triggered before rendering the scene (right after animations and physics)
  31076. */
  31077. onBeforeRenderObservable: Observable<Scene>;
  31078. private _onBeforeRenderObserver;
  31079. /** Sets a function to be executed before rendering this scene */
  31080. beforeRender: Nullable<() => void>;
  31081. /**
  31082. * An event triggered after rendering the scene
  31083. */
  31084. onAfterRenderObservable: Observable<Scene>;
  31085. private _onAfterRenderObserver;
  31086. /** Sets a function to be executed after rendering this scene */
  31087. afterRender: Nullable<() => void>;
  31088. /**
  31089. * An event triggered before animating the scene
  31090. */
  31091. onBeforeAnimationsObservable: Observable<Scene>;
  31092. /**
  31093. * An event triggered after animations processing
  31094. */
  31095. onAfterAnimationsObservable: Observable<Scene>;
  31096. /**
  31097. * An event triggered before draw calls are ready to be sent
  31098. */
  31099. onBeforeDrawPhaseObservable: Observable<Scene>;
  31100. /**
  31101. * An event triggered after draw calls have been sent
  31102. */
  31103. onAfterDrawPhaseObservable: Observable<Scene>;
  31104. /**
  31105. * An event triggered when the scene is ready
  31106. */
  31107. onReadyObservable: Observable<Scene>;
  31108. /**
  31109. * An event triggered before rendering a camera
  31110. */
  31111. onBeforeCameraRenderObservable: Observable<Camera>;
  31112. private _onBeforeCameraRenderObserver;
  31113. /** Sets a function to be executed before rendering a camera*/
  31114. beforeCameraRender: () => void;
  31115. /**
  31116. * An event triggered after rendering a camera
  31117. */
  31118. onAfterCameraRenderObservable: Observable<Camera>;
  31119. private _onAfterCameraRenderObserver;
  31120. /** Sets a function to be executed after rendering a camera*/
  31121. afterCameraRender: () => void;
  31122. /**
  31123. * An event triggered when active meshes evaluation is about to start
  31124. */
  31125. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31126. /**
  31127. * An event triggered when active meshes evaluation is done
  31128. */
  31129. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31130. /**
  31131. * An event triggered when particles rendering is about to start
  31132. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31133. */
  31134. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31135. /**
  31136. * An event triggered when particles rendering is done
  31137. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31138. */
  31139. onAfterParticlesRenderingObservable: Observable<Scene>;
  31140. /**
  31141. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31142. */
  31143. onDataLoadedObservable: Observable<Scene>;
  31144. /**
  31145. * An event triggered when a camera is created
  31146. */
  31147. onNewCameraAddedObservable: Observable<Camera>;
  31148. /**
  31149. * An event triggered when a camera is removed
  31150. */
  31151. onCameraRemovedObservable: Observable<Camera>;
  31152. /**
  31153. * An event triggered when a light is created
  31154. */
  31155. onNewLightAddedObservable: Observable<Light>;
  31156. /**
  31157. * An event triggered when a light is removed
  31158. */
  31159. onLightRemovedObservable: Observable<Light>;
  31160. /**
  31161. * An event triggered when a geometry is created
  31162. */
  31163. onNewGeometryAddedObservable: Observable<Geometry>;
  31164. /**
  31165. * An event triggered when a geometry is removed
  31166. */
  31167. onGeometryRemovedObservable: Observable<Geometry>;
  31168. /**
  31169. * An event triggered when a transform node is created
  31170. */
  31171. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31172. /**
  31173. * An event triggered when a transform node is removed
  31174. */
  31175. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31176. /**
  31177. * An event triggered when a mesh is created
  31178. */
  31179. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31180. /**
  31181. * An event triggered when a mesh is removed
  31182. */
  31183. onMeshRemovedObservable: Observable<AbstractMesh>;
  31184. /**
  31185. * An event triggered when a material is created
  31186. */
  31187. onNewMaterialAddedObservable: Observable<Material>;
  31188. /**
  31189. * An event triggered when a material is removed
  31190. */
  31191. onMaterialRemovedObservable: Observable<Material>;
  31192. /**
  31193. * An event triggered when a texture is created
  31194. */
  31195. onNewTextureAddedObservable: Observable<BaseTexture>;
  31196. /**
  31197. * An event triggered when a texture is removed
  31198. */
  31199. onTextureRemovedObservable: Observable<BaseTexture>;
  31200. /**
  31201. * An event triggered when render targets are about to be rendered
  31202. * Can happen multiple times per frame.
  31203. */
  31204. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31205. /**
  31206. * An event triggered when render targets were rendered.
  31207. * Can happen multiple times per frame.
  31208. */
  31209. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31210. /**
  31211. * An event triggered before calculating deterministic simulation step
  31212. */
  31213. onBeforeStepObservable: Observable<Scene>;
  31214. /**
  31215. * An event triggered after calculating deterministic simulation step
  31216. */
  31217. onAfterStepObservable: Observable<Scene>;
  31218. /**
  31219. * An event triggered when the activeCamera property is updated
  31220. */
  31221. onActiveCameraChanged: Observable<Scene>;
  31222. /**
  31223. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31224. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31225. * 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)
  31226. */
  31227. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31228. /**
  31229. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31230. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31231. * 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)
  31232. */
  31233. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31234. /**
  31235. * This Observable will when a mesh has been imported into the scene.
  31236. */
  31237. onMeshImportedObservable: Observable<AbstractMesh>;
  31238. /** @hidden */
  31239. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31240. /**
  31241. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31242. */
  31243. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31244. /**
  31245. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31246. */
  31247. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31248. /**
  31249. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31250. */
  31251. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31252. private _onPointerMove;
  31253. private _onPointerDown;
  31254. private _onPointerUp;
  31255. /** Callback called when a pointer move is detected */
  31256. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31257. /** Callback called when a pointer down is detected */
  31258. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31259. /** Callback called when a pointer up is detected */
  31260. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31261. /** Callback called when a pointer pick is detected */
  31262. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31263. /**
  31264. * 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).
  31265. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31266. */
  31267. onPrePointerObservable: Observable<PointerInfoPre>;
  31268. /**
  31269. * Observable event triggered each time an input event is received from the rendering canvas
  31270. */
  31271. onPointerObservable: Observable<PointerInfo>;
  31272. /**
  31273. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31274. */
  31275. readonly unTranslatedPointer: Vector2;
  31276. /** The distance in pixel that you have to move to prevent some events */
  31277. static DragMovementThreshold: number;
  31278. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31279. static LongPressDelay: number;
  31280. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31281. static DoubleClickDelay: number;
  31282. /** If you need to check double click without raising a single click at first click, enable this flag */
  31283. static ExclusiveDoubleClickMode: boolean;
  31284. private _initClickEvent;
  31285. private _initActionManager;
  31286. private _delayedSimpleClick;
  31287. private _delayedSimpleClickTimeout;
  31288. private _previousDelayedSimpleClickTimeout;
  31289. private _meshPickProceed;
  31290. private _previousButtonPressed;
  31291. private _currentPickResult;
  31292. private _previousPickResult;
  31293. private _totalPointersPressed;
  31294. private _doubleClickOccured;
  31295. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31296. cameraToUseForPointers: Nullable<Camera>;
  31297. private _pointerX;
  31298. private _pointerY;
  31299. private _unTranslatedPointerX;
  31300. private _unTranslatedPointerY;
  31301. private _startingPointerPosition;
  31302. private _previousStartingPointerPosition;
  31303. private _startingPointerTime;
  31304. private _previousStartingPointerTime;
  31305. private _pointerCaptures;
  31306. private _timeAccumulator;
  31307. private _currentStepId;
  31308. private _currentInternalStep;
  31309. /** @hidden */
  31310. _mirroredCameraPosition: Nullable<Vector3>;
  31311. /**
  31312. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31313. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31314. */
  31315. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31316. /**
  31317. * Observable event triggered each time an keyboard event is received from the hosting window
  31318. */
  31319. onKeyboardObservable: Observable<KeyboardInfo>;
  31320. private _onKeyDown;
  31321. private _onKeyUp;
  31322. private _onCanvasFocusObserver;
  31323. private _onCanvasBlurObserver;
  31324. private _useRightHandedSystem;
  31325. /**
  31326. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31327. */
  31328. useRightHandedSystem: boolean;
  31329. /**
  31330. * Sets the step Id used by deterministic lock step
  31331. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31332. * @param newStepId defines the step Id
  31333. */
  31334. setStepId(newStepId: number): void;
  31335. /**
  31336. * Gets the step Id used by deterministic lock step
  31337. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31338. * @returns the step Id
  31339. */
  31340. getStepId(): number;
  31341. /**
  31342. * Gets the internal step used by deterministic lock step
  31343. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31344. * @returns the internal step
  31345. */
  31346. getInternalStep(): number;
  31347. private _fogEnabled;
  31348. /**
  31349. * Gets or sets a boolean indicating if fog is enabled on this scene
  31350. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31351. * (Default is true)
  31352. */
  31353. fogEnabled: boolean;
  31354. private _fogMode;
  31355. /**
  31356. * Gets or sets the fog mode to use
  31357. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31358. * | mode | value |
  31359. * | --- | --- |
  31360. * | FOGMODE_NONE | 0 |
  31361. * | FOGMODE_EXP | 1 |
  31362. * | FOGMODE_EXP2 | 2 |
  31363. * | FOGMODE_LINEAR | 3 |
  31364. */
  31365. fogMode: number;
  31366. /**
  31367. * Gets or sets the fog color to use
  31368. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31369. * (Default is Color3(0.2, 0.2, 0.3))
  31370. */
  31371. fogColor: Color3;
  31372. /**
  31373. * Gets or sets the fog density to use
  31374. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31375. * (Default is 0.1)
  31376. */
  31377. fogDensity: number;
  31378. /**
  31379. * Gets or sets the fog start distance to use
  31380. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31381. * (Default is 0)
  31382. */
  31383. fogStart: number;
  31384. /**
  31385. * Gets or sets the fog end distance to use
  31386. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31387. * (Default is 1000)
  31388. */
  31389. fogEnd: number;
  31390. private _shadowsEnabled;
  31391. /**
  31392. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31393. */
  31394. shadowsEnabled: boolean;
  31395. private _lightsEnabled;
  31396. /**
  31397. * Gets or sets a boolean indicating if lights are enabled on this scene
  31398. */
  31399. lightsEnabled: boolean;
  31400. /** All of the active cameras added to this scene. */
  31401. activeCameras: Camera[];
  31402. private _activeCamera;
  31403. /** Gets or sets the current active camera */
  31404. activeCamera: Nullable<Camera>;
  31405. private _defaultMaterial;
  31406. /** The default material used on meshes when no material is affected */
  31407. /** The default material used on meshes when no material is affected */
  31408. defaultMaterial: Material;
  31409. private _texturesEnabled;
  31410. /**
  31411. * Gets or sets a boolean indicating if textures are enabled on this scene
  31412. */
  31413. texturesEnabled: boolean;
  31414. /**
  31415. * Gets or sets a boolean indicating if particles are enabled on this scene
  31416. */
  31417. particlesEnabled: boolean;
  31418. /**
  31419. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31420. */
  31421. spritesEnabled: boolean;
  31422. private _skeletonsEnabled;
  31423. /**
  31424. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31425. */
  31426. skeletonsEnabled: boolean;
  31427. /**
  31428. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31429. */
  31430. lensFlaresEnabled: boolean;
  31431. /**
  31432. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31433. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31434. */
  31435. collisionsEnabled: boolean;
  31436. private _collisionCoordinator;
  31437. /** @hidden */
  31438. readonly collisionCoordinator: ICollisionCoordinator;
  31439. /**
  31440. * Defines the gravity applied to this scene (used only for collisions)
  31441. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31442. */
  31443. gravity: Vector3;
  31444. /**
  31445. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31446. */
  31447. postProcessesEnabled: boolean;
  31448. /**
  31449. * The list of postprocesses added to the scene
  31450. */
  31451. postProcesses: PostProcess[];
  31452. /**
  31453. * Gets the current postprocess manager
  31454. */
  31455. postProcessManager: PostProcessManager;
  31456. /**
  31457. * Gets or sets a boolean indicating if render targets are enabled on this scene
  31458. */
  31459. renderTargetsEnabled: boolean;
  31460. /**
  31461. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  31462. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  31463. */
  31464. dumpNextRenderTargets: boolean;
  31465. /**
  31466. * The list of user defined render targets added to the scene
  31467. */
  31468. customRenderTargets: RenderTargetTexture[];
  31469. /**
  31470. * Defines if texture loading must be delayed
  31471. * If true, textures will only be loaded when they need to be rendered
  31472. */
  31473. useDelayedTextureLoading: boolean;
  31474. /**
  31475. * Gets the list of meshes imported to the scene through SceneLoader
  31476. */
  31477. importedMeshesFiles: String[];
  31478. /**
  31479. * Gets or sets a boolean indicating if probes are enabled on this scene
  31480. */
  31481. probesEnabled: boolean;
  31482. /**
  31483. * Gets or sets the current offline provider to use to store scene data
  31484. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  31485. */
  31486. offlineProvider: IOfflineProvider;
  31487. /**
  31488. * Gets or sets the action manager associated with the scene
  31489. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31490. */
  31491. actionManager: AbstractActionManager;
  31492. private _meshesForIntersections;
  31493. /**
  31494. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  31495. */
  31496. proceduralTexturesEnabled: boolean;
  31497. private _engine;
  31498. private _totalVertices;
  31499. /** @hidden */
  31500. _activeIndices: PerfCounter;
  31501. /** @hidden */
  31502. _activeParticles: PerfCounter;
  31503. /** @hidden */
  31504. _activeBones: PerfCounter;
  31505. private _animationRatio;
  31506. /** @hidden */
  31507. _animationTimeLast: number;
  31508. /** @hidden */
  31509. _animationTime: number;
  31510. /**
  31511. * Gets or sets a general scale for animation speed
  31512. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  31513. */
  31514. animationTimeScale: number;
  31515. /** @hidden */
  31516. _cachedMaterial: Nullable<Material>;
  31517. /** @hidden */
  31518. _cachedEffect: Nullable<Effect>;
  31519. /** @hidden */
  31520. _cachedVisibility: Nullable<number>;
  31521. private _renderId;
  31522. private _frameId;
  31523. private _executeWhenReadyTimeoutId;
  31524. private _intermediateRendering;
  31525. private _viewUpdateFlag;
  31526. private _projectionUpdateFlag;
  31527. private _alternateViewUpdateFlag;
  31528. private _alternateProjectionUpdateFlag;
  31529. /** @hidden */
  31530. _toBeDisposed: Nullable<IDisposable>[];
  31531. private _activeRequests;
  31532. /** @hidden */
  31533. _pendingData: any[];
  31534. private _isDisposed;
  31535. /**
  31536. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  31537. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  31538. */
  31539. dispatchAllSubMeshesOfActiveMeshes: boolean;
  31540. private _activeMeshes;
  31541. private _processedMaterials;
  31542. private _renderTargets;
  31543. /** @hidden */
  31544. _activeParticleSystems: SmartArray<IParticleSystem>;
  31545. private _activeSkeletons;
  31546. private _softwareSkinnedMeshes;
  31547. private _renderingManager;
  31548. /** @hidden */
  31549. _activeAnimatables: Animatable[];
  31550. private _transformMatrix;
  31551. private _sceneUbo;
  31552. private _alternateSceneUbo;
  31553. private _viewMatrix;
  31554. private _projectionMatrix;
  31555. private _alternateViewMatrix;
  31556. private _alternateProjectionMatrix;
  31557. private _alternateTransformMatrix;
  31558. private _useAlternateCameraConfiguration;
  31559. private _alternateRendering;
  31560. private _wheelEventName;
  31561. /** @hidden */
  31562. _forcedViewPosition: Nullable<Vector3>;
  31563. /** @hidden */
  31564. readonly _isAlternateRenderingEnabled: boolean;
  31565. private _frustumPlanes;
  31566. /**
  31567. * Gets the list of frustum planes (built from the active camera)
  31568. */
  31569. readonly frustumPlanes: Plane[];
  31570. /**
  31571. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31572. * This is useful if there are more lights that the maximum simulteanous authorized
  31573. */
  31574. requireLightSorting: boolean;
  31575. /** @hidden */
  31576. readonly useMaterialMeshMap: boolean;
  31577. /** @hidden */
  31578. readonly useClonedMeshhMap: boolean;
  31579. private _pointerOverMesh;
  31580. private _pickedDownMesh;
  31581. private _pickedUpMesh;
  31582. private _externalData;
  31583. private _uid;
  31584. /**
  31585. * @hidden
  31586. * Backing store of defined scene components.
  31587. */
  31588. _components: ISceneComponent[];
  31589. /**
  31590. * @hidden
  31591. * Backing store of defined scene components.
  31592. */
  31593. _serializableComponents: ISceneSerializableComponent[];
  31594. /**
  31595. * List of components to register on the next registration step.
  31596. */
  31597. private _transientComponents;
  31598. /**
  31599. * Registers the transient components if needed.
  31600. */
  31601. private _registerTransientComponents;
  31602. /**
  31603. * @hidden
  31604. * Add a component to the scene.
  31605. * Note that the ccomponent could be registered on th next frame if this is called after
  31606. * the register component stage.
  31607. * @param component Defines the component to add to the scene
  31608. */
  31609. _addComponent(component: ISceneComponent): void;
  31610. /**
  31611. * @hidden
  31612. * Gets a component from the scene.
  31613. * @param name defines the name of the component to retrieve
  31614. * @returns the component or null if not present
  31615. */
  31616. _getComponent(name: string): Nullable<ISceneComponent>;
  31617. /**
  31618. * @hidden
  31619. * Defines the actions happening before camera updates.
  31620. */
  31621. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  31622. /**
  31623. * @hidden
  31624. * Defines the actions happening before clear the canvas.
  31625. */
  31626. _beforeClearStage: Stage<SimpleStageAction>;
  31627. /**
  31628. * @hidden
  31629. * Defines the actions when collecting render targets for the frame.
  31630. */
  31631. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31632. /**
  31633. * @hidden
  31634. * Defines the actions happening for one camera in the frame.
  31635. */
  31636. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31637. /**
  31638. * @hidden
  31639. * Defines the actions happening during the per mesh ready checks.
  31640. */
  31641. _isReadyForMeshStage: Stage<MeshStageAction>;
  31642. /**
  31643. * @hidden
  31644. * Defines the actions happening before evaluate active mesh checks.
  31645. */
  31646. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  31647. /**
  31648. * @hidden
  31649. * Defines the actions happening during the evaluate sub mesh checks.
  31650. */
  31651. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  31652. /**
  31653. * @hidden
  31654. * Defines the actions happening during the active mesh stage.
  31655. */
  31656. _activeMeshStage: Stage<ActiveMeshStageAction>;
  31657. /**
  31658. * @hidden
  31659. * Defines the actions happening during the per camera render target step.
  31660. */
  31661. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  31662. /**
  31663. * @hidden
  31664. * Defines the actions happening just before the active camera is drawing.
  31665. */
  31666. _beforeCameraDrawStage: Stage<CameraStageAction>;
  31667. /**
  31668. * @hidden
  31669. * Defines the actions happening just before a render target is drawing.
  31670. */
  31671. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31672. /**
  31673. * @hidden
  31674. * Defines the actions happening just before a rendering group is drawing.
  31675. */
  31676. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31677. /**
  31678. * @hidden
  31679. * Defines the actions happening just before a mesh is drawing.
  31680. */
  31681. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31682. /**
  31683. * @hidden
  31684. * Defines the actions happening just after a mesh has been drawn.
  31685. */
  31686. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31687. /**
  31688. * @hidden
  31689. * Defines the actions happening just after a rendering group has been drawn.
  31690. */
  31691. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31692. /**
  31693. * @hidden
  31694. * Defines the actions happening just after the active camera has been drawn.
  31695. */
  31696. _afterCameraDrawStage: Stage<CameraStageAction>;
  31697. /**
  31698. * @hidden
  31699. * Defines the actions happening just after a render target has been drawn.
  31700. */
  31701. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31702. /**
  31703. * @hidden
  31704. * Defines the actions happening just after rendering all cameras and computing intersections.
  31705. */
  31706. _afterRenderStage: Stage<SimpleStageAction>;
  31707. /**
  31708. * @hidden
  31709. * Defines the actions happening when a pointer move event happens.
  31710. */
  31711. _pointerMoveStage: Stage<PointerMoveStageAction>;
  31712. /**
  31713. * @hidden
  31714. * Defines the actions happening when a pointer down event happens.
  31715. */
  31716. _pointerDownStage: Stage<PointerUpDownStageAction>;
  31717. /**
  31718. * @hidden
  31719. * Defines the actions happening when a pointer up event happens.
  31720. */
  31721. _pointerUpStage: Stage<PointerUpDownStageAction>;
  31722. /**
  31723. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  31724. */
  31725. private geometriesByUniqueId;
  31726. /**
  31727. * Creates a new Scene
  31728. * @param engine defines the engine to use to render this scene
  31729. * @param options defines the scene options
  31730. */
  31731. constructor(engine: Engine, options?: SceneOptions);
  31732. private _defaultMeshCandidates;
  31733. /**
  31734. * @hidden
  31735. */
  31736. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  31737. private _defaultSubMeshCandidates;
  31738. /**
  31739. * @hidden
  31740. */
  31741. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  31742. /**
  31743. * Sets the default candidate providers for the scene.
  31744. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  31745. * and getCollidingSubMeshCandidates to their default function
  31746. */
  31747. setDefaultCandidateProviders(): void;
  31748. /**
  31749. * Gets the mesh that is currently under the pointer
  31750. */
  31751. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31752. /**
  31753. * Gets or sets the current on-screen X position of the pointer
  31754. */
  31755. pointerX: number;
  31756. /**
  31757. * Gets or sets the current on-screen Y position of the pointer
  31758. */
  31759. pointerY: number;
  31760. /**
  31761. * Gets the cached material (ie. the latest rendered one)
  31762. * @returns the cached material
  31763. */
  31764. getCachedMaterial(): Nullable<Material>;
  31765. /**
  31766. * Gets the cached effect (ie. the latest rendered one)
  31767. * @returns the cached effect
  31768. */
  31769. getCachedEffect(): Nullable<Effect>;
  31770. /**
  31771. * Gets the cached visibility state (ie. the latest rendered one)
  31772. * @returns the cached visibility state
  31773. */
  31774. getCachedVisibility(): Nullable<number>;
  31775. /**
  31776. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  31777. * @param material defines the current material
  31778. * @param effect defines the current effect
  31779. * @param visibility defines the current visibility state
  31780. * @returns true if one parameter is not cached
  31781. */
  31782. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  31783. /**
  31784. * Gets the engine associated with the scene
  31785. * @returns an Engine
  31786. */
  31787. getEngine(): Engine;
  31788. /**
  31789. * Gets the total number of vertices rendered per frame
  31790. * @returns the total number of vertices rendered per frame
  31791. */
  31792. getTotalVertices(): number;
  31793. /**
  31794. * Gets the performance counter for total vertices
  31795. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31796. */
  31797. readonly totalVerticesPerfCounter: PerfCounter;
  31798. /**
  31799. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  31800. * @returns the total number of active indices rendered per frame
  31801. */
  31802. getActiveIndices(): number;
  31803. /**
  31804. * Gets the performance counter for active indices
  31805. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31806. */
  31807. readonly totalActiveIndicesPerfCounter: PerfCounter;
  31808. /**
  31809. * Gets the total number of active particles rendered per frame
  31810. * @returns the total number of active particles rendered per frame
  31811. */
  31812. getActiveParticles(): number;
  31813. /**
  31814. * Gets the performance counter for active particles
  31815. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31816. */
  31817. readonly activeParticlesPerfCounter: PerfCounter;
  31818. /**
  31819. * Gets the total number of active bones rendered per frame
  31820. * @returns the total number of active bones rendered per frame
  31821. */
  31822. getActiveBones(): number;
  31823. /**
  31824. * Gets the performance counter for active bones
  31825. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31826. */
  31827. readonly activeBonesPerfCounter: PerfCounter;
  31828. /**
  31829. * Gets the array of active meshes
  31830. * @returns an array of AbstractMesh
  31831. */
  31832. getActiveMeshes(): SmartArray<AbstractMesh>;
  31833. /**
  31834. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  31835. * @returns a number
  31836. */
  31837. getAnimationRatio(): number;
  31838. /**
  31839. * Gets an unique Id for the current render phase
  31840. * @returns a number
  31841. */
  31842. getRenderId(): number;
  31843. /**
  31844. * Gets an unique Id for the current frame
  31845. * @returns a number
  31846. */
  31847. getFrameId(): number;
  31848. /** Call this function if you want to manually increment the render Id*/
  31849. incrementRenderId(): void;
  31850. private _updatePointerPosition;
  31851. private _createUbo;
  31852. private _createAlternateUbo;
  31853. private _setRayOnPointerInfo;
  31854. /**
  31855. * Use this method to simulate a pointer move on a mesh
  31856. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31857. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31858. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31859. * @returns the current scene
  31860. */
  31861. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  31862. private _processPointerMove;
  31863. private _checkPrePointerObservable;
  31864. /**
  31865. * Use this method to simulate a pointer down on a mesh
  31866. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31867. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31868. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31869. * @returns the current scene
  31870. */
  31871. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  31872. private _processPointerDown;
  31873. /**
  31874. * Use this method to simulate a pointer up on a mesh
  31875. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31876. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31877. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31878. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31879. * @returns the current scene
  31880. */
  31881. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  31882. private _processPointerUp;
  31883. /**
  31884. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31885. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31886. * @returns true if the pointer was captured
  31887. */
  31888. isPointerCaptured(pointerId?: number): boolean;
  31889. /** @hidden */
  31890. _isPointerSwiping(): boolean;
  31891. /**
  31892. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31893. * @param attachUp defines if you want to attach events to pointerup
  31894. * @param attachDown defines if you want to attach events to pointerdown
  31895. * @param attachMove defines if you want to attach events to pointermove
  31896. */
  31897. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31898. /** Detaches all event handlers*/
  31899. detachControl(): void;
  31900. /**
  31901. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  31902. * Delay loaded resources are not taking in account
  31903. * @return true if all required resources are ready
  31904. */
  31905. isReady(): boolean;
  31906. /** Resets all cached information relative to material (including effect and visibility) */
  31907. resetCachedMaterial(): void;
  31908. /**
  31909. * Registers a function to be called before every frame render
  31910. * @param func defines the function to register
  31911. */
  31912. registerBeforeRender(func: () => void): void;
  31913. /**
  31914. * Unregisters a function called before every frame render
  31915. * @param func defines the function to unregister
  31916. */
  31917. unregisterBeforeRender(func: () => void): void;
  31918. /**
  31919. * Registers a function to be called after every frame render
  31920. * @param func defines the function to register
  31921. */
  31922. registerAfterRender(func: () => void): void;
  31923. /**
  31924. * Unregisters a function called after every frame render
  31925. * @param func defines the function to unregister
  31926. */
  31927. unregisterAfterRender(func: () => void): void;
  31928. private _executeOnceBeforeRender;
  31929. /**
  31930. * The provided function will run before render once and will be disposed afterwards.
  31931. * A timeout delay can be provided so that the function will be executed in N ms.
  31932. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  31933. * @param func The function to be executed.
  31934. * @param timeout optional delay in ms
  31935. */
  31936. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  31937. /** @hidden */
  31938. _addPendingData(data: any): void;
  31939. /** @hidden */
  31940. _removePendingData(data: any): void;
  31941. /**
  31942. * Returns the number of items waiting to be loaded
  31943. * @returns the number of items waiting to be loaded
  31944. */
  31945. getWaitingItemsCount(): number;
  31946. /**
  31947. * Returns a boolean indicating if the scene is still loading data
  31948. */
  31949. readonly isLoading: boolean;
  31950. /**
  31951. * Registers a function to be executed when the scene is ready
  31952. * @param {Function} func - the function to be executed
  31953. */
  31954. executeWhenReady(func: () => void): void;
  31955. /**
  31956. * Returns a promise that resolves when the scene is ready
  31957. * @returns A promise that resolves when the scene is ready
  31958. */
  31959. whenReadyAsync(): Promise<void>;
  31960. /** @hidden */
  31961. _checkIsReady(): void;
  31962. /**
  31963. * Gets all animatable attached to the scene
  31964. */
  31965. readonly animatables: Animatable[];
  31966. /**
  31967. * Resets the last animation time frame.
  31968. * Useful to override when animations start running when loading a scene for the first time.
  31969. */
  31970. resetLastAnimationTimeFrame(): void;
  31971. /** @hidden */
  31972. _switchToAlternateCameraConfiguration(active: boolean): void;
  31973. /**
  31974. * Gets the current view matrix
  31975. * @returns a Matrix
  31976. */
  31977. getViewMatrix(): Matrix;
  31978. /**
  31979. * Gets the current projection matrix
  31980. * @returns a Matrix
  31981. */
  31982. getProjectionMatrix(): Matrix;
  31983. /**
  31984. * Gets the current transform matrix
  31985. * @returns a Matrix made of View * Projection
  31986. */
  31987. getTransformMatrix(): Matrix;
  31988. /**
  31989. * Sets the current transform matrix
  31990. * @param view defines the View matrix to use
  31991. * @param projection defines the Projection matrix to use
  31992. */
  31993. setTransformMatrix(view: Matrix, projection: Matrix): void;
  31994. /** @hidden */
  31995. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  31996. /**
  31997. * Gets the uniform buffer used to store scene data
  31998. * @returns a UniformBuffer
  31999. */
  32000. getSceneUniformBuffer(): UniformBuffer;
  32001. /**
  32002. * Gets an unique (relatively to the current scene) Id
  32003. * @returns an unique number for the scene
  32004. */
  32005. getUniqueId(): number;
  32006. /**
  32007. * Add a mesh to the list of scene's meshes
  32008. * @param newMesh defines the mesh to add
  32009. * @param recursive if all child meshes should also be added to the scene
  32010. */
  32011. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32012. /**
  32013. * Remove a mesh for the list of scene's meshes
  32014. * @param toRemove defines the mesh to remove
  32015. * @param recursive if all child meshes should also be removed from the scene
  32016. * @returns the index where the mesh was in the mesh list
  32017. */
  32018. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32019. /**
  32020. * Add a transform node to the list of scene's transform nodes
  32021. * @param newTransformNode defines the transform node to add
  32022. */
  32023. addTransformNode(newTransformNode: TransformNode): void;
  32024. /**
  32025. * Remove a transform node for the list of scene's transform nodes
  32026. * @param toRemove defines the transform node to remove
  32027. * @returns the index where the transform node was in the transform node list
  32028. */
  32029. removeTransformNode(toRemove: TransformNode): number;
  32030. /**
  32031. * Remove a skeleton for the list of scene's skeletons
  32032. * @param toRemove defines the skeleton to remove
  32033. * @returns the index where the skeleton was in the skeleton list
  32034. */
  32035. removeSkeleton(toRemove: Skeleton): number;
  32036. /**
  32037. * Remove a morph target for the list of scene's morph targets
  32038. * @param toRemove defines the morph target to remove
  32039. * @returns the index where the morph target was in the morph target list
  32040. */
  32041. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32042. /**
  32043. * Remove a light for the list of scene's lights
  32044. * @param toRemove defines the light to remove
  32045. * @returns the index where the light was in the light list
  32046. */
  32047. removeLight(toRemove: Light): number;
  32048. /**
  32049. * Remove a camera for the list of scene's cameras
  32050. * @param toRemove defines the camera to remove
  32051. * @returns the index where the camera was in the camera list
  32052. */
  32053. removeCamera(toRemove: Camera): number;
  32054. /**
  32055. * Remove a particle system for the list of scene's particle systems
  32056. * @param toRemove defines the particle system to remove
  32057. * @returns the index where the particle system was in the particle system list
  32058. */
  32059. removeParticleSystem(toRemove: IParticleSystem): number;
  32060. /**
  32061. * Remove a animation for the list of scene's animations
  32062. * @param toRemove defines the animation to remove
  32063. * @returns the index where the animation was in the animation list
  32064. */
  32065. removeAnimation(toRemove: Animation): number;
  32066. /**
  32067. * Removes the given animation group from this scene.
  32068. * @param toRemove The animation group to remove
  32069. * @returns The index of the removed animation group
  32070. */
  32071. removeAnimationGroup(toRemove: AnimationGroup): number;
  32072. /**
  32073. * Removes the given multi-material from this scene.
  32074. * @param toRemove The multi-material to remove
  32075. * @returns The index of the removed multi-material
  32076. */
  32077. removeMultiMaterial(toRemove: MultiMaterial): number;
  32078. /**
  32079. * Removes the given material from this scene.
  32080. * @param toRemove The material to remove
  32081. * @returns The index of the removed material
  32082. */
  32083. removeMaterial(toRemove: Material): number;
  32084. /**
  32085. * Removes the given action manager from this scene.
  32086. * @param toRemove The action manager to remove
  32087. * @returns The index of the removed action manager
  32088. */
  32089. removeActionManager(toRemove: AbstractActionManager): number;
  32090. /**
  32091. * Removes the given texture from this scene.
  32092. * @param toRemove The texture to remove
  32093. * @returns The index of the removed texture
  32094. */
  32095. removeTexture(toRemove: BaseTexture): number;
  32096. /**
  32097. * Adds the given light to this scene
  32098. * @param newLight The light to add
  32099. */
  32100. addLight(newLight: Light): void;
  32101. /**
  32102. * Sorts the list list based on light priorities
  32103. */
  32104. sortLightsByPriority(): void;
  32105. /**
  32106. * Adds the given camera to this scene
  32107. * @param newCamera The camera to add
  32108. */
  32109. addCamera(newCamera: Camera): void;
  32110. /**
  32111. * Adds the given skeleton to this scene
  32112. * @param newSkeleton The skeleton to add
  32113. */
  32114. addSkeleton(newSkeleton: Skeleton): void;
  32115. /**
  32116. * Adds the given particle system to this scene
  32117. * @param newParticleSystem The particle system to add
  32118. */
  32119. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32120. /**
  32121. * Adds the given animation to this scene
  32122. * @param newAnimation The animation to add
  32123. */
  32124. addAnimation(newAnimation: Animation): void;
  32125. /**
  32126. * Adds the given animation group to this scene.
  32127. * @param newAnimationGroup The animation group to add
  32128. */
  32129. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32130. /**
  32131. * Adds the given multi-material to this scene
  32132. * @param newMultiMaterial The multi-material to add
  32133. */
  32134. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32135. /**
  32136. * Adds the given material to this scene
  32137. * @param newMaterial The material to add
  32138. */
  32139. addMaterial(newMaterial: Material): void;
  32140. /**
  32141. * Adds the given morph target to this scene
  32142. * @param newMorphTargetManager The morph target to add
  32143. */
  32144. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32145. /**
  32146. * Adds the given geometry to this scene
  32147. * @param newGeometry The geometry to add
  32148. */
  32149. addGeometry(newGeometry: Geometry): void;
  32150. /**
  32151. * Adds the given action manager to this scene
  32152. * @param newActionManager The action manager to add
  32153. */
  32154. addActionManager(newActionManager: AbstractActionManager): void;
  32155. /**
  32156. * Adds the given texture to this scene.
  32157. * @param newTexture The texture to add
  32158. */
  32159. addTexture(newTexture: BaseTexture): void;
  32160. /**
  32161. * Switch active camera
  32162. * @param newCamera defines the new active camera
  32163. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32164. */
  32165. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32166. /**
  32167. * sets the active camera of the scene using its ID
  32168. * @param id defines the camera's ID
  32169. * @return the new active camera or null if none found.
  32170. */
  32171. setActiveCameraByID(id: string): Nullable<Camera>;
  32172. /**
  32173. * sets the active camera of the scene using its name
  32174. * @param name defines the camera's name
  32175. * @returns the new active camera or null if none found.
  32176. */
  32177. setActiveCameraByName(name: string): Nullable<Camera>;
  32178. /**
  32179. * get an animation group using its name
  32180. * @param name defines the material's name
  32181. * @return the animation group or null if none found.
  32182. */
  32183. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32184. /**
  32185. * get a material using its id
  32186. * @param id defines the material's ID
  32187. * @return the material or null if none found.
  32188. */
  32189. getMaterialByID(id: string): Nullable<Material>;
  32190. /**
  32191. * Gets a material using its name
  32192. * @param name defines the material's name
  32193. * @return the material or null if none found.
  32194. */
  32195. getMaterialByName(name: string): Nullable<Material>;
  32196. /**
  32197. * Gets a camera using its id
  32198. * @param id defines the id to look for
  32199. * @returns the camera or null if not found
  32200. */
  32201. getCameraByID(id: string): Nullable<Camera>;
  32202. /**
  32203. * Gets a camera using its unique id
  32204. * @param uniqueId defines the unique id to look for
  32205. * @returns the camera or null if not found
  32206. */
  32207. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32208. /**
  32209. * Gets a camera using its name
  32210. * @param name defines the camera's name
  32211. * @return the camera or null if none found.
  32212. */
  32213. getCameraByName(name: string): Nullable<Camera>;
  32214. /**
  32215. * Gets a bone using its id
  32216. * @param id defines the bone's id
  32217. * @return the bone or null if not found
  32218. */
  32219. getBoneByID(id: string): Nullable<Bone>;
  32220. /**
  32221. * Gets a bone using its id
  32222. * @param name defines the bone's name
  32223. * @return the bone or null if not found
  32224. */
  32225. getBoneByName(name: string): Nullable<Bone>;
  32226. /**
  32227. * Gets a light node using its name
  32228. * @param name defines the the light's name
  32229. * @return the light or null if none found.
  32230. */
  32231. getLightByName(name: string): Nullable<Light>;
  32232. /**
  32233. * Gets a light node using its id
  32234. * @param id defines the light's id
  32235. * @return the light or null if none found.
  32236. */
  32237. getLightByID(id: string): Nullable<Light>;
  32238. /**
  32239. * Gets a light node using its scene-generated unique ID
  32240. * @param uniqueId defines the light's unique id
  32241. * @return the light or null if none found.
  32242. */
  32243. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32244. /**
  32245. * Gets a particle system by id
  32246. * @param id defines the particle system id
  32247. * @return the corresponding system or null if none found
  32248. */
  32249. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32250. /**
  32251. * Gets a geometry using its ID
  32252. * @param id defines the geometry's id
  32253. * @return the geometry or null if none found.
  32254. */
  32255. getGeometryByID(id: string): Nullable<Geometry>;
  32256. private _getGeometryByUniqueID;
  32257. /**
  32258. * Add a new geometry to this scene
  32259. * @param geometry defines the geometry to be added to the scene.
  32260. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32261. * @return a boolean defining if the geometry was added or not
  32262. */
  32263. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32264. /**
  32265. * Removes an existing geometry
  32266. * @param geometry defines the geometry to be removed from the scene
  32267. * @return a boolean defining if the geometry was removed or not
  32268. */
  32269. removeGeometry(geometry: Geometry): boolean;
  32270. /**
  32271. * Gets the list of geometries attached to the scene
  32272. * @returns an array of Geometry
  32273. */
  32274. getGeometries(): Geometry[];
  32275. /**
  32276. * Gets the first added mesh found of a given ID
  32277. * @param id defines the id to search for
  32278. * @return the mesh found or null if not found at all
  32279. */
  32280. getMeshByID(id: string): Nullable<AbstractMesh>;
  32281. /**
  32282. * Gets a list of meshes using their id
  32283. * @param id defines the id to search for
  32284. * @returns a list of meshes
  32285. */
  32286. getMeshesByID(id: string): Array<AbstractMesh>;
  32287. /**
  32288. * Gets the first added transform node found of a given ID
  32289. * @param id defines the id to search for
  32290. * @return the found transform node or null if not found at all.
  32291. */
  32292. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32293. /**
  32294. * Gets a list of transform nodes using their id
  32295. * @param id defines the id to search for
  32296. * @returns a list of transform nodes
  32297. */
  32298. getTransformNodesByID(id: string): Array<TransformNode>;
  32299. /**
  32300. * Gets a mesh with its auto-generated unique id
  32301. * @param uniqueId defines the unique id to search for
  32302. * @return the found mesh or null if not found at all.
  32303. */
  32304. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32305. /**
  32306. * Gets a the last added mesh using a given id
  32307. * @param id defines the id to search for
  32308. * @return the found mesh or null if not found at all.
  32309. */
  32310. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32311. /**
  32312. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32313. * @param id defines the id to search for
  32314. * @return the found node or null if not found at all
  32315. */
  32316. getLastEntryByID(id: string): Nullable<Node>;
  32317. /**
  32318. * Gets a node (Mesh, Camera, Light) using a given id
  32319. * @param id defines the id to search for
  32320. * @return the found node or null if not found at all
  32321. */
  32322. getNodeByID(id: string): Nullable<Node>;
  32323. /**
  32324. * Gets a node (Mesh, Camera, Light) using a given name
  32325. * @param name defines the name to search for
  32326. * @return the found node or null if not found at all.
  32327. */
  32328. getNodeByName(name: string): Nullable<Node>;
  32329. /**
  32330. * Gets a mesh using a given name
  32331. * @param name defines the name to search for
  32332. * @return the found mesh or null if not found at all.
  32333. */
  32334. getMeshByName(name: string): Nullable<AbstractMesh>;
  32335. /**
  32336. * Gets a transform node using a given name
  32337. * @param name defines the name to search for
  32338. * @return the found transform node or null if not found at all.
  32339. */
  32340. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32341. /**
  32342. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32343. * @param id defines the id to search for
  32344. * @return the found skeleton or null if not found at all.
  32345. */
  32346. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32347. /**
  32348. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32349. * @param id defines the id to search for
  32350. * @return the found skeleton or null if not found at all.
  32351. */
  32352. getSkeletonById(id: string): Nullable<Skeleton>;
  32353. /**
  32354. * Gets a skeleton using a given name
  32355. * @param name defines the name to search for
  32356. * @return the found skeleton or null if not found at all.
  32357. */
  32358. getSkeletonByName(name: string): Nullable<Skeleton>;
  32359. /**
  32360. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32361. * @param id defines the id to search for
  32362. * @return the found morph target manager or null if not found at all.
  32363. */
  32364. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32365. /**
  32366. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32367. * @param id defines the id to search for
  32368. * @return the found morph target or null if not found at all.
  32369. */
  32370. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32371. /**
  32372. * Gets a boolean indicating if the given mesh is active
  32373. * @param mesh defines the mesh to look for
  32374. * @returns true if the mesh is in the active list
  32375. */
  32376. isActiveMesh(mesh: AbstractMesh): boolean;
  32377. /**
  32378. * Return a unique id as a string which can serve as an identifier for the scene
  32379. */
  32380. readonly uid: string;
  32381. /**
  32382. * Add an externaly attached data from its key.
  32383. * This method call will fail and return false, if such key already exists.
  32384. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32385. * @param key the unique key that identifies the data
  32386. * @param data the data object to associate to the key for this Engine instance
  32387. * @return true if no such key were already present and the data was added successfully, false otherwise
  32388. */
  32389. addExternalData<T>(key: string, data: T): boolean;
  32390. /**
  32391. * Get an externaly attached data from its key
  32392. * @param key the unique key that identifies the data
  32393. * @return the associated data, if present (can be null), or undefined if not present
  32394. */
  32395. getExternalData<T>(key: string): Nullable<T>;
  32396. /**
  32397. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32398. * @param key the unique key that identifies the data
  32399. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32400. * @return the associated data, can be null if the factory returned null.
  32401. */
  32402. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32403. /**
  32404. * Remove an externaly attached data from the Engine instance
  32405. * @param key the unique key that identifies the data
  32406. * @return true if the data was successfully removed, false if it doesn't exist
  32407. */
  32408. removeExternalData(key: string): boolean;
  32409. private _evaluateSubMesh;
  32410. /**
  32411. * Clear the processed materials smart array preventing retention point in material dispose.
  32412. */
  32413. freeProcessedMaterials(): void;
  32414. private _preventFreeActiveMeshesAndRenderingGroups;
  32415. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32416. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32417. * when disposing several meshes in a row or a hierarchy of meshes.
  32418. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32419. */
  32420. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32421. /**
  32422. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32423. */
  32424. freeActiveMeshes(): void;
  32425. /**
  32426. * Clear the info related to rendering groups preventing retention points during dispose.
  32427. */
  32428. freeRenderingGroups(): void;
  32429. /** @hidden */
  32430. _isInIntermediateRendering(): boolean;
  32431. /**
  32432. * Lambda returning the list of potentially active meshes.
  32433. */
  32434. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32435. /**
  32436. * Lambda returning the list of potentially active sub meshes.
  32437. */
  32438. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  32439. /**
  32440. * Lambda returning the list of potentially intersecting sub meshes.
  32441. */
  32442. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  32443. /**
  32444. * Lambda returning the list of potentially colliding sub meshes.
  32445. */
  32446. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  32447. private _activeMeshesFrozen;
  32448. /**
  32449. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  32450. * @returns the current scene
  32451. */
  32452. freezeActiveMeshes(): Scene;
  32453. /**
  32454. * Use this function to restart evaluating active meshes on every frame
  32455. * @returns the current scene
  32456. */
  32457. unfreezeActiveMeshes(): Scene;
  32458. private _evaluateActiveMeshes;
  32459. private _activeMesh;
  32460. /**
  32461. * Update the transform matrix to update from the current active camera
  32462. * @param force defines a boolean used to force the update even if cache is up to date
  32463. */
  32464. updateTransformMatrix(force?: boolean): void;
  32465. /**
  32466. * 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)
  32467. * @param alternateCamera defines the camera to use
  32468. */
  32469. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  32470. /** @hidden */
  32471. _allowPostProcessClearColor: boolean;
  32472. private _renderForCamera;
  32473. private _processSubCameras;
  32474. private _checkIntersections;
  32475. /** @hidden */
  32476. _advancePhysicsEngineStep(step: number): void;
  32477. /**
  32478. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  32479. */
  32480. getDeterministicFrameTime: () => number;
  32481. /** @hidden */
  32482. _animate(): void;
  32483. /**
  32484. * Render the scene
  32485. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  32486. */
  32487. render(updateCameras?: boolean): void;
  32488. /**
  32489. * Freeze all materials
  32490. * A frozen material will not be updatable but should be faster to render
  32491. */
  32492. freezeMaterials(): void;
  32493. /**
  32494. * Unfreeze all materials
  32495. * A frozen material will not be updatable but should be faster to render
  32496. */
  32497. unfreezeMaterials(): void;
  32498. /**
  32499. * Releases all held ressources
  32500. */
  32501. dispose(): void;
  32502. /**
  32503. * Gets if the scene is already disposed
  32504. */
  32505. readonly isDisposed: boolean;
  32506. /**
  32507. * Call this function to reduce memory footprint of the scene.
  32508. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  32509. */
  32510. clearCachedVertexData(): void;
  32511. /**
  32512. * This function will remove the local cached buffer data from texture.
  32513. * It will save memory but will prevent the texture from being rebuilt
  32514. */
  32515. cleanCachedTextureBuffer(): void;
  32516. /**
  32517. * Get the world extend vectors with an optional filter
  32518. *
  32519. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  32520. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  32521. */
  32522. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  32523. min: Vector3;
  32524. max: Vector3;
  32525. };
  32526. /**
  32527. * Creates a ray that can be used to pick in the scene
  32528. * @param x defines the x coordinate of the origin (on-screen)
  32529. * @param y defines the y coordinate of the origin (on-screen)
  32530. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32531. * @param camera defines the camera to use for the picking
  32532. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32533. * @returns a Ray
  32534. */
  32535. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  32536. /**
  32537. * Creates a ray that can be used to pick in the scene
  32538. * @param x defines the x coordinate of the origin (on-screen)
  32539. * @param y defines the y coordinate of the origin (on-screen)
  32540. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32541. * @param result defines the ray where to store the picking ray
  32542. * @param camera defines the camera to use for the picking
  32543. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32544. * @returns the current scene
  32545. */
  32546. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  32547. /**
  32548. * Creates a ray that can be used to pick in the scene
  32549. * @param x defines the x coordinate of the origin (on-screen)
  32550. * @param y defines the y coordinate of the origin (on-screen)
  32551. * @param camera defines the camera to use for the picking
  32552. * @returns a Ray
  32553. */
  32554. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  32555. /**
  32556. * Creates a ray that can be used to pick in the scene
  32557. * @param x defines the x coordinate of the origin (on-screen)
  32558. * @param y defines the y coordinate of the origin (on-screen)
  32559. * @param result defines the ray where to store the picking ray
  32560. * @param camera defines the camera to use for the picking
  32561. * @returns the current scene
  32562. */
  32563. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  32564. /** Launch a ray to try to pick a mesh in the scene
  32565. * @param x position on screen
  32566. * @param y position on screen
  32567. * @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
  32568. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  32569. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32570. * @returns a PickingInfo
  32571. */
  32572. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  32573. /** Use the given ray to pick a mesh in the scene
  32574. * @param ray The ray to use to pick meshes
  32575. * @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
  32576. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  32577. * @returns a PickingInfo
  32578. */
  32579. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  32580. /**
  32581. * Launch a ray to try to pick a mesh in the scene
  32582. * @param x X position on screen
  32583. * @param y Y position on screen
  32584. * @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
  32585. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32586. * @returns an array of PickingInfo
  32587. */
  32588. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  32589. /**
  32590. * Launch a ray to try to pick a mesh in the scene
  32591. * @param ray Ray to use
  32592. * @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
  32593. * @returns an array of PickingInfo
  32594. */
  32595. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  32596. /**
  32597. * Force the value of meshUnderPointer
  32598. * @param mesh defines the mesh to use
  32599. */
  32600. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32601. /**
  32602. * Gets the mesh under the pointer
  32603. * @returns a Mesh or null if no mesh is under the pointer
  32604. */
  32605. getPointerOverMesh(): Nullable<AbstractMesh>;
  32606. /** @hidden */
  32607. _rebuildGeometries(): void;
  32608. /** @hidden */
  32609. _rebuildTextures(): void;
  32610. private _getByTags;
  32611. /**
  32612. * Get a list of meshes by tags
  32613. * @param tagsQuery defines the tags query to use
  32614. * @param forEach defines a predicate used to filter results
  32615. * @returns an array of Mesh
  32616. */
  32617. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32618. /**
  32619. * Get a list of cameras by tags
  32620. * @param tagsQuery defines the tags query to use
  32621. * @param forEach defines a predicate used to filter results
  32622. * @returns an array of Camera
  32623. */
  32624. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32625. /**
  32626. * Get a list of lights by tags
  32627. * @param tagsQuery defines the tags query to use
  32628. * @param forEach defines a predicate used to filter results
  32629. * @returns an array of Light
  32630. */
  32631. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32632. /**
  32633. * Get a list of materials by tags
  32634. * @param tagsQuery defines the tags query to use
  32635. * @param forEach defines a predicate used to filter results
  32636. * @returns an array of Material
  32637. */
  32638. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  32639. /**
  32640. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32641. * This allowed control for front to back rendering or reversly depending of the special needs.
  32642. *
  32643. * @param renderingGroupId The rendering group id corresponding to its index
  32644. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32645. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32646. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32647. */
  32648. 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;
  32649. /**
  32650. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32651. *
  32652. * @param renderingGroupId The rendering group id corresponding to its index
  32653. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32654. * @param depth Automatically clears depth between groups if true and autoClear is true.
  32655. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  32656. */
  32657. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  32658. /**
  32659. * Gets the current auto clear configuration for one rendering group of the rendering
  32660. * manager.
  32661. * @param index the rendering group index to get the information for
  32662. * @returns The auto clear setup for the requested rendering group
  32663. */
  32664. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  32665. private _blockMaterialDirtyMechanism;
  32666. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  32667. blockMaterialDirtyMechanism: boolean;
  32668. /**
  32669. * Will flag all materials as dirty to trigger new shader compilation
  32670. * @param flag defines the flag used to specify which material part must be marked as dirty
  32671. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  32672. */
  32673. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32674. /** @hidden */
  32675. _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;
  32676. /** @hidden */
  32677. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32678. }
  32679. }
  32680. declare module BABYLON {
  32681. /**
  32682. * Set of assets to keep when moving a scene into an asset container.
  32683. */
  32684. export class KeepAssets extends AbstractScene {
  32685. }
  32686. /**
  32687. * Container with a set of assets that can be added or removed from a scene.
  32688. */
  32689. export class AssetContainer extends AbstractScene {
  32690. /**
  32691. * The scene the AssetContainer belongs to.
  32692. */
  32693. scene: Scene;
  32694. /**
  32695. * Instantiates an AssetContainer.
  32696. * @param scene The scene the AssetContainer belongs to.
  32697. */
  32698. constructor(scene: Scene);
  32699. /**
  32700. * Adds all the assets from the container to the scene.
  32701. */
  32702. addAllToScene(): void;
  32703. /**
  32704. * Removes all the assets in the container from the scene
  32705. */
  32706. removeAllFromScene(): void;
  32707. /**
  32708. * Disposes all the assets in the container
  32709. */
  32710. dispose(): void;
  32711. private _moveAssets;
  32712. /**
  32713. * Removes all the assets contained in the scene and adds them to the container.
  32714. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  32715. */
  32716. moveAllFromScene(keepAssets?: KeepAssets): void;
  32717. /**
  32718. * 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.
  32719. * @returns the root mesh
  32720. */
  32721. createRootMesh(): Mesh;
  32722. }
  32723. }
  32724. declare module BABYLON {
  32725. /**
  32726. * Defines how the parser contract is defined.
  32727. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  32728. */
  32729. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  32730. /**
  32731. * Defines how the individual parser contract is defined.
  32732. * These parser can parse an individual asset
  32733. */
  32734. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  32735. /**
  32736. * Base class of the scene acting as a container for the different elements composing a scene.
  32737. * This class is dynamically extended by the different components of the scene increasing
  32738. * flexibility and reducing coupling
  32739. */
  32740. export abstract class AbstractScene {
  32741. /**
  32742. * Stores the list of available parsers in the application.
  32743. */
  32744. private static _BabylonFileParsers;
  32745. /**
  32746. * Stores the list of available individual parsers in the application.
  32747. */
  32748. private static _IndividualBabylonFileParsers;
  32749. /**
  32750. * Adds a parser in the list of available ones
  32751. * @param name Defines the name of the parser
  32752. * @param parser Defines the parser to add
  32753. */
  32754. static AddParser(name: string, parser: BabylonFileParser): void;
  32755. /**
  32756. * Gets a general parser from the list of avaialble ones
  32757. * @param name Defines the name of the parser
  32758. * @returns the requested parser or null
  32759. */
  32760. static GetParser(name: string): Nullable<BabylonFileParser>;
  32761. /**
  32762. * Adds n individual parser in the list of available ones
  32763. * @param name Defines the name of the parser
  32764. * @param parser Defines the parser to add
  32765. */
  32766. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  32767. /**
  32768. * Gets an individual parser from the list of avaialble ones
  32769. * @param name Defines the name of the parser
  32770. * @returns the requested parser or null
  32771. */
  32772. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  32773. /**
  32774. * Parser json data and populate both a scene and its associated container object
  32775. * @param jsonData Defines the data to parse
  32776. * @param scene Defines the scene to parse the data for
  32777. * @param container Defines the container attached to the parsing sequence
  32778. * @param rootUrl Defines the root url of the data
  32779. */
  32780. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  32781. /**
  32782. * Gets the list of root nodes (ie. nodes with no parent)
  32783. */
  32784. rootNodes: Node[];
  32785. /** All of the cameras added to this scene
  32786. * @see http://doc.babylonjs.com/babylon101/cameras
  32787. */
  32788. cameras: Camera[];
  32789. /**
  32790. * All of the lights added to this scene
  32791. * @see http://doc.babylonjs.com/babylon101/lights
  32792. */
  32793. lights: Light[];
  32794. /**
  32795. * All of the (abstract) meshes added to this scene
  32796. */
  32797. meshes: AbstractMesh[];
  32798. /**
  32799. * The list of skeletons added to the scene
  32800. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32801. */
  32802. skeletons: Skeleton[];
  32803. /**
  32804. * All of the particle systems added to this scene
  32805. * @see http://doc.babylonjs.com/babylon101/particles
  32806. */
  32807. particleSystems: IParticleSystem[];
  32808. /**
  32809. * Gets a list of Animations associated with the scene
  32810. */
  32811. animations: Animation[];
  32812. /**
  32813. * All of the animation groups added to this scene
  32814. * @see http://doc.babylonjs.com/how_to/group
  32815. */
  32816. animationGroups: AnimationGroup[];
  32817. /**
  32818. * All of the multi-materials added to this scene
  32819. * @see http://doc.babylonjs.com/how_to/multi_materials
  32820. */
  32821. multiMaterials: MultiMaterial[];
  32822. /**
  32823. * All of the materials added to this scene
  32824. * In the context of a Scene, it is not supposed to be modified manually.
  32825. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  32826. * Note also that the order of the Material wihin the array is not significant and might change.
  32827. * @see http://doc.babylonjs.com/babylon101/materials
  32828. */
  32829. materials: Material[];
  32830. /**
  32831. * The list of morph target managers added to the scene
  32832. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  32833. */
  32834. morphTargetManagers: MorphTargetManager[];
  32835. /**
  32836. * The list of geometries used in the scene.
  32837. */
  32838. geometries: Geometry[];
  32839. /**
  32840. * All of the tranform nodes added to this scene
  32841. * In the context of a Scene, it is not supposed to be modified manually.
  32842. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  32843. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  32844. * @see http://doc.babylonjs.com/how_to/transformnode
  32845. */
  32846. transformNodes: TransformNode[];
  32847. /**
  32848. * ActionManagers available on the scene.
  32849. */
  32850. actionManagers: AbstractActionManager[];
  32851. /**
  32852. * Textures to keep.
  32853. */
  32854. textures: BaseTexture[];
  32855. }
  32856. }
  32857. declare module BABYLON {
  32858. /**
  32859. * Defines a sound that can be played in the application.
  32860. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  32861. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32862. */
  32863. export class Sound {
  32864. /**
  32865. * The name of the sound in the scene.
  32866. */
  32867. name: string;
  32868. /**
  32869. * Does the sound autoplay once loaded.
  32870. */
  32871. autoplay: boolean;
  32872. /**
  32873. * Does the sound loop after it finishes playing once.
  32874. */
  32875. loop: boolean;
  32876. /**
  32877. * Does the sound use a custom attenuation curve to simulate the falloff
  32878. * happening when the source gets further away from the camera.
  32879. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  32880. */
  32881. useCustomAttenuation: boolean;
  32882. /**
  32883. * The sound track id this sound belongs to.
  32884. */
  32885. soundTrackId: number;
  32886. /**
  32887. * Is this sound currently played.
  32888. */
  32889. isPlaying: boolean;
  32890. /**
  32891. * Is this sound currently paused.
  32892. */
  32893. isPaused: boolean;
  32894. /**
  32895. * Does this sound enables spatial sound.
  32896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32897. */
  32898. spatialSound: boolean;
  32899. /**
  32900. * Define the reference distance the sound should be heard perfectly.
  32901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32902. */
  32903. refDistance: number;
  32904. /**
  32905. * Define the roll off factor of spatial sounds.
  32906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32907. */
  32908. rolloffFactor: number;
  32909. /**
  32910. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  32911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32912. */
  32913. maxDistance: number;
  32914. /**
  32915. * Define the distance attenuation model the sound will follow.
  32916. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32917. */
  32918. distanceModel: string;
  32919. /**
  32920. * @hidden
  32921. * Back Compat
  32922. **/
  32923. onended: () => any;
  32924. /**
  32925. * Observable event when the current playing sound finishes.
  32926. */
  32927. onEndedObservable: Observable<Sound>;
  32928. private _panningModel;
  32929. private _playbackRate;
  32930. private _streaming;
  32931. private _startTime;
  32932. private _startOffset;
  32933. private _position;
  32934. /** @hidden */
  32935. _positionInEmitterSpace: boolean;
  32936. private _localDirection;
  32937. private _volume;
  32938. private _isReadyToPlay;
  32939. private _isDirectional;
  32940. private _readyToPlayCallback;
  32941. private _audioBuffer;
  32942. private _soundSource;
  32943. private _streamingSource;
  32944. private _soundPanner;
  32945. private _soundGain;
  32946. private _inputAudioNode;
  32947. private _outputAudioNode;
  32948. private _coneInnerAngle;
  32949. private _coneOuterAngle;
  32950. private _coneOuterGain;
  32951. private _scene;
  32952. private _connectedTransformNode;
  32953. private _customAttenuationFunction;
  32954. private _registerFunc;
  32955. private _isOutputConnected;
  32956. private _htmlAudioElement;
  32957. private _urlType;
  32958. /** @hidden */
  32959. static _SceneComponentInitialization: (scene: Scene) => void;
  32960. /**
  32961. * Create a sound and attach it to a scene
  32962. * @param name Name of your sound
  32963. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  32964. * @param scene defines the scene the sound belongs to
  32965. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  32966. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  32967. */
  32968. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  32969. /**
  32970. * Release the sound and its associated resources
  32971. */
  32972. dispose(): void;
  32973. /**
  32974. * Gets if the sounds is ready to be played or not.
  32975. * @returns true if ready, otherwise false
  32976. */
  32977. isReady(): boolean;
  32978. private _soundLoaded;
  32979. /**
  32980. * Sets the data of the sound from an audiobuffer
  32981. * @param audioBuffer The audioBuffer containing the data
  32982. */
  32983. setAudioBuffer(audioBuffer: AudioBuffer): void;
  32984. /**
  32985. * Updates the current sounds options such as maxdistance, loop...
  32986. * @param options A JSON object containing values named as the object properties
  32987. */
  32988. updateOptions(options: any): void;
  32989. private _createSpatialParameters;
  32990. private _updateSpatialParameters;
  32991. /**
  32992. * Switch the panning model to HRTF:
  32993. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  32994. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32995. */
  32996. switchPanningModelToHRTF(): void;
  32997. /**
  32998. * Switch the panning model to Equal Power:
  32999. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33001. */
  33002. switchPanningModelToEqualPower(): void;
  33003. private _switchPanningModel;
  33004. /**
  33005. * Connect this sound to a sound track audio node like gain...
  33006. * @param soundTrackAudioNode the sound track audio node to connect to
  33007. */
  33008. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33009. /**
  33010. * Transform this sound into a directional source
  33011. * @param coneInnerAngle Size of the inner cone in degree
  33012. * @param coneOuterAngle Size of the outer cone in degree
  33013. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33014. */
  33015. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33016. /**
  33017. * Gets or sets the inner angle for the directional cone.
  33018. */
  33019. /**
  33020. * Gets or sets the inner angle for the directional cone.
  33021. */
  33022. directionalConeInnerAngle: number;
  33023. /**
  33024. * Gets or sets the outer angle for the directional cone.
  33025. */
  33026. /**
  33027. * Gets or sets the outer angle for the directional cone.
  33028. */
  33029. directionalConeOuterAngle: number;
  33030. /**
  33031. * Sets the position of the emitter if spatial sound is enabled
  33032. * @param newPosition Defines the new posisiton
  33033. */
  33034. setPosition(newPosition: Vector3): void;
  33035. /**
  33036. * Sets the local direction of the emitter if spatial sound is enabled
  33037. * @param newLocalDirection Defines the new local direction
  33038. */
  33039. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33040. private _updateDirection;
  33041. /** @hidden */
  33042. updateDistanceFromListener(): void;
  33043. /**
  33044. * Sets a new custom attenuation function for the sound.
  33045. * @param callback Defines the function used for the attenuation
  33046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33047. */
  33048. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33049. /**
  33050. * Play the sound
  33051. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33052. * @param offset (optional) Start the sound setting it at a specific time
  33053. */
  33054. play(time?: number, offset?: number): void;
  33055. private _onended;
  33056. /**
  33057. * Stop the sound
  33058. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33059. */
  33060. stop(time?: number): void;
  33061. /**
  33062. * Put the sound in pause
  33063. */
  33064. pause(): void;
  33065. /**
  33066. * Sets a dedicated volume for this sounds
  33067. * @param newVolume Define the new volume of the sound
  33068. * @param time Define in how long the sound should be at this value
  33069. */
  33070. setVolume(newVolume: number, time?: number): void;
  33071. /**
  33072. * Set the sound play back rate
  33073. * @param newPlaybackRate Define the playback rate the sound should be played at
  33074. */
  33075. setPlaybackRate(newPlaybackRate: number): void;
  33076. /**
  33077. * Gets the volume of the sound.
  33078. * @returns the volume of the sound
  33079. */
  33080. getVolume(): number;
  33081. /**
  33082. * Attach the sound to a dedicated mesh
  33083. * @param transformNode The transform node to connect the sound with
  33084. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33085. */
  33086. attachToMesh(transformNode: TransformNode): void;
  33087. /**
  33088. * Detach the sound from the previously attached mesh
  33089. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33090. */
  33091. detachFromMesh(): void;
  33092. private _onRegisterAfterWorldMatrixUpdate;
  33093. /**
  33094. * Clone the current sound in the scene.
  33095. * @returns the new sound clone
  33096. */
  33097. clone(): Nullable<Sound>;
  33098. /**
  33099. * Gets the current underlying audio buffer containing the data
  33100. * @returns the audio buffer
  33101. */
  33102. getAudioBuffer(): Nullable<AudioBuffer>;
  33103. /**
  33104. * Serializes the Sound in a JSON representation
  33105. * @returns the JSON representation of the sound
  33106. */
  33107. serialize(): any;
  33108. /**
  33109. * Parse a JSON representation of a sound to innstantiate in a given scene
  33110. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33111. * @param scene Define the scene the new parsed sound should be created in
  33112. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33113. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33114. * @returns the newly parsed sound
  33115. */
  33116. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33117. }
  33118. }
  33119. declare module BABYLON {
  33120. /**
  33121. * This defines an action helpful to play a defined sound on a triggered action.
  33122. */
  33123. export class PlaySoundAction extends Action {
  33124. private _sound;
  33125. /**
  33126. * Instantiate the action
  33127. * @param triggerOptions defines the trigger options
  33128. * @param sound defines the sound to play
  33129. * @param condition defines the trigger related conditions
  33130. */
  33131. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33132. /** @hidden */
  33133. _prepare(): void;
  33134. /**
  33135. * Execute the action and play the sound.
  33136. */
  33137. execute(): void;
  33138. /**
  33139. * Serializes the actions and its related information.
  33140. * @param parent defines the object to serialize in
  33141. * @returns the serialized object
  33142. */
  33143. serialize(parent: any): any;
  33144. }
  33145. /**
  33146. * This defines an action helpful to stop a defined sound on a triggered action.
  33147. */
  33148. export class StopSoundAction extends Action {
  33149. private _sound;
  33150. /**
  33151. * Instantiate the action
  33152. * @param triggerOptions defines the trigger options
  33153. * @param sound defines the sound to stop
  33154. * @param condition defines the trigger related conditions
  33155. */
  33156. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33157. /** @hidden */
  33158. _prepare(): void;
  33159. /**
  33160. * Execute the action and stop the sound.
  33161. */
  33162. execute(): void;
  33163. /**
  33164. * Serializes the actions and its related information.
  33165. * @param parent defines the object to serialize in
  33166. * @returns the serialized object
  33167. */
  33168. serialize(parent: any): any;
  33169. }
  33170. }
  33171. declare module BABYLON {
  33172. /**
  33173. * This defines an action responsible to change the value of a property
  33174. * by interpolating between its current value and the newly set one once triggered.
  33175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33176. */
  33177. export class InterpolateValueAction extends Action {
  33178. /**
  33179. * Defines the path of the property where the value should be interpolated
  33180. */
  33181. propertyPath: string;
  33182. /**
  33183. * Defines the target value at the end of the interpolation.
  33184. */
  33185. value: any;
  33186. /**
  33187. * Defines the time it will take for the property to interpolate to the value.
  33188. */
  33189. duration: number;
  33190. /**
  33191. * Defines if the other scene animations should be stopped when the action has been triggered
  33192. */
  33193. stopOtherAnimations?: boolean;
  33194. /**
  33195. * Defines a callback raised once the interpolation animation has been done.
  33196. */
  33197. onInterpolationDone?: () => void;
  33198. /**
  33199. * Observable triggered once the interpolation animation has been done.
  33200. */
  33201. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33202. private _target;
  33203. private _effectiveTarget;
  33204. private _property;
  33205. /**
  33206. * Instantiate the action
  33207. * @param triggerOptions defines the trigger options
  33208. * @param target defines the object containing the value to interpolate
  33209. * @param propertyPath defines the path to the property in the target object
  33210. * @param value defines the target value at the end of the interpolation
  33211. * @param duration deines the time it will take for the property to interpolate to the value.
  33212. * @param condition defines the trigger related conditions
  33213. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33214. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33215. */
  33216. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33217. /** @hidden */
  33218. _prepare(): void;
  33219. /**
  33220. * Execute the action starts the value interpolation.
  33221. */
  33222. execute(): void;
  33223. /**
  33224. * Serializes the actions and its related information.
  33225. * @param parent defines the object to serialize in
  33226. * @returns the serialized object
  33227. */
  33228. serialize(parent: any): any;
  33229. }
  33230. }
  33231. declare module BABYLON {
  33232. /**
  33233. * Options allowed during the creation of a sound track.
  33234. */
  33235. export interface ISoundTrackOptions {
  33236. /**
  33237. * The volume the sound track should take during creation
  33238. */
  33239. volume?: number;
  33240. /**
  33241. * Define if the sound track is the main sound track of the scene
  33242. */
  33243. mainTrack?: boolean;
  33244. }
  33245. /**
  33246. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33247. * It will be also used in a future release to apply effects on a specific track.
  33248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33249. */
  33250. export class SoundTrack {
  33251. /**
  33252. * The unique identifier of the sound track in the scene.
  33253. */
  33254. id: number;
  33255. /**
  33256. * The list of sounds included in the sound track.
  33257. */
  33258. soundCollection: Array<Sound>;
  33259. private _outputAudioNode;
  33260. private _scene;
  33261. private _isMainTrack;
  33262. private _connectedAnalyser;
  33263. private _options;
  33264. private _isInitialized;
  33265. /**
  33266. * Creates a new sound track.
  33267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33268. * @param scene Define the scene the sound track belongs to
  33269. * @param options
  33270. */
  33271. constructor(scene: Scene, options?: ISoundTrackOptions);
  33272. private _initializeSoundTrackAudioGraph;
  33273. /**
  33274. * Release the sound track and its associated resources
  33275. */
  33276. dispose(): void;
  33277. /**
  33278. * Adds a sound to this sound track
  33279. * @param sound define the cound to add
  33280. * @ignoreNaming
  33281. */
  33282. AddSound(sound: Sound): void;
  33283. /**
  33284. * Removes a sound to this sound track
  33285. * @param sound define the cound to remove
  33286. * @ignoreNaming
  33287. */
  33288. RemoveSound(sound: Sound): void;
  33289. /**
  33290. * Set a global volume for the full sound track.
  33291. * @param newVolume Define the new volume of the sound track
  33292. */
  33293. setVolume(newVolume: number): void;
  33294. /**
  33295. * Switch the panning model to HRTF:
  33296. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33297. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33298. */
  33299. switchPanningModelToHRTF(): void;
  33300. /**
  33301. * Switch the panning model to Equal Power:
  33302. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33304. */
  33305. switchPanningModelToEqualPower(): void;
  33306. /**
  33307. * Connect the sound track to an audio analyser allowing some amazing
  33308. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33310. * @param analyser The analyser to connect to the engine
  33311. */
  33312. connectToAnalyser(analyser: Analyser): void;
  33313. }
  33314. }
  33315. declare module BABYLON {
  33316. interface AbstractScene {
  33317. /**
  33318. * The list of sounds used in the scene.
  33319. */
  33320. sounds: Nullable<Array<Sound>>;
  33321. }
  33322. interface Scene {
  33323. /**
  33324. * @hidden
  33325. * Backing field
  33326. */
  33327. _mainSoundTrack: SoundTrack;
  33328. /**
  33329. * The main sound track played by the scene.
  33330. * It cotains your primary collection of sounds.
  33331. */
  33332. mainSoundTrack: SoundTrack;
  33333. /**
  33334. * The list of sound tracks added to the scene
  33335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33336. */
  33337. soundTracks: Nullable<Array<SoundTrack>>;
  33338. /**
  33339. * Gets a sound using a given name
  33340. * @param name defines the name to search for
  33341. * @return the found sound or null if not found at all.
  33342. */
  33343. getSoundByName(name: string): Nullable<Sound>;
  33344. /**
  33345. * Gets or sets if audio support is enabled
  33346. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33347. */
  33348. audioEnabled: boolean;
  33349. /**
  33350. * Gets or sets if audio will be output to headphones
  33351. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33352. */
  33353. headphone: boolean;
  33354. }
  33355. /**
  33356. * Defines the sound scene component responsible to manage any sounds
  33357. * in a given scene.
  33358. */
  33359. export class AudioSceneComponent implements ISceneSerializableComponent {
  33360. /**
  33361. * The component name helpfull to identify the component in the list of scene components.
  33362. */
  33363. readonly name: string;
  33364. /**
  33365. * The scene the component belongs to.
  33366. */
  33367. scene: Scene;
  33368. private _audioEnabled;
  33369. /**
  33370. * Gets whether audio is enabled or not.
  33371. * Please use related enable/disable method to switch state.
  33372. */
  33373. readonly audioEnabled: boolean;
  33374. private _headphone;
  33375. /**
  33376. * Gets whether audio is outputing to headphone or not.
  33377. * Please use the according Switch methods to change output.
  33378. */
  33379. readonly headphone: boolean;
  33380. /**
  33381. * Creates a new instance of the component for the given scene
  33382. * @param scene Defines the scene to register the component in
  33383. */
  33384. constructor(scene: Scene);
  33385. /**
  33386. * Registers the component in a given scene
  33387. */
  33388. register(): void;
  33389. /**
  33390. * Rebuilds the elements related to this component in case of
  33391. * context lost for instance.
  33392. */
  33393. rebuild(): void;
  33394. /**
  33395. * Serializes the component data to the specified json object
  33396. * @param serializationObject The object to serialize to
  33397. */
  33398. serialize(serializationObject: any): void;
  33399. /**
  33400. * Adds all the element from the container to the scene
  33401. * @param container the container holding the elements
  33402. */
  33403. addFromContainer(container: AbstractScene): void;
  33404. /**
  33405. * Removes all the elements in the container from the scene
  33406. * @param container contains the elements to remove
  33407. */
  33408. removeFromContainer(container: AbstractScene): void;
  33409. /**
  33410. * Disposes the component and the associated ressources.
  33411. */
  33412. dispose(): void;
  33413. /**
  33414. * Disables audio in the associated scene.
  33415. */
  33416. disableAudio(): void;
  33417. /**
  33418. * Enables audio in the associated scene.
  33419. */
  33420. enableAudio(): void;
  33421. /**
  33422. * Switch audio to headphone output.
  33423. */
  33424. switchAudioModeForHeadphones(): void;
  33425. /**
  33426. * Switch audio to normal speakers.
  33427. */
  33428. switchAudioModeForNormalSpeakers(): void;
  33429. private _afterRender;
  33430. }
  33431. }
  33432. declare module BABYLON {
  33433. /**
  33434. * Wraps one or more Sound objects and selects one with random weight for playback.
  33435. */
  33436. export class WeightedSound {
  33437. /** When true a Sound will be selected and played when the current playing Sound completes. */
  33438. loop: boolean;
  33439. private _coneInnerAngle;
  33440. private _coneOuterAngle;
  33441. private _volume;
  33442. /** A Sound is currently playing. */
  33443. isPlaying: boolean;
  33444. /** A Sound is currently paused. */
  33445. isPaused: boolean;
  33446. private _sounds;
  33447. private _weights;
  33448. private _currentIndex?;
  33449. /**
  33450. * Creates a new WeightedSound from the list of sounds given.
  33451. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  33452. * @param sounds Array of Sounds that will be selected from.
  33453. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  33454. */
  33455. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  33456. /**
  33457. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  33458. */
  33459. /**
  33460. * The size of cone in degress for a directional sound in which there will be no attenuation.
  33461. */
  33462. directionalConeInnerAngle: number;
  33463. /**
  33464. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33465. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33466. */
  33467. /**
  33468. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33469. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33470. */
  33471. directionalConeOuterAngle: number;
  33472. /**
  33473. * Playback volume.
  33474. */
  33475. /**
  33476. * Playback volume.
  33477. */
  33478. volume: number;
  33479. private _onended;
  33480. /**
  33481. * Suspend playback
  33482. */
  33483. pause(): void;
  33484. /**
  33485. * Stop playback
  33486. */
  33487. stop(): void;
  33488. /**
  33489. * Start playback.
  33490. * @param startOffset Position the clip head at a specific time in seconds.
  33491. */
  33492. play(startOffset?: number): void;
  33493. }
  33494. }
  33495. declare module BABYLON {
  33496. /**
  33497. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  33498. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33499. */
  33500. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  33501. /**
  33502. * Gets the name of the behavior.
  33503. */
  33504. readonly name: string;
  33505. /**
  33506. * The easing function used by animations
  33507. */
  33508. static EasingFunction: BackEase;
  33509. /**
  33510. * The easing mode used by animations
  33511. */
  33512. static EasingMode: number;
  33513. /**
  33514. * The duration of the animation, in milliseconds
  33515. */
  33516. transitionDuration: number;
  33517. /**
  33518. * Length of the distance animated by the transition when lower radius is reached
  33519. */
  33520. lowerRadiusTransitionRange: number;
  33521. /**
  33522. * Length of the distance animated by the transition when upper radius is reached
  33523. */
  33524. upperRadiusTransitionRange: number;
  33525. private _autoTransitionRange;
  33526. /**
  33527. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33528. */
  33529. /**
  33530. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33531. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  33532. */
  33533. autoTransitionRange: boolean;
  33534. private _attachedCamera;
  33535. private _onAfterCheckInputsObserver;
  33536. private _onMeshTargetChangedObserver;
  33537. /**
  33538. * Initializes the behavior.
  33539. */
  33540. init(): void;
  33541. /**
  33542. * Attaches the behavior to its arc rotate camera.
  33543. * @param camera Defines the camera to attach the behavior to
  33544. */
  33545. attach(camera: ArcRotateCamera): void;
  33546. /**
  33547. * Detaches the behavior from its current arc rotate camera.
  33548. */
  33549. detach(): void;
  33550. private _radiusIsAnimating;
  33551. private _radiusBounceTransition;
  33552. private _animatables;
  33553. private _cachedWheelPrecision;
  33554. /**
  33555. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  33556. * @param radiusLimit The limit to check against.
  33557. * @return Bool to indicate if at limit.
  33558. */
  33559. private _isRadiusAtLimit;
  33560. /**
  33561. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  33562. * @param radiusDelta The delta by which to animate to. Can be negative.
  33563. */
  33564. private _applyBoundRadiusAnimation;
  33565. /**
  33566. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  33567. */
  33568. protected _clearAnimationLocks(): void;
  33569. /**
  33570. * Stops and removes all animations that have been applied to the camera
  33571. */
  33572. stopAllAnimations(): void;
  33573. }
  33574. }
  33575. declare module BABYLON {
  33576. /**
  33577. * 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.
  33578. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33579. */
  33580. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  33581. /**
  33582. * Gets the name of the behavior.
  33583. */
  33584. readonly name: string;
  33585. private _mode;
  33586. private _radiusScale;
  33587. private _positionScale;
  33588. private _defaultElevation;
  33589. private _elevationReturnTime;
  33590. private _elevationReturnWaitTime;
  33591. private _zoomStopsAnimation;
  33592. private _framingTime;
  33593. /**
  33594. * The easing function used by animations
  33595. */
  33596. static EasingFunction: ExponentialEase;
  33597. /**
  33598. * The easing mode used by animations
  33599. */
  33600. static EasingMode: number;
  33601. /**
  33602. * Sets the current mode used by the behavior
  33603. */
  33604. /**
  33605. * Gets current mode used by the behavior.
  33606. */
  33607. mode: number;
  33608. /**
  33609. * Sets the scale applied to the radius (1 by default)
  33610. */
  33611. /**
  33612. * Gets the scale applied to the radius
  33613. */
  33614. radiusScale: number;
  33615. /**
  33616. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33617. */
  33618. /**
  33619. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33620. */
  33621. positionScale: number;
  33622. /**
  33623. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33624. * behaviour is triggered, in radians.
  33625. */
  33626. /**
  33627. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33628. * behaviour is triggered, in radians.
  33629. */
  33630. defaultElevation: number;
  33631. /**
  33632. * Sets the time (in milliseconds) taken to return to the default beta position.
  33633. * Negative value indicates camera should not return to default.
  33634. */
  33635. /**
  33636. * Gets the time (in milliseconds) taken to return to the default beta position.
  33637. * Negative value indicates camera should not return to default.
  33638. */
  33639. elevationReturnTime: number;
  33640. /**
  33641. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33642. */
  33643. /**
  33644. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33645. */
  33646. elevationReturnWaitTime: number;
  33647. /**
  33648. * Sets the flag that indicates if user zooming should stop animation.
  33649. */
  33650. /**
  33651. * Gets the flag that indicates if user zooming should stop animation.
  33652. */
  33653. zoomStopsAnimation: boolean;
  33654. /**
  33655. * Sets the transition time when framing the mesh, in milliseconds
  33656. */
  33657. /**
  33658. * Gets the transition time when framing the mesh, in milliseconds
  33659. */
  33660. framingTime: number;
  33661. /**
  33662. * Define if the behavior should automatically change the configured
  33663. * camera limits and sensibilities.
  33664. */
  33665. autoCorrectCameraLimitsAndSensibility: boolean;
  33666. private _onPrePointerObservableObserver;
  33667. private _onAfterCheckInputsObserver;
  33668. private _onMeshTargetChangedObserver;
  33669. private _attachedCamera;
  33670. private _isPointerDown;
  33671. private _lastInteractionTime;
  33672. /**
  33673. * Initializes the behavior.
  33674. */
  33675. init(): void;
  33676. /**
  33677. * Attaches the behavior to its arc rotate camera.
  33678. * @param camera Defines the camera to attach the behavior to
  33679. */
  33680. attach(camera: ArcRotateCamera): void;
  33681. /**
  33682. * Detaches the behavior from its current arc rotate camera.
  33683. */
  33684. detach(): void;
  33685. private _animatables;
  33686. private _betaIsAnimating;
  33687. private _betaTransition;
  33688. private _radiusTransition;
  33689. private _vectorTransition;
  33690. /**
  33691. * Targets the given mesh and updates zoom level accordingly.
  33692. * @param mesh The mesh to target.
  33693. * @param radius Optional. If a cached radius position already exists, overrides default.
  33694. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33695. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33696. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33697. */
  33698. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33699. /**
  33700. * Targets the given mesh with its children and updates zoom level accordingly.
  33701. * @param mesh The mesh to target.
  33702. * @param radius Optional. If a cached radius position already exists, overrides default.
  33703. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33704. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33705. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33706. */
  33707. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33708. /**
  33709. * Targets the given meshes with their children and updates zoom level accordingly.
  33710. * @param meshes The mesh to target.
  33711. * @param radius Optional. If a cached radius position already exists, overrides default.
  33712. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33713. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33714. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33715. */
  33716. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33717. /**
  33718. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  33719. * @param minimumWorld Determines the smaller position of the bounding box extend
  33720. * @param maximumWorld Determines the bigger position of the bounding box extend
  33721. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33722. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33723. */
  33724. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33725. /**
  33726. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  33727. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  33728. * frustum width.
  33729. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  33730. * to fully enclose the mesh in the viewing frustum.
  33731. */
  33732. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  33733. /**
  33734. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  33735. * is automatically returned to its default position (expected to be above ground plane).
  33736. */
  33737. private _maintainCameraAboveGround;
  33738. /**
  33739. * Returns the frustum slope based on the canvas ratio and camera FOV
  33740. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  33741. */
  33742. private _getFrustumSlope;
  33743. /**
  33744. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  33745. */
  33746. private _clearAnimationLocks;
  33747. /**
  33748. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33749. */
  33750. private _applyUserInteraction;
  33751. /**
  33752. * Stops and removes all animations that have been applied to the camera
  33753. */
  33754. stopAllAnimations(): void;
  33755. /**
  33756. * Gets a value indicating if the user is moving the camera
  33757. */
  33758. readonly isUserIsMoving: boolean;
  33759. /**
  33760. * The camera can move all the way towards the mesh.
  33761. */
  33762. static IgnoreBoundsSizeMode: number;
  33763. /**
  33764. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  33765. */
  33766. static FitFrustumSidesMode: number;
  33767. }
  33768. }
  33769. declare module BABYLON {
  33770. /**
  33771. * Manage the pointers inputs to control an arc rotate camera.
  33772. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33773. */
  33774. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  33775. /**
  33776. * Defines the camera the input is attached to.
  33777. */
  33778. camera: ArcRotateCamera;
  33779. /**
  33780. * Defines the buttons associated with the input to handle camera move.
  33781. */
  33782. buttons: number[];
  33783. /**
  33784. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  33785. */
  33786. angularSensibilityX: number;
  33787. /**
  33788. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  33789. */
  33790. angularSensibilityY: number;
  33791. /**
  33792. * Defines the pointer pinch precision or how fast is the camera zooming.
  33793. */
  33794. pinchPrecision: number;
  33795. /**
  33796. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  33797. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  33798. */
  33799. pinchDeltaPercentage: number;
  33800. /**
  33801. * Defines the pointer panning sensibility or how fast is the camera moving.
  33802. */
  33803. panningSensibility: number;
  33804. /**
  33805. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  33806. */
  33807. multiTouchPanning: boolean;
  33808. /**
  33809. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  33810. */
  33811. multiTouchPanAndZoom: boolean;
  33812. /**
  33813. * Revers pinch action direction.
  33814. */
  33815. pinchInwards: boolean;
  33816. private _isPanClick;
  33817. private _pointerInput;
  33818. private _observer;
  33819. private _onMouseMove;
  33820. private _onGestureStart;
  33821. private _onGesture;
  33822. private _MSGestureHandler;
  33823. private _onLostFocus;
  33824. private _onContextMenu;
  33825. /**
  33826. * Attach the input controls to a specific dom element to get the input from.
  33827. * @param element Defines the element the controls should be listened from
  33828. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33829. */
  33830. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33831. /**
  33832. * Detach the current controls from the specified dom element.
  33833. * @param element Defines the element to stop listening the inputs from
  33834. */
  33835. detachControl(element: Nullable<HTMLElement>): void;
  33836. /**
  33837. * Gets the class name of the current intput.
  33838. * @returns the class name
  33839. */
  33840. getClassName(): string;
  33841. /**
  33842. * Get the friendly name associated with the input class.
  33843. * @returns the input friendly name
  33844. */
  33845. getSimpleName(): string;
  33846. }
  33847. }
  33848. declare module BABYLON {
  33849. /**
  33850. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  33851. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33852. */
  33853. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  33854. /**
  33855. * Defines the camera the input is attached to.
  33856. */
  33857. camera: ArcRotateCamera;
  33858. /**
  33859. * Defines the list of key codes associated with the up action (increase alpha)
  33860. */
  33861. keysUp: number[];
  33862. /**
  33863. * Defines the list of key codes associated with the down action (decrease alpha)
  33864. */
  33865. keysDown: number[];
  33866. /**
  33867. * Defines the list of key codes associated with the left action (increase beta)
  33868. */
  33869. keysLeft: number[];
  33870. /**
  33871. * Defines the list of key codes associated with the right action (decrease beta)
  33872. */
  33873. keysRight: number[];
  33874. /**
  33875. * Defines the list of key codes associated with the reset action.
  33876. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  33877. */
  33878. keysReset: number[];
  33879. /**
  33880. * Defines the panning sensibility of the inputs.
  33881. * (How fast is the camera paning)
  33882. */
  33883. panningSensibility: number;
  33884. /**
  33885. * Defines the zooming sensibility of the inputs.
  33886. * (How fast is the camera zooming)
  33887. */
  33888. zoomingSensibility: number;
  33889. /**
  33890. * Defines wether maintaining the alt key down switch the movement mode from
  33891. * orientation to zoom.
  33892. */
  33893. useAltToZoom: boolean;
  33894. /**
  33895. * Rotation speed of the camera
  33896. */
  33897. angularSpeed: number;
  33898. private _keys;
  33899. private _ctrlPressed;
  33900. private _altPressed;
  33901. private _onCanvasBlurObserver;
  33902. private _onKeyboardObserver;
  33903. private _engine;
  33904. private _scene;
  33905. /**
  33906. * Attach the input controls to a specific dom element to get the input from.
  33907. * @param element Defines the element the controls should be listened from
  33908. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33909. */
  33910. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33911. /**
  33912. * Detach the current controls from the specified dom element.
  33913. * @param element Defines the element to stop listening the inputs from
  33914. */
  33915. detachControl(element: Nullable<HTMLElement>): void;
  33916. /**
  33917. * Update the current camera state depending on the inputs that have been used this frame.
  33918. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  33919. */
  33920. checkInputs(): void;
  33921. /**
  33922. * Gets the class name of the current intput.
  33923. * @returns the class name
  33924. */
  33925. getClassName(): string;
  33926. /**
  33927. * Get the friendly name associated with the input class.
  33928. * @returns the input friendly name
  33929. */
  33930. getSimpleName(): string;
  33931. }
  33932. }
  33933. declare module BABYLON {
  33934. /**
  33935. * Manage the mouse wheel inputs to control an arc rotate camera.
  33936. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33937. */
  33938. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  33939. /**
  33940. * Defines the camera the input is attached to.
  33941. */
  33942. camera: ArcRotateCamera;
  33943. /**
  33944. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  33945. */
  33946. wheelPrecision: number;
  33947. /**
  33948. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  33949. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  33950. */
  33951. wheelDeltaPercentage: number;
  33952. private _wheel;
  33953. private _observer;
  33954. /**
  33955. * Attach the input controls to a specific dom element to get the input from.
  33956. * @param element Defines the element the controls should be listened from
  33957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33958. */
  33959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33960. /**
  33961. * Detach the current controls from the specified dom element.
  33962. * @param element Defines the element to stop listening the inputs from
  33963. */
  33964. detachControl(element: Nullable<HTMLElement>): void;
  33965. /**
  33966. * Gets the class name of the current intput.
  33967. * @returns the class name
  33968. */
  33969. getClassName(): string;
  33970. /**
  33971. * Get the friendly name associated with the input class.
  33972. * @returns the input friendly name
  33973. */
  33974. getSimpleName(): string;
  33975. }
  33976. }
  33977. declare module BABYLON {
  33978. /**
  33979. * Default Inputs manager for the ArcRotateCamera.
  33980. * It groups all the default supported inputs for ease of use.
  33981. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33982. */
  33983. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  33984. /**
  33985. * Instantiates a new ArcRotateCameraInputsManager.
  33986. * @param camera Defines the camera the inputs belong to
  33987. */
  33988. constructor(camera: ArcRotateCamera);
  33989. /**
  33990. * Add mouse wheel input support to the input manager.
  33991. * @returns the current input manager
  33992. */
  33993. addMouseWheel(): ArcRotateCameraInputsManager;
  33994. /**
  33995. * Add pointers input support to the input manager.
  33996. * @returns the current input manager
  33997. */
  33998. addPointers(): ArcRotateCameraInputsManager;
  33999. /**
  34000. * Add keyboard input support to the input manager.
  34001. * @returns the current input manager
  34002. */
  34003. addKeyboard(): ArcRotateCameraInputsManager;
  34004. }
  34005. }
  34006. declare module BABYLON {
  34007. /**
  34008. * This represents an orbital type of camera.
  34009. *
  34010. * 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.
  34011. * 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.
  34012. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34013. */
  34014. export class ArcRotateCamera extends TargetCamera {
  34015. /**
  34016. * Defines the rotation angle of the camera along the longitudinal axis.
  34017. */
  34018. alpha: number;
  34019. /**
  34020. * Defines the rotation angle of the camera along the latitudinal axis.
  34021. */
  34022. beta: number;
  34023. /**
  34024. * Defines the radius of the camera from it s target point.
  34025. */
  34026. radius: number;
  34027. protected _target: Vector3;
  34028. protected _targetHost: Nullable<AbstractMesh>;
  34029. /**
  34030. * Defines the target point of the camera.
  34031. * The camera looks towards it form the radius distance.
  34032. */
  34033. target: Vector3;
  34034. /**
  34035. * Define the current local position of the camera in the scene
  34036. */
  34037. position: Vector3;
  34038. /**
  34039. * Current inertia value on the longitudinal axis.
  34040. * The bigger this number the longer it will take for the camera to stop.
  34041. */
  34042. inertialAlphaOffset: number;
  34043. /**
  34044. * Current inertia value on the latitudinal axis.
  34045. * The bigger this number the longer it will take for the camera to stop.
  34046. */
  34047. inertialBetaOffset: number;
  34048. /**
  34049. * Current inertia value on the radius axis.
  34050. * The bigger this number the longer it will take for the camera to stop.
  34051. */
  34052. inertialRadiusOffset: number;
  34053. /**
  34054. * Minimum allowed angle on the longitudinal axis.
  34055. * This can help limiting how the Camera is able to move in the scene.
  34056. */
  34057. lowerAlphaLimit: Nullable<number>;
  34058. /**
  34059. * Maximum allowed angle on the longitudinal axis.
  34060. * This can help limiting how the Camera is able to move in the scene.
  34061. */
  34062. upperAlphaLimit: Nullable<number>;
  34063. /**
  34064. * Minimum allowed angle on the latitudinal axis.
  34065. * This can help limiting how the Camera is able to move in the scene.
  34066. */
  34067. lowerBetaLimit: number;
  34068. /**
  34069. * Maximum allowed angle on the latitudinal axis.
  34070. * This can help limiting how the Camera is able to move in the scene.
  34071. */
  34072. upperBetaLimit: number;
  34073. /**
  34074. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34075. * This can help limiting how the Camera is able to move in the scene.
  34076. */
  34077. lowerRadiusLimit: Nullable<number>;
  34078. /**
  34079. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34080. * This can help limiting how the Camera is able to move in the scene.
  34081. */
  34082. upperRadiusLimit: Nullable<number>;
  34083. /**
  34084. * Defines the current inertia value used during panning of the camera along the X axis.
  34085. */
  34086. inertialPanningX: number;
  34087. /**
  34088. * Defines the current inertia value used during panning of the camera along the Y axis.
  34089. */
  34090. inertialPanningY: number;
  34091. /**
  34092. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34093. * Basically if your fingers moves away from more than this distance you will be considered
  34094. * in pinch mode.
  34095. */
  34096. pinchToPanMaxDistance: number;
  34097. /**
  34098. * Defines the maximum distance the camera can pan.
  34099. * This could help keeping the cammera always in your scene.
  34100. */
  34101. panningDistanceLimit: Nullable<number>;
  34102. /**
  34103. * Defines the target of the camera before paning.
  34104. */
  34105. panningOriginTarget: Vector3;
  34106. /**
  34107. * Defines the value of the inertia used during panning.
  34108. * 0 would mean stop inertia and one would mean no decelleration at all.
  34109. */
  34110. panningInertia: number;
  34111. /**
  34112. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34113. */
  34114. angularSensibilityX: number;
  34115. /**
  34116. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34117. */
  34118. angularSensibilityY: number;
  34119. /**
  34120. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34121. */
  34122. pinchPrecision: number;
  34123. /**
  34124. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34125. * It will be used instead of pinchDeltaPrecision if different from 0.
  34126. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34127. */
  34128. pinchDeltaPercentage: number;
  34129. /**
  34130. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34131. */
  34132. panningSensibility: number;
  34133. /**
  34134. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34135. */
  34136. keysUp: number[];
  34137. /**
  34138. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34139. */
  34140. keysDown: number[];
  34141. /**
  34142. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34143. */
  34144. keysLeft: number[];
  34145. /**
  34146. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34147. */
  34148. keysRight: number[];
  34149. /**
  34150. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34151. */
  34152. wheelPrecision: number;
  34153. /**
  34154. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34155. * It will be used instead of pinchDeltaPrecision if different from 0.
  34156. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34157. */
  34158. wheelDeltaPercentage: number;
  34159. /**
  34160. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34161. */
  34162. zoomOnFactor: number;
  34163. /**
  34164. * Defines a screen offset for the camera position.
  34165. */
  34166. targetScreenOffset: Vector2;
  34167. /**
  34168. * Allows the camera to be completely reversed.
  34169. * If false the camera can not arrive upside down.
  34170. */
  34171. allowUpsideDown: boolean;
  34172. /**
  34173. * Define if double tap/click is used to restore the previously saved state of the camera.
  34174. */
  34175. useInputToRestoreState: boolean;
  34176. /** @hidden */
  34177. _viewMatrix: Matrix;
  34178. /** @hidden */
  34179. _useCtrlForPanning: boolean;
  34180. /** @hidden */
  34181. _panningMouseButton: number;
  34182. /**
  34183. * Defines the input associated to the camera.
  34184. */
  34185. inputs: ArcRotateCameraInputsManager;
  34186. /** @hidden */
  34187. _reset: () => void;
  34188. /**
  34189. * Defines the allowed panning axis.
  34190. */
  34191. panningAxis: Vector3;
  34192. protected _localDirection: Vector3;
  34193. protected _transformedDirection: Vector3;
  34194. private _bouncingBehavior;
  34195. /**
  34196. * Gets the bouncing behavior of the camera if it has been enabled.
  34197. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34198. */
  34199. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34200. /**
  34201. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34202. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34203. */
  34204. useBouncingBehavior: boolean;
  34205. private _framingBehavior;
  34206. /**
  34207. * Gets the framing behavior of the camera if it has been enabled.
  34208. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34209. */
  34210. readonly framingBehavior: Nullable<FramingBehavior>;
  34211. /**
  34212. * Defines if the framing behavior of the camera is enabled on the camera.
  34213. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34214. */
  34215. useFramingBehavior: boolean;
  34216. private _autoRotationBehavior;
  34217. /**
  34218. * Gets the auto rotation behavior of the camera if it has been enabled.
  34219. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34220. */
  34221. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34222. /**
  34223. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34224. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34225. */
  34226. useAutoRotationBehavior: boolean;
  34227. /**
  34228. * Observable triggered when the mesh target has been changed on the camera.
  34229. */
  34230. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34231. /**
  34232. * Event raised when the camera is colliding with a mesh.
  34233. */
  34234. onCollide: (collidedMesh: AbstractMesh) => void;
  34235. /**
  34236. * Defines whether the camera should check collision with the objects oh the scene.
  34237. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34238. */
  34239. checkCollisions: boolean;
  34240. /**
  34241. * Defines the collision radius of the camera.
  34242. * This simulates a sphere around the camera.
  34243. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34244. */
  34245. collisionRadius: Vector3;
  34246. protected _collider: Collider;
  34247. protected _previousPosition: Vector3;
  34248. protected _collisionVelocity: Vector3;
  34249. protected _newPosition: Vector3;
  34250. protected _previousAlpha: number;
  34251. protected _previousBeta: number;
  34252. protected _previousRadius: number;
  34253. protected _collisionTriggered: boolean;
  34254. protected _targetBoundingCenter: Nullable<Vector3>;
  34255. private _computationVector;
  34256. private _tempAxisVector;
  34257. private _tempAxisRotationMatrix;
  34258. /**
  34259. * Instantiates a new ArcRotateCamera in a given scene
  34260. * @param name Defines the name of the camera
  34261. * @param alpha Defines the camera rotation along the logitudinal axis
  34262. * @param beta Defines the camera rotation along the latitudinal axis
  34263. * @param radius Defines the camera distance from its target
  34264. * @param target Defines the camera target
  34265. * @param scene Defines the scene the camera belongs to
  34266. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34267. */
  34268. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34269. /** @hidden */
  34270. _initCache(): void;
  34271. /** @hidden */
  34272. _updateCache(ignoreParentClass?: boolean): void;
  34273. protected _getTargetPosition(): Vector3;
  34274. private _storedAlpha;
  34275. private _storedBeta;
  34276. private _storedRadius;
  34277. private _storedTarget;
  34278. /**
  34279. * Stores the current state of the camera (alpha, beta, radius and target)
  34280. * @returns the camera itself
  34281. */
  34282. storeState(): Camera;
  34283. /**
  34284. * @hidden
  34285. * Restored camera state. You must call storeState() first
  34286. */
  34287. _restoreStateValues(): boolean;
  34288. /** @hidden */
  34289. _isSynchronizedViewMatrix(): boolean;
  34290. /**
  34291. * Attached controls to the current camera.
  34292. * @param element Defines the element the controls should be listened from
  34293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34294. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34295. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34296. */
  34297. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34298. /**
  34299. * Detach the current controls from the camera.
  34300. * The camera will stop reacting to inputs.
  34301. * @param element Defines the element to stop listening the inputs from
  34302. */
  34303. detachControl(element: HTMLElement): void;
  34304. /** @hidden */
  34305. _checkInputs(): void;
  34306. protected _checkLimits(): void;
  34307. /**
  34308. * Rebuilds angles (alpha, beta) and radius from the give position and target
  34309. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  34310. */
  34311. rebuildAnglesAndRadius(updateView?: boolean): void;
  34312. /**
  34313. * Use a position to define the current camera related information like aplha, beta and radius
  34314. * @param position Defines the position to set the camera at
  34315. */
  34316. setPosition(position: Vector3): void;
  34317. /**
  34318. * Defines the target the camera should look at.
  34319. * This will automatically adapt alpha beta and radius to fit within the new target.
  34320. * @param target Defines the new target as a Vector or a mesh
  34321. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34322. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34323. */
  34324. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34325. /** @hidden */
  34326. _getViewMatrix(): Matrix;
  34327. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34328. /**
  34329. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34330. * @param meshes Defines the mesh to zoom on
  34331. * @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)
  34332. */
  34333. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  34334. /**
  34335. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  34336. * The target will be changed but the radius
  34337. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  34338. * @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)
  34339. */
  34340. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  34341. min: Vector3;
  34342. max: Vector3;
  34343. distance: number;
  34344. }, doNotUpdateMaxZ?: boolean): void;
  34345. /**
  34346. * @override
  34347. * Override Camera.createRigCamera
  34348. */
  34349. createRigCamera(name: string, cameraIndex: number): Camera;
  34350. /**
  34351. * @hidden
  34352. * @override
  34353. * Override Camera._updateRigCameras
  34354. */
  34355. _updateRigCameras(): void;
  34356. /**
  34357. * Destroy the camera and release the current resources hold by it.
  34358. */
  34359. dispose(): void;
  34360. /**
  34361. * Gets the current object class name.
  34362. * @return the class name
  34363. */
  34364. getClassName(): string;
  34365. }
  34366. }
  34367. declare module BABYLON {
  34368. /**
  34369. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  34370. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34371. */
  34372. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34373. /**
  34374. * Gets the name of the behavior.
  34375. */
  34376. readonly name: string;
  34377. private _zoomStopsAnimation;
  34378. private _idleRotationSpeed;
  34379. private _idleRotationWaitTime;
  34380. private _idleRotationSpinupTime;
  34381. /**
  34382. * Sets the flag that indicates if user zooming should stop animation.
  34383. */
  34384. /**
  34385. * Gets the flag that indicates if user zooming should stop animation.
  34386. */
  34387. zoomStopsAnimation: boolean;
  34388. /**
  34389. * Sets the default speed at which the camera rotates around the model.
  34390. */
  34391. /**
  34392. * Gets the default speed at which the camera rotates around the model.
  34393. */
  34394. idleRotationSpeed: number;
  34395. /**
  34396. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34397. */
  34398. /**
  34399. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34400. */
  34401. idleRotationWaitTime: number;
  34402. /**
  34403. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34404. */
  34405. /**
  34406. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34407. */
  34408. idleRotationSpinupTime: number;
  34409. /**
  34410. * Gets a value indicating if the camera is currently rotating because of this behavior
  34411. */
  34412. readonly rotationInProgress: boolean;
  34413. private _onPrePointerObservableObserver;
  34414. private _onAfterCheckInputsObserver;
  34415. private _attachedCamera;
  34416. private _isPointerDown;
  34417. private _lastFrameTime;
  34418. private _lastInteractionTime;
  34419. private _cameraRotationSpeed;
  34420. /**
  34421. * Initializes the behavior.
  34422. */
  34423. init(): void;
  34424. /**
  34425. * Attaches the behavior to its arc rotate camera.
  34426. * @param camera Defines the camera to attach the behavior to
  34427. */
  34428. attach(camera: ArcRotateCamera): void;
  34429. /**
  34430. * Detaches the behavior from its current arc rotate camera.
  34431. */
  34432. detach(): void;
  34433. /**
  34434. * Returns true if user is scrolling.
  34435. * @return true if user is scrolling.
  34436. */
  34437. private _userIsZooming;
  34438. private _lastFrameRadius;
  34439. private _shouldAnimationStopForInteraction;
  34440. /**
  34441. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34442. */
  34443. private _applyUserInteraction;
  34444. private _userIsMoving;
  34445. }
  34446. }
  34447. declare module BABYLON {
  34448. /**
  34449. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  34450. */
  34451. export class AttachToBoxBehavior implements Behavior<Mesh> {
  34452. private ui;
  34453. /**
  34454. * The name of the behavior
  34455. */
  34456. name: string;
  34457. /**
  34458. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  34459. */
  34460. distanceAwayFromFace: number;
  34461. /**
  34462. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  34463. */
  34464. distanceAwayFromBottomOfFace: number;
  34465. private _faceVectors;
  34466. private _target;
  34467. private _scene;
  34468. private _onRenderObserver;
  34469. private _tmpMatrix;
  34470. private _tmpVector;
  34471. /**
  34472. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  34473. * @param ui The transform node that should be attched to the mesh
  34474. */
  34475. constructor(ui: TransformNode);
  34476. /**
  34477. * Initializes the behavior
  34478. */
  34479. init(): void;
  34480. private _closestFace;
  34481. private _zeroVector;
  34482. private _lookAtTmpMatrix;
  34483. private _lookAtToRef;
  34484. /**
  34485. * Attaches the AttachToBoxBehavior to the passed in mesh
  34486. * @param target The mesh that the specified node will be attached to
  34487. */
  34488. attach(target: Mesh): void;
  34489. /**
  34490. * Detaches the behavior from the mesh
  34491. */
  34492. detach(): void;
  34493. }
  34494. }
  34495. declare module BABYLON {
  34496. /**
  34497. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  34498. */
  34499. export class FadeInOutBehavior implements Behavior<Mesh> {
  34500. /**
  34501. * Time in milliseconds to delay before fading in (Default: 0)
  34502. */
  34503. delay: number;
  34504. /**
  34505. * Time in milliseconds for the mesh to fade in (Default: 300)
  34506. */
  34507. fadeInTime: number;
  34508. private _millisecondsPerFrame;
  34509. private _hovered;
  34510. private _hoverValue;
  34511. private _ownerNode;
  34512. /**
  34513. * Instatiates the FadeInOutBehavior
  34514. */
  34515. constructor();
  34516. /**
  34517. * The name of the behavior
  34518. */
  34519. readonly name: string;
  34520. /**
  34521. * Initializes the behavior
  34522. */
  34523. init(): void;
  34524. /**
  34525. * Attaches the fade behavior on the passed in mesh
  34526. * @param ownerNode The mesh that will be faded in/out once attached
  34527. */
  34528. attach(ownerNode: Mesh): void;
  34529. /**
  34530. * Detaches the behavior from the mesh
  34531. */
  34532. detach(): void;
  34533. /**
  34534. * Triggers the mesh to begin fading in or out
  34535. * @param value if the object should fade in or out (true to fade in)
  34536. */
  34537. fadeIn(value: boolean): void;
  34538. private _update;
  34539. private _setAllVisibility;
  34540. }
  34541. }
  34542. declare module BABYLON {
  34543. /**
  34544. * Class containing a set of static utilities functions for managing Pivots
  34545. * @hidden
  34546. */
  34547. export class PivotTools {
  34548. private static _PivotCached;
  34549. private static _OldPivotPoint;
  34550. private static _PivotTranslation;
  34551. private static _PivotTmpVector;
  34552. /** @hidden */
  34553. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  34554. /** @hidden */
  34555. static _RestorePivotPoint(mesh: AbstractMesh): void;
  34556. }
  34557. }
  34558. declare module BABYLON {
  34559. /**
  34560. * Class containing static functions to help procedurally build meshes
  34561. */
  34562. export class PlaneBuilder {
  34563. /**
  34564. * Creates a plane mesh
  34565. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  34566. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  34567. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  34568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34569. * * 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
  34570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34571. * @param name defines the name of the mesh
  34572. * @param options defines the options used to create the mesh
  34573. * @param scene defines the hosting scene
  34574. * @returns the plane mesh
  34575. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  34576. */
  34577. static CreatePlane(name: string, options: {
  34578. size?: number;
  34579. width?: number;
  34580. height?: number;
  34581. sideOrientation?: number;
  34582. frontUVs?: Vector4;
  34583. backUVs?: Vector4;
  34584. updatable?: boolean;
  34585. sourcePlane?: Plane;
  34586. }, scene: Scene): Mesh;
  34587. }
  34588. }
  34589. declare module BABYLON {
  34590. /**
  34591. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  34592. */
  34593. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  34594. private static _AnyMouseID;
  34595. private _attachedNode;
  34596. private _dragPlane;
  34597. private _scene;
  34598. private _pointerObserver;
  34599. private _beforeRenderObserver;
  34600. private static _planeScene;
  34601. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  34602. /**
  34603. * 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)
  34604. */
  34605. maxDragAngle: number;
  34606. /**
  34607. * @hidden
  34608. */
  34609. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  34610. /**
  34611. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34612. */
  34613. currentDraggingPointerID: number;
  34614. /**
  34615. * The last position where the pointer hit the drag plane in world space
  34616. */
  34617. lastDragPosition: Vector3;
  34618. /**
  34619. * If the behavior is currently in a dragging state
  34620. */
  34621. dragging: boolean;
  34622. /**
  34623. * 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)
  34624. */
  34625. dragDeltaRatio: number;
  34626. /**
  34627. * If the drag plane orientation should be updated during the dragging (Default: true)
  34628. */
  34629. updateDragPlane: boolean;
  34630. private _debugMode;
  34631. private _moving;
  34632. /**
  34633. * Fires each time the attached mesh is dragged with the pointer
  34634. * * delta between last drag position and current drag position in world space
  34635. * * dragDistance along the drag axis
  34636. * * dragPlaneNormal normal of the current drag plane used during the drag
  34637. * * dragPlanePoint in world space where the drag intersects the drag plane
  34638. */
  34639. onDragObservable: Observable<{
  34640. delta: Vector3;
  34641. dragPlanePoint: Vector3;
  34642. dragPlaneNormal: Vector3;
  34643. dragDistance: number;
  34644. pointerId: number;
  34645. }>;
  34646. /**
  34647. * Fires each time a drag begins (eg. mouse down on mesh)
  34648. */
  34649. onDragStartObservable: Observable<{
  34650. dragPlanePoint: Vector3;
  34651. pointerId: number;
  34652. }>;
  34653. /**
  34654. * Fires each time a drag ends (eg. mouse release after drag)
  34655. */
  34656. onDragEndObservable: Observable<{
  34657. dragPlanePoint: Vector3;
  34658. pointerId: number;
  34659. }>;
  34660. /**
  34661. * If the attached mesh should be moved when dragged
  34662. */
  34663. moveAttached: boolean;
  34664. /**
  34665. * If the drag behavior will react to drag events (Default: true)
  34666. */
  34667. enabled: boolean;
  34668. /**
  34669. * If camera controls should be detached during the drag
  34670. */
  34671. detachCameraControls: boolean;
  34672. /**
  34673. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  34674. */
  34675. useObjectOrienationForDragging: boolean;
  34676. private _options;
  34677. /**
  34678. * Creates a pointer drag behavior that can be attached to a mesh
  34679. * @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)
  34680. */
  34681. constructor(options?: {
  34682. dragAxis?: Vector3;
  34683. dragPlaneNormal?: Vector3;
  34684. });
  34685. /**
  34686. * Predicate to determine if it is valid to move the object to a new position when it is moved
  34687. */
  34688. validateDrag: (targetPosition: Vector3) => boolean;
  34689. /**
  34690. * The name of the behavior
  34691. */
  34692. readonly name: string;
  34693. /**
  34694. * Initializes the behavior
  34695. */
  34696. init(): void;
  34697. private _tmpVector;
  34698. private _alternatePickedPoint;
  34699. private _worldDragAxis;
  34700. private _targetPosition;
  34701. private _attachedElement;
  34702. /**
  34703. * Attaches the drag behavior the passed in mesh
  34704. * @param ownerNode The mesh that will be dragged around once attached
  34705. */
  34706. attach(ownerNode: AbstractMesh): void;
  34707. /**
  34708. * Force relase the drag action by code.
  34709. */
  34710. releaseDrag(): void;
  34711. private _startDragRay;
  34712. private _lastPointerRay;
  34713. /**
  34714. * Simulates the start of a pointer drag event on the behavior
  34715. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  34716. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  34717. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  34718. */
  34719. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  34720. private _startDrag;
  34721. private _dragDelta;
  34722. private _moveDrag;
  34723. private _pickWithRayOnDragPlane;
  34724. private _pointA;
  34725. private _pointB;
  34726. private _pointC;
  34727. private _lineA;
  34728. private _lineB;
  34729. private _localAxis;
  34730. private _lookAt;
  34731. private _updateDragPlanePosition;
  34732. /**
  34733. * Detaches the behavior from the mesh
  34734. */
  34735. detach(): void;
  34736. }
  34737. }
  34738. declare module BABYLON {
  34739. /**
  34740. * A behavior that when attached to a mesh will allow the mesh to be scaled
  34741. */
  34742. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  34743. private _dragBehaviorA;
  34744. private _dragBehaviorB;
  34745. private _startDistance;
  34746. private _initialScale;
  34747. private _targetScale;
  34748. private _ownerNode;
  34749. private _sceneRenderObserver;
  34750. /**
  34751. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  34752. */
  34753. constructor();
  34754. /**
  34755. * The name of the behavior
  34756. */
  34757. readonly name: string;
  34758. /**
  34759. * Initializes the behavior
  34760. */
  34761. init(): void;
  34762. private _getCurrentDistance;
  34763. /**
  34764. * Attaches the scale behavior the passed in mesh
  34765. * @param ownerNode The mesh that will be scaled around once attached
  34766. */
  34767. attach(ownerNode: Mesh): void;
  34768. /**
  34769. * Detaches the behavior from the mesh
  34770. */
  34771. detach(): void;
  34772. }
  34773. }
  34774. declare module BABYLON {
  34775. /**
  34776. * 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
  34777. */
  34778. export class SixDofDragBehavior implements Behavior<Mesh> {
  34779. private static _virtualScene;
  34780. private _ownerNode;
  34781. private _sceneRenderObserver;
  34782. private _scene;
  34783. private _targetPosition;
  34784. private _virtualOriginMesh;
  34785. private _virtualDragMesh;
  34786. private _pointerObserver;
  34787. private _moving;
  34788. private _startingOrientation;
  34789. /**
  34790. * 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)
  34791. */
  34792. private zDragFactor;
  34793. /**
  34794. * If the object should rotate to face the drag origin
  34795. */
  34796. rotateDraggedObject: boolean;
  34797. /**
  34798. * If the behavior is currently in a dragging state
  34799. */
  34800. dragging: boolean;
  34801. /**
  34802. * 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)
  34803. */
  34804. dragDeltaRatio: number;
  34805. /**
  34806. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34807. */
  34808. currentDraggingPointerID: number;
  34809. /**
  34810. * If camera controls should be detached during the drag
  34811. */
  34812. detachCameraControls: boolean;
  34813. /**
  34814. * Fires each time a drag starts
  34815. */
  34816. onDragStartObservable: Observable<{}>;
  34817. /**
  34818. * Fires each time a drag ends (eg. mouse release after drag)
  34819. */
  34820. onDragEndObservable: Observable<{}>;
  34821. /**
  34822. * 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
  34823. */
  34824. constructor();
  34825. /**
  34826. * The name of the behavior
  34827. */
  34828. readonly name: string;
  34829. /**
  34830. * Initializes the behavior
  34831. */
  34832. init(): void;
  34833. /**
  34834. * Attaches the scale behavior the passed in mesh
  34835. * @param ownerNode The mesh that will be scaled around once attached
  34836. */
  34837. attach(ownerNode: Mesh): void;
  34838. /**
  34839. * Detaches the behavior from the mesh
  34840. */
  34841. detach(): void;
  34842. }
  34843. }
  34844. declare module BABYLON {
  34845. /**
  34846. * Class used to apply inverse kinematics to bones
  34847. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  34848. */
  34849. export class BoneIKController {
  34850. private static _tmpVecs;
  34851. private static _tmpQuat;
  34852. private static _tmpMats;
  34853. /**
  34854. * Gets or sets the target mesh
  34855. */
  34856. targetMesh: AbstractMesh;
  34857. /** Gets or sets the mesh used as pole */
  34858. poleTargetMesh: AbstractMesh;
  34859. /**
  34860. * Gets or sets the bone used as pole
  34861. */
  34862. poleTargetBone: Nullable<Bone>;
  34863. /**
  34864. * Gets or sets the target position
  34865. */
  34866. targetPosition: Vector3;
  34867. /**
  34868. * Gets or sets the pole target position
  34869. */
  34870. poleTargetPosition: Vector3;
  34871. /**
  34872. * Gets or sets the pole target local offset
  34873. */
  34874. poleTargetLocalOffset: Vector3;
  34875. /**
  34876. * Gets or sets the pole angle
  34877. */
  34878. poleAngle: number;
  34879. /**
  34880. * Gets or sets the mesh associated with the controller
  34881. */
  34882. mesh: AbstractMesh;
  34883. /**
  34884. * 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)
  34885. */
  34886. slerpAmount: number;
  34887. private _bone1Quat;
  34888. private _bone1Mat;
  34889. private _bone2Ang;
  34890. private _bone1;
  34891. private _bone2;
  34892. private _bone1Length;
  34893. private _bone2Length;
  34894. private _maxAngle;
  34895. private _maxReach;
  34896. private _rightHandedSystem;
  34897. private _bendAxis;
  34898. private _slerping;
  34899. private _adjustRoll;
  34900. /**
  34901. * Gets or sets maximum allowed angle
  34902. */
  34903. maxAngle: number;
  34904. /**
  34905. * Creates a new BoneIKController
  34906. * @param mesh defines the mesh to control
  34907. * @param bone defines the bone to control
  34908. * @param options defines options to set up the controller
  34909. */
  34910. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  34911. targetMesh?: AbstractMesh;
  34912. poleTargetMesh?: AbstractMesh;
  34913. poleTargetBone?: Bone;
  34914. poleTargetLocalOffset?: Vector3;
  34915. poleAngle?: number;
  34916. bendAxis?: Vector3;
  34917. maxAngle?: number;
  34918. slerpAmount?: number;
  34919. });
  34920. private _setMaxAngle;
  34921. /**
  34922. * Force the controller to update the bones
  34923. */
  34924. update(): void;
  34925. }
  34926. }
  34927. declare module BABYLON {
  34928. /**
  34929. * Class used to make a bone look toward a point in space
  34930. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  34931. */
  34932. export class BoneLookController {
  34933. private static _tmpVecs;
  34934. private static _tmpQuat;
  34935. private static _tmpMats;
  34936. /**
  34937. * The target Vector3 that the bone will look at
  34938. */
  34939. target: Vector3;
  34940. /**
  34941. * The mesh that the bone is attached to
  34942. */
  34943. mesh: AbstractMesh;
  34944. /**
  34945. * The bone that will be looking to the target
  34946. */
  34947. bone: Bone;
  34948. /**
  34949. * The up axis of the coordinate system that is used when the bone is rotated
  34950. */
  34951. upAxis: Vector3;
  34952. /**
  34953. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  34954. */
  34955. upAxisSpace: Space;
  34956. /**
  34957. * Used to make an adjustment to the yaw of the bone
  34958. */
  34959. adjustYaw: number;
  34960. /**
  34961. * Used to make an adjustment to the pitch of the bone
  34962. */
  34963. adjustPitch: number;
  34964. /**
  34965. * Used to make an adjustment to the roll of the bone
  34966. */
  34967. adjustRoll: number;
  34968. /**
  34969. * 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)
  34970. */
  34971. slerpAmount: number;
  34972. private _minYaw;
  34973. private _maxYaw;
  34974. private _minPitch;
  34975. private _maxPitch;
  34976. private _minYawSin;
  34977. private _minYawCos;
  34978. private _maxYawSin;
  34979. private _maxYawCos;
  34980. private _midYawConstraint;
  34981. private _minPitchTan;
  34982. private _maxPitchTan;
  34983. private _boneQuat;
  34984. private _slerping;
  34985. private _transformYawPitch;
  34986. private _transformYawPitchInv;
  34987. private _firstFrameSkipped;
  34988. private _yawRange;
  34989. private _fowardAxis;
  34990. /**
  34991. * Gets or sets the minimum yaw angle that the bone can look to
  34992. */
  34993. minYaw: number;
  34994. /**
  34995. * Gets or sets the maximum yaw angle that the bone can look to
  34996. */
  34997. maxYaw: number;
  34998. /**
  34999. * Gets or sets the minimum pitch angle that the bone can look to
  35000. */
  35001. minPitch: number;
  35002. /**
  35003. * Gets or sets the maximum pitch angle that the bone can look to
  35004. */
  35005. maxPitch: number;
  35006. /**
  35007. * Create a BoneLookController
  35008. * @param mesh the mesh that the bone belongs to
  35009. * @param bone the bone that will be looking to the target
  35010. * @param target the target Vector3 to look at
  35011. * @param options optional settings:
  35012. * * maxYaw: the maximum angle the bone will yaw to
  35013. * * minYaw: the minimum angle the bone will yaw to
  35014. * * maxPitch: the maximum angle the bone will pitch to
  35015. * * minPitch: the minimum angle the bone will yaw to
  35016. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35017. * * upAxis: the up axis of the coordinate system
  35018. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35019. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35020. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35021. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35022. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35023. * * adjustRoll: used to make an adjustment to the roll of the bone
  35024. **/
  35025. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35026. maxYaw?: number;
  35027. minYaw?: number;
  35028. maxPitch?: number;
  35029. minPitch?: number;
  35030. slerpAmount?: number;
  35031. upAxis?: Vector3;
  35032. upAxisSpace?: Space;
  35033. yawAxis?: Vector3;
  35034. pitchAxis?: Vector3;
  35035. adjustYaw?: number;
  35036. adjustPitch?: number;
  35037. adjustRoll?: number;
  35038. });
  35039. /**
  35040. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35041. */
  35042. update(): void;
  35043. private _getAngleDiff;
  35044. private _getAngleBetween;
  35045. private _isAngleBetween;
  35046. }
  35047. }
  35048. declare module BABYLON {
  35049. /**
  35050. * Manage the gamepad inputs to control an arc rotate camera.
  35051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35052. */
  35053. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35054. /**
  35055. * Defines the camera the input is attached to.
  35056. */
  35057. camera: ArcRotateCamera;
  35058. /**
  35059. * Defines the gamepad the input is gathering event from.
  35060. */
  35061. gamepad: Nullable<Gamepad>;
  35062. /**
  35063. * Defines the gamepad rotation sensiblity.
  35064. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35065. */
  35066. gamepadRotationSensibility: number;
  35067. /**
  35068. * Defines the gamepad move sensiblity.
  35069. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35070. */
  35071. gamepadMoveSensibility: number;
  35072. private _onGamepadConnectedObserver;
  35073. private _onGamepadDisconnectedObserver;
  35074. /**
  35075. * Attach the input controls to a specific dom element to get the input from.
  35076. * @param element Defines the element the controls should be listened from
  35077. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35078. */
  35079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35080. /**
  35081. * Detach the current controls from the specified dom element.
  35082. * @param element Defines the element to stop listening the inputs from
  35083. */
  35084. detachControl(element: Nullable<HTMLElement>): void;
  35085. /**
  35086. * Update the current camera state depending on the inputs that have been used this frame.
  35087. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35088. */
  35089. checkInputs(): void;
  35090. /**
  35091. * Gets the class name of the current intput.
  35092. * @returns the class name
  35093. */
  35094. getClassName(): string;
  35095. /**
  35096. * Get the friendly name associated with the input class.
  35097. * @returns the input friendly name
  35098. */
  35099. getSimpleName(): string;
  35100. }
  35101. }
  35102. declare module BABYLON {
  35103. interface ArcRotateCameraInputsManager {
  35104. /**
  35105. * Add orientation input support to the input manager.
  35106. * @returns the current input manager
  35107. */
  35108. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35109. }
  35110. /**
  35111. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35112. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35113. */
  35114. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35115. /**
  35116. * Defines the camera the input is attached to.
  35117. */
  35118. camera: ArcRotateCamera;
  35119. /**
  35120. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35121. */
  35122. alphaCorrection: number;
  35123. /**
  35124. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35125. */
  35126. gammaCorrection: number;
  35127. private _alpha;
  35128. private _gamma;
  35129. private _dirty;
  35130. private _deviceOrientationHandler;
  35131. /**
  35132. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35133. */
  35134. constructor();
  35135. /**
  35136. * Attach the input controls to a specific dom element to get the input from.
  35137. * @param element Defines the element the controls should be listened from
  35138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35139. */
  35140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35141. /** @hidden */
  35142. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  35143. /**
  35144. * Update the current camera state depending on the inputs that have been used this frame.
  35145. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35146. */
  35147. checkInputs(): void;
  35148. /**
  35149. * Detach the current controls from the specified dom element.
  35150. * @param element Defines the element to stop listening the inputs from
  35151. */
  35152. detachControl(element: Nullable<HTMLElement>): void;
  35153. /**
  35154. * Gets the class name of the current intput.
  35155. * @returns the class name
  35156. */
  35157. getClassName(): string;
  35158. /**
  35159. * Get the friendly name associated with the input class.
  35160. * @returns the input friendly name
  35161. */
  35162. getSimpleName(): string;
  35163. }
  35164. }
  35165. declare module BABYLON {
  35166. /**
  35167. * Listen to mouse events to control the camera.
  35168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35169. */
  35170. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35171. /**
  35172. * Defines the camera the input is attached to.
  35173. */
  35174. camera: FlyCamera;
  35175. /**
  35176. * Defines if touch is enabled. (Default is true.)
  35177. */
  35178. touchEnabled: boolean;
  35179. /**
  35180. * Defines the buttons associated with the input to handle camera rotation.
  35181. */
  35182. buttons: number[];
  35183. /**
  35184. * Assign buttons for Yaw control.
  35185. */
  35186. buttonsYaw: number[];
  35187. /**
  35188. * Assign buttons for Pitch control.
  35189. */
  35190. buttonsPitch: number[];
  35191. /**
  35192. * Assign buttons for Roll control.
  35193. */
  35194. buttonsRoll: number[];
  35195. /**
  35196. * Detect if any button is being pressed while mouse is moved.
  35197. * -1 = Mouse locked.
  35198. * 0 = Left button.
  35199. * 1 = Middle Button.
  35200. * 2 = Right Button.
  35201. */
  35202. activeButton: number;
  35203. /**
  35204. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35205. * Higher values reduce its sensitivity.
  35206. */
  35207. angularSensibility: number;
  35208. private _mousemoveCallback;
  35209. private _observer;
  35210. private _rollObserver;
  35211. private previousPosition;
  35212. private noPreventDefault;
  35213. private element;
  35214. /**
  35215. * Listen to mouse events to control the camera.
  35216. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35218. */
  35219. constructor(touchEnabled?: boolean);
  35220. /**
  35221. * Attach the mouse control to the HTML DOM element.
  35222. * @param element Defines the element that listens to the input events.
  35223. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35224. */
  35225. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35226. /**
  35227. * Detach the current controls from the specified dom element.
  35228. * @param element Defines the element to stop listening the inputs from
  35229. */
  35230. detachControl(element: Nullable<HTMLElement>): void;
  35231. /**
  35232. * Gets the class name of the current input.
  35233. * @returns the class name.
  35234. */
  35235. getClassName(): string;
  35236. /**
  35237. * Get the friendly name associated with the input class.
  35238. * @returns the input's friendly name.
  35239. */
  35240. getSimpleName(): string;
  35241. private _pointerInput;
  35242. private _onMouseMove;
  35243. /**
  35244. * Rotate camera by mouse offset.
  35245. */
  35246. private rotateCamera;
  35247. }
  35248. }
  35249. declare module BABYLON {
  35250. /**
  35251. * Default Inputs manager for the FlyCamera.
  35252. * It groups all the default supported inputs for ease of use.
  35253. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35254. */
  35255. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35256. /**
  35257. * Instantiates a new FlyCameraInputsManager.
  35258. * @param camera Defines the camera the inputs belong to.
  35259. */
  35260. constructor(camera: FlyCamera);
  35261. /**
  35262. * Add keyboard input support to the input manager.
  35263. * @returns the new FlyCameraKeyboardMoveInput().
  35264. */
  35265. addKeyboard(): FlyCameraInputsManager;
  35266. /**
  35267. * Add mouse input support to the input manager.
  35268. * @param touchEnabled Enable touch screen support.
  35269. * @returns the new FlyCameraMouseInput().
  35270. */
  35271. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35272. }
  35273. }
  35274. declare module BABYLON {
  35275. /**
  35276. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35277. * such as in a 3D Space Shooter or a Flight Simulator.
  35278. */
  35279. export class FlyCamera extends TargetCamera {
  35280. /**
  35281. * Define the collision ellipsoid of the camera.
  35282. * This is helpful for simulating a camera body, like a player's body.
  35283. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35284. */
  35285. ellipsoid: Vector3;
  35286. /**
  35287. * Define an offset for the position of the ellipsoid around the camera.
  35288. * This can be helpful if the camera is attached away from the player's body center,
  35289. * such as at its head.
  35290. */
  35291. ellipsoidOffset: Vector3;
  35292. /**
  35293. * Enable or disable collisions of the camera with the rest of the scene objects.
  35294. */
  35295. checkCollisions: boolean;
  35296. /**
  35297. * Enable or disable gravity on the camera.
  35298. */
  35299. applyGravity: boolean;
  35300. /**
  35301. * Define the current direction the camera is moving to.
  35302. */
  35303. cameraDirection: Vector3;
  35304. /**
  35305. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35306. * This overrides and empties cameraRotation.
  35307. */
  35308. rotationQuaternion: Quaternion;
  35309. /**
  35310. * Track Roll to maintain the wanted Rolling when looking around.
  35311. */
  35312. _trackRoll: number;
  35313. /**
  35314. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35315. */
  35316. rollCorrect: number;
  35317. /**
  35318. * Mimic a banked turn, Rolling the camera when Yawing.
  35319. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35320. */
  35321. bankedTurn: boolean;
  35322. /**
  35323. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35324. */
  35325. bankedTurnLimit: number;
  35326. /**
  35327. * Value of 0 disables the banked Roll.
  35328. * Value of 1 is equal to the Yaw angle in radians.
  35329. */
  35330. bankedTurnMultiplier: number;
  35331. /**
  35332. * The inputs manager loads all the input sources, such as keyboard and mouse.
  35333. */
  35334. inputs: FlyCameraInputsManager;
  35335. /**
  35336. * Gets the input sensibility for mouse input.
  35337. * Higher values reduce sensitivity.
  35338. */
  35339. /**
  35340. * Sets the input sensibility for a mouse input.
  35341. * Higher values reduce sensitivity.
  35342. */
  35343. angularSensibility: number;
  35344. /**
  35345. * Get the keys for camera movement forward.
  35346. */
  35347. /**
  35348. * Set the keys for camera movement forward.
  35349. */
  35350. keysForward: number[];
  35351. /**
  35352. * Get the keys for camera movement backward.
  35353. */
  35354. keysBackward: number[];
  35355. /**
  35356. * Get the keys for camera movement up.
  35357. */
  35358. /**
  35359. * Set the keys for camera movement up.
  35360. */
  35361. keysUp: number[];
  35362. /**
  35363. * Get the keys for camera movement down.
  35364. */
  35365. /**
  35366. * Set the keys for camera movement down.
  35367. */
  35368. keysDown: number[];
  35369. /**
  35370. * Get the keys for camera movement left.
  35371. */
  35372. /**
  35373. * Set the keys for camera movement left.
  35374. */
  35375. keysLeft: number[];
  35376. /**
  35377. * Set the keys for camera movement right.
  35378. */
  35379. /**
  35380. * Set the keys for camera movement right.
  35381. */
  35382. keysRight: number[];
  35383. /**
  35384. * Event raised when the camera collides with a mesh in the scene.
  35385. */
  35386. onCollide: (collidedMesh: AbstractMesh) => void;
  35387. private _collider;
  35388. private _needMoveForGravity;
  35389. private _oldPosition;
  35390. private _diffPosition;
  35391. private _newPosition;
  35392. /** @hidden */
  35393. _localDirection: Vector3;
  35394. /** @hidden */
  35395. _transformedDirection: Vector3;
  35396. /**
  35397. * Instantiates a FlyCamera.
  35398. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35399. * such as in a 3D Space Shooter or a Flight Simulator.
  35400. * @param name Define the name of the camera in the scene.
  35401. * @param position Define the starting position of the camera in the scene.
  35402. * @param scene Define the scene the camera belongs to.
  35403. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  35404. */
  35405. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35406. /**
  35407. * Attach a control to the HTML DOM element.
  35408. * @param element Defines the element that listens to the input events.
  35409. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  35410. */
  35411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35412. /**
  35413. * Detach a control from the HTML DOM element.
  35414. * The camera will stop reacting to that input.
  35415. * @param element Defines the element that listens to the input events.
  35416. */
  35417. detachControl(element: HTMLElement): void;
  35418. private _collisionMask;
  35419. /**
  35420. * Get the mask that the camera ignores in collision events.
  35421. */
  35422. /**
  35423. * Set the mask that the camera ignores in collision events.
  35424. */
  35425. collisionMask: number;
  35426. /** @hidden */
  35427. _collideWithWorld(displacement: Vector3): void;
  35428. /** @hidden */
  35429. private _onCollisionPositionChange;
  35430. /** @hidden */
  35431. _checkInputs(): void;
  35432. /** @hidden */
  35433. _decideIfNeedsToMove(): boolean;
  35434. /** @hidden */
  35435. _updatePosition(): void;
  35436. /**
  35437. * Restore the Roll to its target value at the rate specified.
  35438. * @param rate - Higher means slower restoring.
  35439. * @hidden
  35440. */
  35441. restoreRoll(rate: number): void;
  35442. /**
  35443. * Destroy the camera and release the current resources held by it.
  35444. */
  35445. dispose(): void;
  35446. /**
  35447. * Get the current object class name.
  35448. * @returns the class name.
  35449. */
  35450. getClassName(): string;
  35451. }
  35452. }
  35453. declare module BABYLON {
  35454. /**
  35455. * Listen to keyboard events to control the camera.
  35456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35457. */
  35458. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  35459. /**
  35460. * Defines the camera the input is attached to.
  35461. */
  35462. camera: FlyCamera;
  35463. /**
  35464. * The list of keyboard keys used to control the forward move of the camera.
  35465. */
  35466. keysForward: number[];
  35467. /**
  35468. * The list of keyboard keys used to control the backward move of the camera.
  35469. */
  35470. keysBackward: number[];
  35471. /**
  35472. * The list of keyboard keys used to control the forward move of the camera.
  35473. */
  35474. keysUp: number[];
  35475. /**
  35476. * The list of keyboard keys used to control the backward move of the camera.
  35477. */
  35478. keysDown: number[];
  35479. /**
  35480. * The list of keyboard keys used to control the right strafe move of the camera.
  35481. */
  35482. keysRight: number[];
  35483. /**
  35484. * The list of keyboard keys used to control the left strafe move of the camera.
  35485. */
  35486. keysLeft: number[];
  35487. private _keys;
  35488. private _onCanvasBlurObserver;
  35489. private _onKeyboardObserver;
  35490. private _engine;
  35491. private _scene;
  35492. /**
  35493. * Attach the input controls to a specific dom element to get the input from.
  35494. * @param element Defines the element the controls should be listened from
  35495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35496. */
  35497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35498. /**
  35499. * Detach the current controls from the specified dom element.
  35500. * @param element Defines the element to stop listening the inputs from
  35501. */
  35502. detachControl(element: Nullable<HTMLElement>): void;
  35503. /**
  35504. * Gets the class name of the current intput.
  35505. * @returns the class name
  35506. */
  35507. getClassName(): string;
  35508. /** @hidden */
  35509. _onLostFocus(e: FocusEvent): void;
  35510. /**
  35511. * Get the friendly name associated with the input class.
  35512. * @returns the input friendly name
  35513. */
  35514. getSimpleName(): string;
  35515. /**
  35516. * Update the current camera state depending on the inputs that have been used this frame.
  35517. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35518. */
  35519. checkInputs(): void;
  35520. }
  35521. }
  35522. declare module BABYLON {
  35523. interface FreeCameraInputsManager {
  35524. /**
  35525. * Add orientation input support to the input manager.
  35526. * @returns the current input manager
  35527. */
  35528. addDeviceOrientation(): FreeCameraInputsManager;
  35529. }
  35530. /**
  35531. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  35532. * Screen rotation is taken into account.
  35533. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35534. */
  35535. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  35536. private _camera;
  35537. private _screenOrientationAngle;
  35538. private _constantTranform;
  35539. private _screenQuaternion;
  35540. private _alpha;
  35541. private _beta;
  35542. private _gamma;
  35543. /**
  35544. * Instantiates a new input
  35545. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35546. */
  35547. constructor();
  35548. /**
  35549. * Define the camera controlled by the input.
  35550. */
  35551. camera: FreeCamera;
  35552. /**
  35553. * Attach the input controls to a specific dom element to get the input from.
  35554. * @param element Defines the element the controls should be listened from
  35555. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35556. */
  35557. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35558. private _orientationChanged;
  35559. private _deviceOrientation;
  35560. /**
  35561. * Detach the current controls from the specified dom element.
  35562. * @param element Defines the element to stop listening the inputs from
  35563. */
  35564. detachControl(element: Nullable<HTMLElement>): void;
  35565. /**
  35566. * Update the current camera state depending on the inputs that have been used this frame.
  35567. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35568. */
  35569. checkInputs(): void;
  35570. /**
  35571. * Gets the class name of the current intput.
  35572. * @returns the class name
  35573. */
  35574. getClassName(): string;
  35575. /**
  35576. * Get the friendly name associated with the input class.
  35577. * @returns the input friendly name
  35578. */
  35579. getSimpleName(): string;
  35580. }
  35581. }
  35582. declare module BABYLON {
  35583. /**
  35584. * Manage the gamepad inputs to control a free camera.
  35585. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35586. */
  35587. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  35588. /**
  35589. * Define the camera the input is attached to.
  35590. */
  35591. camera: FreeCamera;
  35592. /**
  35593. * Define the Gamepad controlling the input
  35594. */
  35595. gamepad: Nullable<Gamepad>;
  35596. /**
  35597. * Defines the gamepad rotation sensiblity.
  35598. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35599. */
  35600. gamepadAngularSensibility: number;
  35601. /**
  35602. * Defines the gamepad move sensiblity.
  35603. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35604. */
  35605. gamepadMoveSensibility: number;
  35606. private _onGamepadConnectedObserver;
  35607. private _onGamepadDisconnectedObserver;
  35608. private _cameraTransform;
  35609. private _deltaTransform;
  35610. private _vector3;
  35611. private _vector2;
  35612. /**
  35613. * Attach the input controls to a specific dom element to get the input from.
  35614. * @param element Defines the element the controls should be listened from
  35615. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35616. */
  35617. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35618. /**
  35619. * Detach the current controls from the specified dom element.
  35620. * @param element Defines the element to stop listening the inputs from
  35621. */
  35622. detachControl(element: Nullable<HTMLElement>): void;
  35623. /**
  35624. * Update the current camera state depending on the inputs that have been used this frame.
  35625. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35626. */
  35627. checkInputs(): void;
  35628. /**
  35629. * Gets the class name of the current intput.
  35630. * @returns the class name
  35631. */
  35632. getClassName(): string;
  35633. /**
  35634. * Get the friendly name associated with the input class.
  35635. * @returns the input friendly name
  35636. */
  35637. getSimpleName(): string;
  35638. }
  35639. }
  35640. declare module BABYLON {
  35641. /**
  35642. * Defines the potential axis of a Joystick
  35643. */
  35644. export enum JoystickAxis {
  35645. /** X axis */
  35646. X = 0,
  35647. /** Y axis */
  35648. Y = 1,
  35649. /** Z axis */
  35650. Z = 2
  35651. }
  35652. /**
  35653. * Class used to define virtual joystick (used in touch mode)
  35654. */
  35655. export class VirtualJoystick {
  35656. /**
  35657. * Gets or sets a boolean indicating that left and right values must be inverted
  35658. */
  35659. reverseLeftRight: boolean;
  35660. /**
  35661. * Gets or sets a boolean indicating that up and down values must be inverted
  35662. */
  35663. reverseUpDown: boolean;
  35664. /**
  35665. * Gets the offset value for the position (ie. the change of the position value)
  35666. */
  35667. deltaPosition: Vector3;
  35668. /**
  35669. * Gets a boolean indicating if the virtual joystick was pressed
  35670. */
  35671. pressed: boolean;
  35672. /**
  35673. * Canvas the virtual joystick will render onto, default z-index of this is 5
  35674. */
  35675. static Canvas: Nullable<HTMLCanvasElement>;
  35676. private static _globalJoystickIndex;
  35677. private static vjCanvasContext;
  35678. private static vjCanvasWidth;
  35679. private static vjCanvasHeight;
  35680. private static halfWidth;
  35681. private _action;
  35682. private _axisTargetedByLeftAndRight;
  35683. private _axisTargetedByUpAndDown;
  35684. private _joystickSensibility;
  35685. private _inversedSensibility;
  35686. private _joystickPointerID;
  35687. private _joystickColor;
  35688. private _joystickPointerPos;
  35689. private _joystickPreviousPointerPos;
  35690. private _joystickPointerStartPos;
  35691. private _deltaJoystickVector;
  35692. private _leftJoystick;
  35693. private _touches;
  35694. private _onPointerDownHandlerRef;
  35695. private _onPointerMoveHandlerRef;
  35696. private _onPointerUpHandlerRef;
  35697. private _onResize;
  35698. /**
  35699. * Creates a new virtual joystick
  35700. * @param leftJoystick defines that the joystick is for left hand (false by default)
  35701. */
  35702. constructor(leftJoystick?: boolean);
  35703. /**
  35704. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  35705. * @param newJoystickSensibility defines the new sensibility
  35706. */
  35707. setJoystickSensibility(newJoystickSensibility: number): void;
  35708. private _onPointerDown;
  35709. private _onPointerMove;
  35710. private _onPointerUp;
  35711. /**
  35712. * Change the color of the virtual joystick
  35713. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  35714. */
  35715. setJoystickColor(newColor: string): void;
  35716. /**
  35717. * Defines a callback to call when the joystick is touched
  35718. * @param action defines the callback
  35719. */
  35720. setActionOnTouch(action: () => any): void;
  35721. /**
  35722. * Defines which axis you'd like to control for left & right
  35723. * @param axis defines the axis to use
  35724. */
  35725. setAxisForLeftRight(axis: JoystickAxis): void;
  35726. /**
  35727. * Defines which axis you'd like to control for up & down
  35728. * @param axis defines the axis to use
  35729. */
  35730. setAxisForUpDown(axis: JoystickAxis): void;
  35731. private _drawVirtualJoystick;
  35732. /**
  35733. * Release internal HTML canvas
  35734. */
  35735. releaseCanvas(): void;
  35736. }
  35737. }
  35738. declare module BABYLON {
  35739. interface FreeCameraInputsManager {
  35740. /**
  35741. * Add virtual joystick input support to the input manager.
  35742. * @returns the current input manager
  35743. */
  35744. addVirtualJoystick(): FreeCameraInputsManager;
  35745. }
  35746. /**
  35747. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  35748. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35749. */
  35750. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  35751. /**
  35752. * Defines the camera the input is attached to.
  35753. */
  35754. camera: FreeCamera;
  35755. private _leftjoystick;
  35756. private _rightjoystick;
  35757. /**
  35758. * Gets the left stick of the virtual joystick.
  35759. * @returns The virtual Joystick
  35760. */
  35761. getLeftJoystick(): VirtualJoystick;
  35762. /**
  35763. * Gets the right stick of the virtual joystick.
  35764. * @returns The virtual Joystick
  35765. */
  35766. getRightJoystick(): VirtualJoystick;
  35767. /**
  35768. * Update the current camera state depending on the inputs that have been used this frame.
  35769. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35770. */
  35771. checkInputs(): void;
  35772. /**
  35773. * Attach the input controls to a specific dom element to get the input from.
  35774. * @param element Defines the element the controls should be listened from
  35775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35776. */
  35777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35778. /**
  35779. * Detach the current controls from the specified dom element.
  35780. * @param element Defines the element to stop listening the inputs from
  35781. */
  35782. detachControl(element: Nullable<HTMLElement>): void;
  35783. /**
  35784. * Gets the class name of the current intput.
  35785. * @returns the class name
  35786. */
  35787. getClassName(): string;
  35788. /**
  35789. * Get the friendly name associated with the input class.
  35790. * @returns the input friendly name
  35791. */
  35792. getSimpleName(): string;
  35793. }
  35794. }
  35795. declare module BABYLON {
  35796. /**
  35797. * This represents a FPS type of camera controlled by touch.
  35798. * This is like a universal camera minus the Gamepad controls.
  35799. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35800. */
  35801. export class TouchCamera extends FreeCamera {
  35802. /**
  35803. * Defines the touch sensibility for rotation.
  35804. * The higher the faster.
  35805. */
  35806. touchAngularSensibility: number;
  35807. /**
  35808. * Defines the touch sensibility for move.
  35809. * The higher the faster.
  35810. */
  35811. touchMoveSensibility: number;
  35812. /**
  35813. * Instantiates a new touch camera.
  35814. * This represents a FPS type of camera controlled by touch.
  35815. * This is like a universal camera minus the Gamepad controls.
  35816. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35817. * @param name Define the name of the camera in the scene
  35818. * @param position Define the start position of the camera in the scene
  35819. * @param scene Define the scene the camera belongs to
  35820. */
  35821. constructor(name: string, position: Vector3, scene: Scene);
  35822. /**
  35823. * Gets the current object class name.
  35824. * @return the class name
  35825. */
  35826. getClassName(): string;
  35827. /** @hidden */
  35828. _setupInputs(): void;
  35829. }
  35830. }
  35831. declare module BABYLON {
  35832. /**
  35833. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  35834. * being tilted forward or back and left or right.
  35835. */
  35836. export class DeviceOrientationCamera extends FreeCamera {
  35837. private _initialQuaternion;
  35838. private _quaternionCache;
  35839. /**
  35840. * Creates a new device orientation camera
  35841. * @param name The name of the camera
  35842. * @param position The start position camera
  35843. * @param scene The scene the camera belongs to
  35844. */
  35845. constructor(name: string, position: Vector3, scene: Scene);
  35846. /**
  35847. * Gets the current instance class name ("DeviceOrientationCamera").
  35848. * This helps avoiding instanceof at run time.
  35849. * @returns the class name
  35850. */
  35851. getClassName(): string;
  35852. /**
  35853. * @hidden
  35854. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  35855. */
  35856. _checkInputs(): void;
  35857. /**
  35858. * Reset the camera to its default orientation on the specified axis only.
  35859. * @param axis The axis to reset
  35860. */
  35861. resetToCurrentRotation(axis?: Axis): void;
  35862. }
  35863. }
  35864. declare module BABYLON {
  35865. /**
  35866. * Manage the keyboard inputs to control the movement of a follow camera.
  35867. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35868. */
  35869. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  35870. /**
  35871. * Defines the camera the input is attached to.
  35872. */
  35873. camera: FollowCamera;
  35874. /**
  35875. * Defines the list of key codes associated with the up action (increase heightOffset)
  35876. */
  35877. keysHeightOffsetIncr: number[];
  35878. /**
  35879. * Defines the list of key codes associated with the down action (decrease heightOffset)
  35880. */
  35881. keysHeightOffsetDecr: number[];
  35882. /**
  35883. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  35884. */
  35885. keysHeightOffsetModifierAlt: boolean;
  35886. /**
  35887. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  35888. */
  35889. keysHeightOffsetModifierCtrl: boolean;
  35890. /**
  35891. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  35892. */
  35893. keysHeightOffsetModifierShift: boolean;
  35894. /**
  35895. * Defines the list of key codes associated with the left action (increase rotationOffset)
  35896. */
  35897. keysRotationOffsetIncr: number[];
  35898. /**
  35899. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  35900. */
  35901. keysRotationOffsetDecr: number[];
  35902. /**
  35903. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  35904. */
  35905. keysRotationOffsetModifierAlt: boolean;
  35906. /**
  35907. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  35908. */
  35909. keysRotationOffsetModifierCtrl: boolean;
  35910. /**
  35911. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  35912. */
  35913. keysRotationOffsetModifierShift: boolean;
  35914. /**
  35915. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  35916. */
  35917. keysRadiusIncr: number[];
  35918. /**
  35919. * Defines the list of key codes associated with the zoom-out action (increase radius)
  35920. */
  35921. keysRadiusDecr: number[];
  35922. /**
  35923. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  35924. */
  35925. keysRadiusModifierAlt: boolean;
  35926. /**
  35927. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  35928. */
  35929. keysRadiusModifierCtrl: boolean;
  35930. /**
  35931. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  35932. */
  35933. keysRadiusModifierShift: boolean;
  35934. /**
  35935. * Defines the rate of change of heightOffset.
  35936. */
  35937. heightSensibility: number;
  35938. /**
  35939. * Defines the rate of change of rotationOffset.
  35940. */
  35941. rotationSensibility: number;
  35942. /**
  35943. * Defines the rate of change of radius.
  35944. */
  35945. radiusSensibility: number;
  35946. private _keys;
  35947. private _ctrlPressed;
  35948. private _altPressed;
  35949. private _shiftPressed;
  35950. private _onCanvasBlurObserver;
  35951. private _onKeyboardObserver;
  35952. private _engine;
  35953. private _scene;
  35954. /**
  35955. * Attach the input controls to a specific dom element to get the input from.
  35956. * @param element Defines the element the controls should be listened from
  35957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35958. */
  35959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35960. /**
  35961. * Detach the current controls from the specified dom element.
  35962. * @param element Defines the element to stop listening the inputs from
  35963. */
  35964. detachControl(element: Nullable<HTMLElement>): void;
  35965. /**
  35966. * Update the current camera state depending on the inputs that have been used this frame.
  35967. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35968. */
  35969. checkInputs(): void;
  35970. /**
  35971. * Gets the class name of the current input.
  35972. * @returns the class name
  35973. */
  35974. getClassName(): string;
  35975. /**
  35976. * Get the friendly name associated with the input class.
  35977. * @returns the input friendly name
  35978. */
  35979. getSimpleName(): string;
  35980. /**
  35981. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35982. * allow modification of the heightOffset value.
  35983. */
  35984. private _modifierHeightOffset;
  35985. /**
  35986. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35987. * allow modification of the rotationOffset value.
  35988. */
  35989. private _modifierRotationOffset;
  35990. /**
  35991. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35992. * allow modification of the radius value.
  35993. */
  35994. private _modifierRadius;
  35995. }
  35996. }
  35997. declare module BABYLON {
  35998. /**
  35999. * Manage the mouse wheel inputs to control a follow camera.
  36000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36001. */
  36002. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36003. /**
  36004. * Defines the camera the input is attached to.
  36005. */
  36006. camera: FollowCamera;
  36007. /**
  36008. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  36009. */
  36010. axisControlRadius: boolean;
  36011. /**
  36012. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  36013. */
  36014. axisControlHeight: boolean;
  36015. /**
  36016. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  36017. */
  36018. axisControlRotation: boolean;
  36019. /**
  36020. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36021. * relation to mouseWheel events.
  36022. */
  36023. wheelPrecision: number;
  36024. /**
  36025. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36026. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36027. */
  36028. wheelDeltaPercentage: number;
  36029. private _wheel;
  36030. private _observer;
  36031. /**
  36032. * Attach the input controls to a specific dom element to get the input from.
  36033. * @param element Defines the element the controls should be listened from
  36034. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36035. */
  36036. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36037. /**
  36038. * Detach the current controls from the specified dom element.
  36039. * @param element Defines the element to stop listening the inputs from
  36040. */
  36041. detachControl(element: Nullable<HTMLElement>): void;
  36042. /**
  36043. * Gets the class name of the current intput.
  36044. * @returns the class name
  36045. */
  36046. getClassName(): string;
  36047. /**
  36048. * Get the friendly name associated with the input class.
  36049. * @returns the input friendly name
  36050. */
  36051. getSimpleName(): string;
  36052. }
  36053. }
  36054. declare module BABYLON {
  36055. /**
  36056. * Default Inputs manager for the FollowCamera.
  36057. * It groups all the default supported inputs for ease of use.
  36058. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36059. */
  36060. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36061. /**
  36062. * Instantiates a new FollowCameraInputsManager.
  36063. * @param camera Defines the camera the inputs belong to
  36064. */
  36065. constructor(camera: FollowCamera);
  36066. /**
  36067. * Add keyboard input support to the input manager.
  36068. * @returns the current input manager
  36069. */
  36070. addKeyboard(): FollowCameraInputsManager;
  36071. /**
  36072. * Add mouse wheel input support to the input manager.
  36073. * @returns the current input manager
  36074. */
  36075. addMouseWheel(): FollowCameraInputsManager;
  36076. /**
  36077. * Add pointers input support to the input manager.
  36078. * @returns the current input manager
  36079. */
  36080. addPointers(): FollowCameraInputsManager;
  36081. /**
  36082. * Add orientation input support to the input manager.
  36083. * @returns the current input manager
  36084. */
  36085. addVRDeviceOrientation(): FollowCameraInputsManager;
  36086. }
  36087. }
  36088. declare module BABYLON {
  36089. /**
  36090. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36091. * an arc rotate version arcFollowCamera are available.
  36092. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36093. */
  36094. export class FollowCamera extends TargetCamera {
  36095. /**
  36096. * Distance the follow camera should follow an object at
  36097. */
  36098. radius: number;
  36099. /**
  36100. * Minimum allowed distance of the camera to the axis of rotation
  36101. * (The camera can not get closer).
  36102. * This can help limiting how the Camera is able to move in the scene.
  36103. */
  36104. lowerRadiusLimit: Nullable<number>;
  36105. /**
  36106. * Maximum allowed distance of the camera to the axis of rotation
  36107. * (The camera can not get further).
  36108. * This can help limiting how the Camera is able to move in the scene.
  36109. */
  36110. upperRadiusLimit: Nullable<number>;
  36111. /**
  36112. * Define a rotation offset between the camera and the object it follows
  36113. */
  36114. rotationOffset: number;
  36115. /**
  36116. * Minimum allowed angle to camera position relative to target object.
  36117. * This can help limiting how the Camera is able to move in the scene.
  36118. */
  36119. lowerRotationOffsetLimit: Nullable<number>;
  36120. /**
  36121. * Maximum allowed angle to camera position relative to target object.
  36122. * This can help limiting how the Camera is able to move in the scene.
  36123. */
  36124. upperRotationOffsetLimit: Nullable<number>;
  36125. /**
  36126. * Define a height offset between the camera and the object it follows.
  36127. * It can help following an object from the top (like a car chaing a plane)
  36128. */
  36129. heightOffset: number;
  36130. /**
  36131. * Minimum allowed height of camera position relative to target object.
  36132. * This can help limiting how the Camera is able to move in the scene.
  36133. */
  36134. lowerHeightOffsetLimit: Nullable<number>;
  36135. /**
  36136. * Maximum allowed height of camera position relative to target object.
  36137. * This can help limiting how the Camera is able to move in the scene.
  36138. */
  36139. upperHeightOffsetLimit: Nullable<number>;
  36140. /**
  36141. * Define how fast the camera can accelerate to follow it s target.
  36142. */
  36143. cameraAcceleration: number;
  36144. /**
  36145. * Define the speed limit of the camera following an object.
  36146. */
  36147. maxCameraSpeed: number;
  36148. /**
  36149. * Define the target of the camera.
  36150. */
  36151. lockedTarget: Nullable<AbstractMesh>;
  36152. /**
  36153. * Defines the input associated with the camera.
  36154. */
  36155. inputs: FollowCameraInputsManager;
  36156. /**
  36157. * Instantiates the follow camera.
  36158. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36159. * @param name Define the name of the camera in the scene
  36160. * @param position Define the position of the camera
  36161. * @param scene Define the scene the camera belong to
  36162. * @param lockedTarget Define the target of the camera
  36163. */
  36164. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36165. private _follow;
  36166. /**
  36167. * Attached controls to the current camera.
  36168. * @param element Defines the element the controls should be listened from
  36169. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36170. */
  36171. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36172. /**
  36173. * Detach the current controls from the camera.
  36174. * The camera will stop reacting to inputs.
  36175. * @param element Defines the element to stop listening the inputs from
  36176. */
  36177. detachControl(element: HTMLElement): void;
  36178. /** @hidden */
  36179. _checkInputs(): void;
  36180. private _checkLimits;
  36181. /**
  36182. * Gets the camera class name.
  36183. * @returns the class name
  36184. */
  36185. getClassName(): string;
  36186. }
  36187. /**
  36188. * Arc Rotate version of the follow camera.
  36189. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36190. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36191. */
  36192. export class ArcFollowCamera extends TargetCamera {
  36193. /** The longitudinal angle of the camera */
  36194. alpha: number;
  36195. /** The latitudinal angle of the camera */
  36196. beta: number;
  36197. /** The radius of the camera from its target */
  36198. radius: number;
  36199. /** Define the camera target (the messh it should follow) */
  36200. target: Nullable<AbstractMesh>;
  36201. private _cartesianCoordinates;
  36202. /**
  36203. * Instantiates a new ArcFollowCamera
  36204. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36205. * @param name Define the name of the camera
  36206. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36207. * @param beta Define the rotation angle of the camera around the elevation axis
  36208. * @param radius Define the radius of the camera from its target point
  36209. * @param target Define the target of the camera
  36210. * @param scene Define the scene the camera belongs to
  36211. */
  36212. constructor(name: string,
  36213. /** The longitudinal angle of the camera */
  36214. alpha: number,
  36215. /** The latitudinal angle of the camera */
  36216. beta: number,
  36217. /** The radius of the camera from its target */
  36218. radius: number,
  36219. /** Define the camera target (the messh it should follow) */
  36220. target: Nullable<AbstractMesh>, scene: Scene);
  36221. private _follow;
  36222. /** @hidden */
  36223. _checkInputs(): void;
  36224. /**
  36225. * Returns the class name of the object.
  36226. * It is mostly used internally for serialization purposes.
  36227. */
  36228. getClassName(): string;
  36229. }
  36230. }
  36231. declare module BABYLON {
  36232. /**
  36233. * 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,
  36234. * which still works and will still be found in many Playgrounds.
  36235. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36236. */
  36237. export class UniversalCamera extends TouchCamera {
  36238. /**
  36239. * Defines the gamepad rotation sensiblity.
  36240. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36241. */
  36242. gamepadAngularSensibility: number;
  36243. /**
  36244. * Defines the gamepad move sensiblity.
  36245. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36246. */
  36247. gamepadMoveSensibility: number;
  36248. /**
  36249. * 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,
  36250. * which still works and will still be found in many Playgrounds.
  36251. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36252. * @param name Define the name of the camera in the scene
  36253. * @param position Define the start position of the camera in the scene
  36254. * @param scene Define the scene the camera belongs to
  36255. */
  36256. constructor(name: string, position: Vector3, scene: Scene);
  36257. /**
  36258. * Gets the current object class name.
  36259. * @return the class name
  36260. */
  36261. getClassName(): string;
  36262. }
  36263. }
  36264. declare module BABYLON {
  36265. /**
  36266. * This represents a FPS type of camera. This is only here for back compat purpose.
  36267. * Please use the UniversalCamera instead as both are identical.
  36268. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36269. */
  36270. export class GamepadCamera extends UniversalCamera {
  36271. /**
  36272. * Instantiates a new Gamepad Camera
  36273. * This represents a FPS type of camera. This is only here for back compat purpose.
  36274. * Please use the UniversalCamera instead as both are identical.
  36275. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36276. * @param name Define the name of the camera in the scene
  36277. * @param position Define the start position of the camera in the scene
  36278. * @param scene Define the scene the camera belongs to
  36279. */
  36280. constructor(name: string, position: Vector3, scene: Scene);
  36281. /**
  36282. * Gets the current object class name.
  36283. * @return the class name
  36284. */
  36285. getClassName(): string;
  36286. }
  36287. }
  36288. declare module BABYLON {
  36289. /** @hidden */
  36290. export var passPixelShader: {
  36291. name: string;
  36292. shader: string;
  36293. };
  36294. }
  36295. declare module BABYLON {
  36296. /** @hidden */
  36297. export var passCubePixelShader: {
  36298. name: string;
  36299. shader: string;
  36300. };
  36301. }
  36302. declare module BABYLON {
  36303. /**
  36304. * PassPostProcess which produces an output the same as it's input
  36305. */
  36306. export class PassPostProcess extends PostProcess {
  36307. /**
  36308. * Creates the PassPostProcess
  36309. * @param name The name of the effect.
  36310. * @param options The required width/height ratio to downsize to before computing the render pass.
  36311. * @param camera The camera to apply the render pass to.
  36312. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36313. * @param engine The engine which the post process will be applied. (default: current engine)
  36314. * @param reusable If the post process can be reused on the same frame. (default: false)
  36315. * @param textureType The type of texture to be used when performing the post processing.
  36316. * @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)
  36317. */
  36318. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36319. }
  36320. /**
  36321. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36322. */
  36323. export class PassCubePostProcess extends PostProcess {
  36324. private _face;
  36325. /**
  36326. * Gets or sets the cube face to display.
  36327. * * 0 is +X
  36328. * * 1 is -X
  36329. * * 2 is +Y
  36330. * * 3 is -Y
  36331. * * 4 is +Z
  36332. * * 5 is -Z
  36333. */
  36334. face: number;
  36335. /**
  36336. * Creates the PassCubePostProcess
  36337. * @param name The name of the effect.
  36338. * @param options The required width/height ratio to downsize to before computing the render pass.
  36339. * @param camera The camera to apply the render pass to.
  36340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36341. * @param engine The engine which the post process will be applied. (default: current engine)
  36342. * @param reusable If the post process can be reused on the same frame. (default: false)
  36343. * @param textureType The type of texture to be used when performing the post processing.
  36344. * @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)
  36345. */
  36346. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36347. }
  36348. }
  36349. declare module BABYLON {
  36350. /** @hidden */
  36351. export var anaglyphPixelShader: {
  36352. name: string;
  36353. shader: string;
  36354. };
  36355. }
  36356. declare module BABYLON {
  36357. /**
  36358. * Postprocess used to generate anaglyphic rendering
  36359. */
  36360. export class AnaglyphPostProcess extends PostProcess {
  36361. private _passedProcess;
  36362. /**
  36363. * Creates a new AnaglyphPostProcess
  36364. * @param name defines postprocess name
  36365. * @param options defines creation options or target ratio scale
  36366. * @param rigCameras defines cameras using this postprocess
  36367. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  36368. * @param engine defines hosting engine
  36369. * @param reusable defines if the postprocess will be reused multiple times per frame
  36370. */
  36371. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  36372. }
  36373. }
  36374. declare module BABYLON {
  36375. /**
  36376. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  36377. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36378. */
  36379. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  36380. /**
  36381. * Creates a new AnaglyphArcRotateCamera
  36382. * @param name defines camera name
  36383. * @param alpha defines alpha angle (in radians)
  36384. * @param beta defines beta angle (in radians)
  36385. * @param radius defines radius
  36386. * @param target defines camera target
  36387. * @param interaxialDistance defines distance between each color axis
  36388. * @param scene defines the hosting scene
  36389. */
  36390. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  36391. /**
  36392. * Gets camera class name
  36393. * @returns AnaglyphArcRotateCamera
  36394. */
  36395. getClassName(): string;
  36396. }
  36397. }
  36398. declare module BABYLON {
  36399. /**
  36400. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  36401. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36402. */
  36403. export class AnaglyphFreeCamera extends FreeCamera {
  36404. /**
  36405. * Creates a new AnaglyphFreeCamera
  36406. * @param name defines camera name
  36407. * @param position defines initial position
  36408. * @param interaxialDistance defines distance between each color axis
  36409. * @param scene defines the hosting scene
  36410. */
  36411. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36412. /**
  36413. * Gets camera class name
  36414. * @returns AnaglyphFreeCamera
  36415. */
  36416. getClassName(): string;
  36417. }
  36418. }
  36419. declare module BABYLON {
  36420. /**
  36421. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  36422. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36423. */
  36424. export class AnaglyphGamepadCamera extends GamepadCamera {
  36425. /**
  36426. * Creates a new AnaglyphGamepadCamera
  36427. * @param name defines camera name
  36428. * @param position defines initial position
  36429. * @param interaxialDistance defines distance between each color axis
  36430. * @param scene defines the hosting scene
  36431. */
  36432. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36433. /**
  36434. * Gets camera class name
  36435. * @returns AnaglyphGamepadCamera
  36436. */
  36437. getClassName(): string;
  36438. }
  36439. }
  36440. declare module BABYLON {
  36441. /**
  36442. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  36443. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36444. */
  36445. export class AnaglyphUniversalCamera extends UniversalCamera {
  36446. /**
  36447. * Creates a new AnaglyphUniversalCamera
  36448. * @param name defines camera name
  36449. * @param position defines initial position
  36450. * @param interaxialDistance defines distance between each color axis
  36451. * @param scene defines the hosting scene
  36452. */
  36453. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36454. /**
  36455. * Gets camera class name
  36456. * @returns AnaglyphUniversalCamera
  36457. */
  36458. getClassName(): string;
  36459. }
  36460. }
  36461. declare module BABYLON {
  36462. /** @hidden */
  36463. export var stereoscopicInterlacePixelShader: {
  36464. name: string;
  36465. shader: string;
  36466. };
  36467. }
  36468. declare module BABYLON {
  36469. /**
  36470. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36471. */
  36472. export class StereoscopicInterlacePostProcess extends PostProcess {
  36473. private _stepSize;
  36474. private _passedProcess;
  36475. /**
  36476. * Initializes a StereoscopicInterlacePostProcess
  36477. * @param name The name of the effect.
  36478. * @param rigCameras The rig cameras to be appled to the post process
  36479. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36480. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36481. * @param engine The engine which the post process will be applied. (default: current engine)
  36482. * @param reusable If the post process can be reused on the same frame. (default: false)
  36483. */
  36484. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36485. }
  36486. }
  36487. declare module BABYLON {
  36488. /**
  36489. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  36490. * @see http://doc.babylonjs.com/features/cameras
  36491. */
  36492. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  36493. /**
  36494. * Creates a new StereoscopicArcRotateCamera
  36495. * @param name defines camera name
  36496. * @param alpha defines alpha angle (in radians)
  36497. * @param beta defines beta angle (in radians)
  36498. * @param radius defines radius
  36499. * @param target defines camera target
  36500. * @param interaxialDistance defines distance between each color axis
  36501. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36502. * @param scene defines the hosting scene
  36503. */
  36504. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36505. /**
  36506. * Gets camera class name
  36507. * @returns StereoscopicArcRotateCamera
  36508. */
  36509. getClassName(): string;
  36510. }
  36511. }
  36512. declare module BABYLON {
  36513. /**
  36514. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  36515. * @see http://doc.babylonjs.com/features/cameras
  36516. */
  36517. export class StereoscopicFreeCamera extends FreeCamera {
  36518. /**
  36519. * Creates a new StereoscopicFreeCamera
  36520. * @param name defines camera name
  36521. * @param position defines initial position
  36522. * @param interaxialDistance defines distance between each color axis
  36523. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36524. * @param scene defines the hosting scene
  36525. */
  36526. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36527. /**
  36528. * Gets camera class name
  36529. * @returns StereoscopicFreeCamera
  36530. */
  36531. getClassName(): string;
  36532. }
  36533. }
  36534. declare module BABYLON {
  36535. /**
  36536. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  36537. * @see http://doc.babylonjs.com/features/cameras
  36538. */
  36539. export class StereoscopicGamepadCamera extends GamepadCamera {
  36540. /**
  36541. * Creates a new StereoscopicGamepadCamera
  36542. * @param name defines camera name
  36543. * @param position defines initial position
  36544. * @param interaxialDistance defines distance between each color axis
  36545. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36546. * @param scene defines the hosting scene
  36547. */
  36548. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36549. /**
  36550. * Gets camera class name
  36551. * @returns StereoscopicGamepadCamera
  36552. */
  36553. getClassName(): string;
  36554. }
  36555. }
  36556. declare module BABYLON {
  36557. /**
  36558. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  36559. * @see http://doc.babylonjs.com/features/cameras
  36560. */
  36561. export class StereoscopicUniversalCamera extends UniversalCamera {
  36562. /**
  36563. * Creates a new StereoscopicUniversalCamera
  36564. * @param name defines camera name
  36565. * @param position defines initial position
  36566. * @param interaxialDistance defines distance between each color axis
  36567. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36568. * @param scene defines the hosting scene
  36569. */
  36570. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36571. /**
  36572. * Gets camera class name
  36573. * @returns StereoscopicUniversalCamera
  36574. */
  36575. getClassName(): string;
  36576. }
  36577. }
  36578. declare module BABYLON {
  36579. /**
  36580. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  36581. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36582. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36583. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36584. */
  36585. export class VirtualJoysticksCamera extends FreeCamera {
  36586. /**
  36587. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  36588. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36589. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36590. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36591. * @param name Define the name of the camera in the scene
  36592. * @param position Define the start position of the camera in the scene
  36593. * @param scene Define the scene the camera belongs to
  36594. */
  36595. constructor(name: string, position: Vector3, scene: Scene);
  36596. /**
  36597. * Gets the current object class name.
  36598. * @return the class name
  36599. */
  36600. getClassName(): string;
  36601. }
  36602. }
  36603. declare module BABYLON {
  36604. /**
  36605. * This represents all the required metrics to create a VR camera.
  36606. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  36607. */
  36608. export class VRCameraMetrics {
  36609. /**
  36610. * Define the horizontal resolution off the screen.
  36611. */
  36612. hResolution: number;
  36613. /**
  36614. * Define the vertical resolution off the screen.
  36615. */
  36616. vResolution: number;
  36617. /**
  36618. * Define the horizontal screen size.
  36619. */
  36620. hScreenSize: number;
  36621. /**
  36622. * Define the vertical screen size.
  36623. */
  36624. vScreenSize: number;
  36625. /**
  36626. * Define the vertical screen center position.
  36627. */
  36628. vScreenCenter: number;
  36629. /**
  36630. * Define the distance of the eyes to the screen.
  36631. */
  36632. eyeToScreenDistance: number;
  36633. /**
  36634. * Define the distance between both lenses
  36635. */
  36636. lensSeparationDistance: number;
  36637. /**
  36638. * Define the distance between both viewer's eyes.
  36639. */
  36640. interpupillaryDistance: number;
  36641. /**
  36642. * Define the distortion factor of the VR postprocess.
  36643. * Please, touch with care.
  36644. */
  36645. distortionK: number[];
  36646. /**
  36647. * Define the chromatic aberration correction factors for the VR post process.
  36648. */
  36649. chromaAbCorrection: number[];
  36650. /**
  36651. * Define the scale factor of the post process.
  36652. * The smaller the better but the slower.
  36653. */
  36654. postProcessScaleFactor: number;
  36655. /**
  36656. * Define an offset for the lens center.
  36657. */
  36658. lensCenterOffset: number;
  36659. /**
  36660. * Define if the current vr camera should compensate the distortion of the lense or not.
  36661. */
  36662. compensateDistortion: boolean;
  36663. /**
  36664. * Gets the rendering aspect ratio based on the provided resolutions.
  36665. */
  36666. readonly aspectRatio: number;
  36667. /**
  36668. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  36669. */
  36670. readonly aspectRatioFov: number;
  36671. /**
  36672. * @hidden
  36673. */
  36674. readonly leftHMatrix: Matrix;
  36675. /**
  36676. * @hidden
  36677. */
  36678. readonly rightHMatrix: Matrix;
  36679. /**
  36680. * @hidden
  36681. */
  36682. readonly leftPreViewMatrix: Matrix;
  36683. /**
  36684. * @hidden
  36685. */
  36686. readonly rightPreViewMatrix: Matrix;
  36687. /**
  36688. * Get the default VRMetrics based on the most generic setup.
  36689. * @returns the default vr metrics
  36690. */
  36691. static GetDefault(): VRCameraMetrics;
  36692. }
  36693. }
  36694. declare module BABYLON {
  36695. /** @hidden */
  36696. export var vrDistortionCorrectionPixelShader: {
  36697. name: string;
  36698. shader: string;
  36699. };
  36700. }
  36701. declare module BABYLON {
  36702. /**
  36703. * VRDistortionCorrectionPostProcess used for mobile VR
  36704. */
  36705. export class VRDistortionCorrectionPostProcess extends PostProcess {
  36706. private _isRightEye;
  36707. private _distortionFactors;
  36708. private _postProcessScaleFactor;
  36709. private _lensCenterOffset;
  36710. private _scaleIn;
  36711. private _scaleFactor;
  36712. private _lensCenter;
  36713. /**
  36714. * Initializes the VRDistortionCorrectionPostProcess
  36715. * @param name The name of the effect.
  36716. * @param camera The camera to apply the render pass to.
  36717. * @param isRightEye If this is for the right eye distortion
  36718. * @param vrMetrics All the required metrics for the VR camera
  36719. */
  36720. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  36721. }
  36722. }
  36723. declare module BABYLON {
  36724. /**
  36725. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  36726. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36727. */
  36728. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  36729. /**
  36730. * Creates a new VRDeviceOrientationArcRotateCamera
  36731. * @param name defines camera name
  36732. * @param alpha defines the camera rotation along the logitudinal axis
  36733. * @param beta defines the camera rotation along the latitudinal axis
  36734. * @param radius defines the camera distance from its target
  36735. * @param target defines the camera target
  36736. * @param scene defines the scene the camera belongs to
  36737. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36738. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36739. */
  36740. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36741. /**
  36742. * Gets camera class name
  36743. * @returns VRDeviceOrientationArcRotateCamera
  36744. */
  36745. getClassName(): string;
  36746. }
  36747. }
  36748. declare module BABYLON {
  36749. /**
  36750. * Camera used to simulate VR rendering (based on FreeCamera)
  36751. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36752. */
  36753. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  36754. /**
  36755. * Creates a new VRDeviceOrientationFreeCamera
  36756. * @param name defines camera name
  36757. * @param position defines the start position of the camera
  36758. * @param scene defines the scene the camera belongs to
  36759. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36760. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36761. */
  36762. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36763. /**
  36764. * Gets camera class name
  36765. * @returns VRDeviceOrientationFreeCamera
  36766. */
  36767. getClassName(): string;
  36768. }
  36769. }
  36770. declare module BABYLON {
  36771. /**
  36772. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  36773. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36774. */
  36775. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  36776. /**
  36777. * Creates a new VRDeviceOrientationGamepadCamera
  36778. * @param name defines camera name
  36779. * @param position defines the start position of the camera
  36780. * @param scene defines the scene the camera belongs to
  36781. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36782. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36783. */
  36784. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36785. /**
  36786. * Gets camera class name
  36787. * @returns VRDeviceOrientationGamepadCamera
  36788. */
  36789. getClassName(): string;
  36790. }
  36791. }
  36792. declare module BABYLON {
  36793. /**
  36794. * Defines supported buttons for XBox360 compatible gamepads
  36795. */
  36796. export enum Xbox360Button {
  36797. /** A */
  36798. A = 0,
  36799. /** B */
  36800. B = 1,
  36801. /** X */
  36802. X = 2,
  36803. /** Y */
  36804. Y = 3,
  36805. /** Start */
  36806. Start = 4,
  36807. /** Back */
  36808. Back = 5,
  36809. /** Left button */
  36810. LB = 6,
  36811. /** Right button */
  36812. RB = 7,
  36813. /** Left stick */
  36814. LeftStick = 8,
  36815. /** Right stick */
  36816. RightStick = 9
  36817. }
  36818. /** Defines values for XBox360 DPad */
  36819. export enum Xbox360Dpad {
  36820. /** Up */
  36821. Up = 0,
  36822. /** Down */
  36823. Down = 1,
  36824. /** Left */
  36825. Left = 2,
  36826. /** Right */
  36827. Right = 3
  36828. }
  36829. /**
  36830. * Defines a XBox360 gamepad
  36831. */
  36832. export class Xbox360Pad extends Gamepad {
  36833. private _leftTrigger;
  36834. private _rightTrigger;
  36835. private _onlefttriggerchanged;
  36836. private _onrighttriggerchanged;
  36837. private _onbuttondown;
  36838. private _onbuttonup;
  36839. private _ondpaddown;
  36840. private _ondpadup;
  36841. /** Observable raised when a button is pressed */
  36842. onButtonDownObservable: Observable<Xbox360Button>;
  36843. /** Observable raised when a button is released */
  36844. onButtonUpObservable: Observable<Xbox360Button>;
  36845. /** Observable raised when a pad is pressed */
  36846. onPadDownObservable: Observable<Xbox360Dpad>;
  36847. /** Observable raised when a pad is released */
  36848. onPadUpObservable: Observable<Xbox360Dpad>;
  36849. private _buttonA;
  36850. private _buttonB;
  36851. private _buttonX;
  36852. private _buttonY;
  36853. private _buttonBack;
  36854. private _buttonStart;
  36855. private _buttonLB;
  36856. private _buttonRB;
  36857. private _buttonLeftStick;
  36858. private _buttonRightStick;
  36859. private _dPadUp;
  36860. private _dPadDown;
  36861. private _dPadLeft;
  36862. private _dPadRight;
  36863. private _isXboxOnePad;
  36864. /**
  36865. * Creates a new XBox360 gamepad object
  36866. * @param id defines the id of this gamepad
  36867. * @param index defines its index
  36868. * @param gamepad defines the internal HTML gamepad object
  36869. * @param xboxOne defines if it is a XBox One gamepad
  36870. */
  36871. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  36872. /**
  36873. * Defines the callback to call when left trigger is pressed
  36874. * @param callback defines the callback to use
  36875. */
  36876. onlefttriggerchanged(callback: (value: number) => void): void;
  36877. /**
  36878. * Defines the callback to call when right trigger is pressed
  36879. * @param callback defines the callback to use
  36880. */
  36881. onrighttriggerchanged(callback: (value: number) => void): void;
  36882. /**
  36883. * Gets the left trigger value
  36884. */
  36885. /**
  36886. * Sets the left trigger value
  36887. */
  36888. leftTrigger: number;
  36889. /**
  36890. * Gets the right trigger value
  36891. */
  36892. /**
  36893. * Sets the right trigger value
  36894. */
  36895. rightTrigger: number;
  36896. /**
  36897. * Defines the callback to call when a button is pressed
  36898. * @param callback defines the callback to use
  36899. */
  36900. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  36901. /**
  36902. * Defines the callback to call when a button is released
  36903. * @param callback defines the callback to use
  36904. */
  36905. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  36906. /**
  36907. * Defines the callback to call when a pad is pressed
  36908. * @param callback defines the callback to use
  36909. */
  36910. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  36911. /**
  36912. * Defines the callback to call when a pad is released
  36913. * @param callback defines the callback to use
  36914. */
  36915. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  36916. private _setButtonValue;
  36917. private _setDPadValue;
  36918. /**
  36919. * Gets the value of the `A` button
  36920. */
  36921. /**
  36922. * Sets the value of the `A` button
  36923. */
  36924. buttonA: number;
  36925. /**
  36926. * Gets the value of the `B` button
  36927. */
  36928. /**
  36929. * Sets the value of the `B` button
  36930. */
  36931. buttonB: number;
  36932. /**
  36933. * Gets the value of the `X` button
  36934. */
  36935. /**
  36936. * Sets the value of the `X` button
  36937. */
  36938. buttonX: number;
  36939. /**
  36940. * Gets the value of the `Y` button
  36941. */
  36942. /**
  36943. * Sets the value of the `Y` button
  36944. */
  36945. buttonY: number;
  36946. /**
  36947. * Gets the value of the `Start` button
  36948. */
  36949. /**
  36950. * Sets the value of the `Start` button
  36951. */
  36952. buttonStart: number;
  36953. /**
  36954. * Gets the value of the `Back` button
  36955. */
  36956. /**
  36957. * Sets the value of the `Back` button
  36958. */
  36959. buttonBack: number;
  36960. /**
  36961. * Gets the value of the `Left` button
  36962. */
  36963. /**
  36964. * Sets the value of the `Left` button
  36965. */
  36966. buttonLB: number;
  36967. /**
  36968. * Gets the value of the `Right` button
  36969. */
  36970. /**
  36971. * Sets the value of the `Right` button
  36972. */
  36973. buttonRB: number;
  36974. /**
  36975. * Gets the value of the Left joystick
  36976. */
  36977. /**
  36978. * Sets the value of the Left joystick
  36979. */
  36980. buttonLeftStick: number;
  36981. /**
  36982. * Gets the value of the Right joystick
  36983. */
  36984. /**
  36985. * Sets the value of the Right joystick
  36986. */
  36987. buttonRightStick: number;
  36988. /**
  36989. * Gets the value of D-pad up
  36990. */
  36991. /**
  36992. * Sets the value of D-pad up
  36993. */
  36994. dPadUp: number;
  36995. /**
  36996. * Gets the value of D-pad down
  36997. */
  36998. /**
  36999. * Sets the value of D-pad down
  37000. */
  37001. dPadDown: number;
  37002. /**
  37003. * Gets the value of D-pad left
  37004. */
  37005. /**
  37006. * Sets the value of D-pad left
  37007. */
  37008. dPadLeft: number;
  37009. /**
  37010. * Gets the value of D-pad right
  37011. */
  37012. /**
  37013. * Sets the value of D-pad right
  37014. */
  37015. dPadRight: number;
  37016. /**
  37017. * Force the gamepad to synchronize with device values
  37018. */
  37019. update(): void;
  37020. /**
  37021. * Disposes the gamepad
  37022. */
  37023. dispose(): void;
  37024. }
  37025. }
  37026. declare module BABYLON {
  37027. /**
  37028. * Base class of materials working in push mode in babylon JS
  37029. * @hidden
  37030. */
  37031. export class PushMaterial extends Material {
  37032. protected _activeEffect: Effect;
  37033. protected _normalMatrix: Matrix;
  37034. /**
  37035. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  37036. * This means that the material can keep using a previous shader while a new one is being compiled.
  37037. * This is mostly used when shader parallel compilation is supported (true by default)
  37038. */
  37039. allowShaderHotSwapping: boolean;
  37040. constructor(name: string, scene: Scene);
  37041. getEffect(): Effect;
  37042. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37043. /**
  37044. * Binds the given world matrix to the active effect
  37045. *
  37046. * @param world the matrix to bind
  37047. */
  37048. bindOnlyWorldMatrix(world: Matrix): void;
  37049. /**
  37050. * Binds the given normal matrix to the active effect
  37051. *
  37052. * @param normalMatrix the matrix to bind
  37053. */
  37054. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37055. bind(world: Matrix, mesh?: Mesh): void;
  37056. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37057. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37058. }
  37059. }
  37060. declare module BABYLON {
  37061. /**
  37062. * This groups all the flags used to control the materials channel.
  37063. */
  37064. export class MaterialFlags {
  37065. private static _DiffuseTextureEnabled;
  37066. /**
  37067. * Are diffuse textures enabled in the application.
  37068. */
  37069. static DiffuseTextureEnabled: boolean;
  37070. private static _AmbientTextureEnabled;
  37071. /**
  37072. * Are ambient textures enabled in the application.
  37073. */
  37074. static AmbientTextureEnabled: boolean;
  37075. private static _OpacityTextureEnabled;
  37076. /**
  37077. * Are opacity textures enabled in the application.
  37078. */
  37079. static OpacityTextureEnabled: boolean;
  37080. private static _ReflectionTextureEnabled;
  37081. /**
  37082. * Are reflection textures enabled in the application.
  37083. */
  37084. static ReflectionTextureEnabled: boolean;
  37085. private static _EmissiveTextureEnabled;
  37086. /**
  37087. * Are emissive textures enabled in the application.
  37088. */
  37089. static EmissiveTextureEnabled: boolean;
  37090. private static _SpecularTextureEnabled;
  37091. /**
  37092. * Are specular textures enabled in the application.
  37093. */
  37094. static SpecularTextureEnabled: boolean;
  37095. private static _BumpTextureEnabled;
  37096. /**
  37097. * Are bump textures enabled in the application.
  37098. */
  37099. static BumpTextureEnabled: boolean;
  37100. private static _LightmapTextureEnabled;
  37101. /**
  37102. * Are lightmap textures enabled in the application.
  37103. */
  37104. static LightmapTextureEnabled: boolean;
  37105. private static _RefractionTextureEnabled;
  37106. /**
  37107. * Are refraction textures enabled in the application.
  37108. */
  37109. static RefractionTextureEnabled: boolean;
  37110. private static _ColorGradingTextureEnabled;
  37111. /**
  37112. * Are color grading textures enabled in the application.
  37113. */
  37114. static ColorGradingTextureEnabled: boolean;
  37115. private static _FresnelEnabled;
  37116. /**
  37117. * Are fresnels enabled in the application.
  37118. */
  37119. static FresnelEnabled: boolean;
  37120. private static _ClearCoatTextureEnabled;
  37121. /**
  37122. * Are clear coat textures enabled in the application.
  37123. */
  37124. static ClearCoatTextureEnabled: boolean;
  37125. private static _ClearCoatBumpTextureEnabled;
  37126. /**
  37127. * Are clear coat bump textures enabled in the application.
  37128. */
  37129. static ClearCoatBumpTextureEnabled: boolean;
  37130. private static _ClearCoatTintTextureEnabled;
  37131. /**
  37132. * Are clear coat tint textures enabled in the application.
  37133. */
  37134. static ClearCoatTintTextureEnabled: boolean;
  37135. }
  37136. }
  37137. declare module BABYLON {
  37138. /** @hidden */
  37139. export var defaultFragmentDeclaration: {
  37140. name: string;
  37141. shader: string;
  37142. };
  37143. }
  37144. declare module BABYLON {
  37145. /** @hidden */
  37146. export var defaultUboDeclaration: {
  37147. name: string;
  37148. shader: string;
  37149. };
  37150. }
  37151. declare module BABYLON {
  37152. /** @hidden */
  37153. export var lightFragmentDeclaration: {
  37154. name: string;
  37155. shader: string;
  37156. };
  37157. }
  37158. declare module BABYLON {
  37159. /** @hidden */
  37160. export var lightUboDeclaration: {
  37161. name: string;
  37162. shader: string;
  37163. };
  37164. }
  37165. declare module BABYLON {
  37166. /** @hidden */
  37167. export var lightsFragmentFunctions: {
  37168. name: string;
  37169. shader: string;
  37170. };
  37171. }
  37172. declare module BABYLON {
  37173. /** @hidden */
  37174. export var shadowsFragmentFunctions: {
  37175. name: string;
  37176. shader: string;
  37177. };
  37178. }
  37179. declare module BABYLON {
  37180. /** @hidden */
  37181. export var fresnelFunction: {
  37182. name: string;
  37183. shader: string;
  37184. };
  37185. }
  37186. declare module BABYLON {
  37187. /** @hidden */
  37188. export var reflectionFunction: {
  37189. name: string;
  37190. shader: string;
  37191. };
  37192. }
  37193. declare module BABYLON {
  37194. /** @hidden */
  37195. export var bumpFragmentFunctions: {
  37196. name: string;
  37197. shader: string;
  37198. };
  37199. }
  37200. declare module BABYLON {
  37201. /** @hidden */
  37202. export var logDepthDeclaration: {
  37203. name: string;
  37204. shader: string;
  37205. };
  37206. }
  37207. declare module BABYLON {
  37208. /** @hidden */
  37209. export var bumpFragment: {
  37210. name: string;
  37211. shader: string;
  37212. };
  37213. }
  37214. declare module BABYLON {
  37215. /** @hidden */
  37216. export var depthPrePass: {
  37217. name: string;
  37218. shader: string;
  37219. };
  37220. }
  37221. declare module BABYLON {
  37222. /** @hidden */
  37223. export var lightFragment: {
  37224. name: string;
  37225. shader: string;
  37226. };
  37227. }
  37228. declare module BABYLON {
  37229. /** @hidden */
  37230. export var logDepthFragment: {
  37231. name: string;
  37232. shader: string;
  37233. };
  37234. }
  37235. declare module BABYLON {
  37236. /** @hidden */
  37237. export var defaultPixelShader: {
  37238. name: string;
  37239. shader: string;
  37240. };
  37241. }
  37242. declare module BABYLON {
  37243. /** @hidden */
  37244. export var defaultVertexDeclaration: {
  37245. name: string;
  37246. shader: string;
  37247. };
  37248. }
  37249. declare module BABYLON {
  37250. /** @hidden */
  37251. export var bumpVertexDeclaration: {
  37252. name: string;
  37253. shader: string;
  37254. };
  37255. }
  37256. declare module BABYLON {
  37257. /** @hidden */
  37258. export var bumpVertex: {
  37259. name: string;
  37260. shader: string;
  37261. };
  37262. }
  37263. declare module BABYLON {
  37264. /** @hidden */
  37265. export var fogVertex: {
  37266. name: string;
  37267. shader: string;
  37268. };
  37269. }
  37270. declare module BABYLON {
  37271. /** @hidden */
  37272. export var shadowsVertex: {
  37273. name: string;
  37274. shader: string;
  37275. };
  37276. }
  37277. declare module BABYLON {
  37278. /** @hidden */
  37279. export var pointCloudVertex: {
  37280. name: string;
  37281. shader: string;
  37282. };
  37283. }
  37284. declare module BABYLON {
  37285. /** @hidden */
  37286. export var logDepthVertex: {
  37287. name: string;
  37288. shader: string;
  37289. };
  37290. }
  37291. declare module BABYLON {
  37292. /** @hidden */
  37293. export var defaultVertexShader: {
  37294. name: string;
  37295. shader: string;
  37296. };
  37297. }
  37298. declare module BABYLON {
  37299. /** @hidden */
  37300. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  37301. MAINUV1: boolean;
  37302. MAINUV2: boolean;
  37303. DIFFUSE: boolean;
  37304. DIFFUSEDIRECTUV: number;
  37305. AMBIENT: boolean;
  37306. AMBIENTDIRECTUV: number;
  37307. OPACITY: boolean;
  37308. OPACITYDIRECTUV: number;
  37309. OPACITYRGB: boolean;
  37310. REFLECTION: boolean;
  37311. EMISSIVE: boolean;
  37312. EMISSIVEDIRECTUV: number;
  37313. SPECULAR: boolean;
  37314. SPECULARDIRECTUV: number;
  37315. BUMP: boolean;
  37316. BUMPDIRECTUV: number;
  37317. PARALLAX: boolean;
  37318. PARALLAXOCCLUSION: boolean;
  37319. SPECULAROVERALPHA: boolean;
  37320. CLIPPLANE: boolean;
  37321. CLIPPLANE2: boolean;
  37322. CLIPPLANE3: boolean;
  37323. CLIPPLANE4: boolean;
  37324. ALPHATEST: boolean;
  37325. DEPTHPREPASS: boolean;
  37326. ALPHAFROMDIFFUSE: boolean;
  37327. POINTSIZE: boolean;
  37328. FOG: boolean;
  37329. SPECULARTERM: boolean;
  37330. DIFFUSEFRESNEL: boolean;
  37331. OPACITYFRESNEL: boolean;
  37332. REFLECTIONFRESNEL: boolean;
  37333. REFRACTIONFRESNEL: boolean;
  37334. EMISSIVEFRESNEL: boolean;
  37335. FRESNEL: boolean;
  37336. NORMAL: boolean;
  37337. UV1: boolean;
  37338. UV2: boolean;
  37339. VERTEXCOLOR: boolean;
  37340. VERTEXALPHA: boolean;
  37341. NUM_BONE_INFLUENCERS: number;
  37342. BonesPerMesh: number;
  37343. BONETEXTURE: boolean;
  37344. INSTANCES: boolean;
  37345. GLOSSINESS: boolean;
  37346. ROUGHNESS: boolean;
  37347. EMISSIVEASILLUMINATION: boolean;
  37348. LINKEMISSIVEWITHDIFFUSE: boolean;
  37349. REFLECTIONFRESNELFROMSPECULAR: boolean;
  37350. LIGHTMAP: boolean;
  37351. LIGHTMAPDIRECTUV: number;
  37352. OBJECTSPACE_NORMALMAP: boolean;
  37353. USELIGHTMAPASSHADOWMAP: boolean;
  37354. REFLECTIONMAP_3D: boolean;
  37355. REFLECTIONMAP_SPHERICAL: boolean;
  37356. REFLECTIONMAP_PLANAR: boolean;
  37357. REFLECTIONMAP_CUBIC: boolean;
  37358. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  37359. REFLECTIONMAP_PROJECTION: boolean;
  37360. REFLECTIONMAP_SKYBOX: boolean;
  37361. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  37362. REFLECTIONMAP_EXPLICIT: boolean;
  37363. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  37364. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  37365. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  37366. INVERTCUBICMAP: boolean;
  37367. LOGARITHMICDEPTH: boolean;
  37368. REFRACTION: boolean;
  37369. REFRACTIONMAP_3D: boolean;
  37370. REFLECTIONOVERALPHA: boolean;
  37371. TWOSIDEDLIGHTING: boolean;
  37372. SHADOWFLOAT: boolean;
  37373. MORPHTARGETS: boolean;
  37374. MORPHTARGETS_NORMAL: boolean;
  37375. MORPHTARGETS_TANGENT: boolean;
  37376. NUM_MORPH_INFLUENCERS: number;
  37377. NONUNIFORMSCALING: boolean;
  37378. PREMULTIPLYALPHA: boolean;
  37379. IMAGEPROCESSING: boolean;
  37380. VIGNETTE: boolean;
  37381. VIGNETTEBLENDMODEMULTIPLY: boolean;
  37382. VIGNETTEBLENDMODEOPAQUE: boolean;
  37383. TONEMAPPING: boolean;
  37384. TONEMAPPING_ACES: boolean;
  37385. CONTRAST: boolean;
  37386. COLORCURVES: boolean;
  37387. COLORGRADING: boolean;
  37388. COLORGRADING3D: boolean;
  37389. SAMPLER3DGREENDEPTH: boolean;
  37390. SAMPLER3DBGRMAP: boolean;
  37391. IMAGEPROCESSINGPOSTPROCESS: boolean;
  37392. /**
  37393. * If the reflection texture on this material is in linear color space
  37394. * @hidden
  37395. */
  37396. IS_REFLECTION_LINEAR: boolean;
  37397. /**
  37398. * If the refraction texture on this material is in linear color space
  37399. * @hidden
  37400. */
  37401. IS_REFRACTION_LINEAR: boolean;
  37402. EXPOSURE: boolean;
  37403. constructor();
  37404. setReflectionMode(modeToEnable: string): void;
  37405. }
  37406. /**
  37407. * This is the default material used in Babylon. It is the best trade off between quality
  37408. * and performances.
  37409. * @see http://doc.babylonjs.com/babylon101/materials
  37410. */
  37411. export class StandardMaterial extends PushMaterial {
  37412. private _diffuseTexture;
  37413. /**
  37414. * The basic texture of the material as viewed under a light.
  37415. */
  37416. diffuseTexture: Nullable<BaseTexture>;
  37417. private _ambientTexture;
  37418. /**
  37419. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  37420. */
  37421. ambientTexture: Nullable<BaseTexture>;
  37422. private _opacityTexture;
  37423. /**
  37424. * Define the transparency of the material from a texture.
  37425. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  37426. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  37427. */
  37428. opacityTexture: Nullable<BaseTexture>;
  37429. private _reflectionTexture;
  37430. /**
  37431. * Define the texture used to display the reflection.
  37432. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37433. */
  37434. reflectionTexture: Nullable<BaseTexture>;
  37435. private _emissiveTexture;
  37436. /**
  37437. * Define texture of the material as if self lit.
  37438. * This will be mixed in the final result even in the absence of light.
  37439. */
  37440. emissiveTexture: Nullable<BaseTexture>;
  37441. private _specularTexture;
  37442. /**
  37443. * Define how the color and intensity of the highlight given by the light in the material.
  37444. */
  37445. specularTexture: Nullable<BaseTexture>;
  37446. private _bumpTexture;
  37447. /**
  37448. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  37449. * 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.
  37450. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  37451. */
  37452. bumpTexture: Nullable<BaseTexture>;
  37453. private _lightmapTexture;
  37454. /**
  37455. * Complex lighting can be computationally expensive to compute at runtime.
  37456. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  37457. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  37458. */
  37459. lightmapTexture: Nullable<BaseTexture>;
  37460. private _refractionTexture;
  37461. /**
  37462. * Define the texture used to display the refraction.
  37463. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37464. */
  37465. refractionTexture: Nullable<BaseTexture>;
  37466. /**
  37467. * The color of the material lit by the environmental background lighting.
  37468. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  37469. */
  37470. ambientColor: Color3;
  37471. /**
  37472. * The basic color of the material as viewed under a light.
  37473. */
  37474. diffuseColor: Color3;
  37475. /**
  37476. * Define how the color and intensity of the highlight given by the light in the material.
  37477. */
  37478. specularColor: Color3;
  37479. /**
  37480. * Define the color of the material as if self lit.
  37481. * This will be mixed in the final result even in the absence of light.
  37482. */
  37483. emissiveColor: Color3;
  37484. /**
  37485. * Defines how sharp are the highlights in the material.
  37486. * The bigger the value the sharper giving a more glossy feeling to the result.
  37487. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  37488. */
  37489. specularPower: number;
  37490. private _useAlphaFromDiffuseTexture;
  37491. /**
  37492. * Does the transparency come from the diffuse texture alpha channel.
  37493. */
  37494. useAlphaFromDiffuseTexture: boolean;
  37495. private _useEmissiveAsIllumination;
  37496. /**
  37497. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  37498. */
  37499. useEmissiveAsIllumination: boolean;
  37500. private _linkEmissiveWithDiffuse;
  37501. /**
  37502. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  37503. * the emissive level when the final color is close to one.
  37504. */
  37505. linkEmissiveWithDiffuse: boolean;
  37506. private _useSpecularOverAlpha;
  37507. /**
  37508. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  37509. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  37510. */
  37511. useSpecularOverAlpha: boolean;
  37512. private _useReflectionOverAlpha;
  37513. /**
  37514. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  37515. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  37516. */
  37517. useReflectionOverAlpha: boolean;
  37518. private _disableLighting;
  37519. /**
  37520. * Does lights from the scene impacts this material.
  37521. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  37522. */
  37523. disableLighting: boolean;
  37524. private _useObjectSpaceNormalMap;
  37525. /**
  37526. * Allows using an object space normal map (instead of tangent space).
  37527. */
  37528. useObjectSpaceNormalMap: boolean;
  37529. private _useParallax;
  37530. /**
  37531. * Is parallax enabled or not.
  37532. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37533. */
  37534. useParallax: boolean;
  37535. private _useParallaxOcclusion;
  37536. /**
  37537. * Is parallax occlusion enabled or not.
  37538. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  37539. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37540. */
  37541. useParallaxOcclusion: boolean;
  37542. /**
  37543. * 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.
  37544. */
  37545. parallaxScaleBias: number;
  37546. private _roughness;
  37547. /**
  37548. * Helps to define how blurry the reflections should appears in the material.
  37549. */
  37550. roughness: number;
  37551. /**
  37552. * In case of refraction, define the value of the indice of refraction.
  37553. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37554. */
  37555. indexOfRefraction: number;
  37556. /**
  37557. * Invert the refraction texture alongside the y axis.
  37558. * It can be useful with procedural textures or probe for instance.
  37559. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37560. */
  37561. invertRefractionY: boolean;
  37562. /**
  37563. * Defines the alpha limits in alpha test mode.
  37564. */
  37565. alphaCutOff: number;
  37566. private _useLightmapAsShadowmap;
  37567. /**
  37568. * In case of light mapping, define whether the map contains light or shadow informations.
  37569. */
  37570. useLightmapAsShadowmap: boolean;
  37571. private _diffuseFresnelParameters;
  37572. /**
  37573. * Define the diffuse fresnel parameters of the material.
  37574. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37575. */
  37576. diffuseFresnelParameters: FresnelParameters;
  37577. private _opacityFresnelParameters;
  37578. /**
  37579. * Define the opacity fresnel parameters of the material.
  37580. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37581. */
  37582. opacityFresnelParameters: FresnelParameters;
  37583. private _reflectionFresnelParameters;
  37584. /**
  37585. * Define the reflection fresnel parameters of the material.
  37586. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37587. */
  37588. reflectionFresnelParameters: FresnelParameters;
  37589. private _refractionFresnelParameters;
  37590. /**
  37591. * Define the refraction fresnel parameters of the material.
  37592. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37593. */
  37594. refractionFresnelParameters: FresnelParameters;
  37595. private _emissiveFresnelParameters;
  37596. /**
  37597. * Define the emissive fresnel parameters of the material.
  37598. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37599. */
  37600. emissiveFresnelParameters: FresnelParameters;
  37601. private _useReflectionFresnelFromSpecular;
  37602. /**
  37603. * If true automatically deducts the fresnels values from the material specularity.
  37604. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37605. */
  37606. useReflectionFresnelFromSpecular: boolean;
  37607. private _useGlossinessFromSpecularMapAlpha;
  37608. /**
  37609. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  37610. */
  37611. useGlossinessFromSpecularMapAlpha: boolean;
  37612. private _maxSimultaneousLights;
  37613. /**
  37614. * Defines the maximum number of lights that can be used in the material
  37615. */
  37616. maxSimultaneousLights: number;
  37617. private _invertNormalMapX;
  37618. /**
  37619. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  37620. */
  37621. invertNormalMapX: boolean;
  37622. private _invertNormalMapY;
  37623. /**
  37624. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  37625. */
  37626. invertNormalMapY: boolean;
  37627. private _twoSidedLighting;
  37628. /**
  37629. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  37630. */
  37631. twoSidedLighting: boolean;
  37632. /**
  37633. * Default configuration related to image processing available in the standard Material.
  37634. */
  37635. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  37636. /**
  37637. * Gets the image processing configuration used either in this material.
  37638. */
  37639. /**
  37640. * Sets the Default image processing configuration used either in the this material.
  37641. *
  37642. * If sets to null, the scene one is in use.
  37643. */
  37644. imageProcessingConfiguration: ImageProcessingConfiguration;
  37645. /**
  37646. * Keep track of the image processing observer to allow dispose and replace.
  37647. */
  37648. private _imageProcessingObserver;
  37649. /**
  37650. * Attaches a new image processing configuration to the Standard Material.
  37651. * @param configuration
  37652. */
  37653. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  37654. /**
  37655. * Gets wether the color curves effect is enabled.
  37656. */
  37657. /**
  37658. * Sets wether the color curves effect is enabled.
  37659. */
  37660. cameraColorCurvesEnabled: boolean;
  37661. /**
  37662. * Gets wether the color grading effect is enabled.
  37663. */
  37664. /**
  37665. * Gets wether the color grading effect is enabled.
  37666. */
  37667. cameraColorGradingEnabled: boolean;
  37668. /**
  37669. * Gets wether tonemapping is enabled or not.
  37670. */
  37671. /**
  37672. * Sets wether tonemapping is enabled or not
  37673. */
  37674. cameraToneMappingEnabled: boolean;
  37675. /**
  37676. * The camera exposure used on this material.
  37677. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37678. * This corresponds to a photographic exposure.
  37679. */
  37680. /**
  37681. * The camera exposure used on this material.
  37682. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37683. * This corresponds to a photographic exposure.
  37684. */
  37685. cameraExposure: number;
  37686. /**
  37687. * Gets The camera contrast used on this material.
  37688. */
  37689. /**
  37690. * Sets The camera contrast used on this material.
  37691. */
  37692. cameraContrast: number;
  37693. /**
  37694. * Gets the Color Grading 2D Lookup Texture.
  37695. */
  37696. /**
  37697. * Sets the Color Grading 2D Lookup Texture.
  37698. */
  37699. cameraColorGradingTexture: Nullable<BaseTexture>;
  37700. /**
  37701. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37702. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37703. * 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;
  37704. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37705. */
  37706. /**
  37707. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37708. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37709. * 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;
  37710. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37711. */
  37712. cameraColorCurves: Nullable<ColorCurves>;
  37713. /**
  37714. * Custom callback helping to override the default shader used in the material.
  37715. */
  37716. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  37717. protected _renderTargets: SmartArray<RenderTargetTexture>;
  37718. protected _worldViewProjectionMatrix: Matrix;
  37719. protected _globalAmbientColor: Color3;
  37720. protected _useLogarithmicDepth: boolean;
  37721. /**
  37722. * Instantiates a new standard material.
  37723. * This is the default material used in Babylon. It is the best trade off between quality
  37724. * and performances.
  37725. * @see http://doc.babylonjs.com/babylon101/materials
  37726. * @param name Define the name of the material in the scene
  37727. * @param scene Define the scene the material belong to
  37728. */
  37729. constructor(name: string, scene: Scene);
  37730. /**
  37731. * Gets a boolean indicating that current material needs to register RTT
  37732. */
  37733. readonly hasRenderTargetTextures: boolean;
  37734. /**
  37735. * Gets the current class name of the material e.g. "StandardMaterial"
  37736. * Mainly use in serialization.
  37737. * @returns the class name
  37738. */
  37739. getClassName(): string;
  37740. /**
  37741. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  37742. * You can try switching to logarithmic depth.
  37743. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  37744. */
  37745. useLogarithmicDepth: boolean;
  37746. /**
  37747. * Specifies if the material will require alpha blending
  37748. * @returns a boolean specifying if alpha blending is needed
  37749. */
  37750. needAlphaBlending(): boolean;
  37751. /**
  37752. * Specifies if this material should be rendered in alpha test mode
  37753. * @returns a boolean specifying if an alpha test is needed.
  37754. */
  37755. needAlphaTesting(): boolean;
  37756. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  37757. /**
  37758. * Get the texture used for alpha test purpose.
  37759. * @returns the diffuse texture in case of the standard material.
  37760. */
  37761. getAlphaTestTexture(): Nullable<BaseTexture>;
  37762. /**
  37763. * Get if the submesh is ready to be used and all its information available.
  37764. * Child classes can use it to update shaders
  37765. * @param mesh defines the mesh to check
  37766. * @param subMesh defines which submesh to check
  37767. * @param useInstances specifies that instances should be used
  37768. * @returns a boolean indicating that the submesh is ready or not
  37769. */
  37770. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  37771. /**
  37772. * Builds the material UBO layouts.
  37773. * Used internally during the effect preparation.
  37774. */
  37775. buildUniformLayout(): void;
  37776. /**
  37777. * Unbinds the material from the mesh
  37778. */
  37779. unbind(): void;
  37780. /**
  37781. * Binds the submesh to this material by preparing the effect and shader to draw
  37782. * @param world defines the world transformation matrix
  37783. * @param mesh defines the mesh containing the submesh
  37784. * @param subMesh defines the submesh to bind the material to
  37785. */
  37786. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  37787. /**
  37788. * Get the list of animatables in the material.
  37789. * @returns the list of animatables object used in the material
  37790. */
  37791. getAnimatables(): IAnimatable[];
  37792. /**
  37793. * Gets the active textures from the material
  37794. * @returns an array of textures
  37795. */
  37796. getActiveTextures(): BaseTexture[];
  37797. /**
  37798. * Specifies if the material uses a texture
  37799. * @param texture defines the texture to check against the material
  37800. * @returns a boolean specifying if the material uses the texture
  37801. */
  37802. hasTexture(texture: BaseTexture): boolean;
  37803. /**
  37804. * Disposes the material
  37805. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  37806. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  37807. */
  37808. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  37809. /**
  37810. * Makes a duplicate of the material, and gives it a new name
  37811. * @param name defines the new name for the duplicated material
  37812. * @returns the cloned material
  37813. */
  37814. clone(name: string): StandardMaterial;
  37815. /**
  37816. * Serializes this material in a JSON representation
  37817. * @returns the serialized material object
  37818. */
  37819. serialize(): any;
  37820. /**
  37821. * Creates a standard material from parsed material data
  37822. * @param source defines the JSON representation of the material
  37823. * @param scene defines the hosting scene
  37824. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  37825. * @returns a new standard material
  37826. */
  37827. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  37828. /**
  37829. * Are diffuse textures enabled in the application.
  37830. */
  37831. static DiffuseTextureEnabled: boolean;
  37832. /**
  37833. * Are ambient textures enabled in the application.
  37834. */
  37835. static AmbientTextureEnabled: boolean;
  37836. /**
  37837. * Are opacity textures enabled in the application.
  37838. */
  37839. static OpacityTextureEnabled: boolean;
  37840. /**
  37841. * Are reflection textures enabled in the application.
  37842. */
  37843. static ReflectionTextureEnabled: boolean;
  37844. /**
  37845. * Are emissive textures enabled in the application.
  37846. */
  37847. static EmissiveTextureEnabled: boolean;
  37848. /**
  37849. * Are specular textures enabled in the application.
  37850. */
  37851. static SpecularTextureEnabled: boolean;
  37852. /**
  37853. * Are bump textures enabled in the application.
  37854. */
  37855. static BumpTextureEnabled: boolean;
  37856. /**
  37857. * Are lightmap textures enabled in the application.
  37858. */
  37859. static LightmapTextureEnabled: boolean;
  37860. /**
  37861. * Are refraction textures enabled in the application.
  37862. */
  37863. static RefractionTextureEnabled: boolean;
  37864. /**
  37865. * Are color grading textures enabled in the application.
  37866. */
  37867. static ColorGradingTextureEnabled: boolean;
  37868. /**
  37869. * Are fresnels enabled in the application.
  37870. */
  37871. static FresnelEnabled: boolean;
  37872. }
  37873. }
  37874. declare module BABYLON {
  37875. /**
  37876. * A class extending Texture allowing drawing on a texture
  37877. * @see http://doc.babylonjs.com/how_to/dynamictexture
  37878. */
  37879. export class DynamicTexture extends Texture {
  37880. private _generateMipMaps;
  37881. private _canvas;
  37882. private _context;
  37883. private _engine;
  37884. /**
  37885. * Creates a DynamicTexture
  37886. * @param name defines the name of the texture
  37887. * @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
  37888. * @param scene defines the scene where you want the texture
  37889. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  37890. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  37891. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  37892. */
  37893. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  37894. /**
  37895. * Get the current class name of the texture useful for serialization or dynamic coding.
  37896. * @returns "DynamicTexture"
  37897. */
  37898. getClassName(): string;
  37899. /**
  37900. * Gets the current state of canRescale
  37901. */
  37902. readonly canRescale: boolean;
  37903. private _recreate;
  37904. /**
  37905. * Scales the texture
  37906. * @param ratio the scale factor to apply to both width and height
  37907. */
  37908. scale(ratio: number): void;
  37909. /**
  37910. * Resizes the texture
  37911. * @param width the new width
  37912. * @param height the new height
  37913. */
  37914. scaleTo(width: number, height: number): void;
  37915. /**
  37916. * Gets the context of the canvas used by the texture
  37917. * @returns the canvas context of the dynamic texture
  37918. */
  37919. getContext(): CanvasRenderingContext2D;
  37920. /**
  37921. * Clears the texture
  37922. */
  37923. clear(): void;
  37924. /**
  37925. * Updates the texture
  37926. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37927. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  37928. */
  37929. update(invertY?: boolean, premulAlpha?: boolean): void;
  37930. /**
  37931. * Draws text onto the texture
  37932. * @param text defines the text to be drawn
  37933. * @param x defines the placement of the text from the left
  37934. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  37935. * @param font defines the font to be used with font-style, font-size, font-name
  37936. * @param color defines the color used for the text
  37937. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  37938. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37939. * @param update defines whether texture is immediately update (default is true)
  37940. */
  37941. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  37942. /**
  37943. * Clones the texture
  37944. * @returns the clone of the texture.
  37945. */
  37946. clone(): DynamicTexture;
  37947. /**
  37948. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  37949. * @returns a serialized dynamic texture object
  37950. */
  37951. serialize(): any;
  37952. /** @hidden */
  37953. _rebuild(): void;
  37954. }
  37955. }
  37956. declare module BABYLON {
  37957. /** @hidden */
  37958. export var imageProcessingPixelShader: {
  37959. name: string;
  37960. shader: string;
  37961. };
  37962. }
  37963. declare module BABYLON {
  37964. /**
  37965. * ImageProcessingPostProcess
  37966. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  37967. */
  37968. export class ImageProcessingPostProcess extends PostProcess {
  37969. /**
  37970. * Default configuration related to image processing available in the PBR Material.
  37971. */
  37972. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  37973. /**
  37974. * Gets the image processing configuration used either in this material.
  37975. */
  37976. /**
  37977. * Sets the Default image processing configuration used either in the this material.
  37978. *
  37979. * If sets to null, the scene one is in use.
  37980. */
  37981. imageProcessingConfiguration: ImageProcessingConfiguration;
  37982. /**
  37983. * Keep track of the image processing observer to allow dispose and replace.
  37984. */
  37985. private _imageProcessingObserver;
  37986. /**
  37987. * Attaches a new image processing configuration to the PBR Material.
  37988. * @param configuration
  37989. */
  37990. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  37991. /**
  37992. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  37993. */
  37994. /**
  37995. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  37996. */
  37997. colorCurves: Nullable<ColorCurves>;
  37998. /**
  37999. * Gets wether the color curves effect is enabled.
  38000. */
  38001. /**
  38002. * Sets wether the color curves effect is enabled.
  38003. */
  38004. colorCurvesEnabled: boolean;
  38005. /**
  38006. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38007. */
  38008. /**
  38009. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38010. */
  38011. colorGradingTexture: Nullable<BaseTexture>;
  38012. /**
  38013. * Gets wether the color grading effect is enabled.
  38014. */
  38015. /**
  38016. * Gets wether the color grading effect is enabled.
  38017. */
  38018. colorGradingEnabled: boolean;
  38019. /**
  38020. * Gets exposure used in the effect.
  38021. */
  38022. /**
  38023. * Sets exposure used in the effect.
  38024. */
  38025. exposure: number;
  38026. /**
  38027. * Gets wether tonemapping is enabled or not.
  38028. */
  38029. /**
  38030. * Sets wether tonemapping is enabled or not
  38031. */
  38032. toneMappingEnabled: boolean;
  38033. /**
  38034. * Gets contrast used in the effect.
  38035. */
  38036. /**
  38037. * Sets contrast used in the effect.
  38038. */
  38039. contrast: number;
  38040. /**
  38041. * Gets Vignette stretch size.
  38042. */
  38043. /**
  38044. * Sets Vignette stretch size.
  38045. */
  38046. vignetteStretch: number;
  38047. /**
  38048. * Gets Vignette centre X Offset.
  38049. */
  38050. /**
  38051. * Sets Vignette centre X Offset.
  38052. */
  38053. vignetteCentreX: number;
  38054. /**
  38055. * Gets Vignette centre Y Offset.
  38056. */
  38057. /**
  38058. * Sets Vignette centre Y Offset.
  38059. */
  38060. vignetteCentreY: number;
  38061. /**
  38062. * Gets Vignette weight or intensity of the vignette effect.
  38063. */
  38064. /**
  38065. * Sets Vignette weight or intensity of the vignette effect.
  38066. */
  38067. vignetteWeight: number;
  38068. /**
  38069. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38070. * if vignetteEnabled is set to true.
  38071. */
  38072. /**
  38073. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38074. * if vignetteEnabled is set to true.
  38075. */
  38076. vignetteColor: Color4;
  38077. /**
  38078. * Gets Camera field of view used by the Vignette effect.
  38079. */
  38080. /**
  38081. * Sets Camera field of view used by the Vignette effect.
  38082. */
  38083. vignetteCameraFov: number;
  38084. /**
  38085. * Gets the vignette blend mode allowing different kind of effect.
  38086. */
  38087. /**
  38088. * Sets the vignette blend mode allowing different kind of effect.
  38089. */
  38090. vignetteBlendMode: number;
  38091. /**
  38092. * Gets wether the vignette effect is enabled.
  38093. */
  38094. /**
  38095. * Sets wether the vignette effect is enabled.
  38096. */
  38097. vignetteEnabled: boolean;
  38098. private _fromLinearSpace;
  38099. /**
  38100. * Gets wether the input of the processing is in Gamma or Linear Space.
  38101. */
  38102. /**
  38103. * Sets wether the input of the processing is in Gamma or Linear Space.
  38104. */
  38105. fromLinearSpace: boolean;
  38106. /**
  38107. * Defines cache preventing GC.
  38108. */
  38109. private _defines;
  38110. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38111. /**
  38112. * "ImageProcessingPostProcess"
  38113. * @returns "ImageProcessingPostProcess"
  38114. */
  38115. getClassName(): string;
  38116. protected _updateParameters(): void;
  38117. dispose(camera?: Camera): void;
  38118. }
  38119. }
  38120. declare module BABYLON {
  38121. /**
  38122. * Class containing static functions to help procedurally build meshes
  38123. */
  38124. export class GroundBuilder {
  38125. /**
  38126. * Creates a ground mesh
  38127. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38128. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38130. * @param name defines the name of the mesh
  38131. * @param options defines the options used to create the mesh
  38132. * @param scene defines the hosting scene
  38133. * @returns the ground mesh
  38134. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38135. */
  38136. static CreateGround(name: string, options: {
  38137. width?: number;
  38138. height?: number;
  38139. subdivisions?: number;
  38140. subdivisionsX?: number;
  38141. subdivisionsY?: number;
  38142. updatable?: boolean;
  38143. }, scene: any): Mesh;
  38144. /**
  38145. * Creates a tiled ground mesh
  38146. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38147. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38148. * * 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
  38149. * * 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
  38150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38151. * @param name defines the name of the mesh
  38152. * @param options defines the options used to create the mesh
  38153. * @param scene defines the hosting scene
  38154. * @returns the tiled ground mesh
  38155. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38156. */
  38157. static CreateTiledGround(name: string, options: {
  38158. xmin: number;
  38159. zmin: number;
  38160. xmax: number;
  38161. zmax: number;
  38162. subdivisions?: {
  38163. w: number;
  38164. h: number;
  38165. };
  38166. precision?: {
  38167. w: number;
  38168. h: number;
  38169. };
  38170. updatable?: boolean;
  38171. }, scene: Scene): Mesh;
  38172. /**
  38173. * Creates a ground mesh from a height map
  38174. * * The parameter `url` sets the URL of the height map image resource.
  38175. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38176. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38177. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38178. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38179. * * 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.
  38180. * * 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).
  38181. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38183. * @param name defines the name of the mesh
  38184. * @param url defines the url to the height map
  38185. * @param options defines the options used to create the mesh
  38186. * @param scene defines the hosting scene
  38187. * @returns the ground mesh
  38188. * @see https://doc.babylonjs.com/babylon101/height_map
  38189. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38190. */
  38191. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38192. width?: number;
  38193. height?: number;
  38194. subdivisions?: number;
  38195. minHeight?: number;
  38196. maxHeight?: number;
  38197. colorFilter?: Color3;
  38198. alphaFilter?: number;
  38199. updatable?: boolean;
  38200. onReady?: (mesh: GroundMesh) => void;
  38201. }, scene: Scene): GroundMesh;
  38202. }
  38203. }
  38204. declare module BABYLON {
  38205. /**
  38206. * Class containing static functions to help procedurally build meshes
  38207. */
  38208. export class TorusBuilder {
  38209. /**
  38210. * Creates a torus mesh
  38211. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38212. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38213. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38215. * * 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
  38216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38217. * @param name defines the name of the mesh
  38218. * @param options defines the options used to create the mesh
  38219. * @param scene defines the hosting scene
  38220. * @returns the torus mesh
  38221. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38222. */
  38223. static CreateTorus(name: string, options: {
  38224. diameter?: number;
  38225. thickness?: number;
  38226. tessellation?: number;
  38227. updatable?: boolean;
  38228. sideOrientation?: number;
  38229. frontUVs?: Vector4;
  38230. backUVs?: Vector4;
  38231. }, scene: any): Mesh;
  38232. }
  38233. }
  38234. declare module BABYLON {
  38235. /**
  38236. * Class containing static functions to help procedurally build meshes
  38237. */
  38238. export class CylinderBuilder {
  38239. /**
  38240. * Creates a cylinder or a cone mesh
  38241. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  38242. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  38243. * * 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.
  38244. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  38245. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  38246. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  38247. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  38248. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  38249. * * 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).
  38250. * * 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
  38251. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  38252. * * 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
  38253. * * 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.
  38254. * * If `enclose` is false, a ring surface is one element.
  38255. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  38256. * * 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
  38257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38258. * * 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
  38259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38260. * @param name defines the name of the mesh
  38261. * @param options defines the options used to create the mesh
  38262. * @param scene defines the hosting scene
  38263. * @returns the cylinder mesh
  38264. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  38265. */
  38266. static CreateCylinder(name: string, options: {
  38267. height?: number;
  38268. diameterTop?: number;
  38269. diameterBottom?: number;
  38270. diameter?: number;
  38271. tessellation?: number;
  38272. subdivisions?: number;
  38273. arc?: number;
  38274. faceColors?: Color4[];
  38275. faceUV?: Vector4[];
  38276. updatable?: boolean;
  38277. hasRings?: boolean;
  38278. enclose?: boolean;
  38279. sideOrientation?: number;
  38280. frontUVs?: Vector4;
  38281. backUVs?: Vector4;
  38282. }, scene: any): Mesh;
  38283. }
  38284. }
  38285. declare module BABYLON {
  38286. /**
  38287. * Manager for handling gamepads
  38288. */
  38289. export class GamepadManager {
  38290. private _scene?;
  38291. private _babylonGamepads;
  38292. private _oneGamepadConnected;
  38293. /** @hidden */
  38294. _isMonitoring: boolean;
  38295. private _gamepadEventSupported;
  38296. private _gamepadSupport;
  38297. /**
  38298. * observable to be triggered when the gamepad controller has been connected
  38299. */
  38300. onGamepadConnectedObservable: Observable<Gamepad>;
  38301. /**
  38302. * observable to be triggered when the gamepad controller has been disconnected
  38303. */
  38304. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38305. private _onGamepadConnectedEvent;
  38306. private _onGamepadDisconnectedEvent;
  38307. /**
  38308. * Initializes the gamepad manager
  38309. * @param _scene BabylonJS scene
  38310. */
  38311. constructor(_scene?: Scene | undefined);
  38312. /**
  38313. * The gamepads in the game pad manager
  38314. */
  38315. readonly gamepads: Gamepad[];
  38316. /**
  38317. * Get the gamepad controllers based on type
  38318. * @param type The type of gamepad controller
  38319. * @returns Nullable gamepad
  38320. */
  38321. getGamepadByType(type?: number): Nullable<Gamepad>;
  38322. /**
  38323. * Disposes the gamepad manager
  38324. */
  38325. dispose(): void;
  38326. private _addNewGamepad;
  38327. private _startMonitoringGamepads;
  38328. private _stopMonitoringGamepads;
  38329. /** @hidden */
  38330. _checkGamepadsStatus(): void;
  38331. private _updateGamepadObjects;
  38332. }
  38333. }
  38334. declare module BABYLON {
  38335. interface Scene {
  38336. /** @hidden */
  38337. _gamepadManager: Nullable<GamepadManager>;
  38338. /**
  38339. * Gets the gamepad manager associated with the scene
  38340. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38341. */
  38342. gamepadManager: GamepadManager;
  38343. }
  38344. /**
  38345. * Interface representing a free camera inputs manager
  38346. */
  38347. interface FreeCameraInputsManager {
  38348. /**
  38349. * Adds gamepad input support to the FreeCameraInputsManager.
  38350. * @returns the FreeCameraInputsManager
  38351. */
  38352. addGamepad(): FreeCameraInputsManager;
  38353. }
  38354. /**
  38355. * Interface representing an arc rotate camera inputs manager
  38356. */
  38357. interface ArcRotateCameraInputsManager {
  38358. /**
  38359. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38360. * @returns the camera inputs manager
  38361. */
  38362. addGamepad(): ArcRotateCameraInputsManager;
  38363. }
  38364. /**
  38365. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38366. */
  38367. export class GamepadSystemSceneComponent implements ISceneComponent {
  38368. /**
  38369. * The component name helpfull to identify the component in the list of scene components.
  38370. */
  38371. readonly name: string;
  38372. /**
  38373. * The scene the component belongs to.
  38374. */
  38375. scene: Scene;
  38376. /**
  38377. * Creates a new instance of the component for the given scene
  38378. * @param scene Defines the scene to register the component in
  38379. */
  38380. constructor(scene: Scene);
  38381. /**
  38382. * Registers the component in a given scene
  38383. */
  38384. register(): void;
  38385. /**
  38386. * Rebuilds the elements related to this component in case of
  38387. * context lost for instance.
  38388. */
  38389. rebuild(): void;
  38390. /**
  38391. * Disposes the component and the associated ressources
  38392. */
  38393. dispose(): void;
  38394. private _beforeCameraUpdate;
  38395. }
  38396. }
  38397. declare module BABYLON {
  38398. /**
  38399. * Options to modify the vr teleportation behavior.
  38400. */
  38401. export interface VRTeleportationOptions {
  38402. /**
  38403. * The name of the mesh which should be used as the teleportation floor. (default: null)
  38404. */
  38405. floorMeshName?: string;
  38406. /**
  38407. * A list of meshes to be used as the teleportation floor. (default: empty)
  38408. */
  38409. floorMeshes?: Mesh[];
  38410. }
  38411. /**
  38412. * Options to modify the vr experience helper's behavior.
  38413. */
  38414. export interface VRExperienceHelperOptions extends WebVROptions {
  38415. /**
  38416. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  38417. */
  38418. createDeviceOrientationCamera?: boolean;
  38419. /**
  38420. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  38421. */
  38422. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  38423. /**
  38424. * Uses the main button on the controller to toggle the laser casted. (default: true)
  38425. */
  38426. laserToggle?: boolean;
  38427. /**
  38428. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  38429. */
  38430. floorMeshes?: Mesh[];
  38431. /**
  38432. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  38433. */
  38434. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  38435. }
  38436. /**
  38437. * Helps to quickly add VR support to an existing scene.
  38438. * See http://doc.babylonjs.com/how_to/webvr_helper
  38439. */
  38440. export class VRExperienceHelper {
  38441. /** Options to modify the vr experience helper's behavior. */
  38442. webVROptions: VRExperienceHelperOptions;
  38443. private _scene;
  38444. private _position;
  38445. private _btnVR;
  38446. private _btnVRDisplayed;
  38447. private _webVRsupported;
  38448. private _webVRready;
  38449. private _webVRrequesting;
  38450. private _webVRpresenting;
  38451. private _hasEnteredVR;
  38452. private _fullscreenVRpresenting;
  38453. private _canvas;
  38454. private _webVRCamera;
  38455. private _vrDeviceOrientationCamera;
  38456. private _deviceOrientationCamera;
  38457. private _existingCamera;
  38458. private _onKeyDown;
  38459. private _onVrDisplayPresentChange;
  38460. private _onVRDisplayChanged;
  38461. private _onVRRequestPresentStart;
  38462. private _onVRRequestPresentComplete;
  38463. /**
  38464. * Observable raised when entering VR.
  38465. */
  38466. onEnteringVRObservable: Observable<VRExperienceHelper>;
  38467. /**
  38468. * Observable raised when exiting VR.
  38469. */
  38470. onExitingVRObservable: Observable<VRExperienceHelper>;
  38471. /**
  38472. * Observable raised when controller mesh is loaded.
  38473. */
  38474. onControllerMeshLoadedObservable: Observable<WebVRController>;
  38475. /** Return this.onEnteringVRObservable
  38476. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  38477. */
  38478. readonly onEnteringVR: Observable<VRExperienceHelper>;
  38479. /** Return this.onExitingVRObservable
  38480. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  38481. */
  38482. readonly onExitingVR: Observable<VRExperienceHelper>;
  38483. /** Return this.onControllerMeshLoadedObservable
  38484. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  38485. */
  38486. readonly onControllerMeshLoaded: Observable<WebVRController>;
  38487. private _rayLength;
  38488. private _useCustomVRButton;
  38489. private _teleportationRequested;
  38490. private _teleportActive;
  38491. private _floorMeshName;
  38492. private _floorMeshesCollection;
  38493. private _rotationAllowed;
  38494. private _teleportBackwardsVector;
  38495. private _teleportationTarget;
  38496. private _isDefaultTeleportationTarget;
  38497. private _postProcessMove;
  38498. private _teleportationFillColor;
  38499. private _teleportationBorderColor;
  38500. private _rotationAngle;
  38501. private _haloCenter;
  38502. private _cameraGazer;
  38503. private _padSensibilityUp;
  38504. private _padSensibilityDown;
  38505. private _leftController;
  38506. private _rightController;
  38507. /**
  38508. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  38509. */
  38510. onNewMeshSelected: Observable<AbstractMesh>;
  38511. /**
  38512. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  38513. */
  38514. onNewMeshPicked: Observable<PickingInfo>;
  38515. private _circleEase;
  38516. /**
  38517. * Observable raised before camera teleportation
  38518. */
  38519. onBeforeCameraTeleport: Observable<Vector3>;
  38520. /**
  38521. * Observable raised after camera teleportation
  38522. */
  38523. onAfterCameraTeleport: Observable<Vector3>;
  38524. /**
  38525. * Observable raised when current selected mesh gets unselected
  38526. */
  38527. onSelectedMeshUnselected: Observable<AbstractMesh>;
  38528. private _raySelectionPredicate;
  38529. /**
  38530. * To be optionaly changed by user to define custom ray selection
  38531. */
  38532. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  38533. /**
  38534. * To be optionaly changed by user to define custom selection logic (after ray selection)
  38535. */
  38536. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  38537. /**
  38538. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  38539. */
  38540. teleportationEnabled: boolean;
  38541. private _defaultHeight;
  38542. private _teleportationInitialized;
  38543. private _interactionsEnabled;
  38544. private _interactionsRequested;
  38545. private _displayGaze;
  38546. private _displayLaserPointer;
  38547. /**
  38548. * The mesh used to display where the user is going to teleport.
  38549. */
  38550. /**
  38551. * Sets the mesh to be used to display where the user is going to teleport.
  38552. */
  38553. teleportationTarget: Mesh;
  38554. /**
  38555. * 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
  38556. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  38557. * See http://doc.babylonjs.com/resources/baking_transformations
  38558. */
  38559. gazeTrackerMesh: Mesh;
  38560. /**
  38561. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  38562. */
  38563. updateGazeTrackerScale: boolean;
  38564. /**
  38565. * If the gaze trackers color should be updated when selecting meshes
  38566. */
  38567. updateGazeTrackerColor: boolean;
  38568. /**
  38569. * The gaze tracking mesh corresponding to the left controller
  38570. */
  38571. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  38572. /**
  38573. * The gaze tracking mesh corresponding to the right controller
  38574. */
  38575. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  38576. /**
  38577. * If the ray of the gaze should be displayed.
  38578. */
  38579. /**
  38580. * Sets if the ray of the gaze should be displayed.
  38581. */
  38582. displayGaze: boolean;
  38583. /**
  38584. * If the ray of the LaserPointer should be displayed.
  38585. */
  38586. /**
  38587. * Sets if the ray of the LaserPointer should be displayed.
  38588. */
  38589. displayLaserPointer: boolean;
  38590. /**
  38591. * The deviceOrientationCamera used as the camera when not in VR.
  38592. */
  38593. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  38594. /**
  38595. * Based on the current WebVR support, returns the current VR camera used.
  38596. */
  38597. readonly currentVRCamera: Nullable<Camera>;
  38598. /**
  38599. * The webVRCamera which is used when in VR.
  38600. */
  38601. readonly webVRCamera: WebVRFreeCamera;
  38602. /**
  38603. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  38604. */
  38605. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  38606. private readonly _teleportationRequestInitiated;
  38607. /**
  38608. * Defines wether or not Pointer lock should be requested when switching to
  38609. * full screen.
  38610. */
  38611. requestPointerLockOnFullScreen: boolean;
  38612. /**
  38613. * Instantiates a VRExperienceHelper.
  38614. * Helps to quickly add VR support to an existing scene.
  38615. * @param scene The scene the VRExperienceHelper belongs to.
  38616. * @param webVROptions Options to modify the vr experience helper's behavior.
  38617. */
  38618. constructor(scene: Scene,
  38619. /** Options to modify the vr experience helper's behavior. */
  38620. webVROptions?: VRExperienceHelperOptions);
  38621. private _onDefaultMeshLoaded;
  38622. private _onResize;
  38623. private _onFullscreenChange;
  38624. /**
  38625. * Gets a value indicating if we are currently in VR mode.
  38626. */
  38627. readonly isInVRMode: boolean;
  38628. private onVrDisplayPresentChange;
  38629. private onVRDisplayChanged;
  38630. private moveButtonToBottomRight;
  38631. private displayVRButton;
  38632. private updateButtonVisibility;
  38633. private _cachedAngularSensibility;
  38634. /**
  38635. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  38636. * Otherwise, will use the fullscreen API.
  38637. */
  38638. enterVR(): void;
  38639. /**
  38640. * Attempt to exit VR, or fullscreen.
  38641. */
  38642. exitVR(): void;
  38643. /**
  38644. * The position of the vr experience helper.
  38645. */
  38646. /**
  38647. * Sets the position of the vr experience helper.
  38648. */
  38649. position: Vector3;
  38650. /**
  38651. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  38652. */
  38653. enableInteractions(): void;
  38654. private readonly _noControllerIsActive;
  38655. private beforeRender;
  38656. private _isTeleportationFloor;
  38657. /**
  38658. * Adds a floor mesh to be used for teleportation.
  38659. * @param floorMesh the mesh to be used for teleportation.
  38660. */
  38661. addFloorMesh(floorMesh: Mesh): void;
  38662. /**
  38663. * Removes a floor mesh from being used for teleportation.
  38664. * @param floorMesh the mesh to be removed.
  38665. */
  38666. removeFloorMesh(floorMesh: Mesh): void;
  38667. /**
  38668. * Enables interactions and teleportation using the VR controllers and gaze.
  38669. * @param vrTeleportationOptions options to modify teleportation behavior.
  38670. */
  38671. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  38672. private _onNewGamepadConnected;
  38673. private _tryEnableInteractionOnController;
  38674. private _onNewGamepadDisconnected;
  38675. private _enableInteractionOnController;
  38676. private _checkTeleportWithRay;
  38677. private _checkRotate;
  38678. private _checkTeleportBackwards;
  38679. private _enableTeleportationOnController;
  38680. private _createTeleportationCircles;
  38681. private _displayTeleportationTarget;
  38682. private _hideTeleportationTarget;
  38683. private _rotateCamera;
  38684. private _moveTeleportationSelectorTo;
  38685. private _workingVector;
  38686. private _workingQuaternion;
  38687. private _workingMatrix;
  38688. /**
  38689. * Teleports the users feet to the desired location
  38690. * @param location The location where the user's feet should be placed
  38691. */
  38692. teleportCamera(location: Vector3): void;
  38693. private _convertNormalToDirectionOfRay;
  38694. private _castRayAndSelectObject;
  38695. private _notifySelectedMeshUnselected;
  38696. /**
  38697. * Sets the color of the laser ray from the vr controllers.
  38698. * @param color new color for the ray.
  38699. */
  38700. changeLaserColor(color: Color3): void;
  38701. /**
  38702. * Sets the color of the ray from the vr headsets gaze.
  38703. * @param color new color for the ray.
  38704. */
  38705. changeGazeColor(color: Color3): void;
  38706. /**
  38707. * Exits VR and disposes of the vr experience helper
  38708. */
  38709. dispose(): void;
  38710. /**
  38711. * Gets the name of the VRExperienceHelper class
  38712. * @returns "VRExperienceHelper"
  38713. */
  38714. getClassName(): string;
  38715. }
  38716. }
  38717. declare module BABYLON {
  38718. /**
  38719. * Manages an XRSession
  38720. * @see https://doc.babylonjs.com/how_to/webxr
  38721. */
  38722. export class WebXRSessionManager implements IDisposable {
  38723. private scene;
  38724. /**
  38725. * Fires every time a new xrFrame arrives which can be used to update the camera
  38726. */
  38727. onXRFrameObservable: Observable<any>;
  38728. /**
  38729. * Fires when the xr session is ended either by the device or manually done
  38730. */
  38731. onXRSessionEnded: Observable<any>;
  38732. /** @hidden */
  38733. _xrSession: XRSession;
  38734. /** @hidden */
  38735. _frameOfReference: XRFrameOfReference;
  38736. /** @hidden */
  38737. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  38738. /** @hidden */
  38739. _currentXRFrame: Nullable<XRFrame>;
  38740. private _xrNavigator;
  38741. private _xrDevice;
  38742. private _tmpMatrix;
  38743. /**
  38744. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  38745. * @param scene The scene which the session should be created for
  38746. */
  38747. constructor(scene: Scene);
  38748. /**
  38749. * Initializes the manager
  38750. * After initialization enterXR can be called to start an XR session
  38751. * @returns Promise which resolves after it is initialized
  38752. */
  38753. initializeAsync(): Promise<void>;
  38754. /**
  38755. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  38756. * @param sessionCreationOptions xr options to create the session with
  38757. * @param frameOfReferenceType option to configure how the xr pose is expressed
  38758. * @returns Promise which resolves after it enters XR
  38759. */
  38760. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  38761. /**
  38762. * Stops the xrSession and restores the renderloop
  38763. * @returns Promise which resolves after it exits XR
  38764. */
  38765. exitXRAsync(): Promise<void>;
  38766. /**
  38767. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  38768. * @param ray ray to cast into the environment
  38769. * @returns Promise which resolves with a collision point in the environment if it exists
  38770. */
  38771. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  38772. /**
  38773. * Checks if a session would be supported for the creation options specified
  38774. * @param options creation options to check if they are supported
  38775. * @returns true if supported
  38776. */
  38777. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  38778. /**
  38779. * @hidden
  38780. * Converts the render layer of xrSession to a render target
  38781. * @param session session to create render target for
  38782. * @param scene scene the new render target should be created for
  38783. */
  38784. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  38785. /**
  38786. * Disposes of the session manager
  38787. */
  38788. dispose(): void;
  38789. }
  38790. }
  38791. declare module BABYLON {
  38792. /**
  38793. * WebXR Camera which holds the views for the xrSession
  38794. * @see https://doc.babylonjs.com/how_to/webxr
  38795. */
  38796. export class WebXRCamera extends FreeCamera {
  38797. private static _TmpMatrix;
  38798. /**
  38799. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  38800. * @param name the name of the camera
  38801. * @param scene the scene to add the camera to
  38802. */
  38803. constructor(name: string, scene: Scene);
  38804. private _updateNumberOfRigCameras;
  38805. /** @hidden */
  38806. _updateForDualEyeDebugging(pupilDistance?: number): void;
  38807. /**
  38808. * Updates the cameras position from the current pose information of the XR session
  38809. * @param xrSessionManager the session containing pose information
  38810. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  38811. */
  38812. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  38813. }
  38814. }
  38815. declare module BABYLON {
  38816. /**
  38817. * States of the webXR experience
  38818. */
  38819. export enum WebXRState {
  38820. /**
  38821. * Transitioning to being in XR mode
  38822. */
  38823. ENTERING_XR = 0,
  38824. /**
  38825. * Transitioning to non XR mode
  38826. */
  38827. EXITING_XR = 1,
  38828. /**
  38829. * In XR mode and presenting
  38830. */
  38831. IN_XR = 2,
  38832. /**
  38833. * Not entered XR mode
  38834. */
  38835. NOT_IN_XR = 3
  38836. }
  38837. /**
  38838. * Helper class used to enable XR
  38839. * @see https://doc.babylonjs.com/how_to/webxr
  38840. */
  38841. export class WebXRExperienceHelper implements IDisposable {
  38842. private scene;
  38843. /**
  38844. * 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
  38845. */
  38846. container: AbstractMesh;
  38847. /**
  38848. * Camera used to render xr content
  38849. */
  38850. camera: WebXRCamera;
  38851. /**
  38852. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  38853. */
  38854. state: WebXRState;
  38855. private _setState;
  38856. private static _TmpVector;
  38857. /**
  38858. * Fires when the state of the experience helper has changed
  38859. */
  38860. onStateChangedObservable: Observable<WebXRState>;
  38861. /** @hidden */
  38862. _sessionManager: WebXRSessionManager;
  38863. private _nonVRCamera;
  38864. private _originalSceneAutoClear;
  38865. private _supported;
  38866. /**
  38867. * Creates the experience helper
  38868. * @param scene the scene to attach the experience helper to
  38869. * @returns a promise for the experience helper
  38870. */
  38871. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  38872. /**
  38873. * Creates a WebXRExperienceHelper
  38874. * @param scene The scene the helper should be created in
  38875. */
  38876. private constructor();
  38877. /**
  38878. * Exits XR mode and returns the scene to its original state
  38879. * @returns promise that resolves after xr mode has exited
  38880. */
  38881. exitXRAsync(): Promise<void>;
  38882. /**
  38883. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  38884. * @param sessionCreationOptions options for the XR session
  38885. * @param frameOfReference frame of reference of the XR session
  38886. * @returns promise that resolves after xr mode has entered
  38887. */
  38888. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  38889. /**
  38890. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  38891. * @param ray ray to cast into the environment
  38892. * @returns Promise which resolves with a collision point in the environment if it exists
  38893. */
  38894. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  38895. /**
  38896. * Updates the global position of the camera by moving the camera's container
  38897. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  38898. * @param position The desired global position of the camera
  38899. */
  38900. setPositionOfCameraUsingContainer(position: Vector3): void;
  38901. /**
  38902. * Rotates the xr camera by rotating the camera's container around the camera's position
  38903. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  38904. * @param rotation the desired quaternion rotation to apply to the camera
  38905. */
  38906. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  38907. /**
  38908. * Checks if the creation options are supported by the xr session
  38909. * @param options creation options
  38910. * @returns true if supported
  38911. */
  38912. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  38913. /**
  38914. * Disposes of the experience helper
  38915. */
  38916. dispose(): void;
  38917. }
  38918. }
  38919. declare module BABYLON {
  38920. /**
  38921. * Button which can be used to enter a different mode of XR
  38922. */
  38923. export class WebXREnterExitUIButton {
  38924. /** button element */
  38925. element: HTMLElement;
  38926. /** XR initialization options for the button */
  38927. initializationOptions: XRSessionCreationOptions;
  38928. /**
  38929. * Creates a WebXREnterExitUIButton
  38930. * @param element button element
  38931. * @param initializationOptions XR initialization options for the button
  38932. */
  38933. constructor(
  38934. /** button element */
  38935. element: HTMLElement,
  38936. /** XR initialization options for the button */
  38937. initializationOptions: XRSessionCreationOptions);
  38938. /**
  38939. * Overwritable function which can be used to update the button's visuals when the state changes
  38940. * @param activeButton the current active button in the UI
  38941. */
  38942. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  38943. }
  38944. /**
  38945. * Options to create the webXR UI
  38946. */
  38947. export class WebXREnterExitUIOptions {
  38948. /**
  38949. * Context to enter xr with
  38950. */
  38951. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  38952. /**
  38953. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  38954. */
  38955. customButtons?: Array<WebXREnterExitUIButton>;
  38956. }
  38957. /**
  38958. * UI to allow the user to enter/exit XR mode
  38959. */
  38960. export class WebXREnterExitUI implements IDisposable {
  38961. private scene;
  38962. private _overlay;
  38963. private _buttons;
  38964. private _activeButton;
  38965. /**
  38966. * Fired every time the active button is changed.
  38967. *
  38968. * When xr is entered via a button that launches xr that button will be the callback parameter
  38969. *
  38970. * When exiting xr the callback parameter will be null)
  38971. */
  38972. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  38973. /**
  38974. * Creates UI to allow the user to enter/exit XR mode
  38975. * @param scene the scene to add the ui to
  38976. * @param helper the xr experience helper to enter/exit xr with
  38977. * @param options options to configure the UI
  38978. * @returns the created ui
  38979. */
  38980. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  38981. private constructor();
  38982. private _updateButtons;
  38983. /**
  38984. * Disposes of the object
  38985. */
  38986. dispose(): void;
  38987. }
  38988. }
  38989. declare module BABYLON {
  38990. /**
  38991. * Represents an XR input
  38992. */
  38993. export class WebXRController {
  38994. /**
  38995. * 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
  38996. */
  38997. grip?: AbstractMesh;
  38998. /**
  38999. * Pointer which can be used to select objects or attach a visible laser to
  39000. */
  39001. pointer: AbstractMesh;
  39002. /**
  39003. * Creates the controller
  39004. * @see https://doc.babylonjs.com/how_to/webxr
  39005. * @param scene the scene which the controller should be associated to
  39006. */
  39007. constructor(scene: Scene);
  39008. /**
  39009. * Disposes of the object
  39010. */
  39011. dispose(): void;
  39012. }
  39013. /**
  39014. * XR input used to track XR inputs such as controllers/rays
  39015. */
  39016. export class WebXRInput implements IDisposable {
  39017. private helper;
  39018. /**
  39019. * XR controllers being tracked
  39020. */
  39021. controllers: Array<WebXRController>;
  39022. private _tmpMatrix;
  39023. private _frameObserver;
  39024. /**
  39025. * Initializes the WebXRInput
  39026. * @param helper experience helper which the input should be created for
  39027. */
  39028. constructor(helper: WebXRExperienceHelper);
  39029. /**
  39030. * Disposes of the object
  39031. */
  39032. dispose(): void;
  39033. }
  39034. }
  39035. declare module BABYLON {
  39036. /**
  39037. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39038. */
  39039. export class WebXRManagedOutputCanvas implements IDisposable {
  39040. private _canvas;
  39041. /**
  39042. * xrpresent context of the canvas which can be used to display/mirror xr content
  39043. */
  39044. canvasContext: Nullable<WebGLRenderingContext>;
  39045. /**
  39046. * Initializes the canvas to be added/removed upon entering/exiting xr
  39047. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39048. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39049. */
  39050. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39051. /**
  39052. * Disposes of the object
  39053. */
  39054. dispose(): void;
  39055. private _setManagedOutputCanvas;
  39056. private _addCanvas;
  39057. private _removeCanvas;
  39058. }
  39059. }
  39060. declare module BABYLON {
  39061. /**
  39062. * Contains an array of blocks representing the octree
  39063. */
  39064. export interface IOctreeContainer<T> {
  39065. /**
  39066. * Blocks within the octree
  39067. */
  39068. blocks: Array<OctreeBlock<T>>;
  39069. }
  39070. /**
  39071. * Class used to store a cell in an octree
  39072. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39073. */
  39074. export class OctreeBlock<T> {
  39075. /**
  39076. * Gets the content of the current block
  39077. */
  39078. entries: T[];
  39079. /**
  39080. * Gets the list of block children
  39081. */
  39082. blocks: Array<OctreeBlock<T>>;
  39083. private _depth;
  39084. private _maxDepth;
  39085. private _capacity;
  39086. private _minPoint;
  39087. private _maxPoint;
  39088. private _boundingVectors;
  39089. private _creationFunc;
  39090. /**
  39091. * Creates a new block
  39092. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39093. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39094. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39095. * @param depth defines the current depth of this block in the octree
  39096. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39097. * @param creationFunc defines a callback to call when an element is added to the block
  39098. */
  39099. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39100. /**
  39101. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39102. */
  39103. readonly capacity: number;
  39104. /**
  39105. * Gets the minimum vector (in world space) of the block's bounding box
  39106. */
  39107. readonly minPoint: Vector3;
  39108. /**
  39109. * Gets the maximum vector (in world space) of the block's bounding box
  39110. */
  39111. readonly maxPoint: Vector3;
  39112. /**
  39113. * Add a new element to this block
  39114. * @param entry defines the element to add
  39115. */
  39116. addEntry(entry: T): void;
  39117. /**
  39118. * Remove an element from this block
  39119. * @param entry defines the element to remove
  39120. */
  39121. removeEntry(entry: T): void;
  39122. /**
  39123. * Add an array of elements to this block
  39124. * @param entries defines the array of elements to add
  39125. */
  39126. addEntries(entries: T[]): void;
  39127. /**
  39128. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39129. * @param frustumPlanes defines the frustum planes to test
  39130. * @param selection defines the array to store current content if selection is positive
  39131. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39132. */
  39133. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39134. /**
  39135. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39136. * @param sphereCenter defines the bounding sphere center
  39137. * @param sphereRadius defines the bounding sphere radius
  39138. * @param selection defines the array to store current content if selection is positive
  39139. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39140. */
  39141. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39142. /**
  39143. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39144. * @param ray defines the ray to test with
  39145. * @param selection defines the array to store current content if selection is positive
  39146. */
  39147. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39148. /**
  39149. * Subdivide the content into child blocks (this block will then be empty)
  39150. */
  39151. createInnerBlocks(): void;
  39152. /**
  39153. * @hidden
  39154. */
  39155. 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;
  39156. }
  39157. }
  39158. declare module BABYLON {
  39159. /**
  39160. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39161. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39162. */
  39163. export class Octree<T> {
  39164. /** 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.) */
  39165. maxDepth: number;
  39166. /**
  39167. * Blocks within the octree containing objects
  39168. */
  39169. blocks: Array<OctreeBlock<T>>;
  39170. /**
  39171. * Content stored in the octree
  39172. */
  39173. dynamicContent: T[];
  39174. private _maxBlockCapacity;
  39175. private _selectionContent;
  39176. private _creationFunc;
  39177. /**
  39178. * Creates a octree
  39179. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39180. * @param creationFunc function to be used to instatiate the octree
  39181. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39182. * @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.)
  39183. */
  39184. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39185. /** 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.) */
  39186. maxDepth?: number);
  39187. /**
  39188. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39189. * @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);
  39190. * @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);
  39191. * @param entries meshes to be added to the octree blocks
  39192. */
  39193. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39194. /**
  39195. * Adds a mesh to the octree
  39196. * @param entry Mesh to add to the octree
  39197. */
  39198. addMesh(entry: T): void;
  39199. /**
  39200. * Remove an element from the octree
  39201. * @param entry defines the element to remove
  39202. */
  39203. removeMesh(entry: T): void;
  39204. /**
  39205. * Selects an array of meshes within the frustum
  39206. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39207. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39208. * @returns array of meshes within the frustum
  39209. */
  39210. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39211. /**
  39212. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39213. * @param sphereCenter defines the bounding sphere center
  39214. * @param sphereRadius defines the bounding sphere radius
  39215. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39216. * @returns an array of objects that intersect the sphere
  39217. */
  39218. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39219. /**
  39220. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39221. * @param ray defines the ray to test with
  39222. * @returns array of intersected objects
  39223. */
  39224. intersectsRay(ray: Ray): SmartArray<T>;
  39225. /**
  39226. * Adds a mesh into the octree block if it intersects the block
  39227. */
  39228. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39229. /**
  39230. * Adds a submesh into the octree block if it intersects the block
  39231. */
  39232. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39233. }
  39234. }
  39235. declare module BABYLON {
  39236. interface Scene {
  39237. /**
  39238. * @hidden
  39239. * Backing Filed
  39240. */
  39241. _selectionOctree: Octree<AbstractMesh>;
  39242. /**
  39243. * Gets the octree used to boost mesh selection (picking)
  39244. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39245. */
  39246. selectionOctree: Octree<AbstractMesh>;
  39247. /**
  39248. * Creates or updates the octree used to boost selection (picking)
  39249. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39250. * @param maxCapacity defines the maximum capacity per leaf
  39251. * @param maxDepth defines the maximum depth of the octree
  39252. * @returns an octree of AbstractMesh
  39253. */
  39254. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39255. }
  39256. interface AbstractMesh {
  39257. /**
  39258. * @hidden
  39259. * Backing Field
  39260. */
  39261. _submeshesOctree: Octree<SubMesh>;
  39262. /**
  39263. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39264. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39265. * @param maxCapacity defines the maximum size of each block (64 by default)
  39266. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39267. * @returns the new octree
  39268. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39269. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39270. */
  39271. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39272. }
  39273. /**
  39274. * Defines the octree scene component responsible to manage any octrees
  39275. * in a given scene.
  39276. */
  39277. export class OctreeSceneComponent {
  39278. /**
  39279. * The component name helpfull to identify the component in the list of scene components.
  39280. */
  39281. readonly name: string;
  39282. /**
  39283. * The scene the component belongs to.
  39284. */
  39285. scene: Scene;
  39286. /**
  39287. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39288. */
  39289. readonly checksIsEnabled: boolean;
  39290. /**
  39291. * Creates a new instance of the component for the given scene
  39292. * @param scene Defines the scene to register the component in
  39293. */
  39294. constructor(scene: Scene);
  39295. /**
  39296. * Registers the component in a given scene
  39297. */
  39298. register(): void;
  39299. /**
  39300. * Return the list of active meshes
  39301. * @returns the list of active meshes
  39302. */
  39303. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39304. /**
  39305. * Return the list of active sub meshes
  39306. * @param mesh The mesh to get the candidates sub meshes from
  39307. * @returns the list of active sub meshes
  39308. */
  39309. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39310. private _tempRay;
  39311. /**
  39312. * Return the list of sub meshes intersecting with a given local ray
  39313. * @param mesh defines the mesh to find the submesh for
  39314. * @param localRay defines the ray in local space
  39315. * @returns the list of intersecting sub meshes
  39316. */
  39317. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  39318. /**
  39319. * Return the list of sub meshes colliding with a collider
  39320. * @param mesh defines the mesh to find the submesh for
  39321. * @param collider defines the collider to evaluate the collision against
  39322. * @returns the list of colliding sub meshes
  39323. */
  39324. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  39325. /**
  39326. * Rebuilds the elements related to this component in case of
  39327. * context lost for instance.
  39328. */
  39329. rebuild(): void;
  39330. /**
  39331. * Disposes the component and the associated ressources.
  39332. */
  39333. dispose(): void;
  39334. }
  39335. }
  39336. declare module BABYLON {
  39337. /**
  39338. * Class containing static functions to help procedurally build meshes
  39339. */
  39340. export class LinesBuilder {
  39341. /**
  39342. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  39343. * * 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
  39344. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  39345. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  39346. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  39347. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  39348. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  39349. * * 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
  39350. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  39351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39352. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  39353. * @param name defines the name of the new line system
  39354. * @param options defines the options used to create the line system
  39355. * @param scene defines the hosting scene
  39356. * @returns a new line system mesh
  39357. */
  39358. static CreateLineSystem(name: string, options: {
  39359. lines: Vector3[][];
  39360. updatable?: boolean;
  39361. instance?: Nullable<LinesMesh>;
  39362. colors?: Nullable<Color4[][]>;
  39363. useVertexAlpha?: boolean;
  39364. }, scene: Nullable<Scene>): LinesMesh;
  39365. /**
  39366. * Creates a line mesh
  39367. * 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
  39368. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  39369. * * The parameter `points` is an array successive Vector3
  39370. * * 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
  39371. * * The optional parameter `colors` is an array of successive Color4, one per line point
  39372. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  39373. * * When updating an instance, remember that only point positions can change, not the number of points
  39374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39375. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  39376. * @param name defines the name of the new line system
  39377. * @param options defines the options used to create the line system
  39378. * @param scene defines the hosting scene
  39379. * @returns a new line mesh
  39380. */
  39381. static CreateLines(name: string, options: {
  39382. points: Vector3[];
  39383. updatable?: boolean;
  39384. instance?: Nullable<LinesMesh>;
  39385. colors?: Color4[];
  39386. useVertexAlpha?: boolean;
  39387. }, scene?: Nullable<Scene>): LinesMesh;
  39388. /**
  39389. * Creates a dashed line mesh
  39390. * * 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
  39391. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  39392. * * The parameter `points` is an array successive Vector3
  39393. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  39394. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  39395. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  39396. * * 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
  39397. * * When updating an instance, remember that only point positions can change, not the number of points
  39398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39399. * @param name defines the name of the mesh
  39400. * @param options defines the options used to create the mesh
  39401. * @param scene defines the hosting scene
  39402. * @returns the dashed line mesh
  39403. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  39404. */
  39405. static CreateDashedLines(name: string, options: {
  39406. points: Vector3[];
  39407. dashSize?: number;
  39408. gapSize?: number;
  39409. dashNb?: number;
  39410. updatable?: boolean;
  39411. instance?: LinesMesh;
  39412. }, scene?: Nullable<Scene>): LinesMesh;
  39413. }
  39414. }
  39415. declare module BABYLON {
  39416. /**
  39417. * Renders a layer on top of an existing scene
  39418. */
  39419. export class UtilityLayerRenderer implements IDisposable {
  39420. /** the original scene that will be rendered on top of */
  39421. originalScene: Scene;
  39422. private _pointerCaptures;
  39423. private _lastPointerEvents;
  39424. private static _DefaultUtilityLayer;
  39425. private static _DefaultKeepDepthUtilityLayer;
  39426. /**
  39427. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  39428. */
  39429. pickUtilitySceneFirst: boolean;
  39430. /**
  39431. * 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)
  39432. */
  39433. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  39434. /**
  39435. * 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)
  39436. */
  39437. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  39438. /**
  39439. * The scene that is rendered on top of the original scene
  39440. */
  39441. utilityLayerScene: Scene;
  39442. /**
  39443. * If the utility layer should automatically be rendered on top of existing scene
  39444. */
  39445. shouldRender: boolean;
  39446. /**
  39447. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  39448. */
  39449. onlyCheckPointerDownEvents: boolean;
  39450. /**
  39451. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  39452. */
  39453. processAllEvents: boolean;
  39454. /**
  39455. * Observable raised when the pointer move from the utility layer scene to the main scene
  39456. */
  39457. onPointerOutObservable: Observable<number>;
  39458. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  39459. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  39460. private _afterRenderObserver;
  39461. private _sceneDisposeObserver;
  39462. private _originalPointerObserver;
  39463. /**
  39464. * Instantiates a UtilityLayerRenderer
  39465. * @param originalScene the original scene that will be rendered on top of
  39466. * @param handleEvents boolean indicating if the utility layer should handle events
  39467. */
  39468. constructor(
  39469. /** the original scene that will be rendered on top of */
  39470. originalScene: Scene, handleEvents?: boolean);
  39471. private _notifyObservers;
  39472. /**
  39473. * Renders the utility layers scene on top of the original scene
  39474. */
  39475. render(): void;
  39476. /**
  39477. * Disposes of the renderer
  39478. */
  39479. dispose(): void;
  39480. private _updateCamera;
  39481. }
  39482. }
  39483. declare module BABYLON {
  39484. /**
  39485. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39486. */
  39487. export class Gizmo implements IDisposable {
  39488. /** The utility layer the gizmo will be added to */
  39489. gizmoLayer: UtilityLayerRenderer;
  39490. /**
  39491. * The root mesh of the gizmo
  39492. */
  39493. _rootMesh: Mesh;
  39494. private _attachedMesh;
  39495. /**
  39496. * Ratio for the scale of the gizmo (Default: 1)
  39497. */
  39498. scaleRatio: number;
  39499. private _tmpMatrix;
  39500. /**
  39501. * If a custom mesh has been set (Default: false)
  39502. */
  39503. protected _customMeshSet: boolean;
  39504. /**
  39505. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39506. * * When set, interactions will be enabled
  39507. */
  39508. attachedMesh: Nullable<AbstractMesh>;
  39509. /**
  39510. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39511. * @param mesh The mesh to replace the default mesh of the gizmo
  39512. */
  39513. setCustomMesh(mesh: Mesh): void;
  39514. /**
  39515. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39516. */
  39517. updateGizmoRotationToMatchAttachedMesh: boolean;
  39518. /**
  39519. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  39520. */
  39521. updateGizmoPositionToMatchAttachedMesh: boolean;
  39522. /**
  39523. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  39524. */
  39525. protected _updateScale: boolean;
  39526. protected _interactionsEnabled: boolean;
  39527. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39528. private _beforeRenderObserver;
  39529. /**
  39530. * Creates a gizmo
  39531. * @param gizmoLayer The utility layer the gizmo will be added to
  39532. */
  39533. constructor(
  39534. /** The utility layer the gizmo will be added to */
  39535. gizmoLayer?: UtilityLayerRenderer);
  39536. private _tempVector;
  39537. /**
  39538. * @hidden
  39539. * Updates the gizmo to match the attached mesh's position/rotation
  39540. */
  39541. protected _update(): void;
  39542. /**
  39543. * Disposes of the gizmo
  39544. */
  39545. dispose(): void;
  39546. }
  39547. }
  39548. declare module BABYLON {
  39549. /**
  39550. * Single axis drag gizmo
  39551. */
  39552. export class AxisDragGizmo extends Gizmo {
  39553. /**
  39554. * Drag behavior responsible for the gizmos dragging interactions
  39555. */
  39556. dragBehavior: PointerDragBehavior;
  39557. private _pointerObserver;
  39558. /**
  39559. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39560. */
  39561. snapDistance: number;
  39562. /**
  39563. * Event that fires each time the gizmo snaps to a new location.
  39564. * * snapDistance is the the change in distance
  39565. */
  39566. onSnapObservable: Observable<{
  39567. snapDistance: number;
  39568. }>;
  39569. /** @hidden */
  39570. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  39571. /** @hidden */
  39572. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  39573. /**
  39574. * Creates an AxisDragGizmo
  39575. * @param gizmoLayer The utility layer the gizmo will be added to
  39576. * @param dragAxis The axis which the gizmo will be able to drag on
  39577. * @param color The color of the gizmo
  39578. */
  39579. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  39580. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39581. /**
  39582. * Disposes of the gizmo
  39583. */
  39584. dispose(): void;
  39585. }
  39586. }
  39587. declare module BABYLON.Debug {
  39588. /**
  39589. * The Axes viewer will show 3 axes in a specific point in space
  39590. */
  39591. export class AxesViewer {
  39592. private _xAxis;
  39593. private _yAxis;
  39594. private _zAxis;
  39595. private _scaleLinesFactor;
  39596. private _instanced;
  39597. /**
  39598. * Gets the hosting scene
  39599. */
  39600. scene: Scene;
  39601. /**
  39602. * Gets or sets a number used to scale line length
  39603. */
  39604. scaleLines: number;
  39605. /** Gets the node hierarchy used to render x-axis */
  39606. readonly xAxis: TransformNode;
  39607. /** Gets the node hierarchy used to render y-axis */
  39608. readonly yAxis: TransformNode;
  39609. /** Gets the node hierarchy used to render z-axis */
  39610. readonly zAxis: TransformNode;
  39611. /**
  39612. * Creates a new AxesViewer
  39613. * @param scene defines the hosting scene
  39614. * @param scaleLines defines a number used to scale line length (1 by default)
  39615. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  39616. * @param xAxis defines the node hierarchy used to render the x-axis
  39617. * @param yAxis defines the node hierarchy used to render the y-axis
  39618. * @param zAxis defines the node hierarchy used to render the z-axis
  39619. */
  39620. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  39621. /**
  39622. * Force the viewer to update
  39623. * @param position defines the position of the viewer
  39624. * @param xaxis defines the x axis of the viewer
  39625. * @param yaxis defines the y axis of the viewer
  39626. * @param zaxis defines the z axis of the viewer
  39627. */
  39628. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  39629. /**
  39630. * Creates an instance of this axes viewer.
  39631. * @returns a new axes viewer with instanced meshes
  39632. */
  39633. createInstance(): AxesViewer;
  39634. /** Releases resources */
  39635. dispose(): void;
  39636. private static _SetRenderingGroupId;
  39637. }
  39638. }
  39639. declare module BABYLON.Debug {
  39640. /**
  39641. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  39642. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  39643. */
  39644. export class BoneAxesViewer extends AxesViewer {
  39645. /**
  39646. * Gets or sets the target mesh where to display the axes viewer
  39647. */
  39648. mesh: Nullable<Mesh>;
  39649. /**
  39650. * Gets or sets the target bone where to display the axes viewer
  39651. */
  39652. bone: Nullable<Bone>;
  39653. /** Gets current position */
  39654. pos: Vector3;
  39655. /** Gets direction of X axis */
  39656. xaxis: Vector3;
  39657. /** Gets direction of Y axis */
  39658. yaxis: Vector3;
  39659. /** Gets direction of Z axis */
  39660. zaxis: Vector3;
  39661. /**
  39662. * Creates a new BoneAxesViewer
  39663. * @param scene defines the hosting scene
  39664. * @param bone defines the target bone
  39665. * @param mesh defines the target mesh
  39666. * @param scaleLines defines a scaling factor for line length (1 by default)
  39667. */
  39668. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  39669. /**
  39670. * Force the viewer to update
  39671. */
  39672. update(): void;
  39673. /** Releases resources */
  39674. dispose(): void;
  39675. }
  39676. }
  39677. declare module BABYLON {
  39678. /**
  39679. * Interface used to define scene explorer extensibility option
  39680. */
  39681. export interface IExplorerExtensibilityOption {
  39682. /**
  39683. * Define the option label
  39684. */
  39685. label: string;
  39686. /**
  39687. * Defines the action to execute on click
  39688. */
  39689. action: (entity: any) => void;
  39690. }
  39691. /**
  39692. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  39693. */
  39694. export interface IExplorerExtensibilityGroup {
  39695. /**
  39696. * Defines a predicate to test if a given type mut be extended
  39697. */
  39698. predicate: (entity: any) => boolean;
  39699. /**
  39700. * Gets the list of options added to a type
  39701. */
  39702. entries: IExplorerExtensibilityOption[];
  39703. }
  39704. /**
  39705. * Interface used to define the options to use to create the Inspector
  39706. */
  39707. export interface IInspectorOptions {
  39708. /**
  39709. * Display in overlay mode (default: false)
  39710. */
  39711. overlay?: boolean;
  39712. /**
  39713. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  39714. */
  39715. globalRoot?: HTMLElement;
  39716. /**
  39717. * Display the Scene explorer
  39718. */
  39719. showExplorer?: boolean;
  39720. /**
  39721. * Display the property inspector
  39722. */
  39723. showInspector?: boolean;
  39724. /**
  39725. * Display in embed mode (both panes on the right)
  39726. */
  39727. embedMode?: boolean;
  39728. /**
  39729. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  39730. */
  39731. handleResize?: boolean;
  39732. /**
  39733. * Allow the panes to popup (default: true)
  39734. */
  39735. enablePopup?: boolean;
  39736. /**
  39737. * Allow the panes to be closed by users (default: true)
  39738. */
  39739. enableClose?: boolean;
  39740. /**
  39741. * Optional list of extensibility entries
  39742. */
  39743. explorerExtensibility?: IExplorerExtensibilityGroup[];
  39744. /**
  39745. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  39746. */
  39747. inspectorURL?: string;
  39748. }
  39749. interface Scene {
  39750. /**
  39751. * @hidden
  39752. * Backing field
  39753. */
  39754. _debugLayer: DebugLayer;
  39755. /**
  39756. * Gets the debug layer (aka Inspector) associated with the scene
  39757. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39758. */
  39759. debugLayer: DebugLayer;
  39760. }
  39761. /**
  39762. * The debug layer (aka Inspector) is the go to tool in order to better understand
  39763. * what is happening in your scene
  39764. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39765. */
  39766. export class DebugLayer {
  39767. /**
  39768. * Define the url to get the inspector script from.
  39769. * By default it uses the babylonjs CDN.
  39770. * @ignoreNaming
  39771. */
  39772. static InspectorURL: string;
  39773. private _scene;
  39774. private BJSINSPECTOR;
  39775. /**
  39776. * Observable triggered when a property is changed through the inspector.
  39777. */
  39778. onPropertyChangedObservable: Observable<{
  39779. object: any;
  39780. property: string;
  39781. value: any;
  39782. initialValue: any;
  39783. }>;
  39784. /**
  39785. * Instantiates a new debug layer.
  39786. * The debug layer (aka Inspector) is the go to tool in order to better understand
  39787. * what is happening in your scene
  39788. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39789. * @param scene Defines the scene to inspect
  39790. */
  39791. constructor(scene: Scene);
  39792. /** Creates the inspector window. */
  39793. private _createInspector;
  39794. /**
  39795. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  39796. * @param entity defines the entity to select
  39797. * @param lineContainerTitle defines the specific block to highlight
  39798. */
  39799. select(entity: any, lineContainerTitle?: string): void;
  39800. /** Get the inspector from bundle or global */
  39801. private _getGlobalInspector;
  39802. /**
  39803. * Get if the inspector is visible or not.
  39804. * @returns true if visible otherwise, false
  39805. */
  39806. isVisible(): boolean;
  39807. /**
  39808. * Hide the inspector and close its window.
  39809. */
  39810. hide(): void;
  39811. /**
  39812. * Launch the debugLayer.
  39813. * @param config Define the configuration of the inspector
  39814. * @return a promise fulfilled when the debug layer is visible
  39815. */
  39816. show(config?: IInspectorOptions): Promise<DebugLayer>;
  39817. }
  39818. }
  39819. declare module BABYLON {
  39820. /**
  39821. * Class containing static functions to help procedurally build meshes
  39822. */
  39823. export class BoxBuilder {
  39824. /**
  39825. * Creates a box mesh
  39826. * * The parameter `size` sets the size (float) of each box side (default 1)
  39827. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  39828. * * 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)
  39829. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  39830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39831. * * 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
  39832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39833. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  39834. * @param name defines the name of the mesh
  39835. * @param options defines the options used to create the mesh
  39836. * @param scene defines the hosting scene
  39837. * @returns the box mesh
  39838. */
  39839. static CreateBox(name: string, options: {
  39840. size?: number;
  39841. width?: number;
  39842. height?: number;
  39843. depth?: number;
  39844. faceUV?: Vector4[];
  39845. faceColors?: Color4[];
  39846. sideOrientation?: number;
  39847. frontUVs?: Vector4;
  39848. backUVs?: Vector4;
  39849. updatable?: boolean;
  39850. }, scene?: Nullable<Scene>): Mesh;
  39851. }
  39852. }
  39853. declare module BABYLON {
  39854. /**
  39855. * Class containing static functions to help procedurally build meshes
  39856. */
  39857. export class SphereBuilder {
  39858. /**
  39859. * Creates a sphere mesh
  39860. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  39861. * * 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`)
  39862. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  39863. * * 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
  39864. * * 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)
  39865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39866. * * 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
  39867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39868. * @param name defines the name of the mesh
  39869. * @param options defines the options used to create the mesh
  39870. * @param scene defines the hosting scene
  39871. * @returns the sphere mesh
  39872. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  39873. */
  39874. static CreateSphere(name: string, options: {
  39875. segments?: number;
  39876. diameter?: number;
  39877. diameterX?: number;
  39878. diameterY?: number;
  39879. diameterZ?: number;
  39880. arc?: number;
  39881. slice?: number;
  39882. sideOrientation?: number;
  39883. frontUVs?: Vector4;
  39884. backUVs?: Vector4;
  39885. updatable?: boolean;
  39886. }, scene: any): Mesh;
  39887. }
  39888. }
  39889. declare module BABYLON.Debug {
  39890. /**
  39891. * Used to show the physics impostor around the specific mesh
  39892. */
  39893. export class PhysicsViewer {
  39894. /** @hidden */
  39895. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  39896. /** @hidden */
  39897. protected _meshes: Array<Nullable<AbstractMesh>>;
  39898. /** @hidden */
  39899. protected _scene: Nullable<Scene>;
  39900. /** @hidden */
  39901. protected _numMeshes: number;
  39902. /** @hidden */
  39903. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  39904. private _renderFunction;
  39905. private _utilityLayer;
  39906. private _debugBoxMesh;
  39907. private _debugSphereMesh;
  39908. private _debugMaterial;
  39909. /**
  39910. * Creates a new PhysicsViewer
  39911. * @param scene defines the hosting scene
  39912. */
  39913. constructor(scene: Scene);
  39914. /** @hidden */
  39915. protected _updateDebugMeshes(): void;
  39916. /**
  39917. * Renders a specified physic impostor
  39918. * @param impostor defines the impostor to render
  39919. * @returns the new debug mesh used to render the impostor
  39920. */
  39921. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  39922. /**
  39923. * Hides a specified physic impostor
  39924. * @param impostor defines the impostor to hide
  39925. */
  39926. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  39927. private _getDebugMaterial;
  39928. private _getDebugBoxMesh;
  39929. private _getDebugSphereMesh;
  39930. private _getDebugMesh;
  39931. /** Releases all resources */
  39932. dispose(): void;
  39933. }
  39934. }
  39935. declare module BABYLON {
  39936. /**
  39937. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  39938. * in order to better appreciate the issue one might have.
  39939. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  39940. */
  39941. export class RayHelper {
  39942. /**
  39943. * Defines the ray we are currently tryin to visualize.
  39944. */
  39945. ray: Nullable<Ray>;
  39946. private _renderPoints;
  39947. private _renderLine;
  39948. private _renderFunction;
  39949. private _scene;
  39950. private _updateToMeshFunction;
  39951. private _attachedToMesh;
  39952. private _meshSpaceDirection;
  39953. private _meshSpaceOrigin;
  39954. /**
  39955. * Helper function to create a colored helper in a scene in one line.
  39956. * @param ray Defines the ray we are currently tryin to visualize
  39957. * @param scene Defines the scene the ray is used in
  39958. * @param color Defines the color we want to see the ray in
  39959. * @returns The newly created ray helper.
  39960. */
  39961. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  39962. /**
  39963. * Instantiate a new ray helper.
  39964. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  39965. * in order to better appreciate the issue one might have.
  39966. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  39967. * @param ray Defines the ray we are currently tryin to visualize
  39968. */
  39969. constructor(ray: Ray);
  39970. /**
  39971. * Shows the ray we are willing to debug.
  39972. * @param scene Defines the scene the ray needs to be rendered in
  39973. * @param color Defines the color the ray needs to be rendered in
  39974. */
  39975. show(scene: Scene, color?: Color3): void;
  39976. /**
  39977. * Hides the ray we are debugging.
  39978. */
  39979. hide(): void;
  39980. private _render;
  39981. /**
  39982. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  39983. * @param mesh Defines the mesh we want the helper attached to
  39984. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  39985. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  39986. * @param length Defines the length of the ray
  39987. */
  39988. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  39989. /**
  39990. * Detach the ray helper from the mesh it has previously been attached to.
  39991. */
  39992. detachFromMesh(): void;
  39993. private _updateToMesh;
  39994. /**
  39995. * Dispose the helper and release its associated resources.
  39996. */
  39997. dispose(): void;
  39998. }
  39999. }
  40000. declare module BABYLON.Debug {
  40001. /**
  40002. * Class used to render a debug view of a given skeleton
  40003. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40004. */
  40005. export class SkeletonViewer {
  40006. /** defines the skeleton to render */
  40007. skeleton: Skeleton;
  40008. /** defines the mesh attached to the skeleton */
  40009. mesh: AbstractMesh;
  40010. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40011. autoUpdateBonesMatrices: boolean;
  40012. /** defines the rendering group id to use with the viewer */
  40013. renderingGroupId: number;
  40014. /** Gets or sets the color used to render the skeleton */
  40015. color: Color3;
  40016. private _scene;
  40017. private _debugLines;
  40018. private _debugMesh;
  40019. private _isEnabled;
  40020. private _renderFunction;
  40021. private _utilityLayer;
  40022. /**
  40023. * Returns the mesh used to render the bones
  40024. */
  40025. readonly debugMesh: Nullable<LinesMesh>;
  40026. /**
  40027. * Creates a new SkeletonViewer
  40028. * @param skeleton defines the skeleton to render
  40029. * @param mesh defines the mesh attached to the skeleton
  40030. * @param scene defines the hosting scene
  40031. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40032. * @param renderingGroupId defines the rendering group id to use with the viewer
  40033. */
  40034. constructor(
  40035. /** defines the skeleton to render */
  40036. skeleton: Skeleton,
  40037. /** defines the mesh attached to the skeleton */
  40038. mesh: AbstractMesh, scene: Scene,
  40039. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40040. autoUpdateBonesMatrices?: boolean,
  40041. /** defines the rendering group id to use with the viewer */
  40042. renderingGroupId?: number);
  40043. /** Gets or sets a boolean indicating if the viewer is enabled */
  40044. isEnabled: boolean;
  40045. private _getBonePosition;
  40046. private _getLinesForBonesWithLength;
  40047. private _getLinesForBonesNoLength;
  40048. /** Update the viewer to sync with current skeleton state */
  40049. update(): void;
  40050. /** Release associated resources */
  40051. dispose(): void;
  40052. }
  40053. }
  40054. declare module BABYLON {
  40055. /**
  40056. * Options to create the null engine
  40057. */
  40058. export class NullEngineOptions {
  40059. /**
  40060. * Render width (Default: 512)
  40061. */
  40062. renderWidth: number;
  40063. /**
  40064. * Render height (Default: 256)
  40065. */
  40066. renderHeight: number;
  40067. /**
  40068. * Texture size (Default: 512)
  40069. */
  40070. textureSize: number;
  40071. /**
  40072. * If delta time between frames should be constant
  40073. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40074. */
  40075. deterministicLockstep: boolean;
  40076. /**
  40077. * Maximum about of steps between frames (Default: 4)
  40078. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40079. */
  40080. lockstepMaxSteps: number;
  40081. }
  40082. /**
  40083. * The null engine class provides support for headless version of babylon.js.
  40084. * This can be used in server side scenario or for testing purposes
  40085. */
  40086. export class NullEngine extends Engine {
  40087. private _options;
  40088. /**
  40089. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40090. */
  40091. isDeterministicLockStep(): boolean;
  40092. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40093. getLockstepMaxSteps(): number;
  40094. /**
  40095. * Sets hardware scaling, used to save performance if needed
  40096. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40097. */
  40098. getHardwareScalingLevel(): number;
  40099. constructor(options?: NullEngineOptions);
  40100. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40101. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  40102. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40103. getRenderWidth(useScreen?: boolean): number;
  40104. getRenderHeight(useScreen?: boolean): number;
  40105. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40106. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40107. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  40108. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  40109. bindSamplers(effect: Effect): void;
  40110. enableEffect(effect: Effect): void;
  40111. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40112. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40113. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40114. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40115. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40116. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40117. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40118. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40119. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40120. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40121. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40122. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40123. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40124. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40125. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40126. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40127. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40128. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40129. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40130. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40131. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40132. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40133. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40134. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40135. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40136. bindBuffers(vertexBuffers: {
  40137. [key: string]: VertexBuffer;
  40138. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  40139. wipeCaches(bruteForce?: boolean): void;
  40140. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40141. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40142. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40143. /** @hidden */
  40144. _createTexture(): WebGLTexture;
  40145. /** @hidden */
  40146. _releaseTexture(texture: InternalTexture): void;
  40147. 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;
  40148. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40149. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40150. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40151. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40152. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40153. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40154. areAllEffectsReady(): boolean;
  40155. /**
  40156. * @hidden
  40157. * Get the current error code of the webGL context
  40158. * @returns the error code
  40159. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40160. */
  40161. getError(): number;
  40162. /** @hidden */
  40163. _getUnpackAlignement(): number;
  40164. /** @hidden */
  40165. _unpackFlipY(value: boolean): void;
  40166. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40167. /**
  40168. * Updates a dynamic vertex buffer.
  40169. * @param vertexBuffer the vertex buffer to update
  40170. * @param data the data used to update the vertex buffer
  40171. * @param byteOffset the byte offset of the data (optional)
  40172. * @param byteLength the byte length of the data (optional)
  40173. */
  40174. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  40175. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40176. /** @hidden */
  40177. _bindTexture(channel: number, texture: InternalTexture): void;
  40178. /** @hidden */
  40179. _releaseBuffer(buffer: WebGLBuffer): boolean;
  40180. releaseEffects(): void;
  40181. displayLoadingUI(): void;
  40182. hideLoadingUI(): void;
  40183. /** @hidden */
  40184. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40185. /** @hidden */
  40186. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40187. /** @hidden */
  40188. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40189. /** @hidden */
  40190. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40191. }
  40192. }
  40193. declare module BABYLON {
  40194. /** @hidden */
  40195. export class _OcclusionDataStorage {
  40196. /** @hidden */
  40197. occlusionInternalRetryCounter: number;
  40198. /** @hidden */
  40199. isOcclusionQueryInProgress: boolean;
  40200. /** @hidden */
  40201. isOccluded: boolean;
  40202. /** @hidden */
  40203. occlusionRetryCount: number;
  40204. /** @hidden */
  40205. occlusionType: number;
  40206. /** @hidden */
  40207. occlusionQueryAlgorithmType: number;
  40208. }
  40209. interface Engine {
  40210. /**
  40211. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40212. * @return the new query
  40213. */
  40214. createQuery(): WebGLQuery;
  40215. /**
  40216. * Delete and release a webGL query
  40217. * @param query defines the query to delete
  40218. * @return the current engine
  40219. */
  40220. deleteQuery(query: WebGLQuery): Engine;
  40221. /**
  40222. * Check if a given query has resolved and got its value
  40223. * @param query defines the query to check
  40224. * @returns true if the query got its value
  40225. */
  40226. isQueryResultAvailable(query: WebGLQuery): boolean;
  40227. /**
  40228. * Gets the value of a given query
  40229. * @param query defines the query to check
  40230. * @returns the value of the query
  40231. */
  40232. getQueryResult(query: WebGLQuery): number;
  40233. /**
  40234. * Initiates an occlusion query
  40235. * @param algorithmType defines the algorithm to use
  40236. * @param query defines the query to use
  40237. * @returns the current engine
  40238. * @see http://doc.babylonjs.com/features/occlusionquery
  40239. */
  40240. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40241. /**
  40242. * Ends an occlusion query
  40243. * @see http://doc.babylonjs.com/features/occlusionquery
  40244. * @param algorithmType defines the algorithm to use
  40245. * @returns the current engine
  40246. */
  40247. endOcclusionQuery(algorithmType: number): Engine;
  40248. /**
  40249. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40250. * Please note that only one query can be issued at a time
  40251. * @returns a time token used to track the time span
  40252. */
  40253. startTimeQuery(): Nullable<_TimeToken>;
  40254. /**
  40255. * Ends a time query
  40256. * @param token defines the token used to measure the time span
  40257. * @returns the time spent (in ns)
  40258. */
  40259. endTimeQuery(token: _TimeToken): int;
  40260. /** @hidden */
  40261. _currentNonTimestampToken: Nullable<_TimeToken>;
  40262. /** @hidden */
  40263. _createTimeQuery(): WebGLQuery;
  40264. /** @hidden */
  40265. _deleteTimeQuery(query: WebGLQuery): void;
  40266. /** @hidden */
  40267. _getGlAlgorithmType(algorithmType: number): number;
  40268. /** @hidden */
  40269. _getTimeQueryResult(query: WebGLQuery): any;
  40270. /** @hidden */
  40271. _getTimeQueryAvailability(query: WebGLQuery): any;
  40272. }
  40273. interface AbstractMesh {
  40274. /**
  40275. * Backing filed
  40276. * @hidden
  40277. */
  40278. __occlusionDataStorage: _OcclusionDataStorage;
  40279. /**
  40280. * Access property
  40281. * @hidden
  40282. */
  40283. _occlusionDataStorage: _OcclusionDataStorage;
  40284. /**
  40285. * 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.
  40286. * The default value is -1 which means don't break the query and wait till the result
  40287. * @see http://doc.babylonjs.com/features/occlusionquery
  40288. */
  40289. occlusionRetryCount: number;
  40290. /**
  40291. * 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:
  40292. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40293. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40294. * * 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.
  40295. * @see http://doc.babylonjs.com/features/occlusionquery
  40296. */
  40297. occlusionType: number;
  40298. /**
  40299. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40300. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40301. * * 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.
  40302. * @see http://doc.babylonjs.com/features/occlusionquery
  40303. */
  40304. occlusionQueryAlgorithmType: number;
  40305. /**
  40306. * 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
  40307. * @see http://doc.babylonjs.com/features/occlusionquery
  40308. */
  40309. isOccluded: boolean;
  40310. /**
  40311. * Flag to check the progress status of the query
  40312. * @see http://doc.babylonjs.com/features/occlusionquery
  40313. */
  40314. isOcclusionQueryInProgress: boolean;
  40315. }
  40316. }
  40317. declare module BABYLON {
  40318. /** @hidden */
  40319. export var _forceTransformFeedbackToBundle: boolean;
  40320. interface Engine {
  40321. /**
  40322. * Creates a webGL transform feedback object
  40323. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40324. * @returns the webGL transform feedback object
  40325. */
  40326. createTransformFeedback(): WebGLTransformFeedback;
  40327. /**
  40328. * Delete a webGL transform feedback object
  40329. * @param value defines the webGL transform feedback object to delete
  40330. */
  40331. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40332. /**
  40333. * Bind a webGL transform feedback object to the webgl context
  40334. * @param value defines the webGL transform feedback object to bind
  40335. */
  40336. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40337. /**
  40338. * Begins a transform feedback operation
  40339. * @param usePoints defines if points or triangles must be used
  40340. */
  40341. beginTransformFeedback(usePoints: boolean): void;
  40342. /**
  40343. * Ends a transform feedback operation
  40344. */
  40345. endTransformFeedback(): void;
  40346. /**
  40347. * Specify the varyings to use with transform feedback
  40348. * @param program defines the associated webGL program
  40349. * @param value defines the list of strings representing the varying names
  40350. */
  40351. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40352. /**
  40353. * Bind a webGL buffer for a transform feedback operation
  40354. * @param value defines the webGL buffer to bind
  40355. */
  40356. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  40357. }
  40358. }
  40359. declare module BABYLON {
  40360. /**
  40361. * Gather the list of clipboard event types as constants.
  40362. */
  40363. export class ClipboardEventTypes {
  40364. /**
  40365. * The clipboard event is fired when a copy command is active (pressed).
  40366. */
  40367. static readonly COPY: number;
  40368. /**
  40369. * The clipboard event is fired when a cut command is active (pressed).
  40370. */
  40371. static readonly CUT: number;
  40372. /**
  40373. * The clipboard event is fired when a paste command is active (pressed).
  40374. */
  40375. static readonly PASTE: number;
  40376. }
  40377. /**
  40378. * This class is used to store clipboard related info for the onClipboardObservable event.
  40379. */
  40380. export class ClipboardInfo {
  40381. /**
  40382. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40383. */
  40384. type: number;
  40385. /**
  40386. * Defines the related dom event
  40387. */
  40388. event: ClipboardEvent;
  40389. /**
  40390. *Creates an instance of ClipboardInfo.
  40391. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  40392. * @param event Defines the related dom event
  40393. */
  40394. constructor(
  40395. /**
  40396. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40397. */
  40398. type: number,
  40399. /**
  40400. * Defines the related dom event
  40401. */
  40402. event: ClipboardEvent);
  40403. /**
  40404. * Get the clipboard event's type from the keycode.
  40405. * @param keyCode Defines the keyCode for the current keyboard event.
  40406. * @return {number}
  40407. */
  40408. static GetTypeFromCharacter(keyCode: number): number;
  40409. }
  40410. }
  40411. declare module BABYLON {
  40412. /**
  40413. * Class used to represent data loading progression
  40414. */
  40415. export class SceneLoaderProgressEvent {
  40416. /** defines if data length to load can be evaluated */
  40417. readonly lengthComputable: boolean;
  40418. /** defines the loaded data length */
  40419. readonly loaded: number;
  40420. /** defines the data length to load */
  40421. readonly total: number;
  40422. /**
  40423. * Create a new progress event
  40424. * @param lengthComputable defines if data length to load can be evaluated
  40425. * @param loaded defines the loaded data length
  40426. * @param total defines the data length to load
  40427. */
  40428. constructor(
  40429. /** defines if data length to load can be evaluated */
  40430. lengthComputable: boolean,
  40431. /** defines the loaded data length */
  40432. loaded: number,
  40433. /** defines the data length to load */
  40434. total: number);
  40435. /**
  40436. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40437. * @param event defines the source event
  40438. * @returns a new SceneLoaderProgressEvent
  40439. */
  40440. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40441. }
  40442. /**
  40443. * Interface used by SceneLoader plugins to define supported file extensions
  40444. */
  40445. export interface ISceneLoaderPluginExtensions {
  40446. /**
  40447. * Defines the list of supported extensions
  40448. */
  40449. [extension: string]: {
  40450. isBinary: boolean;
  40451. };
  40452. }
  40453. /**
  40454. * Interface used by SceneLoader plugin factory
  40455. */
  40456. export interface ISceneLoaderPluginFactory {
  40457. /**
  40458. * Defines the name of the factory
  40459. */
  40460. name: string;
  40461. /**
  40462. * Function called to create a new plugin
  40463. * @return the new plugin
  40464. */
  40465. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40466. /**
  40467. * Boolean indicating if the plugin can direct load specific data
  40468. */
  40469. canDirectLoad?: (data: string) => boolean;
  40470. }
  40471. /**
  40472. * Interface used to define a SceneLoader plugin
  40473. */
  40474. export interface ISceneLoaderPlugin {
  40475. /**
  40476. * The friendly name of this plugin.
  40477. */
  40478. name: string;
  40479. /**
  40480. * The file extensions supported by this plugin.
  40481. */
  40482. extensions: string | ISceneLoaderPluginExtensions;
  40483. /**
  40484. * Import meshes into a scene.
  40485. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40486. * @param scene The scene to import into
  40487. * @param data The data to import
  40488. * @param rootUrl The root url for scene and resources
  40489. * @param meshes The meshes array to import into
  40490. * @param particleSystems The particle systems array to import into
  40491. * @param skeletons The skeletons array to import into
  40492. * @param onError The callback when import fails
  40493. * @returns True if successful or false otherwise
  40494. */
  40495. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  40496. /**
  40497. * Load into a scene.
  40498. * @param scene The scene to load into
  40499. * @param data The data to import
  40500. * @param rootUrl The root url for scene and resources
  40501. * @param onError The callback when import fails
  40502. * @returns true if successful or false otherwise
  40503. */
  40504. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  40505. /**
  40506. * The callback that returns true if the data can be directly loaded.
  40507. */
  40508. canDirectLoad?: (data: string) => boolean;
  40509. /**
  40510. * The callback that allows custom handling of the root url based on the response url.
  40511. */
  40512. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40513. /**
  40514. * Load into an asset container.
  40515. * @param scene The scene to load into
  40516. * @param data The data to import
  40517. * @param rootUrl The root url for scene and resources
  40518. * @param onError The callback when import fails
  40519. * @returns The loaded asset container
  40520. */
  40521. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  40522. }
  40523. /**
  40524. * Interface used to define an async SceneLoader plugin
  40525. */
  40526. export interface ISceneLoaderPluginAsync {
  40527. /**
  40528. * The friendly name of this plugin.
  40529. */
  40530. name: string;
  40531. /**
  40532. * The file extensions supported by this plugin.
  40533. */
  40534. extensions: string | ISceneLoaderPluginExtensions;
  40535. /**
  40536. * Import meshes into a scene.
  40537. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40538. * @param scene The scene to import into
  40539. * @param data The data to import
  40540. * @param rootUrl The root url for scene and resources
  40541. * @param onProgress The callback when the load progresses
  40542. * @param fileName Defines the name of the file to load
  40543. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  40544. */
  40545. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  40546. meshes: AbstractMesh[];
  40547. particleSystems: IParticleSystem[];
  40548. skeletons: Skeleton[];
  40549. animationGroups: AnimationGroup[];
  40550. }>;
  40551. /**
  40552. * Load into a scene.
  40553. * @param scene The scene to load into
  40554. * @param data The data to import
  40555. * @param rootUrl The root url for scene and resources
  40556. * @param onProgress The callback when the load progresses
  40557. * @param fileName Defines the name of the file to load
  40558. * @returns Nothing
  40559. */
  40560. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  40561. /**
  40562. * The callback that returns true if the data can be directly loaded.
  40563. */
  40564. canDirectLoad?: (data: string) => boolean;
  40565. /**
  40566. * The callback that allows custom handling of the root url based on the response url.
  40567. */
  40568. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40569. /**
  40570. * Load into an asset container.
  40571. * @param scene The scene to load into
  40572. * @param data The data to import
  40573. * @param rootUrl The root url for scene and resources
  40574. * @param onProgress The callback when the load progresses
  40575. * @param fileName Defines the name of the file to load
  40576. * @returns The loaded asset container
  40577. */
  40578. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  40579. }
  40580. /**
  40581. * Class used to load scene from various file formats using registered plugins
  40582. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  40583. */
  40584. export class SceneLoader {
  40585. /**
  40586. * No logging while loading
  40587. */
  40588. static readonly NO_LOGGING: number;
  40589. /**
  40590. * Minimal logging while loading
  40591. */
  40592. static readonly MINIMAL_LOGGING: number;
  40593. /**
  40594. * Summary logging while loading
  40595. */
  40596. static readonly SUMMARY_LOGGING: number;
  40597. /**
  40598. * Detailled logging while loading
  40599. */
  40600. static readonly DETAILED_LOGGING: number;
  40601. /**
  40602. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  40603. */
  40604. static ForceFullSceneLoadingForIncremental: boolean;
  40605. /**
  40606. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  40607. */
  40608. static ShowLoadingScreen: boolean;
  40609. /**
  40610. * Defines the current logging level (while loading the scene)
  40611. * @ignorenaming
  40612. */
  40613. static loggingLevel: number;
  40614. /**
  40615. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  40616. */
  40617. static CleanBoneMatrixWeights: boolean;
  40618. /**
  40619. * Event raised when a plugin is used to load a scene
  40620. */
  40621. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  40622. private static _registeredPlugins;
  40623. private static _getDefaultPlugin;
  40624. private static _getPluginForExtension;
  40625. private static _getPluginForDirectLoad;
  40626. private static _getPluginForFilename;
  40627. private static _getDirectLoad;
  40628. private static _loadData;
  40629. private static _getFileInfo;
  40630. /**
  40631. * Gets a plugin that can load the given extension
  40632. * @param extension defines the extension to load
  40633. * @returns a plugin or null if none works
  40634. */
  40635. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  40636. /**
  40637. * Gets a boolean indicating that the given extension can be loaded
  40638. * @param extension defines the extension to load
  40639. * @returns true if the extension is supported
  40640. */
  40641. static IsPluginForExtensionAvailable(extension: string): boolean;
  40642. /**
  40643. * Adds a new plugin to the list of registered plugins
  40644. * @param plugin defines the plugin to add
  40645. */
  40646. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  40647. /**
  40648. * Import meshes into a scene
  40649. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40650. * @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)
  40651. * @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)
  40652. * @param scene the instance of BABYLON.Scene to append to
  40653. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  40654. * @param onProgress a callback with a progress event for each file being loaded
  40655. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40656. * @param pluginExtension the extension used to determine the plugin
  40657. * @returns The loaded plugin
  40658. */
  40659. 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>;
  40660. /**
  40661. * Import meshes into a scene
  40662. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40663. * @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)
  40664. * @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)
  40665. * @param scene the instance of BABYLON.Scene to append to
  40666. * @param onProgress a callback with a progress event for each file being loaded
  40667. * @param pluginExtension the extension used to determine the plugin
  40668. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  40669. */
  40670. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  40671. meshes: AbstractMesh[];
  40672. particleSystems: IParticleSystem[];
  40673. skeletons: Skeleton[];
  40674. animationGroups: AnimationGroup[];
  40675. }>;
  40676. /**
  40677. * Load a scene
  40678. * @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)
  40679. * @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)
  40680. * @param engine is the instance of BABYLON.Engine to use to create the scene
  40681. * @param onSuccess a callback with the scene when import succeeds
  40682. * @param onProgress a callback with a progress event for each file being loaded
  40683. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40684. * @param pluginExtension the extension used to determine the plugin
  40685. * @returns The loaded plugin
  40686. */
  40687. 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>;
  40688. /**
  40689. * Load a scene
  40690. * @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)
  40691. * @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)
  40692. * @param engine is the instance of BABYLON.Engine to use to create the scene
  40693. * @param onProgress a callback with a progress event for each file being loaded
  40694. * @param pluginExtension the extension used to determine the plugin
  40695. * @returns The loaded scene
  40696. */
  40697. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  40698. /**
  40699. * Append a scene
  40700. * @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)
  40701. * @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)
  40702. * @param scene is the instance of BABYLON.Scene to append to
  40703. * @param onSuccess a callback with the scene when import succeeds
  40704. * @param onProgress a callback with a progress event for each file being loaded
  40705. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40706. * @param pluginExtension the extension used to determine the plugin
  40707. * @returns The loaded plugin
  40708. */
  40709. 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>;
  40710. /**
  40711. * Append a scene
  40712. * @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)
  40713. * @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)
  40714. * @param scene is the instance of BABYLON.Scene to append to
  40715. * @param onProgress a callback with a progress event for each file being loaded
  40716. * @param pluginExtension the extension used to determine the plugin
  40717. * @returns The given scene
  40718. */
  40719. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  40720. /**
  40721. * Load a scene into an asset container
  40722. * @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)
  40723. * @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)
  40724. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40725. * @param onSuccess a callback with the scene when import succeeds
  40726. * @param onProgress a callback with a progress event for each file being loaded
  40727. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40728. * @param pluginExtension the extension used to determine the plugin
  40729. * @returns The loaded plugin
  40730. */
  40731. 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>;
  40732. /**
  40733. * Load a scene into an asset container
  40734. * @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)
  40735. * @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)
  40736. * @param scene is the instance of Scene to append to
  40737. * @param onProgress a callback with a progress event for each file being loaded
  40738. * @param pluginExtension the extension used to determine the plugin
  40739. * @returns The loaded asset container
  40740. */
  40741. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  40742. }
  40743. }
  40744. declare module BABYLON {
  40745. /**
  40746. * Google Daydream controller
  40747. */
  40748. export class DaydreamController extends WebVRController {
  40749. /**
  40750. * Base Url for the controller model.
  40751. */
  40752. static MODEL_BASE_URL: string;
  40753. /**
  40754. * File name for the controller model.
  40755. */
  40756. static MODEL_FILENAME: string;
  40757. /**
  40758. * Gamepad Id prefix used to identify Daydream Controller.
  40759. */
  40760. static readonly GAMEPAD_ID_PREFIX: string;
  40761. /**
  40762. * Creates a new DaydreamController from a gamepad
  40763. * @param vrGamepad the gamepad that the controller should be created from
  40764. */
  40765. constructor(vrGamepad: any);
  40766. /**
  40767. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40768. * @param scene scene in which to add meshes
  40769. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40770. */
  40771. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40772. /**
  40773. * Called once for each button that changed state since the last frame
  40774. * @param buttonIdx Which button index changed
  40775. * @param state New state of the button
  40776. * @param changes Which properties on the state changed since last frame
  40777. */
  40778. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40779. }
  40780. }
  40781. declare module BABYLON {
  40782. /**
  40783. * Gear VR Controller
  40784. */
  40785. export class GearVRController extends WebVRController {
  40786. /**
  40787. * Base Url for the controller model.
  40788. */
  40789. static MODEL_BASE_URL: string;
  40790. /**
  40791. * File name for the controller model.
  40792. */
  40793. static MODEL_FILENAME: string;
  40794. /**
  40795. * Gamepad Id prefix used to identify this controller.
  40796. */
  40797. static readonly GAMEPAD_ID_PREFIX: string;
  40798. private readonly _buttonIndexToObservableNameMap;
  40799. /**
  40800. * Creates a new GearVRController from a gamepad
  40801. * @param vrGamepad the gamepad that the controller should be created from
  40802. */
  40803. constructor(vrGamepad: any);
  40804. /**
  40805. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40806. * @param scene scene in which to add meshes
  40807. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40808. */
  40809. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40810. /**
  40811. * Called once for each button that changed state since the last frame
  40812. * @param buttonIdx Which button index changed
  40813. * @param state New state of the button
  40814. * @param changes Which properties on the state changed since last frame
  40815. */
  40816. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40817. }
  40818. }
  40819. declare module BABYLON {
  40820. /**
  40821. * Generic Controller
  40822. */
  40823. export class GenericController extends WebVRController {
  40824. /**
  40825. * Base Url for the controller model.
  40826. */
  40827. static readonly MODEL_BASE_URL: string;
  40828. /**
  40829. * File name for the controller model.
  40830. */
  40831. static readonly MODEL_FILENAME: string;
  40832. /**
  40833. * Creates a new GenericController from a gamepad
  40834. * @param vrGamepad the gamepad that the controller should be created from
  40835. */
  40836. constructor(vrGamepad: any);
  40837. /**
  40838. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40839. * @param scene scene in which to add meshes
  40840. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40841. */
  40842. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40843. /**
  40844. * Called once for each button that changed state since the last frame
  40845. * @param buttonIdx Which button index changed
  40846. * @param state New state of the button
  40847. * @param changes Which properties on the state changed since last frame
  40848. */
  40849. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40850. }
  40851. }
  40852. declare module BABYLON {
  40853. /**
  40854. * Oculus Touch Controller
  40855. */
  40856. export class OculusTouchController extends WebVRController {
  40857. /**
  40858. * Base Url for the controller model.
  40859. */
  40860. static MODEL_BASE_URL: string;
  40861. /**
  40862. * File name for the left controller model.
  40863. */
  40864. static MODEL_LEFT_FILENAME: string;
  40865. /**
  40866. * File name for the right controller model.
  40867. */
  40868. static MODEL_RIGHT_FILENAME: string;
  40869. /**
  40870. * Fired when the secondary trigger on this controller is modified
  40871. */
  40872. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  40873. /**
  40874. * Fired when the thumb rest on this controller is modified
  40875. */
  40876. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  40877. /**
  40878. * Creates a new OculusTouchController from a gamepad
  40879. * @param vrGamepad the gamepad that the controller should be created from
  40880. */
  40881. constructor(vrGamepad: any);
  40882. /**
  40883. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40884. * @param scene scene in which to add meshes
  40885. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40886. */
  40887. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40888. /**
  40889. * Fired when the A button on this controller is modified
  40890. */
  40891. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40892. /**
  40893. * Fired when the B button on this controller is modified
  40894. */
  40895. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40896. /**
  40897. * Fired when the X button on this controller is modified
  40898. */
  40899. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40900. /**
  40901. * Fired when the Y button on this controller is modified
  40902. */
  40903. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40904. /**
  40905. * Called once for each button that changed state since the last frame
  40906. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  40907. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  40908. * 2) secondary trigger (same)
  40909. * 3) A (right) X (left), touch, pressed = value
  40910. * 4) B / Y
  40911. * 5) thumb rest
  40912. * @param buttonIdx Which button index changed
  40913. * @param state New state of the button
  40914. * @param changes Which properties on the state changed since last frame
  40915. */
  40916. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40917. }
  40918. }
  40919. declare module BABYLON {
  40920. /**
  40921. * Vive Controller
  40922. */
  40923. export class ViveController extends WebVRController {
  40924. /**
  40925. * Base Url for the controller model.
  40926. */
  40927. static MODEL_BASE_URL: string;
  40928. /**
  40929. * File name for the controller model.
  40930. */
  40931. static MODEL_FILENAME: string;
  40932. /**
  40933. * Creates a new ViveController from a gamepad
  40934. * @param vrGamepad the gamepad that the controller should be created from
  40935. */
  40936. constructor(vrGamepad: any);
  40937. /**
  40938. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40939. * @param scene scene in which to add meshes
  40940. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40941. */
  40942. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40943. /**
  40944. * Fired when the left button on this controller is modified
  40945. */
  40946. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40947. /**
  40948. * Fired when the right button on this controller is modified
  40949. */
  40950. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40951. /**
  40952. * Fired when the menu button on this controller is modified
  40953. */
  40954. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40955. /**
  40956. * Called once for each button that changed state since the last frame
  40957. * Vive mapping:
  40958. * 0: touchpad
  40959. * 1: trigger
  40960. * 2: left AND right buttons
  40961. * 3: menu button
  40962. * @param buttonIdx Which button index changed
  40963. * @param state New state of the button
  40964. * @param changes Which properties on the state changed since last frame
  40965. */
  40966. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40967. }
  40968. }
  40969. declare module BABYLON {
  40970. /**
  40971. * Defines the WindowsMotionController object that the state of the windows motion controller
  40972. */
  40973. export class WindowsMotionController extends WebVRController {
  40974. /**
  40975. * The base url used to load the left and right controller models
  40976. */
  40977. static MODEL_BASE_URL: string;
  40978. /**
  40979. * The name of the left controller model file
  40980. */
  40981. static MODEL_LEFT_FILENAME: string;
  40982. /**
  40983. * The name of the right controller model file
  40984. */
  40985. static MODEL_RIGHT_FILENAME: string;
  40986. /**
  40987. * The controller name prefix for this controller type
  40988. */
  40989. static readonly GAMEPAD_ID_PREFIX: string;
  40990. /**
  40991. * The controller id pattern for this controller type
  40992. */
  40993. private static readonly GAMEPAD_ID_PATTERN;
  40994. private _loadedMeshInfo;
  40995. private readonly _mapping;
  40996. /**
  40997. * Fired when the trackpad on this controller is clicked
  40998. */
  40999. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41000. /**
  41001. * Fired when the trackpad on this controller is modified
  41002. */
  41003. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41004. /**
  41005. * The current x and y values of this controller's trackpad
  41006. */
  41007. trackpad: StickValues;
  41008. /**
  41009. * Creates a new WindowsMotionController from a gamepad
  41010. * @param vrGamepad the gamepad that the controller should be created from
  41011. */
  41012. constructor(vrGamepad: any);
  41013. /**
  41014. * Fired when the trigger on this controller is modified
  41015. */
  41016. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41017. /**
  41018. * Fired when the menu button on this controller is modified
  41019. */
  41020. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41021. /**
  41022. * Fired when the grip button on this controller is modified
  41023. */
  41024. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41025. /**
  41026. * Fired when the thumbstick button on this controller is modified
  41027. */
  41028. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41029. /**
  41030. * Fired when the touchpad button on this controller is modified
  41031. */
  41032. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41033. /**
  41034. * Fired when the touchpad values on this controller are modified
  41035. */
  41036. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41037. private _updateTrackpad;
  41038. /**
  41039. * Called once per frame by the engine.
  41040. */
  41041. update(): void;
  41042. /**
  41043. * Called once for each button that changed state since the last frame
  41044. * @param buttonIdx Which button index changed
  41045. * @param state New state of the button
  41046. * @param changes Which properties on the state changed since last frame
  41047. */
  41048. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41049. /**
  41050. * Moves the buttons on the controller mesh based on their current state
  41051. * @param buttonName the name of the button to move
  41052. * @param buttonValue the value of the button which determines the buttons new position
  41053. */
  41054. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41055. /**
  41056. * Moves the axis on the controller mesh based on its current state
  41057. * @param axis the index of the axis
  41058. * @param axisValue the value of the axis which determines the meshes new position
  41059. * @hidden
  41060. */
  41061. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41062. /**
  41063. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41064. * @param scene scene in which to add meshes
  41065. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41066. */
  41067. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41068. /**
  41069. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41070. * can be transformed by button presses and axes values, based on this._mapping.
  41071. *
  41072. * @param scene scene in which the meshes exist
  41073. * @param meshes list of meshes that make up the controller model to process
  41074. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41075. */
  41076. private processModel;
  41077. private createMeshInfo;
  41078. /**
  41079. * Gets the ray of the controller in the direction the controller is pointing
  41080. * @param length the length the resulting ray should be
  41081. * @returns a ray in the direction the controller is pointing
  41082. */
  41083. getForwardRay(length?: number): Ray;
  41084. /**
  41085. * Disposes of the controller
  41086. */
  41087. dispose(): void;
  41088. }
  41089. }
  41090. declare module BABYLON {
  41091. /**
  41092. * Single axis scale gizmo
  41093. */
  41094. export class AxisScaleGizmo extends Gizmo {
  41095. private _coloredMaterial;
  41096. /**
  41097. * Drag behavior responsible for the gizmos dragging interactions
  41098. */
  41099. dragBehavior: PointerDragBehavior;
  41100. private _pointerObserver;
  41101. /**
  41102. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41103. */
  41104. snapDistance: number;
  41105. /**
  41106. * Event that fires each time the gizmo snaps to a new location.
  41107. * * snapDistance is the the change in distance
  41108. */
  41109. onSnapObservable: Observable<{
  41110. snapDistance: number;
  41111. }>;
  41112. /**
  41113. * If the scaling operation should be done on all axis (default: false)
  41114. */
  41115. uniformScaling: boolean;
  41116. /**
  41117. * Creates an AxisScaleGizmo
  41118. * @param gizmoLayer The utility layer the gizmo will be added to
  41119. * @param dragAxis The axis which the gizmo will be able to scale on
  41120. * @param color The color of the gizmo
  41121. */
  41122. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41123. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41124. /**
  41125. * Disposes of the gizmo
  41126. */
  41127. dispose(): void;
  41128. /**
  41129. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41130. * @param mesh The mesh to replace the default mesh of the gizmo
  41131. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41132. */
  41133. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41134. }
  41135. }
  41136. declare module BABYLON {
  41137. /**
  41138. * Bounding box gizmo
  41139. */
  41140. export class BoundingBoxGizmo extends Gizmo {
  41141. private _lineBoundingBox;
  41142. private _rotateSpheresParent;
  41143. private _scaleBoxesParent;
  41144. private _boundingDimensions;
  41145. private _renderObserver;
  41146. private _pointerObserver;
  41147. private _scaleDragSpeed;
  41148. private _tmpQuaternion;
  41149. private _tmpVector;
  41150. private _tmpRotationMatrix;
  41151. /**
  41152. * 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)
  41153. */
  41154. ignoreChildren: boolean;
  41155. /**
  41156. * 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)
  41157. */
  41158. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41159. /**
  41160. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41161. */
  41162. rotationSphereSize: number;
  41163. /**
  41164. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41165. */
  41166. scaleBoxSize: number;
  41167. /**
  41168. * 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)
  41169. */
  41170. fixedDragMeshScreenSize: boolean;
  41171. /**
  41172. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41173. */
  41174. fixedDragMeshScreenSizeDistanceFactor: number;
  41175. /**
  41176. * Fired when a rotation sphere or scale box is dragged
  41177. */
  41178. onDragStartObservable: Observable<{}>;
  41179. /**
  41180. * Fired when a scale box is dragged
  41181. */
  41182. onScaleBoxDragObservable: Observable<{}>;
  41183. /**
  41184. * Fired when a scale box drag is ended
  41185. */
  41186. onScaleBoxDragEndObservable: Observable<{}>;
  41187. /**
  41188. * Fired when a rotation sphere is dragged
  41189. */
  41190. onRotationSphereDragObservable: Observable<{}>;
  41191. /**
  41192. * Fired when a rotation sphere drag is ended
  41193. */
  41194. onRotationSphereDragEndObservable: Observable<{}>;
  41195. /**
  41196. * 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)
  41197. */
  41198. scalePivot: Nullable<Vector3>;
  41199. private _anchorMesh;
  41200. private _existingMeshScale;
  41201. private _dragMesh;
  41202. private pointerDragBehavior;
  41203. private coloredMaterial;
  41204. private hoverColoredMaterial;
  41205. /**
  41206. * Sets the color of the bounding box gizmo
  41207. * @param color the color to set
  41208. */
  41209. setColor(color: Color3): void;
  41210. /**
  41211. * Creates an BoundingBoxGizmo
  41212. * @param gizmoLayer The utility layer the gizmo will be added to
  41213. * @param color The color of the gizmo
  41214. */
  41215. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41216. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41217. private _selectNode;
  41218. /**
  41219. * Updates the bounding box information for the Gizmo
  41220. */
  41221. updateBoundingBox(): void;
  41222. private _updateRotationSpheres;
  41223. private _updateScaleBoxes;
  41224. /**
  41225. * Enables rotation on the specified axis and disables rotation on the others
  41226. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41227. */
  41228. setEnabledRotationAxis(axis: string): void;
  41229. /**
  41230. * Enables/disables scaling
  41231. * @param enable if scaling should be enabled
  41232. */
  41233. setEnabledScaling(enable: boolean): void;
  41234. private _updateDummy;
  41235. /**
  41236. * Enables a pointer drag behavior on the bounding box of the gizmo
  41237. */
  41238. enableDragBehavior(): void;
  41239. /**
  41240. * Disposes of the gizmo
  41241. */
  41242. dispose(): void;
  41243. /**
  41244. * 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)
  41245. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41246. * @returns the bounding box mesh with the passed in mesh as a child
  41247. */
  41248. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41249. /**
  41250. * CustomMeshes are not supported by this gizmo
  41251. * @param mesh The mesh to replace the default mesh of the gizmo
  41252. */
  41253. setCustomMesh(mesh: Mesh): void;
  41254. }
  41255. }
  41256. declare module BABYLON {
  41257. /**
  41258. * Single plane rotation gizmo
  41259. */
  41260. export class PlaneRotationGizmo extends Gizmo {
  41261. /**
  41262. * Drag behavior responsible for the gizmos dragging interactions
  41263. */
  41264. dragBehavior: PointerDragBehavior;
  41265. private _pointerObserver;
  41266. /**
  41267. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41268. */
  41269. snapDistance: number;
  41270. /**
  41271. * Event that fires each time the gizmo snaps to a new location.
  41272. * * snapDistance is the the change in distance
  41273. */
  41274. onSnapObservable: Observable<{
  41275. snapDistance: number;
  41276. }>;
  41277. /**
  41278. * Creates a PlaneRotationGizmo
  41279. * @param gizmoLayer The utility layer the gizmo will be added to
  41280. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41281. * @param color The color of the gizmo
  41282. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41283. */
  41284. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41285. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41286. /**
  41287. * Disposes of the gizmo
  41288. */
  41289. dispose(): void;
  41290. }
  41291. }
  41292. declare module BABYLON {
  41293. /**
  41294. * Gizmo that enables rotating a mesh along 3 axis
  41295. */
  41296. export class RotationGizmo extends Gizmo {
  41297. /**
  41298. * Internal gizmo used for interactions on the x axis
  41299. */
  41300. xGizmo: PlaneRotationGizmo;
  41301. /**
  41302. * Internal gizmo used for interactions on the y axis
  41303. */
  41304. yGizmo: PlaneRotationGizmo;
  41305. /**
  41306. * Internal gizmo used for interactions on the z axis
  41307. */
  41308. zGizmo: PlaneRotationGizmo;
  41309. /** Fires an event when any of it's sub gizmos are dragged */
  41310. onDragStartObservable: Observable<{}>;
  41311. /** Fires an event when any of it's sub gizmos are released from dragging */
  41312. onDragEndObservable: Observable<{}>;
  41313. attachedMesh: Nullable<AbstractMesh>;
  41314. /**
  41315. * Creates a RotationGizmo
  41316. * @param gizmoLayer The utility layer the gizmo will be added to
  41317. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41318. */
  41319. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41320. updateGizmoRotationToMatchAttachedMesh: boolean;
  41321. /**
  41322. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41323. */
  41324. snapDistance: number;
  41325. /**
  41326. * Ratio for the scale of the gizmo (Default: 1)
  41327. */
  41328. scaleRatio: number;
  41329. /**
  41330. * Disposes of the gizmo
  41331. */
  41332. dispose(): void;
  41333. /**
  41334. * CustomMeshes are not supported by this gizmo
  41335. * @param mesh The mesh to replace the default mesh of the gizmo
  41336. */
  41337. setCustomMesh(mesh: Mesh): void;
  41338. }
  41339. }
  41340. declare module BABYLON {
  41341. /**
  41342. * Gizmo that enables dragging a mesh along 3 axis
  41343. */
  41344. export class PositionGizmo extends Gizmo {
  41345. /**
  41346. * Internal gizmo used for interactions on the x axis
  41347. */
  41348. xGizmo: AxisDragGizmo;
  41349. /**
  41350. * Internal gizmo used for interactions on the y axis
  41351. */
  41352. yGizmo: AxisDragGizmo;
  41353. /**
  41354. * Internal gizmo used for interactions on the z axis
  41355. */
  41356. zGizmo: AxisDragGizmo;
  41357. /** Fires an event when any of it's sub gizmos are dragged */
  41358. onDragStartObservable: Observable<{}>;
  41359. /** Fires an event when any of it's sub gizmos are released from dragging */
  41360. onDragEndObservable: Observable<{}>;
  41361. attachedMesh: Nullable<AbstractMesh>;
  41362. /**
  41363. * Creates a PositionGizmo
  41364. * @param gizmoLayer The utility layer the gizmo will be added to
  41365. */
  41366. constructor(gizmoLayer?: UtilityLayerRenderer);
  41367. updateGizmoRotationToMatchAttachedMesh: boolean;
  41368. /**
  41369. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41370. */
  41371. snapDistance: number;
  41372. /**
  41373. * Ratio for the scale of the gizmo (Default: 1)
  41374. */
  41375. scaleRatio: number;
  41376. /**
  41377. * Disposes of the gizmo
  41378. */
  41379. dispose(): void;
  41380. /**
  41381. * CustomMeshes are not supported by this gizmo
  41382. * @param mesh The mesh to replace the default mesh of the gizmo
  41383. */
  41384. setCustomMesh(mesh: Mesh): void;
  41385. }
  41386. }
  41387. declare module BABYLON {
  41388. /**
  41389. * Class containing static functions to help procedurally build meshes
  41390. */
  41391. export class PolyhedronBuilder {
  41392. /**
  41393. * Creates a polyhedron mesh
  41394. * * 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
  41395. * * The parameter `size` (positive float, default 1) sets the polygon size
  41396. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  41397. * * 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`
  41398. * * 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
  41399. * * 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)`)
  41400. * * 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
  41401. * * 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
  41402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41403. * * 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
  41404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41405. * @param name defines the name of the mesh
  41406. * @param options defines the options used to create the mesh
  41407. * @param scene defines the hosting scene
  41408. * @returns the polyhedron mesh
  41409. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  41410. */
  41411. static CreatePolyhedron(name: string, options: {
  41412. type?: number;
  41413. size?: number;
  41414. sizeX?: number;
  41415. sizeY?: number;
  41416. sizeZ?: number;
  41417. custom?: any;
  41418. faceUV?: Vector4[];
  41419. faceColors?: Color4[];
  41420. flat?: boolean;
  41421. updatable?: boolean;
  41422. sideOrientation?: number;
  41423. frontUVs?: Vector4;
  41424. backUVs?: Vector4;
  41425. }, scene: Scene): Mesh;
  41426. }
  41427. }
  41428. declare module BABYLON {
  41429. /**
  41430. * Gizmo that enables scaling a mesh along 3 axis
  41431. */
  41432. export class ScaleGizmo extends Gizmo {
  41433. /**
  41434. * Internal gizmo used for interactions on the x axis
  41435. */
  41436. xGizmo: AxisScaleGizmo;
  41437. /**
  41438. * Internal gizmo used for interactions on the y axis
  41439. */
  41440. yGizmo: AxisScaleGizmo;
  41441. /**
  41442. * Internal gizmo used for interactions on the z axis
  41443. */
  41444. zGizmo: AxisScaleGizmo;
  41445. /**
  41446. * Internal gizmo used to scale all axis equally
  41447. */
  41448. uniformScaleGizmo: AxisScaleGizmo;
  41449. /** Fires an event when any of it's sub gizmos are dragged */
  41450. onDragStartObservable: Observable<{}>;
  41451. /** Fires an event when any of it's sub gizmos are released from dragging */
  41452. onDragEndObservable: Observable<{}>;
  41453. attachedMesh: Nullable<AbstractMesh>;
  41454. /**
  41455. * Creates a ScaleGizmo
  41456. * @param gizmoLayer The utility layer the gizmo will be added to
  41457. */
  41458. constructor(gizmoLayer?: UtilityLayerRenderer);
  41459. updateGizmoRotationToMatchAttachedMesh: boolean;
  41460. /**
  41461. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41462. */
  41463. snapDistance: number;
  41464. /**
  41465. * Ratio for the scale of the gizmo (Default: 1)
  41466. */
  41467. scaleRatio: number;
  41468. /**
  41469. * Disposes of the gizmo
  41470. */
  41471. dispose(): void;
  41472. }
  41473. }
  41474. declare module BABYLON {
  41475. /**
  41476. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  41477. */
  41478. export class GizmoManager implements IDisposable {
  41479. private scene;
  41480. /**
  41481. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  41482. */
  41483. gizmos: {
  41484. positionGizmo: Nullable<PositionGizmo>;
  41485. rotationGizmo: Nullable<RotationGizmo>;
  41486. scaleGizmo: Nullable<ScaleGizmo>;
  41487. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  41488. };
  41489. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  41490. clearGizmoOnEmptyPointerEvent: boolean;
  41491. /** Fires an event when the manager is attached to a mesh */
  41492. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  41493. private _gizmosEnabled;
  41494. private _pointerObserver;
  41495. private _attachedMesh;
  41496. private _boundingBoxColor;
  41497. private _defaultUtilityLayer;
  41498. private _defaultKeepDepthUtilityLayer;
  41499. /**
  41500. * When bounding box gizmo is enabled, this can be used to track drag/end events
  41501. */
  41502. boundingBoxDragBehavior: SixDofDragBehavior;
  41503. /**
  41504. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  41505. */
  41506. attachableMeshes: Nullable<Array<AbstractMesh>>;
  41507. /**
  41508. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  41509. */
  41510. usePointerToAttachGizmos: boolean;
  41511. /**
  41512. * Instatiates a gizmo manager
  41513. * @param scene the scene to overlay the gizmos on top of
  41514. */
  41515. constructor(scene: Scene);
  41516. /**
  41517. * Attaches a set of gizmos to the specified mesh
  41518. * @param mesh The mesh the gizmo's should be attached to
  41519. */
  41520. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  41521. /**
  41522. * If the position gizmo is enabled
  41523. */
  41524. positionGizmoEnabled: boolean;
  41525. /**
  41526. * If the rotation gizmo is enabled
  41527. */
  41528. rotationGizmoEnabled: boolean;
  41529. /**
  41530. * If the scale gizmo is enabled
  41531. */
  41532. scaleGizmoEnabled: boolean;
  41533. /**
  41534. * If the boundingBox gizmo is enabled
  41535. */
  41536. boundingBoxGizmoEnabled: boolean;
  41537. /**
  41538. * Disposes of the gizmo manager
  41539. */
  41540. dispose(): void;
  41541. }
  41542. }
  41543. declare module BABYLON {
  41544. /**
  41545. * Gizmo that enables viewing a light
  41546. */
  41547. export class LightGizmo extends Gizmo {
  41548. private _box;
  41549. /**
  41550. * Creates a LightGizmo
  41551. * @param gizmoLayer The utility layer the gizmo will be added to
  41552. */
  41553. constructor(gizmoLayer?: UtilityLayerRenderer);
  41554. private _light;
  41555. /**
  41556. * The light that the gizmo is attached to
  41557. */
  41558. light: Nullable<Light>;
  41559. /**
  41560. * @hidden
  41561. * Updates the gizmo to match the attached mesh's position/rotation
  41562. */
  41563. protected _update(): void;
  41564. }
  41565. }
  41566. declare module BABYLON {
  41567. /** @hidden */
  41568. export var backgroundFragmentDeclaration: {
  41569. name: string;
  41570. shader: string;
  41571. };
  41572. }
  41573. declare module BABYLON {
  41574. /** @hidden */
  41575. export var backgroundUboDeclaration: {
  41576. name: string;
  41577. shader: string;
  41578. };
  41579. }
  41580. declare module BABYLON {
  41581. /** @hidden */
  41582. export var backgroundPixelShader: {
  41583. name: string;
  41584. shader: string;
  41585. };
  41586. }
  41587. declare module BABYLON {
  41588. /** @hidden */
  41589. export var backgroundVertexDeclaration: {
  41590. name: string;
  41591. shader: string;
  41592. };
  41593. }
  41594. declare module BABYLON {
  41595. /** @hidden */
  41596. export var backgroundVertexShader: {
  41597. name: string;
  41598. shader: string;
  41599. };
  41600. }
  41601. declare module BABYLON {
  41602. /**
  41603. * Background material used to create an efficient environement around your scene.
  41604. */
  41605. export class BackgroundMaterial extends PushMaterial {
  41606. /**
  41607. * Standard reflectance value at parallel view angle.
  41608. */
  41609. static StandardReflectance0: number;
  41610. /**
  41611. * Standard reflectance value at grazing angle.
  41612. */
  41613. static StandardReflectance90: number;
  41614. protected _primaryColor: Color3;
  41615. /**
  41616. * Key light Color (multiply against the environement texture)
  41617. */
  41618. primaryColor: Color3;
  41619. protected __perceptualColor: Nullable<Color3>;
  41620. /**
  41621. * Experimental Internal Use Only.
  41622. *
  41623. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  41624. * This acts as a helper to set the primary color to a more "human friendly" value.
  41625. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  41626. * output color as close as possible from the chosen value.
  41627. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  41628. * part of lighting setup.)
  41629. */
  41630. _perceptualColor: Nullable<Color3>;
  41631. protected _primaryColorShadowLevel: float;
  41632. /**
  41633. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  41634. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  41635. */
  41636. primaryColorShadowLevel: float;
  41637. protected _primaryColorHighlightLevel: float;
  41638. /**
  41639. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  41640. * The primary color is used at the level chosen to define what the white area would look.
  41641. */
  41642. primaryColorHighlightLevel: float;
  41643. protected _reflectionTexture: Nullable<BaseTexture>;
  41644. /**
  41645. * Reflection Texture used in the material.
  41646. * Should be author in a specific way for the best result (refer to the documentation).
  41647. */
  41648. reflectionTexture: Nullable<BaseTexture>;
  41649. protected _reflectionBlur: float;
  41650. /**
  41651. * Reflection Texture level of blur.
  41652. *
  41653. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  41654. * texture twice.
  41655. */
  41656. reflectionBlur: float;
  41657. protected _diffuseTexture: Nullable<BaseTexture>;
  41658. /**
  41659. * Diffuse Texture used in the material.
  41660. * Should be author in a specific way for the best result (refer to the documentation).
  41661. */
  41662. diffuseTexture: Nullable<BaseTexture>;
  41663. protected _shadowLights: Nullable<IShadowLight[]>;
  41664. /**
  41665. * Specify the list of lights casting shadow on the material.
  41666. * All scene shadow lights will be included if null.
  41667. */
  41668. shadowLights: Nullable<IShadowLight[]>;
  41669. protected _shadowLevel: float;
  41670. /**
  41671. * Helps adjusting the shadow to a softer level if required.
  41672. * 0 means black shadows and 1 means no shadows.
  41673. */
  41674. shadowLevel: float;
  41675. protected _sceneCenter: Vector3;
  41676. /**
  41677. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  41678. * It is usually zero but might be interesting to modify according to your setup.
  41679. */
  41680. sceneCenter: Vector3;
  41681. protected _opacityFresnel: boolean;
  41682. /**
  41683. * This helps specifying that the material is falling off to the sky box at grazing angle.
  41684. * This helps ensuring a nice transition when the camera goes under the ground.
  41685. */
  41686. opacityFresnel: boolean;
  41687. protected _reflectionFresnel: boolean;
  41688. /**
  41689. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  41690. * This helps adding a mirror texture on the ground.
  41691. */
  41692. reflectionFresnel: boolean;
  41693. protected _reflectionFalloffDistance: number;
  41694. /**
  41695. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  41696. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  41697. */
  41698. reflectionFalloffDistance: number;
  41699. protected _reflectionAmount: number;
  41700. /**
  41701. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  41702. */
  41703. reflectionAmount: number;
  41704. protected _reflectionReflectance0: number;
  41705. /**
  41706. * This specifies the weight of the reflection at grazing angle.
  41707. */
  41708. reflectionReflectance0: number;
  41709. protected _reflectionReflectance90: number;
  41710. /**
  41711. * This specifies the weight of the reflection at a perpendicular point of view.
  41712. */
  41713. reflectionReflectance90: number;
  41714. /**
  41715. * Sets the reflection reflectance fresnel values according to the default standard
  41716. * empirically know to work well :-)
  41717. */
  41718. reflectionStandardFresnelWeight: number;
  41719. protected _useRGBColor: boolean;
  41720. /**
  41721. * Helps to directly use the maps channels instead of their level.
  41722. */
  41723. useRGBColor: boolean;
  41724. protected _enableNoise: boolean;
  41725. /**
  41726. * This helps reducing the banding effect that could occur on the background.
  41727. */
  41728. enableNoise: boolean;
  41729. /**
  41730. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  41731. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  41732. * Recommended to be keep at 1.0 except for special cases.
  41733. */
  41734. fovMultiplier: number;
  41735. private _fovMultiplier;
  41736. /**
  41737. * Enable the FOV adjustment feature controlled by fovMultiplier.
  41738. */
  41739. useEquirectangularFOV: boolean;
  41740. private _maxSimultaneousLights;
  41741. /**
  41742. * Number of Simultaneous lights allowed on the material.
  41743. */
  41744. maxSimultaneousLights: int;
  41745. /**
  41746. * Default configuration related to image processing available in the Background Material.
  41747. */
  41748. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41749. /**
  41750. * Keep track of the image processing observer to allow dispose and replace.
  41751. */
  41752. private _imageProcessingObserver;
  41753. /**
  41754. * Attaches a new image processing configuration to the PBR Material.
  41755. * @param configuration (if null the scene configuration will be use)
  41756. */
  41757. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41758. /**
  41759. * Gets the image processing configuration used either in this material.
  41760. */
  41761. /**
  41762. * Sets the Default image processing configuration used either in the this material.
  41763. *
  41764. * If sets to null, the scene one is in use.
  41765. */
  41766. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  41767. /**
  41768. * Gets wether the color curves effect is enabled.
  41769. */
  41770. /**
  41771. * Sets wether the color curves effect is enabled.
  41772. */
  41773. cameraColorCurvesEnabled: boolean;
  41774. /**
  41775. * Gets wether the color grading effect is enabled.
  41776. */
  41777. /**
  41778. * Gets wether the color grading effect is enabled.
  41779. */
  41780. cameraColorGradingEnabled: boolean;
  41781. /**
  41782. * Gets wether tonemapping is enabled or not.
  41783. */
  41784. /**
  41785. * Sets wether tonemapping is enabled or not
  41786. */
  41787. cameraToneMappingEnabled: boolean;
  41788. /**
  41789. * The camera exposure used on this material.
  41790. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41791. * This corresponds to a photographic exposure.
  41792. */
  41793. /**
  41794. * The camera exposure used on this material.
  41795. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41796. * This corresponds to a photographic exposure.
  41797. */
  41798. cameraExposure: float;
  41799. /**
  41800. * Gets The camera contrast used on this material.
  41801. */
  41802. /**
  41803. * Sets The camera contrast used on this material.
  41804. */
  41805. cameraContrast: float;
  41806. /**
  41807. * Gets the Color Grading 2D Lookup Texture.
  41808. */
  41809. /**
  41810. * Sets the Color Grading 2D Lookup Texture.
  41811. */
  41812. cameraColorGradingTexture: Nullable<BaseTexture>;
  41813. /**
  41814. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41815. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41816. * 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;
  41817. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41818. */
  41819. /**
  41820. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41821. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41822. * 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;
  41823. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41824. */
  41825. cameraColorCurves: Nullable<ColorCurves>;
  41826. /**
  41827. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  41828. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  41829. */
  41830. switchToBGR: boolean;
  41831. private _renderTargets;
  41832. private _reflectionControls;
  41833. private _white;
  41834. private _primaryShadowColor;
  41835. private _primaryHighlightColor;
  41836. /**
  41837. * Instantiates a Background Material in the given scene
  41838. * @param name The friendly name of the material
  41839. * @param scene The scene to add the material to
  41840. */
  41841. constructor(name: string, scene: Scene);
  41842. /**
  41843. * Gets a boolean indicating that current material needs to register RTT
  41844. */
  41845. readonly hasRenderTargetTextures: boolean;
  41846. /**
  41847. * The entire material has been created in order to prevent overdraw.
  41848. * @returns false
  41849. */
  41850. needAlphaTesting(): boolean;
  41851. /**
  41852. * The entire material has been created in order to prevent overdraw.
  41853. * @returns true if blending is enable
  41854. */
  41855. needAlphaBlending(): boolean;
  41856. /**
  41857. * Checks wether the material is ready to be rendered for a given mesh.
  41858. * @param mesh The mesh to render
  41859. * @param subMesh The submesh to check against
  41860. * @param useInstances Specify wether or not the material is used with instances
  41861. * @returns true if all the dependencies are ready (Textures, Effects...)
  41862. */
  41863. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41864. /**
  41865. * Compute the primary color according to the chosen perceptual color.
  41866. */
  41867. private _computePrimaryColorFromPerceptualColor;
  41868. /**
  41869. * Compute the highlights and shadow colors according to their chosen levels.
  41870. */
  41871. private _computePrimaryColors;
  41872. /**
  41873. * Build the uniform buffer used in the material.
  41874. */
  41875. buildUniformLayout(): void;
  41876. /**
  41877. * Unbind the material.
  41878. */
  41879. unbind(): void;
  41880. /**
  41881. * Bind only the world matrix to the material.
  41882. * @param world The world matrix to bind.
  41883. */
  41884. bindOnlyWorldMatrix(world: Matrix): void;
  41885. /**
  41886. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  41887. * @param world The world matrix to bind.
  41888. * @param subMesh The submesh to bind for.
  41889. */
  41890. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41891. /**
  41892. * Dispose the material.
  41893. * @param forceDisposeEffect Force disposal of the associated effect.
  41894. * @param forceDisposeTextures Force disposal of the associated textures.
  41895. */
  41896. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41897. /**
  41898. * Clones the material.
  41899. * @param name The cloned name.
  41900. * @returns The cloned material.
  41901. */
  41902. clone(name: string): BackgroundMaterial;
  41903. /**
  41904. * Serializes the current material to its JSON representation.
  41905. * @returns The JSON representation.
  41906. */
  41907. serialize(): any;
  41908. /**
  41909. * Gets the class name of the material
  41910. * @returns "BackgroundMaterial"
  41911. */
  41912. getClassName(): string;
  41913. /**
  41914. * Parse a JSON input to create back a background material.
  41915. * @param source The JSON data to parse
  41916. * @param scene The scene to create the parsed material in
  41917. * @param rootUrl The root url of the assets the material depends upon
  41918. * @returns the instantiated BackgroundMaterial.
  41919. */
  41920. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  41921. }
  41922. }
  41923. declare module BABYLON {
  41924. /**
  41925. * Represents the different options available during the creation of
  41926. * a Environment helper.
  41927. *
  41928. * This can control the default ground, skybox and image processing setup of your scene.
  41929. */
  41930. export interface IEnvironmentHelperOptions {
  41931. /**
  41932. * Specifies wether or not to create a ground.
  41933. * True by default.
  41934. */
  41935. createGround: boolean;
  41936. /**
  41937. * Specifies the ground size.
  41938. * 15 by default.
  41939. */
  41940. groundSize: number;
  41941. /**
  41942. * The texture used on the ground for the main color.
  41943. * Comes from the BabylonJS CDN by default.
  41944. *
  41945. * Remarks: Can be either a texture or a url.
  41946. */
  41947. groundTexture: string | BaseTexture;
  41948. /**
  41949. * The color mixed in the ground texture by default.
  41950. * BabylonJS clearColor by default.
  41951. */
  41952. groundColor: Color3;
  41953. /**
  41954. * Specifies the ground opacity.
  41955. * 1 by default.
  41956. */
  41957. groundOpacity: number;
  41958. /**
  41959. * Enables the ground to receive shadows.
  41960. * True by default.
  41961. */
  41962. enableGroundShadow: boolean;
  41963. /**
  41964. * Helps preventing the shadow to be fully black on the ground.
  41965. * 0.5 by default.
  41966. */
  41967. groundShadowLevel: number;
  41968. /**
  41969. * Creates a mirror texture attach to the ground.
  41970. * false by default.
  41971. */
  41972. enableGroundMirror: boolean;
  41973. /**
  41974. * Specifies the ground mirror size ratio.
  41975. * 0.3 by default as the default kernel is 64.
  41976. */
  41977. groundMirrorSizeRatio: number;
  41978. /**
  41979. * Specifies the ground mirror blur kernel size.
  41980. * 64 by default.
  41981. */
  41982. groundMirrorBlurKernel: number;
  41983. /**
  41984. * Specifies the ground mirror visibility amount.
  41985. * 1 by default
  41986. */
  41987. groundMirrorAmount: number;
  41988. /**
  41989. * Specifies the ground mirror reflectance weight.
  41990. * This uses the standard weight of the background material to setup the fresnel effect
  41991. * of the mirror.
  41992. * 1 by default.
  41993. */
  41994. groundMirrorFresnelWeight: number;
  41995. /**
  41996. * Specifies the ground mirror Falloff distance.
  41997. * This can helps reducing the size of the reflection.
  41998. * 0 by Default.
  41999. */
  42000. groundMirrorFallOffDistance: number;
  42001. /**
  42002. * Specifies the ground mirror texture type.
  42003. * Unsigned Int by Default.
  42004. */
  42005. groundMirrorTextureType: number;
  42006. /**
  42007. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  42008. * the shown objects.
  42009. */
  42010. groundYBias: number;
  42011. /**
  42012. * Specifies wether or not to create a skybox.
  42013. * True by default.
  42014. */
  42015. createSkybox: boolean;
  42016. /**
  42017. * Specifies the skybox size.
  42018. * 20 by default.
  42019. */
  42020. skyboxSize: number;
  42021. /**
  42022. * The texture used on the skybox for the main color.
  42023. * Comes from the BabylonJS CDN by default.
  42024. *
  42025. * Remarks: Can be either a texture or a url.
  42026. */
  42027. skyboxTexture: string | BaseTexture;
  42028. /**
  42029. * The color mixed in the skybox texture by default.
  42030. * BabylonJS clearColor by default.
  42031. */
  42032. skyboxColor: Color3;
  42033. /**
  42034. * The background rotation around the Y axis of the scene.
  42035. * This helps aligning the key lights of your scene with the background.
  42036. * 0 by default.
  42037. */
  42038. backgroundYRotation: number;
  42039. /**
  42040. * Compute automatically the size of the elements to best fit with the scene.
  42041. */
  42042. sizeAuto: boolean;
  42043. /**
  42044. * Default position of the rootMesh if autoSize is not true.
  42045. */
  42046. rootPosition: Vector3;
  42047. /**
  42048. * Sets up the image processing in the scene.
  42049. * true by default.
  42050. */
  42051. setupImageProcessing: boolean;
  42052. /**
  42053. * The texture used as your environment texture in the scene.
  42054. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  42055. *
  42056. * Remarks: Can be either a texture or a url.
  42057. */
  42058. environmentTexture: string | BaseTexture;
  42059. /**
  42060. * The value of the exposure to apply to the scene.
  42061. * 0.6 by default if setupImageProcessing is true.
  42062. */
  42063. cameraExposure: number;
  42064. /**
  42065. * The value of the contrast to apply to the scene.
  42066. * 1.6 by default if setupImageProcessing is true.
  42067. */
  42068. cameraContrast: number;
  42069. /**
  42070. * Specifies wether or not tonemapping should be enabled in the scene.
  42071. * true by default if setupImageProcessing is true.
  42072. */
  42073. toneMappingEnabled: boolean;
  42074. }
  42075. /**
  42076. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  42077. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  42078. * It also helps with the default setup of your imageProcessing configuration.
  42079. */
  42080. export class EnvironmentHelper {
  42081. /**
  42082. * Default ground texture URL.
  42083. */
  42084. private static _groundTextureCDNUrl;
  42085. /**
  42086. * Default skybox texture URL.
  42087. */
  42088. private static _skyboxTextureCDNUrl;
  42089. /**
  42090. * Default environment texture URL.
  42091. */
  42092. private static _environmentTextureCDNUrl;
  42093. /**
  42094. * Creates the default options for the helper.
  42095. */
  42096. private static _getDefaultOptions;
  42097. private _rootMesh;
  42098. /**
  42099. * Gets the root mesh created by the helper.
  42100. */
  42101. readonly rootMesh: Mesh;
  42102. private _skybox;
  42103. /**
  42104. * Gets the skybox created by the helper.
  42105. */
  42106. readonly skybox: Nullable<Mesh>;
  42107. private _skyboxTexture;
  42108. /**
  42109. * Gets the skybox texture created by the helper.
  42110. */
  42111. readonly skyboxTexture: Nullable<BaseTexture>;
  42112. private _skyboxMaterial;
  42113. /**
  42114. * Gets the skybox material created by the helper.
  42115. */
  42116. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  42117. private _ground;
  42118. /**
  42119. * Gets the ground mesh created by the helper.
  42120. */
  42121. readonly ground: Nullable<Mesh>;
  42122. private _groundTexture;
  42123. /**
  42124. * Gets the ground texture created by the helper.
  42125. */
  42126. readonly groundTexture: Nullable<BaseTexture>;
  42127. private _groundMirror;
  42128. /**
  42129. * Gets the ground mirror created by the helper.
  42130. */
  42131. readonly groundMirror: Nullable<MirrorTexture>;
  42132. /**
  42133. * Gets the ground mirror render list to helps pushing the meshes
  42134. * you wish in the ground reflection.
  42135. */
  42136. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  42137. private _groundMaterial;
  42138. /**
  42139. * Gets the ground material created by the helper.
  42140. */
  42141. readonly groundMaterial: Nullable<BackgroundMaterial>;
  42142. /**
  42143. * Stores the creation options.
  42144. */
  42145. private readonly _scene;
  42146. private _options;
  42147. /**
  42148. * This observable will be notified with any error during the creation of the environment,
  42149. * mainly texture creation errors.
  42150. */
  42151. onErrorObservable: Observable<{
  42152. message?: string;
  42153. exception?: any;
  42154. }>;
  42155. /**
  42156. * constructor
  42157. * @param options Defines the options we want to customize the helper
  42158. * @param scene The scene to add the material to
  42159. */
  42160. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  42161. /**
  42162. * Updates the background according to the new options
  42163. * @param options
  42164. */
  42165. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  42166. /**
  42167. * Sets the primary color of all the available elements.
  42168. * @param color the main color to affect to the ground and the background
  42169. */
  42170. setMainColor(color: Color3): void;
  42171. /**
  42172. * Setup the image processing according to the specified options.
  42173. */
  42174. private _setupImageProcessing;
  42175. /**
  42176. * Setup the environment texture according to the specified options.
  42177. */
  42178. private _setupEnvironmentTexture;
  42179. /**
  42180. * Setup the background according to the specified options.
  42181. */
  42182. private _setupBackground;
  42183. /**
  42184. * Get the scene sizes according to the setup.
  42185. */
  42186. private _getSceneSize;
  42187. /**
  42188. * Setup the ground according to the specified options.
  42189. */
  42190. private _setupGround;
  42191. /**
  42192. * Setup the ground material according to the specified options.
  42193. */
  42194. private _setupGroundMaterial;
  42195. /**
  42196. * Setup the ground diffuse texture according to the specified options.
  42197. */
  42198. private _setupGroundDiffuseTexture;
  42199. /**
  42200. * Setup the ground mirror texture according to the specified options.
  42201. */
  42202. private _setupGroundMirrorTexture;
  42203. /**
  42204. * Setup the ground to receive the mirror texture.
  42205. */
  42206. private _setupMirrorInGroundMaterial;
  42207. /**
  42208. * Setup the skybox according to the specified options.
  42209. */
  42210. private _setupSkybox;
  42211. /**
  42212. * Setup the skybox material according to the specified options.
  42213. */
  42214. private _setupSkyboxMaterial;
  42215. /**
  42216. * Setup the skybox reflection texture according to the specified options.
  42217. */
  42218. private _setupSkyboxReflectionTexture;
  42219. private _errorHandler;
  42220. /**
  42221. * Dispose all the elements created by the Helper.
  42222. */
  42223. dispose(): void;
  42224. }
  42225. }
  42226. declare module BABYLON {
  42227. /**
  42228. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  42229. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  42230. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  42231. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  42232. */
  42233. export class PhotoDome extends TransformNode {
  42234. private _useDirectMapping;
  42235. /**
  42236. * The texture being displayed on the sphere
  42237. */
  42238. protected _photoTexture: Texture;
  42239. /**
  42240. * Gets or sets the texture being displayed on the sphere
  42241. */
  42242. photoTexture: Texture;
  42243. /**
  42244. * Observable raised when an error occured while loading the 360 image
  42245. */
  42246. onLoadErrorObservable: Observable<string>;
  42247. /**
  42248. * The skybox material
  42249. */
  42250. protected _material: BackgroundMaterial;
  42251. /**
  42252. * The surface used for the skybox
  42253. */
  42254. protected _mesh: Mesh;
  42255. /**
  42256. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42257. * Also see the options.resolution property.
  42258. */
  42259. fovMultiplier: number;
  42260. /**
  42261. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  42262. * @param name Element's name, child elements will append suffixes for their own names.
  42263. * @param urlsOfPhoto defines the url of the photo to display
  42264. * @param options defines an object containing optional or exposed sub element properties
  42265. * @param onError defines a callback called when an error occured while loading the texture
  42266. */
  42267. constructor(name: string, urlOfPhoto: string, options: {
  42268. resolution?: number;
  42269. size?: number;
  42270. useDirectMapping?: boolean;
  42271. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  42272. /**
  42273. * Releases resources associated with this node.
  42274. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  42275. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  42276. */
  42277. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  42278. }
  42279. }
  42280. declare module BABYLON {
  42281. /**
  42282. * Class used to host texture specific utilities
  42283. */
  42284. export class TextureTools {
  42285. /**
  42286. * Uses the GPU to create a copy texture rescaled at a given size
  42287. * @param texture Texture to copy from
  42288. * @param width defines the desired width
  42289. * @param height defines the desired height
  42290. * @param useBilinearMode defines if bilinear mode has to be used
  42291. * @return the generated texture
  42292. */
  42293. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  42294. /**
  42295. * Gets an environment BRDF texture for a given scene
  42296. * @param scene defines the hosting scene
  42297. * @returns the environment BRDF texture
  42298. */
  42299. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  42300. private static _environmentBRDFBase64Texture;
  42301. }
  42302. }
  42303. declare module BABYLON {
  42304. /**
  42305. * @hidden
  42306. */
  42307. export interface IMaterialClearCoatDefines {
  42308. CLEARCOAT: boolean;
  42309. CLEARCOAT_DEFAULTIOR: boolean;
  42310. CLEARCOAT_TEXTURE: boolean;
  42311. CLEARCOAT_TEXTUREDIRECTUV: number;
  42312. CLEARCOAT_BUMP: boolean;
  42313. CLEARCOAT_BUMPDIRECTUV: number;
  42314. CLEARCOAT_TINT: boolean;
  42315. CLEARCOAT_TINT_TEXTURE: boolean;
  42316. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  42317. /** @hidden */
  42318. _areTexturesDirty: boolean;
  42319. }
  42320. /**
  42321. * Define the code related to the clear coat parameters of the pbr material.
  42322. */
  42323. export class PBRClearCoatConfiguration {
  42324. /**
  42325. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  42326. * The default fits with a polyurethane material.
  42327. */
  42328. private static readonly _DefaultIndiceOfRefraction;
  42329. private _isEnabled;
  42330. /**
  42331. * Defines if the clear coat is enabled in the material.
  42332. */
  42333. isEnabled: boolean;
  42334. /**
  42335. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  42336. */
  42337. intensity: number;
  42338. /**
  42339. * Defines the clear coat layer roughness.
  42340. */
  42341. roughness: number;
  42342. private _indiceOfRefraction;
  42343. /**
  42344. * Defines the indice of refraction of the clear coat.
  42345. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  42346. * The default fits with a polyurethane material.
  42347. * Changing the default value is more performance intensive.
  42348. */
  42349. indiceOfRefraction: number;
  42350. private _texture;
  42351. /**
  42352. * Stores the clear coat values in a texture.
  42353. */
  42354. texture: Nullable<BaseTexture>;
  42355. private _bumpTexture;
  42356. /**
  42357. * Define the clear coat specific bump texture.
  42358. */
  42359. bumpTexture: Nullable<BaseTexture>;
  42360. private _isTintEnabled;
  42361. /**
  42362. * Defines if the clear coat tint is enabled in the material.
  42363. */
  42364. isTintEnabled: boolean;
  42365. /**
  42366. * Defines if the clear coat tint is enabled in the material.
  42367. * This is only use if tint is enabled
  42368. */
  42369. tintColor: Color3;
  42370. /**
  42371. * Defines if the distance at which the tint color should be found in the
  42372. * clear coat media.
  42373. * This is only use if tint is enabled
  42374. */
  42375. tintColorAtDistance: number;
  42376. /**
  42377. * Defines the clear coat layer thickness.
  42378. * This is only use if tint is enabled
  42379. */
  42380. tintThickness: number;
  42381. private _tintTexture;
  42382. /**
  42383. * Stores the clear tint values in a texture.
  42384. * rgb is tint
  42385. * a is a thickness factor
  42386. */
  42387. tintTexture: Nullable<BaseTexture>;
  42388. /** @hidden */
  42389. private _internalMarkAllSubMeshesAsTexturesDirty;
  42390. /** @hidden */
  42391. _markAllSubMeshesAsTexturesDirty(): void;
  42392. /**
  42393. * Instantiate a new istance of clear coat configuration.
  42394. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  42395. */
  42396. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  42397. /**
  42398. * Specifies that the submesh is ready to be used.
  42399. * @param defines the list of "defines" to update.
  42400. * @param scene defines the scene the material belongs to.
  42401. * @param engine defines the engine the material belongs to.
  42402. * @param disableBumpMap defines wether the material disables bump or not.
  42403. * @returns - boolean indicating that the submesh is ready or not.
  42404. */
  42405. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  42406. /**
  42407. * Checks to see if a texture is used in the material.
  42408. * @param defines the list of "defines" to update.
  42409. * @param scene defines the scene to the material belongs to.
  42410. */
  42411. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  42412. /**
  42413. * Binds the material data.
  42414. * @param uniformBuffer defines the Uniform buffer to fill in.
  42415. * @param scene defines the scene the material belongs to.
  42416. * @param engine defines the engine the material belongs to.
  42417. * @param disableBumpMap defines wether the material disables bump or not.
  42418. * @param isFrozen defines wether the material is frozen or not.
  42419. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  42420. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  42421. */
  42422. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  42423. /**
  42424. * Checks to see if a texture is used in the material.
  42425. * @param texture - Base texture to use.
  42426. * @returns - Boolean specifying if a texture is used in the material.
  42427. */
  42428. hasTexture(texture: BaseTexture): boolean;
  42429. /**
  42430. * Returns an array of the actively used textures.
  42431. * @param activeTextures Array of BaseTextures
  42432. */
  42433. getActiveTextures(activeTextures: BaseTexture[]): void;
  42434. /**
  42435. * Returns the animatable textures.
  42436. * @param animatables Array of animatable textures.
  42437. */
  42438. getAnimatables(animatables: IAnimatable[]): void;
  42439. /**
  42440. * Disposes the resources of the material.
  42441. * @param forceDisposeTextures - Forces the disposal of all textures.
  42442. */
  42443. dispose(forceDisposeTextures?: boolean): void;
  42444. /**
  42445. * Get the current class name of the texture useful for serialization or dynamic coding.
  42446. * @returns "PBRClearCoatConfiguration"
  42447. */
  42448. getClassName(): string;
  42449. /**
  42450. * Makes a duplicate of the current configuration into another one.
  42451. * @param clearCoatConfiguration define the config where to copy the info
  42452. */
  42453. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  42454. /**
  42455. * Serializes this clear coat configuration.
  42456. * @returns - An object with the serialized config.
  42457. */
  42458. serialize(): any;
  42459. /**
  42460. * Parses a Clear Coat Configuration from a serialized object.
  42461. * @param source - Serialized object.
  42462. */
  42463. parse(source: any): void;
  42464. /**
  42465. * Add fallbacks to the effect fallbacks list.
  42466. * @param defines defines the Base texture to use.
  42467. * @param fallbacks defines the current fallback list.
  42468. * @param currentRank defines the current fallback rank.
  42469. * @returns the new fallback rank.
  42470. */
  42471. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  42472. /**
  42473. * Add the required uniforms to the current list.
  42474. * @param uniforms defines the current uniform list.
  42475. */
  42476. static AddUniforms(uniforms: string[]): void;
  42477. /**
  42478. * Add the required samplers to the current list.
  42479. * @param samplers defines the current sampler list.
  42480. */
  42481. static AddSamplers(samplers: string[]): void;
  42482. /**
  42483. * Add the required uniforms to the current buffer.
  42484. * @param uniformBuffer defines the current uniform buffer.
  42485. */
  42486. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  42487. }
  42488. }
  42489. declare module BABYLON {
  42490. /**
  42491. * @hidden
  42492. */
  42493. export interface IMaterialAnisotropicDefines {
  42494. ANISOTROPIC: boolean;
  42495. MAINUV1: boolean;
  42496. _areMiscDirty: boolean;
  42497. _needUVs: boolean;
  42498. }
  42499. /**
  42500. * Define the code related to the anisotropic parameters of the pbr material.
  42501. */
  42502. export class PBRAnisotropicConfiguration {
  42503. private _isEnabled;
  42504. /**
  42505. * Defines if the anisotropy is enabled in the material.
  42506. */
  42507. isEnabled: boolean;
  42508. /**
  42509. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  42510. */
  42511. intensity: number;
  42512. /**
  42513. * Defines if the effect is along the tangents or bitangents.
  42514. * By default, the effect is "strectching" the highlights along the tangents.
  42515. */
  42516. followTangents: boolean;
  42517. /** @hidden */
  42518. private _internalMarkAllSubMeshesAsMiscDirty;
  42519. /** @hidden */
  42520. _markAllSubMeshesAsMiscDirty(): void;
  42521. /**
  42522. * Instantiate a new istance of clear coat configuration.
  42523. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  42524. */
  42525. constructor(markAllSubMeshesAsMiscDirty: () => void);
  42526. /**
  42527. * Checks to see if a texture is used in the material.
  42528. * @param defines the list of "defines" to update.
  42529. * @param mesh the mesh we are preparing the defines for.
  42530. */
  42531. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  42532. /**
  42533. * Binds the material data.
  42534. * @param uniformBuffer defines the Uniform buffer to fill in.
  42535. * @param isFrozen defines wether the material is frozen or not.
  42536. */
  42537. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  42538. /**
  42539. * Get the current class name of the texture useful for serialization or dynamic coding.
  42540. * @returns "PBRAnisotropicConfiguration"
  42541. */
  42542. getClassName(): string;
  42543. /**
  42544. * Makes a duplicate of the current configuration into another one.
  42545. * @param anisotropicConfiguration define the config where to copy the info
  42546. */
  42547. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  42548. /**
  42549. * Serializes this clear coat configuration.
  42550. * @returns - An object with the serialized config.
  42551. */
  42552. serialize(): any;
  42553. /**
  42554. * Parses a Clear Coat Configuration from a serialized object.
  42555. * @param source - Serialized object.
  42556. */
  42557. parse(source: any): void;
  42558. /**
  42559. * Add fallbacks to the effect fallbacks list.
  42560. * @param defines defines the Base texture to use.
  42561. * @param fallbacks defines the current fallback list.
  42562. * @param currentRank defines the current fallback rank.
  42563. * @returns the new fallback rank.
  42564. */
  42565. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  42566. /**
  42567. * Add the required uniforms to the current list.
  42568. * @param uniforms defines the current uniform list.
  42569. */
  42570. static AddUniforms(uniforms: string[]): void;
  42571. /**
  42572. * Add the required uniforms to the current buffer.
  42573. * @param uniformBuffer defines the current uniform buffer.
  42574. */
  42575. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  42576. }
  42577. }
  42578. declare module BABYLON {
  42579. /** @hidden */
  42580. export var pbrFragmentDeclaration: {
  42581. name: string;
  42582. shader: string;
  42583. };
  42584. }
  42585. declare module BABYLON {
  42586. /** @hidden */
  42587. export var pbrUboDeclaration: {
  42588. name: string;
  42589. shader: string;
  42590. };
  42591. }
  42592. declare module BABYLON {
  42593. /** @hidden */
  42594. export var pbrFunctions: {
  42595. name: string;
  42596. shader: string;
  42597. };
  42598. }
  42599. declare module BABYLON {
  42600. /** @hidden */
  42601. export var harmonicsFunctions: {
  42602. name: string;
  42603. shader: string;
  42604. };
  42605. }
  42606. declare module BABYLON {
  42607. /** @hidden */
  42608. export var pbrPreLightingFunctions: {
  42609. name: string;
  42610. shader: string;
  42611. };
  42612. }
  42613. declare module BABYLON {
  42614. /** @hidden */
  42615. export var pbrFalloffLightingFunctions: {
  42616. name: string;
  42617. shader: string;
  42618. };
  42619. }
  42620. declare module BABYLON {
  42621. /** @hidden */
  42622. export var pbrLightingFunctions: {
  42623. name: string;
  42624. shader: string;
  42625. };
  42626. }
  42627. declare module BABYLON {
  42628. /** @hidden */
  42629. export var pbrPixelShader: {
  42630. name: string;
  42631. shader: string;
  42632. };
  42633. }
  42634. declare module BABYLON {
  42635. /** @hidden */
  42636. export var pbrVertexDeclaration: {
  42637. name: string;
  42638. shader: string;
  42639. };
  42640. }
  42641. declare module BABYLON {
  42642. /** @hidden */
  42643. export var pbrVertexShader: {
  42644. name: string;
  42645. shader: string;
  42646. };
  42647. }
  42648. declare module BABYLON {
  42649. /**
  42650. * The Physically based material base class of BJS.
  42651. *
  42652. * This offers the main features of a standard PBR material.
  42653. * For more information, please refer to the documentation :
  42654. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  42655. */
  42656. export abstract class PBRBaseMaterial extends PushMaterial {
  42657. /**
  42658. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  42659. */
  42660. static readonly PBRMATERIAL_OPAQUE: number;
  42661. /**
  42662. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  42663. */
  42664. static readonly PBRMATERIAL_ALPHATEST: number;
  42665. /**
  42666. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42667. */
  42668. static readonly PBRMATERIAL_ALPHABLEND: number;
  42669. /**
  42670. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42671. * They are also discarded below the alpha cutoff threshold to improve performances.
  42672. */
  42673. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  42674. /**
  42675. * Defines the default value of how much AO map is occluding the analytical lights
  42676. * (point spot...).
  42677. */
  42678. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  42679. /**
  42680. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  42681. */
  42682. static readonly LIGHTFALLOFF_PHYSICAL: number;
  42683. /**
  42684. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  42685. * to enhance interoperability with other engines.
  42686. */
  42687. static readonly LIGHTFALLOFF_GLTF: number;
  42688. /**
  42689. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  42690. * to enhance interoperability with other materials.
  42691. */
  42692. static readonly LIGHTFALLOFF_STANDARD: number;
  42693. /**
  42694. * Intensity of the direct lights e.g. the four lights available in your scene.
  42695. * This impacts both the direct diffuse and specular highlights.
  42696. */
  42697. protected _directIntensity: number;
  42698. /**
  42699. * Intensity of the emissive part of the material.
  42700. * This helps controlling the emissive effect without modifying the emissive color.
  42701. */
  42702. protected _emissiveIntensity: number;
  42703. /**
  42704. * Intensity of the environment e.g. how much the environment will light the object
  42705. * either through harmonics for rough material or through the refelction for shiny ones.
  42706. */
  42707. protected _environmentIntensity: number;
  42708. /**
  42709. * This is a special control allowing the reduction of the specular highlights coming from the
  42710. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  42711. */
  42712. protected _specularIntensity: number;
  42713. /**
  42714. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  42715. */
  42716. private _lightingInfos;
  42717. /**
  42718. * Debug Control allowing disabling the bump map on this material.
  42719. */
  42720. protected _disableBumpMap: boolean;
  42721. /**
  42722. * AKA Diffuse Texture in standard nomenclature.
  42723. */
  42724. protected _albedoTexture: BaseTexture;
  42725. /**
  42726. * AKA Occlusion Texture in other nomenclature.
  42727. */
  42728. protected _ambientTexture: BaseTexture;
  42729. /**
  42730. * AKA Occlusion Texture Intensity in other nomenclature.
  42731. */
  42732. protected _ambientTextureStrength: number;
  42733. /**
  42734. * Defines how much the AO map is occluding the analytical lights (point spot...).
  42735. * 1 means it completely occludes it
  42736. * 0 mean it has no impact
  42737. */
  42738. protected _ambientTextureImpactOnAnalyticalLights: number;
  42739. /**
  42740. * Stores the alpha values in a texture.
  42741. */
  42742. protected _opacityTexture: BaseTexture;
  42743. /**
  42744. * Stores the reflection values in a texture.
  42745. */
  42746. protected _reflectionTexture: BaseTexture;
  42747. /**
  42748. * Stores the refraction values in a texture.
  42749. */
  42750. protected _refractionTexture: BaseTexture;
  42751. /**
  42752. * Stores the emissive values in a texture.
  42753. */
  42754. protected _emissiveTexture: BaseTexture;
  42755. /**
  42756. * AKA Specular texture in other nomenclature.
  42757. */
  42758. protected _reflectivityTexture: BaseTexture;
  42759. /**
  42760. * Used to switch from specular/glossiness to metallic/roughness workflow.
  42761. */
  42762. protected _metallicTexture: BaseTexture;
  42763. /**
  42764. * Specifies the metallic scalar of the metallic/roughness workflow.
  42765. * Can also be used to scale the metalness values of the metallic texture.
  42766. */
  42767. protected _metallic: Nullable<number>;
  42768. /**
  42769. * Specifies the roughness scalar of the metallic/roughness workflow.
  42770. * Can also be used to scale the roughness values of the metallic texture.
  42771. */
  42772. protected _roughness: Nullable<number>;
  42773. /**
  42774. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  42775. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  42776. */
  42777. protected _microSurfaceTexture: BaseTexture;
  42778. /**
  42779. * Stores surface normal data used to displace a mesh in a texture.
  42780. */
  42781. protected _bumpTexture: BaseTexture;
  42782. /**
  42783. * Stores the pre-calculated light information of a mesh in a texture.
  42784. */
  42785. protected _lightmapTexture: BaseTexture;
  42786. /**
  42787. * The color of a material in ambient lighting.
  42788. */
  42789. protected _ambientColor: Color3;
  42790. /**
  42791. * AKA Diffuse Color in other nomenclature.
  42792. */
  42793. protected _albedoColor: Color3;
  42794. /**
  42795. * AKA Specular Color in other nomenclature.
  42796. */
  42797. protected _reflectivityColor: Color3;
  42798. /**
  42799. * The color applied when light is reflected from a material.
  42800. */
  42801. protected _reflectionColor: Color3;
  42802. /**
  42803. * The color applied when light is emitted from a material.
  42804. */
  42805. protected _emissiveColor: Color3;
  42806. /**
  42807. * AKA Glossiness in other nomenclature.
  42808. */
  42809. protected _microSurface: number;
  42810. /**
  42811. * source material index of refraction (IOR)' / 'destination material IOR.
  42812. */
  42813. protected _indexOfRefraction: number;
  42814. /**
  42815. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  42816. */
  42817. protected _invertRefractionY: boolean;
  42818. /**
  42819. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  42820. * Materials half opaque for instance using refraction could benefit from this control.
  42821. */
  42822. protected _linkRefractionWithTransparency: boolean;
  42823. /**
  42824. * Specifies that the material will use the light map as a show map.
  42825. */
  42826. protected _useLightmapAsShadowmap: boolean;
  42827. /**
  42828. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  42829. * makes the reflect vector face the model (under horizon).
  42830. */
  42831. protected _useHorizonOcclusion: boolean;
  42832. /**
  42833. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  42834. * too much the area relying on ambient texture to define their ambient occlusion.
  42835. */
  42836. protected _useRadianceOcclusion: boolean;
  42837. /**
  42838. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  42839. */
  42840. protected _useAlphaFromAlbedoTexture: boolean;
  42841. /**
  42842. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  42843. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42844. */
  42845. protected _useSpecularOverAlpha: boolean;
  42846. /**
  42847. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  42848. */
  42849. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  42850. /**
  42851. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  42852. */
  42853. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  42854. /**
  42855. * Specifies if the metallic texture contains the roughness information in its green channel.
  42856. */
  42857. protected _useRoughnessFromMetallicTextureGreen: boolean;
  42858. /**
  42859. * Specifies if the metallic texture contains the metallness information in its blue channel.
  42860. */
  42861. protected _useMetallnessFromMetallicTextureBlue: boolean;
  42862. /**
  42863. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  42864. */
  42865. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  42866. /**
  42867. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  42868. */
  42869. protected _useAmbientInGrayScale: boolean;
  42870. /**
  42871. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  42872. * The material will try to infer what glossiness each pixel should be.
  42873. */
  42874. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  42875. /**
  42876. * Defines the falloff type used in this material.
  42877. * It by default is Physical.
  42878. */
  42879. protected _lightFalloff: number;
  42880. /**
  42881. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42882. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42883. */
  42884. protected _useRadianceOverAlpha: boolean;
  42885. /**
  42886. * Allows using an object space normal map (instead of tangent space).
  42887. */
  42888. protected _useObjectSpaceNormalMap: boolean;
  42889. /**
  42890. * Allows using the bump map in parallax mode.
  42891. */
  42892. protected _useParallax: boolean;
  42893. /**
  42894. * Allows using the bump map in parallax occlusion mode.
  42895. */
  42896. protected _useParallaxOcclusion: boolean;
  42897. /**
  42898. * Controls the scale bias of the parallax mode.
  42899. */
  42900. protected _parallaxScaleBias: number;
  42901. /**
  42902. * If sets to true, disables all the lights affecting the material.
  42903. */
  42904. protected _disableLighting: boolean;
  42905. /**
  42906. * Number of Simultaneous lights allowed on the material.
  42907. */
  42908. protected _maxSimultaneousLights: number;
  42909. /**
  42910. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  42911. */
  42912. protected _invertNormalMapX: boolean;
  42913. /**
  42914. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  42915. */
  42916. protected _invertNormalMapY: boolean;
  42917. /**
  42918. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42919. */
  42920. protected _twoSidedLighting: boolean;
  42921. /**
  42922. * Defines the alpha limits in alpha test mode.
  42923. */
  42924. protected _alphaCutOff: number;
  42925. /**
  42926. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  42927. */
  42928. protected _forceAlphaTest: boolean;
  42929. /**
  42930. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42931. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  42932. */
  42933. protected _useAlphaFresnel: boolean;
  42934. /**
  42935. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42936. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  42937. */
  42938. protected _useLinearAlphaFresnel: boolean;
  42939. /**
  42940. * The transparency mode of the material.
  42941. */
  42942. protected _transparencyMode: Nullable<number>;
  42943. /**
  42944. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  42945. * from cos thetav and roughness:
  42946. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  42947. */
  42948. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  42949. /**
  42950. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  42951. */
  42952. protected _forceIrradianceInFragment: boolean;
  42953. /**
  42954. * Force normal to face away from face.
  42955. */
  42956. protected _forceNormalForward: boolean;
  42957. /**
  42958. * Enables specular anti aliasing in the PBR shader.
  42959. * It will both interacts on the Geometry for analytical and IBL lighting.
  42960. * It also prefilter the roughness map based on the bump values.
  42961. */
  42962. protected _enableSpecularAntiAliasing: boolean;
  42963. /**
  42964. * Default configuration related to image processing available in the PBR Material.
  42965. */
  42966. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42967. /**
  42968. * Keep track of the image processing observer to allow dispose and replace.
  42969. */
  42970. private _imageProcessingObserver;
  42971. /**
  42972. * Attaches a new image processing configuration to the PBR Material.
  42973. * @param configuration
  42974. */
  42975. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42976. /**
  42977. * Stores the available render targets.
  42978. */
  42979. private _renderTargets;
  42980. /**
  42981. * Sets the global ambient color for the material used in lighting calculations.
  42982. */
  42983. private _globalAmbientColor;
  42984. /**
  42985. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  42986. */
  42987. private _useLogarithmicDepth;
  42988. /**
  42989. * If set to true, no lighting calculations will be applied.
  42990. */
  42991. private _unlit;
  42992. /**
  42993. * Defines the clear coat layer parameters for the material.
  42994. */
  42995. readonly clearCoat: PBRClearCoatConfiguration;
  42996. /**
  42997. * Defines the anisotropic parameters for the material.
  42998. */
  42999. readonly anisotropy: PBRAnisotropicConfiguration;
  43000. /**
  43001. * Instantiates a new PBRMaterial instance.
  43002. *
  43003. * @param name The material name
  43004. * @param scene The scene the material will be use in.
  43005. */
  43006. constructor(name: string, scene: Scene);
  43007. /**
  43008. * Gets a boolean indicating that current material needs to register RTT
  43009. */
  43010. readonly hasRenderTargetTextures: boolean;
  43011. /**
  43012. * Gets the name of the material class.
  43013. */
  43014. getClassName(): string;
  43015. /**
  43016. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  43017. */
  43018. /**
  43019. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  43020. */
  43021. useLogarithmicDepth: boolean;
  43022. /**
  43023. * Gets the current transparency mode.
  43024. */
  43025. /**
  43026. * Sets the transparency mode of the material.
  43027. *
  43028. * | Value | Type | Description |
  43029. * | ----- | ----------------------------------- | ----------- |
  43030. * | 0 | OPAQUE | |
  43031. * | 1 | ALPHATEST | |
  43032. * | 2 | ALPHABLEND | |
  43033. * | 3 | ALPHATESTANDBLEND | |
  43034. *
  43035. */
  43036. transparencyMode: Nullable<number>;
  43037. /**
  43038. * Returns true if alpha blending should be disabled.
  43039. */
  43040. private readonly _disableAlphaBlending;
  43041. /**
  43042. * Specifies whether or not this material should be rendered in alpha blend mode.
  43043. */
  43044. needAlphaBlending(): boolean;
  43045. /**
  43046. * Specifies if the mesh will require alpha blending.
  43047. * @param mesh - BJS mesh.
  43048. */
  43049. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  43050. /**
  43051. * Specifies whether or not this material should be rendered in alpha test mode.
  43052. */
  43053. needAlphaTesting(): boolean;
  43054. /**
  43055. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  43056. */
  43057. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  43058. /**
  43059. * Gets the texture used for the alpha test.
  43060. */
  43061. getAlphaTestTexture(): BaseTexture;
  43062. /**
  43063. * Specifies that the submesh is ready to be used.
  43064. * @param mesh - BJS mesh.
  43065. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  43066. * @param useInstances - Specifies that instances should be used.
  43067. * @returns - boolean indicating that the submesh is ready or not.
  43068. */
  43069. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43070. /**
  43071. * Specifies if the material uses metallic roughness workflow.
  43072. * @returns boolean specifiying if the material uses metallic roughness workflow.
  43073. */
  43074. isMetallicWorkflow(): boolean;
  43075. private _prepareEffect;
  43076. private _prepareDefines;
  43077. /**
  43078. * Force shader compilation
  43079. */
  43080. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  43081. clipPlane: boolean;
  43082. }>): void;
  43083. /**
  43084. * Initializes the uniform buffer layout for the shader.
  43085. */
  43086. buildUniformLayout(): void;
  43087. /**
  43088. * Unbinds the textures.
  43089. */
  43090. unbind(): void;
  43091. /**
  43092. * Binds the submesh data.
  43093. * @param world - The world matrix.
  43094. * @param mesh - The BJS mesh.
  43095. * @param subMesh - A submesh of the BJS mesh.
  43096. */
  43097. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43098. /**
  43099. * Returns the animatable textures.
  43100. * @returns - Array of animatable textures.
  43101. */
  43102. getAnimatables(): IAnimatable[];
  43103. /**
  43104. * Returns the texture used for reflections.
  43105. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  43106. */
  43107. private _getReflectionTexture;
  43108. /**
  43109. * Returns the texture used for refraction or null if none is used.
  43110. * @returns - Refection texture if present. If no refraction texture and refraction
  43111. * is linked with transparency, returns environment texture. Otherwise, returns null.
  43112. */
  43113. private _getRefractionTexture;
  43114. /**
  43115. * Returns an array of the actively used textures.
  43116. * @returns - Array of BaseTextures
  43117. */
  43118. getActiveTextures(): BaseTexture[];
  43119. /**
  43120. * Checks to see if a texture is used in the material.
  43121. * @param texture - Base texture to use.
  43122. * @returns - Boolean specifying if a texture is used in the material.
  43123. */
  43124. hasTexture(texture: BaseTexture): boolean;
  43125. /**
  43126. * Disposes the resources of the material.
  43127. * @param forceDisposeEffect - Forces the disposal of effects.
  43128. * @param forceDisposeTextures - Forces the disposal of all textures.
  43129. */
  43130. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43131. }
  43132. }
  43133. declare module BABYLON {
  43134. /**
  43135. * The Physically based material of BJS.
  43136. *
  43137. * This offers the main features of a standard PBR material.
  43138. * For more information, please refer to the documentation :
  43139. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43140. */
  43141. export class PBRMaterial extends PBRBaseMaterial {
  43142. /**
  43143. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  43144. */
  43145. static readonly PBRMATERIAL_OPAQUE: number;
  43146. /**
  43147. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  43148. */
  43149. static readonly PBRMATERIAL_ALPHATEST: number;
  43150. /**
  43151. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43152. */
  43153. static readonly PBRMATERIAL_ALPHABLEND: number;
  43154. /**
  43155. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43156. * They are also discarded below the alpha cutoff threshold to improve performances.
  43157. */
  43158. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  43159. /**
  43160. * Defines the default value of how much AO map is occluding the analytical lights
  43161. * (point spot...).
  43162. */
  43163. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  43164. /**
  43165. * Intensity of the direct lights e.g. the four lights available in your scene.
  43166. * This impacts both the direct diffuse and specular highlights.
  43167. */
  43168. directIntensity: number;
  43169. /**
  43170. * Intensity of the emissive part of the material.
  43171. * This helps controlling the emissive effect without modifying the emissive color.
  43172. */
  43173. emissiveIntensity: number;
  43174. /**
  43175. * Intensity of the environment e.g. how much the environment will light the object
  43176. * either through harmonics for rough material or through the refelction for shiny ones.
  43177. */
  43178. environmentIntensity: number;
  43179. /**
  43180. * This is a special control allowing the reduction of the specular highlights coming from the
  43181. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  43182. */
  43183. specularIntensity: number;
  43184. /**
  43185. * Debug Control allowing disabling the bump map on this material.
  43186. */
  43187. disableBumpMap: boolean;
  43188. /**
  43189. * AKA Diffuse Texture in standard nomenclature.
  43190. */
  43191. albedoTexture: BaseTexture;
  43192. /**
  43193. * AKA Occlusion Texture in other nomenclature.
  43194. */
  43195. ambientTexture: BaseTexture;
  43196. /**
  43197. * AKA Occlusion Texture Intensity in other nomenclature.
  43198. */
  43199. ambientTextureStrength: number;
  43200. /**
  43201. * Defines how much the AO map is occluding the analytical lights (point spot...).
  43202. * 1 means it completely occludes it
  43203. * 0 mean it has no impact
  43204. */
  43205. ambientTextureImpactOnAnalyticalLights: number;
  43206. /**
  43207. * Stores the alpha values in a texture.
  43208. */
  43209. opacityTexture: BaseTexture;
  43210. /**
  43211. * Stores the reflection values in a texture.
  43212. */
  43213. reflectionTexture: Nullable<BaseTexture>;
  43214. /**
  43215. * Stores the emissive values in a texture.
  43216. */
  43217. emissiveTexture: BaseTexture;
  43218. /**
  43219. * AKA Specular texture in other nomenclature.
  43220. */
  43221. reflectivityTexture: BaseTexture;
  43222. /**
  43223. * Used to switch from specular/glossiness to metallic/roughness workflow.
  43224. */
  43225. metallicTexture: BaseTexture;
  43226. /**
  43227. * Specifies the metallic scalar of the metallic/roughness workflow.
  43228. * Can also be used to scale the metalness values of the metallic texture.
  43229. */
  43230. metallic: Nullable<number>;
  43231. /**
  43232. * Specifies the roughness scalar of the metallic/roughness workflow.
  43233. * Can also be used to scale the roughness values of the metallic texture.
  43234. */
  43235. roughness: Nullable<number>;
  43236. /**
  43237. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  43238. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  43239. */
  43240. microSurfaceTexture: BaseTexture;
  43241. /**
  43242. * Stores surface normal data used to displace a mesh in a texture.
  43243. */
  43244. bumpTexture: BaseTexture;
  43245. /**
  43246. * Stores the pre-calculated light information of a mesh in a texture.
  43247. */
  43248. lightmapTexture: BaseTexture;
  43249. /**
  43250. * Stores the refracted light information in a texture.
  43251. */
  43252. refractionTexture: BaseTexture;
  43253. /**
  43254. * The color of a material in ambient lighting.
  43255. */
  43256. ambientColor: Color3;
  43257. /**
  43258. * AKA Diffuse Color in other nomenclature.
  43259. */
  43260. albedoColor: Color3;
  43261. /**
  43262. * AKA Specular Color in other nomenclature.
  43263. */
  43264. reflectivityColor: Color3;
  43265. /**
  43266. * The color reflected from the material.
  43267. */
  43268. reflectionColor: Color3;
  43269. /**
  43270. * The color emitted from the material.
  43271. */
  43272. emissiveColor: Color3;
  43273. /**
  43274. * AKA Glossiness in other nomenclature.
  43275. */
  43276. microSurface: number;
  43277. /**
  43278. * source material index of refraction (IOR)' / 'destination material IOR.
  43279. */
  43280. indexOfRefraction: number;
  43281. /**
  43282. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43283. */
  43284. invertRefractionY: boolean;
  43285. /**
  43286. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43287. * Materials half opaque for instance using refraction could benefit from this control.
  43288. */
  43289. linkRefractionWithTransparency: boolean;
  43290. /**
  43291. * If true, the light map contains occlusion information instead of lighting info.
  43292. */
  43293. useLightmapAsShadowmap: boolean;
  43294. /**
  43295. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  43296. */
  43297. useAlphaFromAlbedoTexture: boolean;
  43298. /**
  43299. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  43300. */
  43301. forceAlphaTest: boolean;
  43302. /**
  43303. * Defines the alpha limits in alpha test mode.
  43304. */
  43305. alphaCutOff: number;
  43306. /**
  43307. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  43308. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  43309. */
  43310. useSpecularOverAlpha: boolean;
  43311. /**
  43312. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  43313. */
  43314. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  43315. /**
  43316. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  43317. */
  43318. useRoughnessFromMetallicTextureAlpha: boolean;
  43319. /**
  43320. * Specifies if the metallic texture contains the roughness information in its green channel.
  43321. */
  43322. useRoughnessFromMetallicTextureGreen: boolean;
  43323. /**
  43324. * Specifies if the metallic texture contains the metallness information in its blue channel.
  43325. */
  43326. useMetallnessFromMetallicTextureBlue: boolean;
  43327. /**
  43328. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  43329. */
  43330. useAmbientOcclusionFromMetallicTextureRed: boolean;
  43331. /**
  43332. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  43333. */
  43334. useAmbientInGrayScale: boolean;
  43335. /**
  43336. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  43337. * The material will try to infer what glossiness each pixel should be.
  43338. */
  43339. useAutoMicroSurfaceFromReflectivityMap: boolean;
  43340. /**
  43341. * BJS is using an harcoded light falloff based on a manually sets up range.
  43342. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  43343. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  43344. */
  43345. /**
  43346. * BJS is using an harcoded light falloff based on a manually sets up range.
  43347. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  43348. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  43349. */
  43350. usePhysicalLightFalloff: boolean;
  43351. /**
  43352. * In order to support the falloff compatibility with gltf, a special mode has been added
  43353. * to reproduce the gltf light falloff.
  43354. */
  43355. /**
  43356. * In order to support the falloff compatibility with gltf, a special mode has been added
  43357. * to reproduce the gltf light falloff.
  43358. */
  43359. useGLTFLightFalloff: boolean;
  43360. /**
  43361. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  43362. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  43363. */
  43364. useRadianceOverAlpha: boolean;
  43365. /**
  43366. * Allows using an object space normal map (instead of tangent space).
  43367. */
  43368. useObjectSpaceNormalMap: boolean;
  43369. /**
  43370. * Allows using the bump map in parallax mode.
  43371. */
  43372. useParallax: boolean;
  43373. /**
  43374. * Allows using the bump map in parallax occlusion mode.
  43375. */
  43376. useParallaxOcclusion: boolean;
  43377. /**
  43378. * Controls the scale bias of the parallax mode.
  43379. */
  43380. parallaxScaleBias: number;
  43381. /**
  43382. * If sets to true, disables all the lights affecting the material.
  43383. */
  43384. disableLighting: boolean;
  43385. /**
  43386. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  43387. */
  43388. forceIrradianceInFragment: boolean;
  43389. /**
  43390. * Number of Simultaneous lights allowed on the material.
  43391. */
  43392. maxSimultaneousLights: number;
  43393. /**
  43394. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  43395. */
  43396. invertNormalMapX: boolean;
  43397. /**
  43398. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  43399. */
  43400. invertNormalMapY: boolean;
  43401. /**
  43402. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  43403. */
  43404. twoSidedLighting: boolean;
  43405. /**
  43406. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43407. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  43408. */
  43409. useAlphaFresnel: boolean;
  43410. /**
  43411. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43412. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  43413. */
  43414. useLinearAlphaFresnel: boolean;
  43415. /**
  43416. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43417. * And/Or occlude the blended part.
  43418. */
  43419. environmentBRDFTexture: Nullable<BaseTexture>;
  43420. /**
  43421. * Force normal to face away from face.
  43422. */
  43423. forceNormalForward: boolean;
  43424. /**
  43425. * Enables specular anti aliasing in the PBR shader.
  43426. * It will both interacts on the Geometry for analytical and IBL lighting.
  43427. * It also prefilter the roughness map based on the bump values.
  43428. */
  43429. enableSpecularAntiAliasing: boolean;
  43430. /**
  43431. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  43432. * makes the reflect vector face the model (under horizon).
  43433. */
  43434. useHorizonOcclusion: boolean;
  43435. /**
  43436. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  43437. * too much the area relying on ambient texture to define their ambient occlusion.
  43438. */
  43439. useRadianceOcclusion: boolean;
  43440. /**
  43441. * If set to true, no lighting calculations will be applied.
  43442. */
  43443. unlit: boolean;
  43444. /**
  43445. * Gets the image processing configuration used either in this material.
  43446. */
  43447. /**
  43448. * Sets the Default image processing configuration used either in the this material.
  43449. *
  43450. * If sets to null, the scene one is in use.
  43451. */
  43452. imageProcessingConfiguration: ImageProcessingConfiguration;
  43453. /**
  43454. * Gets wether the color curves effect is enabled.
  43455. */
  43456. /**
  43457. * Sets wether the color curves effect is enabled.
  43458. */
  43459. cameraColorCurvesEnabled: boolean;
  43460. /**
  43461. * Gets wether the color grading effect is enabled.
  43462. */
  43463. /**
  43464. * Gets wether the color grading effect is enabled.
  43465. */
  43466. cameraColorGradingEnabled: boolean;
  43467. /**
  43468. * Gets wether tonemapping is enabled or not.
  43469. */
  43470. /**
  43471. * Sets wether tonemapping is enabled or not
  43472. */
  43473. cameraToneMappingEnabled: boolean;
  43474. /**
  43475. * The camera exposure used on this material.
  43476. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43477. * This corresponds to a photographic exposure.
  43478. */
  43479. /**
  43480. * The camera exposure used on this material.
  43481. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43482. * This corresponds to a photographic exposure.
  43483. */
  43484. cameraExposure: number;
  43485. /**
  43486. * Gets The camera contrast used on this material.
  43487. */
  43488. /**
  43489. * Sets The camera contrast used on this material.
  43490. */
  43491. cameraContrast: number;
  43492. /**
  43493. * Gets the Color Grading 2D Lookup Texture.
  43494. */
  43495. /**
  43496. * Sets the Color Grading 2D Lookup Texture.
  43497. */
  43498. cameraColorGradingTexture: Nullable<BaseTexture>;
  43499. /**
  43500. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43501. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43502. * 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;
  43503. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43504. */
  43505. /**
  43506. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43507. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43508. * 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;
  43509. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43510. */
  43511. cameraColorCurves: Nullable<ColorCurves>;
  43512. /**
  43513. * Instantiates a new PBRMaterial instance.
  43514. *
  43515. * @param name The material name
  43516. * @param scene The scene the material will be use in.
  43517. */
  43518. constructor(name: string, scene: Scene);
  43519. /**
  43520. * Returns the name of this material class.
  43521. */
  43522. getClassName(): string;
  43523. /**
  43524. * Makes a duplicate of the current material.
  43525. * @param name - name to use for the new material.
  43526. */
  43527. clone(name: string): PBRMaterial;
  43528. /**
  43529. * Serializes this PBR Material.
  43530. * @returns - An object with the serialized material.
  43531. */
  43532. serialize(): any;
  43533. /**
  43534. * Parses a PBR Material from a serialized object.
  43535. * @param source - Serialized object.
  43536. * @param scene - BJS scene instance.
  43537. * @param rootUrl - url for the scene object
  43538. * @returns - PBRMaterial
  43539. */
  43540. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  43541. }
  43542. }
  43543. declare module BABYLON {
  43544. /** @hidden */
  43545. export var _forceSceneHelpersToBundle: boolean;
  43546. interface Scene {
  43547. /**
  43548. * Creates a default light for the scene.
  43549. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  43550. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  43551. */
  43552. createDefaultLight(replace?: boolean): void;
  43553. /**
  43554. * Creates a default camera for the scene.
  43555. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  43556. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  43557. * @param replace has default false, when true replaces the active camera in the scene
  43558. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  43559. */
  43560. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  43561. /**
  43562. * Creates a default camera and a default light.
  43563. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  43564. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  43565. * @param replace has the default false, when true replaces the active camera/light in the scene
  43566. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  43567. */
  43568. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  43569. /**
  43570. * Creates a new sky box
  43571. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  43572. * @param environmentTexture defines the texture to use as environment texture
  43573. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  43574. * @param scale defines the overall scale of the skybox
  43575. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  43576. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  43577. * @returns a new mesh holding the sky box
  43578. */
  43579. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  43580. /**
  43581. * Creates a new environment
  43582. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  43583. * @param options defines the options you can use to configure the environment
  43584. * @returns the new EnvironmentHelper
  43585. */
  43586. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  43587. /**
  43588. * Creates a new VREXperienceHelper
  43589. * @see http://doc.babylonjs.com/how_to/webvr_helper
  43590. * @param webVROptions defines the options used to create the new VREXperienceHelper
  43591. * @returns a new VREXperienceHelper
  43592. */
  43593. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  43594. /**
  43595. * Creates a new XREXperienceHelper
  43596. * @see http://doc.babylonjs.com/how_to/webxr
  43597. * @returns a promise for a new XREXperienceHelper
  43598. */
  43599. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  43600. }
  43601. }
  43602. declare module BABYLON {
  43603. /**
  43604. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  43605. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  43606. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  43607. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43608. */
  43609. export class VideoDome extends TransformNode {
  43610. private _useDirectMapping;
  43611. /**
  43612. * The video texture being displayed on the sphere
  43613. */
  43614. protected _videoTexture: VideoTexture;
  43615. /**
  43616. * Gets the video texture being displayed on the sphere
  43617. */
  43618. readonly videoTexture: VideoTexture;
  43619. /**
  43620. * The skybox material
  43621. */
  43622. protected _material: BackgroundMaterial;
  43623. /**
  43624. * The surface used for the skybox
  43625. */
  43626. protected _mesh: Mesh;
  43627. /**
  43628. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43629. * Also see the options.resolution property.
  43630. */
  43631. fovMultiplier: number;
  43632. /**
  43633. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  43634. * @param name Element's name, child elements will append suffixes for their own names.
  43635. * @param urlsOrVideo defines the url(s) or the video element to use
  43636. * @param options An object containing optional or exposed sub element properties
  43637. */
  43638. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  43639. resolution?: number;
  43640. clickToPlay?: boolean;
  43641. autoPlay?: boolean;
  43642. loop?: boolean;
  43643. size?: number;
  43644. poster?: string;
  43645. useDirectMapping?: boolean;
  43646. }, scene: Scene);
  43647. /**
  43648. * Releases resources associated with this node.
  43649. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43650. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43651. */
  43652. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43653. }
  43654. }
  43655. declare module BABYLON {
  43656. /**
  43657. * This class can be used to get instrumentation data from a Babylon engine
  43658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  43659. */
  43660. export class EngineInstrumentation implements IDisposable {
  43661. /**
  43662. * Define the instrumented engine.
  43663. */
  43664. engine: Engine;
  43665. private _captureGPUFrameTime;
  43666. private _gpuFrameTimeToken;
  43667. private _gpuFrameTime;
  43668. private _captureShaderCompilationTime;
  43669. private _shaderCompilationTime;
  43670. private _onBeginFrameObserver;
  43671. private _onEndFrameObserver;
  43672. private _onBeforeShaderCompilationObserver;
  43673. private _onAfterShaderCompilationObserver;
  43674. /**
  43675. * Gets the perf counter used for GPU frame time
  43676. */
  43677. readonly gpuFrameTimeCounter: PerfCounter;
  43678. /**
  43679. * Gets the GPU frame time capture status
  43680. */
  43681. /**
  43682. * Enable or disable the GPU frame time capture
  43683. */
  43684. captureGPUFrameTime: boolean;
  43685. /**
  43686. * Gets the perf counter used for shader compilation time
  43687. */
  43688. readonly shaderCompilationTimeCounter: PerfCounter;
  43689. /**
  43690. * Gets the shader compilation time capture status
  43691. */
  43692. /**
  43693. * Enable or disable the shader compilation time capture
  43694. */
  43695. captureShaderCompilationTime: boolean;
  43696. /**
  43697. * Instantiates a new engine instrumentation.
  43698. * This class can be used to get instrumentation data from a Babylon engine
  43699. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  43700. * @param engine Defines the engine to instrument
  43701. */
  43702. constructor(
  43703. /**
  43704. * Define the instrumented engine.
  43705. */
  43706. engine: Engine);
  43707. /**
  43708. * Dispose and release associated resources.
  43709. */
  43710. dispose(): void;
  43711. }
  43712. }
  43713. declare module BABYLON {
  43714. /**
  43715. * This class can be used to get instrumentation data from a Babylon engine
  43716. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  43717. */
  43718. export class SceneInstrumentation implements IDisposable {
  43719. /**
  43720. * Defines the scene to instrument
  43721. */
  43722. scene: Scene;
  43723. private _captureActiveMeshesEvaluationTime;
  43724. private _activeMeshesEvaluationTime;
  43725. private _captureRenderTargetsRenderTime;
  43726. private _renderTargetsRenderTime;
  43727. private _captureFrameTime;
  43728. private _frameTime;
  43729. private _captureRenderTime;
  43730. private _renderTime;
  43731. private _captureInterFrameTime;
  43732. private _interFrameTime;
  43733. private _captureParticlesRenderTime;
  43734. private _particlesRenderTime;
  43735. private _captureSpritesRenderTime;
  43736. private _spritesRenderTime;
  43737. private _capturePhysicsTime;
  43738. private _physicsTime;
  43739. private _captureAnimationsTime;
  43740. private _animationsTime;
  43741. private _captureCameraRenderTime;
  43742. private _cameraRenderTime;
  43743. private _onBeforeActiveMeshesEvaluationObserver;
  43744. private _onAfterActiveMeshesEvaluationObserver;
  43745. private _onBeforeRenderTargetsRenderObserver;
  43746. private _onAfterRenderTargetsRenderObserver;
  43747. private _onAfterRenderObserver;
  43748. private _onBeforeDrawPhaseObserver;
  43749. private _onAfterDrawPhaseObserver;
  43750. private _onBeforeAnimationsObserver;
  43751. private _onBeforeParticlesRenderingObserver;
  43752. private _onAfterParticlesRenderingObserver;
  43753. private _onBeforeSpritesRenderingObserver;
  43754. private _onAfterSpritesRenderingObserver;
  43755. private _onBeforePhysicsObserver;
  43756. private _onAfterPhysicsObserver;
  43757. private _onAfterAnimationsObserver;
  43758. private _onBeforeCameraRenderObserver;
  43759. private _onAfterCameraRenderObserver;
  43760. /**
  43761. * Gets the perf counter used for active meshes evaluation time
  43762. */
  43763. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  43764. /**
  43765. * Gets the active meshes evaluation time capture status
  43766. */
  43767. /**
  43768. * Enable or disable the active meshes evaluation time capture
  43769. */
  43770. captureActiveMeshesEvaluationTime: boolean;
  43771. /**
  43772. * Gets the perf counter used for render targets render time
  43773. */
  43774. readonly renderTargetsRenderTimeCounter: PerfCounter;
  43775. /**
  43776. * Gets the render targets render time capture status
  43777. */
  43778. /**
  43779. * Enable or disable the render targets render time capture
  43780. */
  43781. captureRenderTargetsRenderTime: boolean;
  43782. /**
  43783. * Gets the perf counter used for particles render time
  43784. */
  43785. readonly particlesRenderTimeCounter: PerfCounter;
  43786. /**
  43787. * Gets the particles render time capture status
  43788. */
  43789. /**
  43790. * Enable or disable the particles render time capture
  43791. */
  43792. captureParticlesRenderTime: boolean;
  43793. /**
  43794. * Gets the perf counter used for sprites render time
  43795. */
  43796. readonly spritesRenderTimeCounter: PerfCounter;
  43797. /**
  43798. * Gets the sprites render time capture status
  43799. */
  43800. /**
  43801. * Enable or disable the sprites render time capture
  43802. */
  43803. captureSpritesRenderTime: boolean;
  43804. /**
  43805. * Gets the perf counter used for physics time
  43806. */
  43807. readonly physicsTimeCounter: PerfCounter;
  43808. /**
  43809. * Gets the physics time capture status
  43810. */
  43811. /**
  43812. * Enable or disable the physics time capture
  43813. */
  43814. capturePhysicsTime: boolean;
  43815. /**
  43816. * Gets the perf counter used for animations time
  43817. */
  43818. readonly animationsTimeCounter: PerfCounter;
  43819. /**
  43820. * Gets the animations time capture status
  43821. */
  43822. /**
  43823. * Enable or disable the animations time capture
  43824. */
  43825. captureAnimationsTime: boolean;
  43826. /**
  43827. * Gets the perf counter used for frame time capture
  43828. */
  43829. readonly frameTimeCounter: PerfCounter;
  43830. /**
  43831. * Gets the frame time capture status
  43832. */
  43833. /**
  43834. * Enable or disable the frame time capture
  43835. */
  43836. captureFrameTime: boolean;
  43837. /**
  43838. * Gets the perf counter used for inter-frames time capture
  43839. */
  43840. readonly interFrameTimeCounter: PerfCounter;
  43841. /**
  43842. * Gets the inter-frames time capture status
  43843. */
  43844. /**
  43845. * Enable or disable the inter-frames time capture
  43846. */
  43847. captureInterFrameTime: boolean;
  43848. /**
  43849. * Gets the perf counter used for render time capture
  43850. */
  43851. readonly renderTimeCounter: PerfCounter;
  43852. /**
  43853. * Gets the render time capture status
  43854. */
  43855. /**
  43856. * Enable or disable the render time capture
  43857. */
  43858. captureRenderTime: boolean;
  43859. /**
  43860. * Gets the perf counter used for camera render time capture
  43861. */
  43862. readonly cameraRenderTimeCounter: PerfCounter;
  43863. /**
  43864. * Gets the camera render time capture status
  43865. */
  43866. /**
  43867. * Enable or disable the camera render time capture
  43868. */
  43869. captureCameraRenderTime: boolean;
  43870. /**
  43871. * Gets the perf counter used for draw calls
  43872. */
  43873. readonly drawCallsCounter: PerfCounter;
  43874. /**
  43875. * Gets the perf counter used for texture collisions
  43876. */
  43877. readonly textureCollisionsCounter: PerfCounter;
  43878. /**
  43879. * Instantiates a new scene instrumentation.
  43880. * This class can be used to get instrumentation data from a Babylon engine
  43881. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  43882. * @param scene Defines the scene to instrument
  43883. */
  43884. constructor(
  43885. /**
  43886. * Defines the scene to instrument
  43887. */
  43888. scene: Scene);
  43889. /**
  43890. * Dispose and release associated resources.
  43891. */
  43892. dispose(): void;
  43893. }
  43894. }
  43895. declare module BABYLON {
  43896. /** @hidden */
  43897. export var glowMapGenerationPixelShader: {
  43898. name: string;
  43899. shader: string;
  43900. };
  43901. }
  43902. declare module BABYLON {
  43903. /** @hidden */
  43904. export var glowMapGenerationVertexShader: {
  43905. name: string;
  43906. shader: string;
  43907. };
  43908. }
  43909. declare module BABYLON {
  43910. /**
  43911. * Effect layer options. This helps customizing the behaviour
  43912. * of the effect layer.
  43913. */
  43914. export interface IEffectLayerOptions {
  43915. /**
  43916. * Multiplication factor apply to the canvas size to compute the render target size
  43917. * used to generated the objects (the smaller the faster).
  43918. */
  43919. mainTextureRatio: number;
  43920. /**
  43921. * Enforces a fixed size texture to ensure effect stability across devices.
  43922. */
  43923. mainTextureFixedSize?: number;
  43924. /**
  43925. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  43926. */
  43927. alphaBlendingMode: number;
  43928. /**
  43929. * The camera attached to the layer.
  43930. */
  43931. camera: Nullable<Camera>;
  43932. /**
  43933. * The rendering group to draw the layer in.
  43934. */
  43935. renderingGroupId: number;
  43936. }
  43937. /**
  43938. * The effect layer Helps adding post process effect blended with the main pass.
  43939. *
  43940. * This can be for instance use to generate glow or higlight effects on the scene.
  43941. *
  43942. * The effect layer class can not be used directly and is intented to inherited from to be
  43943. * customized per effects.
  43944. */
  43945. export abstract class EffectLayer {
  43946. private _vertexBuffers;
  43947. private _indexBuffer;
  43948. private _cachedDefines;
  43949. private _effectLayerMapGenerationEffect;
  43950. private _effectLayerOptions;
  43951. private _mergeEffect;
  43952. protected _scene: Scene;
  43953. protected _engine: Engine;
  43954. protected _maxSize: number;
  43955. protected _mainTextureDesiredSize: ISize;
  43956. protected _mainTexture: RenderTargetTexture;
  43957. protected _shouldRender: boolean;
  43958. protected _postProcesses: PostProcess[];
  43959. protected _textures: BaseTexture[];
  43960. protected _emissiveTextureAndColor: {
  43961. texture: Nullable<BaseTexture>;
  43962. color: Color4;
  43963. };
  43964. /**
  43965. * The name of the layer
  43966. */
  43967. name: string;
  43968. /**
  43969. * The clear color of the texture used to generate the glow map.
  43970. */
  43971. neutralColor: Color4;
  43972. /**
  43973. * Specifies wether the highlight layer is enabled or not.
  43974. */
  43975. isEnabled: boolean;
  43976. /**
  43977. * Gets the camera attached to the layer.
  43978. */
  43979. readonly camera: Nullable<Camera>;
  43980. /**
  43981. * Gets the rendering group id the layer should render in.
  43982. */
  43983. readonly renderingGroupId: number;
  43984. /**
  43985. * An event triggered when the effect layer has been disposed.
  43986. */
  43987. onDisposeObservable: Observable<EffectLayer>;
  43988. /**
  43989. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  43990. */
  43991. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  43992. /**
  43993. * An event triggered when the generated texture is being merged in the scene.
  43994. */
  43995. onBeforeComposeObservable: Observable<EffectLayer>;
  43996. /**
  43997. * An event triggered when the generated texture has been merged in the scene.
  43998. */
  43999. onAfterComposeObservable: Observable<EffectLayer>;
  44000. /**
  44001. * An event triggered when the efffect layer changes its size.
  44002. */
  44003. onSizeChangedObservable: Observable<EffectLayer>;
  44004. /** @hidden */
  44005. static _SceneComponentInitialization: (scene: Scene) => void;
  44006. /**
  44007. * Instantiates a new effect Layer and references it in the scene.
  44008. * @param name The name of the layer
  44009. * @param scene The scene to use the layer in
  44010. */
  44011. constructor(
  44012. /** The Friendly of the effect in the scene */
  44013. name: string, scene: Scene);
  44014. /**
  44015. * Get the effect name of the layer.
  44016. * @return The effect name
  44017. */
  44018. abstract getEffectName(): string;
  44019. /**
  44020. * Checks for the readiness of the element composing the layer.
  44021. * @param subMesh the mesh to check for
  44022. * @param useInstances specify wether or not to use instances to render the mesh
  44023. * @return true if ready otherwise, false
  44024. */
  44025. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44026. /**
  44027. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  44028. * @returns true if the effect requires stencil during the main canvas render pass.
  44029. */
  44030. abstract needStencil(): boolean;
  44031. /**
  44032. * Create the merge effect. This is the shader use to blit the information back
  44033. * to the main canvas at the end of the scene rendering.
  44034. * @returns The effect containing the shader used to merge the effect on the main canvas
  44035. */
  44036. protected abstract _createMergeEffect(): Effect;
  44037. /**
  44038. * Creates the render target textures and post processes used in the effect layer.
  44039. */
  44040. protected abstract _createTextureAndPostProcesses(): void;
  44041. /**
  44042. * Implementation specific of rendering the generating effect on the main canvas.
  44043. * @param effect The effect used to render through
  44044. */
  44045. protected abstract _internalRender(effect: Effect): void;
  44046. /**
  44047. * Sets the required values for both the emissive texture and and the main color.
  44048. */
  44049. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  44050. /**
  44051. * Free any resources and references associated to a mesh.
  44052. * Internal use
  44053. * @param mesh The mesh to free.
  44054. */
  44055. abstract _disposeMesh(mesh: Mesh): void;
  44056. /**
  44057. * Serializes this layer (Glow or Highlight for example)
  44058. * @returns a serialized layer object
  44059. */
  44060. abstract serialize?(): any;
  44061. /**
  44062. * Initializes the effect layer with the required options.
  44063. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  44064. */
  44065. protected _init(options: Partial<IEffectLayerOptions>): void;
  44066. /**
  44067. * Generates the index buffer of the full screen quad blending to the main canvas.
  44068. */
  44069. private _generateIndexBuffer;
  44070. /**
  44071. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  44072. */
  44073. private _genrateVertexBuffer;
  44074. /**
  44075. * Sets the main texture desired size which is the closest power of two
  44076. * of the engine canvas size.
  44077. */
  44078. private _setMainTextureSize;
  44079. /**
  44080. * Creates the main texture for the effect layer.
  44081. */
  44082. protected _createMainTexture(): void;
  44083. /**
  44084. * Adds specific effects defines.
  44085. * @param defines The defines to add specifics to.
  44086. */
  44087. protected _addCustomEffectDefines(defines: string[]): void;
  44088. /**
  44089. * Checks for the readiness of the element composing the layer.
  44090. * @param subMesh the mesh to check for
  44091. * @param useInstances specify wether or not to use instances to render the mesh
  44092. * @param emissiveTexture the associated emissive texture used to generate the glow
  44093. * @return true if ready otherwise, false
  44094. */
  44095. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  44096. /**
  44097. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  44098. */
  44099. render(): void;
  44100. /**
  44101. * Determine if a given mesh will be used in the current effect.
  44102. * @param mesh mesh to test
  44103. * @returns true if the mesh will be used
  44104. */
  44105. hasMesh(mesh: AbstractMesh): boolean;
  44106. /**
  44107. * Returns true if the layer contains information to display, otherwise false.
  44108. * @returns true if the glow layer should be rendered
  44109. */
  44110. shouldRender(): boolean;
  44111. /**
  44112. * Returns true if the mesh should render, otherwise false.
  44113. * @param mesh The mesh to render
  44114. * @returns true if it should render otherwise false
  44115. */
  44116. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  44117. /**
  44118. * Returns true if the mesh can be rendered, otherwise false.
  44119. * @param mesh The mesh to render
  44120. * @param material The material used on the mesh
  44121. * @returns true if it can be rendered otherwise false
  44122. */
  44123. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  44124. /**
  44125. * Returns true if the mesh should render, otherwise false.
  44126. * @param mesh The mesh to render
  44127. * @returns true if it should render otherwise false
  44128. */
  44129. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  44130. /**
  44131. * Renders the submesh passed in parameter to the generation map.
  44132. */
  44133. protected _renderSubMesh(subMesh: SubMesh): void;
  44134. /**
  44135. * Rebuild the required buffers.
  44136. * @hidden Internal use only.
  44137. */
  44138. _rebuild(): void;
  44139. /**
  44140. * Dispose only the render target textures and post process.
  44141. */
  44142. private _disposeTextureAndPostProcesses;
  44143. /**
  44144. * Dispose the highlight layer and free resources.
  44145. */
  44146. dispose(): void;
  44147. /**
  44148. * Gets the class name of the effect layer
  44149. * @returns the string with the class name of the effect layer
  44150. */
  44151. getClassName(): string;
  44152. /**
  44153. * Creates an effect layer from parsed effect layer data
  44154. * @param parsedEffectLayer defines effect layer data
  44155. * @param scene defines the current scene
  44156. * @param rootUrl defines the root URL containing the effect layer information
  44157. * @returns a parsed effect Layer
  44158. */
  44159. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  44160. }
  44161. }
  44162. declare module BABYLON {
  44163. interface AbstractScene {
  44164. /**
  44165. * The list of effect layers (highlights/glow) added to the scene
  44166. * @see http://doc.babylonjs.com/how_to/highlight_layer
  44167. * @see http://doc.babylonjs.com/how_to/glow_layer
  44168. */
  44169. effectLayers: Array<EffectLayer>;
  44170. /**
  44171. * Removes the given effect layer from this scene.
  44172. * @param toRemove defines the effect layer to remove
  44173. * @returns the index of the removed effect layer
  44174. */
  44175. removeEffectLayer(toRemove: EffectLayer): number;
  44176. /**
  44177. * Adds the given effect layer to this scene
  44178. * @param newEffectLayer defines the effect layer to add
  44179. */
  44180. addEffectLayer(newEffectLayer: EffectLayer): void;
  44181. }
  44182. /**
  44183. * Defines the layer scene component responsible to manage any effect layers
  44184. * in a given scene.
  44185. */
  44186. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  44187. /**
  44188. * The component name helpfull to identify the component in the list of scene components.
  44189. */
  44190. readonly name: string;
  44191. /**
  44192. * The scene the component belongs to.
  44193. */
  44194. scene: Scene;
  44195. private _engine;
  44196. private _renderEffects;
  44197. private _needStencil;
  44198. private _previousStencilState;
  44199. /**
  44200. * Creates a new instance of the component for the given scene
  44201. * @param scene Defines the scene to register the component in
  44202. */
  44203. constructor(scene: Scene);
  44204. /**
  44205. * Registers the component in a given scene
  44206. */
  44207. register(): void;
  44208. /**
  44209. * Rebuilds the elements related to this component in case of
  44210. * context lost for instance.
  44211. */
  44212. rebuild(): void;
  44213. /**
  44214. * Serializes the component data to the specified json object
  44215. * @param serializationObject The object to serialize to
  44216. */
  44217. serialize(serializationObject: any): void;
  44218. /**
  44219. * Adds all the element from the container to the scene
  44220. * @param container the container holding the elements
  44221. */
  44222. addFromContainer(container: AbstractScene): void;
  44223. /**
  44224. * Removes all the elements in the container from the scene
  44225. * @param container contains the elements to remove
  44226. */
  44227. removeFromContainer(container: AbstractScene): void;
  44228. /**
  44229. * Disposes the component and the associated ressources.
  44230. */
  44231. dispose(): void;
  44232. private _isReadyForMesh;
  44233. private _renderMainTexture;
  44234. private _setStencil;
  44235. private _setStencilBack;
  44236. private _draw;
  44237. private _drawCamera;
  44238. private _drawRenderingGroup;
  44239. }
  44240. }
  44241. declare module BABYLON {
  44242. /** @hidden */
  44243. export var glowMapMergePixelShader: {
  44244. name: string;
  44245. shader: string;
  44246. };
  44247. }
  44248. declare module BABYLON {
  44249. /** @hidden */
  44250. export var glowMapMergeVertexShader: {
  44251. name: string;
  44252. shader: string;
  44253. };
  44254. }
  44255. declare module BABYLON {
  44256. interface AbstractScene {
  44257. /**
  44258. * Return a the first highlight layer of the scene with a given name.
  44259. * @param name The name of the highlight layer to look for.
  44260. * @return The highlight layer if found otherwise null.
  44261. */
  44262. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  44263. }
  44264. /**
  44265. * Glow layer options. This helps customizing the behaviour
  44266. * of the glow layer.
  44267. */
  44268. export interface IGlowLayerOptions {
  44269. /**
  44270. * Multiplication factor apply to the canvas size to compute the render target size
  44271. * used to generated the glowing objects (the smaller the faster).
  44272. */
  44273. mainTextureRatio: number;
  44274. /**
  44275. * Enforces a fixed size texture to ensure resize independant blur.
  44276. */
  44277. mainTextureFixedSize?: number;
  44278. /**
  44279. * How big is the kernel of the blur texture.
  44280. */
  44281. blurKernelSize: number;
  44282. /**
  44283. * The camera attached to the layer.
  44284. */
  44285. camera: Nullable<Camera>;
  44286. /**
  44287. * Enable MSAA by chosing the number of samples.
  44288. */
  44289. mainTextureSamples?: number;
  44290. /**
  44291. * The rendering group to draw the layer in.
  44292. */
  44293. renderingGroupId: number;
  44294. }
  44295. /**
  44296. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  44297. *
  44298. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  44299. * glowy meshes to your scene.
  44300. *
  44301. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  44302. */
  44303. export class GlowLayer extends EffectLayer {
  44304. /**
  44305. * Effect Name of the layer.
  44306. */
  44307. static readonly EffectName: string;
  44308. /**
  44309. * The default blur kernel size used for the glow.
  44310. */
  44311. static DefaultBlurKernelSize: number;
  44312. /**
  44313. * The default texture size ratio used for the glow.
  44314. */
  44315. static DefaultTextureRatio: number;
  44316. /**
  44317. * Sets the kernel size of the blur.
  44318. */
  44319. /**
  44320. * Gets the kernel size of the blur.
  44321. */
  44322. blurKernelSize: number;
  44323. /**
  44324. * Sets the glow intensity.
  44325. */
  44326. /**
  44327. * Gets the glow intensity.
  44328. */
  44329. intensity: number;
  44330. private _options;
  44331. private _intensity;
  44332. private _horizontalBlurPostprocess1;
  44333. private _verticalBlurPostprocess1;
  44334. private _horizontalBlurPostprocess2;
  44335. private _verticalBlurPostprocess2;
  44336. private _blurTexture1;
  44337. private _blurTexture2;
  44338. private _postProcesses1;
  44339. private _postProcesses2;
  44340. private _includedOnlyMeshes;
  44341. private _excludedMeshes;
  44342. /**
  44343. * Callback used to let the user override the color selection on a per mesh basis
  44344. */
  44345. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  44346. /**
  44347. * Callback used to let the user override the texture selection on a per mesh basis
  44348. */
  44349. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  44350. /**
  44351. * Instantiates a new glow Layer and references it to the scene.
  44352. * @param name The name of the layer
  44353. * @param scene The scene to use the layer in
  44354. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  44355. */
  44356. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  44357. /**
  44358. * Get the effect name of the layer.
  44359. * @return The effect name
  44360. */
  44361. getEffectName(): string;
  44362. /**
  44363. * Create the merge effect. This is the shader use to blit the information back
  44364. * to the main canvas at the end of the scene rendering.
  44365. */
  44366. protected _createMergeEffect(): Effect;
  44367. /**
  44368. * Creates the render target textures and post processes used in the glow layer.
  44369. */
  44370. protected _createTextureAndPostProcesses(): void;
  44371. /**
  44372. * Checks for the readiness of the element composing the layer.
  44373. * @param subMesh the mesh to check for
  44374. * @param useInstances specify wether or not to use instances to render the mesh
  44375. * @param emissiveTexture the associated emissive texture used to generate the glow
  44376. * @return true if ready otherwise, false
  44377. */
  44378. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44379. /**
  44380. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  44381. */
  44382. needStencil(): boolean;
  44383. /**
  44384. * Returns true if the mesh can be rendered, otherwise false.
  44385. * @param mesh The mesh to render
  44386. * @param material The material used on the mesh
  44387. * @returns true if it can be rendered otherwise false
  44388. */
  44389. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  44390. /**
  44391. * Implementation specific of rendering the generating effect on the main canvas.
  44392. * @param effect The effect used to render through
  44393. */
  44394. protected _internalRender(effect: Effect): void;
  44395. /**
  44396. * Sets the required values for both the emissive texture and and the main color.
  44397. */
  44398. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  44399. /**
  44400. * Returns true if the mesh should render, otherwise false.
  44401. * @param mesh The mesh to render
  44402. * @returns true if it should render otherwise false
  44403. */
  44404. protected _shouldRenderMesh(mesh: Mesh): boolean;
  44405. /**
  44406. * Adds specific effects defines.
  44407. * @param defines The defines to add specifics to.
  44408. */
  44409. protected _addCustomEffectDefines(defines: string[]): void;
  44410. /**
  44411. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  44412. * @param mesh The mesh to exclude from the glow layer
  44413. */
  44414. addExcludedMesh(mesh: Mesh): void;
  44415. /**
  44416. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  44417. * @param mesh The mesh to remove
  44418. */
  44419. removeExcludedMesh(mesh: Mesh): void;
  44420. /**
  44421. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  44422. * @param mesh The mesh to include in the glow layer
  44423. */
  44424. addIncludedOnlyMesh(mesh: Mesh): void;
  44425. /**
  44426. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  44427. * @param mesh The mesh to remove
  44428. */
  44429. removeIncludedOnlyMesh(mesh: Mesh): void;
  44430. /**
  44431. * Determine if a given mesh will be used in the glow layer
  44432. * @param mesh The mesh to test
  44433. * @returns true if the mesh will be highlighted by the current glow layer
  44434. */
  44435. hasMesh(mesh: AbstractMesh): boolean;
  44436. /**
  44437. * Free any resources and references associated to a mesh.
  44438. * Internal use
  44439. * @param mesh The mesh to free.
  44440. * @hidden
  44441. */
  44442. _disposeMesh(mesh: Mesh): void;
  44443. /**
  44444. * Gets the class name of the effect layer
  44445. * @returns the string with the class name of the effect layer
  44446. */
  44447. getClassName(): string;
  44448. /**
  44449. * Serializes this glow layer
  44450. * @returns a serialized glow layer object
  44451. */
  44452. serialize(): any;
  44453. /**
  44454. * Creates a Glow Layer from parsed glow layer data
  44455. * @param parsedGlowLayer defines glow layer data
  44456. * @param scene defines the current scene
  44457. * @param rootUrl defines the root URL containing the glow layer information
  44458. * @returns a parsed Glow Layer
  44459. */
  44460. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  44461. }
  44462. }
  44463. declare module BABYLON {
  44464. /** @hidden */
  44465. export var glowBlurPostProcessPixelShader: {
  44466. name: string;
  44467. shader: string;
  44468. };
  44469. }
  44470. declare module BABYLON {
  44471. interface AbstractScene {
  44472. /**
  44473. * Return a the first highlight layer of the scene with a given name.
  44474. * @param name The name of the highlight layer to look for.
  44475. * @return The highlight layer if found otherwise null.
  44476. */
  44477. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  44478. }
  44479. /**
  44480. * Highlight layer options. This helps customizing the behaviour
  44481. * of the highlight layer.
  44482. */
  44483. export interface IHighlightLayerOptions {
  44484. /**
  44485. * Multiplication factor apply to the canvas size to compute the render target size
  44486. * used to generated the glowing objects (the smaller the faster).
  44487. */
  44488. mainTextureRatio: number;
  44489. /**
  44490. * Enforces a fixed size texture to ensure resize independant blur.
  44491. */
  44492. mainTextureFixedSize?: number;
  44493. /**
  44494. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  44495. * of the picture to blur (the smaller the faster).
  44496. */
  44497. blurTextureSizeRatio: number;
  44498. /**
  44499. * How big in texel of the blur texture is the vertical blur.
  44500. */
  44501. blurVerticalSize: number;
  44502. /**
  44503. * How big in texel of the blur texture is the horizontal blur.
  44504. */
  44505. blurHorizontalSize: number;
  44506. /**
  44507. * Alpha blending mode used to apply the blur. Default is combine.
  44508. */
  44509. alphaBlendingMode: number;
  44510. /**
  44511. * The camera attached to the layer.
  44512. */
  44513. camera: Nullable<Camera>;
  44514. /**
  44515. * Should we display highlight as a solid stroke?
  44516. */
  44517. isStroke?: boolean;
  44518. /**
  44519. * The rendering group to draw the layer in.
  44520. */
  44521. renderingGroupId: number;
  44522. }
  44523. /**
  44524. * The highlight layer Helps adding a glow effect around a mesh.
  44525. *
  44526. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  44527. * glowy meshes to your scene.
  44528. *
  44529. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  44530. */
  44531. export class HighlightLayer extends EffectLayer {
  44532. name: string;
  44533. /**
  44534. * Effect Name of the highlight layer.
  44535. */
  44536. static readonly EffectName: string;
  44537. /**
  44538. * The neutral color used during the preparation of the glow effect.
  44539. * This is black by default as the blend operation is a blend operation.
  44540. */
  44541. static NeutralColor: Color4;
  44542. /**
  44543. * Stencil value used for glowing meshes.
  44544. */
  44545. static GlowingMeshStencilReference: number;
  44546. /**
  44547. * Stencil value used for the other meshes in the scene.
  44548. */
  44549. static NormalMeshStencilReference: number;
  44550. /**
  44551. * Specifies whether or not the inner glow is ACTIVE in the layer.
  44552. */
  44553. innerGlow: boolean;
  44554. /**
  44555. * Specifies whether or not the outer glow is ACTIVE in the layer.
  44556. */
  44557. outerGlow: boolean;
  44558. /**
  44559. * Specifies the horizontal size of the blur.
  44560. */
  44561. /**
  44562. * Gets the horizontal size of the blur.
  44563. */
  44564. blurHorizontalSize: number;
  44565. /**
  44566. * Specifies the vertical size of the blur.
  44567. */
  44568. /**
  44569. * Gets the vertical size of the blur.
  44570. */
  44571. blurVerticalSize: number;
  44572. /**
  44573. * An event triggered when the highlight layer is being blurred.
  44574. */
  44575. onBeforeBlurObservable: Observable<HighlightLayer>;
  44576. /**
  44577. * An event triggered when the highlight layer has been blurred.
  44578. */
  44579. onAfterBlurObservable: Observable<HighlightLayer>;
  44580. private _instanceGlowingMeshStencilReference;
  44581. private _options;
  44582. private _downSamplePostprocess;
  44583. private _horizontalBlurPostprocess;
  44584. private _verticalBlurPostprocess;
  44585. private _blurTexture;
  44586. private _meshes;
  44587. private _excludedMeshes;
  44588. /**
  44589. * Instantiates a new highlight Layer and references it to the scene..
  44590. * @param name The name of the layer
  44591. * @param scene The scene to use the layer in
  44592. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  44593. */
  44594. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  44595. /**
  44596. * Get the effect name of the layer.
  44597. * @return The effect name
  44598. */
  44599. getEffectName(): string;
  44600. /**
  44601. * Create the merge effect. This is the shader use to blit the information back
  44602. * to the main canvas at the end of the scene rendering.
  44603. */
  44604. protected _createMergeEffect(): Effect;
  44605. /**
  44606. * Creates the render target textures and post processes used in the highlight layer.
  44607. */
  44608. protected _createTextureAndPostProcesses(): void;
  44609. /**
  44610. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  44611. */
  44612. needStencil(): boolean;
  44613. /**
  44614. * Checks for the readiness of the element composing the layer.
  44615. * @param subMesh the mesh to check for
  44616. * @param useInstances specify wether or not to use instances to render the mesh
  44617. * @param emissiveTexture the associated emissive texture used to generate the glow
  44618. * @return true if ready otherwise, false
  44619. */
  44620. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44621. /**
  44622. * Implementation specific of rendering the generating effect on the main canvas.
  44623. * @param effect The effect used to render through
  44624. */
  44625. protected _internalRender(effect: Effect): void;
  44626. /**
  44627. * Returns true if the layer contains information to display, otherwise false.
  44628. */
  44629. shouldRender(): boolean;
  44630. /**
  44631. * Returns true if the mesh should render, otherwise false.
  44632. * @param mesh The mesh to render
  44633. * @returns true if it should render otherwise false
  44634. */
  44635. protected _shouldRenderMesh(mesh: Mesh): boolean;
  44636. /**
  44637. * Sets the required values for both the emissive texture and and the main color.
  44638. */
  44639. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  44640. /**
  44641. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  44642. * @param mesh The mesh to exclude from the highlight layer
  44643. */
  44644. addExcludedMesh(mesh: Mesh): void;
  44645. /**
  44646. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  44647. * @param mesh The mesh to highlight
  44648. */
  44649. removeExcludedMesh(mesh: Mesh): void;
  44650. /**
  44651. * Determine if a given mesh will be highlighted by the current HighlightLayer
  44652. * @param mesh mesh to test
  44653. * @returns true if the mesh will be highlighted by the current HighlightLayer
  44654. */
  44655. hasMesh(mesh: AbstractMesh): boolean;
  44656. /**
  44657. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  44658. * @param mesh The mesh to highlight
  44659. * @param color The color of the highlight
  44660. * @param glowEmissiveOnly Extract the glow from the emissive texture
  44661. */
  44662. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  44663. /**
  44664. * Remove a mesh from the highlight layer in order to make it stop glowing.
  44665. * @param mesh The mesh to highlight
  44666. */
  44667. removeMesh(mesh: Mesh): void;
  44668. /**
  44669. * Force the stencil to the normal expected value for none glowing parts
  44670. */
  44671. private _defaultStencilReference;
  44672. /**
  44673. * Free any resources and references associated to a mesh.
  44674. * Internal use
  44675. * @param mesh The mesh to free.
  44676. * @hidden
  44677. */
  44678. _disposeMesh(mesh: Mesh): void;
  44679. /**
  44680. * Dispose the highlight layer and free resources.
  44681. */
  44682. dispose(): void;
  44683. /**
  44684. * Gets the class name of the effect layer
  44685. * @returns the string with the class name of the effect layer
  44686. */
  44687. getClassName(): string;
  44688. /**
  44689. * Serializes this Highlight layer
  44690. * @returns a serialized Highlight layer object
  44691. */
  44692. serialize(): any;
  44693. /**
  44694. * Creates a Highlight layer from parsed Highlight layer data
  44695. * @param parsedHightlightLayer defines the Highlight layer data
  44696. * @param scene defines the current scene
  44697. * @param rootUrl defines the root URL containing the Highlight layer information
  44698. * @returns a parsed Highlight layer
  44699. */
  44700. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  44701. }
  44702. }
  44703. declare module BABYLON {
  44704. /** @hidden */
  44705. export var lensFlarePixelShader: {
  44706. name: string;
  44707. shader: string;
  44708. };
  44709. }
  44710. declare module BABYLON {
  44711. /** @hidden */
  44712. export var lensFlareVertexShader: {
  44713. name: string;
  44714. shader: string;
  44715. };
  44716. }
  44717. declare module BABYLON {
  44718. /**
  44719. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44720. * It is usually composed of several `lensFlare`.
  44721. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44722. */
  44723. export class LensFlareSystem {
  44724. /**
  44725. * Define the name of the lens flare system
  44726. */
  44727. name: string;
  44728. /**
  44729. * List of lens flares used in this system.
  44730. */
  44731. lensFlares: LensFlare[];
  44732. /**
  44733. * Define a limit from the border the lens flare can be visible.
  44734. */
  44735. borderLimit: number;
  44736. /**
  44737. * Define a viewport border we do not want to see the lens flare in.
  44738. */
  44739. viewportBorder: number;
  44740. /**
  44741. * Define a predicate which could limit the list of meshes able to occlude the effect.
  44742. */
  44743. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44744. /**
  44745. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  44746. */
  44747. layerMask: number;
  44748. /**
  44749. * Define the id of the lens flare system in the scene.
  44750. * (equal to name by default)
  44751. */
  44752. id: string;
  44753. private _scene;
  44754. private _emitter;
  44755. private _vertexBuffers;
  44756. private _indexBuffer;
  44757. private _effect;
  44758. private _positionX;
  44759. private _positionY;
  44760. private _isEnabled;
  44761. /** @hidden */
  44762. static _SceneComponentInitialization: (scene: Scene) => void;
  44763. /**
  44764. * Instantiates a lens flare system.
  44765. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44766. * It is usually composed of several `lensFlare`.
  44767. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44768. * @param name Define the name of the lens flare system in the scene
  44769. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  44770. * @param scene Define the scene the lens flare system belongs to
  44771. */
  44772. constructor(
  44773. /**
  44774. * Define the name of the lens flare system
  44775. */
  44776. name: string, emitter: any, scene: Scene);
  44777. /**
  44778. * Define if the lens flare system is enabled.
  44779. */
  44780. isEnabled: boolean;
  44781. /**
  44782. * Get the scene the effects belongs to.
  44783. * @returns the scene holding the lens flare system
  44784. */
  44785. getScene(): Scene;
  44786. /**
  44787. * Get the emitter of the lens flare system.
  44788. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  44789. * @returns the emitter of the lens flare system
  44790. */
  44791. getEmitter(): any;
  44792. /**
  44793. * Set the emitter of the lens flare system.
  44794. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  44795. * @param newEmitter Define the new emitter of the system
  44796. */
  44797. setEmitter(newEmitter: any): void;
  44798. /**
  44799. * Get the lens flare system emitter position.
  44800. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  44801. * @returns the position
  44802. */
  44803. getEmitterPosition(): Vector3;
  44804. /**
  44805. * @hidden
  44806. */
  44807. computeEffectivePosition(globalViewport: Viewport): boolean;
  44808. /** @hidden */
  44809. _isVisible(): boolean;
  44810. /**
  44811. * @hidden
  44812. */
  44813. render(): boolean;
  44814. /**
  44815. * Dispose and release the lens flare with its associated resources.
  44816. */
  44817. dispose(): void;
  44818. /**
  44819. * Parse a lens flare system from a JSON repressentation
  44820. * @param parsedLensFlareSystem Define the JSON to parse
  44821. * @param scene Define the scene the parsed system should be instantiated in
  44822. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  44823. * @returns the parsed system
  44824. */
  44825. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  44826. /**
  44827. * Serialize the current Lens Flare System into a JSON representation.
  44828. * @returns the serialized JSON
  44829. */
  44830. serialize(): any;
  44831. }
  44832. }
  44833. declare module BABYLON {
  44834. /**
  44835. * This represents one of the lens effect in a `lensFlareSystem`.
  44836. * It controls one of the indiviual texture used in the effect.
  44837. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44838. */
  44839. export class LensFlare {
  44840. /**
  44841. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  44842. */
  44843. size: number;
  44844. /**
  44845. * 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.
  44846. */
  44847. position: number;
  44848. /**
  44849. * Define the lens color.
  44850. */
  44851. color: Color3;
  44852. /**
  44853. * Define the lens texture.
  44854. */
  44855. texture: Nullable<Texture>;
  44856. /**
  44857. * Define the alpha mode to render this particular lens.
  44858. */
  44859. alphaMode: number;
  44860. private _system;
  44861. /**
  44862. * Creates a new Lens Flare.
  44863. * This represents one of the lens effect in a `lensFlareSystem`.
  44864. * It controls one of the indiviual texture used in the effect.
  44865. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44866. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  44867. * @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.
  44868. * @param color Define the lens color
  44869. * @param imgUrl Define the lens texture url
  44870. * @param system Define the `lensFlareSystem` this flare is part of
  44871. * @returns The newly created Lens Flare
  44872. */
  44873. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  44874. /**
  44875. * Instantiates a new Lens Flare.
  44876. * This represents one of the lens effect in a `lensFlareSystem`.
  44877. * It controls one of the indiviual texture used in the effect.
  44878. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44879. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  44880. * @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.
  44881. * @param color Define the lens color
  44882. * @param imgUrl Define the lens texture url
  44883. * @param system Define the `lensFlareSystem` this flare is part of
  44884. */
  44885. constructor(
  44886. /**
  44887. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  44888. */
  44889. size: number,
  44890. /**
  44891. * 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.
  44892. */
  44893. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  44894. /**
  44895. * Dispose and release the lens flare with its associated resources.
  44896. */
  44897. dispose(): void;
  44898. }
  44899. }
  44900. declare module BABYLON {
  44901. interface AbstractScene {
  44902. /**
  44903. * The list of lens flare system added to the scene
  44904. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44905. */
  44906. lensFlareSystems: Array<LensFlareSystem>;
  44907. /**
  44908. * Removes the given lens flare system from this scene.
  44909. * @param toRemove The lens flare system to remove
  44910. * @returns The index of the removed lens flare system
  44911. */
  44912. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  44913. /**
  44914. * Adds the given lens flare system to this scene
  44915. * @param newLensFlareSystem The lens flare system to add
  44916. */
  44917. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  44918. /**
  44919. * Gets a lens flare system using its name
  44920. * @param name defines the name to look for
  44921. * @returns the lens flare system or null if not found
  44922. */
  44923. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  44924. /**
  44925. * Gets a lens flare system using its id
  44926. * @param id defines the id to look for
  44927. * @returns the lens flare system or null if not found
  44928. */
  44929. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  44930. }
  44931. /**
  44932. * Defines the lens flare scene component responsible to manage any lens flares
  44933. * in a given scene.
  44934. */
  44935. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  44936. /**
  44937. * The component name helpfull to identify the component in the list of scene components.
  44938. */
  44939. readonly name: string;
  44940. /**
  44941. * The scene the component belongs to.
  44942. */
  44943. scene: Scene;
  44944. /**
  44945. * Creates a new instance of the component for the given scene
  44946. * @param scene Defines the scene to register the component in
  44947. */
  44948. constructor(scene: Scene);
  44949. /**
  44950. * Registers the component in a given scene
  44951. */
  44952. register(): void;
  44953. /**
  44954. * Rebuilds the elements related to this component in case of
  44955. * context lost for instance.
  44956. */
  44957. rebuild(): void;
  44958. /**
  44959. * Adds all the element from the container to the scene
  44960. * @param container the container holding the elements
  44961. */
  44962. addFromContainer(container: AbstractScene): void;
  44963. /**
  44964. * Removes all the elements in the container from the scene
  44965. * @param container contains the elements to remove
  44966. */
  44967. removeFromContainer(container: AbstractScene): void;
  44968. /**
  44969. * Serializes the component data to the specified json object
  44970. * @param serializationObject The object to serialize to
  44971. */
  44972. serialize(serializationObject: any): void;
  44973. /**
  44974. * Disposes the component and the associated ressources.
  44975. */
  44976. dispose(): void;
  44977. private _draw;
  44978. }
  44979. }
  44980. declare module BABYLON {
  44981. /**
  44982. * Defines the shadow generator component responsible to manage any shadow generators
  44983. * in a given scene.
  44984. */
  44985. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44986. /**
  44987. * The component name helpfull to identify the component in the list of scene components.
  44988. */
  44989. readonly name: string;
  44990. /**
  44991. * The scene the component belongs to.
  44992. */
  44993. scene: Scene;
  44994. /**
  44995. * Creates a new instance of the component for the given scene
  44996. * @param scene Defines the scene to register the component in
  44997. */
  44998. constructor(scene: Scene);
  44999. /**
  45000. * Registers the component in a given scene
  45001. */
  45002. register(): void;
  45003. /**
  45004. * Rebuilds the elements related to this component in case of
  45005. * context lost for instance.
  45006. */
  45007. rebuild(): void;
  45008. /**
  45009. * Serializes the component data to the specified json object
  45010. * @param serializationObject The object to serialize to
  45011. */
  45012. serialize(serializationObject: any): void;
  45013. /**
  45014. * Adds all the element from the container to the scene
  45015. * @param container the container holding the elements
  45016. */
  45017. addFromContainer(container: AbstractScene): void;
  45018. /**
  45019. * Removes all the elements in the container from the scene
  45020. * @param container contains the elements to remove
  45021. */
  45022. removeFromContainer(container: AbstractScene): void;
  45023. /**
  45024. * Rebuilds the elements related to this component in case of
  45025. * context lost for instance.
  45026. */
  45027. dispose(): void;
  45028. private _gatherRenderTargets;
  45029. }
  45030. }
  45031. declare module BABYLON {
  45032. /**
  45033. * A directional light is defined by a direction (what a surprise!).
  45034. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45035. * 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.
  45036. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45037. */
  45038. export class DirectionalLight extends ShadowLight {
  45039. private _shadowFrustumSize;
  45040. /**
  45041. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45042. */
  45043. /**
  45044. * Specifies a fix frustum size for the shadow generation.
  45045. */
  45046. shadowFrustumSize: number;
  45047. private _shadowOrthoScale;
  45048. /**
  45049. * Gets the shadow projection scale against the optimal computed one.
  45050. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45051. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45052. */
  45053. /**
  45054. * Sets the shadow projection scale against the optimal computed one.
  45055. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45056. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45057. */
  45058. shadowOrthoScale: number;
  45059. /**
  45060. * Automatically compute the projection matrix to best fit (including all the casters)
  45061. * on each frame.
  45062. */
  45063. autoUpdateExtends: boolean;
  45064. private _orthoLeft;
  45065. private _orthoRight;
  45066. private _orthoTop;
  45067. private _orthoBottom;
  45068. /**
  45069. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45070. * The directional light is emitted from everywhere in the given direction.
  45071. * It can cast shadows.
  45072. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45073. * @param name The friendly name of the light
  45074. * @param direction The direction of the light
  45075. * @param scene The scene the light belongs to
  45076. */
  45077. constructor(name: string, direction: Vector3, scene: Scene);
  45078. /**
  45079. * Returns the string "DirectionalLight".
  45080. * @return The class name
  45081. */
  45082. getClassName(): string;
  45083. /**
  45084. * Returns the integer 1.
  45085. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45086. */
  45087. getTypeID(): number;
  45088. /**
  45089. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45090. * Returns the DirectionalLight Shadow projection matrix.
  45091. */
  45092. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45093. /**
  45094. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45095. * Returns the DirectionalLight Shadow projection matrix.
  45096. */
  45097. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45098. /**
  45099. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45100. * Returns the DirectionalLight Shadow projection matrix.
  45101. */
  45102. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45103. protected _buildUniformLayout(): void;
  45104. /**
  45105. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45106. * @param effect The effect to update
  45107. * @param lightIndex The index of the light in the effect to update
  45108. * @returns The directional light
  45109. */
  45110. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45111. /**
  45112. * Gets the minZ used for shadow according to both the scene and the light.
  45113. *
  45114. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45115. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45116. * @param activeCamera The camera we are returning the min for
  45117. * @returns the depth min z
  45118. */
  45119. getDepthMinZ(activeCamera: Camera): number;
  45120. /**
  45121. * Gets the maxZ used for shadow according to both the scene and the light.
  45122. *
  45123. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45124. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45125. * @param activeCamera The camera we are returning the max for
  45126. * @returns the depth max z
  45127. */
  45128. getDepthMaxZ(activeCamera: Camera): number;
  45129. /**
  45130. * Prepares the list of defines specific to the light type.
  45131. * @param defines the list of defines
  45132. * @param lightIndex defines the index of the light for the effect
  45133. */
  45134. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45135. }
  45136. }
  45137. declare module BABYLON {
  45138. /**
  45139. * A point light is a light defined by an unique point in world space.
  45140. * The light is emitted in every direction from this point.
  45141. * A good example of a point light is a standard light bulb.
  45142. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45143. */
  45144. export class PointLight extends ShadowLight {
  45145. private _shadowAngle;
  45146. /**
  45147. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45148. * This specifies what angle the shadow will use to be created.
  45149. *
  45150. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  45151. */
  45152. /**
  45153. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45154. * This specifies what angle the shadow will use to be created.
  45155. *
  45156. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  45157. */
  45158. shadowAngle: number;
  45159. /**
  45160. * Gets the direction if it has been set.
  45161. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45162. */
  45163. /**
  45164. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45165. */
  45166. direction: Vector3;
  45167. /**
  45168. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  45169. * A PointLight emits the light in every direction.
  45170. * It can cast shadows.
  45171. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  45172. * ```javascript
  45173. * var pointLight = new PointLight("pl", camera.position, scene);
  45174. * ```
  45175. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45176. * @param name The light friendly name
  45177. * @param position The position of the point light in the scene
  45178. * @param scene The scene the lights belongs to
  45179. */
  45180. constructor(name: string, position: Vector3, scene: Scene);
  45181. /**
  45182. * Returns the string "PointLight"
  45183. * @returns the class name
  45184. */
  45185. getClassName(): string;
  45186. /**
  45187. * Returns the integer 0.
  45188. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45189. */
  45190. getTypeID(): number;
  45191. /**
  45192. * Specifies wether or not the shadowmap should be a cube texture.
  45193. * @returns true if the shadowmap needs to be a cube texture.
  45194. */
  45195. needCube(): boolean;
  45196. /**
  45197. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  45198. * @param faceIndex The index of the face we are computed the direction to generate shadow
  45199. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  45200. */
  45201. getShadowDirection(faceIndex?: number): Vector3;
  45202. /**
  45203. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  45204. * - fov = PI / 2
  45205. * - aspect ratio : 1.0
  45206. * - z-near and far equal to the active camera minZ and maxZ.
  45207. * Returns the PointLight.
  45208. */
  45209. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45210. protected _buildUniformLayout(): void;
  45211. /**
  45212. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  45213. * @param effect The effect to update
  45214. * @param lightIndex The index of the light in the effect to update
  45215. * @returns The point light
  45216. */
  45217. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  45218. /**
  45219. * Prepares the list of defines specific to the light type.
  45220. * @param defines the list of defines
  45221. * @param lightIndex defines the index of the light for the effect
  45222. */
  45223. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45224. }
  45225. }
  45226. declare module BABYLON {
  45227. /**
  45228. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45229. * These values define a cone of light starting from the position, emitting toward the direction.
  45230. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45231. * and the exponent defines the speed of the decay of the light with distance (reach).
  45232. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45233. */
  45234. export class SpotLight extends ShadowLight {
  45235. private _angle;
  45236. private _innerAngle;
  45237. private _cosHalfAngle;
  45238. private _lightAngleScale;
  45239. private _lightAngleOffset;
  45240. /**
  45241. * Gets the cone angle of the spot light in Radians.
  45242. */
  45243. /**
  45244. * Sets the cone angle of the spot light in Radians.
  45245. */
  45246. angle: number;
  45247. /**
  45248. * Only used in gltf falloff mode, this defines the angle where
  45249. * the directional falloff will start before cutting at angle which could be seen
  45250. * as outer angle.
  45251. */
  45252. /**
  45253. * Only used in gltf falloff mode, this defines the angle where
  45254. * the directional falloff will start before cutting at angle which could be seen
  45255. * as outer angle.
  45256. */
  45257. innerAngle: number;
  45258. private _shadowAngleScale;
  45259. /**
  45260. * Allows scaling the angle of the light for shadow generation only.
  45261. */
  45262. /**
  45263. * Allows scaling the angle of the light for shadow generation only.
  45264. */
  45265. shadowAngleScale: number;
  45266. /**
  45267. * The light decay speed with the distance from the emission spot.
  45268. */
  45269. exponent: number;
  45270. private _projectionTextureMatrix;
  45271. /**
  45272. * Allows reading the projecton texture
  45273. */
  45274. readonly projectionTextureMatrix: Matrix;
  45275. protected _projectionTextureLightNear: number;
  45276. /**
  45277. * Gets the near clip of the Spotlight for texture projection.
  45278. */
  45279. /**
  45280. * Sets the near clip of the Spotlight for texture projection.
  45281. */
  45282. projectionTextureLightNear: number;
  45283. protected _projectionTextureLightFar: number;
  45284. /**
  45285. * Gets the far clip of the Spotlight for texture projection.
  45286. */
  45287. /**
  45288. * Sets the far clip of the Spotlight for texture projection.
  45289. */
  45290. projectionTextureLightFar: number;
  45291. protected _projectionTextureUpDirection: Vector3;
  45292. /**
  45293. * Gets the Up vector of the Spotlight for texture projection.
  45294. */
  45295. /**
  45296. * Sets the Up vector of the Spotlight for texture projection.
  45297. */
  45298. projectionTextureUpDirection: Vector3;
  45299. private _projectionTexture;
  45300. /**
  45301. * Gets the projection texture of the light.
  45302. */
  45303. /**
  45304. * Sets the projection texture of the light.
  45305. */
  45306. projectionTexture: Nullable<BaseTexture>;
  45307. private _projectionTextureViewLightDirty;
  45308. private _projectionTextureProjectionLightDirty;
  45309. private _projectionTextureDirty;
  45310. private _projectionTextureViewTargetVector;
  45311. private _projectionTextureViewLightMatrix;
  45312. private _projectionTextureProjectionLightMatrix;
  45313. private _projectionTextureScalingMatrix;
  45314. /**
  45315. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45316. * It can cast shadows.
  45317. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45318. * @param name The light friendly name
  45319. * @param position The position of the spot light in the scene
  45320. * @param direction The direction of the light in the scene
  45321. * @param angle The cone angle of the light in Radians
  45322. * @param exponent The light decay speed with the distance from the emission spot
  45323. * @param scene The scene the lights belongs to
  45324. */
  45325. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45326. /**
  45327. * Returns the string "SpotLight".
  45328. * @returns the class name
  45329. */
  45330. getClassName(): string;
  45331. /**
  45332. * Returns the integer 2.
  45333. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45334. */
  45335. getTypeID(): number;
  45336. /**
  45337. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45338. */
  45339. protected _setDirection(value: Vector3): void;
  45340. /**
  45341. * Overrides the position setter to recompute the projection texture view light Matrix.
  45342. */
  45343. protected _setPosition(value: Vector3): void;
  45344. /**
  45345. * 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.
  45346. * Returns the SpotLight.
  45347. */
  45348. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45349. protected _computeProjectionTextureViewLightMatrix(): void;
  45350. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45351. /**
  45352. * Main function for light texture projection matrix computing.
  45353. */
  45354. protected _computeProjectionTextureMatrix(): void;
  45355. protected _buildUniformLayout(): void;
  45356. private _computeAngleValues;
  45357. /**
  45358. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45359. * @param effect The effect to update
  45360. * @param lightIndex The index of the light in the effect to update
  45361. * @returns The spot light
  45362. */
  45363. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45364. /**
  45365. * Disposes the light and the associated resources.
  45366. */
  45367. dispose(): void;
  45368. /**
  45369. * Prepares the list of defines specific to the light type.
  45370. * @param defines the list of defines
  45371. * @param lightIndex defines the index of the light for the effect
  45372. */
  45373. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45374. }
  45375. }
  45376. declare module BABYLON {
  45377. /**
  45378. * Header information of HDR texture files.
  45379. */
  45380. export interface HDRInfo {
  45381. /**
  45382. * The height of the texture in pixels.
  45383. */
  45384. height: number;
  45385. /**
  45386. * The width of the texture in pixels.
  45387. */
  45388. width: number;
  45389. /**
  45390. * The index of the beginning of the data in the binary file.
  45391. */
  45392. dataPosition: number;
  45393. }
  45394. /**
  45395. * This groups tools to convert HDR texture to native colors array.
  45396. */
  45397. export class HDRTools {
  45398. private static Ldexp;
  45399. private static Rgbe2float;
  45400. private static readStringLine;
  45401. /**
  45402. * Reads header information from an RGBE texture stored in a native array.
  45403. * More information on this format are available here:
  45404. * https://en.wikipedia.org/wiki/RGBE_image_format
  45405. *
  45406. * @param uint8array The binary file stored in native array.
  45407. * @return The header information.
  45408. */
  45409. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  45410. /**
  45411. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  45412. * This RGBE texture needs to store the information as a panorama.
  45413. *
  45414. * More information on this format are available here:
  45415. * https://en.wikipedia.org/wiki/RGBE_image_format
  45416. *
  45417. * @param buffer The binary file stored in an array buffer.
  45418. * @param size The expected size of the extracted cubemap.
  45419. * @return The Cube Map information.
  45420. */
  45421. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  45422. /**
  45423. * Returns the pixels data extracted from an RGBE texture.
  45424. * This pixels will be stored left to right up to down in the R G B order in one array.
  45425. *
  45426. * More information on this format are available here:
  45427. * https://en.wikipedia.org/wiki/RGBE_image_format
  45428. *
  45429. * @param uint8array The binary file stored in an array buffer.
  45430. * @param hdrInfo The header information of the file.
  45431. * @return The pixels data in RGB right to left up to down order.
  45432. */
  45433. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  45434. private static RGBE_ReadPixels_RLE;
  45435. }
  45436. }
  45437. declare module BABYLON {
  45438. /**
  45439. * This represents a texture coming from an HDR input.
  45440. *
  45441. * The only supported format is currently panorama picture stored in RGBE format.
  45442. * Example of such files can be found on HDRLib: http://hdrlib.com/
  45443. */
  45444. export class HDRCubeTexture extends BaseTexture {
  45445. private static _facesMapping;
  45446. private _generateHarmonics;
  45447. private _noMipmap;
  45448. private _textureMatrix;
  45449. private _size;
  45450. private _onLoad;
  45451. private _onError;
  45452. /**
  45453. * The texture URL.
  45454. */
  45455. url: string;
  45456. /**
  45457. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  45458. */
  45459. coordinatesMode: number;
  45460. protected _isBlocking: boolean;
  45461. /**
  45462. * Sets wether or not the texture is blocking during loading.
  45463. */
  45464. /**
  45465. * Gets wether or not the texture is blocking during loading.
  45466. */
  45467. isBlocking: boolean;
  45468. protected _rotationY: number;
  45469. /**
  45470. * Sets texture matrix rotation angle around Y axis in radians.
  45471. */
  45472. /**
  45473. * Gets texture matrix rotation angle around Y axis radians.
  45474. */
  45475. rotationY: number;
  45476. /**
  45477. * Gets or sets the center of the bounding box associated with the cube texture
  45478. * It must define where the camera used to render the texture was set
  45479. */
  45480. boundingBoxPosition: Vector3;
  45481. private _boundingBoxSize;
  45482. /**
  45483. * Gets or sets the size of the bounding box associated with the cube texture
  45484. * When defined, the cubemap will switch to local mode
  45485. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  45486. * @example https://www.babylonjs-playground.com/#RNASML
  45487. */
  45488. boundingBoxSize: Vector3;
  45489. /**
  45490. * Instantiates an HDRTexture from the following parameters.
  45491. *
  45492. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  45493. * @param scene The scene the texture will be used in
  45494. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  45495. * @param noMipmap Forces to not generate the mipmap if true
  45496. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  45497. * @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)
  45498. * @param reserved Reserved flag for internal use.
  45499. */
  45500. 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>);
  45501. /**
  45502. * Get the current class name of the texture useful for serialization or dynamic coding.
  45503. * @returns "HDRCubeTexture"
  45504. */
  45505. getClassName(): string;
  45506. /**
  45507. * Occurs when the file is raw .hdr file.
  45508. */
  45509. private loadTexture;
  45510. clone(): HDRCubeTexture;
  45511. delayLoad(): void;
  45512. /**
  45513. * Get the texture reflection matrix used to rotate/transform the reflection.
  45514. * @returns the reflection matrix
  45515. */
  45516. getReflectionTextureMatrix(): Matrix;
  45517. /**
  45518. * Set the texture reflection matrix used to rotate/transform the reflection.
  45519. * @param value Define the reflection matrix to set
  45520. */
  45521. setReflectionTextureMatrix(value: Matrix): void;
  45522. /**
  45523. * Parses a JSON representation of an HDR Texture in order to create the texture
  45524. * @param parsedTexture Define the JSON representation
  45525. * @param scene Define the scene the texture should be created in
  45526. * @param rootUrl Define the root url in case we need to load relative dependencies
  45527. * @returns the newly created texture after parsing
  45528. */
  45529. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  45530. serialize(): any;
  45531. }
  45532. }
  45533. declare module BABYLON {
  45534. /**
  45535. * Class used to control physics engine
  45536. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  45537. */
  45538. export class PhysicsEngine implements IPhysicsEngine {
  45539. private _physicsPlugin;
  45540. /**
  45541. * Global value used to control the smallest number supported by the simulation
  45542. */
  45543. static Epsilon: number;
  45544. private _impostors;
  45545. private _joints;
  45546. /**
  45547. * Gets the gravity vector used by the simulation
  45548. */
  45549. gravity: Vector3;
  45550. /**
  45551. * Factory used to create the default physics plugin.
  45552. * @returns The default physics plugin
  45553. */
  45554. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  45555. /**
  45556. * Creates a new Physics Engine
  45557. * @param gravity defines the gravity vector used by the simulation
  45558. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  45559. */
  45560. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  45561. /**
  45562. * Sets the gravity vector used by the simulation
  45563. * @param gravity defines the gravity vector to use
  45564. */
  45565. setGravity(gravity: Vector3): void;
  45566. /**
  45567. * Set the time step of the physics engine.
  45568. * Default is 1/60.
  45569. * To slow it down, enter 1/600 for example.
  45570. * To speed it up, 1/30
  45571. * @param newTimeStep defines the new timestep to apply to this world.
  45572. */
  45573. setTimeStep(newTimeStep?: number): void;
  45574. /**
  45575. * Get the time step of the physics engine.
  45576. * @returns the current time step
  45577. */
  45578. getTimeStep(): number;
  45579. /**
  45580. * Release all resources
  45581. */
  45582. dispose(): void;
  45583. /**
  45584. * Gets the name of the current physics plugin
  45585. * @returns the name of the plugin
  45586. */
  45587. getPhysicsPluginName(): string;
  45588. /**
  45589. * Adding a new impostor for the impostor tracking.
  45590. * This will be done by the impostor itself.
  45591. * @param impostor the impostor to add
  45592. */
  45593. addImpostor(impostor: PhysicsImpostor): void;
  45594. /**
  45595. * Remove an impostor from the engine.
  45596. * This impostor and its mesh will not longer be updated by the physics engine.
  45597. * @param impostor the impostor to remove
  45598. */
  45599. removeImpostor(impostor: PhysicsImpostor): void;
  45600. /**
  45601. * Add a joint to the physics engine
  45602. * @param mainImpostor defines the main impostor to which the joint is added.
  45603. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  45604. * @param joint defines the joint that will connect both impostors.
  45605. */
  45606. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  45607. /**
  45608. * Removes a joint from the simulation
  45609. * @param mainImpostor defines the impostor used with the joint
  45610. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  45611. * @param joint defines the joint to remove
  45612. */
  45613. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  45614. /**
  45615. * Called by the scene. No need to call it.
  45616. * @param delta defines the timespam between frames
  45617. */
  45618. _step(delta: number): void;
  45619. /**
  45620. * Gets the current plugin used to run the simulation
  45621. * @returns current plugin
  45622. */
  45623. getPhysicsPlugin(): IPhysicsEnginePlugin;
  45624. /**
  45625. * Gets the list of physic impostors
  45626. * @returns an array of PhysicsImpostor
  45627. */
  45628. getImpostors(): Array<PhysicsImpostor>;
  45629. /**
  45630. * Gets the impostor for a physics enabled object
  45631. * @param object defines the object impersonated by the impostor
  45632. * @returns the PhysicsImpostor or null if not found
  45633. */
  45634. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  45635. /**
  45636. * Gets the impostor for a physics body object
  45637. * @param body defines physics body used by the impostor
  45638. * @returns the PhysicsImpostor or null if not found
  45639. */
  45640. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  45641. }
  45642. }
  45643. declare module BABYLON {
  45644. /** @hidden */
  45645. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  45646. private _useDeltaForWorldStep;
  45647. world: any;
  45648. name: string;
  45649. private _physicsMaterials;
  45650. private _fixedTimeStep;
  45651. BJSCANNON: any;
  45652. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  45653. setGravity(gravity: Vector3): void;
  45654. setTimeStep(timeStep: number): void;
  45655. getTimeStep(): number;
  45656. executeStep(delta: number): void;
  45657. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45658. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45659. generatePhysicsBody(impostor: PhysicsImpostor): void;
  45660. private _processChildMeshes;
  45661. removePhysicsBody(impostor: PhysicsImpostor): void;
  45662. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  45663. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  45664. private _addMaterial;
  45665. private _checkWithEpsilon;
  45666. private _createShape;
  45667. private _createHeightmap;
  45668. private _minus90X;
  45669. private _plus90X;
  45670. private _tmpPosition;
  45671. private _tmpDeltaPosition;
  45672. private _tmpUnityRotation;
  45673. private _updatePhysicsBodyTransformation;
  45674. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  45675. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  45676. isSupported(): boolean;
  45677. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45678. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45679. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45680. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45681. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  45682. getBodyMass(impostor: PhysicsImpostor): number;
  45683. getBodyFriction(impostor: PhysicsImpostor): number;
  45684. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  45685. getBodyRestitution(impostor: PhysicsImpostor): number;
  45686. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  45687. sleepBody(impostor: PhysicsImpostor): void;
  45688. wakeUpBody(impostor: PhysicsImpostor): void;
  45689. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  45690. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  45691. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  45692. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  45693. getRadius(impostor: PhysicsImpostor): number;
  45694. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  45695. dispose(): void;
  45696. private _extendNamespace;
  45697. }
  45698. }
  45699. declare module BABYLON {
  45700. /** @hidden */
  45701. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  45702. world: any;
  45703. name: string;
  45704. BJSOIMO: any;
  45705. constructor(iterations?: number, oimoInjection?: any);
  45706. setGravity(gravity: Vector3): void;
  45707. setTimeStep(timeStep: number): void;
  45708. getTimeStep(): number;
  45709. private _tmpImpostorsArray;
  45710. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  45711. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45712. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45713. generatePhysicsBody(impostor: PhysicsImpostor): void;
  45714. private _tmpPositionVector;
  45715. removePhysicsBody(impostor: PhysicsImpostor): void;
  45716. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  45717. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  45718. isSupported(): boolean;
  45719. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  45720. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  45721. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45722. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45723. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45724. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45725. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  45726. getBodyMass(impostor: PhysicsImpostor): number;
  45727. getBodyFriction(impostor: PhysicsImpostor): number;
  45728. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  45729. getBodyRestitution(impostor: PhysicsImpostor): number;
  45730. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  45731. sleepBody(impostor: PhysicsImpostor): void;
  45732. wakeUpBody(impostor: PhysicsImpostor): void;
  45733. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  45734. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  45735. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  45736. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  45737. getRadius(impostor: PhysicsImpostor): number;
  45738. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  45739. dispose(): void;
  45740. }
  45741. }
  45742. declare module BABYLON {
  45743. interface AbstractScene {
  45744. /**
  45745. * The list of reflection probes added to the scene
  45746. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  45747. */
  45748. reflectionProbes: Array<ReflectionProbe>;
  45749. /**
  45750. * Removes the given reflection probe from this scene.
  45751. * @param toRemove The reflection probe to remove
  45752. * @returns The index of the removed reflection probe
  45753. */
  45754. removeReflectionProbe(toRemove: ReflectionProbe): number;
  45755. /**
  45756. * Adds the given reflection probe to this scene.
  45757. * @param newReflectionProbe The reflection probe to add
  45758. */
  45759. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  45760. }
  45761. /**
  45762. * Class used to generate realtime reflection / refraction cube textures
  45763. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  45764. */
  45765. export class ReflectionProbe {
  45766. /** defines the name of the probe */
  45767. name: string;
  45768. private _scene;
  45769. private _renderTargetTexture;
  45770. private _projectionMatrix;
  45771. private _viewMatrix;
  45772. private _target;
  45773. private _add;
  45774. private _attachedMesh;
  45775. private _invertYAxis;
  45776. /** Gets or sets probe position (center of the cube map) */
  45777. position: Vector3;
  45778. /**
  45779. * Creates a new reflection probe
  45780. * @param name defines the name of the probe
  45781. * @param size defines the texture resolution (for each face)
  45782. * @param scene defines the hosting scene
  45783. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  45784. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  45785. */
  45786. constructor(
  45787. /** defines the name of the probe */
  45788. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  45789. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  45790. samples: number;
  45791. /** Gets or sets the refresh rate to use (on every frame by default) */
  45792. refreshRate: number;
  45793. /**
  45794. * Gets the hosting scene
  45795. * @returns a Scene
  45796. */
  45797. getScene(): Scene;
  45798. /** Gets the internal CubeTexture used to render to */
  45799. readonly cubeTexture: RenderTargetTexture;
  45800. /** Gets the list of meshes to render */
  45801. readonly renderList: Nullable<AbstractMesh[]>;
  45802. /**
  45803. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  45804. * @param mesh defines the mesh to attach to
  45805. */
  45806. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45807. /**
  45808. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  45809. * @param renderingGroupId The rendering group id corresponding to its index
  45810. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  45811. */
  45812. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  45813. /**
  45814. * Clean all associated resources
  45815. */
  45816. dispose(): void;
  45817. /**
  45818. * Converts the reflection probe information to a readable string for debug purpose.
  45819. * @param fullDetails Supports for multiple levels of logging within scene loading
  45820. * @returns the human readable reflection probe info
  45821. */
  45822. toString(fullDetails?: boolean): string;
  45823. /**
  45824. * Get the class name of the relfection probe.
  45825. * @returns "ReflectionProbe"
  45826. */
  45827. getClassName(): string;
  45828. /**
  45829. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  45830. * @returns The JSON representation of the texture
  45831. */
  45832. serialize(): any;
  45833. /**
  45834. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  45835. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  45836. * @param scene Define the scene the parsed reflection probe should be instantiated in
  45837. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  45838. * @returns The parsed reflection probe if successful
  45839. */
  45840. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  45841. }
  45842. }
  45843. declare module BABYLON {
  45844. /** @hidden */
  45845. export var _BabylonLoaderRegistered: boolean;
  45846. }
  45847. declare module BABYLON {
  45848. /**
  45849. * The Physically based simple base material of BJS.
  45850. *
  45851. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45852. * It is used as the base class for both the specGloss and metalRough conventions.
  45853. */
  45854. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45855. /**
  45856. * Number of Simultaneous lights allowed on the material.
  45857. */
  45858. maxSimultaneousLights: number;
  45859. /**
  45860. * If sets to true, disables all the lights affecting the material.
  45861. */
  45862. disableLighting: boolean;
  45863. /**
  45864. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45865. */
  45866. environmentTexture: BaseTexture;
  45867. /**
  45868. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45869. */
  45870. invertNormalMapX: boolean;
  45871. /**
  45872. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45873. */
  45874. invertNormalMapY: boolean;
  45875. /**
  45876. * Normal map used in the model.
  45877. */
  45878. normalTexture: BaseTexture;
  45879. /**
  45880. * Emissivie color used to self-illuminate the model.
  45881. */
  45882. emissiveColor: Color3;
  45883. /**
  45884. * Emissivie texture used to self-illuminate the model.
  45885. */
  45886. emissiveTexture: BaseTexture;
  45887. /**
  45888. * Occlusion Channel Strenght.
  45889. */
  45890. occlusionStrength: number;
  45891. /**
  45892. * Occlusion Texture of the material (adding extra occlusion effects).
  45893. */
  45894. occlusionTexture: BaseTexture;
  45895. /**
  45896. * Defines the alpha limits in alpha test mode.
  45897. */
  45898. alphaCutOff: number;
  45899. /**
  45900. * Gets the current double sided mode.
  45901. */
  45902. /**
  45903. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45904. */
  45905. doubleSided: boolean;
  45906. /**
  45907. * Stores the pre-calculated light information of a mesh in a texture.
  45908. */
  45909. lightmapTexture: BaseTexture;
  45910. /**
  45911. * If true, the light map contains occlusion information instead of lighting info.
  45912. */
  45913. useLightmapAsShadowmap: boolean;
  45914. /**
  45915. * Instantiates a new PBRMaterial instance.
  45916. *
  45917. * @param name The material name
  45918. * @param scene The scene the material will be use in.
  45919. */
  45920. constructor(name: string, scene: Scene);
  45921. getClassName(): string;
  45922. }
  45923. }
  45924. declare module BABYLON {
  45925. /**
  45926. * The PBR material of BJS following the metal roughness convention.
  45927. *
  45928. * This fits to the PBR convention in the GLTF definition:
  45929. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  45930. */
  45931. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  45932. /**
  45933. * The base color has two different interpretations depending on the value of metalness.
  45934. * When the material is a metal, the base color is the specific measured reflectance value
  45935. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  45936. * of the material.
  45937. */
  45938. baseColor: Color3;
  45939. /**
  45940. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  45941. * well as opacity information in the alpha channel.
  45942. */
  45943. baseTexture: BaseTexture;
  45944. /**
  45945. * Specifies the metallic scalar value of the material.
  45946. * Can also be used to scale the metalness values of the metallic texture.
  45947. */
  45948. metallic: number;
  45949. /**
  45950. * Specifies the roughness scalar value of the material.
  45951. * Can also be used to scale the roughness values of the metallic texture.
  45952. */
  45953. roughness: number;
  45954. /**
  45955. * Texture containing both the metallic value in the B channel and the
  45956. * roughness value in the G channel to keep better precision.
  45957. */
  45958. metallicRoughnessTexture: BaseTexture;
  45959. /**
  45960. * Instantiates a new PBRMetalRoughnessMaterial instance.
  45961. *
  45962. * @param name The material name
  45963. * @param scene The scene the material will be use in.
  45964. */
  45965. constructor(name: string, scene: Scene);
  45966. /**
  45967. * Return the currrent class name of the material.
  45968. */
  45969. getClassName(): string;
  45970. /**
  45971. * Makes a duplicate of the current material.
  45972. * @param name - name to use for the new material.
  45973. */
  45974. clone(name: string): PBRMetallicRoughnessMaterial;
  45975. /**
  45976. * Serialize the material to a parsable JSON object.
  45977. */
  45978. serialize(): any;
  45979. /**
  45980. * Parses a JSON object correponding to the serialize function.
  45981. */
  45982. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  45983. }
  45984. }
  45985. declare module BABYLON {
  45986. /**
  45987. * The PBR material of BJS following the specular glossiness convention.
  45988. *
  45989. * This fits to the PBR convention in the GLTF definition:
  45990. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  45991. */
  45992. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  45993. /**
  45994. * Specifies the diffuse color of the material.
  45995. */
  45996. diffuseColor: Color3;
  45997. /**
  45998. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  45999. * channel.
  46000. */
  46001. diffuseTexture: BaseTexture;
  46002. /**
  46003. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46004. */
  46005. specularColor: Color3;
  46006. /**
  46007. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46008. */
  46009. glossiness: number;
  46010. /**
  46011. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46012. */
  46013. specularGlossinessTexture: BaseTexture;
  46014. /**
  46015. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46016. *
  46017. * @param name The material name
  46018. * @param scene The scene the material will be use in.
  46019. */
  46020. constructor(name: string, scene: Scene);
  46021. /**
  46022. * Return the currrent class name of the material.
  46023. */
  46024. getClassName(): string;
  46025. /**
  46026. * Makes a duplicate of the current material.
  46027. * @param name - name to use for the new material.
  46028. */
  46029. clone(name: string): PBRSpecularGlossinessMaterial;
  46030. /**
  46031. * Serialize the material to a parsable JSON object.
  46032. */
  46033. serialize(): any;
  46034. /**
  46035. * Parses a JSON object correponding to the serialize function.
  46036. */
  46037. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46038. }
  46039. }
  46040. declare module BABYLON {
  46041. /**
  46042. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46043. * It can help converting any input color in a desired output one. This can then be used to create effects
  46044. * from sepia, black and white to sixties or futuristic rendering...
  46045. *
  46046. * The only supported format is currently 3dl.
  46047. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46048. */
  46049. export class ColorGradingTexture extends BaseTexture {
  46050. /**
  46051. * The current texture matrix. (will always be identity in color grading texture)
  46052. */
  46053. private _textureMatrix;
  46054. /**
  46055. * The texture URL.
  46056. */
  46057. url: string;
  46058. /**
  46059. * Empty line regex stored for GC.
  46060. */
  46061. private static _noneEmptyLineRegex;
  46062. private _engine;
  46063. /**
  46064. * Instantiates a ColorGradingTexture from the following parameters.
  46065. *
  46066. * @param url The location of the color gradind data (currently only supporting 3dl)
  46067. * @param scene The scene the texture will be used in
  46068. */
  46069. constructor(url: string, scene: Scene);
  46070. /**
  46071. * Returns the texture matrix used in most of the material.
  46072. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46073. */
  46074. getTextureMatrix(): Matrix;
  46075. /**
  46076. * Occurs when the file being loaded is a .3dl LUT file.
  46077. */
  46078. private load3dlTexture;
  46079. /**
  46080. * Starts the loading process of the texture.
  46081. */
  46082. private loadTexture;
  46083. /**
  46084. * Clones the color gradind texture.
  46085. */
  46086. clone(): ColorGradingTexture;
  46087. /**
  46088. * Called during delayed load for textures.
  46089. */
  46090. delayLoad(): void;
  46091. /**
  46092. * Parses a color grading texture serialized by Babylon.
  46093. * @param parsedTexture The texture information being parsedTexture
  46094. * @param scene The scene to load the texture in
  46095. * @param rootUrl The root url of the data assets to load
  46096. * @return A color gradind texture
  46097. */
  46098. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  46099. /**
  46100. * Serializes the LUT texture to json format.
  46101. */
  46102. serialize(): any;
  46103. }
  46104. }
  46105. declare module BABYLON {
  46106. /**
  46107. * Direct draw surface info
  46108. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46109. */
  46110. export interface DDSInfo {
  46111. /**
  46112. * Width of the texture
  46113. */
  46114. width: number;
  46115. /**
  46116. * Width of the texture
  46117. */
  46118. height: number;
  46119. /**
  46120. * Number of Mipmaps for the texture
  46121. * @see https://en.wikipedia.org/wiki/Mipmap
  46122. */
  46123. mipmapCount: number;
  46124. /**
  46125. * If the textures format is a known fourCC format
  46126. * @see https://www.fourcc.org/
  46127. */
  46128. isFourCC: boolean;
  46129. /**
  46130. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46131. */
  46132. isRGB: boolean;
  46133. /**
  46134. * If the texture is a lumincance format
  46135. */
  46136. isLuminance: boolean;
  46137. /**
  46138. * If this is a cube texture
  46139. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46140. */
  46141. isCube: boolean;
  46142. /**
  46143. * If the texture is a compressed format eg. FOURCC_DXT1
  46144. */
  46145. isCompressed: boolean;
  46146. /**
  46147. * The dxgiFormat of the texture
  46148. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46149. */
  46150. dxgiFormat: number;
  46151. /**
  46152. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46153. */
  46154. textureType: number;
  46155. /**
  46156. * Sphericle polynomial created for the dds texture
  46157. */
  46158. sphericalPolynomial?: SphericalPolynomial;
  46159. }
  46160. /**
  46161. * Class used to provide DDS decompression tools
  46162. */
  46163. export class DDSTools {
  46164. /**
  46165. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46166. */
  46167. static StoreLODInAlphaChannel: boolean;
  46168. /**
  46169. * Gets DDS information from an array buffer
  46170. * @param arrayBuffer defines the array buffer to read data from
  46171. * @returns the DDS information
  46172. */
  46173. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46174. private static _FloatView;
  46175. private static _Int32View;
  46176. private static _ToHalfFloat;
  46177. private static _FromHalfFloat;
  46178. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46179. private static _GetHalfFloatRGBAArrayBuffer;
  46180. private static _GetFloatRGBAArrayBuffer;
  46181. private static _GetFloatAsUIntRGBAArrayBuffer;
  46182. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46183. private static _GetRGBAArrayBuffer;
  46184. private static _ExtractLongWordOrder;
  46185. private static _GetRGBArrayBuffer;
  46186. private static _GetLuminanceArrayBuffer;
  46187. /**
  46188. * Uploads DDS Levels to a Babylon Texture
  46189. * @hidden
  46190. */
  46191. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46192. }
  46193. interface Engine {
  46194. /**
  46195. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46196. * @param rootUrl defines the url where the file to load is located
  46197. * @param scene defines the current scene
  46198. * @param lodScale defines scale to apply to the mip map selection
  46199. * @param lodOffset defines offset to apply to the mip map selection
  46200. * @param onLoad defines an optional callback raised when the texture is loaded
  46201. * @param onError defines an optional callback raised if there is an issue to load the texture
  46202. * @param format defines the format of the data
  46203. * @param forcedExtension defines the extension to use to pick the right loader
  46204. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46205. * @returns the cube texture as an InternalTexture
  46206. */
  46207. 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;
  46208. }
  46209. }
  46210. declare module BABYLON {
  46211. /**
  46212. * Implementation of the DDS Texture Loader.
  46213. * @hidden
  46214. */
  46215. export class _DDSTextureLoader implements IInternalTextureLoader {
  46216. /**
  46217. * Defines wether the loader supports cascade loading the different faces.
  46218. */
  46219. readonly supportCascades: boolean;
  46220. /**
  46221. * This returns if the loader support the current file information.
  46222. * @param extension defines the file extension of the file being loaded
  46223. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46224. * @param fallback defines the fallback internal texture if any
  46225. * @param isBase64 defines whether the texture is encoded as a base64
  46226. * @param isBuffer defines whether the texture data are stored as a buffer
  46227. * @returns true if the loader can load the specified file
  46228. */
  46229. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46230. /**
  46231. * Transform the url before loading if required.
  46232. * @param rootUrl the url of the texture
  46233. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46234. * @returns the transformed texture
  46235. */
  46236. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46237. /**
  46238. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46239. * @param rootUrl the url of the texture
  46240. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46241. * @returns the fallback texture
  46242. */
  46243. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46244. /**
  46245. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46246. * @param data contains the texture data
  46247. * @param texture defines the BabylonJS internal texture
  46248. * @param createPolynomials will be true if polynomials have been requested
  46249. * @param onLoad defines the callback to trigger once the texture is ready
  46250. * @param onError defines the callback to trigger in case of error
  46251. */
  46252. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46253. /**
  46254. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46255. * @param data contains the texture data
  46256. * @param texture defines the BabylonJS internal texture
  46257. * @param callback defines the method to call once ready to upload
  46258. */
  46259. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46260. }
  46261. }
  46262. declare module BABYLON {
  46263. /** @hidden */
  46264. export var rgbdEncodePixelShader: {
  46265. name: string;
  46266. shader: string;
  46267. };
  46268. }
  46269. declare module BABYLON {
  46270. /** @hidden */
  46271. export var rgbdDecodePixelShader: {
  46272. name: string;
  46273. shader: string;
  46274. };
  46275. }
  46276. declare module BABYLON {
  46277. /**
  46278. * Raw texture data and descriptor sufficient for WebGL texture upload
  46279. */
  46280. export interface EnvironmentTextureInfo {
  46281. /**
  46282. * Version of the environment map
  46283. */
  46284. version: number;
  46285. /**
  46286. * Width of image
  46287. */
  46288. width: number;
  46289. /**
  46290. * Irradiance information stored in the file.
  46291. */
  46292. irradiance: any;
  46293. /**
  46294. * Specular information stored in the file.
  46295. */
  46296. specular: any;
  46297. }
  46298. /**
  46299. * Sets of helpers addressing the serialization and deserialization of environment texture
  46300. * stored in a BabylonJS env file.
  46301. * Those files are usually stored as .env files.
  46302. */
  46303. export class EnvironmentTextureTools {
  46304. /**
  46305. * Magic number identifying the env file.
  46306. */
  46307. private static _MagicBytes;
  46308. /**
  46309. * Gets the environment info from an env file.
  46310. * @param data The array buffer containing the .env bytes.
  46311. * @returns the environment file info (the json header) if successfully parsed.
  46312. */
  46313. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46314. /**
  46315. * Creates an environment texture from a loaded cube texture.
  46316. * @param texture defines the cube texture to convert in env file
  46317. * @return a promise containing the environment data if succesfull.
  46318. */
  46319. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46320. /**
  46321. * Creates a JSON representation of the spherical data.
  46322. * @param texture defines the texture containing the polynomials
  46323. * @return the JSON representation of the spherical info
  46324. */
  46325. private static _CreateEnvTextureIrradiance;
  46326. /**
  46327. * Uploads the texture info contained in the env file to the GPU.
  46328. * @param texture defines the internal texture to upload to
  46329. * @param arrayBuffer defines the buffer cotaining the data to load
  46330. * @param info defines the texture info retrieved through the GetEnvInfo method
  46331. * @returns a promise
  46332. */
  46333. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46334. /**
  46335. * Uploads the levels of image data to the GPU.
  46336. * @param texture defines the internal texture to upload to
  46337. * @param imageData defines the array buffer views of image data [mipmap][face]
  46338. * @returns a promise
  46339. */
  46340. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46341. /**
  46342. * Uploads spherical polynomials information to the texture.
  46343. * @param texture defines the texture we are trying to upload the information to
  46344. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46345. */
  46346. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46347. /** @hidden */
  46348. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46349. }
  46350. }
  46351. declare module BABYLON {
  46352. /**
  46353. * Implementation of the ENV Texture Loader.
  46354. * @hidden
  46355. */
  46356. export class _ENVTextureLoader implements IInternalTextureLoader {
  46357. /**
  46358. * Defines wether the loader supports cascade loading the different faces.
  46359. */
  46360. readonly supportCascades: boolean;
  46361. /**
  46362. * This returns if the loader support the current file information.
  46363. * @param extension defines the file extension of the file being loaded
  46364. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46365. * @param fallback defines the fallback internal texture if any
  46366. * @param isBase64 defines whether the texture is encoded as a base64
  46367. * @param isBuffer defines whether the texture data are stored as a buffer
  46368. * @returns true if the loader can load the specified file
  46369. */
  46370. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46371. /**
  46372. * Transform the url before loading if required.
  46373. * @param rootUrl the url of the texture
  46374. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46375. * @returns the transformed texture
  46376. */
  46377. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46378. /**
  46379. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46380. * @param rootUrl the url of the texture
  46381. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46382. * @returns the fallback texture
  46383. */
  46384. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46385. /**
  46386. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46387. * @param data contains the texture data
  46388. * @param texture defines the BabylonJS internal texture
  46389. * @param createPolynomials will be true if polynomials have been requested
  46390. * @param onLoad defines the callback to trigger once the texture is ready
  46391. * @param onError defines the callback to trigger in case of error
  46392. */
  46393. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46394. /**
  46395. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46396. * @param data contains the texture data
  46397. * @param texture defines the BabylonJS internal texture
  46398. * @param callback defines the method to call once ready to upload
  46399. */
  46400. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46401. }
  46402. }
  46403. declare module BABYLON {
  46404. /**
  46405. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46406. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46407. */
  46408. export class KhronosTextureContainer {
  46409. /** contents of the KTX container file */
  46410. arrayBuffer: any;
  46411. private static HEADER_LEN;
  46412. private static COMPRESSED_2D;
  46413. private static COMPRESSED_3D;
  46414. private static TEX_2D;
  46415. private static TEX_3D;
  46416. /**
  46417. * Gets the openGL type
  46418. */
  46419. glType: number;
  46420. /**
  46421. * Gets the openGL type size
  46422. */
  46423. glTypeSize: number;
  46424. /**
  46425. * Gets the openGL format
  46426. */
  46427. glFormat: number;
  46428. /**
  46429. * Gets the openGL internal format
  46430. */
  46431. glInternalFormat: number;
  46432. /**
  46433. * Gets the base internal format
  46434. */
  46435. glBaseInternalFormat: number;
  46436. /**
  46437. * Gets image width in pixel
  46438. */
  46439. pixelWidth: number;
  46440. /**
  46441. * Gets image height in pixel
  46442. */
  46443. pixelHeight: number;
  46444. /**
  46445. * Gets image depth in pixels
  46446. */
  46447. pixelDepth: number;
  46448. /**
  46449. * Gets the number of array elements
  46450. */
  46451. numberOfArrayElements: number;
  46452. /**
  46453. * Gets the number of faces
  46454. */
  46455. numberOfFaces: number;
  46456. /**
  46457. * Gets the number of mipmap levels
  46458. */
  46459. numberOfMipmapLevels: number;
  46460. /**
  46461. * Gets the bytes of key value data
  46462. */
  46463. bytesOfKeyValueData: number;
  46464. /**
  46465. * Gets the load type
  46466. */
  46467. loadType: number;
  46468. /**
  46469. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46470. */
  46471. isInvalid: boolean;
  46472. /**
  46473. * Creates a new KhronosTextureContainer
  46474. * @param arrayBuffer contents of the KTX container file
  46475. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46476. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46477. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46478. */
  46479. constructor(
  46480. /** contents of the KTX container file */
  46481. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46482. /**
  46483. * Uploads KTX content to a Babylon Texture.
  46484. * It is assumed that the texture has already been created & is currently bound
  46485. * @hidden
  46486. */
  46487. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46488. private _upload2DCompressedLevels;
  46489. }
  46490. }
  46491. declare module BABYLON {
  46492. /**
  46493. * Implementation of the KTX Texture Loader.
  46494. * @hidden
  46495. */
  46496. export class _KTXTextureLoader implements IInternalTextureLoader {
  46497. /**
  46498. * Defines wether the loader supports cascade loading the different faces.
  46499. */
  46500. readonly supportCascades: boolean;
  46501. /**
  46502. * This returns if the loader support the current file information.
  46503. * @param extension defines the file extension of the file being loaded
  46504. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46505. * @param fallback defines the fallback internal texture if any
  46506. * @param isBase64 defines whether the texture is encoded as a base64
  46507. * @param isBuffer defines whether the texture data are stored as a buffer
  46508. * @returns true if the loader can load the specified file
  46509. */
  46510. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46511. /**
  46512. * Transform the url before loading if required.
  46513. * @param rootUrl the url of the texture
  46514. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46515. * @returns the transformed texture
  46516. */
  46517. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46518. /**
  46519. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46520. * @param rootUrl the url of the texture
  46521. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46522. * @returns the fallback texture
  46523. */
  46524. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46525. /**
  46526. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46527. * @param data contains the texture data
  46528. * @param texture defines the BabylonJS internal texture
  46529. * @param createPolynomials will be true if polynomials have been requested
  46530. * @param onLoad defines the callback to trigger once the texture is ready
  46531. * @param onError defines the callback to trigger in case of error
  46532. */
  46533. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46534. /**
  46535. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46536. * @param data contains the texture data
  46537. * @param texture defines the BabylonJS internal texture
  46538. * @param callback defines the method to call once ready to upload
  46539. */
  46540. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46541. }
  46542. }
  46543. declare module BABYLON {
  46544. /**
  46545. * Based on jsTGALoader - Javascript loader for TGA file
  46546. * By Vincent Thibault
  46547. * @see http://blog.robrowser.com/javascript-tga-loader.html
  46548. */
  46549. export class TGATools {
  46550. private static _TYPE_INDEXED;
  46551. private static _TYPE_RGB;
  46552. private static _TYPE_GREY;
  46553. private static _TYPE_RLE_INDEXED;
  46554. private static _TYPE_RLE_RGB;
  46555. private static _TYPE_RLE_GREY;
  46556. private static _ORIGIN_MASK;
  46557. private static _ORIGIN_SHIFT;
  46558. private static _ORIGIN_BL;
  46559. private static _ORIGIN_BR;
  46560. private static _ORIGIN_UL;
  46561. private static _ORIGIN_UR;
  46562. /**
  46563. * Gets the header of a TGA file
  46564. * @param data defines the TGA data
  46565. * @returns the header
  46566. */
  46567. static GetTGAHeader(data: Uint8Array): any;
  46568. /**
  46569. * Uploads TGA content to a Babylon Texture
  46570. * @hidden
  46571. */
  46572. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  46573. /** @hidden */
  46574. 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;
  46575. /** @hidden */
  46576. 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;
  46577. /** @hidden */
  46578. 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;
  46579. /** @hidden */
  46580. 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;
  46581. /** @hidden */
  46582. 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;
  46583. /** @hidden */
  46584. 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;
  46585. }
  46586. }
  46587. declare module BABYLON {
  46588. /**
  46589. * Implementation of the TGA Texture Loader.
  46590. * @hidden
  46591. */
  46592. export class _TGATextureLoader implements IInternalTextureLoader {
  46593. /**
  46594. * Defines wether the loader supports cascade loading the different faces.
  46595. */
  46596. readonly supportCascades: boolean;
  46597. /**
  46598. * This returns if the loader support the current file information.
  46599. * @param extension defines the file extension of the file being loaded
  46600. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46601. * @param fallback defines the fallback internal texture if any
  46602. * @param isBase64 defines whether the texture is encoded as a base64
  46603. * @param isBuffer defines whether the texture data are stored as a buffer
  46604. * @returns true if the loader can load the specified file
  46605. */
  46606. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46607. /**
  46608. * Transform the url before loading if required.
  46609. * @param rootUrl the url of the texture
  46610. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46611. * @returns the transformed texture
  46612. */
  46613. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46614. /**
  46615. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46616. * @param rootUrl the url of the texture
  46617. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46618. * @returns the fallback texture
  46619. */
  46620. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46621. /**
  46622. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46623. * @param data contains the texture data
  46624. * @param texture defines the BabylonJS internal texture
  46625. * @param createPolynomials will be true if polynomials have been requested
  46626. * @param onLoad defines the callback to trigger once the texture is ready
  46627. * @param onError defines the callback to trigger in case of error
  46628. */
  46629. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46630. /**
  46631. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46632. * @param data contains the texture data
  46633. * @param texture defines the BabylonJS internal texture
  46634. * @param callback defines the method to call once ready to upload
  46635. */
  46636. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46637. }
  46638. }
  46639. declare module BABYLON {
  46640. /**
  46641. * 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.
  46642. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  46643. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  46644. */
  46645. export class CustomProceduralTexture extends ProceduralTexture {
  46646. private _animate;
  46647. private _time;
  46648. private _config;
  46649. private _texturePath;
  46650. /**
  46651. * Instantiates a new Custom Procedural Texture.
  46652. * 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.
  46653. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  46654. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  46655. * @param name Define the name of the texture
  46656. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  46657. * @param size Define the size of the texture to create
  46658. * @param scene Define the scene the texture belongs to
  46659. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  46660. * @param generateMipMaps Define if the texture should creates mip maps or not
  46661. */
  46662. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  46663. private _loadJson;
  46664. /**
  46665. * Is the texture ready to be used ? (rendered at least once)
  46666. * @returns true if ready, otherwise, false.
  46667. */
  46668. isReady(): boolean;
  46669. /**
  46670. * Render the texture to its associated render target.
  46671. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  46672. */
  46673. render(useCameraPostProcess?: boolean): void;
  46674. /**
  46675. * Update the list of dependant textures samplers in the shader.
  46676. */
  46677. updateTextures(): void;
  46678. /**
  46679. * Update the uniform values of the procedural texture in the shader.
  46680. */
  46681. updateShaderUniforms(): void;
  46682. /**
  46683. * Define if the texture animates or not.
  46684. */
  46685. animate: boolean;
  46686. }
  46687. }
  46688. declare module BABYLON {
  46689. /** @hidden */
  46690. export var noisePixelShader: {
  46691. name: string;
  46692. shader: string;
  46693. };
  46694. }
  46695. declare module BABYLON {
  46696. /**
  46697. * Class used to generate noise procedural textures
  46698. */
  46699. export class NoiseProceduralTexture extends ProceduralTexture {
  46700. private _time;
  46701. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  46702. brightness: number;
  46703. /** Defines the number of octaves to process */
  46704. octaves: number;
  46705. /** Defines the level of persistence (0.8 by default) */
  46706. persistence: number;
  46707. /** Gets or sets animation speed factor (default is 1) */
  46708. animationSpeedFactor: number;
  46709. /**
  46710. * Creates a new NoiseProceduralTexture
  46711. * @param name defines the name fo the texture
  46712. * @param size defines the size of the texture (default is 256)
  46713. * @param scene defines the hosting scene
  46714. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  46715. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  46716. */
  46717. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  46718. private _updateShaderUniforms;
  46719. protected _getDefines(): string;
  46720. /** Generate the current state of the procedural texture */
  46721. render(useCameraPostProcess?: boolean): void;
  46722. /**
  46723. * Serializes this noise procedural texture
  46724. * @returns a serialized noise procedural texture object
  46725. */
  46726. serialize(): any;
  46727. /**
  46728. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  46729. * @param parsedTexture defines parsed texture data
  46730. * @param scene defines the current scene
  46731. * @param rootUrl defines the root URL containing noise procedural texture information
  46732. * @returns a parsed NoiseProceduralTexture
  46733. */
  46734. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  46735. }
  46736. }
  46737. declare module BABYLON {
  46738. /**
  46739. * Raw cube texture where the raw buffers are passed in
  46740. */
  46741. export class RawCubeTexture extends CubeTexture {
  46742. /**
  46743. * Creates a cube texture where the raw buffers are passed in.
  46744. * @param scene defines the scene the texture is attached to
  46745. * @param data defines the array of data to use to create each face
  46746. * @param size defines the size of the textures
  46747. * @param format defines the format of the data
  46748. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  46749. * @param generateMipMaps defines if the engine should generate the mip levels
  46750. * @param invertY defines if data must be stored with Y axis inverted
  46751. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46752. * @param compression defines the compression used (null by default)
  46753. */
  46754. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  46755. /**
  46756. * Updates the raw cube texture.
  46757. * @param data defines the data to store
  46758. * @param format defines the data format
  46759. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46760. * @param invertY defines if data must be stored with Y axis inverted
  46761. * @param compression defines the compression used (null by default)
  46762. * @param level defines which level of the texture to update
  46763. */
  46764. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  46765. /**
  46766. * Updates a raw cube texture with RGBD encoded data.
  46767. * @param data defines the array of data [mipmap][face] to use to create each face
  46768. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  46769. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46770. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46771. * @returns a promsie that resolves when the operation is complete
  46772. */
  46773. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  46774. /**
  46775. * Clones the raw cube texture.
  46776. * @return a new cube texture
  46777. */
  46778. clone(): CubeTexture;
  46779. /** @hidden */
  46780. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46781. }
  46782. }
  46783. declare module BABYLON {
  46784. /**
  46785. * Class used to store 3D textures containing user data
  46786. */
  46787. export class RawTexture3D extends Texture {
  46788. /** Gets or sets the texture format to use */
  46789. format: number;
  46790. private _engine;
  46791. /**
  46792. * Create a new RawTexture3D
  46793. * @param data defines the data of the texture
  46794. * @param width defines the width of the texture
  46795. * @param height defines the height of the texture
  46796. * @param depth defines the depth of the texture
  46797. * @param format defines the texture format to use
  46798. * @param scene defines the hosting scene
  46799. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  46800. * @param invertY defines if texture must be stored with Y axis inverted
  46801. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  46802. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46803. */
  46804. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  46805. /** Gets or sets the texture format to use */
  46806. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  46807. /**
  46808. * Update the texture with new data
  46809. * @param data defines the data to store in the texture
  46810. */
  46811. update(data: ArrayBufferView): void;
  46812. }
  46813. }
  46814. declare module BABYLON {
  46815. /**
  46816. * Creates a refraction texture used by refraction channel of the standard material.
  46817. * It is like a mirror but to see through a material.
  46818. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46819. */
  46820. export class RefractionTexture extends RenderTargetTexture {
  46821. /**
  46822. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  46823. * 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.
  46824. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46825. */
  46826. refractionPlane: Plane;
  46827. /**
  46828. * Define how deep under the surface we should see.
  46829. */
  46830. depth: number;
  46831. /**
  46832. * Creates a refraction texture used by refraction channel of the standard material.
  46833. * It is like a mirror but to see through a material.
  46834. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46835. * @param name Define the texture name
  46836. * @param size Define the size of the underlying texture
  46837. * @param scene Define the scene the refraction belongs to
  46838. * @param generateMipMaps Define if we need to generate mips level for the refraction
  46839. */
  46840. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  46841. /**
  46842. * Clone the refraction texture.
  46843. * @returns the cloned texture
  46844. */
  46845. clone(): RefractionTexture;
  46846. /**
  46847. * Serialize the texture to a JSON representation you could use in Parse later on
  46848. * @returns the serialized JSON representation
  46849. */
  46850. serialize(): any;
  46851. }
  46852. }
  46853. declare module BABYLON {
  46854. /**
  46855. * Configuration for Draco compression
  46856. */
  46857. export interface IDracoCompressionConfiguration {
  46858. /**
  46859. * Configuration for the decoder.
  46860. */
  46861. decoder?: {
  46862. /**
  46863. * The url to the WebAssembly module.
  46864. */
  46865. wasmUrl?: string;
  46866. /**
  46867. * The url to the WebAssembly binary.
  46868. */
  46869. wasmBinaryUrl?: string;
  46870. /**
  46871. * The url to the fallback JavaScript module.
  46872. */
  46873. fallbackUrl?: string;
  46874. };
  46875. }
  46876. /**
  46877. * Draco compression (https://google.github.io/draco/)
  46878. *
  46879. * This class wraps the Draco module.
  46880. *
  46881. * **Encoder**
  46882. *
  46883. * The encoder is not currently implemented.
  46884. *
  46885. * **Decoder**
  46886. *
  46887. * 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.
  46888. *
  46889. * To update the configuration, use the following code:
  46890. * ```javascript
  46891. * DracoCompression.Configuration = {
  46892. * decoder: {
  46893. * wasmUrl: "<url to the WebAssembly library>",
  46894. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  46895. * fallbackUrl: "<url to the fallback JavaScript library>",
  46896. * }
  46897. * };
  46898. * ```
  46899. *
  46900. * 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.
  46901. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  46902. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  46903. *
  46904. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  46905. * ```javascript
  46906. * var dracoCompression = new DracoCompression();
  46907. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  46908. * [VertexBuffer.PositionKind]: 0
  46909. * });
  46910. * ```
  46911. *
  46912. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  46913. */
  46914. export class DracoCompression implements IDisposable {
  46915. private static _DecoderModulePromise;
  46916. /**
  46917. * The configuration. Defaults to the following urls:
  46918. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  46919. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  46920. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  46921. */
  46922. static Configuration: IDracoCompressionConfiguration;
  46923. /**
  46924. * Returns true if the decoder is available.
  46925. */
  46926. static readonly DecoderAvailable: boolean;
  46927. /**
  46928. * Constructor
  46929. */
  46930. constructor();
  46931. /**
  46932. * Stop all async operations and release resources.
  46933. */
  46934. dispose(): void;
  46935. /**
  46936. * Decode Draco compressed mesh data to vertex data.
  46937. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  46938. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  46939. * @returns A promise that resolves with the decoded vertex data
  46940. */
  46941. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  46942. [kind: string]: number;
  46943. }): Promise<VertexData>;
  46944. private static _GetDecoderModule;
  46945. private static _LoadScriptAsync;
  46946. private static _LoadFileAsync;
  46947. }
  46948. }
  46949. declare module BABYLON {
  46950. /**
  46951. * Class for building Constructive Solid Geometry
  46952. */
  46953. export class CSG {
  46954. private polygons;
  46955. /**
  46956. * The world matrix
  46957. */
  46958. matrix: Matrix;
  46959. /**
  46960. * Stores the position
  46961. */
  46962. position: Vector3;
  46963. /**
  46964. * Stores the rotation
  46965. */
  46966. rotation: Vector3;
  46967. /**
  46968. * Stores the rotation quaternion
  46969. */
  46970. rotationQuaternion: Nullable<Quaternion>;
  46971. /**
  46972. * Stores the scaling vector
  46973. */
  46974. scaling: Vector3;
  46975. /**
  46976. * Convert the Mesh to CSG
  46977. * @param mesh The Mesh to convert to CSG
  46978. * @returns A new CSG from the Mesh
  46979. */
  46980. static FromMesh(mesh: Mesh): CSG;
  46981. /**
  46982. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  46983. * @param polygons Polygons used to construct a CSG solid
  46984. */
  46985. private static FromPolygons;
  46986. /**
  46987. * Clones, or makes a deep copy, of the CSG
  46988. * @returns A new CSG
  46989. */
  46990. clone(): CSG;
  46991. /**
  46992. * Unions this CSG with another CSG
  46993. * @param csg The CSG to union against this CSG
  46994. * @returns The unioned CSG
  46995. */
  46996. union(csg: CSG): CSG;
  46997. /**
  46998. * Unions this CSG with another CSG in place
  46999. * @param csg The CSG to union against this CSG
  47000. */
  47001. unionInPlace(csg: CSG): void;
  47002. /**
  47003. * Subtracts this CSG with another CSG
  47004. * @param csg The CSG to subtract against this CSG
  47005. * @returns A new CSG
  47006. */
  47007. subtract(csg: CSG): CSG;
  47008. /**
  47009. * Subtracts this CSG with another CSG in place
  47010. * @param csg The CSG to subtact against this CSG
  47011. */
  47012. subtractInPlace(csg: CSG): void;
  47013. /**
  47014. * Intersect this CSG with another CSG
  47015. * @param csg The CSG to intersect against this CSG
  47016. * @returns A new CSG
  47017. */
  47018. intersect(csg: CSG): CSG;
  47019. /**
  47020. * Intersects this CSG with another CSG in place
  47021. * @param csg The CSG to intersect against this CSG
  47022. */
  47023. intersectInPlace(csg: CSG): void;
  47024. /**
  47025. * Return a new CSG solid with solid and empty space switched. This solid is
  47026. * not modified.
  47027. * @returns A new CSG solid with solid and empty space switched
  47028. */
  47029. inverse(): CSG;
  47030. /**
  47031. * Inverses the CSG in place
  47032. */
  47033. inverseInPlace(): void;
  47034. /**
  47035. * This is used to keep meshes transformations so they can be restored
  47036. * when we build back a Babylon Mesh
  47037. * NB : All CSG operations are performed in world coordinates
  47038. * @param csg The CSG to copy the transform attributes from
  47039. * @returns This CSG
  47040. */
  47041. copyTransformAttributes(csg: CSG): CSG;
  47042. /**
  47043. * Build Raw mesh from CSG
  47044. * Coordinates here are in world space
  47045. * @param name The name of the mesh geometry
  47046. * @param scene The Scene
  47047. * @param keepSubMeshes Specifies if the submeshes should be kept
  47048. * @returns A new Mesh
  47049. */
  47050. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  47051. /**
  47052. * Build Mesh from CSG taking material and transforms into account
  47053. * @param name The name of the Mesh
  47054. * @param material The material of the Mesh
  47055. * @param scene The Scene
  47056. * @param keepSubMeshes Specifies if submeshes should be kept
  47057. * @returns The new Mesh
  47058. */
  47059. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  47060. }
  47061. }
  47062. declare module BABYLON {
  47063. /**
  47064. * Class used to create a trail following a mesh
  47065. */
  47066. export class TrailMesh extends Mesh {
  47067. private _generator;
  47068. private _autoStart;
  47069. private _running;
  47070. private _diameter;
  47071. private _length;
  47072. private _sectionPolygonPointsCount;
  47073. private _sectionVectors;
  47074. private _sectionNormalVectors;
  47075. private _beforeRenderObserver;
  47076. /**
  47077. * @constructor
  47078. * @param name The value used by scene.getMeshByName() to do a lookup.
  47079. * @param generator The mesh to generate a trail.
  47080. * @param scene The scene to add this mesh to.
  47081. * @param diameter Diameter of trailing mesh. Default is 1.
  47082. * @param length Length of trailing mesh. Default is 60.
  47083. * @param autoStart Automatically start trailing mesh. Default true.
  47084. */
  47085. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  47086. /**
  47087. * "TrailMesh"
  47088. * @returns "TrailMesh"
  47089. */
  47090. getClassName(): string;
  47091. private _createMesh;
  47092. /**
  47093. * Start trailing mesh.
  47094. */
  47095. start(): void;
  47096. /**
  47097. * Stop trailing mesh.
  47098. */
  47099. stop(): void;
  47100. /**
  47101. * Update trailing mesh geometry.
  47102. */
  47103. update(): void;
  47104. /**
  47105. * Returns a new TrailMesh object.
  47106. * @param name is a string, the name given to the new mesh
  47107. * @param newGenerator use new generator object for cloned trail mesh
  47108. * @returns a new mesh
  47109. */
  47110. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  47111. /**
  47112. * Serializes this trail mesh
  47113. * @param serializationObject object to write serialization to
  47114. */
  47115. serialize(serializationObject: any): void;
  47116. /**
  47117. * Parses a serialized trail mesh
  47118. * @param parsedMesh the serialized mesh
  47119. * @param scene the scene to create the trail mesh in
  47120. * @returns the created trail mesh
  47121. */
  47122. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  47123. }
  47124. }
  47125. declare module BABYLON {
  47126. /**
  47127. * Class containing static functions to help procedurally build meshes
  47128. */
  47129. export class RibbonBuilder {
  47130. /**
  47131. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47132. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47133. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47134. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47135. * * 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
  47136. * * 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
  47137. * * 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
  47138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47139. * * 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
  47140. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47141. * * 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
  47142. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47143. * * 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
  47144. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47146. * @param name defines the name of the mesh
  47147. * @param options defines the options used to create the mesh
  47148. * @param scene defines the hosting scene
  47149. * @returns the ribbon mesh
  47150. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47151. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47152. */
  47153. static CreateRibbon(name: string, options: {
  47154. pathArray: Vector3[][];
  47155. closeArray?: boolean;
  47156. closePath?: boolean;
  47157. offset?: number;
  47158. updatable?: boolean;
  47159. sideOrientation?: number;
  47160. frontUVs?: Vector4;
  47161. backUVs?: Vector4;
  47162. instance?: Mesh;
  47163. invertUV?: boolean;
  47164. uvs?: Vector2[];
  47165. colors?: Color4[];
  47166. }, scene?: Nullable<Scene>): Mesh;
  47167. }
  47168. }
  47169. declare module BABYLON {
  47170. /**
  47171. * Class containing static functions to help procedurally build meshes
  47172. */
  47173. export class TorusKnotBuilder {
  47174. /**
  47175. * Creates a torus knot mesh
  47176. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  47177. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  47178. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  47179. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  47180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47181. * * 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
  47182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47183. * @param name defines the name of the mesh
  47184. * @param options defines the options used to create the mesh
  47185. * @param scene defines the hosting scene
  47186. * @returns the torus knot mesh
  47187. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  47188. */
  47189. static CreateTorusKnot(name: string, options: {
  47190. radius?: number;
  47191. tube?: number;
  47192. radialSegments?: number;
  47193. tubularSegments?: number;
  47194. p?: number;
  47195. q?: number;
  47196. updatable?: boolean;
  47197. sideOrientation?: number;
  47198. frontUVs?: Vector4;
  47199. backUVs?: Vector4;
  47200. }, scene: any): Mesh;
  47201. }
  47202. }
  47203. declare module BABYLON {
  47204. /**
  47205. * Polygon
  47206. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  47207. */
  47208. export class Polygon {
  47209. /**
  47210. * Creates a rectangle
  47211. * @param xmin bottom X coord
  47212. * @param ymin bottom Y coord
  47213. * @param xmax top X coord
  47214. * @param ymax top Y coord
  47215. * @returns points that make the resulting rectation
  47216. */
  47217. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  47218. /**
  47219. * Creates a circle
  47220. * @param radius radius of circle
  47221. * @param cx scale in x
  47222. * @param cy scale in y
  47223. * @param numberOfSides number of sides that make up the circle
  47224. * @returns points that make the resulting circle
  47225. */
  47226. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  47227. /**
  47228. * Creates a polygon from input string
  47229. * @param input Input polygon data
  47230. * @returns the parsed points
  47231. */
  47232. static Parse(input: string): Vector2[];
  47233. /**
  47234. * Starts building a polygon from x and y coordinates
  47235. * @param x x coordinate
  47236. * @param y y coordinate
  47237. * @returns the started path2
  47238. */
  47239. static StartingAt(x: number, y: number): Path2;
  47240. }
  47241. /**
  47242. * Builds a polygon
  47243. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  47244. */
  47245. export class PolygonMeshBuilder {
  47246. private _points;
  47247. private _outlinepoints;
  47248. private _holes;
  47249. private _name;
  47250. private _scene;
  47251. private _epoints;
  47252. private _eholes;
  47253. private _addToepoint;
  47254. /**
  47255. * Babylon reference to the earcut plugin.
  47256. */
  47257. bjsEarcut: any;
  47258. /**
  47259. * Creates a PolygonMeshBuilder
  47260. * @param name name of the builder
  47261. * @param contours Path of the polygon
  47262. * @param scene scene to add to
  47263. * @param earcutInjection can be used to inject your own earcut reference
  47264. */
  47265. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  47266. /**
  47267. * Adds a whole within the polygon
  47268. * @param hole Array of points defining the hole
  47269. * @returns this
  47270. */
  47271. addHole(hole: Vector2[]): PolygonMeshBuilder;
  47272. /**
  47273. * Creates the polygon
  47274. * @param updatable If the mesh should be updatable
  47275. * @param depth The depth of the mesh created
  47276. * @returns the created mesh
  47277. */
  47278. build(updatable?: boolean, depth?: number): Mesh;
  47279. /**
  47280. * Adds a side to the polygon
  47281. * @param positions points that make the polygon
  47282. * @param normals normals of the polygon
  47283. * @param uvs uvs of the polygon
  47284. * @param indices indices of the polygon
  47285. * @param bounds bounds of the polygon
  47286. * @param points points of the polygon
  47287. * @param depth depth of the polygon
  47288. * @param flip flip of the polygon
  47289. */
  47290. private addSide;
  47291. }
  47292. }
  47293. declare module BABYLON {
  47294. /**
  47295. * Class containing static functions to help procedurally build meshes
  47296. */
  47297. export class PolygonBuilder {
  47298. /**
  47299. * Creates a polygon mesh
  47300. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  47301. * * 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
  47302. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  47303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47304. * * 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)
  47305. * * Remember you can only change the shape positions, not their number when updating a polygon
  47306. * @param name defines the name of the mesh
  47307. * @param options defines the options used to create the mesh
  47308. * @param scene defines the hosting scene
  47309. * @param earcutInjection can be used to inject your own earcut reference
  47310. * @returns the polygon mesh
  47311. */
  47312. static CreatePolygon(name: string, options: {
  47313. shape: Vector3[];
  47314. holes?: Vector3[][];
  47315. depth?: number;
  47316. faceUV?: Vector4[];
  47317. faceColors?: Color4[];
  47318. updatable?: boolean;
  47319. sideOrientation?: number;
  47320. frontUVs?: Vector4;
  47321. backUVs?: Vector4;
  47322. }, scene: Scene, earcutInjection?: any): Mesh;
  47323. /**
  47324. * Creates an extruded polygon mesh, with depth in the Y direction.
  47325. * * 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)
  47326. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47327. * @param name defines the name of the mesh
  47328. * @param options defines the options used to create the mesh
  47329. * @param scene defines the hosting scene
  47330. * @param earcutInjection can be used to inject your own earcut reference
  47331. * @returns the polygon mesh
  47332. */
  47333. static ExtrudePolygon(name: string, options: {
  47334. shape: Vector3[];
  47335. holes?: Vector3[][];
  47336. depth?: number;
  47337. faceUV?: Vector4[];
  47338. faceColors?: Color4[];
  47339. updatable?: boolean;
  47340. sideOrientation?: number;
  47341. frontUVs?: Vector4;
  47342. backUVs?: Vector4;
  47343. }, scene: Scene, earcutInjection?: any): Mesh;
  47344. }
  47345. }
  47346. declare module BABYLON {
  47347. /**
  47348. * Class containing static functions to help procedurally build meshes
  47349. */
  47350. export class ShapeBuilder {
  47351. /**
  47352. * 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.
  47353. * * 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.
  47354. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47355. * * 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.
  47356. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47357. * * 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
  47358. * * 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
  47359. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47361. * * 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
  47362. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47364. * @param name defines the name of the mesh
  47365. * @param options defines the options used to create the mesh
  47366. * @param scene defines the hosting scene
  47367. * @returns the extruded shape mesh
  47368. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47369. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47370. */
  47371. static ExtrudeShape(name: string, options: {
  47372. shape: Vector3[];
  47373. path: Vector3[];
  47374. scale?: number;
  47375. rotation?: number;
  47376. cap?: number;
  47377. updatable?: boolean;
  47378. sideOrientation?: number;
  47379. frontUVs?: Vector4;
  47380. backUVs?: Vector4;
  47381. instance?: Mesh;
  47382. invertUV?: boolean;
  47383. }, scene?: Nullable<Scene>): Mesh;
  47384. /**
  47385. * Creates an custom extruded shape mesh.
  47386. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47387. * * 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.
  47388. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47389. * * 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
  47390. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47391. * * 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
  47392. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47393. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47394. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47395. * * 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
  47396. * * 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
  47397. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47399. * * 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
  47400. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47402. * @param name defines the name of the mesh
  47403. * @param options defines the options used to create the mesh
  47404. * @param scene defines the hosting scene
  47405. * @returns the custom extruded shape mesh
  47406. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47407. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47409. */
  47410. static ExtrudeShapeCustom(name: string, options: {
  47411. shape: Vector3[];
  47412. path: Vector3[];
  47413. scaleFunction?: any;
  47414. rotationFunction?: any;
  47415. ribbonCloseArray?: boolean;
  47416. ribbonClosePath?: boolean;
  47417. cap?: number;
  47418. updatable?: boolean;
  47419. sideOrientation?: number;
  47420. frontUVs?: Vector4;
  47421. backUVs?: Vector4;
  47422. instance?: Mesh;
  47423. invertUV?: boolean;
  47424. }, scene: Scene): Mesh;
  47425. private static _ExtrudeShapeGeneric;
  47426. }
  47427. }
  47428. declare module BABYLON {
  47429. /**
  47430. * Class containing static functions to help procedurally build meshes
  47431. */
  47432. export class LatheBuilder {
  47433. /**
  47434. * Creates lathe mesh.
  47435. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  47436. * * 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
  47437. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  47438. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  47439. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  47440. * * 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
  47441. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  47442. * * 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
  47443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47444. * * 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
  47445. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47447. * @param name defines the name of the mesh
  47448. * @param options defines the options used to create the mesh
  47449. * @param scene defines the hosting scene
  47450. * @returns the lathe mesh
  47451. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  47452. */
  47453. static CreateLathe(name: string, options: {
  47454. shape: Vector3[];
  47455. radius?: number;
  47456. tessellation?: number;
  47457. clip?: number;
  47458. arc?: number;
  47459. closed?: boolean;
  47460. updatable?: boolean;
  47461. sideOrientation?: number;
  47462. frontUVs?: Vector4;
  47463. backUVs?: Vector4;
  47464. cap?: number;
  47465. invertUV?: boolean;
  47466. }, scene: Scene): Mesh;
  47467. }
  47468. }
  47469. declare module BABYLON {
  47470. /**
  47471. * Class containing static functions to help procedurally build meshes
  47472. */
  47473. export class TubeBuilder {
  47474. /**
  47475. * Creates a tube mesh.
  47476. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47477. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  47478. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  47479. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  47480. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  47481. * * 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)
  47482. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  47483. * * 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
  47484. * * 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
  47485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47486. * * 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
  47487. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47489. * @param name defines the name of the mesh
  47490. * @param options defines the options used to create the mesh
  47491. * @param scene defines the hosting scene
  47492. * @returns the tube mesh
  47493. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47494. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  47495. */
  47496. static CreateTube(name: string, options: {
  47497. path: Vector3[];
  47498. radius?: number;
  47499. tessellation?: number;
  47500. radiusFunction?: {
  47501. (i: number, distance: number): number;
  47502. };
  47503. cap?: number;
  47504. arc?: number;
  47505. updatable?: boolean;
  47506. sideOrientation?: number;
  47507. frontUVs?: Vector4;
  47508. backUVs?: Vector4;
  47509. instance?: Mesh;
  47510. invertUV?: boolean;
  47511. }, scene: Scene): Mesh;
  47512. }
  47513. }
  47514. declare module BABYLON {
  47515. /**
  47516. * Class containing static functions to help procedurally build meshes
  47517. */
  47518. export class IcoSphereBuilder {
  47519. /**
  47520. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  47521. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  47522. * * 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`)
  47523. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  47524. * * 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
  47525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47526. * * 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
  47527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47528. * @param name defines the name of the mesh
  47529. * @param options defines the options used to create the mesh
  47530. * @param scene defines the hosting scene
  47531. * @returns the icosahedron mesh
  47532. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  47533. */
  47534. static CreateIcoSphere(name: string, options: {
  47535. radius?: number;
  47536. radiusX?: number;
  47537. radiusY?: number;
  47538. radiusZ?: number;
  47539. flat?: boolean;
  47540. subdivisions?: number;
  47541. sideOrientation?: number;
  47542. frontUVs?: Vector4;
  47543. backUVs?: Vector4;
  47544. updatable?: boolean;
  47545. }, scene: Scene): Mesh;
  47546. }
  47547. }
  47548. declare module BABYLON {
  47549. /**
  47550. * Class containing static functions to help procedurally build meshes
  47551. */
  47552. export class DecalBuilder {
  47553. /**
  47554. * Creates a decal mesh.
  47555. * 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
  47556. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  47557. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  47558. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  47559. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  47560. * @param name defines the name of the mesh
  47561. * @param sourceMesh defines the mesh where the decal must be applied
  47562. * @param options defines the options used to create the mesh
  47563. * @param scene defines the hosting scene
  47564. * @returns the decal mesh
  47565. * @see https://doc.babylonjs.com/how_to/decals
  47566. */
  47567. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  47568. position?: Vector3;
  47569. normal?: Vector3;
  47570. size?: Vector3;
  47571. angle?: number;
  47572. }): Mesh;
  47573. }
  47574. }
  47575. declare module BABYLON {
  47576. /**
  47577. * Class containing static functions to help procedurally build meshes
  47578. */
  47579. export class MeshBuilder {
  47580. /**
  47581. * Creates a box mesh
  47582. * * The parameter `size` sets the size (float) of each box side (default 1)
  47583. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47584. * * 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)
  47585. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47587. * * 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
  47588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47589. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47590. * @param name defines the name of the mesh
  47591. * @param options defines the options used to create the mesh
  47592. * @param scene defines the hosting scene
  47593. * @returns the box mesh
  47594. */
  47595. static CreateBox(name: string, options: {
  47596. size?: number;
  47597. width?: number;
  47598. height?: number;
  47599. depth?: number;
  47600. faceUV?: Vector4[];
  47601. faceColors?: Color4[];
  47602. sideOrientation?: number;
  47603. frontUVs?: Vector4;
  47604. backUVs?: Vector4;
  47605. updatable?: boolean;
  47606. }, scene?: Nullable<Scene>): Mesh;
  47607. /**
  47608. * Creates a sphere mesh
  47609. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47610. * * 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`)
  47611. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47612. * * 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
  47613. * * 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)
  47614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47615. * * 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
  47616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47617. * @param name defines the name of the mesh
  47618. * @param options defines the options used to create the mesh
  47619. * @param scene defines the hosting scene
  47620. * @returns the sphere mesh
  47621. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47622. */
  47623. static CreateSphere(name: string, options: {
  47624. segments?: number;
  47625. diameter?: number;
  47626. diameterX?: number;
  47627. diameterY?: number;
  47628. diameterZ?: number;
  47629. arc?: number;
  47630. slice?: number;
  47631. sideOrientation?: number;
  47632. frontUVs?: Vector4;
  47633. backUVs?: Vector4;
  47634. updatable?: boolean;
  47635. }, scene: any): Mesh;
  47636. /**
  47637. * Creates a plane polygonal mesh. By default, this is a disc
  47638. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  47639. * * 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
  47640. * * 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
  47641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47642. * * 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
  47643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47644. * @param name defines the name of the mesh
  47645. * @param options defines the options used to create the mesh
  47646. * @param scene defines the hosting scene
  47647. * @returns the plane polygonal mesh
  47648. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  47649. */
  47650. static CreateDisc(name: string, options: {
  47651. radius?: number;
  47652. tessellation?: number;
  47653. arc?: number;
  47654. updatable?: boolean;
  47655. sideOrientation?: number;
  47656. frontUVs?: Vector4;
  47657. backUVs?: Vector4;
  47658. }, scene?: Nullable<Scene>): Mesh;
  47659. /**
  47660. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  47661. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  47662. * * 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`)
  47663. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  47664. * * 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
  47665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47666. * * 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
  47667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47668. * @param name defines the name of the mesh
  47669. * @param options defines the options used to create the mesh
  47670. * @param scene defines the hosting scene
  47671. * @returns the icosahedron mesh
  47672. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  47673. */
  47674. static CreateIcoSphere(name: string, options: {
  47675. radius?: number;
  47676. radiusX?: number;
  47677. radiusY?: number;
  47678. radiusZ?: number;
  47679. flat?: boolean;
  47680. subdivisions?: number;
  47681. sideOrientation?: number;
  47682. frontUVs?: Vector4;
  47683. backUVs?: Vector4;
  47684. updatable?: boolean;
  47685. }, scene: Scene): Mesh;
  47686. /**
  47687. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47688. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47689. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47690. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47691. * * 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
  47692. * * 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
  47693. * * 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
  47694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47695. * * 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
  47696. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47697. * * 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
  47698. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47699. * * 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
  47700. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47702. * @param name defines the name of the mesh
  47703. * @param options defines the options used to create the mesh
  47704. * @param scene defines the hosting scene
  47705. * @returns the ribbon mesh
  47706. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47707. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47708. */
  47709. static CreateRibbon(name: string, options: {
  47710. pathArray: Vector3[][];
  47711. closeArray?: boolean;
  47712. closePath?: boolean;
  47713. offset?: number;
  47714. updatable?: boolean;
  47715. sideOrientation?: number;
  47716. frontUVs?: Vector4;
  47717. backUVs?: Vector4;
  47718. instance?: Mesh;
  47719. invertUV?: boolean;
  47720. uvs?: Vector2[];
  47721. colors?: Color4[];
  47722. }, scene?: Nullable<Scene>): Mesh;
  47723. /**
  47724. * Creates a cylinder or a cone mesh
  47725. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47726. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47727. * * 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.
  47728. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47729. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47730. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47731. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47732. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47733. * * 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).
  47734. * * 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
  47735. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47736. * * 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
  47737. * * 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.
  47738. * * If `enclose` is false, a ring surface is one element.
  47739. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47740. * * 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
  47741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47742. * * 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
  47743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47744. * @param name defines the name of the mesh
  47745. * @param options defines the options used to create the mesh
  47746. * @param scene defines the hosting scene
  47747. * @returns the cylinder mesh
  47748. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47749. */
  47750. static CreateCylinder(name: string, options: {
  47751. height?: number;
  47752. diameterTop?: number;
  47753. diameterBottom?: number;
  47754. diameter?: number;
  47755. tessellation?: number;
  47756. subdivisions?: number;
  47757. arc?: number;
  47758. faceColors?: Color4[];
  47759. faceUV?: Vector4[];
  47760. updatable?: boolean;
  47761. hasRings?: boolean;
  47762. enclose?: boolean;
  47763. sideOrientation?: number;
  47764. frontUVs?: Vector4;
  47765. backUVs?: Vector4;
  47766. }, scene: any): Mesh;
  47767. /**
  47768. * Creates a torus mesh
  47769. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47770. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47771. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47772. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47773. * * 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
  47774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47775. * @param name defines the name of the mesh
  47776. * @param options defines the options used to create the mesh
  47777. * @param scene defines the hosting scene
  47778. * @returns the torus mesh
  47779. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47780. */
  47781. static CreateTorus(name: string, options: {
  47782. diameter?: number;
  47783. thickness?: number;
  47784. tessellation?: number;
  47785. updatable?: boolean;
  47786. sideOrientation?: number;
  47787. frontUVs?: Vector4;
  47788. backUVs?: Vector4;
  47789. }, scene: any): Mesh;
  47790. /**
  47791. * Creates a torus knot mesh
  47792. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  47793. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  47794. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  47795. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  47796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47797. * * 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
  47798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47799. * @param name defines the name of the mesh
  47800. * @param options defines the options used to create the mesh
  47801. * @param scene defines the hosting scene
  47802. * @returns the torus knot mesh
  47803. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  47804. */
  47805. static CreateTorusKnot(name: string, options: {
  47806. radius?: number;
  47807. tube?: number;
  47808. radialSegments?: number;
  47809. tubularSegments?: number;
  47810. p?: number;
  47811. q?: number;
  47812. updatable?: boolean;
  47813. sideOrientation?: number;
  47814. frontUVs?: Vector4;
  47815. backUVs?: Vector4;
  47816. }, scene: any): Mesh;
  47817. /**
  47818. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47819. * * 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
  47820. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47821. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47822. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47823. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47824. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47825. * * 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
  47826. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47828. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47829. * @param name defines the name of the new line system
  47830. * @param options defines the options used to create the line system
  47831. * @param scene defines the hosting scene
  47832. * @returns a new line system mesh
  47833. */
  47834. static CreateLineSystem(name: string, options: {
  47835. lines: Vector3[][];
  47836. updatable?: boolean;
  47837. instance?: Nullable<LinesMesh>;
  47838. colors?: Nullable<Color4[][]>;
  47839. useVertexAlpha?: boolean;
  47840. }, scene: Nullable<Scene>): LinesMesh;
  47841. /**
  47842. * Creates a line mesh
  47843. * 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
  47844. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47845. * * The parameter `points` is an array successive Vector3
  47846. * * 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
  47847. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47848. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47849. * * When updating an instance, remember that only point positions can change, not the number of points
  47850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47851. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47852. * @param name defines the name of the new line system
  47853. * @param options defines the options used to create the line system
  47854. * @param scene defines the hosting scene
  47855. * @returns a new line mesh
  47856. */
  47857. static CreateLines(name: string, options: {
  47858. points: Vector3[];
  47859. updatable?: boolean;
  47860. instance?: Nullable<LinesMesh>;
  47861. colors?: Color4[];
  47862. useVertexAlpha?: boolean;
  47863. }, scene?: Nullable<Scene>): LinesMesh;
  47864. /**
  47865. * Creates a dashed line mesh
  47866. * * 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
  47867. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47868. * * The parameter `points` is an array successive Vector3
  47869. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47870. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47871. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47872. * * 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
  47873. * * When updating an instance, remember that only point positions can change, not the number of points
  47874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47875. * @param name defines the name of the mesh
  47876. * @param options defines the options used to create the mesh
  47877. * @param scene defines the hosting scene
  47878. * @returns the dashed line mesh
  47879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47880. */
  47881. static CreateDashedLines(name: string, options: {
  47882. points: Vector3[];
  47883. dashSize?: number;
  47884. gapSize?: number;
  47885. dashNb?: number;
  47886. updatable?: boolean;
  47887. instance?: LinesMesh;
  47888. }, scene?: Nullable<Scene>): LinesMesh;
  47889. /**
  47890. * 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.
  47891. * * 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.
  47892. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47893. * * 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.
  47894. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47895. * * 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
  47896. * * 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
  47897. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47899. * * 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
  47900. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47902. * @param name defines the name of the mesh
  47903. * @param options defines the options used to create the mesh
  47904. * @param scene defines the hosting scene
  47905. * @returns the extruded shape mesh
  47906. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47908. */
  47909. static ExtrudeShape(name: string, options: {
  47910. shape: Vector3[];
  47911. path: Vector3[];
  47912. scale?: number;
  47913. rotation?: number;
  47914. cap?: number;
  47915. updatable?: boolean;
  47916. sideOrientation?: number;
  47917. frontUVs?: Vector4;
  47918. backUVs?: Vector4;
  47919. instance?: Mesh;
  47920. invertUV?: boolean;
  47921. }, scene?: Nullable<Scene>): Mesh;
  47922. /**
  47923. * Creates an custom extruded shape mesh.
  47924. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47925. * * 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.
  47926. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47927. * * 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
  47928. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47929. * * 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
  47930. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47931. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47932. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47933. * * 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
  47934. * * 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
  47935. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47937. * * 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
  47938. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47940. * @param name defines the name of the mesh
  47941. * @param options defines the options used to create the mesh
  47942. * @param scene defines the hosting scene
  47943. * @returns the custom extruded shape mesh
  47944. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47945. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47946. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47947. */
  47948. static ExtrudeShapeCustom(name: string, options: {
  47949. shape: Vector3[];
  47950. path: Vector3[];
  47951. scaleFunction?: any;
  47952. rotationFunction?: any;
  47953. ribbonCloseArray?: boolean;
  47954. ribbonClosePath?: boolean;
  47955. cap?: number;
  47956. updatable?: boolean;
  47957. sideOrientation?: number;
  47958. frontUVs?: Vector4;
  47959. backUVs?: Vector4;
  47960. instance?: Mesh;
  47961. invertUV?: boolean;
  47962. }, scene: Scene): Mesh;
  47963. /**
  47964. * Creates lathe mesh.
  47965. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  47966. * * 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
  47967. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  47968. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  47969. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  47970. * * 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
  47971. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  47972. * * 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
  47973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47974. * * 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
  47975. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47977. * @param name defines the name of the mesh
  47978. * @param options defines the options used to create the mesh
  47979. * @param scene defines the hosting scene
  47980. * @returns the lathe mesh
  47981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  47982. */
  47983. static CreateLathe(name: string, options: {
  47984. shape: Vector3[];
  47985. radius?: number;
  47986. tessellation?: number;
  47987. clip?: number;
  47988. arc?: number;
  47989. closed?: boolean;
  47990. updatable?: boolean;
  47991. sideOrientation?: number;
  47992. frontUVs?: Vector4;
  47993. backUVs?: Vector4;
  47994. cap?: number;
  47995. invertUV?: boolean;
  47996. }, scene: Scene): Mesh;
  47997. /**
  47998. * Creates a plane mesh
  47999. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48000. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48001. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48003. * * 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
  48004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48005. * @param name defines the name of the mesh
  48006. * @param options defines the options used to create the mesh
  48007. * @param scene defines the hosting scene
  48008. * @returns the plane mesh
  48009. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48010. */
  48011. static CreatePlane(name: string, options: {
  48012. size?: number;
  48013. width?: number;
  48014. height?: number;
  48015. sideOrientation?: number;
  48016. frontUVs?: Vector4;
  48017. backUVs?: Vector4;
  48018. updatable?: boolean;
  48019. sourcePlane?: Plane;
  48020. }, scene: Scene): Mesh;
  48021. /**
  48022. * Creates a ground mesh
  48023. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48024. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48026. * @param name defines the name of the mesh
  48027. * @param options defines the options used to create the mesh
  48028. * @param scene defines the hosting scene
  48029. * @returns the ground mesh
  48030. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48031. */
  48032. static CreateGround(name: string, options: {
  48033. width?: number;
  48034. height?: number;
  48035. subdivisions?: number;
  48036. subdivisionsX?: number;
  48037. subdivisionsY?: number;
  48038. updatable?: boolean;
  48039. }, scene: any): Mesh;
  48040. /**
  48041. * Creates a tiled ground mesh
  48042. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48043. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48044. * * 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
  48045. * * 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
  48046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48047. * @param name defines the name of the mesh
  48048. * @param options defines the options used to create the mesh
  48049. * @param scene defines the hosting scene
  48050. * @returns the tiled ground mesh
  48051. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48052. */
  48053. static CreateTiledGround(name: string, options: {
  48054. xmin: number;
  48055. zmin: number;
  48056. xmax: number;
  48057. zmax: number;
  48058. subdivisions?: {
  48059. w: number;
  48060. h: number;
  48061. };
  48062. precision?: {
  48063. w: number;
  48064. h: number;
  48065. };
  48066. updatable?: boolean;
  48067. }, scene: Scene): Mesh;
  48068. /**
  48069. * Creates a ground mesh from a height map
  48070. * * The parameter `url` sets the URL of the height map image resource.
  48071. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48072. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48073. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48074. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48075. * * 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.
  48076. * * 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).
  48077. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48079. * @param name defines the name of the mesh
  48080. * @param url defines the url to the height map
  48081. * @param options defines the options used to create the mesh
  48082. * @param scene defines the hosting scene
  48083. * @returns the ground mesh
  48084. * @see https://doc.babylonjs.com/babylon101/height_map
  48085. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48086. */
  48087. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48088. width?: number;
  48089. height?: number;
  48090. subdivisions?: number;
  48091. minHeight?: number;
  48092. maxHeight?: number;
  48093. colorFilter?: Color3;
  48094. alphaFilter?: number;
  48095. updatable?: boolean;
  48096. onReady?: (mesh: GroundMesh) => void;
  48097. }, scene: Scene): GroundMesh;
  48098. /**
  48099. * Creates a polygon mesh
  48100. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  48101. * * 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
  48102. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  48103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48104. * * 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)
  48105. * * Remember you can only change the shape positions, not their number when updating a polygon
  48106. * @param name defines the name of the mesh
  48107. * @param options defines the options used to create the mesh
  48108. * @param scene defines the hosting scene
  48109. * @param earcutInjection can be used to inject your own earcut reference
  48110. * @returns the polygon mesh
  48111. */
  48112. static CreatePolygon(name: string, options: {
  48113. shape: Vector3[];
  48114. holes?: Vector3[][];
  48115. depth?: number;
  48116. faceUV?: Vector4[];
  48117. faceColors?: Color4[];
  48118. updatable?: boolean;
  48119. sideOrientation?: number;
  48120. frontUVs?: Vector4;
  48121. backUVs?: Vector4;
  48122. }, scene: Scene, earcutInjection?: any): Mesh;
  48123. /**
  48124. * Creates an extruded polygon mesh, with depth in the Y direction.
  48125. * * 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)
  48126. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48127. * @param name defines the name of the mesh
  48128. * @param options defines the options used to create the mesh
  48129. * @param scene defines the hosting scene
  48130. * @param earcutInjection can be used to inject your own earcut reference
  48131. * @returns the polygon mesh
  48132. */
  48133. static ExtrudePolygon(name: string, options: {
  48134. shape: Vector3[];
  48135. holes?: Vector3[][];
  48136. depth?: number;
  48137. faceUV?: Vector4[];
  48138. faceColors?: Color4[];
  48139. updatable?: boolean;
  48140. sideOrientation?: number;
  48141. frontUVs?: Vector4;
  48142. backUVs?: Vector4;
  48143. }, scene: Scene, earcutInjection?: any): Mesh;
  48144. /**
  48145. * Creates a tube mesh.
  48146. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48147. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  48148. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  48149. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  48150. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  48151. * * 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)
  48152. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  48153. * * 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
  48154. * * 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
  48155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48156. * * 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
  48157. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48159. * @param name defines the name of the mesh
  48160. * @param options defines the options used to create the mesh
  48161. * @param scene defines the hosting scene
  48162. * @returns the tube mesh
  48163. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48164. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  48165. */
  48166. static CreateTube(name: string, options: {
  48167. path: Vector3[];
  48168. radius?: number;
  48169. tessellation?: number;
  48170. radiusFunction?: {
  48171. (i: number, distance: number): number;
  48172. };
  48173. cap?: number;
  48174. arc?: number;
  48175. updatable?: boolean;
  48176. sideOrientation?: number;
  48177. frontUVs?: Vector4;
  48178. backUVs?: Vector4;
  48179. instance?: Mesh;
  48180. invertUV?: boolean;
  48181. }, scene: Scene): Mesh;
  48182. /**
  48183. * Creates a polyhedron mesh
  48184. * * 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
  48185. * * The parameter `size` (positive float, default 1) sets the polygon size
  48186. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48187. * * 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`
  48188. * * 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
  48189. * * 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)`)
  48190. * * 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
  48191. * * 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
  48192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48193. * * 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
  48194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48195. * @param name defines the name of the mesh
  48196. * @param options defines the options used to create the mesh
  48197. * @param scene defines the hosting scene
  48198. * @returns the polyhedron mesh
  48199. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48200. */
  48201. static CreatePolyhedron(name: string, options: {
  48202. type?: number;
  48203. size?: number;
  48204. sizeX?: number;
  48205. sizeY?: number;
  48206. sizeZ?: number;
  48207. custom?: any;
  48208. faceUV?: Vector4[];
  48209. faceColors?: Color4[];
  48210. flat?: boolean;
  48211. updatable?: boolean;
  48212. sideOrientation?: number;
  48213. frontUVs?: Vector4;
  48214. backUVs?: Vector4;
  48215. }, scene: Scene): Mesh;
  48216. /**
  48217. * Creates a decal mesh.
  48218. * 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
  48219. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  48220. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  48221. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  48222. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  48223. * @param name defines the name of the mesh
  48224. * @param sourceMesh defines the mesh where the decal must be applied
  48225. * @param options defines the options used to create the mesh
  48226. * @param scene defines the hosting scene
  48227. * @returns the decal mesh
  48228. * @see https://doc.babylonjs.com/how_to/decals
  48229. */
  48230. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  48231. position?: Vector3;
  48232. normal?: Vector3;
  48233. size?: Vector3;
  48234. angle?: number;
  48235. }): Mesh;
  48236. }
  48237. }
  48238. declare module BABYLON {
  48239. /**
  48240. * A simplifier interface for future simplification implementations
  48241. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  48242. */
  48243. export interface ISimplifier {
  48244. /**
  48245. * Simplification of a given mesh according to the given settings.
  48246. * Since this requires computation, it is assumed that the function runs async.
  48247. * @param settings The settings of the simplification, including quality and distance
  48248. * @param successCallback A callback that will be called after the mesh was simplified.
  48249. * @param errorCallback in case of an error, this callback will be called. optional.
  48250. */
  48251. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  48252. }
  48253. /**
  48254. * Expected simplification settings.
  48255. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  48256. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  48257. */
  48258. export interface ISimplificationSettings {
  48259. /**
  48260. * Gets or sets the expected quality
  48261. */
  48262. quality: number;
  48263. /**
  48264. * Gets or sets the distance when this optimized version should be used
  48265. */
  48266. distance: number;
  48267. /**
  48268. * Gets an already optimized mesh
  48269. */
  48270. optimizeMesh?: boolean;
  48271. }
  48272. /**
  48273. * Class used to specify simplification options
  48274. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  48275. */
  48276. export class SimplificationSettings implements ISimplificationSettings {
  48277. /** expected quality */
  48278. quality: number;
  48279. /** distance when this optimized version should be used */
  48280. distance: number;
  48281. /** already optimized mesh */
  48282. optimizeMesh?: boolean | undefined;
  48283. /**
  48284. * Creates a SimplificationSettings
  48285. * @param quality expected quality
  48286. * @param distance distance when this optimized version should be used
  48287. * @param optimizeMesh already optimized mesh
  48288. */
  48289. constructor(
  48290. /** expected quality */
  48291. quality: number,
  48292. /** distance when this optimized version should be used */
  48293. distance: number,
  48294. /** already optimized mesh */
  48295. optimizeMesh?: boolean | undefined);
  48296. }
  48297. /**
  48298. * Interface used to define a simplification task
  48299. */
  48300. export interface ISimplificationTask {
  48301. /**
  48302. * Array of settings
  48303. */
  48304. settings: Array<ISimplificationSettings>;
  48305. /**
  48306. * Simplification type
  48307. */
  48308. simplificationType: SimplificationType;
  48309. /**
  48310. * Mesh to simplify
  48311. */
  48312. mesh: Mesh;
  48313. /**
  48314. * Callback called on success
  48315. */
  48316. successCallback?: () => void;
  48317. /**
  48318. * Defines if parallel processing can be used
  48319. */
  48320. parallelProcessing: boolean;
  48321. }
  48322. /**
  48323. * Queue used to order the simplification tasks
  48324. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  48325. */
  48326. export class SimplificationQueue {
  48327. private _simplificationArray;
  48328. /**
  48329. * Gets a boolean indicating that the process is still running
  48330. */
  48331. running: boolean;
  48332. /**
  48333. * Creates a new queue
  48334. */
  48335. constructor();
  48336. /**
  48337. * Adds a new simplification task
  48338. * @param task defines a task to add
  48339. */
  48340. addTask(task: ISimplificationTask): void;
  48341. /**
  48342. * Execute next task
  48343. */
  48344. executeNext(): void;
  48345. /**
  48346. * Execute a simplification task
  48347. * @param task defines the task to run
  48348. */
  48349. runSimplification(task: ISimplificationTask): void;
  48350. private getSimplifier;
  48351. }
  48352. /**
  48353. * The implemented types of simplification
  48354. * At the moment only Quadratic Error Decimation is implemented
  48355. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  48356. */
  48357. export enum SimplificationType {
  48358. /** Quadratic error decimation */
  48359. QUADRATIC = 0
  48360. }
  48361. }
  48362. declare module BABYLON {
  48363. interface Scene {
  48364. /** @hidden (Backing field) */
  48365. _simplificationQueue: SimplificationQueue;
  48366. /**
  48367. * Gets or sets the simplification queue attached to the scene
  48368. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  48369. */
  48370. simplificationQueue: SimplificationQueue;
  48371. }
  48372. interface Mesh {
  48373. /**
  48374. * Simplify the mesh according to the given array of settings.
  48375. * Function will return immediately and will simplify async
  48376. * @param settings a collection of simplification settings
  48377. * @param parallelProcessing should all levels calculate parallel or one after the other
  48378. * @param simplificationType the type of simplification to run
  48379. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  48380. * @returns the current mesh
  48381. */
  48382. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  48383. }
  48384. /**
  48385. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  48386. * created in a scene
  48387. */
  48388. export class SimplicationQueueSceneComponent implements ISceneComponent {
  48389. /**
  48390. * The component name helpfull to identify the component in the list of scene components.
  48391. */
  48392. readonly name: string;
  48393. /**
  48394. * The scene the component belongs to.
  48395. */
  48396. scene: Scene;
  48397. /**
  48398. * Creates a new instance of the component for the given scene
  48399. * @param scene Defines the scene to register the component in
  48400. */
  48401. constructor(scene: Scene);
  48402. /**
  48403. * Registers the component in a given scene
  48404. */
  48405. register(): void;
  48406. /**
  48407. * Rebuilds the elements related to this component in case of
  48408. * context lost for instance.
  48409. */
  48410. rebuild(): void;
  48411. /**
  48412. * Disposes the component and the associated ressources
  48413. */
  48414. dispose(): void;
  48415. private _beforeCameraUpdate;
  48416. }
  48417. }
  48418. declare module BABYLON {
  48419. /**
  48420. * Class used to enable access to IndexedDB
  48421. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  48422. */
  48423. export class Database implements IOfflineProvider {
  48424. private _callbackManifestChecked;
  48425. private _currentSceneUrl;
  48426. private _db;
  48427. private _enableSceneOffline;
  48428. private _enableTexturesOffline;
  48429. private _manifestVersionFound;
  48430. private _mustUpdateRessources;
  48431. private _hasReachedQuota;
  48432. private _isSupported;
  48433. private _idbFactory;
  48434. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  48435. private static IsUASupportingBlobStorage;
  48436. /**
  48437. * Gets a boolean indicating if Database storate is enabled (off by default)
  48438. */
  48439. static IDBStorageEnabled: boolean;
  48440. /**
  48441. * Gets a boolean indicating if scene must be saved in the database
  48442. */
  48443. readonly enableSceneOffline: boolean;
  48444. /**
  48445. * Gets a boolean indicating if textures must be saved in the database
  48446. */
  48447. readonly enableTexturesOffline: boolean;
  48448. /**
  48449. * Creates a new Database
  48450. * @param urlToScene defines the url to load the scene
  48451. * @param callbackManifestChecked defines the callback to use when manifest is checked
  48452. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  48453. */
  48454. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  48455. private static _ParseURL;
  48456. private static _ReturnFullUrlLocation;
  48457. private _checkManifestFile;
  48458. /**
  48459. * Open the database and make it available
  48460. * @param successCallback defines the callback to call on success
  48461. * @param errorCallback defines the callback to call on error
  48462. */
  48463. open(successCallback: () => void, errorCallback: () => void): void;
  48464. /**
  48465. * Loads an image from the database
  48466. * @param url defines the url to load from
  48467. * @param image defines the target DOM image
  48468. */
  48469. loadImage(url: string, image: HTMLImageElement): void;
  48470. private _loadImageFromDBAsync;
  48471. private _saveImageIntoDBAsync;
  48472. private _checkVersionFromDB;
  48473. private _loadVersionFromDBAsync;
  48474. private _saveVersionIntoDBAsync;
  48475. /**
  48476. * Loads a file from database
  48477. * @param url defines the URL to load from
  48478. * @param sceneLoaded defines a callback to call on success
  48479. * @param progressCallBack defines a callback to call when progress changed
  48480. * @param errorCallback defines a callback to call on error
  48481. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  48482. */
  48483. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  48484. private _loadFileAsync;
  48485. private _saveFileAsync;
  48486. /**
  48487. * Validates if xhr data is correct
  48488. * @param xhr defines the request to validate
  48489. * @param dataType defines the expected data type
  48490. * @returns true if data is correct
  48491. */
  48492. private static _ValidateXHRData;
  48493. }
  48494. }
  48495. declare module BABYLON {
  48496. /** @hidden */
  48497. export var gpuUpdateParticlesPixelShader: {
  48498. name: string;
  48499. shader: string;
  48500. };
  48501. }
  48502. declare module BABYLON {
  48503. /** @hidden */
  48504. export var gpuUpdateParticlesVertexShader: {
  48505. name: string;
  48506. shader: string;
  48507. };
  48508. }
  48509. declare module BABYLON {
  48510. /** @hidden */
  48511. export var clipPlaneFragmentDeclaration2: {
  48512. name: string;
  48513. shader: string;
  48514. };
  48515. }
  48516. declare module BABYLON {
  48517. /** @hidden */
  48518. export var gpuRenderParticlesPixelShader: {
  48519. name: string;
  48520. shader: string;
  48521. };
  48522. }
  48523. declare module BABYLON {
  48524. /** @hidden */
  48525. export var clipPlaneVertexDeclaration2: {
  48526. name: string;
  48527. shader: string;
  48528. };
  48529. }
  48530. declare module BABYLON {
  48531. /** @hidden */
  48532. export var gpuRenderParticlesVertexShader: {
  48533. name: string;
  48534. shader: string;
  48535. };
  48536. }
  48537. declare module BABYLON {
  48538. /**
  48539. * This represents a GPU particle system in Babylon
  48540. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  48541. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  48542. */
  48543. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  48544. /**
  48545. * The layer mask we are rendering the particles through.
  48546. */
  48547. layerMask: number;
  48548. private _capacity;
  48549. private _activeCount;
  48550. private _currentActiveCount;
  48551. private _accumulatedCount;
  48552. private _renderEffect;
  48553. private _updateEffect;
  48554. private _buffer0;
  48555. private _buffer1;
  48556. private _spriteBuffer;
  48557. private _updateVAO;
  48558. private _renderVAO;
  48559. private _targetIndex;
  48560. private _sourceBuffer;
  48561. private _targetBuffer;
  48562. private _engine;
  48563. private _currentRenderId;
  48564. private _started;
  48565. private _stopped;
  48566. private _timeDelta;
  48567. private _randomTexture;
  48568. private _randomTexture2;
  48569. private _attributesStrideSize;
  48570. private _updateEffectOptions;
  48571. private _randomTextureSize;
  48572. private _actualFrame;
  48573. private readonly _rawTextureWidth;
  48574. /**
  48575. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  48576. */
  48577. static readonly IsSupported: boolean;
  48578. /**
  48579. * An event triggered when the system is disposed.
  48580. */
  48581. onDisposeObservable: Observable<GPUParticleSystem>;
  48582. /**
  48583. * Gets the maximum number of particles active at the same time.
  48584. * @returns The max number of active particles.
  48585. */
  48586. getCapacity(): number;
  48587. /**
  48588. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  48589. * to override the particles.
  48590. */
  48591. forceDepthWrite: boolean;
  48592. /**
  48593. * Gets or set the number of active particles
  48594. */
  48595. activeParticleCount: number;
  48596. private _preWarmDone;
  48597. /**
  48598. * Is this system ready to be used/rendered
  48599. * @return true if the system is ready
  48600. */
  48601. isReady(): boolean;
  48602. /**
  48603. * Gets if the system has been started. (Note: this will still be true after stop is called)
  48604. * @returns True if it has been started, otherwise false.
  48605. */
  48606. isStarted(): boolean;
  48607. /**
  48608. * Starts the particle system and begins to emit
  48609. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  48610. */
  48611. start(delay?: number): void;
  48612. /**
  48613. * Stops the particle system.
  48614. */
  48615. stop(): void;
  48616. /**
  48617. * Remove all active particles
  48618. */
  48619. reset(): void;
  48620. /**
  48621. * Returns the string "GPUParticleSystem"
  48622. * @returns a string containing the class name
  48623. */
  48624. getClassName(): string;
  48625. private _colorGradientsTexture;
  48626. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  48627. /**
  48628. * Adds a new color gradient
  48629. * @param gradient defines the gradient to use (between 0 and 1)
  48630. * @param color1 defines the color to affect to the specified gradient
  48631. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  48632. * @returns the current particle system
  48633. */
  48634. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  48635. /**
  48636. * Remove a specific color gradient
  48637. * @param gradient defines the gradient to remove
  48638. * @returns the current particle system
  48639. */
  48640. removeColorGradient(gradient: number): GPUParticleSystem;
  48641. private _angularSpeedGradientsTexture;
  48642. private _sizeGradientsTexture;
  48643. private _velocityGradientsTexture;
  48644. private _limitVelocityGradientsTexture;
  48645. private _dragGradientsTexture;
  48646. private _addFactorGradient;
  48647. /**
  48648. * Adds a new size gradient
  48649. * @param gradient defines the gradient to use (between 0 and 1)
  48650. * @param factor defines the size factor to affect to the specified gradient
  48651. * @returns the current particle system
  48652. */
  48653. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  48654. /**
  48655. * Remove a specific size gradient
  48656. * @param gradient defines the gradient to remove
  48657. * @returns the current particle system
  48658. */
  48659. removeSizeGradient(gradient: number): GPUParticleSystem;
  48660. /**
  48661. * Adds a new angular speed gradient
  48662. * @param gradient defines the gradient to use (between 0 and 1)
  48663. * @param factor defines the angular speed to affect to the specified gradient
  48664. * @returns the current particle system
  48665. */
  48666. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  48667. /**
  48668. * Remove a specific angular speed gradient
  48669. * @param gradient defines the gradient to remove
  48670. * @returns the current particle system
  48671. */
  48672. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  48673. /**
  48674. * Adds a new velocity gradient
  48675. * @param gradient defines the gradient to use (between 0 and 1)
  48676. * @param factor defines the velocity to affect to the specified gradient
  48677. * @returns the current particle system
  48678. */
  48679. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  48680. /**
  48681. * Remove a specific velocity gradient
  48682. * @param gradient defines the gradient to remove
  48683. * @returns the current particle system
  48684. */
  48685. removeVelocityGradient(gradient: number): GPUParticleSystem;
  48686. /**
  48687. * Adds a new limit velocity gradient
  48688. * @param gradient defines the gradient to use (between 0 and 1)
  48689. * @param factor defines the limit velocity value to affect to the specified gradient
  48690. * @returns the current particle system
  48691. */
  48692. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  48693. /**
  48694. * Remove a specific limit velocity gradient
  48695. * @param gradient defines the gradient to remove
  48696. * @returns the current particle system
  48697. */
  48698. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  48699. /**
  48700. * Adds a new drag gradient
  48701. * @param gradient defines the gradient to use (between 0 and 1)
  48702. * @param factor defines the drag value to affect to the specified gradient
  48703. * @returns the current particle system
  48704. */
  48705. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  48706. /**
  48707. * Remove a specific drag gradient
  48708. * @param gradient defines the gradient to remove
  48709. * @returns the current particle system
  48710. */
  48711. removeDragGradient(gradient: number): GPUParticleSystem;
  48712. /**
  48713. * Not supported by GPUParticleSystem
  48714. * @param gradient defines the gradient to use (between 0 and 1)
  48715. * @param factor defines the emit rate value to affect to the specified gradient
  48716. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  48717. * @returns the current particle system
  48718. */
  48719. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  48720. /**
  48721. * Not supported by GPUParticleSystem
  48722. * @param gradient defines the gradient to remove
  48723. * @returns the current particle system
  48724. */
  48725. removeEmitRateGradient(gradient: number): IParticleSystem;
  48726. /**
  48727. * Not supported by GPUParticleSystem
  48728. * @param gradient defines the gradient to use (between 0 and 1)
  48729. * @param factor defines the start size value to affect to the specified gradient
  48730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  48731. * @returns the current particle system
  48732. */
  48733. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  48734. /**
  48735. * Not supported by GPUParticleSystem
  48736. * @param gradient defines the gradient to remove
  48737. * @returns the current particle system
  48738. */
  48739. removeStartSizeGradient(gradient: number): IParticleSystem;
  48740. /**
  48741. * Not supported by GPUParticleSystem
  48742. * @param gradient defines the gradient to use (between 0 and 1)
  48743. * @param min defines the color remap minimal range
  48744. * @param max defines the color remap maximal range
  48745. * @returns the current particle system
  48746. */
  48747. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  48748. /**
  48749. * Not supported by GPUParticleSystem
  48750. * @param gradient defines the gradient to remove
  48751. * @returns the current particle system
  48752. */
  48753. removeColorRemapGradient(): IParticleSystem;
  48754. /**
  48755. * Not supported by GPUParticleSystem
  48756. * @param gradient defines the gradient to use (between 0 and 1)
  48757. * @param min defines the alpha remap minimal range
  48758. * @param max defines the alpha remap maximal range
  48759. * @returns the current particle system
  48760. */
  48761. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  48762. /**
  48763. * Not supported by GPUParticleSystem
  48764. * @param gradient defines the gradient to remove
  48765. * @returns the current particle system
  48766. */
  48767. removeAlphaRemapGradient(): IParticleSystem;
  48768. /**
  48769. * Not supported by GPUParticleSystem
  48770. * @param gradient defines the gradient to use (between 0 and 1)
  48771. * @param color defines the color to affect to the specified gradient
  48772. * @returns the current particle system
  48773. */
  48774. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  48775. /**
  48776. * Not supported by GPUParticleSystem
  48777. * @param gradient defines the gradient to remove
  48778. * @returns the current particle system
  48779. */
  48780. removeRampGradient(): IParticleSystem;
  48781. /**
  48782. * Not supported by GPUParticleSystem
  48783. * @returns the list of ramp gradients
  48784. */
  48785. getRampGradients(): Nullable<Array<Color3Gradient>>;
  48786. /**
  48787. * Not supported by GPUParticleSystem
  48788. * Gets or sets a boolean indicating that ramp gradients must be used
  48789. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  48790. */
  48791. useRampGradients: boolean;
  48792. /**
  48793. * Not supported by GPUParticleSystem
  48794. * @param gradient defines the gradient to use (between 0 and 1)
  48795. * @param factor defines the life time factor to affect to the specified gradient
  48796. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  48797. * @returns the current particle system
  48798. */
  48799. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  48800. /**
  48801. * Not supported by GPUParticleSystem
  48802. * @param gradient defines the gradient to remove
  48803. * @returns the current particle system
  48804. */
  48805. removeLifeTimeGradient(gradient: number): IParticleSystem;
  48806. /**
  48807. * Instantiates a GPU particle system.
  48808. * 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.
  48809. * @param name The name of the particle system
  48810. * @param options The options used to create the system
  48811. * @param scene The scene the particle system belongs to
  48812. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  48813. */
  48814. constructor(name: string, options: Partial<{
  48815. capacity: number;
  48816. randomTextureSize: number;
  48817. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  48818. protected _reset(): void;
  48819. private _createUpdateVAO;
  48820. private _createRenderVAO;
  48821. private _initialize;
  48822. /** @hidden */
  48823. _recreateUpdateEffect(): void;
  48824. /** @hidden */
  48825. _recreateRenderEffect(): void;
  48826. /**
  48827. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  48828. * @param preWarm defines if we are in the pre-warmimg phase
  48829. */
  48830. animate(preWarm?: boolean): void;
  48831. private _createFactorGradientTexture;
  48832. private _createSizeGradientTexture;
  48833. private _createAngularSpeedGradientTexture;
  48834. private _createVelocityGradientTexture;
  48835. private _createLimitVelocityGradientTexture;
  48836. private _createDragGradientTexture;
  48837. private _createColorGradientTexture;
  48838. /**
  48839. * Renders the particle system in its current state
  48840. * @param preWarm defines if the system should only update the particles but not render them
  48841. * @returns the current number of particles
  48842. */
  48843. render(preWarm?: boolean): number;
  48844. /**
  48845. * Rebuilds the particle system
  48846. */
  48847. rebuild(): void;
  48848. private _releaseBuffers;
  48849. private _releaseVAOs;
  48850. /**
  48851. * Disposes the particle system and free the associated resources
  48852. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  48853. */
  48854. dispose(disposeTexture?: boolean): void;
  48855. /**
  48856. * Clones the particle system.
  48857. * @param name The name of the cloned object
  48858. * @param newEmitter The new emitter to use
  48859. * @returns the cloned particle system
  48860. */
  48861. clone(name: string, newEmitter: any): GPUParticleSystem;
  48862. /**
  48863. * Serializes the particle system to a JSON object.
  48864. * @returns the JSON object
  48865. */
  48866. serialize(): any;
  48867. /**
  48868. * Parses a JSON object to create a GPU particle system.
  48869. * @param parsedParticleSystem The JSON object to parse
  48870. * @param scene The scene to create the particle system in
  48871. * @param rootUrl The root url to use to load external dependencies like texture
  48872. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  48873. * @returns the parsed GPU particle system
  48874. */
  48875. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  48876. }
  48877. }
  48878. declare module BABYLON {
  48879. /**
  48880. * Represents a set of particle systems working together to create a specific effect
  48881. */
  48882. export class ParticleSystemSet implements IDisposable {
  48883. private _emitterCreationOptions;
  48884. private _emitterNode;
  48885. /**
  48886. * Gets the particle system list
  48887. */
  48888. systems: IParticleSystem[];
  48889. /**
  48890. * Gets the emitter node used with this set
  48891. */
  48892. readonly emitterNode: Nullable<TransformNode>;
  48893. /**
  48894. * Creates a new emitter mesh as a sphere
  48895. * @param options defines the options used to create the sphere
  48896. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  48897. * @param scene defines the hosting scene
  48898. */
  48899. setEmitterAsSphere(options: {
  48900. diameter: number;
  48901. segments: number;
  48902. color: Color3;
  48903. }, renderingGroupId: number, scene: Scene): void;
  48904. /**
  48905. * Starts all particle systems of the set
  48906. * @param emitter defines an optional mesh to use as emitter for the particle systems
  48907. */
  48908. start(emitter?: AbstractMesh): void;
  48909. /**
  48910. * Release all associated resources
  48911. */
  48912. dispose(): void;
  48913. /**
  48914. * Serialize the set into a JSON compatible object
  48915. * @returns a JSON compatible representation of the set
  48916. */
  48917. serialize(): any;
  48918. /**
  48919. * Parse a new ParticleSystemSet from a serialized source
  48920. * @param data defines a JSON compatible representation of the set
  48921. * @param scene defines the hosting scene
  48922. * @param gpu defines if we want GPU particles or CPU particles
  48923. * @returns a new ParticleSystemSet
  48924. */
  48925. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  48926. }
  48927. }
  48928. declare module BABYLON {
  48929. /**
  48930. * This class is made for on one-liner static method to help creating particle system set.
  48931. */
  48932. export class ParticleHelper {
  48933. /**
  48934. * Gets or sets base Assets URL
  48935. */
  48936. static BaseAssetsUrl: string;
  48937. /**
  48938. * Create a default particle system that you can tweak
  48939. * @param emitter defines the emitter to use
  48940. * @param capacity defines the system capacity (default is 500 particles)
  48941. * @param scene defines the hosting scene
  48942. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  48943. * @returns the new Particle system
  48944. */
  48945. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  48946. /**
  48947. * This is the main static method (one-liner) of this helper to create different particle systems
  48948. * @param type This string represents the type to the particle system to create
  48949. * @param scene The scene where the particle system should live
  48950. * @param gpu If the system will use gpu
  48951. * @returns the ParticleSystemSet created
  48952. */
  48953. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  48954. /**
  48955. * Static function used to export a particle system to a ParticleSystemSet variable.
  48956. * Please note that the emitter shape is not exported
  48957. * @param systems defines the particle systems to export
  48958. * @returns the created particle system set
  48959. */
  48960. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  48961. }
  48962. }
  48963. declare module BABYLON {
  48964. interface Engine {
  48965. /**
  48966. * Create an effect to use with particle systems.
  48967. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  48968. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  48969. * @param uniformsNames defines a list of attribute names
  48970. * @param samplers defines an array of string used to represent textures
  48971. * @param defines defines the string containing the defines to use to compile the shaders
  48972. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  48973. * @param onCompiled defines a function to call when the effect creation is successful
  48974. * @param onError defines a function to call when the effect creation has failed
  48975. * @returns the new Effect
  48976. */
  48977. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  48978. }
  48979. interface Mesh {
  48980. /**
  48981. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  48982. * @returns an array of IParticleSystem
  48983. */
  48984. getEmittedParticleSystems(): IParticleSystem[];
  48985. /**
  48986. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  48987. * @returns an array of IParticleSystem
  48988. */
  48989. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  48990. }
  48991. /**
  48992. * @hidden
  48993. */
  48994. export var _IDoNeedToBeInTheBuild: number;
  48995. }
  48996. declare module BABYLON {
  48997. interface Scene {
  48998. /** @hidden (Backing field) */
  48999. _physicsEngine: Nullable<IPhysicsEngine>;
  49000. /**
  49001. * Gets the current physics engine
  49002. * @returns a IPhysicsEngine or null if none attached
  49003. */
  49004. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  49005. /**
  49006. * Enables physics to the current scene
  49007. * @param gravity defines the scene's gravity for the physics engine
  49008. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  49009. * @return a boolean indicating if the physics engine was initialized
  49010. */
  49011. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  49012. /**
  49013. * Disables and disposes the physics engine associated with the scene
  49014. */
  49015. disablePhysicsEngine(): void;
  49016. /**
  49017. * Gets a boolean indicating if there is an active physics engine
  49018. * @returns a boolean indicating if there is an active physics engine
  49019. */
  49020. isPhysicsEnabled(): boolean;
  49021. /**
  49022. * Deletes a physics compound impostor
  49023. * @param compound defines the compound to delete
  49024. */
  49025. deleteCompoundImpostor(compound: any): void;
  49026. /**
  49027. * An event triggered when physic simulation is about to be run
  49028. */
  49029. onBeforePhysicsObservable: Observable<Scene>;
  49030. /**
  49031. * An event triggered when physic simulation has been done
  49032. */
  49033. onAfterPhysicsObservable: Observable<Scene>;
  49034. }
  49035. interface AbstractMesh {
  49036. /** @hidden */
  49037. _physicsImpostor: Nullable<PhysicsImpostor>;
  49038. /**
  49039. * Gets or sets impostor used for physic simulation
  49040. * @see http://doc.babylonjs.com/features/physics_engine
  49041. */
  49042. physicsImpostor: Nullable<PhysicsImpostor>;
  49043. /**
  49044. * Gets the current physics impostor
  49045. * @see http://doc.babylonjs.com/features/physics_engine
  49046. * @returns a physics impostor or null
  49047. */
  49048. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  49049. /** Apply a physic impulse to the mesh
  49050. * @param force defines the force to apply
  49051. * @param contactPoint defines where to apply the force
  49052. * @returns the current mesh
  49053. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49054. */
  49055. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  49056. /**
  49057. * Creates a physic joint between two meshes
  49058. * @param otherMesh defines the other mesh to use
  49059. * @param pivot1 defines the pivot to use on this mesh
  49060. * @param pivot2 defines the pivot to use on the other mesh
  49061. * @param options defines additional options (can be plugin dependent)
  49062. * @returns the current mesh
  49063. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  49064. */
  49065. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  49066. /** @hidden */
  49067. _disposePhysicsObserver: Nullable<Observer<Node>>;
  49068. }
  49069. /**
  49070. * Defines the physics engine scene component responsible to manage a physics engine
  49071. */
  49072. export class PhysicsEngineSceneComponent implements ISceneComponent {
  49073. /**
  49074. * The component name helpful to identify the component in the list of scene components.
  49075. */
  49076. readonly name: string;
  49077. /**
  49078. * The scene the component belongs to.
  49079. */
  49080. scene: Scene;
  49081. /**
  49082. * Creates a new instance of the component for the given scene
  49083. * @param scene Defines the scene to register the component in
  49084. */
  49085. constructor(scene: Scene);
  49086. /**
  49087. * Registers the component in a given scene
  49088. */
  49089. register(): void;
  49090. /**
  49091. * Rebuilds the elements related to this component in case of
  49092. * context lost for instance.
  49093. */
  49094. rebuild(): void;
  49095. /**
  49096. * Disposes the component and the associated ressources
  49097. */
  49098. dispose(): void;
  49099. }
  49100. }
  49101. declare module BABYLON {
  49102. /**
  49103. * A helper for physics simulations
  49104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49105. */
  49106. export class PhysicsHelper {
  49107. private _scene;
  49108. private _physicsEngine;
  49109. /**
  49110. * Initializes the Physics helper
  49111. * @param scene Babylon.js scene
  49112. */
  49113. constructor(scene: Scene);
  49114. /**
  49115. * Applies a radial explosion impulse
  49116. * @param origin the origin of the explosion
  49117. * @param radius the explosion radius
  49118. * @param strength the explosion strength
  49119. * @param falloff possible options: Constant & Linear. Defaults to Constant
  49120. * @returns A physics radial explosion event, or null
  49121. */
  49122. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  49123. /**
  49124. * Applies a radial explosion force
  49125. * @param origin the origin of the explosion
  49126. * @param radius the explosion radius
  49127. * @param strength the explosion strength
  49128. * @param falloff possible options: Constant & Linear. Defaults to Constant
  49129. * @returns A physics radial explosion event, or null
  49130. */
  49131. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  49132. /**
  49133. * Creates a gravitational field
  49134. * @param origin the origin of the explosion
  49135. * @param radius the explosion radius
  49136. * @param strength the explosion strength
  49137. * @param falloff possible options: Constant & Linear. Defaults to Constant
  49138. * @returns A physics gravitational field event, or null
  49139. */
  49140. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  49141. /**
  49142. * Creates a physics updraft event
  49143. * @param origin the origin of the updraft
  49144. * @param radius the radius of the updraft
  49145. * @param strength the strength of the updraft
  49146. * @param height the height of the updraft
  49147. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  49148. * @returns A physics updraft event, or null
  49149. */
  49150. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  49151. /**
  49152. * Creates a physics vortex event
  49153. * @param origin the of the vortex
  49154. * @param radius the radius of the vortex
  49155. * @param strength the strength of the vortex
  49156. * @param height the height of the vortex
  49157. * @returns a Physics vortex event, or null
  49158. * A physics vortex event or null
  49159. */
  49160. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  49161. }
  49162. /**
  49163. * Represents a physics radial explosion event
  49164. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49165. */
  49166. export class PhysicsRadialExplosionEvent {
  49167. private _scene;
  49168. private _sphere;
  49169. private _sphereOptions;
  49170. private _rays;
  49171. private _dataFetched;
  49172. /**
  49173. * Initializes a radial explosioin event
  49174. * @param scene BabylonJS scene
  49175. */
  49176. constructor(scene: Scene);
  49177. /**
  49178. * Returns the data related to the radial explosion event (sphere & rays).
  49179. * @returns The radial explosion event data
  49180. */
  49181. getData(): PhysicsRadialExplosionEventData;
  49182. /**
  49183. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  49184. * @param impostor A physics imposter
  49185. * @param origin the origin of the explosion
  49186. * @param radius the explosion radius
  49187. * @param strength the explosion strength
  49188. * @param falloff possible options: Constant & Linear
  49189. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  49190. */
  49191. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  49192. /**
  49193. * Disposes the sphere.
  49194. * @param force Specifies if the sphere should be disposed by force
  49195. */
  49196. dispose(force?: boolean): void;
  49197. /*** Helpers ***/
  49198. private _prepareSphere;
  49199. private _intersectsWithSphere;
  49200. }
  49201. /**
  49202. * Represents a gravitational field event
  49203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49204. */
  49205. export class PhysicsGravitationalFieldEvent {
  49206. private _physicsHelper;
  49207. private _scene;
  49208. private _origin;
  49209. private _radius;
  49210. private _strength;
  49211. private _falloff;
  49212. private _tickCallback;
  49213. private _sphere;
  49214. private _dataFetched;
  49215. /**
  49216. * Initializes the physics gravitational field event
  49217. * @param physicsHelper A physics helper
  49218. * @param scene BabylonJS scene
  49219. * @param origin The origin position of the gravitational field event
  49220. * @param radius The radius of the gravitational field event
  49221. * @param strength The strength of the gravitational field event
  49222. * @param falloff The falloff for the gravitational field event
  49223. */
  49224. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  49225. /**
  49226. * Returns the data related to the gravitational field event (sphere).
  49227. * @returns A gravitational field event
  49228. */
  49229. getData(): PhysicsGravitationalFieldEventData;
  49230. /**
  49231. * Enables the gravitational field.
  49232. */
  49233. enable(): void;
  49234. /**
  49235. * Disables the gravitational field.
  49236. */
  49237. disable(): void;
  49238. /**
  49239. * Disposes the sphere.
  49240. * @param force The force to dispose from the gravitational field event
  49241. */
  49242. dispose(force?: boolean): void;
  49243. private _tick;
  49244. }
  49245. /**
  49246. * Represents a physics updraft event
  49247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49248. */
  49249. export class PhysicsUpdraftEvent {
  49250. private _scene;
  49251. private _origin;
  49252. private _radius;
  49253. private _strength;
  49254. private _height;
  49255. private _updraftMode;
  49256. private _physicsEngine;
  49257. private _originTop;
  49258. private _originDirection;
  49259. private _tickCallback;
  49260. private _cylinder;
  49261. private _cylinderPosition;
  49262. private _dataFetched;
  49263. /**
  49264. * Initializes the physics updraft event
  49265. * @param _scene BabylonJS scene
  49266. * @param _origin The origin position of the updraft
  49267. * @param _radius The radius of the updraft
  49268. * @param _strength The strength of the updraft
  49269. * @param _height The height of the updraft
  49270. * @param _updraftMode The mode of the updraft
  49271. */
  49272. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  49273. /**
  49274. * Returns the data related to the updraft event (cylinder).
  49275. * @returns A physics updraft event
  49276. */
  49277. getData(): PhysicsUpdraftEventData;
  49278. /**
  49279. * Enables the updraft.
  49280. */
  49281. enable(): void;
  49282. /**
  49283. * Disables the cortex.
  49284. */
  49285. disable(): void;
  49286. /**
  49287. * Disposes the sphere.
  49288. * @param force Specifies if the updraft should be disposed by force
  49289. */
  49290. dispose(force?: boolean): void;
  49291. private getImpostorForceAndContactPoint;
  49292. private _tick;
  49293. /*** Helpers ***/
  49294. private _prepareCylinder;
  49295. private _intersectsWithCylinder;
  49296. }
  49297. /**
  49298. * Represents a physics vortex event
  49299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49300. */
  49301. export class PhysicsVortexEvent {
  49302. private _scene;
  49303. private _origin;
  49304. private _radius;
  49305. private _strength;
  49306. private _height;
  49307. private _physicsEngine;
  49308. private _originTop;
  49309. private _centripetalForceThreshold;
  49310. private _updraftMultiplier;
  49311. private _tickCallback;
  49312. private _cylinder;
  49313. private _cylinderPosition;
  49314. private _dataFetched;
  49315. /**
  49316. * Initializes the physics vortex event
  49317. * @param _scene The BabylonJS scene
  49318. * @param _origin The origin position of the vortex
  49319. * @param _radius The radius of the vortex
  49320. * @param _strength The strength of the vortex
  49321. * @param _height The height of the vortex
  49322. */
  49323. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  49324. /**
  49325. * Returns the data related to the vortex event (cylinder).
  49326. * @returns The physics vortex event data
  49327. */
  49328. getData(): PhysicsVortexEventData;
  49329. /**
  49330. * Enables the vortex.
  49331. */
  49332. enable(): void;
  49333. /**
  49334. * Disables the cortex.
  49335. */
  49336. disable(): void;
  49337. /**
  49338. * Disposes the sphere.
  49339. * @param force
  49340. */
  49341. dispose(force?: boolean): void;
  49342. private getImpostorForceAndContactPoint;
  49343. private _tick;
  49344. /*** Helpers ***/
  49345. private _prepareCylinder;
  49346. private _intersectsWithCylinder;
  49347. }
  49348. /**
  49349. * The strenght of the force in correspondence to the distance of the affected object
  49350. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49351. */
  49352. export enum PhysicsRadialImpulseFalloff {
  49353. /** Defines that impulse is constant in strength across it's whole radius */
  49354. Constant = 0,
  49355. /** DEfines that impulse gets weaker if it's further from the origin */
  49356. Linear = 1
  49357. }
  49358. /**
  49359. * The strength of the force in correspondence to the distance of the affected object
  49360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49361. */
  49362. export enum PhysicsUpdraftMode {
  49363. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  49364. Center = 0,
  49365. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  49366. Perpendicular = 1
  49367. }
  49368. /**
  49369. * Interface for a physics force and contact point
  49370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49371. */
  49372. export interface PhysicsForceAndContactPoint {
  49373. /**
  49374. * The force applied at the contact point
  49375. */
  49376. force: Vector3;
  49377. /**
  49378. * The contact point
  49379. */
  49380. contactPoint: Vector3;
  49381. }
  49382. /**
  49383. * Interface for radial explosion event data
  49384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49385. */
  49386. export interface PhysicsRadialExplosionEventData {
  49387. /**
  49388. * A sphere used for the radial explosion event
  49389. */
  49390. sphere: Mesh;
  49391. /**
  49392. * An array of rays for the radial explosion event
  49393. */
  49394. rays: Array<Ray>;
  49395. }
  49396. /**
  49397. * Interface for gravitational field event data
  49398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49399. */
  49400. export interface PhysicsGravitationalFieldEventData {
  49401. /**
  49402. * A sphere mesh used for the gravitational field event
  49403. */
  49404. sphere: Mesh;
  49405. }
  49406. /**
  49407. * Interface for updraft event data
  49408. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49409. */
  49410. export interface PhysicsUpdraftEventData {
  49411. /**
  49412. * A cylinder used for the updraft event
  49413. */
  49414. cylinder: Mesh;
  49415. }
  49416. /**
  49417. * Interface for vortex event data
  49418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49419. */
  49420. export interface PhysicsVortexEventData {
  49421. /**
  49422. * A cylinder used for the vortex event
  49423. */
  49424. cylinder: Mesh;
  49425. }
  49426. }
  49427. declare module BABYLON {
  49428. /**
  49429. * AmmoJS Physics plugin
  49430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49431. * @see https://github.com/kripken/ammo.js/
  49432. */
  49433. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49434. private _useDeltaForWorldStep;
  49435. /**
  49436. * Reference to the Ammo library
  49437. */
  49438. bjsAMMO: any;
  49439. /**
  49440. * Created ammoJS world which physics bodies are added to
  49441. */
  49442. world: any;
  49443. /**
  49444. * Name of the plugin
  49445. */
  49446. name: string;
  49447. private _timeStep;
  49448. private _fixedTimeStep;
  49449. private _maxSteps;
  49450. private _tmpQuaternion;
  49451. private _tmpAmmoTransform;
  49452. private _tmpAmmoQuaternion;
  49453. private _tmpAmmoConcreteContactResultCallback;
  49454. private _collisionConfiguration;
  49455. private _dispatcher;
  49456. private _overlappingPairCache;
  49457. private _solver;
  49458. private _tmpAmmoVectorA;
  49459. private _tmpAmmoVectorB;
  49460. private _tmpAmmoVectorC;
  49461. private _tmpContactCallbackResult;
  49462. private static readonly DISABLE_COLLISION_FLAG;
  49463. private static readonly KINEMATIC_FLAG;
  49464. private static readonly DISABLE_DEACTIVATION_FLAG;
  49465. /**
  49466. * Initializes the ammoJS plugin
  49467. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49468. * @param ammoInjection can be used to inject your own ammo reference
  49469. */
  49470. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  49471. /**
  49472. * Sets the gravity of the physics world (m/(s^2))
  49473. * @param gravity Gravity to set
  49474. */
  49475. setGravity(gravity: Vector3): void;
  49476. /**
  49477. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49478. * @param timeStep timestep to use in seconds
  49479. */
  49480. setTimeStep(timeStep: number): void;
  49481. /**
  49482. * 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)
  49483. * @param fixedTimeStep fixedTimeStep to use in seconds
  49484. */
  49485. setFixedTimeStep(fixedTimeStep: number): void;
  49486. /**
  49487. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49488. * @param maxSteps the maximum number of steps by the physics engine per frame
  49489. */
  49490. setMaxSteps(maxSteps: number): void;
  49491. /**
  49492. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49493. * @returns the current timestep in seconds
  49494. */
  49495. getTimeStep(): number;
  49496. private _isImpostorInContact;
  49497. private _isImpostorPairInContact;
  49498. private _stepSimulation;
  49499. /**
  49500. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49501. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49502. * After the step the babylon meshes are set to the position of the physics imposters
  49503. * @param delta amount of time to step forward
  49504. * @param impostors array of imposters to update before/after the step
  49505. */
  49506. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49507. private _tmpVector;
  49508. private _tmpMatrix;
  49509. /**
  49510. * Applies an implulse on the imposter
  49511. * @param impostor imposter to apply impulse
  49512. * @param force amount of force to be applied to the imposter
  49513. * @param contactPoint the location to apply the impulse on the imposter
  49514. */
  49515. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49516. /**
  49517. * Applies a force on the imposter
  49518. * @param impostor imposter to apply force
  49519. * @param force amount of force to be applied to the imposter
  49520. * @param contactPoint the location to apply the force on the imposter
  49521. */
  49522. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49523. /**
  49524. * Creates a physics body using the plugin
  49525. * @param impostor the imposter to create the physics body on
  49526. */
  49527. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49528. /**
  49529. * Removes the physics body from the imposter and disposes of the body's memory
  49530. * @param impostor imposter to remove the physics body from
  49531. */
  49532. removePhysicsBody(impostor: PhysicsImpostor): void;
  49533. /**
  49534. * Generates a joint
  49535. * @param impostorJoint the imposter joint to create the joint with
  49536. */
  49537. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49538. /**
  49539. * Removes a joint
  49540. * @param impostorJoint the imposter joint to remove the joint from
  49541. */
  49542. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49543. private _addMeshVerts;
  49544. private _createShape;
  49545. /**
  49546. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49547. * @param impostor imposter containing the physics body and babylon object
  49548. */
  49549. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49550. /**
  49551. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49552. * @param impostor imposter containing the physics body and babylon object
  49553. * @param newPosition new position
  49554. * @param newRotation new rotation
  49555. */
  49556. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49557. /**
  49558. * If this plugin is supported
  49559. * @returns true if its supported
  49560. */
  49561. isSupported(): boolean;
  49562. /**
  49563. * Sets the linear velocity of the physics body
  49564. * @param impostor imposter to set the velocity on
  49565. * @param velocity velocity to set
  49566. */
  49567. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49568. /**
  49569. * Sets the angular velocity of the physics body
  49570. * @param impostor imposter to set the velocity on
  49571. * @param velocity velocity to set
  49572. */
  49573. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49574. /**
  49575. * gets the linear velocity
  49576. * @param impostor imposter to get linear velocity from
  49577. * @returns linear velocity
  49578. */
  49579. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49580. /**
  49581. * gets the angular velocity
  49582. * @param impostor imposter to get angular velocity from
  49583. * @returns angular velocity
  49584. */
  49585. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49586. /**
  49587. * Sets the mass of physics body
  49588. * @param impostor imposter to set the mass on
  49589. * @param mass mass to set
  49590. */
  49591. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49592. /**
  49593. * Gets the mass of the physics body
  49594. * @param impostor imposter to get the mass from
  49595. * @returns mass
  49596. */
  49597. getBodyMass(impostor: PhysicsImpostor): number;
  49598. /**
  49599. * Gets friction of the impostor
  49600. * @param impostor impostor to get friction from
  49601. * @returns friction value
  49602. */
  49603. getBodyFriction(impostor: PhysicsImpostor): number;
  49604. /**
  49605. * Sets friction of the impostor
  49606. * @param impostor impostor to set friction on
  49607. * @param friction friction value
  49608. */
  49609. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49610. /**
  49611. * Gets restitution of the impostor
  49612. * @param impostor impostor to get restitution from
  49613. * @returns restitution value
  49614. */
  49615. getBodyRestitution(impostor: PhysicsImpostor): number;
  49616. /**
  49617. * Sets resitution of the impostor
  49618. * @param impostor impostor to set resitution on
  49619. * @param restitution resitution value
  49620. */
  49621. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49622. /**
  49623. * Sleeps the physics body and stops it from being active
  49624. * @param impostor impostor to sleep
  49625. */
  49626. sleepBody(impostor: PhysicsImpostor): void;
  49627. /**
  49628. * Activates the physics body
  49629. * @param impostor impostor to activate
  49630. */
  49631. wakeUpBody(impostor: PhysicsImpostor): void;
  49632. /**
  49633. * Updates the distance parameters of the joint
  49634. * @param joint joint to update
  49635. * @param maxDistance maximum distance of the joint
  49636. * @param minDistance minimum distance of the joint
  49637. */
  49638. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49639. /**
  49640. * Sets a motor on the joint
  49641. * @param joint joint to set motor on
  49642. * @param speed speed of the motor
  49643. * @param maxForce maximum force of the motor
  49644. * @param motorIndex index of the motor
  49645. */
  49646. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49647. /**
  49648. * Sets the motors limit
  49649. * @param joint joint to set limit on
  49650. * @param upperLimit upper limit
  49651. * @param lowerLimit lower limit
  49652. */
  49653. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49654. /**
  49655. * Syncs the position and rotation of a mesh with the impostor
  49656. * @param mesh mesh to sync
  49657. * @param impostor impostor to update the mesh with
  49658. */
  49659. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49660. /**
  49661. * Gets the radius of the impostor
  49662. * @param impostor impostor to get radius from
  49663. * @returns the radius
  49664. */
  49665. getRadius(impostor: PhysicsImpostor): number;
  49666. /**
  49667. * Gets the box size of the impostor
  49668. * @param impostor impostor to get box size from
  49669. * @param result the resulting box size
  49670. */
  49671. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49672. /**
  49673. * Disposes of the impostor
  49674. */
  49675. dispose(): void;
  49676. }
  49677. }
  49678. declare module BABYLON {
  49679. /** @hidden */
  49680. export var blackAndWhitePixelShader: {
  49681. name: string;
  49682. shader: string;
  49683. };
  49684. }
  49685. declare module BABYLON {
  49686. /**
  49687. * Post process used to render in black and white
  49688. */
  49689. export class BlackAndWhitePostProcess extends PostProcess {
  49690. /**
  49691. * Linear about to convert he result to black and white (default: 1)
  49692. */
  49693. degree: number;
  49694. /**
  49695. * Creates a black and white post process
  49696. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  49697. * @param name The name of the effect.
  49698. * @param options The required width/height ratio to downsize to before computing the render pass.
  49699. * @param camera The camera to apply the render pass to.
  49700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49701. * @param engine The engine which the post process will be applied. (default: current engine)
  49702. * @param reusable If the post process can be reused on the same frame. (default: false)
  49703. */
  49704. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49705. }
  49706. }
  49707. declare module BABYLON {
  49708. /**
  49709. * This represents a set of one or more post processes in Babylon.
  49710. * A post process can be used to apply a shader to a texture after it is rendered.
  49711. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49712. */
  49713. export class PostProcessRenderEffect {
  49714. private _postProcesses;
  49715. private _getPostProcesses;
  49716. private _singleInstance;
  49717. private _cameras;
  49718. private _indicesForCamera;
  49719. /**
  49720. * Name of the effect
  49721. * @hidden
  49722. */
  49723. _name: string;
  49724. /**
  49725. * Instantiates a post process render effect.
  49726. * A post process can be used to apply a shader to a texture after it is rendered.
  49727. * @param engine The engine the effect is tied to
  49728. * @param name The name of the effect
  49729. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49730. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49731. */
  49732. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49733. /**
  49734. * Checks if all the post processes in the effect are supported.
  49735. */
  49736. readonly isSupported: boolean;
  49737. /**
  49738. * Updates the current state of the effect
  49739. * @hidden
  49740. */
  49741. _update(): void;
  49742. /**
  49743. * Attaches the effect on cameras
  49744. * @param cameras The camera to attach to.
  49745. * @hidden
  49746. */
  49747. _attachCameras(cameras: Camera): void;
  49748. /**
  49749. * Attaches the effect on cameras
  49750. * @param cameras The camera to attach to.
  49751. * @hidden
  49752. */
  49753. _attachCameras(cameras: Camera[]): void;
  49754. /**
  49755. * Detatches the effect on cameras
  49756. * @param cameras The camera to detatch from.
  49757. * @hidden
  49758. */
  49759. _detachCameras(cameras: Camera): void;
  49760. /**
  49761. * Detatches the effect on cameras
  49762. * @param cameras The camera to detatch from.
  49763. * @hidden
  49764. */
  49765. _detachCameras(cameras: Camera[]): void;
  49766. /**
  49767. * Enables the effect on given cameras
  49768. * @param cameras The camera to enable.
  49769. * @hidden
  49770. */
  49771. _enable(cameras: Camera): void;
  49772. /**
  49773. * Enables the effect on given cameras
  49774. * @param cameras The camera to enable.
  49775. * @hidden
  49776. */
  49777. _enable(cameras: Nullable<Camera[]>): void;
  49778. /**
  49779. * Disables the effect on the given cameras
  49780. * @param cameras The camera to disable.
  49781. * @hidden
  49782. */
  49783. _disable(cameras: Camera): void;
  49784. /**
  49785. * Disables the effect on the given cameras
  49786. * @param cameras The camera to disable.
  49787. * @hidden
  49788. */
  49789. _disable(cameras: Nullable<Camera[]>): void;
  49790. /**
  49791. * Gets a list of the post processes contained in the effect.
  49792. * @param camera The camera to get the post processes on.
  49793. * @returns The list of the post processes in the effect.
  49794. */
  49795. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49796. }
  49797. }
  49798. declare module BABYLON {
  49799. /** @hidden */
  49800. export var extractHighlightsPixelShader: {
  49801. name: string;
  49802. shader: string;
  49803. };
  49804. }
  49805. declare module BABYLON {
  49806. /**
  49807. * 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.
  49808. */
  49809. export class ExtractHighlightsPostProcess extends PostProcess {
  49810. /**
  49811. * The luminance threshold, pixels below this value will be set to black.
  49812. */
  49813. threshold: number;
  49814. /** @hidden */
  49815. _exposure: number;
  49816. /**
  49817. * Post process which has the input texture to be used when performing highlight extraction
  49818. * @hidden
  49819. */
  49820. _inputPostProcess: Nullable<PostProcess>;
  49821. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49822. }
  49823. }
  49824. declare module BABYLON {
  49825. /** @hidden */
  49826. export var bloomMergePixelShader: {
  49827. name: string;
  49828. shader: string;
  49829. };
  49830. }
  49831. declare module BABYLON {
  49832. /**
  49833. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  49834. */
  49835. export class BloomMergePostProcess extends PostProcess {
  49836. /** Weight of the bloom to be added to the original input. */
  49837. weight: number;
  49838. /**
  49839. * Creates a new instance of @see BloomMergePostProcess
  49840. * @param name The name of the effect.
  49841. * @param originalFromInput Post process which's input will be used for the merge.
  49842. * @param blurred Blurred highlights post process which's output will be used.
  49843. * @param weight Weight of the bloom to be added to the original input.
  49844. * @param options The required width/height ratio to downsize to before computing the render pass.
  49845. * @param camera The camera to apply the render pass to.
  49846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49847. * @param engine The engine which the post process will be applied. (default: current engine)
  49848. * @param reusable If the post process can be reused on the same frame. (default: false)
  49849. * @param textureType Type of textures used when performing the post process. (default: 0)
  49850. * @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)
  49851. */
  49852. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  49853. /** Weight of the bloom to be added to the original input. */
  49854. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49855. }
  49856. }
  49857. declare module BABYLON {
  49858. /**
  49859. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  49860. */
  49861. export class BloomEffect extends PostProcessRenderEffect {
  49862. private bloomScale;
  49863. /**
  49864. * @hidden Internal
  49865. */
  49866. _effects: Array<PostProcess>;
  49867. /**
  49868. * @hidden Internal
  49869. */
  49870. _downscale: ExtractHighlightsPostProcess;
  49871. private _blurX;
  49872. private _blurY;
  49873. private _merge;
  49874. /**
  49875. * The luminance threshold to find bright areas of the image to bloom.
  49876. */
  49877. threshold: number;
  49878. /**
  49879. * The strength of the bloom.
  49880. */
  49881. weight: number;
  49882. /**
  49883. * Specifies the size of the bloom blur kernel, relative to the final output size
  49884. */
  49885. kernel: number;
  49886. /**
  49887. * Creates a new instance of @see BloomEffect
  49888. * @param scene The scene the effect belongs to.
  49889. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  49890. * @param bloomKernel The size of the kernel to be used when applying the blur.
  49891. * @param bloomWeight The the strength of bloom.
  49892. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  49893. * @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)
  49894. */
  49895. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  49896. /**
  49897. * Disposes each of the internal effects for a given camera.
  49898. * @param camera The camera to dispose the effect on.
  49899. */
  49900. disposeEffects(camera: Camera): void;
  49901. /**
  49902. * @hidden Internal
  49903. */
  49904. _updateEffects(): void;
  49905. /**
  49906. * Internal
  49907. * @returns if all the contained post processes are ready.
  49908. * @hidden
  49909. */
  49910. _isReady(): boolean;
  49911. }
  49912. }
  49913. declare module BABYLON {
  49914. /** @hidden */
  49915. export var chromaticAberrationPixelShader: {
  49916. name: string;
  49917. shader: string;
  49918. };
  49919. }
  49920. declare module BABYLON {
  49921. /**
  49922. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  49923. */
  49924. export class ChromaticAberrationPostProcess extends PostProcess {
  49925. /**
  49926. * The amount of seperation of rgb channels (default: 30)
  49927. */
  49928. aberrationAmount: number;
  49929. /**
  49930. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  49931. */
  49932. radialIntensity: number;
  49933. /**
  49934. * 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))
  49935. */
  49936. direction: Vector2;
  49937. /**
  49938. * 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))
  49939. */
  49940. centerPosition: Vector2;
  49941. /**
  49942. * Creates a new instance ChromaticAberrationPostProcess
  49943. * @param name The name of the effect.
  49944. * @param screenWidth The width of the screen to apply the effect on.
  49945. * @param screenHeight The height of the screen to apply the effect on.
  49946. * @param options The required width/height ratio to downsize to before computing the render pass.
  49947. * @param camera The camera to apply the render pass to.
  49948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49949. * @param engine The engine which the post process will be applied. (default: current engine)
  49950. * @param reusable If the post process can be reused on the same frame. (default: false)
  49951. * @param textureType Type of textures used when performing the post process. (default: 0)
  49952. * @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)
  49953. */
  49954. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49955. }
  49956. }
  49957. declare module BABYLON {
  49958. /** @hidden */
  49959. export var circleOfConfusionPixelShader: {
  49960. name: string;
  49961. shader: string;
  49962. };
  49963. }
  49964. declare module BABYLON {
  49965. /**
  49966. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  49967. */
  49968. export class CircleOfConfusionPostProcess extends PostProcess {
  49969. /**
  49970. * 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.
  49971. */
  49972. lensSize: number;
  49973. /**
  49974. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  49975. */
  49976. fStop: number;
  49977. /**
  49978. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  49979. */
  49980. focusDistance: number;
  49981. /**
  49982. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  49983. */
  49984. focalLength: number;
  49985. private _depthTexture;
  49986. /**
  49987. * Creates a new instance CircleOfConfusionPostProcess
  49988. * @param name The name of the effect.
  49989. * @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.
  49990. * @param options The required width/height ratio to downsize to before computing the render pass.
  49991. * @param camera The camera to apply the render pass to.
  49992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49993. * @param engine The engine which the post process will be applied. (default: current engine)
  49994. * @param reusable If the post process can be reused on the same frame. (default: false)
  49995. * @param textureType Type of textures used when performing the post process. (default: 0)
  49996. * @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)
  49997. */
  49998. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49999. /**
  50000. * 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.
  50001. */
  50002. depthTexture: RenderTargetTexture;
  50003. }
  50004. }
  50005. declare module BABYLON {
  50006. /** @hidden */
  50007. export var colorCorrectionPixelShader: {
  50008. name: string;
  50009. shader: string;
  50010. };
  50011. }
  50012. declare module BABYLON {
  50013. /**
  50014. *
  50015. * This post-process allows the modification of rendered colors by using
  50016. * a 'look-up table' (LUT). This effect is also called Color Grading.
  50017. *
  50018. * The object needs to be provided an url to a texture containing the color
  50019. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  50020. * Use an image editing software to tweak the LUT to match your needs.
  50021. *
  50022. * For an example of a color LUT, see here:
  50023. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  50024. * For explanations on color grading, see here:
  50025. * @see http://udn.epicgames.com/Three/ColorGrading.html
  50026. *
  50027. */
  50028. export class ColorCorrectionPostProcess extends PostProcess {
  50029. private _colorTableTexture;
  50030. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50031. }
  50032. }
  50033. declare module BABYLON {
  50034. /** @hidden */
  50035. export var convolutionPixelShader: {
  50036. name: string;
  50037. shader: string;
  50038. };
  50039. }
  50040. declare module BABYLON {
  50041. /**
  50042. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  50043. * input texture to perform effects such as edge detection or sharpening
  50044. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  50045. */
  50046. export class ConvolutionPostProcess extends PostProcess {
  50047. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  50048. kernel: number[];
  50049. /**
  50050. * Creates a new instance ConvolutionPostProcess
  50051. * @param name The name of the effect.
  50052. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  50053. * @param options The required width/height ratio to downsize to before computing the render pass.
  50054. * @param camera The camera to apply the render pass to.
  50055. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50056. * @param engine The engine which the post process will be applied. (default: current engine)
  50057. * @param reusable If the post process can be reused on the same frame. (default: false)
  50058. * @param textureType Type of textures used when performing the post process. (default: 0)
  50059. */
  50060. constructor(name: string,
  50061. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  50062. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  50063. /**
  50064. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  50065. */
  50066. static EdgeDetect0Kernel: number[];
  50067. /**
  50068. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  50069. */
  50070. static EdgeDetect1Kernel: number[];
  50071. /**
  50072. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  50073. */
  50074. static EdgeDetect2Kernel: number[];
  50075. /**
  50076. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  50077. */
  50078. static SharpenKernel: number[];
  50079. /**
  50080. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  50081. */
  50082. static EmbossKernel: number[];
  50083. /**
  50084. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  50085. */
  50086. static GaussianKernel: number[];
  50087. }
  50088. }
  50089. declare module BABYLON {
  50090. /**
  50091. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  50092. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  50093. * based on samples that have a large difference in distance than the center pixel.
  50094. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  50095. */
  50096. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  50097. direction: Vector2;
  50098. /**
  50099. * Creates a new instance CircleOfConfusionPostProcess
  50100. * @param name The name of the effect.
  50101. * @param scene The scene the effect belongs to.
  50102. * @param direction The direction the blur should be applied.
  50103. * @param kernel The size of the kernel used to blur.
  50104. * @param options The required width/height ratio to downsize to before computing the render pass.
  50105. * @param camera The camera to apply the render pass to.
  50106. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  50107. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  50108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50109. * @param engine The engine which the post process will be applied. (default: current engine)
  50110. * @param reusable If the post process can be reused on the same frame. (default: false)
  50111. * @param textureType Type of textures used when performing the post process. (default: 0)
  50112. * @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)
  50113. */
  50114. 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);
  50115. }
  50116. }
  50117. declare module BABYLON {
  50118. /** @hidden */
  50119. export var depthOfFieldMergePixelShader: {
  50120. name: string;
  50121. shader: string;
  50122. };
  50123. }
  50124. declare module BABYLON {
  50125. /**
  50126. * Options to be set when merging outputs from the default pipeline.
  50127. */
  50128. export class DepthOfFieldMergePostProcessOptions {
  50129. /**
  50130. * The original image to merge on top of
  50131. */
  50132. originalFromInput: PostProcess;
  50133. /**
  50134. * Parameters to perform the merge of the depth of field effect
  50135. */
  50136. depthOfField?: {
  50137. circleOfConfusion: PostProcess;
  50138. blurSteps: Array<PostProcess>;
  50139. };
  50140. /**
  50141. * Parameters to perform the merge of bloom effect
  50142. */
  50143. bloom?: {
  50144. blurred: PostProcess;
  50145. weight: number;
  50146. };
  50147. }
  50148. /**
  50149. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  50150. */
  50151. export class DepthOfFieldMergePostProcess extends PostProcess {
  50152. private blurSteps;
  50153. /**
  50154. * Creates a new instance of DepthOfFieldMergePostProcess
  50155. * @param name The name of the effect.
  50156. * @param originalFromInput Post process which's input will be used for the merge.
  50157. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  50158. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  50159. * @param options The required width/height ratio to downsize to before computing the render pass.
  50160. * @param camera The camera to apply the render pass to.
  50161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50162. * @param engine The engine which the post process will be applied. (default: current engine)
  50163. * @param reusable If the post process can be reused on the same frame. (default: false)
  50164. * @param textureType Type of textures used when performing the post process. (default: 0)
  50165. * @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)
  50166. */
  50167. 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);
  50168. /**
  50169. * Updates the effect with the current post process compile time values and recompiles the shader.
  50170. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  50171. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  50172. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  50173. * @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
  50174. * @param onCompiled Called when the shader has been compiled.
  50175. * @param onError Called if there is an error when compiling a shader.
  50176. */
  50177. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  50178. }
  50179. }
  50180. declare module BABYLON {
  50181. /**
  50182. * Specifies the level of max blur that should be applied when using the depth of field effect
  50183. */
  50184. export enum DepthOfFieldEffectBlurLevel {
  50185. /**
  50186. * Subtle blur
  50187. */
  50188. Low = 0,
  50189. /**
  50190. * Medium blur
  50191. */
  50192. Medium = 1,
  50193. /**
  50194. * Large blur
  50195. */
  50196. High = 2
  50197. }
  50198. /**
  50199. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  50200. */
  50201. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  50202. private _circleOfConfusion;
  50203. /**
  50204. * @hidden Internal, blurs from high to low
  50205. */
  50206. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  50207. private _depthOfFieldBlurY;
  50208. private _dofMerge;
  50209. /**
  50210. * @hidden Internal post processes in depth of field effect
  50211. */
  50212. _effects: Array<PostProcess>;
  50213. /**
  50214. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  50215. */
  50216. focalLength: number;
  50217. /**
  50218. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  50219. */
  50220. fStop: number;
  50221. /**
  50222. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  50223. */
  50224. focusDistance: number;
  50225. /**
  50226. * 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.
  50227. */
  50228. lensSize: number;
  50229. /**
  50230. * Creates a new instance DepthOfFieldEffect
  50231. * @param scene The scene the effect belongs to.
  50232. * @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.
  50233. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  50234. * @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)
  50235. */
  50236. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  50237. /**
  50238. * 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.
  50239. */
  50240. depthTexture: RenderTargetTexture;
  50241. /**
  50242. * Disposes each of the internal effects for a given camera.
  50243. * @param camera The camera to dispose the effect on.
  50244. */
  50245. disposeEffects(camera: Camera): void;
  50246. /**
  50247. * @hidden Internal
  50248. */
  50249. _updateEffects(): void;
  50250. /**
  50251. * Internal
  50252. * @returns if all the contained post processes are ready.
  50253. * @hidden
  50254. */
  50255. _isReady(): boolean;
  50256. }
  50257. }
  50258. declare module BABYLON {
  50259. /** @hidden */
  50260. export var displayPassPixelShader: {
  50261. name: string;
  50262. shader: string;
  50263. };
  50264. }
  50265. declare module BABYLON {
  50266. /**
  50267. * DisplayPassPostProcess which produces an output the same as it's input
  50268. */
  50269. export class DisplayPassPostProcess extends PostProcess {
  50270. /**
  50271. * Creates the DisplayPassPostProcess
  50272. * @param name The name of the effect.
  50273. * @param options The required width/height ratio to downsize to before computing the render pass.
  50274. * @param camera The camera to apply the render pass to.
  50275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50276. * @param engine The engine which the post process will be applied. (default: current engine)
  50277. * @param reusable If the post process can be reused on the same frame. (default: false)
  50278. */
  50279. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50280. }
  50281. }
  50282. declare module BABYLON {
  50283. /** @hidden */
  50284. export var filterPixelShader: {
  50285. name: string;
  50286. shader: string;
  50287. };
  50288. }
  50289. declare module BABYLON {
  50290. /**
  50291. * Applies a kernel filter to the image
  50292. */
  50293. export class FilterPostProcess extends PostProcess {
  50294. /** The matrix to be applied to the image */
  50295. kernelMatrix: Matrix;
  50296. /**
  50297. *
  50298. * @param name The name of the effect.
  50299. * @param kernelMatrix The matrix to be applied to the image
  50300. * @param options The required width/height ratio to downsize to before computing the render pass.
  50301. * @param camera The camera to apply the render pass to.
  50302. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50303. * @param engine The engine which the post process will be applied. (default: current engine)
  50304. * @param reusable If the post process can be reused on the same frame. (default: false)
  50305. */
  50306. constructor(name: string,
  50307. /** The matrix to be applied to the image */
  50308. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50309. }
  50310. }
  50311. declare module BABYLON {
  50312. /** @hidden */
  50313. export var fxaaPixelShader: {
  50314. name: string;
  50315. shader: string;
  50316. };
  50317. }
  50318. declare module BABYLON {
  50319. /** @hidden */
  50320. export var fxaaVertexShader: {
  50321. name: string;
  50322. shader: string;
  50323. };
  50324. }
  50325. declare module BABYLON {
  50326. /**
  50327. * Fxaa post process
  50328. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  50329. */
  50330. export class FxaaPostProcess extends PostProcess {
  50331. /** @hidden */
  50332. texelWidth: number;
  50333. /** @hidden */
  50334. texelHeight: number;
  50335. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  50336. private _getDefines;
  50337. }
  50338. }
  50339. declare module BABYLON {
  50340. /** @hidden */
  50341. export var grainPixelShader: {
  50342. name: string;
  50343. shader: string;
  50344. };
  50345. }
  50346. declare module BABYLON {
  50347. /**
  50348. * The GrainPostProcess adds noise to the image at mid luminance levels
  50349. */
  50350. export class GrainPostProcess extends PostProcess {
  50351. /**
  50352. * The intensity of the grain added (default: 30)
  50353. */
  50354. intensity: number;
  50355. /**
  50356. * If the grain should be randomized on every frame
  50357. */
  50358. animated: boolean;
  50359. /**
  50360. * Creates a new instance of @see GrainPostProcess
  50361. * @param name The name of the effect.
  50362. * @param options The required width/height ratio to downsize to before computing the render pass.
  50363. * @param camera The camera to apply the render pass to.
  50364. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50365. * @param engine The engine which the post process will be applied. (default: current engine)
  50366. * @param reusable If the post process can be reused on the same frame. (default: false)
  50367. * @param textureType Type of textures used when performing the post process. (default: 0)
  50368. * @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)
  50369. */
  50370. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50371. }
  50372. }
  50373. declare module BABYLON {
  50374. /** @hidden */
  50375. export var highlightsPixelShader: {
  50376. name: string;
  50377. shader: string;
  50378. };
  50379. }
  50380. declare module BABYLON {
  50381. /**
  50382. * Extracts highlights from the image
  50383. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  50384. */
  50385. export class HighlightsPostProcess extends PostProcess {
  50386. /**
  50387. * Extracts highlights from the image
  50388. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  50389. * @param name The name of the effect.
  50390. * @param options The required width/height ratio to downsize to before computing the render pass.
  50391. * @param camera The camera to apply the render pass to.
  50392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50393. * @param engine The engine which the post process will be applied. (default: current engine)
  50394. * @param reusable If the post process can be reused on the same frame. (default: false)
  50395. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  50396. */
  50397. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  50398. }
  50399. }
  50400. declare module BABYLON {
  50401. /** @hidden */
  50402. export var mrtFragmentDeclaration: {
  50403. name: string;
  50404. shader: string;
  50405. };
  50406. }
  50407. declare module BABYLON {
  50408. /** @hidden */
  50409. export var geometryPixelShader: {
  50410. name: string;
  50411. shader: string;
  50412. };
  50413. }
  50414. declare module BABYLON {
  50415. /** @hidden */
  50416. export var geometryVertexShader: {
  50417. name: string;
  50418. shader: string;
  50419. };
  50420. }
  50421. declare module BABYLON {
  50422. /**
  50423. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  50424. */
  50425. export class GeometryBufferRenderer {
  50426. /**
  50427. * Constant used to retrieve the position texture index in the G-Buffer textures array
  50428. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  50429. */
  50430. static readonly POSITION_TEXTURE_TYPE: number;
  50431. /**
  50432. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  50433. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  50434. */
  50435. static readonly VELOCITY_TEXTURE_TYPE: number;
  50436. /**
  50437. * Dictionary used to store the previous transformation matrices of each rendered mesh
  50438. * in order to compute objects velocities when enableVelocity is set to "true"
  50439. * @hidden
  50440. */
  50441. _previousTransformationMatrices: {
  50442. [index: number]: Matrix;
  50443. };
  50444. private _scene;
  50445. private _multiRenderTarget;
  50446. private _ratio;
  50447. private _enablePosition;
  50448. private _enableVelocity;
  50449. private _positionIndex;
  50450. private _velocityIndex;
  50451. protected _effect: Effect;
  50452. protected _cachedDefines: string;
  50453. /**
  50454. * Set the render list (meshes to be rendered) used in the G buffer.
  50455. */
  50456. renderList: Mesh[];
  50457. /**
  50458. * Gets wether or not G buffer are supported by the running hardware.
  50459. * This requires draw buffer supports
  50460. */
  50461. readonly isSupported: boolean;
  50462. /**
  50463. * Returns the index of the given texture type in the G-Buffer textures array
  50464. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  50465. * @returns the index of the given texture type in the G-Buffer textures array
  50466. */
  50467. getTextureIndex(textureType: number): number;
  50468. /**
  50469. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  50470. */
  50471. /**
  50472. * Sets whether or not objects positions are enabled for the G buffer.
  50473. */
  50474. enablePosition: boolean;
  50475. /**
  50476. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  50477. */
  50478. /**
  50479. * Sets wether or not objects velocities are enabled for the G buffer.
  50480. */
  50481. enableVelocity: boolean;
  50482. /**
  50483. * Gets the scene associated with the buffer.
  50484. */
  50485. readonly scene: Scene;
  50486. /**
  50487. * Gets the ratio used by the buffer during its creation.
  50488. * How big is the buffer related to the main canvas.
  50489. */
  50490. readonly ratio: number;
  50491. /** @hidden */
  50492. static _SceneComponentInitialization: (scene: Scene) => void;
  50493. /**
  50494. * Creates a new G Buffer for the scene
  50495. * @param scene The scene the buffer belongs to
  50496. * @param ratio How big is the buffer related to the main canvas.
  50497. */
  50498. constructor(scene: Scene, ratio?: number);
  50499. /**
  50500. * Checks wether everything is ready to render a submesh to the G buffer.
  50501. * @param subMesh the submesh to check readiness for
  50502. * @param useInstances is the mesh drawn using instance or not
  50503. * @returns true if ready otherwise false
  50504. */
  50505. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50506. /**
  50507. * Gets the current underlying G Buffer.
  50508. * @returns the buffer
  50509. */
  50510. getGBuffer(): MultiRenderTarget;
  50511. /**
  50512. * Gets the number of samples used to render the buffer (anti aliasing).
  50513. */
  50514. /**
  50515. * Sets the number of samples used to render the buffer (anti aliasing).
  50516. */
  50517. samples: number;
  50518. /**
  50519. * Disposes the renderer and frees up associated resources.
  50520. */
  50521. dispose(): void;
  50522. protected _createRenderTargets(): void;
  50523. }
  50524. }
  50525. declare module BABYLON {
  50526. /** @hidden */
  50527. export var motionBlurPixelShader: {
  50528. name: string;
  50529. shader: string;
  50530. };
  50531. }
  50532. declare module BABYLON {
  50533. /**
  50534. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  50535. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  50536. * As an example, all you have to do is to create the post-process:
  50537. * var mb = new BABYLON.MotionBlurPostProcess(
  50538. * 'mb', // The name of the effect.
  50539. * scene, // The scene containing the objects to blur according to their velocity.
  50540. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  50541. * camera // The camera to apply the render pass to.
  50542. * );
  50543. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  50544. */
  50545. export class MotionBlurPostProcess extends PostProcess {
  50546. /**
  50547. * Defines how much the image is blurred by the movement. Default value is equal to 1
  50548. */
  50549. motionStrength: number;
  50550. /**
  50551. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  50552. */
  50553. /**
  50554. * Sets the number of iterations to be used for motion blur quality
  50555. */
  50556. motionBlurSamples: number;
  50557. private _motionBlurSamples;
  50558. private _geometryBufferRenderer;
  50559. /**
  50560. * Creates a new instance MotionBlurPostProcess
  50561. * @param name The name of the effect.
  50562. * @param scene The scene containing the objects to blur according to their velocity.
  50563. * @param options The required width/height ratio to downsize to before computing the render pass.
  50564. * @param camera The camera to apply the render pass to.
  50565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50566. * @param engine The engine which the post process will be applied. (default: current engine)
  50567. * @param reusable If the post process can be reused on the same frame. (default: false)
  50568. * @param textureType Type of textures used when performing the post process. (default: 0)
  50569. * @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)
  50570. */
  50571. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50572. /**
  50573. * Disposes the post process.
  50574. * @param camera The camera to dispose the post process on.
  50575. */
  50576. dispose(camera?: Camera): void;
  50577. }
  50578. }
  50579. declare module BABYLON {
  50580. /** @hidden */
  50581. export var refractionPixelShader: {
  50582. name: string;
  50583. shader: string;
  50584. };
  50585. }
  50586. declare module BABYLON {
  50587. /**
  50588. * Post process which applies a refractin texture
  50589. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  50590. */
  50591. export class RefractionPostProcess extends PostProcess {
  50592. /** the base color of the refraction (used to taint the rendering) */
  50593. color: Color3;
  50594. /** simulated refraction depth */
  50595. depth: number;
  50596. /** the coefficient of the base color (0 to remove base color tainting) */
  50597. colorLevel: number;
  50598. private _refTexture;
  50599. private _ownRefractionTexture;
  50600. /**
  50601. * Gets or sets the refraction texture
  50602. * Please note that you are responsible for disposing the texture if you set it manually
  50603. */
  50604. refractionTexture: Texture;
  50605. /**
  50606. * Initializes the RefractionPostProcess
  50607. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  50608. * @param name The name of the effect.
  50609. * @param refractionTextureUrl Url of the refraction texture to use
  50610. * @param color the base color of the refraction (used to taint the rendering)
  50611. * @param depth simulated refraction depth
  50612. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  50613. * @param camera The camera to apply the render pass to.
  50614. * @param options The required width/height ratio to downsize to before computing the render pass.
  50615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50616. * @param engine The engine which the post process will be applied. (default: current engine)
  50617. * @param reusable If the post process can be reused on the same frame. (default: false)
  50618. */
  50619. constructor(name: string, refractionTextureUrl: string,
  50620. /** the base color of the refraction (used to taint the rendering) */
  50621. color: Color3,
  50622. /** simulated refraction depth */
  50623. depth: number,
  50624. /** the coefficient of the base color (0 to remove base color tainting) */
  50625. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50626. /**
  50627. * Disposes of the post process
  50628. * @param camera Camera to dispose post process on
  50629. */
  50630. dispose(camera: Camera): void;
  50631. }
  50632. }
  50633. declare module BABYLON {
  50634. /** @hidden */
  50635. export var sharpenPixelShader: {
  50636. name: string;
  50637. shader: string;
  50638. };
  50639. }
  50640. declare module BABYLON {
  50641. /**
  50642. * The SharpenPostProcess applies a sharpen kernel to every pixel
  50643. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  50644. */
  50645. export class SharpenPostProcess extends PostProcess {
  50646. /**
  50647. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  50648. */
  50649. colorAmount: number;
  50650. /**
  50651. * How much sharpness should be applied (default: 0.3)
  50652. */
  50653. edgeAmount: number;
  50654. /**
  50655. * Creates a new instance ConvolutionPostProcess
  50656. * @param name The name of the effect.
  50657. * @param options The required width/height ratio to downsize to before computing the render pass.
  50658. * @param camera The camera to apply the render pass to.
  50659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50660. * @param engine The engine which the post process will be applied. (default: current engine)
  50661. * @param reusable If the post process can be reused on the same frame. (default: false)
  50662. * @param textureType Type of textures used when performing the post process. (default: 0)
  50663. * @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)
  50664. */
  50665. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50666. }
  50667. }
  50668. declare module BABYLON {
  50669. /**
  50670. * PostProcessRenderPipeline
  50671. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50672. */
  50673. export class PostProcessRenderPipeline {
  50674. private engine;
  50675. private _renderEffects;
  50676. private _renderEffectsForIsolatedPass;
  50677. /**
  50678. * @hidden
  50679. */
  50680. protected _cameras: Camera[];
  50681. /** @hidden */
  50682. _name: string;
  50683. /**
  50684. * Gets pipeline name
  50685. */
  50686. readonly name: string;
  50687. /**
  50688. * Initializes a PostProcessRenderPipeline
  50689. * @param engine engine to add the pipeline to
  50690. * @param name name of the pipeline
  50691. */
  50692. constructor(engine: Engine, name: string);
  50693. /**
  50694. * Gets the class name
  50695. * @returns "PostProcessRenderPipeline"
  50696. */
  50697. getClassName(): string;
  50698. /**
  50699. * If all the render effects in the pipeline are supported
  50700. */
  50701. readonly isSupported: boolean;
  50702. /**
  50703. * Adds an effect to the pipeline
  50704. * @param renderEffect the effect to add
  50705. */
  50706. addEffect(renderEffect: PostProcessRenderEffect): void;
  50707. /** @hidden */
  50708. _rebuild(): void;
  50709. /** @hidden */
  50710. _enableEffect(renderEffectName: string, cameras: Camera): void;
  50711. /** @hidden */
  50712. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  50713. /** @hidden */
  50714. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  50715. /** @hidden */
  50716. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  50717. /** @hidden */
  50718. _attachCameras(cameras: Camera, unique: boolean): void;
  50719. /** @hidden */
  50720. _attachCameras(cameras: Camera[], unique: boolean): void;
  50721. /** @hidden */
  50722. _detachCameras(cameras: Camera): void;
  50723. /** @hidden */
  50724. _detachCameras(cameras: Nullable<Camera[]>): void;
  50725. /** @hidden */
  50726. _update(): void;
  50727. /** @hidden */
  50728. _reset(): void;
  50729. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  50730. /**
  50731. * Disposes of the pipeline
  50732. */
  50733. dispose(): void;
  50734. }
  50735. }
  50736. declare module BABYLON {
  50737. /**
  50738. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  50739. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50740. */
  50741. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50742. private _scene;
  50743. private _camerasToBeAttached;
  50744. /**
  50745. * ID of the sharpen post process,
  50746. */
  50747. private readonly SharpenPostProcessId;
  50748. /**
  50749. * @ignore
  50750. * ID of the image processing post process;
  50751. */
  50752. readonly ImageProcessingPostProcessId: string;
  50753. /**
  50754. * @ignore
  50755. * ID of the Fast Approximate Anti-Aliasing post process;
  50756. */
  50757. readonly FxaaPostProcessId: string;
  50758. /**
  50759. * ID of the chromatic aberration post process,
  50760. */
  50761. private readonly ChromaticAberrationPostProcessId;
  50762. /**
  50763. * ID of the grain post process
  50764. */
  50765. private readonly GrainPostProcessId;
  50766. /**
  50767. * Sharpen post process which will apply a sharpen convolution to enhance edges
  50768. */
  50769. sharpen: SharpenPostProcess;
  50770. private _sharpenEffect;
  50771. private bloom;
  50772. /**
  50773. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  50774. */
  50775. depthOfField: DepthOfFieldEffect;
  50776. /**
  50777. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50778. */
  50779. fxaa: FxaaPostProcess;
  50780. /**
  50781. * Image post processing pass used to perform operations such as tone mapping or color grading.
  50782. */
  50783. imageProcessing: ImageProcessingPostProcess;
  50784. /**
  50785. * Chromatic aberration post process which will shift rgb colors in the image
  50786. */
  50787. chromaticAberration: ChromaticAberrationPostProcess;
  50788. private _chromaticAberrationEffect;
  50789. /**
  50790. * Grain post process which add noise to the image
  50791. */
  50792. grain: GrainPostProcess;
  50793. private _grainEffect;
  50794. /**
  50795. * Glow post process which adds a glow to emissive areas of the image
  50796. */
  50797. private _glowLayer;
  50798. /**
  50799. * Animations which can be used to tweak settings over a period of time
  50800. */
  50801. animations: Animation[];
  50802. private _imageProcessingConfigurationObserver;
  50803. private _sharpenEnabled;
  50804. private _bloomEnabled;
  50805. private _depthOfFieldEnabled;
  50806. private _depthOfFieldBlurLevel;
  50807. private _fxaaEnabled;
  50808. private _imageProcessingEnabled;
  50809. private _defaultPipelineTextureType;
  50810. private _bloomScale;
  50811. private _chromaticAberrationEnabled;
  50812. private _grainEnabled;
  50813. private _buildAllowed;
  50814. /**
  50815. * Gets active scene
  50816. */
  50817. readonly scene: Scene;
  50818. /**
  50819. * Enable or disable the sharpen process from the pipeline
  50820. */
  50821. sharpenEnabled: boolean;
  50822. private _resizeObserver;
  50823. private _hardwareScaleLevel;
  50824. private _bloomKernel;
  50825. /**
  50826. * Specifies the size of the bloom blur kernel, relative to the final output size
  50827. */
  50828. bloomKernel: number;
  50829. /**
  50830. * Specifies the weight of the bloom in the final rendering
  50831. */
  50832. private _bloomWeight;
  50833. /**
  50834. * Specifies the luma threshold for the area that will be blurred by the bloom
  50835. */
  50836. private _bloomThreshold;
  50837. private _hdr;
  50838. /**
  50839. * The strength of the bloom.
  50840. */
  50841. bloomWeight: number;
  50842. /**
  50843. * The strength of the bloom.
  50844. */
  50845. bloomThreshold: number;
  50846. /**
  50847. * The scale of the bloom, lower value will provide better performance.
  50848. */
  50849. bloomScale: number;
  50850. /**
  50851. * Enable or disable the bloom from the pipeline
  50852. */
  50853. bloomEnabled: boolean;
  50854. private _rebuildBloom;
  50855. /**
  50856. * If the depth of field is enabled.
  50857. */
  50858. depthOfFieldEnabled: boolean;
  50859. /**
  50860. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50861. */
  50862. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50863. /**
  50864. * If the anti aliasing is enabled.
  50865. */
  50866. fxaaEnabled: boolean;
  50867. private _samples;
  50868. /**
  50869. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50870. */
  50871. samples: number;
  50872. /**
  50873. * If image processing is enabled.
  50874. */
  50875. imageProcessingEnabled: boolean;
  50876. /**
  50877. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50878. */
  50879. glowLayerEnabled: boolean;
  50880. /**
  50881. * Enable or disable the chromaticAberration process from the pipeline
  50882. */
  50883. chromaticAberrationEnabled: boolean;
  50884. /**
  50885. * Enable or disable the grain process from the pipeline
  50886. */
  50887. grainEnabled: boolean;
  50888. /**
  50889. * @constructor
  50890. * @param name - The rendering pipeline name (default: "")
  50891. * @param hdr - If high dynamic range textures should be used (default: true)
  50892. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50893. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50894. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50895. */
  50896. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50897. /**
  50898. * Get the class name
  50899. * @returns "DefaultRenderingPipeline"
  50900. */
  50901. getClassName(): string;
  50902. /**
  50903. * Force the compilation of the entire pipeline.
  50904. */
  50905. prepare(): void;
  50906. private _hasCleared;
  50907. private _prevPostProcess;
  50908. private _prevPrevPostProcess;
  50909. private _setAutoClearAndTextureSharing;
  50910. private _depthOfFieldSceneObserver;
  50911. private _buildPipeline;
  50912. private _disposePostProcesses;
  50913. /**
  50914. * Adds a camera to the pipeline
  50915. * @param camera the camera to be added
  50916. */
  50917. addCamera(camera: Camera): void;
  50918. /**
  50919. * Removes a camera from the pipeline
  50920. * @param camera the camera to remove
  50921. */
  50922. removeCamera(camera: Camera): void;
  50923. /**
  50924. * Dispose of the pipeline and stop all post processes
  50925. */
  50926. dispose(): void;
  50927. /**
  50928. * Serialize the rendering pipeline (Used when exporting)
  50929. * @returns the serialized object
  50930. */
  50931. serialize(): any;
  50932. /**
  50933. * Parse the serialized pipeline
  50934. * @param source Source pipeline.
  50935. * @param scene The scene to load the pipeline to.
  50936. * @param rootUrl The URL of the serialized pipeline.
  50937. * @returns An instantiated pipeline from the serialized object.
  50938. */
  50939. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50940. }
  50941. }
  50942. declare module BABYLON {
  50943. /** @hidden */
  50944. export var lensHighlightsPixelShader: {
  50945. name: string;
  50946. shader: string;
  50947. };
  50948. }
  50949. declare module BABYLON {
  50950. /** @hidden */
  50951. export var depthOfFieldPixelShader: {
  50952. name: string;
  50953. shader: string;
  50954. };
  50955. }
  50956. declare module BABYLON {
  50957. /**
  50958. * BABYLON.JS Chromatic Aberration GLSL Shader
  50959. * Author: Olivier Guyot
  50960. * Separates very slightly R, G and B colors on the edges of the screen
  50961. * Inspired by Francois Tarlier & Martins Upitis
  50962. */
  50963. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  50964. /**
  50965. * @ignore
  50966. * The chromatic aberration PostProcess id in the pipeline
  50967. */
  50968. LensChromaticAberrationEffect: string;
  50969. /**
  50970. * @ignore
  50971. * The highlights enhancing PostProcess id in the pipeline
  50972. */
  50973. HighlightsEnhancingEffect: string;
  50974. /**
  50975. * @ignore
  50976. * The depth-of-field PostProcess id in the pipeline
  50977. */
  50978. LensDepthOfFieldEffect: string;
  50979. private _scene;
  50980. private _depthTexture;
  50981. private _grainTexture;
  50982. private _chromaticAberrationPostProcess;
  50983. private _highlightsPostProcess;
  50984. private _depthOfFieldPostProcess;
  50985. private _edgeBlur;
  50986. private _grainAmount;
  50987. private _chromaticAberration;
  50988. private _distortion;
  50989. private _highlightsGain;
  50990. private _highlightsThreshold;
  50991. private _dofDistance;
  50992. private _dofAperture;
  50993. private _dofDarken;
  50994. private _dofPentagon;
  50995. private _blurNoise;
  50996. /**
  50997. * @constructor
  50998. *
  50999. * Effect parameters are as follow:
  51000. * {
  51001. * chromatic_aberration: number; // from 0 to x (1 for realism)
  51002. * edge_blur: number; // from 0 to x (1 for realism)
  51003. * distortion: number; // from 0 to x (1 for realism)
  51004. * grain_amount: number; // from 0 to 1
  51005. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  51006. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  51007. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  51008. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  51009. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  51010. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  51011. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  51012. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  51013. * }
  51014. * Note: if an effect parameter is unset, effect is disabled
  51015. *
  51016. * @param name The rendering pipeline name
  51017. * @param parameters - An object containing all parameters (see above)
  51018. * @param scene The scene linked to this pipeline
  51019. * @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)
  51020. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51021. */
  51022. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  51023. /**
  51024. * Sets the amount of blur at the edges
  51025. * @param amount blur amount
  51026. */
  51027. setEdgeBlur(amount: number): void;
  51028. /**
  51029. * Sets edge blur to 0
  51030. */
  51031. disableEdgeBlur(): void;
  51032. /**
  51033. * Sets the amout of grain
  51034. * @param amount Amount of grain
  51035. */
  51036. setGrainAmount(amount: number): void;
  51037. /**
  51038. * Set grain amount to 0
  51039. */
  51040. disableGrain(): void;
  51041. /**
  51042. * Sets the chromatic aberration amount
  51043. * @param amount amount of chromatic aberration
  51044. */
  51045. setChromaticAberration(amount: number): void;
  51046. /**
  51047. * Sets chromatic aberration amount to 0
  51048. */
  51049. disableChromaticAberration(): void;
  51050. /**
  51051. * Sets the EdgeDistortion amount
  51052. * @param amount amount of EdgeDistortion
  51053. */
  51054. setEdgeDistortion(amount: number): void;
  51055. /**
  51056. * Sets edge distortion to 0
  51057. */
  51058. disableEdgeDistortion(): void;
  51059. /**
  51060. * Sets the FocusDistance amount
  51061. * @param amount amount of FocusDistance
  51062. */
  51063. setFocusDistance(amount: number): void;
  51064. /**
  51065. * Disables depth of field
  51066. */
  51067. disableDepthOfField(): void;
  51068. /**
  51069. * Sets the Aperture amount
  51070. * @param amount amount of Aperture
  51071. */
  51072. setAperture(amount: number): void;
  51073. /**
  51074. * Sets the DarkenOutOfFocus amount
  51075. * @param amount amount of DarkenOutOfFocus
  51076. */
  51077. setDarkenOutOfFocus(amount: number): void;
  51078. /**
  51079. * Creates a pentagon bokeh effect
  51080. */
  51081. enablePentagonBokeh(): void;
  51082. /**
  51083. * Disables the pentagon bokeh effect
  51084. */
  51085. disablePentagonBokeh(): void;
  51086. /**
  51087. * Enables noise blur
  51088. */
  51089. enableNoiseBlur(): void;
  51090. /**
  51091. * Disables noise blur
  51092. */
  51093. disableNoiseBlur(): void;
  51094. /**
  51095. * Sets the HighlightsGain amount
  51096. * @param amount amount of HighlightsGain
  51097. */
  51098. setHighlightsGain(amount: number): void;
  51099. /**
  51100. * Sets the HighlightsThreshold amount
  51101. * @param amount amount of HighlightsThreshold
  51102. */
  51103. setHighlightsThreshold(amount: number): void;
  51104. /**
  51105. * Disables highlights
  51106. */
  51107. disableHighlights(): void;
  51108. /**
  51109. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  51110. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  51111. */
  51112. dispose(disableDepthRender?: boolean): void;
  51113. private _createChromaticAberrationPostProcess;
  51114. private _createHighlightsPostProcess;
  51115. private _createDepthOfFieldPostProcess;
  51116. private _createGrainTexture;
  51117. }
  51118. }
  51119. declare module BABYLON {
  51120. /** @hidden */
  51121. export var ssao2PixelShader: {
  51122. name: string;
  51123. shader: string;
  51124. };
  51125. }
  51126. declare module BABYLON {
  51127. /** @hidden */
  51128. export var ssaoCombinePixelShader: {
  51129. name: string;
  51130. shader: string;
  51131. };
  51132. }
  51133. declare module BABYLON {
  51134. /**
  51135. * Render pipeline to produce ssao effect
  51136. */
  51137. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  51138. /**
  51139. * @ignore
  51140. * The PassPostProcess id in the pipeline that contains the original scene color
  51141. */
  51142. SSAOOriginalSceneColorEffect: string;
  51143. /**
  51144. * @ignore
  51145. * The SSAO PostProcess id in the pipeline
  51146. */
  51147. SSAORenderEffect: string;
  51148. /**
  51149. * @ignore
  51150. * The horizontal blur PostProcess id in the pipeline
  51151. */
  51152. SSAOBlurHRenderEffect: string;
  51153. /**
  51154. * @ignore
  51155. * The vertical blur PostProcess id in the pipeline
  51156. */
  51157. SSAOBlurVRenderEffect: string;
  51158. /**
  51159. * @ignore
  51160. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  51161. */
  51162. SSAOCombineRenderEffect: string;
  51163. /**
  51164. * The output strength of the SSAO post-process. Default value is 1.0.
  51165. */
  51166. totalStrength: number;
  51167. /**
  51168. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  51169. */
  51170. maxZ: number;
  51171. /**
  51172. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  51173. */
  51174. minZAspect: number;
  51175. private _samples;
  51176. /**
  51177. * Number of samples used for the SSAO calculations. Default value is 8
  51178. */
  51179. samples: number;
  51180. private _textureSamples;
  51181. /**
  51182. * Number of samples to use for antialiasing
  51183. */
  51184. textureSamples: number;
  51185. /**
  51186. * Ratio object used for SSAO ratio and blur ratio
  51187. */
  51188. private _ratio;
  51189. /**
  51190. * Dynamically generated sphere sampler.
  51191. */
  51192. private _sampleSphere;
  51193. /**
  51194. * Blur filter offsets
  51195. */
  51196. private _samplerOffsets;
  51197. private _expensiveBlur;
  51198. /**
  51199. * If bilateral blur should be used
  51200. */
  51201. expensiveBlur: boolean;
  51202. /**
  51203. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  51204. */
  51205. radius: number;
  51206. /**
  51207. * The base color of the SSAO post-process
  51208. * The final result is "base + ssao" between [0, 1]
  51209. */
  51210. base: number;
  51211. /**
  51212. * Support test.
  51213. */
  51214. static readonly IsSupported: boolean;
  51215. private _scene;
  51216. private _depthTexture;
  51217. private _normalTexture;
  51218. private _randomTexture;
  51219. private _originalColorPostProcess;
  51220. private _ssaoPostProcess;
  51221. private _blurHPostProcess;
  51222. private _blurVPostProcess;
  51223. private _ssaoCombinePostProcess;
  51224. private _firstUpdate;
  51225. /**
  51226. * Gets active scene
  51227. */
  51228. readonly scene: Scene;
  51229. /**
  51230. * @constructor
  51231. * @param name The rendering pipeline name
  51232. * @param scene The scene linked to this pipeline
  51233. * @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 }
  51234. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51235. */
  51236. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  51237. /**
  51238. * Get the class name
  51239. * @returns "SSAO2RenderingPipeline"
  51240. */
  51241. getClassName(): string;
  51242. /**
  51243. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  51244. */
  51245. dispose(disableGeometryBufferRenderer?: boolean): void;
  51246. private _createBlurPostProcess;
  51247. /** @hidden */
  51248. _rebuild(): void;
  51249. private _bits;
  51250. private _radicalInverse_VdC;
  51251. private _hammersley;
  51252. private _hemisphereSample_uniform;
  51253. private _generateHemisphere;
  51254. private _createSSAOPostProcess;
  51255. private _createSSAOCombinePostProcess;
  51256. private _createRandomTexture;
  51257. /**
  51258. * Serialize the rendering pipeline (Used when exporting)
  51259. * @returns the serialized object
  51260. */
  51261. serialize(): any;
  51262. /**
  51263. * Parse the serialized pipeline
  51264. * @param source Source pipeline.
  51265. * @param scene The scene to load the pipeline to.
  51266. * @param rootUrl The URL of the serialized pipeline.
  51267. * @returns An instantiated pipeline from the serialized object.
  51268. */
  51269. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  51270. }
  51271. }
  51272. declare module BABYLON {
  51273. /** @hidden */
  51274. export var ssaoPixelShader: {
  51275. name: string;
  51276. shader: string;
  51277. };
  51278. }
  51279. declare module BABYLON {
  51280. /**
  51281. * Render pipeline to produce ssao effect
  51282. */
  51283. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  51284. /**
  51285. * @ignore
  51286. * The PassPostProcess id in the pipeline that contains the original scene color
  51287. */
  51288. SSAOOriginalSceneColorEffect: string;
  51289. /**
  51290. * @ignore
  51291. * The SSAO PostProcess id in the pipeline
  51292. */
  51293. SSAORenderEffect: string;
  51294. /**
  51295. * @ignore
  51296. * The horizontal blur PostProcess id in the pipeline
  51297. */
  51298. SSAOBlurHRenderEffect: string;
  51299. /**
  51300. * @ignore
  51301. * The vertical blur PostProcess id in the pipeline
  51302. */
  51303. SSAOBlurVRenderEffect: string;
  51304. /**
  51305. * @ignore
  51306. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  51307. */
  51308. SSAOCombineRenderEffect: string;
  51309. /**
  51310. * The output strength of the SSAO post-process. Default value is 1.0.
  51311. */
  51312. totalStrength: number;
  51313. /**
  51314. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  51315. */
  51316. radius: number;
  51317. /**
  51318. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  51319. * Must not be equal to fallOff and superior to fallOff.
  51320. * Default value is 0.0075
  51321. */
  51322. area: number;
  51323. /**
  51324. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  51325. * Must not be equal to area and inferior to area.
  51326. * Default value is 0.000001
  51327. */
  51328. fallOff: number;
  51329. /**
  51330. * The base color of the SSAO post-process
  51331. * The final result is "base + ssao" between [0, 1]
  51332. */
  51333. base: number;
  51334. private _scene;
  51335. private _depthTexture;
  51336. private _randomTexture;
  51337. private _originalColorPostProcess;
  51338. private _ssaoPostProcess;
  51339. private _blurHPostProcess;
  51340. private _blurVPostProcess;
  51341. private _ssaoCombinePostProcess;
  51342. private _firstUpdate;
  51343. /**
  51344. * Gets active scene
  51345. */
  51346. readonly scene: Scene;
  51347. /**
  51348. * @constructor
  51349. * @param name - The rendering pipeline name
  51350. * @param scene - The scene linked to this pipeline
  51351. * @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 }
  51352. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  51353. */
  51354. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  51355. /**
  51356. * Get the class name
  51357. * @returns "SSAORenderingPipeline"
  51358. */
  51359. getClassName(): string;
  51360. /**
  51361. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  51362. */
  51363. dispose(disableDepthRender?: boolean): void;
  51364. private _createBlurPostProcess;
  51365. /** @hidden */
  51366. _rebuild(): void;
  51367. private _createSSAOPostProcess;
  51368. private _createSSAOCombinePostProcess;
  51369. private _createRandomTexture;
  51370. }
  51371. }
  51372. declare module BABYLON {
  51373. /** @hidden */
  51374. export var standardPixelShader: {
  51375. name: string;
  51376. shader: string;
  51377. };
  51378. }
  51379. declare module BABYLON {
  51380. /**
  51381. * Standard rendering pipeline
  51382. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51383. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  51384. */
  51385. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  51386. /**
  51387. * Public members
  51388. */
  51389. /**
  51390. * Post-process which contains the original scene color before the pipeline applies all the effects
  51391. */
  51392. originalPostProcess: Nullable<PostProcess>;
  51393. /**
  51394. * Post-process used to down scale an image x4
  51395. */
  51396. downSampleX4PostProcess: Nullable<PostProcess>;
  51397. /**
  51398. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  51399. */
  51400. brightPassPostProcess: Nullable<PostProcess>;
  51401. /**
  51402. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  51403. */
  51404. blurHPostProcesses: PostProcess[];
  51405. /**
  51406. * Post-process array storing all the vertical blur post-processes used by the pipeline
  51407. */
  51408. blurVPostProcesses: PostProcess[];
  51409. /**
  51410. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  51411. */
  51412. textureAdderPostProcess: Nullable<PostProcess>;
  51413. /**
  51414. * Post-process used to create volumetric lighting effect
  51415. */
  51416. volumetricLightPostProcess: Nullable<PostProcess>;
  51417. /**
  51418. * Post-process used to smooth the previous volumetric light post-process on the X axis
  51419. */
  51420. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  51421. /**
  51422. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  51423. */
  51424. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  51425. /**
  51426. * Post-process used to merge the volumetric light effect and the real scene color
  51427. */
  51428. volumetricLightMergePostProces: Nullable<PostProcess>;
  51429. /**
  51430. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  51431. */
  51432. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  51433. /**
  51434. * Base post-process used to calculate the average luminance of the final image for HDR
  51435. */
  51436. luminancePostProcess: Nullable<PostProcess>;
  51437. /**
  51438. * Post-processes used to create down sample post-processes in order to get
  51439. * the average luminance of the final image for HDR
  51440. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  51441. */
  51442. luminanceDownSamplePostProcesses: PostProcess[];
  51443. /**
  51444. * Post-process used to create a HDR effect (light adaptation)
  51445. */
  51446. hdrPostProcess: Nullable<PostProcess>;
  51447. /**
  51448. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  51449. */
  51450. textureAdderFinalPostProcess: Nullable<PostProcess>;
  51451. /**
  51452. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  51453. */
  51454. lensFlareFinalPostProcess: Nullable<PostProcess>;
  51455. /**
  51456. * Post-process used to merge the final HDR post-process and the real scene color
  51457. */
  51458. hdrFinalPostProcess: Nullable<PostProcess>;
  51459. /**
  51460. * Post-process used to create a lens flare effect
  51461. */
  51462. lensFlarePostProcess: Nullable<PostProcess>;
  51463. /**
  51464. * Post-process that merges the result of the lens flare post-process and the real scene color
  51465. */
  51466. lensFlareComposePostProcess: Nullable<PostProcess>;
  51467. /**
  51468. * Post-process used to create a motion blur effect
  51469. */
  51470. motionBlurPostProcess: Nullable<PostProcess>;
  51471. /**
  51472. * Post-process used to create a depth of field effect
  51473. */
  51474. depthOfFieldPostProcess: Nullable<PostProcess>;
  51475. /**
  51476. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  51477. */
  51478. fxaaPostProcess: Nullable<FxaaPostProcess>;
  51479. /**
  51480. * Represents the brightness threshold in order to configure the illuminated surfaces
  51481. */
  51482. brightThreshold: number;
  51483. /**
  51484. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  51485. */
  51486. blurWidth: number;
  51487. /**
  51488. * Sets if the blur for highlighted surfaces must be only horizontal
  51489. */
  51490. horizontalBlur: boolean;
  51491. /**
  51492. * Sets the overall exposure used by the pipeline
  51493. */
  51494. exposure: number;
  51495. /**
  51496. * Texture used typically to simulate "dirty" on camera lens
  51497. */
  51498. lensTexture: Nullable<Texture>;
  51499. /**
  51500. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  51501. */
  51502. volumetricLightCoefficient: number;
  51503. /**
  51504. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  51505. */
  51506. volumetricLightPower: number;
  51507. /**
  51508. * Used the set the blur intensity to smooth the volumetric lights
  51509. */
  51510. volumetricLightBlurScale: number;
  51511. /**
  51512. * Light (spot or directional) used to generate the volumetric lights rays
  51513. * The source light must have a shadow generate so the pipeline can get its
  51514. * depth map
  51515. */
  51516. sourceLight: Nullable<SpotLight | DirectionalLight>;
  51517. /**
  51518. * For eye adaptation, represents the minimum luminance the eye can see
  51519. */
  51520. hdrMinimumLuminance: number;
  51521. /**
  51522. * For eye adaptation, represents the decrease luminance speed
  51523. */
  51524. hdrDecreaseRate: number;
  51525. /**
  51526. * For eye adaptation, represents the increase luminance speed
  51527. */
  51528. hdrIncreaseRate: number;
  51529. /**
  51530. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  51531. */
  51532. lensColorTexture: Nullable<Texture>;
  51533. /**
  51534. * The overall strengh for the lens flare effect
  51535. */
  51536. lensFlareStrength: number;
  51537. /**
  51538. * Dispersion coefficient for lens flare ghosts
  51539. */
  51540. lensFlareGhostDispersal: number;
  51541. /**
  51542. * Main lens flare halo width
  51543. */
  51544. lensFlareHaloWidth: number;
  51545. /**
  51546. * Based on the lens distortion effect, defines how much the lens flare result
  51547. * is distorted
  51548. */
  51549. lensFlareDistortionStrength: number;
  51550. /**
  51551. * Lens star texture must be used to simulate rays on the flares and is available
  51552. * in the documentation
  51553. */
  51554. lensStarTexture: Nullable<Texture>;
  51555. /**
  51556. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  51557. * flare effect by taking account of the dirt texture
  51558. */
  51559. lensFlareDirtTexture: Nullable<Texture>;
  51560. /**
  51561. * Represents the focal length for the depth of field effect
  51562. */
  51563. depthOfFieldDistance: number;
  51564. /**
  51565. * Represents the blur intensity for the blurred part of the depth of field effect
  51566. */
  51567. depthOfFieldBlurWidth: number;
  51568. /**
  51569. * For motion blur, defines how much the image is blurred by the movement
  51570. */
  51571. motionStrength: number;
  51572. /**
  51573. * List of animations for the pipeline (IAnimatable implementation)
  51574. */
  51575. animations: Animation[];
  51576. /**
  51577. * Private members
  51578. */
  51579. private _scene;
  51580. private _currentDepthOfFieldSource;
  51581. private _basePostProcess;
  51582. private _hdrCurrentLuminance;
  51583. private _floatTextureType;
  51584. private _ratio;
  51585. private _bloomEnabled;
  51586. private _depthOfFieldEnabled;
  51587. private _vlsEnabled;
  51588. private _lensFlareEnabled;
  51589. private _hdrEnabled;
  51590. private _motionBlurEnabled;
  51591. private _fxaaEnabled;
  51592. private _motionBlurSamples;
  51593. private _volumetricLightStepsCount;
  51594. private _samples;
  51595. /**
  51596. * @ignore
  51597. * Specifies if the bloom pipeline is enabled
  51598. */
  51599. BloomEnabled: boolean;
  51600. /**
  51601. * @ignore
  51602. * Specifies if the depth of field pipeline is enabed
  51603. */
  51604. DepthOfFieldEnabled: boolean;
  51605. /**
  51606. * @ignore
  51607. * Specifies if the lens flare pipeline is enabed
  51608. */
  51609. LensFlareEnabled: boolean;
  51610. /**
  51611. * @ignore
  51612. * Specifies if the HDR pipeline is enabled
  51613. */
  51614. HDREnabled: boolean;
  51615. /**
  51616. * @ignore
  51617. * Specifies if the volumetric lights scattering effect is enabled
  51618. */
  51619. VLSEnabled: boolean;
  51620. /**
  51621. * @ignore
  51622. * Specifies if the motion blur effect is enabled
  51623. */
  51624. MotionBlurEnabled: boolean;
  51625. /**
  51626. * Specifies if anti-aliasing is enabled
  51627. */
  51628. fxaaEnabled: boolean;
  51629. /**
  51630. * Specifies the number of steps used to calculate the volumetric lights
  51631. * Typically in interval [50, 200]
  51632. */
  51633. volumetricLightStepsCount: number;
  51634. /**
  51635. * Specifies the number of samples used for the motion blur effect
  51636. * Typically in interval [16, 64]
  51637. */
  51638. motionBlurSamples: number;
  51639. /**
  51640. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  51641. */
  51642. samples: number;
  51643. /**
  51644. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51645. * @constructor
  51646. * @param name The rendering pipeline name
  51647. * @param scene The scene linked to this pipeline
  51648. * @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)
  51649. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  51650. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51651. */
  51652. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  51653. private _buildPipeline;
  51654. private _createDownSampleX4PostProcess;
  51655. private _createBrightPassPostProcess;
  51656. private _createBlurPostProcesses;
  51657. private _createTextureAdderPostProcess;
  51658. private _createVolumetricLightPostProcess;
  51659. private _createLuminancePostProcesses;
  51660. private _createHdrPostProcess;
  51661. private _createLensFlarePostProcess;
  51662. private _createDepthOfFieldPostProcess;
  51663. private _createMotionBlurPostProcess;
  51664. private _getDepthTexture;
  51665. private _disposePostProcesses;
  51666. /**
  51667. * Dispose of the pipeline and stop all post processes
  51668. */
  51669. dispose(): void;
  51670. /**
  51671. * Serialize the rendering pipeline (Used when exporting)
  51672. * @returns the serialized object
  51673. */
  51674. serialize(): any;
  51675. /**
  51676. * Parse the serialized pipeline
  51677. * @param source Source pipeline.
  51678. * @param scene The scene to load the pipeline to.
  51679. * @param rootUrl The URL of the serialized pipeline.
  51680. * @returns An instantiated pipeline from the serialized object.
  51681. */
  51682. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  51683. /**
  51684. * Luminance steps
  51685. */
  51686. static LuminanceSteps: number;
  51687. }
  51688. }
  51689. declare module BABYLON {
  51690. /**
  51691. * PostProcessRenderPipelineManager class
  51692. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51693. */
  51694. export class PostProcessRenderPipelineManager {
  51695. private _renderPipelines;
  51696. /**
  51697. * Initializes a PostProcessRenderPipelineManager
  51698. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51699. */
  51700. constructor();
  51701. /**
  51702. * Gets the list of supported render pipelines
  51703. */
  51704. readonly supportedPipelines: PostProcessRenderPipeline[];
  51705. /**
  51706. * Adds a pipeline to the manager
  51707. * @param renderPipeline The pipeline to add
  51708. */
  51709. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  51710. /**
  51711. * Attaches a camera to the pipeline
  51712. * @param renderPipelineName The name of the pipeline to attach to
  51713. * @param cameras the camera to attach
  51714. * @param unique if the camera can be attached multiple times to the pipeline
  51715. */
  51716. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  51717. /**
  51718. * Detaches a camera from the pipeline
  51719. * @param renderPipelineName The name of the pipeline to detach from
  51720. * @param cameras the camera to detach
  51721. */
  51722. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  51723. /**
  51724. * Enables an effect by name on a pipeline
  51725. * @param renderPipelineName the name of the pipeline to enable the effect in
  51726. * @param renderEffectName the name of the effect to enable
  51727. * @param cameras the cameras that the effect should be enabled on
  51728. */
  51729. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  51730. /**
  51731. * Disables an effect by name on a pipeline
  51732. * @param renderPipelineName the name of the pipeline to disable the effect in
  51733. * @param renderEffectName the name of the effect to disable
  51734. * @param cameras the cameras that the effect should be disabled on
  51735. */
  51736. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  51737. /**
  51738. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  51739. */
  51740. update(): void;
  51741. /** @hidden */
  51742. _rebuild(): void;
  51743. /**
  51744. * Disposes of the manager and pipelines
  51745. */
  51746. dispose(): void;
  51747. }
  51748. }
  51749. declare module BABYLON {
  51750. interface Scene {
  51751. /** @hidden (Backing field) */
  51752. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  51753. /**
  51754. * Gets the postprocess render pipeline manager
  51755. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51756. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  51757. */
  51758. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  51759. }
  51760. /**
  51761. * Defines the Render Pipeline scene component responsible to rendering pipelines
  51762. */
  51763. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  51764. /**
  51765. * The component name helpfull to identify the component in the list of scene components.
  51766. */
  51767. readonly name: string;
  51768. /**
  51769. * The scene the component belongs to.
  51770. */
  51771. scene: Scene;
  51772. /**
  51773. * Creates a new instance of the component for the given scene
  51774. * @param scene Defines the scene to register the component in
  51775. */
  51776. constructor(scene: Scene);
  51777. /**
  51778. * Registers the component in a given scene
  51779. */
  51780. register(): void;
  51781. /**
  51782. * Rebuilds the elements related to this component in case of
  51783. * context lost for instance.
  51784. */
  51785. rebuild(): void;
  51786. /**
  51787. * Disposes the component and the associated ressources
  51788. */
  51789. dispose(): void;
  51790. private _gatherRenderTargets;
  51791. }
  51792. }
  51793. declare module BABYLON {
  51794. /** @hidden */
  51795. export var tonemapPixelShader: {
  51796. name: string;
  51797. shader: string;
  51798. };
  51799. }
  51800. declare module BABYLON {
  51801. /** Defines operator used for tonemapping */
  51802. export enum TonemappingOperator {
  51803. /** Hable */
  51804. Hable = 0,
  51805. /** Reinhard */
  51806. Reinhard = 1,
  51807. /** HejiDawson */
  51808. HejiDawson = 2,
  51809. /** Photographic */
  51810. Photographic = 3
  51811. }
  51812. /**
  51813. * Defines a post process to apply tone mapping
  51814. */
  51815. export class TonemapPostProcess extends PostProcess {
  51816. private _operator;
  51817. /** Defines the required exposure adjustement */
  51818. exposureAdjustment: number;
  51819. /**
  51820. * Creates a new TonemapPostProcess
  51821. * @param name defines the name of the postprocess
  51822. * @param _operator defines the operator to use
  51823. * @param exposureAdjustment defines the required exposure adjustement
  51824. * @param camera defines the camera to use (can be null)
  51825. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  51826. * @param engine defines the hosting engine (can be ignore if camera is set)
  51827. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51828. */
  51829. constructor(name: string, _operator: TonemappingOperator,
  51830. /** Defines the required exposure adjustement */
  51831. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  51832. }
  51833. }
  51834. declare module BABYLON {
  51835. /** @hidden */
  51836. export var depthVertexShader: {
  51837. name: string;
  51838. shader: string;
  51839. };
  51840. }
  51841. declare module BABYLON {
  51842. /** @hidden */
  51843. export var volumetricLightScatteringPixelShader: {
  51844. name: string;
  51845. shader: string;
  51846. };
  51847. }
  51848. declare module BABYLON {
  51849. /** @hidden */
  51850. export var volumetricLightScatteringPassPixelShader: {
  51851. name: string;
  51852. shader: string;
  51853. };
  51854. }
  51855. declare module BABYLON {
  51856. /**
  51857. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  51858. */
  51859. export class VolumetricLightScatteringPostProcess extends PostProcess {
  51860. private _volumetricLightScatteringPass;
  51861. private _volumetricLightScatteringRTT;
  51862. private _viewPort;
  51863. private _screenCoordinates;
  51864. private _cachedDefines;
  51865. /**
  51866. * If not undefined, the mesh position is computed from the attached node position
  51867. */
  51868. attachedNode: {
  51869. position: Vector3;
  51870. };
  51871. /**
  51872. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  51873. */
  51874. customMeshPosition: Vector3;
  51875. /**
  51876. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  51877. */
  51878. useCustomMeshPosition: boolean;
  51879. /**
  51880. * If the post-process should inverse the light scattering direction
  51881. */
  51882. invert: boolean;
  51883. /**
  51884. * The internal mesh used by the post-process
  51885. */
  51886. mesh: Mesh;
  51887. /**
  51888. * @hidden
  51889. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  51890. */
  51891. useDiffuseColor: boolean;
  51892. /**
  51893. * Array containing the excluded meshes not rendered in the internal pass
  51894. */
  51895. excludedMeshes: AbstractMesh[];
  51896. /**
  51897. * Controls the overall intensity of the post-process
  51898. */
  51899. exposure: number;
  51900. /**
  51901. * Dissipates each sample's contribution in range [0, 1]
  51902. */
  51903. decay: number;
  51904. /**
  51905. * Controls the overall intensity of each sample
  51906. */
  51907. weight: number;
  51908. /**
  51909. * Controls the density of each sample
  51910. */
  51911. density: number;
  51912. /**
  51913. * @constructor
  51914. * @param name The post-process name
  51915. * @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)
  51916. * @param camera The camera that the post-process will be attached to
  51917. * @param mesh The mesh used to create the light scattering
  51918. * @param samples The post-process quality, default 100
  51919. * @param samplingModeThe post-process filtering mode
  51920. * @param engine The babylon engine
  51921. * @param reusable If the post-process is reusable
  51922. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  51923. */
  51924. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  51925. /**
  51926. * Returns the string "VolumetricLightScatteringPostProcess"
  51927. * @returns "VolumetricLightScatteringPostProcess"
  51928. */
  51929. getClassName(): string;
  51930. private _isReady;
  51931. /**
  51932. * Sets the new light position for light scattering effect
  51933. * @param position The new custom light position
  51934. */
  51935. setCustomMeshPosition(position: Vector3): void;
  51936. /**
  51937. * Returns the light position for light scattering effect
  51938. * @return Vector3 The custom light position
  51939. */
  51940. getCustomMeshPosition(): Vector3;
  51941. /**
  51942. * Disposes the internal assets and detaches the post-process from the camera
  51943. */
  51944. dispose(camera: Camera): void;
  51945. /**
  51946. * Returns the render target texture used by the post-process
  51947. * @return the render target texture used by the post-process
  51948. */
  51949. getPass(): RenderTargetTexture;
  51950. private _meshExcluded;
  51951. private _createPass;
  51952. private _updateMeshScreenCoordinates;
  51953. /**
  51954. * Creates a default mesh for the Volumeric Light Scattering post-process
  51955. * @param name The mesh name
  51956. * @param scene The scene where to create the mesh
  51957. * @return the default mesh
  51958. */
  51959. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  51960. }
  51961. }
  51962. declare module BABYLON {
  51963. interface Scene {
  51964. /** @hidden (Backing field) */
  51965. _boundingBoxRenderer: BoundingBoxRenderer;
  51966. /** @hidden (Backing field) */
  51967. _forceShowBoundingBoxes: boolean;
  51968. /**
  51969. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  51970. */
  51971. forceShowBoundingBoxes: boolean;
  51972. /**
  51973. * Gets the bounding box renderer associated with the scene
  51974. * @returns a BoundingBoxRenderer
  51975. */
  51976. getBoundingBoxRenderer(): BoundingBoxRenderer;
  51977. }
  51978. interface AbstractMesh {
  51979. /** @hidden (Backing field) */
  51980. _showBoundingBox: boolean;
  51981. /**
  51982. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  51983. */
  51984. showBoundingBox: boolean;
  51985. }
  51986. /**
  51987. * Component responsible of rendering the bounding box of the meshes in a scene.
  51988. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  51989. */
  51990. export class BoundingBoxRenderer implements ISceneComponent {
  51991. /**
  51992. * The component name helpfull to identify the component in the list of scene components.
  51993. */
  51994. readonly name: string;
  51995. /**
  51996. * The scene the component belongs to.
  51997. */
  51998. scene: Scene;
  51999. /**
  52000. * Color of the bounding box lines placed in front of an object
  52001. */
  52002. frontColor: Color3;
  52003. /**
  52004. * Color of the bounding box lines placed behind an object
  52005. */
  52006. backColor: Color3;
  52007. /**
  52008. * Defines if the renderer should show the back lines or not
  52009. */
  52010. showBackLines: boolean;
  52011. /**
  52012. * @hidden
  52013. */
  52014. renderList: SmartArray<BoundingBox>;
  52015. private _colorShader;
  52016. private _vertexBuffers;
  52017. private _indexBuffer;
  52018. /**
  52019. * Instantiates a new bounding box renderer in a scene.
  52020. * @param scene the scene the renderer renders in
  52021. */
  52022. constructor(scene: Scene);
  52023. /**
  52024. * Registers the component in a given scene
  52025. */
  52026. register(): void;
  52027. private _evaluateSubMesh;
  52028. private _activeMesh;
  52029. private _prepareRessources;
  52030. private _createIndexBuffer;
  52031. /**
  52032. * Rebuilds the elements related to this component in case of
  52033. * context lost for instance.
  52034. */
  52035. rebuild(): void;
  52036. /**
  52037. * @hidden
  52038. */
  52039. reset(): void;
  52040. /**
  52041. * Render the bounding boxes of a specific rendering group
  52042. * @param renderingGroupId defines the rendering group to render
  52043. */
  52044. render(renderingGroupId: number): void;
  52045. /**
  52046. * In case of occlusion queries, we can render the occlusion bounding box through this method
  52047. * @param mesh Define the mesh to render the occlusion bounding box for
  52048. */
  52049. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  52050. /**
  52051. * Dispose and release the resources attached to this renderer.
  52052. */
  52053. dispose(): void;
  52054. }
  52055. }
  52056. declare module BABYLON {
  52057. /** @hidden */
  52058. export var depthPixelShader: {
  52059. name: string;
  52060. shader: string;
  52061. };
  52062. }
  52063. declare module BABYLON {
  52064. /**
  52065. * This represents a depth renderer in Babylon.
  52066. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  52067. */
  52068. export class DepthRenderer {
  52069. private _scene;
  52070. private _depthMap;
  52071. private _effect;
  52072. private _cachedDefines;
  52073. private _camera;
  52074. /**
  52075. * Specifiess that the depth renderer will only be used within
  52076. * the camera it is created for.
  52077. * This can help forcing its rendering during the camera processing.
  52078. */
  52079. useOnlyInActiveCamera: boolean;
  52080. /** @hidden */
  52081. static _SceneComponentInitialization: (scene: Scene) => void;
  52082. /**
  52083. * Instantiates a depth renderer
  52084. * @param scene The scene the renderer belongs to
  52085. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  52086. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  52087. */
  52088. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  52089. /**
  52090. * Creates the depth rendering effect and checks if the effect is ready.
  52091. * @param subMesh The submesh to be used to render the depth map of
  52092. * @param useInstances If multiple world instances should be used
  52093. * @returns if the depth renderer is ready to render the depth map
  52094. */
  52095. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52096. /**
  52097. * Gets the texture which the depth map will be written to.
  52098. * @returns The depth map texture
  52099. */
  52100. getDepthMap(): RenderTargetTexture;
  52101. /**
  52102. * Disposes of the depth renderer.
  52103. */
  52104. dispose(): void;
  52105. }
  52106. }
  52107. declare module BABYLON {
  52108. interface Scene {
  52109. /** @hidden (Backing field) */
  52110. _depthRenderer: {
  52111. [id: string]: DepthRenderer;
  52112. };
  52113. /**
  52114. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  52115. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  52116. * @returns the created depth renderer
  52117. */
  52118. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  52119. /**
  52120. * Disables a depth renderer for a given camera
  52121. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  52122. */
  52123. disableDepthRenderer(camera?: Nullable<Camera>): void;
  52124. }
  52125. /**
  52126. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  52127. * in several rendering techniques.
  52128. */
  52129. export class DepthRendererSceneComponent implements ISceneComponent {
  52130. /**
  52131. * The component name helpfull to identify the component in the list of scene components.
  52132. */
  52133. readonly name: string;
  52134. /**
  52135. * The scene the component belongs to.
  52136. */
  52137. scene: Scene;
  52138. /**
  52139. * Creates a new instance of the component for the given scene
  52140. * @param scene Defines the scene to register the component in
  52141. */
  52142. constructor(scene: Scene);
  52143. /**
  52144. * Registers the component in a given scene
  52145. */
  52146. register(): void;
  52147. /**
  52148. * Rebuilds the elements related to this component in case of
  52149. * context lost for instance.
  52150. */
  52151. rebuild(): void;
  52152. /**
  52153. * Disposes the component and the associated ressources
  52154. */
  52155. dispose(): void;
  52156. private _gatherRenderTargets;
  52157. private _gatherActiveCameraRenderTargets;
  52158. }
  52159. }
  52160. declare module BABYLON {
  52161. interface Scene {
  52162. /** @hidden (Backing field) */
  52163. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52164. /**
  52165. * Gets or Sets the current geometry buffer associated to the scene.
  52166. */
  52167. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52168. /**
  52169. * Enables a GeometryBufferRender and associates it with the scene
  52170. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  52171. * @returns the GeometryBufferRenderer
  52172. */
  52173. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  52174. /**
  52175. * Disables the GeometryBufferRender associated with the scene
  52176. */
  52177. disableGeometryBufferRenderer(): void;
  52178. }
  52179. /**
  52180. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  52181. * in several rendering techniques.
  52182. */
  52183. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  52184. /**
  52185. * The component name helpful to identify the component in the list of scene components.
  52186. */
  52187. readonly name: string;
  52188. /**
  52189. * The scene the component belongs to.
  52190. */
  52191. scene: Scene;
  52192. /**
  52193. * Creates a new instance of the component for the given scene
  52194. * @param scene Defines the scene to register the component in
  52195. */
  52196. constructor(scene: Scene);
  52197. /**
  52198. * Registers the component in a given scene
  52199. */
  52200. register(): void;
  52201. /**
  52202. * Rebuilds the elements related to this component in case of
  52203. * context lost for instance.
  52204. */
  52205. rebuild(): void;
  52206. /**
  52207. * Disposes the component and the associated ressources
  52208. */
  52209. dispose(): void;
  52210. private _gatherRenderTargets;
  52211. }
  52212. }
  52213. declare module BABYLON {
  52214. /** @hidden */
  52215. export var outlinePixelShader: {
  52216. name: string;
  52217. shader: string;
  52218. };
  52219. }
  52220. declare module BABYLON {
  52221. /** @hidden */
  52222. export var outlineVertexShader: {
  52223. name: string;
  52224. shader: string;
  52225. };
  52226. }
  52227. declare module BABYLON {
  52228. interface Scene {
  52229. /** @hidden */
  52230. _outlineRenderer: OutlineRenderer;
  52231. /**
  52232. * Gets the outline renderer associated with the scene
  52233. * @returns a OutlineRenderer
  52234. */
  52235. getOutlineRenderer(): OutlineRenderer;
  52236. }
  52237. interface AbstractMesh {
  52238. /** @hidden (Backing field) */
  52239. _renderOutline: boolean;
  52240. /**
  52241. * Gets or sets a boolean indicating if the outline must be rendered as well
  52242. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  52243. */
  52244. renderOutline: boolean;
  52245. /** @hidden (Backing field) */
  52246. _renderOverlay: boolean;
  52247. /**
  52248. * Gets or sets a boolean indicating if the overlay must be rendered as well
  52249. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  52250. */
  52251. renderOverlay: boolean;
  52252. }
  52253. /**
  52254. * This class is responsible to draw bothe outline/overlay of meshes.
  52255. * It should not be used directly but through the available method on mesh.
  52256. */
  52257. export class OutlineRenderer implements ISceneComponent {
  52258. /**
  52259. * The name of the component. Each component must have a unique name.
  52260. */
  52261. name: string;
  52262. /**
  52263. * The scene the component belongs to.
  52264. */
  52265. scene: Scene;
  52266. /**
  52267. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  52268. */
  52269. zOffset: number;
  52270. private _engine;
  52271. private _effect;
  52272. private _cachedDefines;
  52273. private _savedDepthWrite;
  52274. /**
  52275. * Instantiates a new outline renderer. (There could be only one per scene).
  52276. * @param scene Defines the scene it belongs to
  52277. */
  52278. constructor(scene: Scene);
  52279. /**
  52280. * Register the component to one instance of a scene.
  52281. */
  52282. register(): void;
  52283. /**
  52284. * Rebuilds the elements related to this component in case of
  52285. * context lost for instance.
  52286. */
  52287. rebuild(): void;
  52288. /**
  52289. * Disposes the component and the associated ressources.
  52290. */
  52291. dispose(): void;
  52292. /**
  52293. * Renders the outline in the canvas.
  52294. * @param subMesh Defines the sumesh to render
  52295. * @param batch Defines the batch of meshes in case of instances
  52296. * @param useOverlay Defines if the rendering is for the overlay or the outline
  52297. */
  52298. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  52299. /**
  52300. * Returns whether or not the outline renderer is ready for a given submesh.
  52301. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  52302. * @param subMesh Defines the submesh to check readyness for
  52303. * @param useInstances Defines wheter wee are trying to render instances or not
  52304. * @returns true if ready otherwise false
  52305. */
  52306. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52307. private _beforeRenderingMesh;
  52308. private _afterRenderingMesh;
  52309. }
  52310. }
  52311. declare module BABYLON {
  52312. /**
  52313. * Defines the list of states available for a task inside a AssetsManager
  52314. */
  52315. export enum AssetTaskState {
  52316. /**
  52317. * Initialization
  52318. */
  52319. INIT = 0,
  52320. /**
  52321. * Running
  52322. */
  52323. RUNNING = 1,
  52324. /**
  52325. * Done
  52326. */
  52327. DONE = 2,
  52328. /**
  52329. * Error
  52330. */
  52331. ERROR = 3
  52332. }
  52333. /**
  52334. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  52335. */
  52336. export abstract class AbstractAssetTask {
  52337. /**
  52338. * Task name
  52339. */ name: string;
  52340. /**
  52341. * Callback called when the task is successful
  52342. */
  52343. onSuccess: (task: any) => void;
  52344. /**
  52345. * Callback called when the task is not successful
  52346. */
  52347. onError: (task: any, message?: string, exception?: any) => void;
  52348. /**
  52349. * Creates a new AssetsManager
  52350. * @param name defines the name of the task
  52351. */
  52352. constructor(
  52353. /**
  52354. * Task name
  52355. */ name: string);
  52356. private _isCompleted;
  52357. private _taskState;
  52358. private _errorObject;
  52359. /**
  52360. * Get if the task is completed
  52361. */
  52362. readonly isCompleted: boolean;
  52363. /**
  52364. * Gets the current state of the task
  52365. */
  52366. readonly taskState: AssetTaskState;
  52367. /**
  52368. * Gets the current error object (if task is in error)
  52369. */
  52370. readonly errorObject: {
  52371. message?: string;
  52372. exception?: any;
  52373. };
  52374. /**
  52375. * Internal only
  52376. * @hidden
  52377. */
  52378. _setErrorObject(message?: string, exception?: any): void;
  52379. /**
  52380. * Execute the current task
  52381. * @param scene defines the scene where you want your assets to be loaded
  52382. * @param onSuccess is a callback called when the task is successfully executed
  52383. * @param onError is a callback called if an error occurs
  52384. */
  52385. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52386. /**
  52387. * Execute the current task
  52388. * @param scene defines the scene where you want your assets to be loaded
  52389. * @param onSuccess is a callback called when the task is successfully executed
  52390. * @param onError is a callback called if an error occurs
  52391. */
  52392. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52393. /**
  52394. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  52395. * This can be used with failed tasks that have the reason for failure fixed.
  52396. */
  52397. reset(): void;
  52398. private onErrorCallback;
  52399. private onDoneCallback;
  52400. }
  52401. /**
  52402. * Define the interface used by progress events raised during assets loading
  52403. */
  52404. export interface IAssetsProgressEvent {
  52405. /**
  52406. * Defines the number of remaining tasks to process
  52407. */
  52408. remainingCount: number;
  52409. /**
  52410. * Defines the total number of tasks
  52411. */
  52412. totalCount: number;
  52413. /**
  52414. * Defines the task that was just processed
  52415. */
  52416. task: AbstractAssetTask;
  52417. }
  52418. /**
  52419. * Class used to share progress information about assets loading
  52420. */
  52421. export class AssetsProgressEvent implements IAssetsProgressEvent {
  52422. /**
  52423. * Defines the number of remaining tasks to process
  52424. */
  52425. remainingCount: number;
  52426. /**
  52427. * Defines the total number of tasks
  52428. */
  52429. totalCount: number;
  52430. /**
  52431. * Defines the task that was just processed
  52432. */
  52433. task: AbstractAssetTask;
  52434. /**
  52435. * Creates a AssetsProgressEvent
  52436. * @param remainingCount defines the number of remaining tasks to process
  52437. * @param totalCount defines the total number of tasks
  52438. * @param task defines the task that was just processed
  52439. */
  52440. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  52441. }
  52442. /**
  52443. * Define a task used by AssetsManager to load meshes
  52444. */
  52445. export class MeshAssetTask extends AbstractAssetTask {
  52446. /**
  52447. * Defines the name of the task
  52448. */
  52449. name: string;
  52450. /**
  52451. * Defines the list of mesh's names you want to load
  52452. */
  52453. meshesNames: any;
  52454. /**
  52455. * Defines the root url to use as a base to load your meshes and associated resources
  52456. */
  52457. rootUrl: string;
  52458. /**
  52459. * Defines the filename of the scene to load from
  52460. */
  52461. sceneFilename: string;
  52462. /**
  52463. * Gets the list of loaded meshes
  52464. */
  52465. loadedMeshes: Array<AbstractMesh>;
  52466. /**
  52467. * Gets the list of loaded particle systems
  52468. */
  52469. loadedParticleSystems: Array<IParticleSystem>;
  52470. /**
  52471. * Gets the list of loaded skeletons
  52472. */
  52473. loadedSkeletons: Array<Skeleton>;
  52474. /**
  52475. * Gets the list of loaded animation groups
  52476. */
  52477. loadedAnimationGroups: Array<AnimationGroup>;
  52478. /**
  52479. * Callback called when the task is successful
  52480. */
  52481. onSuccess: (task: MeshAssetTask) => void;
  52482. /**
  52483. * Callback called when the task is successful
  52484. */
  52485. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  52486. /**
  52487. * Creates a new MeshAssetTask
  52488. * @param name defines the name of the task
  52489. * @param meshesNames defines the list of mesh's names you want to load
  52490. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  52491. * @param sceneFilename defines the filename of the scene to load from
  52492. */
  52493. constructor(
  52494. /**
  52495. * Defines the name of the task
  52496. */
  52497. name: string,
  52498. /**
  52499. * Defines the list of mesh's names you want to load
  52500. */
  52501. meshesNames: any,
  52502. /**
  52503. * Defines the root url to use as a base to load your meshes and associated resources
  52504. */
  52505. rootUrl: string,
  52506. /**
  52507. * Defines the filename of the scene to load from
  52508. */
  52509. sceneFilename: string);
  52510. /**
  52511. * Execute the current task
  52512. * @param scene defines the scene where you want your assets to be loaded
  52513. * @param onSuccess is a callback called when the task is successfully executed
  52514. * @param onError is a callback called if an error occurs
  52515. */
  52516. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52517. }
  52518. /**
  52519. * Define a task used by AssetsManager to load text content
  52520. */
  52521. export class TextFileAssetTask extends AbstractAssetTask {
  52522. /**
  52523. * Defines the name of the task
  52524. */
  52525. name: string;
  52526. /**
  52527. * Defines the location of the file to load
  52528. */
  52529. url: string;
  52530. /**
  52531. * Gets the loaded text string
  52532. */
  52533. text: string;
  52534. /**
  52535. * Callback called when the task is successful
  52536. */
  52537. onSuccess: (task: TextFileAssetTask) => void;
  52538. /**
  52539. * Callback called when the task is successful
  52540. */
  52541. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  52542. /**
  52543. * Creates a new TextFileAssetTask object
  52544. * @param name defines the name of the task
  52545. * @param url defines the location of the file to load
  52546. */
  52547. constructor(
  52548. /**
  52549. * Defines the name of the task
  52550. */
  52551. name: string,
  52552. /**
  52553. * Defines the location of the file to load
  52554. */
  52555. url: string);
  52556. /**
  52557. * Execute the current task
  52558. * @param scene defines the scene where you want your assets to be loaded
  52559. * @param onSuccess is a callback called when the task is successfully executed
  52560. * @param onError is a callback called if an error occurs
  52561. */
  52562. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52563. }
  52564. /**
  52565. * Define a task used by AssetsManager to load binary data
  52566. */
  52567. export class BinaryFileAssetTask extends AbstractAssetTask {
  52568. /**
  52569. * Defines the name of the task
  52570. */
  52571. name: string;
  52572. /**
  52573. * Defines the location of the file to load
  52574. */
  52575. url: string;
  52576. /**
  52577. * Gets the lodaded data (as an array buffer)
  52578. */
  52579. data: ArrayBuffer;
  52580. /**
  52581. * Callback called when the task is successful
  52582. */
  52583. onSuccess: (task: BinaryFileAssetTask) => void;
  52584. /**
  52585. * Callback called when the task is successful
  52586. */
  52587. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  52588. /**
  52589. * Creates a new BinaryFileAssetTask object
  52590. * @param name defines the name of the new task
  52591. * @param url defines the location of the file to load
  52592. */
  52593. constructor(
  52594. /**
  52595. * Defines the name of the task
  52596. */
  52597. name: string,
  52598. /**
  52599. * Defines the location of the file to load
  52600. */
  52601. url: string);
  52602. /**
  52603. * Execute the current task
  52604. * @param scene defines the scene where you want your assets to be loaded
  52605. * @param onSuccess is a callback called when the task is successfully executed
  52606. * @param onError is a callback called if an error occurs
  52607. */
  52608. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52609. }
  52610. /**
  52611. * Define a task used by AssetsManager to load images
  52612. */
  52613. export class ImageAssetTask extends AbstractAssetTask {
  52614. /**
  52615. * Defines the name of the task
  52616. */
  52617. name: string;
  52618. /**
  52619. * Defines the location of the image to load
  52620. */
  52621. url: string;
  52622. /**
  52623. * Gets the loaded images
  52624. */
  52625. image: HTMLImageElement;
  52626. /**
  52627. * Callback called when the task is successful
  52628. */
  52629. onSuccess: (task: ImageAssetTask) => void;
  52630. /**
  52631. * Callback called when the task is successful
  52632. */
  52633. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  52634. /**
  52635. * Creates a new ImageAssetTask
  52636. * @param name defines the name of the task
  52637. * @param url defines the location of the image to load
  52638. */
  52639. constructor(
  52640. /**
  52641. * Defines the name of the task
  52642. */
  52643. name: string,
  52644. /**
  52645. * Defines the location of the image to load
  52646. */
  52647. url: string);
  52648. /**
  52649. * Execute the current task
  52650. * @param scene defines the scene where you want your assets to be loaded
  52651. * @param onSuccess is a callback called when the task is successfully executed
  52652. * @param onError is a callback called if an error occurs
  52653. */
  52654. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52655. }
  52656. /**
  52657. * Defines the interface used by texture loading tasks
  52658. */
  52659. export interface ITextureAssetTask<TEX extends BaseTexture> {
  52660. /**
  52661. * Gets the loaded texture
  52662. */
  52663. texture: TEX;
  52664. }
  52665. /**
  52666. * Define a task used by AssetsManager to load 2D textures
  52667. */
  52668. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  52669. /**
  52670. * Defines the name of the task
  52671. */
  52672. name: string;
  52673. /**
  52674. * Defines the location of the file to load
  52675. */
  52676. url: string;
  52677. /**
  52678. * Defines if mipmap should not be generated (default is false)
  52679. */
  52680. noMipmap?: boolean | undefined;
  52681. /**
  52682. * Defines if texture must be inverted on Y axis (default is false)
  52683. */
  52684. invertY?: boolean | undefined;
  52685. /**
  52686. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52687. */
  52688. samplingMode: number;
  52689. /**
  52690. * Gets the loaded texture
  52691. */
  52692. texture: Texture;
  52693. /**
  52694. * Callback called when the task is successful
  52695. */
  52696. onSuccess: (task: TextureAssetTask) => void;
  52697. /**
  52698. * Callback called when the task is successful
  52699. */
  52700. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  52701. /**
  52702. * Creates a new TextureAssetTask object
  52703. * @param name defines the name of the task
  52704. * @param url defines the location of the file to load
  52705. * @param noMipmap defines if mipmap should not be generated (default is false)
  52706. * @param invertY defines if texture must be inverted on Y axis (default is false)
  52707. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52708. */
  52709. constructor(
  52710. /**
  52711. * Defines the name of the task
  52712. */
  52713. name: string,
  52714. /**
  52715. * Defines the location of the file to load
  52716. */
  52717. url: string,
  52718. /**
  52719. * Defines if mipmap should not be generated (default is false)
  52720. */
  52721. noMipmap?: boolean | undefined,
  52722. /**
  52723. * Defines if texture must be inverted on Y axis (default is false)
  52724. */
  52725. invertY?: boolean | undefined,
  52726. /**
  52727. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52728. */
  52729. samplingMode?: number);
  52730. /**
  52731. * Execute the current task
  52732. * @param scene defines the scene where you want your assets to be loaded
  52733. * @param onSuccess is a callback called when the task is successfully executed
  52734. * @param onError is a callback called if an error occurs
  52735. */
  52736. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52737. }
  52738. /**
  52739. * Define a task used by AssetsManager to load cube textures
  52740. */
  52741. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  52742. /**
  52743. * Defines the name of the task
  52744. */
  52745. name: string;
  52746. /**
  52747. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  52748. */
  52749. url: string;
  52750. /**
  52751. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  52752. */
  52753. extensions?: string[] | undefined;
  52754. /**
  52755. * Defines if mipmaps should not be generated (default is false)
  52756. */
  52757. noMipmap?: boolean | undefined;
  52758. /**
  52759. * Defines the explicit list of files (undefined by default)
  52760. */
  52761. files?: string[] | undefined;
  52762. /**
  52763. * Gets the loaded texture
  52764. */
  52765. texture: CubeTexture;
  52766. /**
  52767. * Callback called when the task is successful
  52768. */
  52769. onSuccess: (task: CubeTextureAssetTask) => void;
  52770. /**
  52771. * Callback called when the task is successful
  52772. */
  52773. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  52774. /**
  52775. * Creates a new CubeTextureAssetTask
  52776. * @param name defines the name of the task
  52777. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  52778. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  52779. * @param noMipmap defines if mipmaps should not be generated (default is false)
  52780. * @param files defines the explicit list of files (undefined by default)
  52781. */
  52782. constructor(
  52783. /**
  52784. * Defines the name of the task
  52785. */
  52786. name: string,
  52787. /**
  52788. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  52789. */
  52790. url: string,
  52791. /**
  52792. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  52793. */
  52794. extensions?: string[] | undefined,
  52795. /**
  52796. * Defines if mipmaps should not be generated (default is false)
  52797. */
  52798. noMipmap?: boolean | undefined,
  52799. /**
  52800. * Defines the explicit list of files (undefined by default)
  52801. */
  52802. files?: string[] | undefined);
  52803. /**
  52804. * Execute the current task
  52805. * @param scene defines the scene where you want your assets to be loaded
  52806. * @param onSuccess is a callback called when the task is successfully executed
  52807. * @param onError is a callback called if an error occurs
  52808. */
  52809. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52810. }
  52811. /**
  52812. * Define a task used by AssetsManager to load HDR cube textures
  52813. */
  52814. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  52815. /**
  52816. * Defines the name of the task
  52817. */
  52818. name: string;
  52819. /**
  52820. * Defines the location of the file to load
  52821. */
  52822. url: string;
  52823. /**
  52824. * Defines the desired size (the more it increases the longer the generation will be)
  52825. */
  52826. size: number;
  52827. /**
  52828. * Defines if mipmaps should not be generated (default is false)
  52829. */
  52830. noMipmap: boolean;
  52831. /**
  52832. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  52833. */
  52834. generateHarmonics: boolean;
  52835. /**
  52836. * 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)
  52837. */
  52838. gammaSpace: boolean;
  52839. /**
  52840. * Internal Use Only
  52841. */
  52842. reserved: boolean;
  52843. /**
  52844. * Gets the loaded texture
  52845. */
  52846. texture: HDRCubeTexture;
  52847. /**
  52848. * Callback called when the task is successful
  52849. */
  52850. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  52851. /**
  52852. * Callback called when the task is successful
  52853. */
  52854. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  52855. /**
  52856. * Creates a new HDRCubeTextureAssetTask object
  52857. * @param name defines the name of the task
  52858. * @param url defines the location of the file to load
  52859. * @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.
  52860. * @param noMipmap defines if mipmaps should not be generated (default is false)
  52861. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  52862. * @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)
  52863. * @param reserved Internal use only
  52864. */
  52865. constructor(
  52866. /**
  52867. * Defines the name of the task
  52868. */
  52869. name: string,
  52870. /**
  52871. * Defines the location of the file to load
  52872. */
  52873. url: string,
  52874. /**
  52875. * Defines the desired size (the more it increases the longer the generation will be)
  52876. */
  52877. size: number,
  52878. /**
  52879. * Defines if mipmaps should not be generated (default is false)
  52880. */
  52881. noMipmap?: boolean,
  52882. /**
  52883. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  52884. */
  52885. generateHarmonics?: boolean,
  52886. /**
  52887. * 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)
  52888. */
  52889. gammaSpace?: boolean,
  52890. /**
  52891. * Internal Use Only
  52892. */
  52893. reserved?: boolean);
  52894. /**
  52895. * Execute the current task
  52896. * @param scene defines the scene where you want your assets to be loaded
  52897. * @param onSuccess is a callback called when the task is successfully executed
  52898. * @param onError is a callback called if an error occurs
  52899. */
  52900. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52901. }
  52902. /**
  52903. * This class can be used to easily import assets into a scene
  52904. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  52905. */
  52906. export class AssetsManager {
  52907. private _scene;
  52908. private _isLoading;
  52909. protected _tasks: AbstractAssetTask[];
  52910. protected _waitingTasksCount: number;
  52911. protected _totalTasksCount: number;
  52912. /**
  52913. * Callback called when all tasks are processed
  52914. */
  52915. onFinish: (tasks: AbstractAssetTask[]) => void;
  52916. /**
  52917. * Callback called when a task is successful
  52918. */
  52919. onTaskSuccess: (task: AbstractAssetTask) => void;
  52920. /**
  52921. * Callback called when a task had an error
  52922. */
  52923. onTaskError: (task: AbstractAssetTask) => void;
  52924. /**
  52925. * Callback called when a task is done (whatever the result is)
  52926. */
  52927. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  52928. /**
  52929. * Observable called when all tasks are processed
  52930. */
  52931. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  52932. /**
  52933. * Observable called when a task had an error
  52934. */
  52935. onTaskErrorObservable: Observable<AbstractAssetTask>;
  52936. /**
  52937. * Observable called when a task is successful
  52938. */
  52939. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  52940. /**
  52941. * Observable called when a task is done (whatever the result is)
  52942. */
  52943. onProgressObservable: Observable<IAssetsProgressEvent>;
  52944. /**
  52945. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  52946. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  52947. */
  52948. useDefaultLoadingScreen: boolean;
  52949. /**
  52950. * Creates a new AssetsManager
  52951. * @param scene defines the scene to work on
  52952. */
  52953. constructor(scene: Scene);
  52954. /**
  52955. * Add a MeshAssetTask to the list of active tasks
  52956. * @param taskName defines the name of the new task
  52957. * @param meshesNames defines the name of meshes to load
  52958. * @param rootUrl defines the root url to use to locate files
  52959. * @param sceneFilename defines the filename of the scene file
  52960. * @returns a new MeshAssetTask object
  52961. */
  52962. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  52963. /**
  52964. * Add a TextFileAssetTask to the list of active tasks
  52965. * @param taskName defines the name of the new task
  52966. * @param url defines the url of the file to load
  52967. * @returns a new TextFileAssetTask object
  52968. */
  52969. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  52970. /**
  52971. * Add a BinaryFileAssetTask to the list of active tasks
  52972. * @param taskName defines the name of the new task
  52973. * @param url defines the url of the file to load
  52974. * @returns a new BinaryFileAssetTask object
  52975. */
  52976. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  52977. /**
  52978. * Add a ImageAssetTask to the list of active tasks
  52979. * @param taskName defines the name of the new task
  52980. * @param url defines the url of the file to load
  52981. * @returns a new ImageAssetTask object
  52982. */
  52983. addImageTask(taskName: string, url: string): ImageAssetTask;
  52984. /**
  52985. * Add a TextureAssetTask to the list of active tasks
  52986. * @param taskName defines the name of the new task
  52987. * @param url defines the url of the file to load
  52988. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  52989. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  52990. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52991. * @returns a new TextureAssetTask object
  52992. */
  52993. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  52994. /**
  52995. * Add a CubeTextureAssetTask to the list of active tasks
  52996. * @param taskName defines the name of the new task
  52997. * @param url defines the url of the file to load
  52998. * @param extensions defines the extension to use to load the cube map (can be null)
  52999. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  53000. * @param files defines the list of files to load (can be null)
  53001. * @returns a new CubeTextureAssetTask object
  53002. */
  53003. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  53004. /**
  53005. *
  53006. * Add a HDRCubeTextureAssetTask to the list of active tasks
  53007. * @param taskName defines the name of the new task
  53008. * @param url defines the url of the file to load
  53009. * @param size defines the size you want for the cubemap (can be null)
  53010. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  53011. * @param generateHarmonics defines if you want to automatically generate (true by default)
  53012. * @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)
  53013. * @param reserved Internal use only
  53014. * @returns a new HDRCubeTextureAssetTask object
  53015. */
  53016. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  53017. /**
  53018. * Remove a task from the assets manager.
  53019. * @param task the task to remove
  53020. */
  53021. removeTask(task: AbstractAssetTask): void;
  53022. private _decreaseWaitingTasksCount;
  53023. private _runTask;
  53024. /**
  53025. * Reset the AssetsManager and remove all tasks
  53026. * @return the current instance of the AssetsManager
  53027. */
  53028. reset(): AssetsManager;
  53029. /**
  53030. * Start the loading process
  53031. * @return the current instance of the AssetsManager
  53032. */
  53033. load(): AssetsManager;
  53034. }
  53035. }
  53036. declare module BABYLON {
  53037. /**
  53038. * Wrapper class for promise with external resolve and reject.
  53039. */
  53040. export class Deferred<T> {
  53041. /**
  53042. * The promise associated with this deferred object.
  53043. */
  53044. readonly promise: Promise<T>;
  53045. private _resolve;
  53046. private _reject;
  53047. /**
  53048. * The resolve method of the promise associated with this deferred object.
  53049. */
  53050. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  53051. /**
  53052. * The reject method of the promise associated with this deferred object.
  53053. */
  53054. readonly reject: (reason?: any) => void;
  53055. /**
  53056. * Constructor for this deferred object.
  53057. */
  53058. constructor();
  53059. }
  53060. }
  53061. declare module BABYLON {
  53062. /**
  53063. * Class used to help managing file picking and drag'n'drop
  53064. */
  53065. export class FilesInput {
  53066. /**
  53067. * List of files ready to be loaded
  53068. */
  53069. static readonly FilesToLoad: {
  53070. [key: string]: File;
  53071. };
  53072. /**
  53073. * Callback called when a file is processed
  53074. */
  53075. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  53076. private _engine;
  53077. private _currentScene;
  53078. private _sceneLoadedCallback;
  53079. private _progressCallback;
  53080. private _additionalRenderLoopLogicCallback;
  53081. private _textureLoadingCallback;
  53082. private _startingProcessingFilesCallback;
  53083. private _onReloadCallback;
  53084. private _errorCallback;
  53085. private _elementToMonitor;
  53086. private _sceneFileToLoad;
  53087. private _filesToLoad;
  53088. /**
  53089. * Creates a new FilesInput
  53090. * @param engine defines the rendering engine
  53091. * @param scene defines the hosting scene
  53092. * @param sceneLoadedCallback callback called when scene is loaded
  53093. * @param progressCallback callback called to track progress
  53094. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  53095. * @param textureLoadingCallback callback called when a texture is loading
  53096. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  53097. * @param onReloadCallback callback called when a reload is requested
  53098. * @param errorCallback callback call if an error occurs
  53099. */
  53100. 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);
  53101. private _dragEnterHandler;
  53102. private _dragOverHandler;
  53103. private _dropHandler;
  53104. /**
  53105. * Calls this function to listen to drag'n'drop events on a specific DOM element
  53106. * @param elementToMonitor defines the DOM element to track
  53107. */
  53108. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  53109. /**
  53110. * Release all associated resources
  53111. */
  53112. dispose(): void;
  53113. private renderFunction;
  53114. private drag;
  53115. private drop;
  53116. private _traverseFolder;
  53117. private _processFiles;
  53118. /**
  53119. * Load files from a drop event
  53120. * @param event defines the drop event to use as source
  53121. */
  53122. loadFiles(event: any): void;
  53123. private _processReload;
  53124. /**
  53125. * Reload the current scene from the loaded files
  53126. */
  53127. reload(): void;
  53128. }
  53129. }
  53130. declare module BABYLON {
  53131. /**
  53132. * Defines the root class used to create scene optimization to use with SceneOptimizer
  53133. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53134. */
  53135. export class SceneOptimization {
  53136. /**
  53137. * Defines the priority of this optimization (0 by default which means first in the list)
  53138. */
  53139. priority: number;
  53140. /**
  53141. * Gets a string describing the action executed by the current optimization
  53142. * @returns description string
  53143. */
  53144. getDescription(): string;
  53145. /**
  53146. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53147. * @param scene defines the current scene where to apply this optimization
  53148. * @param optimizer defines the current optimizer
  53149. * @returns true if everything that can be done was applied
  53150. */
  53151. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53152. /**
  53153. * Creates the SceneOptimization object
  53154. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  53155. * @param desc defines the description associated with the optimization
  53156. */
  53157. constructor(
  53158. /**
  53159. * Defines the priority of this optimization (0 by default which means first in the list)
  53160. */
  53161. priority?: number);
  53162. }
  53163. /**
  53164. * Defines an optimization used to reduce the size of render target textures
  53165. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53166. */
  53167. export class TextureOptimization extends SceneOptimization {
  53168. /**
  53169. * Defines the priority of this optimization (0 by default which means first in the list)
  53170. */
  53171. priority: number;
  53172. /**
  53173. * 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
  53174. */
  53175. maximumSize: number;
  53176. /**
  53177. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  53178. */
  53179. step: number;
  53180. /**
  53181. * Gets a string describing the action executed by the current optimization
  53182. * @returns description string
  53183. */
  53184. getDescription(): string;
  53185. /**
  53186. * Creates the TextureOptimization object
  53187. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  53188. * @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
  53189. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  53190. */
  53191. constructor(
  53192. /**
  53193. * Defines the priority of this optimization (0 by default which means first in the list)
  53194. */
  53195. priority?: number,
  53196. /**
  53197. * 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
  53198. */
  53199. maximumSize?: number,
  53200. /**
  53201. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  53202. */
  53203. step?: number);
  53204. /**
  53205. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53206. * @param scene defines the current scene where to apply this optimization
  53207. * @param optimizer defines the current optimizer
  53208. * @returns true if everything that can be done was applied
  53209. */
  53210. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53211. }
  53212. /**
  53213. * Defines an optimization used to increase or decrease the rendering resolution
  53214. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53215. */
  53216. export class HardwareScalingOptimization extends SceneOptimization {
  53217. /**
  53218. * Defines the priority of this optimization (0 by default which means first in the list)
  53219. */
  53220. priority: number;
  53221. /**
  53222. * Defines the maximum scale to use (2 by default)
  53223. */
  53224. maximumScale: number;
  53225. /**
  53226. * Defines the step to use between two passes (0.5 by default)
  53227. */
  53228. step: number;
  53229. private _currentScale;
  53230. private _directionOffset;
  53231. /**
  53232. * Gets a string describing the action executed by the current optimization
  53233. * @return description string
  53234. */
  53235. getDescription(): string;
  53236. /**
  53237. * Creates the HardwareScalingOptimization object
  53238. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  53239. * @param maximumScale defines the maximum scale to use (2 by default)
  53240. * @param step defines the step to use between two passes (0.5 by default)
  53241. */
  53242. constructor(
  53243. /**
  53244. * Defines the priority of this optimization (0 by default which means first in the list)
  53245. */
  53246. priority?: number,
  53247. /**
  53248. * Defines the maximum scale to use (2 by default)
  53249. */
  53250. maximumScale?: number,
  53251. /**
  53252. * Defines the step to use between two passes (0.5 by default)
  53253. */
  53254. step?: number);
  53255. /**
  53256. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53257. * @param scene defines the current scene where to apply this optimization
  53258. * @param optimizer defines the current optimizer
  53259. * @returns true if everything that can be done was applied
  53260. */
  53261. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53262. }
  53263. /**
  53264. * Defines an optimization used to remove shadows
  53265. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53266. */
  53267. export class ShadowsOptimization extends SceneOptimization {
  53268. /**
  53269. * Gets a string describing the action executed by the current optimization
  53270. * @return description string
  53271. */
  53272. getDescription(): string;
  53273. /**
  53274. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53275. * @param scene defines the current scene where to apply this optimization
  53276. * @param optimizer defines the current optimizer
  53277. * @returns true if everything that can be done was applied
  53278. */
  53279. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53280. }
  53281. /**
  53282. * Defines an optimization used to turn post-processes off
  53283. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53284. */
  53285. export class PostProcessesOptimization extends SceneOptimization {
  53286. /**
  53287. * Gets a string describing the action executed by the current optimization
  53288. * @return description string
  53289. */
  53290. getDescription(): string;
  53291. /**
  53292. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53293. * @param scene defines the current scene where to apply this optimization
  53294. * @param optimizer defines the current optimizer
  53295. * @returns true if everything that can be done was applied
  53296. */
  53297. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53298. }
  53299. /**
  53300. * Defines an optimization used to turn lens flares off
  53301. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53302. */
  53303. export class LensFlaresOptimization extends SceneOptimization {
  53304. /**
  53305. * Gets a string describing the action executed by the current optimization
  53306. * @return description string
  53307. */
  53308. getDescription(): string;
  53309. /**
  53310. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53311. * @param scene defines the current scene where to apply this optimization
  53312. * @param optimizer defines the current optimizer
  53313. * @returns true if everything that can be done was applied
  53314. */
  53315. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53316. }
  53317. /**
  53318. * Defines an optimization based on user defined callback.
  53319. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53320. */
  53321. export class CustomOptimization extends SceneOptimization {
  53322. /**
  53323. * Callback called to apply the custom optimization.
  53324. */
  53325. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  53326. /**
  53327. * Callback called to get custom description
  53328. */
  53329. onGetDescription: () => string;
  53330. /**
  53331. * Gets a string describing the action executed by the current optimization
  53332. * @returns description string
  53333. */
  53334. getDescription(): string;
  53335. /**
  53336. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53337. * @param scene defines the current scene where to apply this optimization
  53338. * @param optimizer defines the current optimizer
  53339. * @returns true if everything that can be done was applied
  53340. */
  53341. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53342. }
  53343. /**
  53344. * Defines an optimization used to turn particles off
  53345. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53346. */
  53347. export class ParticlesOptimization extends SceneOptimization {
  53348. /**
  53349. * Gets a string describing the action executed by the current optimization
  53350. * @return description string
  53351. */
  53352. getDescription(): string;
  53353. /**
  53354. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53355. * @param scene defines the current scene where to apply this optimization
  53356. * @param optimizer defines the current optimizer
  53357. * @returns true if everything that can be done was applied
  53358. */
  53359. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53360. }
  53361. /**
  53362. * Defines an optimization used to turn render targets off
  53363. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53364. */
  53365. export class RenderTargetsOptimization extends SceneOptimization {
  53366. /**
  53367. * Gets a string describing the action executed by the current optimization
  53368. * @return description string
  53369. */
  53370. getDescription(): string;
  53371. /**
  53372. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53373. * @param scene defines the current scene where to apply this optimization
  53374. * @param optimizer defines the current optimizer
  53375. * @returns true if everything that can be done was applied
  53376. */
  53377. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53378. }
  53379. /**
  53380. * Defines an optimization used to merge meshes with compatible materials
  53381. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53382. */
  53383. export class MergeMeshesOptimization extends SceneOptimization {
  53384. private static _UpdateSelectionTree;
  53385. /**
  53386. * Gets or sets a boolean which defines if optimization octree has to be updated
  53387. */
  53388. /**
  53389. * Gets or sets a boolean which defines if optimization octree has to be updated
  53390. */
  53391. static UpdateSelectionTree: boolean;
  53392. /**
  53393. * Gets a string describing the action executed by the current optimization
  53394. * @return description string
  53395. */
  53396. getDescription(): string;
  53397. private _canBeMerged;
  53398. /**
  53399. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53400. * @param scene defines the current scene where to apply this optimization
  53401. * @param optimizer defines the current optimizer
  53402. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  53403. * @returns true if everything that can be done was applied
  53404. */
  53405. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  53406. }
  53407. /**
  53408. * Defines a list of options used by SceneOptimizer
  53409. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53410. */
  53411. export class SceneOptimizerOptions {
  53412. /**
  53413. * Defines the target frame rate to reach (60 by default)
  53414. */
  53415. targetFrameRate: number;
  53416. /**
  53417. * Defines the interval between two checkes (2000ms by default)
  53418. */
  53419. trackerDuration: number;
  53420. /**
  53421. * Gets the list of optimizations to apply
  53422. */
  53423. optimizations: SceneOptimization[];
  53424. /**
  53425. * Creates a new list of options used by SceneOptimizer
  53426. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  53427. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  53428. */
  53429. constructor(
  53430. /**
  53431. * Defines the target frame rate to reach (60 by default)
  53432. */
  53433. targetFrameRate?: number,
  53434. /**
  53435. * Defines the interval between two checkes (2000ms by default)
  53436. */
  53437. trackerDuration?: number);
  53438. /**
  53439. * Add a new optimization
  53440. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  53441. * @returns the current SceneOptimizerOptions
  53442. */
  53443. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  53444. /**
  53445. * Add a new custom optimization
  53446. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  53447. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  53448. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  53449. * @returns the current SceneOptimizerOptions
  53450. */
  53451. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  53452. /**
  53453. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  53454. * @param targetFrameRate defines the target frame rate (60 by default)
  53455. * @returns a SceneOptimizerOptions object
  53456. */
  53457. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  53458. /**
  53459. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  53460. * @param targetFrameRate defines the target frame rate (60 by default)
  53461. * @returns a SceneOptimizerOptions object
  53462. */
  53463. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  53464. /**
  53465. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  53466. * @param targetFrameRate defines the target frame rate (60 by default)
  53467. * @returns a SceneOptimizerOptions object
  53468. */
  53469. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  53470. }
  53471. /**
  53472. * Class used to run optimizations in order to reach a target frame rate
  53473. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53474. */
  53475. export class SceneOptimizer implements IDisposable {
  53476. private _isRunning;
  53477. private _options;
  53478. private _scene;
  53479. private _currentPriorityLevel;
  53480. private _targetFrameRate;
  53481. private _trackerDuration;
  53482. private _currentFrameRate;
  53483. private _sceneDisposeObserver;
  53484. private _improvementMode;
  53485. /**
  53486. * Defines an observable called when the optimizer reaches the target frame rate
  53487. */
  53488. onSuccessObservable: Observable<SceneOptimizer>;
  53489. /**
  53490. * Defines an observable called when the optimizer enables an optimization
  53491. */
  53492. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  53493. /**
  53494. * Defines an observable called when the optimizer is not able to reach the target frame rate
  53495. */
  53496. onFailureObservable: Observable<SceneOptimizer>;
  53497. /**
  53498. * Gets a boolean indicating if the optimizer is in improvement mode
  53499. */
  53500. readonly isInImprovementMode: boolean;
  53501. /**
  53502. * Gets the current priority level (0 at start)
  53503. */
  53504. readonly currentPriorityLevel: number;
  53505. /**
  53506. * Gets the current frame rate checked by the SceneOptimizer
  53507. */
  53508. readonly currentFrameRate: number;
  53509. /**
  53510. * Gets or sets the current target frame rate (60 by default)
  53511. */
  53512. /**
  53513. * Gets or sets the current target frame rate (60 by default)
  53514. */
  53515. targetFrameRate: number;
  53516. /**
  53517. * Gets or sets the current interval between two checks (every 2000ms by default)
  53518. */
  53519. /**
  53520. * Gets or sets the current interval between two checks (every 2000ms by default)
  53521. */
  53522. trackerDuration: number;
  53523. /**
  53524. * Gets the list of active optimizations
  53525. */
  53526. readonly optimizations: SceneOptimization[];
  53527. /**
  53528. * Creates a new SceneOptimizer
  53529. * @param scene defines the scene to work on
  53530. * @param options defines the options to use with the SceneOptimizer
  53531. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  53532. * @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)
  53533. */
  53534. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  53535. /**
  53536. * Stops the current optimizer
  53537. */
  53538. stop(): void;
  53539. /**
  53540. * Reset the optimizer to initial step (current priority level = 0)
  53541. */
  53542. reset(): void;
  53543. /**
  53544. * Start the optimizer. By default it will try to reach a specific framerate
  53545. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  53546. */
  53547. start(): void;
  53548. private _checkCurrentState;
  53549. /**
  53550. * Release all resources
  53551. */
  53552. dispose(): void;
  53553. /**
  53554. * Helper function to create a SceneOptimizer with one single line of code
  53555. * @param scene defines the scene to work on
  53556. * @param options defines the options to use with the SceneOptimizer
  53557. * @param onSuccess defines a callback to call on success
  53558. * @param onFailure defines a callback to call on failure
  53559. * @returns the new SceneOptimizer object
  53560. */
  53561. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  53562. }
  53563. }
  53564. declare module BABYLON {
  53565. /**
  53566. * Class used to serialize a scene into a string
  53567. */
  53568. export class SceneSerializer {
  53569. /**
  53570. * Clear cache used by a previous serialization
  53571. */
  53572. static ClearCache(): void;
  53573. /**
  53574. * Serialize a scene into a JSON compatible object
  53575. * @param scene defines the scene to serialize
  53576. * @returns a JSON compatible object
  53577. */
  53578. static Serialize(scene: Scene): any;
  53579. /**
  53580. * Serialize a mesh into a JSON compatible object
  53581. * @param toSerialize defines the mesh to serialize
  53582. * @param withParents defines if parents must be serialized as well
  53583. * @param withChildren defines if children must be serialized as well
  53584. * @returns a JSON compatible object
  53585. */
  53586. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  53587. }
  53588. }
  53589. declare module BABYLON {
  53590. /**
  53591. * This represents the different options avilable for the video capture.
  53592. */
  53593. export interface VideoRecorderOptions {
  53594. /** Defines the mime type of the video */
  53595. mimeType: string;
  53596. /** Defines the video the video should be recorded at */
  53597. fps: number;
  53598. /** Defines the chunk size for the recording data */
  53599. recordChunckSize: number;
  53600. /** The audio tracks to attach to the record */
  53601. audioTracks?: MediaStreamTrack[];
  53602. }
  53603. /**
  53604. * This can helps recording videos from BabylonJS.
  53605. * This is based on the available WebRTC functionalities of the browser.
  53606. *
  53607. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  53608. */
  53609. export class VideoRecorder {
  53610. private static readonly _defaultOptions;
  53611. /**
  53612. * Returns wehther or not the VideoRecorder is available in your browser.
  53613. * @param engine Defines the Babylon Engine to check the support for
  53614. * @returns true if supported otherwise false
  53615. */
  53616. static IsSupported(engine: Engine): boolean;
  53617. private readonly _options;
  53618. private _canvas;
  53619. private _mediaRecorder;
  53620. private _recordedChunks;
  53621. private _fileName;
  53622. private _resolve;
  53623. private _reject;
  53624. /**
  53625. * True wether a recording is already in progress.
  53626. */
  53627. readonly isRecording: boolean;
  53628. /**
  53629. * Create a new VideoCapture object which can help converting what you see in Babylon to
  53630. * a video file.
  53631. * @param engine Defines the BabylonJS Engine you wish to record
  53632. * @param options Defines options that can be used to customized the capture
  53633. */
  53634. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  53635. /**
  53636. * Stops the current recording before the default capture timeout passed in the startRecording
  53637. * functions.
  53638. */
  53639. stopRecording(): void;
  53640. /**
  53641. * Starts recording the canvas for a max duration specified in parameters.
  53642. * @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.
  53643. * @param maxDuration Defines the maximum recording time in seconds.
  53644. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  53645. * @return a promise callback at the end of the recording with the video data in Blob.
  53646. */
  53647. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  53648. /**
  53649. * Releases internal resources used during the recording.
  53650. */
  53651. dispose(): void;
  53652. private _handleDataAvailable;
  53653. private _handleError;
  53654. private _handleStop;
  53655. }
  53656. }
  53657. declare module BABYLON {
  53658. /**
  53659. * Helper class to push actions to a pool of workers.
  53660. */
  53661. export class WorkerPool implements IDisposable {
  53662. private _workerInfos;
  53663. private _pendingActions;
  53664. /**
  53665. * Constructor
  53666. * @param workers Array of workers to use for actions
  53667. */
  53668. constructor(workers: Array<Worker>);
  53669. /**
  53670. * Terminates all workers and clears any pending actions.
  53671. */
  53672. dispose(): void;
  53673. /**
  53674. * Pushes an action to the worker pool. If all the workers are active, the action will be
  53675. * pended until a worker has completed its action.
  53676. * @param action The action to perform. Call onComplete when the action is complete.
  53677. */
  53678. push(action: (worker: Worker, onComplete: () => void) => void): void;
  53679. private _execute;
  53680. }
  53681. }
  53682. declare module BABYLON {
  53683. /**
  53684. * Class containing a set of static utilities functions for screenshots
  53685. */
  53686. export class ScreenshotTools {
  53687. /**
  53688. * Captures a screenshot of the current rendering
  53689. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  53690. * @param engine defines the rendering engine
  53691. * @param camera defines the source camera
  53692. * @param size This parameter can be set to a single number or to an object with the
  53693. * following (optional) properties: precision, width, height. If a single number is passed,
  53694. * it will be used for both width and height. If an object is passed, the screenshot size
  53695. * will be derived from the parameters. The precision property is a multiplier allowing
  53696. * rendering at a higher or lower resolution
  53697. * @param successCallback defines the callback receives a single parameter which contains the
  53698. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  53699. * src parameter of an <img> to display it
  53700. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  53701. * Check your browser for supported MIME types
  53702. */
  53703. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  53704. /**
  53705. * Generates an image screenshot from the specified camera.
  53706. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  53707. * @param engine The engine to use for rendering
  53708. * @param camera The camera to use for rendering
  53709. * @param size This parameter can be set to a single number or to an object with the
  53710. * following (optional) properties: precision, width, height. If a single number is passed,
  53711. * it will be used for both width and height. If an object is passed, the screenshot size
  53712. * will be derived from the parameters. The precision property is a multiplier allowing
  53713. * rendering at a higher or lower resolution
  53714. * @param successCallback The callback receives a single parameter which contains the
  53715. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  53716. * src parameter of an <img> to display it
  53717. * @param mimeType The MIME type of the screenshot image (default: image/png).
  53718. * Check your browser for supported MIME types
  53719. * @param samples Texture samples (default: 1)
  53720. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  53721. * @param fileName A name for for the downloaded file.
  53722. */
  53723. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  53724. }
  53725. }
  53726. declare module BABYLON {
  53727. /**
  53728. * A cursor which tracks a point on a path
  53729. */
  53730. export class PathCursor {
  53731. private path;
  53732. /**
  53733. * Stores path cursor callbacks for when an onchange event is triggered
  53734. */
  53735. private _onchange;
  53736. /**
  53737. * The value of the path cursor
  53738. */
  53739. value: number;
  53740. /**
  53741. * The animation array of the path cursor
  53742. */
  53743. animations: Animation[];
  53744. /**
  53745. * Initializes the path cursor
  53746. * @param path The path to track
  53747. */
  53748. constructor(path: Path2);
  53749. /**
  53750. * Gets the cursor point on the path
  53751. * @returns A point on the path cursor at the cursor location
  53752. */
  53753. getPoint(): Vector3;
  53754. /**
  53755. * Moves the cursor ahead by the step amount
  53756. * @param step The amount to move the cursor forward
  53757. * @returns This path cursor
  53758. */
  53759. moveAhead(step?: number): PathCursor;
  53760. /**
  53761. * Moves the cursor behind by the step amount
  53762. * @param step The amount to move the cursor back
  53763. * @returns This path cursor
  53764. */
  53765. moveBack(step?: number): PathCursor;
  53766. /**
  53767. * Moves the cursor by the step amount
  53768. * If the step amount is greater than one, an exception is thrown
  53769. * @param step The amount to move the cursor
  53770. * @returns This path cursor
  53771. */
  53772. move(step: number): PathCursor;
  53773. /**
  53774. * Ensures that the value is limited between zero and one
  53775. * @returns This path cursor
  53776. */
  53777. private ensureLimits;
  53778. /**
  53779. * Runs onchange callbacks on change (used by the animation engine)
  53780. * @returns This path cursor
  53781. */
  53782. private raiseOnChange;
  53783. /**
  53784. * Executes a function on change
  53785. * @param f A path cursor onchange callback
  53786. * @returns This path cursor
  53787. */
  53788. onchange(f: (cursor: PathCursor) => void): PathCursor;
  53789. }
  53790. }
  53791. declare module BABYLON {
  53792. /** @hidden */
  53793. export var blurPixelShader: {
  53794. name: string;
  53795. shader: string;
  53796. };
  53797. }
  53798. declare module BABYLON {
  53799. /** @hidden */
  53800. export var bones300Declaration: {
  53801. name: string;
  53802. shader: string;
  53803. };
  53804. }
  53805. declare module BABYLON {
  53806. /** @hidden */
  53807. export var instances300Declaration: {
  53808. name: string;
  53809. shader: string;
  53810. };
  53811. }
  53812. declare module BABYLON {
  53813. /** @hidden */
  53814. export var pointCloudVertexDeclaration: {
  53815. name: string;
  53816. shader: string;
  53817. };
  53818. }
  53819. // Mixins
  53820. interface Window {
  53821. mozIndexedDB: IDBFactory;
  53822. webkitIndexedDB: IDBFactory;
  53823. msIndexedDB: IDBFactory;
  53824. webkitURL: typeof URL;
  53825. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  53826. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  53827. WebGLRenderingContext: WebGLRenderingContext;
  53828. MSGesture: MSGesture;
  53829. CANNON: any;
  53830. AudioContext: AudioContext;
  53831. webkitAudioContext: AudioContext;
  53832. PointerEvent: any;
  53833. Math: Math;
  53834. Uint8Array: Uint8ArrayConstructor;
  53835. Float32Array: Float32ArrayConstructor;
  53836. mozURL: typeof URL;
  53837. msURL: typeof URL;
  53838. VRFrameData: any; // WebVR, from specs 1.1
  53839. DracoDecoderModule: any;
  53840. setImmediate(handler: (...args: any[]) => void): number;
  53841. }
  53842. interface Document {
  53843. mozCancelFullScreen(): void;
  53844. msCancelFullScreen(): void;
  53845. webkitCancelFullScreen(): void;
  53846. requestPointerLock(): void;
  53847. exitPointerLock(): void;
  53848. mozFullScreen: boolean;
  53849. msIsFullScreen: boolean;
  53850. readonly webkitIsFullScreen: boolean;
  53851. readonly pointerLockElement: Element;
  53852. mozPointerLockElement: HTMLElement;
  53853. msPointerLockElement: HTMLElement;
  53854. webkitPointerLockElement: HTMLElement;
  53855. }
  53856. interface HTMLCanvasElement {
  53857. requestPointerLock(): void;
  53858. msRequestPointerLock?(): void;
  53859. mozRequestPointerLock?(): void;
  53860. webkitRequestPointerLock?(): void;
  53861. /** Track wether a record is in progress */
  53862. isRecording: boolean;
  53863. /** Capture Stream method defined by some browsers */
  53864. captureStream(fps?: number): MediaStream;
  53865. }
  53866. interface CanvasRenderingContext2D {
  53867. msImageSmoothingEnabled: boolean;
  53868. }
  53869. interface MouseEvent {
  53870. mozMovementX: number;
  53871. mozMovementY: number;
  53872. webkitMovementX: number;
  53873. webkitMovementY: number;
  53874. msMovementX: number;
  53875. msMovementY: number;
  53876. }
  53877. interface Navigator {
  53878. mozGetVRDevices: (any: any) => any;
  53879. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  53880. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  53881. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  53882. webkitGetGamepads(): Gamepad[];
  53883. msGetGamepads(): Gamepad[];
  53884. webkitGamepads(): Gamepad[];
  53885. }
  53886. interface HTMLVideoElement {
  53887. mozSrcObject: any;
  53888. }
  53889. interface Math {
  53890. fround(x: number): number;
  53891. imul(a: number, b: number): number;
  53892. }
  53893. interface WebGLProgram {
  53894. context?: WebGLRenderingContext;
  53895. vertexShader?: WebGLShader;
  53896. fragmentShader?: WebGLShader;
  53897. isParallelCompiled: boolean;
  53898. onCompiled?: () => void;
  53899. }
  53900. interface WebGLRenderingContext {
  53901. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  53902. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  53903. vertexAttribDivisor(index: number, divisor: number): void;
  53904. createVertexArray(): any;
  53905. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  53906. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  53907. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  53908. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  53909. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  53910. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  53911. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  53912. // Queries
  53913. createQuery(): WebGLQuery;
  53914. deleteQuery(query: WebGLQuery): void;
  53915. beginQuery(target: number, query: WebGLQuery): void;
  53916. endQuery(target: number): void;
  53917. getQueryParameter(query: WebGLQuery, pname: number): any;
  53918. getQuery(target: number, pname: number): any;
  53919. MAX_SAMPLES: number;
  53920. RGBA8: number;
  53921. READ_FRAMEBUFFER: number;
  53922. DRAW_FRAMEBUFFER: number;
  53923. UNIFORM_BUFFER: number;
  53924. HALF_FLOAT_OES: number;
  53925. RGBA16F: number;
  53926. RGBA32F: number;
  53927. R32F: number;
  53928. RG32F: number;
  53929. RGB32F: number;
  53930. R16F: number;
  53931. RG16F: number;
  53932. RGB16F: number;
  53933. RED: number;
  53934. RG: number;
  53935. R8: number;
  53936. RG8: number;
  53937. UNSIGNED_INT_24_8: number;
  53938. DEPTH24_STENCIL8: number;
  53939. /* Multiple Render Targets */
  53940. drawBuffers(buffers: number[]): void;
  53941. readBuffer(src: number): void;
  53942. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  53943. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  53944. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  53945. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  53946. // Occlusion Query
  53947. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  53948. ANY_SAMPLES_PASSED: number;
  53949. QUERY_RESULT_AVAILABLE: number;
  53950. QUERY_RESULT: number;
  53951. }
  53952. interface WebGLBuffer {
  53953. references: number;
  53954. capacity: number;
  53955. is32Bits: boolean;
  53956. }
  53957. interface WebGLProgram {
  53958. transformFeedback?: WebGLTransformFeedback | null;
  53959. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  53960. }
  53961. interface EXT_disjoint_timer_query {
  53962. QUERY_COUNTER_BITS_EXT: number;
  53963. TIME_ELAPSED_EXT: number;
  53964. TIMESTAMP_EXT: number;
  53965. GPU_DISJOINT_EXT: number;
  53966. QUERY_RESULT_EXT: number;
  53967. QUERY_RESULT_AVAILABLE_EXT: number;
  53968. queryCounterEXT(query: WebGLQuery, target: number): void;
  53969. createQueryEXT(): WebGLQuery;
  53970. beginQueryEXT(target: number, query: WebGLQuery): void;
  53971. endQueryEXT(target: number): void;
  53972. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  53973. deleteQueryEXT(query: WebGLQuery): void;
  53974. }
  53975. interface WebGLUniformLocation {
  53976. _currentState: any;
  53977. }
  53978. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  53979. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  53980. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  53981. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  53982. interface WebGLRenderingContext {
  53983. readonly RASTERIZER_DISCARD: number;
  53984. readonly DEPTH_COMPONENT24: number;
  53985. readonly TEXTURE_3D: number;
  53986. readonly TEXTURE_2D_ARRAY: number;
  53987. readonly TEXTURE_COMPARE_FUNC: number;
  53988. readonly TEXTURE_COMPARE_MODE: number;
  53989. readonly COMPARE_REF_TO_TEXTURE: number;
  53990. readonly TEXTURE_WRAP_R: number;
  53991. readonly HALF_FLOAT: number;
  53992. readonly RGB8: number;
  53993. readonly RED_INTEGER: number;
  53994. readonly RG_INTEGER: number;
  53995. readonly RGB_INTEGER: number;
  53996. readonly RGBA_INTEGER: number;
  53997. readonly R8_SNORM: number;
  53998. readonly RG8_SNORM: number;
  53999. readonly RGB8_SNORM: number;
  54000. readonly RGBA8_SNORM: number;
  54001. readonly R8I: number;
  54002. readonly RG8I: number;
  54003. readonly RGB8I: number;
  54004. readonly RGBA8I: number;
  54005. readonly R8UI: number;
  54006. readonly RG8UI: number;
  54007. readonly RGB8UI: number;
  54008. readonly RGBA8UI: number;
  54009. readonly R16I: number;
  54010. readonly RG16I: number;
  54011. readonly RGB16I: number;
  54012. readonly RGBA16I: number;
  54013. readonly R16UI: number;
  54014. readonly RG16UI: number;
  54015. readonly RGB16UI: number;
  54016. readonly RGBA16UI: number;
  54017. readonly R32I: number;
  54018. readonly RG32I: number;
  54019. readonly RGB32I: number;
  54020. readonly RGBA32I: number;
  54021. readonly R32UI: number;
  54022. readonly RG32UI: number;
  54023. readonly RGB32UI: number;
  54024. readonly RGBA32UI: number;
  54025. readonly RGB10_A2UI: number;
  54026. readonly R11F_G11F_B10F: number;
  54027. readonly RGB9_E5: number;
  54028. readonly RGB10_A2: number;
  54029. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  54030. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  54031. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  54032. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  54033. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  54034. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  54035. 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;
  54036. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  54037. readonly TRANSFORM_FEEDBACK: number;
  54038. readonly INTERLEAVED_ATTRIBS: number;
  54039. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  54040. createTransformFeedback(): WebGLTransformFeedback;
  54041. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  54042. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  54043. beginTransformFeedback(primitiveMode: number): void;
  54044. endTransformFeedback(): void;
  54045. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  54046. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  54047. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  54048. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  54049. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  54050. }
  54051. interface ImageBitmap {
  54052. readonly width: number;
  54053. readonly height: number;
  54054. close(): void;
  54055. }
  54056. interface WebGLQuery extends WebGLObject {
  54057. }
  54058. declare var WebGLQuery: {
  54059. prototype: WebGLQuery;
  54060. new(): WebGLQuery;
  54061. };
  54062. interface WebGLSampler extends WebGLObject {
  54063. }
  54064. declare var WebGLSampler: {
  54065. prototype: WebGLSampler;
  54066. new(): WebGLSampler;
  54067. };
  54068. interface WebGLSync extends WebGLObject {
  54069. }
  54070. declare var WebGLSync: {
  54071. prototype: WebGLSync;
  54072. new(): WebGLSync;
  54073. };
  54074. interface WebGLTransformFeedback extends WebGLObject {
  54075. }
  54076. declare var WebGLTransformFeedback: {
  54077. prototype: WebGLTransformFeedback;
  54078. new(): WebGLTransformFeedback;
  54079. };
  54080. interface WebGLVertexArrayObject extends WebGLObject {
  54081. }
  54082. declare var WebGLVertexArrayObject: {
  54083. prototype: WebGLVertexArrayObject;
  54084. new(): WebGLVertexArrayObject;
  54085. };
  54086. // Type definitions for WebVR API
  54087. // Project: https://w3c.github.io/webvr/
  54088. // Definitions by: six a <https://github.com/lostfictions>
  54089. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  54090. interface VRDisplay extends EventTarget {
  54091. /**
  54092. * Dictionary of capabilities describing the VRDisplay.
  54093. */
  54094. readonly capabilities: VRDisplayCapabilities;
  54095. /**
  54096. * z-depth defining the far plane of the eye view frustum
  54097. * enables mapping of values in the render target depth
  54098. * attachment to scene coordinates. Initially set to 10000.0.
  54099. */
  54100. depthFar: number;
  54101. /**
  54102. * z-depth defining the near plane of the eye view frustum
  54103. * enables mapping of values in the render target depth
  54104. * attachment to scene coordinates. Initially set to 0.01.
  54105. */
  54106. depthNear: number;
  54107. /**
  54108. * An identifier for this distinct VRDisplay. Used as an
  54109. * association point in the Gamepad API.
  54110. */
  54111. readonly displayId: number;
  54112. /**
  54113. * A display name, a user-readable name identifying it.
  54114. */
  54115. readonly displayName: string;
  54116. readonly isConnected: boolean;
  54117. readonly isPresenting: boolean;
  54118. /**
  54119. * If this VRDisplay supports room-scale experiences, the optional
  54120. * stage attribute contains details on the room-scale parameters.
  54121. */
  54122. readonly stageParameters: VRStageParameters | null;
  54123. /**
  54124. * Passing the value returned by `requestAnimationFrame` to
  54125. * `cancelAnimationFrame` will unregister the callback.
  54126. * @param handle Define the hanle of the request to cancel
  54127. */
  54128. cancelAnimationFrame(handle: number): void;
  54129. /**
  54130. * Stops presenting to the VRDisplay.
  54131. * @returns a promise to know when it stopped
  54132. */
  54133. exitPresent(): Promise<void>;
  54134. /**
  54135. * Return the current VREyeParameters for the given eye.
  54136. * @param whichEye Define the eye we want the parameter for
  54137. * @returns the eye parameters
  54138. */
  54139. getEyeParameters(whichEye: string): VREyeParameters;
  54140. /**
  54141. * Populates the passed VRFrameData with the information required to render
  54142. * the current frame.
  54143. * @param frameData Define the data structure to populate
  54144. * @returns true if ok otherwise false
  54145. */
  54146. getFrameData(frameData: VRFrameData): boolean;
  54147. /**
  54148. * Get the layers currently being presented.
  54149. * @returns the list of VR layers
  54150. */
  54151. getLayers(): VRLayer[];
  54152. /**
  54153. * Return a VRPose containing the future predicted pose of the VRDisplay
  54154. * when the current frame will be presented. The value returned will not
  54155. * change until JavaScript has returned control to the browser.
  54156. *
  54157. * The VRPose will contain the position, orientation, velocity,
  54158. * and acceleration of each of these properties.
  54159. * @returns the pose object
  54160. */
  54161. getPose(): VRPose;
  54162. /**
  54163. * Return the current instantaneous pose of the VRDisplay, with no
  54164. * prediction applied.
  54165. * @returns the current instantaneous pose
  54166. */
  54167. getImmediatePose(): VRPose;
  54168. /**
  54169. * The callback passed to `requestAnimationFrame` will be called
  54170. * any time a new frame should be rendered. When the VRDisplay is
  54171. * presenting the callback will be called at the native refresh
  54172. * rate of the HMD. When not presenting this function acts
  54173. * identically to how window.requestAnimationFrame acts. Content should
  54174. * make no assumptions of frame rate or vsync behavior as the HMD runs
  54175. * asynchronously from other displays and at differing refresh rates.
  54176. * @param callback Define the eaction to run next frame
  54177. * @returns the request handle it
  54178. */
  54179. requestAnimationFrame(callback: FrameRequestCallback): number;
  54180. /**
  54181. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  54182. * Repeat calls while already presenting will update the VRLayers being displayed.
  54183. * @param layers Define the list of layer to present
  54184. * @returns a promise to know when the request has been fulfilled
  54185. */
  54186. requestPresent(layers: VRLayer[]): Promise<void>;
  54187. /**
  54188. * Reset the pose for this display, treating its current position and
  54189. * orientation as the "origin/zero" values. VRPose.position,
  54190. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  54191. * updated when calling resetPose(). This should be called in only
  54192. * sitting-space experiences.
  54193. */
  54194. resetPose(): void;
  54195. /**
  54196. * The VRLayer provided to the VRDisplay will be captured and presented
  54197. * in the HMD. Calling this function has the same effect on the source
  54198. * canvas as any other operation that uses its source image, and canvases
  54199. * created without preserveDrawingBuffer set to true will be cleared.
  54200. * @param pose Define the pose to submit
  54201. */
  54202. submitFrame(pose?: VRPose): void;
  54203. }
  54204. declare var VRDisplay: {
  54205. prototype: VRDisplay;
  54206. new(): VRDisplay;
  54207. };
  54208. interface VRLayer {
  54209. leftBounds?: number[] | Float32Array | null;
  54210. rightBounds?: number[] | Float32Array | null;
  54211. source?: HTMLCanvasElement | null;
  54212. }
  54213. interface VRDisplayCapabilities {
  54214. readonly canPresent: boolean;
  54215. readonly hasExternalDisplay: boolean;
  54216. readonly hasOrientation: boolean;
  54217. readonly hasPosition: boolean;
  54218. readonly maxLayers: number;
  54219. }
  54220. interface VREyeParameters {
  54221. /** @deprecated */
  54222. readonly fieldOfView: VRFieldOfView;
  54223. readonly offset: Float32Array;
  54224. readonly renderHeight: number;
  54225. readonly renderWidth: number;
  54226. }
  54227. interface VRFieldOfView {
  54228. readonly downDegrees: number;
  54229. readonly leftDegrees: number;
  54230. readonly rightDegrees: number;
  54231. readonly upDegrees: number;
  54232. }
  54233. interface VRFrameData {
  54234. readonly leftProjectionMatrix: Float32Array;
  54235. readonly leftViewMatrix: Float32Array;
  54236. readonly pose: VRPose;
  54237. readonly rightProjectionMatrix: Float32Array;
  54238. readonly rightViewMatrix: Float32Array;
  54239. readonly timestamp: number;
  54240. }
  54241. interface VRPose {
  54242. readonly angularAcceleration: Float32Array | null;
  54243. readonly angularVelocity: Float32Array | null;
  54244. readonly linearAcceleration: Float32Array | null;
  54245. readonly linearVelocity: Float32Array | null;
  54246. readonly orientation: Float32Array | null;
  54247. readonly position: Float32Array | null;
  54248. readonly timestamp: number;
  54249. }
  54250. interface VRStageParameters {
  54251. sittingToStandingTransform?: Float32Array;
  54252. sizeX?: number;
  54253. sizeY?: number;
  54254. }
  54255. interface Navigator {
  54256. getVRDisplays(): Promise<VRDisplay[]>;
  54257. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  54258. }
  54259. interface Window {
  54260. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  54261. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  54262. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  54263. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  54264. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  54265. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  54266. }
  54267. interface Gamepad {
  54268. readonly displayId: number;
  54269. }
  54270. interface XRDevice {
  54271. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  54272. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  54273. }
  54274. interface XRSession {
  54275. getInputSources(): Array<any>;
  54276. baseLayer: XRWebGLLayer;
  54277. requestFrameOfReference(type: string): Promise<void>;
  54278. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  54279. end(): Promise<void>;
  54280. requestAnimationFrame: Function;
  54281. addEventListener: Function;
  54282. }
  54283. interface XRSessionCreationOptions {
  54284. outputContext?: WebGLRenderingContext | null;
  54285. immersive?: boolean;
  54286. environmentIntegration?: boolean;
  54287. }
  54288. interface XRLayer {
  54289. getViewport: Function;
  54290. framebufferWidth: number;
  54291. framebufferHeight: number;
  54292. }
  54293. interface XRView {
  54294. projectionMatrix: Float32Array;
  54295. }
  54296. interface XRFrame {
  54297. getDevicePose: Function;
  54298. getInputPose: Function;
  54299. views: Array<XRView>;
  54300. baseLayer: XRLayer;
  54301. }
  54302. interface XRFrameOfReference {
  54303. }
  54304. interface XRWebGLLayer extends XRLayer {
  54305. framebuffer: WebGLFramebuffer;
  54306. }
  54307. declare var XRWebGLLayer: {
  54308. prototype: XRWebGLLayer;
  54309. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  54310. };