babylon.d.ts 2.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /**
  62. * Gets the list of root nodes (ie. nodes with no parent)
  63. */
  64. rootNodes: Node[];
  65. /** All of the cameras added to this scene
  66. * @see http://doc.babylonjs.com/babylon101/cameras
  67. */
  68. cameras: Camera[];
  69. /**
  70. * All of the lights added to this scene
  71. * @see http://doc.babylonjs.com/babylon101/lights
  72. */
  73. lights: Light[];
  74. /**
  75. * All of the (abstract) meshes added to this scene
  76. */
  77. meshes: AbstractMesh[];
  78. /**
  79. * The list of skeletons added to the scene
  80. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81. */
  82. skeletons: Skeleton[];
  83. /**
  84. * All of the particle systems added to this scene
  85. * @see http://doc.babylonjs.com/babylon101/particles
  86. */
  87. particleSystems: IParticleSystem[];
  88. /**
  89. * Gets a list of Animations associated with the scene
  90. */
  91. animations: Animation[];
  92. /**
  93. * All of the animation groups added to this scene
  94. * @see http://doc.babylonjs.com/how_to/group
  95. */
  96. animationGroups: AnimationGroup[];
  97. /**
  98. * All of the multi-materials added to this scene
  99. * @see http://doc.babylonjs.com/how_to/multi_materials
  100. */
  101. multiMaterials: MultiMaterial[];
  102. /**
  103. * All of the materials added to this scene
  104. * In the context of a Scene, it is not supposed to be modified manually.
  105. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  106. * Note also that the order of the Material wihin the array is not significant and might change.
  107. * @see http://doc.babylonjs.com/babylon101/materials
  108. */
  109. materials: Material[];
  110. /**
  111. * The list of morph target managers added to the scene
  112. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113. */
  114. morphTargetManagers: MorphTargetManager[];
  115. /**
  116. * The list of geometries used in the scene.
  117. */
  118. geometries: Geometry[];
  119. /**
  120. * All of the tranform nodes added to this scene
  121. * In the context of a Scene, it is not supposed to be modified manually.
  122. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  123. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  124. * @see http://doc.babylonjs.com/how_to/transformnode
  125. */
  126. transformNodes: TransformNode[];
  127. /**
  128. * ActionManagers available on the scene.
  129. */
  130. actionManagers: ActionManager[];
  131. /**
  132. * Textures to keep.
  133. */
  134. textures: BaseTexture[];
  135. }
  136. }
  137. declare module BABYLON {
  138. /**
  139. * Set of assets to keep when moving a scene into an asset container.
  140. */
  141. class KeepAssets extends AbstractScene {
  142. }
  143. /**
  144. * Container with a set of assets that can be added or removed from a scene.
  145. */
  146. class AssetContainer extends AbstractScene {
  147. /**
  148. * The scene the AssetContainer belongs to.
  149. */
  150. scene: Scene;
  151. /**
  152. * Instantiates an AssetContainer.
  153. * @param scene The scene the AssetContainer belongs to.
  154. */
  155. constructor(scene: Scene);
  156. /**
  157. * Adds all the assets from the container to the scene.
  158. */
  159. addAllToScene(): void;
  160. /**
  161. * Removes all the assets in the container from the scene
  162. */
  163. removeAllFromScene(): void;
  164. private _moveAssets;
  165. /**
  166. * Removes all the assets contained in the scene and adds them to the container.
  167. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  168. */
  169. moveAllFromScene(keepAssets?: KeepAssets): void;
  170. /**
  171. * 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.
  172. * @returns the root mesh
  173. */
  174. createRootMesh(): Mesh;
  175. }
  176. }
  177. interface Window {
  178. mozIndexedDB: IDBFactory;
  179. webkitIndexedDB: IDBFactory;
  180. msIndexedDB: IDBFactory;
  181. webkitURL: typeof URL;
  182. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  183. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  184. WebGLRenderingContext: WebGLRenderingContext;
  185. MSGesture: MSGesture;
  186. CANNON: any;
  187. AudioContext: AudioContext;
  188. webkitAudioContext: AudioContext;
  189. PointerEvent: any;
  190. Math: Math;
  191. Uint8Array: Uint8ArrayConstructor;
  192. Float32Array: Float32ArrayConstructor;
  193. mozURL: typeof URL;
  194. msURL: typeof URL;
  195. VRFrameData: any;
  196. DracoDecoderModule: any;
  197. setImmediate(handler: (...args: any[]) => void): number;
  198. }
  199. interface WebGLProgram {
  200. context?: WebGLRenderingContext;
  201. vertexShader?: WebGLShader;
  202. fragmentShader?: WebGLShader;
  203. isParallelCompiled: boolean;
  204. onCompiled?: () => void;
  205. }
  206. interface WebGLRenderingContext {
  207. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  208. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  209. vertexAttribDivisor(index: number, divisor: number): void;
  210. createVertexArray(): any;
  211. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  212. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  213. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  214. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  215. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  216. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  217. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  218. createQuery(): WebGLQuery;
  219. deleteQuery(query: WebGLQuery): void;
  220. beginQuery(target: number, query: WebGLQuery): void;
  221. endQuery(target: number): void;
  222. getQueryParameter(query: WebGLQuery, pname: number): any;
  223. getQuery(target: number, pname: number): any;
  224. MAX_SAMPLES: number;
  225. RGBA8: number;
  226. READ_FRAMEBUFFER: number;
  227. DRAW_FRAMEBUFFER: number;
  228. UNIFORM_BUFFER: number;
  229. HALF_FLOAT_OES: number;
  230. RGBA16F: number;
  231. RGBA32F: number;
  232. R32F: number;
  233. RG32F: number;
  234. RGB32F: number;
  235. R16F: number;
  236. RG16F: number;
  237. RGB16F: number;
  238. RED: number;
  239. RG: number;
  240. R8: number;
  241. RG8: number;
  242. UNSIGNED_INT_24_8: number;
  243. DEPTH24_STENCIL8: number;
  244. drawBuffers(buffers: number[]): void;
  245. readBuffer(src: number): void;
  246. readonly COLOR_ATTACHMENT0: number;
  247. readonly COLOR_ATTACHMENT1: number;
  248. readonly COLOR_ATTACHMENT2: number;
  249. readonly COLOR_ATTACHMENT3: number;
  250. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  251. ANY_SAMPLES_PASSED: number;
  252. QUERY_RESULT_AVAILABLE: number;
  253. QUERY_RESULT: number;
  254. }
  255. interface Document {
  256. mozCancelFullScreen(): void;
  257. msCancelFullScreen(): void;
  258. webkitCancelFullScreen(): void;
  259. requestPointerLock(): void;
  260. exitPointerLock(): void;
  261. mozFullScreen: boolean;
  262. msIsFullScreen: boolean;
  263. readonly webkitIsFullScreen: boolean;
  264. readonly pointerLockElement: Element;
  265. mozPointerLockElement: HTMLElement;
  266. msPointerLockElement: HTMLElement;
  267. webkitPointerLockElement: HTMLElement;
  268. }
  269. interface HTMLCanvasElement {
  270. requestPointerLock(): void;
  271. msRequestPointerLock?(): void;
  272. mozRequestPointerLock?(): void;
  273. webkitRequestPointerLock?(): void;
  274. }
  275. interface CanvasRenderingContext2D {
  276. msImageSmoothingEnabled: boolean;
  277. }
  278. interface WebGLBuffer {
  279. references: number;
  280. capacity: number;
  281. is32Bits: boolean;
  282. }
  283. interface WebGLProgram {
  284. transformFeedback?: WebGLTransformFeedback | null;
  285. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  286. }
  287. interface MouseEvent {
  288. mozMovementX: number;
  289. mozMovementY: number;
  290. webkitMovementX: number;
  291. webkitMovementY: number;
  292. msMovementX: number;
  293. msMovementY: number;
  294. }
  295. interface Navigator {
  296. mozGetVRDevices: (any: any) => any;
  297. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  298. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  299. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  300. webkitGetGamepads(): Gamepad[];
  301. msGetGamepads(): Gamepad[];
  302. webkitGamepads(): Gamepad[];
  303. }
  304. interface HTMLVideoElement {
  305. mozSrcObject: any;
  306. }
  307. interface Math {
  308. fround(x: number): number;
  309. imul(a: number, b: number): number;
  310. }
  311. interface EXT_disjoint_timer_query {
  312. QUERY_COUNTER_BITS_EXT: number;
  313. TIME_ELAPSED_EXT: number;
  314. TIMESTAMP_EXT: number;
  315. GPU_DISJOINT_EXT: number;
  316. QUERY_RESULT_EXT: number;
  317. QUERY_RESULT_AVAILABLE_EXT: number;
  318. queryCounterEXT(query: WebGLQuery, target: number): void;
  319. createQueryEXT(): WebGLQuery;
  320. beginQueryEXT(target: number, query: WebGLQuery): void;
  321. endQueryEXT(target: number): void;
  322. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  323. deleteQueryEXT(query: WebGLQuery): void;
  324. }
  325. interface WebGLUniformLocation {
  326. _currentState: any;
  327. }
  328. interface XRDevice {
  329. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  330. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  331. }
  332. interface XRSession {
  333. getInputSources(): Array<any>;
  334. baseLayer: XRWebGLLayer;
  335. requestFrameOfReference(type: string): Promise<void>;
  336. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  337. end(): Promise<void>;
  338. requestAnimationFrame: Function;
  339. addEventListener: Function;
  340. }
  341. interface XRSessionCreationOptions {
  342. outputContext?: WebGLRenderingContext | null;
  343. immersive?: boolean;
  344. environmentIntegration?: boolean;
  345. }
  346. interface XRLayer {
  347. getViewport: Function;
  348. framebufferWidth: number;
  349. framebufferHeight: number;
  350. }
  351. interface XRView {
  352. projectionMatrix: Float32Array;
  353. }
  354. interface XRFrame {
  355. getDevicePose: Function;
  356. getInputPose: Function;
  357. views: Array<XRView>;
  358. baseLayer: XRLayer;
  359. }
  360. interface XRFrameOfReference {
  361. }
  362. interface XRWebGLLayer extends XRLayer {
  363. framebuffer: WebGLFramebuffer;
  364. }
  365. declare var XRWebGLLayer: {
  366. prototype: XRWebGLLayer;
  367. new (session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  368. };
  369. declare module BABYLON {
  370. /**
  371. * Defines how a node can be built from a string name.
  372. */
  373. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  374. /**
  375. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  376. */
  377. class Node implements IBehaviorAware<Node> {
  378. private static _NodeConstructors;
  379. /**
  380. * Add a new node constructor
  381. * @param type defines the type name of the node to construct
  382. * @param constructorFunc defines the constructor function
  383. */
  384. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  385. /**
  386. * Returns a node constructor based on type name
  387. * @param type defines the type name
  388. * @param name defines the new node name
  389. * @param scene defines the hosting scene
  390. * @param options defines optional options to transmit to constructors
  391. * @returns the new constructor or null
  392. */
  393. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  394. /**
  395. * Gets or sets the name of the node
  396. */
  397. name: string;
  398. /**
  399. * Gets or sets the id of the node
  400. */
  401. id: string;
  402. /**
  403. * Gets or sets the unique id of the node
  404. */
  405. uniqueId: number;
  406. /**
  407. * Gets or sets a string used to store user defined state for the node
  408. */
  409. state: string;
  410. /**
  411. * Gets or sets an object used to store user defined information for the node
  412. */
  413. metadata: any;
  414. /**
  415. * Gets or sets a boolean used to define if the node must be serialized
  416. */
  417. doNotSerialize: boolean;
  418. /** @hidden */
  419. _isDisposed: boolean;
  420. /**
  421. * Gets a list of Animations associated with the node
  422. */
  423. animations: Animation[];
  424. protected _ranges: {
  425. [name: string]: Nullable<AnimationRange>;
  426. };
  427. /**
  428. * Callback raised when the node is ready to be used
  429. */
  430. onReady: (node: Node) => void;
  431. private _isEnabled;
  432. private _isParentEnabled;
  433. private _isReady;
  434. /** @hidden */
  435. _currentRenderId: number;
  436. private _parentRenderId;
  437. protected _childRenderId: number;
  438. /** @hidden */
  439. _waitingParentId: Nullable<string>;
  440. /** @hidden */
  441. _scene: Scene;
  442. /** @hidden */
  443. _cache: any;
  444. private _parentNode;
  445. private _children;
  446. /** @hidden */
  447. _worldMatrix: Matrix;
  448. /** @hidden */
  449. _worldMatrixDeterminant: number;
  450. /** @hidden */
  451. private _sceneRootNodesIndex;
  452. /**
  453. * Gets a boolean indicating if the node has been disposed
  454. * @returns true if the node was disposed
  455. */
  456. isDisposed(): boolean;
  457. /**
  458. * Gets or sets the parent of the node
  459. */
  460. parent: Nullable<Node>;
  461. private addToSceneRootNodes;
  462. private removeFromSceneRootNodes;
  463. private _animationPropertiesOverride;
  464. /**
  465. * Gets or sets the animation properties override
  466. */
  467. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  468. /**
  469. * Gets a string idenfifying the name of the class
  470. * @returns "Node" string
  471. */
  472. getClassName(): string;
  473. /**
  474. * An event triggered when the mesh is disposed
  475. */
  476. onDisposeObservable: Observable<Node>;
  477. private _onDisposeObserver;
  478. /**
  479. * Sets a callback that will be raised when the node will be disposed
  480. */
  481. onDispose: () => void;
  482. /**
  483. * Creates a new Node
  484. * @param name the name and id to be given to this node
  485. * @param scene the scene this node will be added to
  486. */
  487. constructor(name: string, scene?: Nullable<Scene>);
  488. /**
  489. * Gets the scene of the node
  490. * @returns a scene
  491. */
  492. getScene(): Scene;
  493. /**
  494. * Gets the engine of the node
  495. * @returns a Engine
  496. */
  497. getEngine(): Engine;
  498. private _behaviors;
  499. /**
  500. * Attach a behavior to the node
  501. * @see http://doc.babylonjs.com/features/behaviour
  502. * @param behavior defines the behavior to attach
  503. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  504. * @returns the current Node
  505. */
  506. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  507. /**
  508. * Remove an attached behavior
  509. * @see http://doc.babylonjs.com/features/behaviour
  510. * @param behavior defines the behavior to attach
  511. * @returns the current Node
  512. */
  513. removeBehavior(behavior: Behavior<Node>): Node;
  514. /**
  515. * Gets the list of attached behaviors
  516. * @see http://doc.babylonjs.com/features/behaviour
  517. */
  518. readonly behaviors: Behavior<Node>[];
  519. /**
  520. * Gets an attached behavior by name
  521. * @param name defines the name of the behavior to look for
  522. * @see http://doc.babylonjs.com/features/behaviour
  523. * @returns null if behavior was not found else the requested behavior
  524. */
  525. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  526. /**
  527. * Returns the latest update of the World matrix
  528. * @returns a Matrix
  529. */
  530. getWorldMatrix(): Matrix;
  531. /** @hidden */
  532. _getWorldMatrixDeterminant(): number;
  533. /**
  534. * Returns directly the latest state of the mesh World matrix.
  535. * A Matrix is returned.
  536. */
  537. readonly worldMatrixFromCache: Matrix;
  538. /** @hidden */
  539. _initCache(): void;
  540. /** @hidden */
  541. updateCache(force?: boolean): void;
  542. /** @hidden */
  543. _updateCache(ignoreParentClass?: boolean): void;
  544. /** @hidden */
  545. _isSynchronized(): boolean;
  546. /** @hidden */
  547. _markSyncedWithParent(): void;
  548. /** @hidden */
  549. isSynchronizedWithParent(): boolean;
  550. /** @hidden */
  551. isSynchronized(): boolean;
  552. /**
  553. * Is this node ready to be used/rendered
  554. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  555. * @return true if the node is ready
  556. */
  557. isReady(completeCheck?: boolean): boolean;
  558. /**
  559. * Is this node enabled?
  560. * 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
  561. * @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
  562. * @return whether this node (and its parent) is enabled
  563. */
  564. isEnabled(checkAncestors?: boolean): boolean;
  565. /** @hidden */
  566. protected _syncParentEnabledState(): void;
  567. /**
  568. * Set the enabled state of this node
  569. * @param value defines the new enabled state
  570. */
  571. setEnabled(value: boolean): void;
  572. /**
  573. * Is this node a descendant of the given node?
  574. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  575. * @param ancestor defines the parent node to inspect
  576. * @returns a boolean indicating if this node is a descendant of the given node
  577. */
  578. isDescendantOf(ancestor: Node): boolean;
  579. /** @hidden */
  580. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  581. /**
  582. * Will return all nodes that have this node as ascendant
  583. * @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
  584. * @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
  585. * @return all children nodes of all types
  586. */
  587. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  588. /**
  589. * Get all child-meshes of this node
  590. * @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
  591. * @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
  592. * @returns an array of AbstractMesh
  593. */
  594. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  595. /**
  596. * Get all child-transformNodes of this node
  597. * @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
  598. * @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
  599. * @returns an array of TransformNode
  600. */
  601. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  602. /**
  603. * Get all direct children of this node
  604. * @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
  605. * @returns an array of Node
  606. */
  607. getChildren(predicate?: (node: Node) => boolean): Node[];
  608. /** @hidden */
  609. _setReady(state: boolean): void;
  610. /**
  611. * Get an animation by name
  612. * @param name defines the name of the animation to look for
  613. * @returns null if not found else the requested animation
  614. */
  615. getAnimationByName(name: string): Nullable<Animation>;
  616. /**
  617. * Creates an animation range for this node
  618. * @param name defines the name of the range
  619. * @param from defines the starting key
  620. * @param to defines the end key
  621. */
  622. createAnimationRange(name: string, from: number, to: number): void;
  623. /**
  624. * Delete a specific animation range
  625. * @param name defines the name of the range to delete
  626. * @param deleteFrames defines if animation frames from the range must be deleted as well
  627. */
  628. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  629. /**
  630. * Get an animation range by name
  631. * @param name defines the name of the animation range to look for
  632. * @returns null if not found else the requested animation range
  633. */
  634. getAnimationRange(name: string): Nullable<AnimationRange>;
  635. /**
  636. * Will start the animation sequence
  637. * @param name defines the range frames for animation sequence
  638. * @param loop defines if the animation should loop (false by default)
  639. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  640. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  641. * @returns the object created for this animation. If range does not exist, it will return null
  642. */
  643. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  644. /**
  645. * Serialize animation ranges into a JSON compatible object
  646. * @returns serialization object
  647. */
  648. serializeAnimationRanges(): any;
  649. /**
  650. * Computes the world matrix of the node
  651. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  652. * @returns the world matrix
  653. */
  654. computeWorldMatrix(force?: boolean): Matrix;
  655. /**
  656. * Releases resources associated with this node.
  657. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  658. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  659. */
  660. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  661. /**
  662. * Parse animation range data from a serialization object and store them into a given node
  663. * @param node defines where to store the animation ranges
  664. * @param parsedNode defines the serialization object to read data from
  665. * @param scene defines the hosting scene
  666. */
  667. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  668. }
  669. }
  670. declare module BABYLON {
  671. /**
  672. * Define an interface for all classes that will hold resources
  673. */
  674. interface IDisposable {
  675. /**
  676. * Releases all held resources
  677. */
  678. dispose(): void;
  679. }
  680. /**
  681. * This class is used by the onRenderingGroupObservable
  682. */
  683. class RenderingGroupInfo {
  684. /**
  685. * The Scene that being rendered
  686. */
  687. scene: Scene;
  688. /**
  689. * The camera currently used for the rendering pass
  690. */
  691. camera: Nullable<Camera>;
  692. /**
  693. * The ID of the renderingGroup being processed
  694. */
  695. renderingGroupId: number;
  696. }
  697. /** Interface defining initialization parameters for Scene class */
  698. interface SceneOptions {
  699. /**
  700. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  701. * It will improve performance when the number of geometries becomes important.
  702. */
  703. useGeometryIdsMap?: boolean;
  704. /**
  705. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  706. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  707. */
  708. useMaterialMeshMap?: boolean;
  709. /**
  710. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  711. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  712. */
  713. useClonedMeshhMap?: boolean;
  714. }
  715. /**
  716. * Represents a scene to be rendered by the engine.
  717. * @see http://doc.babylonjs.com/features/scene
  718. */
  719. class Scene extends AbstractScene implements IAnimatable {
  720. private static _uniqueIdCounter;
  721. /** The fog is deactivated */
  722. static readonly FOGMODE_NONE: number;
  723. /** The fog density is following an exponential function */
  724. static readonly FOGMODE_EXP: number;
  725. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  726. static readonly FOGMODE_EXP2: number;
  727. /** The fog density is following a linear function. */
  728. static readonly FOGMODE_LINEAR: number;
  729. /**
  730. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  731. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  732. */
  733. static MinDeltaTime: number;
  734. /**
  735. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  736. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  737. */
  738. static MaxDeltaTime: number;
  739. /**
  740. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  741. */
  742. autoClear: boolean;
  743. /**
  744. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  745. */
  746. autoClearDepthAndStencil: boolean;
  747. /**
  748. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  749. */
  750. clearColor: Color4;
  751. /**
  752. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  753. */
  754. ambientColor: Color3;
  755. /** @hidden */
  756. _environmentBRDFTexture: BaseTexture;
  757. /** @hidden */
  758. protected _environmentTexture: BaseTexture;
  759. /**
  760. * Texture used in all pbr material as the reflection texture.
  761. * As in the majority of the scene they are the same (exception for multi room and so on),
  762. * this is easier to reference from here than from all the materials.
  763. */
  764. /**
  765. * Texture used in all pbr material as the reflection texture.
  766. * As in the majority of the scene they are the same (exception for multi room and so on),
  767. * this is easier to set here than in all the materials.
  768. */
  769. environmentTexture: BaseTexture;
  770. /** @hidden */
  771. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  772. /**
  773. * Default image processing configuration used either in the rendering
  774. * Forward main pass or through the imageProcessingPostProcess if present.
  775. * As in the majority of the scene they are the same (exception for multi camera),
  776. * this is easier to reference from here than from all the materials and post process.
  777. *
  778. * No setter as we it is a shared configuration, you can set the values instead.
  779. */
  780. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  781. private _forceWireframe;
  782. /**
  783. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  784. */
  785. forceWireframe: boolean;
  786. private _forcePointsCloud;
  787. /**
  788. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  789. */
  790. forcePointsCloud: boolean;
  791. /**
  792. * Gets or sets the active clipplane 1
  793. */
  794. clipPlane: Nullable<Plane>;
  795. /**
  796. * Gets or sets the active clipplane 2
  797. */
  798. clipPlane2: Nullable<Plane>;
  799. /**
  800. * Gets or sets the active clipplane 3
  801. */
  802. clipPlane3: Nullable<Plane>;
  803. /**
  804. * Gets or sets the active clipplane 4
  805. */
  806. clipPlane4: Nullable<Plane>;
  807. /**
  808. * Gets or sets a boolean indicating if animations are enabled
  809. */
  810. animationsEnabled: boolean;
  811. private _animationPropertiesOverride;
  812. /**
  813. * Gets or sets the animation properties override
  814. */
  815. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  816. /**
  817. * Gets or sets a boolean indicating if a constant deltatime has to be used
  818. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  819. */
  820. useConstantAnimationDeltaTime: boolean;
  821. /**
  822. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  823. * Please note that it requires to run a ray cast through the scene on every frame
  824. */
  825. constantlyUpdateMeshUnderPointer: boolean;
  826. /**
  827. * Defines the HTML cursor to use when hovering over interactive elements
  828. */
  829. hoverCursor: string;
  830. /**
  831. * Defines the HTML default cursor to use (empty by default)
  832. */
  833. defaultCursor: string;
  834. /**
  835. * This is used to call preventDefault() on pointer down
  836. * in order to block unwanted artifacts like system double clicks
  837. */
  838. preventDefaultOnPointerDown: boolean;
  839. /**
  840. * This is used to call preventDefault() on pointer up
  841. * in order to block unwanted artifacts like system double clicks
  842. */
  843. preventDefaultOnPointerUp: boolean;
  844. /**
  845. * Gets or sets user defined metadata
  846. */
  847. metadata: any;
  848. /**
  849. * Gets the name of the plugin used to load this scene (null by default)
  850. */
  851. loadingPluginName: string;
  852. /**
  853. * Use this array to add regular expressions used to disable offline support for specific urls
  854. */
  855. disableOfflineSupportExceptionRules: RegExp[];
  856. /**
  857. * An event triggered when the scene is disposed.
  858. */
  859. onDisposeObservable: Observable<Scene>;
  860. private _onDisposeObserver;
  861. /** Sets a function to be executed when this scene is disposed. */
  862. onDispose: () => void;
  863. /**
  864. * An event triggered before rendering the scene (right after animations and physics)
  865. */
  866. onBeforeRenderObservable: Observable<Scene>;
  867. private _onBeforeRenderObserver;
  868. /** Sets a function to be executed before rendering this scene */
  869. beforeRender: Nullable<() => void>;
  870. /**
  871. * An event triggered after rendering the scene
  872. */
  873. onAfterRenderObservable: Observable<Scene>;
  874. private _onAfterRenderObserver;
  875. /** Sets a function to be executed after rendering this scene */
  876. afterRender: Nullable<() => void>;
  877. /**
  878. * An event triggered before animating the scene
  879. */
  880. onBeforeAnimationsObservable: Observable<Scene>;
  881. /**
  882. * An event triggered after animations processing
  883. */
  884. onAfterAnimationsObservable: Observable<Scene>;
  885. /**
  886. * An event triggered before draw calls are ready to be sent
  887. */
  888. onBeforeDrawPhaseObservable: Observable<Scene>;
  889. /**
  890. * An event triggered after draw calls have been sent
  891. */
  892. onAfterDrawPhaseObservable: Observable<Scene>;
  893. /**
  894. * An event triggered when the scene is ready
  895. */
  896. onReadyObservable: Observable<Scene>;
  897. /**
  898. * An event triggered before rendering a camera
  899. */
  900. onBeforeCameraRenderObservable: Observable<Camera>;
  901. private _onBeforeCameraRenderObserver;
  902. /** Sets a function to be executed before rendering a camera*/
  903. beforeCameraRender: () => void;
  904. /**
  905. * An event triggered after rendering a camera
  906. */
  907. onAfterCameraRenderObservable: Observable<Camera>;
  908. private _onAfterCameraRenderObserver;
  909. /** Sets a function to be executed after rendering a camera*/
  910. afterCameraRender: () => void;
  911. /**
  912. * An event triggered when active meshes evaluation is about to start
  913. */
  914. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  915. /**
  916. * An event triggered when active meshes evaluation is done
  917. */
  918. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  919. /**
  920. * An event triggered when particles rendering is about to start
  921. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  922. */
  923. onBeforeParticlesRenderingObservable: Observable<Scene>;
  924. /**
  925. * An event triggered when particles rendering is done
  926. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  927. */
  928. onAfterParticlesRenderingObservable: Observable<Scene>;
  929. /**
  930. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  931. */
  932. onDataLoadedObservable: Observable<Scene>;
  933. /**
  934. * An event triggered when a camera is created
  935. */
  936. onNewCameraAddedObservable: Observable<Camera>;
  937. /**
  938. * An event triggered when a camera is removed
  939. */
  940. onCameraRemovedObservable: Observable<Camera>;
  941. /**
  942. * An event triggered when a light is created
  943. */
  944. onNewLightAddedObservable: Observable<Light>;
  945. /**
  946. * An event triggered when a light is removed
  947. */
  948. onLightRemovedObservable: Observable<Light>;
  949. /**
  950. * An event triggered when a geometry is created
  951. */
  952. onNewGeometryAddedObservable: Observable<Geometry>;
  953. /**
  954. * An event triggered when a geometry is removed
  955. */
  956. onGeometryRemovedObservable: Observable<Geometry>;
  957. /**
  958. * An event triggered when a transform node is created
  959. */
  960. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  961. /**
  962. * An event triggered when a transform node is removed
  963. */
  964. onTransformNodeRemovedObservable: Observable<TransformNode>;
  965. /**
  966. * An event triggered when a mesh is created
  967. */
  968. onNewMeshAddedObservable: Observable<AbstractMesh>;
  969. /**
  970. * An event triggered when a mesh is removed
  971. */
  972. onMeshRemovedObservable: Observable<AbstractMesh>;
  973. /**
  974. * An event triggered when a material is created
  975. */
  976. onNewMaterialAddedObservable: Observable<Material>;
  977. /**
  978. * An event triggered when a material is removed
  979. */
  980. onMaterialRemovedObservable: Observable<Material>;
  981. /**
  982. * An event triggered when a texture is created
  983. */
  984. onNewTextureAddedObservable: Observable<BaseTexture>;
  985. /**
  986. * An event triggered when a texture is removed
  987. */
  988. onTextureRemovedObservable: Observable<BaseTexture>;
  989. /**
  990. * An event triggered when render targets are about to be rendered
  991. * Can happen multiple times per frame.
  992. */
  993. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  994. /**
  995. * An event triggered when render targets were rendered.
  996. * Can happen multiple times per frame.
  997. */
  998. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  999. /**
  1000. * An event triggered before calculating deterministic simulation step
  1001. */
  1002. onBeforeStepObservable: Observable<Scene>;
  1003. /**
  1004. * An event triggered after calculating deterministic simulation step
  1005. */
  1006. onAfterStepObservable: Observable<Scene>;
  1007. /**
  1008. * An event triggered when the activeCamera property is updated
  1009. */
  1010. onActiveCameraChanged: Observable<Scene>;
  1011. /**
  1012. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  1013. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1014. * 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)
  1015. */
  1016. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1017. /**
  1018. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  1019. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1020. * 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)
  1021. */
  1022. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1023. /**
  1024. * This Observable will when a mesh has been imported into the scene.
  1025. */
  1026. onMeshImportedObservable: Observable<AbstractMesh>;
  1027. private _registeredForLateAnimationBindings;
  1028. /**
  1029. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  1030. */
  1031. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  1032. /**
  1033. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  1034. */
  1035. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  1036. /**
  1037. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  1038. */
  1039. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  1040. private _onPointerMove;
  1041. private _onPointerDown;
  1042. private _onPointerUp;
  1043. /** Callback called when a pointer move is detected */
  1044. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1045. /** Callback called when a pointer down is detected */
  1046. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1047. /** Callback called when a pointer up is detected */
  1048. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  1049. /** Callback called when a pointer pick is detected */
  1050. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  1051. /**
  1052. * 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).
  1053. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  1054. */
  1055. onPrePointerObservable: Observable<PointerInfoPre>;
  1056. /**
  1057. * Observable event triggered each time an input event is received from the rendering canvas
  1058. */
  1059. onPointerObservable: Observable<PointerInfo>;
  1060. /**
  1061. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1062. */
  1063. readonly unTranslatedPointer: Vector2;
  1064. /** The distance in pixel that you have to move to prevent some events */
  1065. static DragMovementThreshold: number;
  1066. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1067. static LongPressDelay: number;
  1068. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1069. static DoubleClickDelay: number;
  1070. /** If you need to check double click without raising a single click at first click, enable this flag */
  1071. static ExclusiveDoubleClickMode: boolean;
  1072. private _initClickEvent;
  1073. private _initActionManager;
  1074. private _delayedSimpleClick;
  1075. private _delayedSimpleClickTimeout;
  1076. private _previousDelayedSimpleClickTimeout;
  1077. private _meshPickProceed;
  1078. private _previousButtonPressed;
  1079. private _currentPickResult;
  1080. private _previousPickResult;
  1081. private _totalPointersPressed;
  1082. private _doubleClickOccured;
  1083. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1084. cameraToUseForPointers: Nullable<Camera>;
  1085. private _pointerX;
  1086. private _pointerY;
  1087. private _unTranslatedPointerX;
  1088. private _unTranslatedPointerY;
  1089. private _startingPointerPosition;
  1090. private _previousStartingPointerPosition;
  1091. private _startingPointerTime;
  1092. private _previousStartingPointerTime;
  1093. private _pointerCaptures;
  1094. private _timeAccumulator;
  1095. private _currentStepId;
  1096. private _currentInternalStep;
  1097. /** @hidden */
  1098. _mirroredCameraPosition: Nullable<Vector3>;
  1099. /**
  1100. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1101. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1102. */
  1103. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1104. /**
  1105. * Observable event triggered each time an keyboard event is received from the hosting window
  1106. */
  1107. onKeyboardObservable: Observable<KeyboardInfo>;
  1108. private _onKeyDown;
  1109. private _onKeyUp;
  1110. private _onCanvasFocusObserver;
  1111. private _onCanvasBlurObserver;
  1112. private _useRightHandedSystem;
  1113. /**
  1114. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1115. */
  1116. useRightHandedSystem: boolean;
  1117. /**
  1118. * Sets the step Id used by deterministic lock step
  1119. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1120. * @param newStepId defines the step Id
  1121. */
  1122. setStepId(newStepId: number): void;
  1123. /**
  1124. * Gets the step Id used by deterministic lock step
  1125. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1126. * @returns the step Id
  1127. */
  1128. getStepId(): number;
  1129. /**
  1130. * Gets the internal step used by deterministic lock step
  1131. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1132. * @returns the internal step
  1133. */
  1134. getInternalStep(): number;
  1135. private _fogEnabled;
  1136. /**
  1137. * Gets or sets a boolean indicating if fog is enabled on this scene
  1138. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1139. * (Default is true)
  1140. */
  1141. fogEnabled: boolean;
  1142. private _fogMode;
  1143. /**
  1144. * Gets or sets the fog mode to use
  1145. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1146. * | mode | value |
  1147. * | --- | --- |
  1148. * | FOGMODE_NONE | 0 |
  1149. * | FOGMODE_EXP | 1 |
  1150. * | FOGMODE_EXP2 | 2 |
  1151. * | FOGMODE_LINEAR | 3 |
  1152. */
  1153. fogMode: number;
  1154. /**
  1155. * Gets or sets the fog color to use
  1156. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1157. * (Default is Color3(0.2, 0.2, 0.3))
  1158. */
  1159. fogColor: Color3;
  1160. /**
  1161. * Gets or sets the fog density to use
  1162. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1163. * (Default is 0.1)
  1164. */
  1165. fogDensity: number;
  1166. /**
  1167. * Gets or sets the fog start distance to use
  1168. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1169. * (Default is 0)
  1170. */
  1171. fogStart: number;
  1172. /**
  1173. * Gets or sets the fog end distance to use
  1174. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1175. * (Default is 1000)
  1176. */
  1177. fogEnd: number;
  1178. private _shadowsEnabled;
  1179. /**
  1180. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1181. */
  1182. shadowsEnabled: boolean;
  1183. private _lightsEnabled;
  1184. /**
  1185. * Gets or sets a boolean indicating if lights are enabled on this scene
  1186. */
  1187. lightsEnabled: boolean;
  1188. /** All of the active cameras added to this scene. */
  1189. activeCameras: Camera[];
  1190. private _activeCamera;
  1191. /** Gets or sets the current active camera */
  1192. activeCamera: Nullable<Camera>;
  1193. private _defaultMaterial;
  1194. /** The default material used on meshes when no material is affected */
  1195. /** The default material used on meshes when no material is affected */
  1196. defaultMaterial: Material;
  1197. private _texturesEnabled;
  1198. /**
  1199. * Gets or sets a boolean indicating if textures are enabled on this scene
  1200. */
  1201. texturesEnabled: boolean;
  1202. /**
  1203. * Gets or sets a boolean indicating if particles are enabled on this scene
  1204. */
  1205. particlesEnabled: boolean;
  1206. /**
  1207. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1208. */
  1209. spritesEnabled: boolean;
  1210. private _skeletonsEnabled;
  1211. /**
  1212. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1213. */
  1214. skeletonsEnabled: boolean;
  1215. /**
  1216. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1217. */
  1218. lensFlaresEnabled: boolean;
  1219. /**
  1220. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1221. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1222. */
  1223. collisionsEnabled: boolean;
  1224. private _workerCollisions;
  1225. /** @hidden */
  1226. collisionCoordinator: ICollisionCoordinator;
  1227. /**
  1228. * Defines the gravity applied to this scene (used only for collisions)
  1229. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1230. */
  1231. gravity: Vector3;
  1232. /**
  1233. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1234. */
  1235. postProcessesEnabled: boolean;
  1236. /**
  1237. * The list of postprocesses added to the scene
  1238. */
  1239. postProcesses: PostProcess[];
  1240. /**
  1241. * Gets the current postprocess manager
  1242. */
  1243. postProcessManager: PostProcessManager;
  1244. /**
  1245. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1246. */
  1247. renderTargetsEnabled: boolean;
  1248. /**
  1249. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1250. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1251. */
  1252. dumpNextRenderTargets: boolean;
  1253. /**
  1254. * The list of user defined render targets added to the scene
  1255. */
  1256. customRenderTargets: RenderTargetTexture[];
  1257. /**
  1258. * Defines if texture loading must be delayed
  1259. * If true, textures will only be loaded when they need to be rendered
  1260. */
  1261. useDelayedTextureLoading: boolean;
  1262. /**
  1263. * Gets the list of meshes imported to the scene through SceneLoader
  1264. */
  1265. importedMeshesFiles: String[];
  1266. /**
  1267. * Gets or sets a boolean indicating if probes are enabled on this scene
  1268. */
  1269. probesEnabled: boolean;
  1270. /**
  1271. * Gets or sets the current offline provider to use to store scene data
  1272. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1273. */
  1274. offlineProvider: IOfflineProvider;
  1275. /**
  1276. * Gets or sets the action manager associated with the scene
  1277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1278. */
  1279. actionManager: ActionManager;
  1280. private _meshesForIntersections;
  1281. /**
  1282. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1283. */
  1284. proceduralTexturesEnabled: boolean;
  1285. private _engine;
  1286. private _totalVertices;
  1287. /** @hidden */
  1288. _activeIndices: PerfCounter;
  1289. /** @hidden */
  1290. _activeParticles: PerfCounter;
  1291. /** @hidden */
  1292. _activeBones: PerfCounter;
  1293. private _animationRatio;
  1294. private _animationTimeLast;
  1295. private _animationTime;
  1296. /**
  1297. * Gets or sets a general scale for animation speed
  1298. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1299. */
  1300. animationTimeScale: number;
  1301. /** @hidden */
  1302. _cachedMaterial: Nullable<Material>;
  1303. /** @hidden */
  1304. _cachedEffect: Nullable<Effect>;
  1305. /** @hidden */
  1306. _cachedVisibility: Nullable<number>;
  1307. private _renderId;
  1308. private _frameId;
  1309. private _executeWhenReadyTimeoutId;
  1310. private _intermediateRendering;
  1311. private _viewUpdateFlag;
  1312. private _projectionUpdateFlag;
  1313. private _alternateViewUpdateFlag;
  1314. private _alternateProjectionUpdateFlag;
  1315. /** @hidden */
  1316. _toBeDisposed: Nullable<IDisposable>[];
  1317. private _activeRequests;
  1318. private _pendingData;
  1319. private _isDisposed;
  1320. /**
  1321. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1322. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1323. */
  1324. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1325. private _activeMeshes;
  1326. private _processedMaterials;
  1327. private _renderTargets;
  1328. /** @hidden */
  1329. _activeParticleSystems: SmartArray<IParticleSystem>;
  1330. private _activeSkeletons;
  1331. private _softwareSkinnedMeshes;
  1332. private _renderingManager;
  1333. /** @hidden */
  1334. _activeAnimatables: Animatable[];
  1335. private _transformMatrix;
  1336. private _sceneUbo;
  1337. private _alternateSceneUbo;
  1338. private _pickWithRayInverseMatrix;
  1339. private _viewMatrix;
  1340. private _projectionMatrix;
  1341. private _alternateViewMatrix;
  1342. private _alternateProjectionMatrix;
  1343. private _alternateTransformMatrix;
  1344. private _useAlternateCameraConfiguration;
  1345. private _alternateRendering;
  1346. private _wheelEventName;
  1347. /** @hidden */
  1348. _forcedViewPosition: Nullable<Vector3>;
  1349. /** @hidden */
  1350. readonly _isAlternateRenderingEnabled: boolean;
  1351. private _frustumPlanes;
  1352. /**
  1353. * Gets the list of frustum planes (built from the active camera)
  1354. */
  1355. readonly frustumPlanes: Plane[];
  1356. /**
  1357. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1358. * This is useful if there are more lights that the maximum simulteanous authorized
  1359. */
  1360. requireLightSorting: boolean;
  1361. /** @hidden */
  1362. readonly useMaterialMeshMap: boolean;
  1363. /** @hidden */
  1364. readonly useClonedMeshhMap: boolean;
  1365. private _pointerOverMesh;
  1366. private _pickedDownMesh;
  1367. private _pickedUpMesh;
  1368. private _externalData;
  1369. private _uid;
  1370. /**
  1371. * @hidden
  1372. * Backing store of defined scene components.
  1373. */
  1374. _components: ISceneComponent[];
  1375. /**
  1376. * @hidden
  1377. * Backing store of defined scene components.
  1378. */
  1379. _serializableComponents: ISceneSerializableComponent[];
  1380. /**
  1381. * List of components to register on the next registration step.
  1382. */
  1383. private _transientComponents;
  1384. /**
  1385. * Registers the transient components if needed.
  1386. */
  1387. private _registerTransientComponents;
  1388. /**
  1389. * @hidden
  1390. * Add a component to the scene.
  1391. * Note that the ccomponent could be registered on th next frame if this is called after
  1392. * the register component stage.
  1393. * @param component Defines the component to add to the scene
  1394. */
  1395. _addComponent(component: ISceneComponent): void;
  1396. /**
  1397. * @hidden
  1398. * Gets a component from the scene.
  1399. * @param name defines the name of the component to retrieve
  1400. * @returns the component or null if not present
  1401. */
  1402. _getComponent(name: string): Nullable<ISceneComponent>;
  1403. /**
  1404. * @hidden
  1405. * Defines the actions happening before camera updates.
  1406. */
  1407. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1408. /**
  1409. * @hidden
  1410. * Defines the actions happening before clear the canvas.
  1411. */
  1412. _beforeClearStage: Stage<SimpleStageAction>;
  1413. /**
  1414. * @hidden
  1415. * Defines the actions when collecting render targets for the frame.
  1416. */
  1417. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1418. /**
  1419. * @hidden
  1420. * Defines the actions happening for one camera in the frame.
  1421. */
  1422. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1423. /**
  1424. * @hidden
  1425. * Defines the actions happening during the per mesh ready checks.
  1426. */
  1427. _isReadyForMeshStage: Stage<MeshStageAction>;
  1428. /**
  1429. * @hidden
  1430. * Defines the actions happening before evaluate active mesh checks.
  1431. */
  1432. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1433. /**
  1434. * @hidden
  1435. * Defines the actions happening during the evaluate sub mesh checks.
  1436. */
  1437. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1438. /**
  1439. * @hidden
  1440. * Defines the actions happening during the active mesh stage.
  1441. */
  1442. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1443. /**
  1444. * @hidden
  1445. * Defines the actions happening during the per camera render target step.
  1446. */
  1447. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1448. /**
  1449. * @hidden
  1450. * Defines the actions happening just before the active camera is drawing.
  1451. */
  1452. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1453. /**
  1454. * @hidden
  1455. * Defines the actions happening just before a rendering group is drawing.
  1456. */
  1457. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1458. /**
  1459. * @hidden
  1460. * Defines the actions happening just before a mesh is drawing.
  1461. */
  1462. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1463. /**
  1464. * @hidden
  1465. * Defines the actions happening just after a mesh has been drawn.
  1466. */
  1467. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1468. /**
  1469. * @hidden
  1470. * Defines the actions happening just after a rendering group has been drawn.
  1471. */
  1472. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1473. /**
  1474. * @hidden
  1475. * Defines the actions happening just after the active camera has been drawn.
  1476. */
  1477. _afterCameraDrawStage: Stage<CameraStageAction>;
  1478. /**
  1479. * @hidden
  1480. * Defines the actions happening just after rendering all cameras and computing intersections.
  1481. */
  1482. _afterRenderStage: Stage<SimpleStageAction>;
  1483. /**
  1484. * @hidden
  1485. * Defines the actions happening when a pointer move event happens.
  1486. */
  1487. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1488. /**
  1489. * @hidden
  1490. * Defines the actions happening when a pointer down event happens.
  1491. */
  1492. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1493. /**
  1494. * @hidden
  1495. * Defines the actions happening when a pointer up event happens.
  1496. */
  1497. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1498. /**
  1499. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1500. */
  1501. private geometriesById;
  1502. /**
  1503. * Creates a new Scene
  1504. * @param engine defines the engine to use to render this scene
  1505. */
  1506. constructor(engine: Engine, options?: SceneOptions);
  1507. private _defaultMeshCandidates;
  1508. /**
  1509. * @hidden
  1510. */
  1511. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1512. private _defaultSubMeshCandidates;
  1513. /**
  1514. * @hidden
  1515. */
  1516. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1517. /**
  1518. * Sets the default candidate providers for the scene.
  1519. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1520. * and getCollidingSubMeshCandidates to their default function
  1521. */
  1522. setDefaultCandidateProviders(): void;
  1523. /**
  1524. * Gets a boolean indicating if collisions are processed on a web worker
  1525. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1526. */
  1527. workerCollisions: boolean;
  1528. /**
  1529. * Gets the mesh that is currently under the pointer
  1530. */
  1531. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1532. /**
  1533. * Gets the current on-screen X position of the pointer
  1534. */
  1535. readonly pointerX: number;
  1536. /**
  1537. * Gets the current on-screen Y position of the pointer
  1538. */
  1539. readonly pointerY: number;
  1540. /**
  1541. * Gets the cached material (ie. the latest rendered one)
  1542. * @returns the cached material
  1543. */
  1544. getCachedMaterial(): Nullable<Material>;
  1545. /**
  1546. * Gets the cached effect (ie. the latest rendered one)
  1547. * @returns the cached effect
  1548. */
  1549. getCachedEffect(): Nullable<Effect>;
  1550. /**
  1551. * Gets the cached visibility state (ie. the latest rendered one)
  1552. * @returns the cached visibility state
  1553. */
  1554. getCachedVisibility(): Nullable<number>;
  1555. /**
  1556. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1557. * @param material defines the current material
  1558. * @param effect defines the current effect
  1559. * @param visibility defines the current visibility state
  1560. * @returns true if one parameter is not cached
  1561. */
  1562. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1563. /**
  1564. * Gets the engine associated with the scene
  1565. * @returns an Engine
  1566. */
  1567. getEngine(): Engine;
  1568. /**
  1569. * Gets the total number of vertices rendered per frame
  1570. * @returns the total number of vertices rendered per frame
  1571. */
  1572. getTotalVertices(): number;
  1573. /**
  1574. * Gets the performance counter for total vertices
  1575. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1576. */
  1577. readonly totalVerticesPerfCounter: PerfCounter;
  1578. /**
  1579. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1580. * @returns the total number of active indices rendered per frame
  1581. */
  1582. getActiveIndices(): number;
  1583. /**
  1584. * Gets the performance counter for active indices
  1585. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1586. */
  1587. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1588. /**
  1589. * Gets the total number of active particles rendered per frame
  1590. * @returns the total number of active particles rendered per frame
  1591. */
  1592. getActiveParticles(): number;
  1593. /**
  1594. * Gets the performance counter for active particles
  1595. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1596. */
  1597. readonly activeParticlesPerfCounter: PerfCounter;
  1598. /**
  1599. * Gets the total number of active bones rendered per frame
  1600. * @returns the total number of active bones rendered per frame
  1601. */
  1602. getActiveBones(): number;
  1603. /**
  1604. * Gets the performance counter for active bones
  1605. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1606. */
  1607. readonly activeBonesPerfCounter: PerfCounter;
  1608. /**
  1609. * Gets the array of active meshes
  1610. * @returns an array of AbstractMesh
  1611. */
  1612. getActiveMeshes(): SmartArray<AbstractMesh>;
  1613. /**
  1614. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1615. * @returns a number
  1616. */
  1617. getAnimationRatio(): number;
  1618. /**
  1619. * Gets an unique Id for the current render phase
  1620. * @returns a number
  1621. */
  1622. getRenderId(): number;
  1623. /**
  1624. * Gets an unique Id for the current frame
  1625. * @returns a number
  1626. */
  1627. getFrameId(): number;
  1628. /** Call this function if you want to manually increment the render Id*/
  1629. incrementRenderId(): void;
  1630. private _updatePointerPosition;
  1631. private _createUbo;
  1632. private _createAlternateUbo;
  1633. private _setRayOnPointerInfo;
  1634. /**
  1635. * Use this method to simulate a pointer move on a mesh
  1636. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1637. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1638. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1639. * @returns the current scene
  1640. */
  1641. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1642. private _processPointerMove;
  1643. private _checkPrePointerObservable;
  1644. /**
  1645. * Use this method to simulate a pointer down on a mesh
  1646. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1647. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1648. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1649. * @returns the current scene
  1650. */
  1651. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1652. private _processPointerDown;
  1653. /**
  1654. * Use this method to simulate a pointer up on a mesh
  1655. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1656. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1657. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1658. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  1659. * @returns the current scene
  1660. */
  1661. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  1662. private _processPointerUp;
  1663. /**
  1664. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1665. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1666. * @returns true if the pointer was captured
  1667. */
  1668. isPointerCaptured(pointerId?: number): boolean;
  1669. /** @hidden */
  1670. _isPointerSwiping(): boolean;
  1671. /**
  1672. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1673. * @param attachUp defines if you want to attach events to pointerup
  1674. * @param attachDown defines if you want to attach events to pointerdown
  1675. * @param attachMove defines if you want to attach events to pointermove
  1676. */
  1677. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1678. /** Detaches all event handlers*/
  1679. detachControl(): void;
  1680. /**
  1681. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1682. * Delay loaded resources are not taking in account
  1683. * @return true if all required resources are ready
  1684. */
  1685. isReady(): boolean;
  1686. /** Resets all cached information relative to material (including effect and visibility) */
  1687. resetCachedMaterial(): void;
  1688. /**
  1689. * Registers a function to be called before every frame render
  1690. * @param func defines the function to register
  1691. */
  1692. registerBeforeRender(func: () => void): void;
  1693. /**
  1694. * Unregisters a function called before every frame render
  1695. * @param func defines the function to unregister
  1696. */
  1697. unregisterBeforeRender(func: () => void): void;
  1698. /**
  1699. * Registers a function to be called after every frame render
  1700. * @param func defines the function to register
  1701. */
  1702. registerAfterRender(func: () => void): void;
  1703. /**
  1704. * Unregisters a function called after every frame render
  1705. * @param func defines the function to unregister
  1706. */
  1707. unregisterAfterRender(func: () => void): void;
  1708. private _executeOnceBeforeRender;
  1709. /**
  1710. * The provided function will run before render once and will be disposed afterwards.
  1711. * A timeout delay can be provided so that the function will be executed in N ms.
  1712. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1713. * @param func The function to be executed.
  1714. * @param timeout optional delay in ms
  1715. */
  1716. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1717. /** @hidden */
  1718. _addPendingData(data: any): void;
  1719. /** @hidden */
  1720. _removePendingData(data: any): void;
  1721. /**
  1722. * Returns the number of items waiting to be loaded
  1723. * @returns the number of items waiting to be loaded
  1724. */
  1725. getWaitingItemsCount(): number;
  1726. /**
  1727. * Returns a boolean indicating if the scene is still loading data
  1728. */
  1729. readonly isLoading: boolean;
  1730. /**
  1731. * Registers a function to be executed when the scene is ready
  1732. * @param {Function} func - the function to be executed
  1733. */
  1734. executeWhenReady(func: () => void): void;
  1735. /**
  1736. * Returns a promise that resolves when the scene is ready
  1737. * @returns A promise that resolves when the scene is ready
  1738. */
  1739. whenReadyAsync(): Promise<void>;
  1740. /** @hidden */
  1741. _checkIsReady(): void;
  1742. /**
  1743. * Will start the animation sequence of a given target
  1744. * @param target defines the target
  1745. * @param from defines from which frame should animation start
  1746. * @param to defines until which frame should animation run.
  1747. * @param weight defines the weight to apply to the animation (1.0 by default)
  1748. * @param loop defines if the animation loops
  1749. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1750. * @param onAnimationEnd defines the function to be executed when the animation ends
  1751. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1752. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1753. * @returns the animatable object created for this animation
  1754. */
  1755. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1756. /**
  1757. * Will start the animation sequence of a given target
  1758. * @param target defines the target
  1759. * @param from defines from which frame should animation start
  1760. * @param to defines until which frame should animation run.
  1761. * @param loop defines if the animation loops
  1762. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1763. * @param onAnimationEnd defines the function to be executed when the animation ends
  1764. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1765. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1766. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1767. * @returns the animatable object created for this animation
  1768. */
  1769. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1770. /**
  1771. * Begin a new animation on a given node
  1772. * @param target defines the target where the animation will take place
  1773. * @param animations defines the list of animations to start
  1774. * @param from defines the initial value
  1775. * @param to defines the final value
  1776. * @param loop defines if you want animation to loop (off by default)
  1777. * @param speedRatio defines the speed ratio to apply to all animations
  1778. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1779. * @returns the list of created animatables
  1780. */
  1781. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1782. /**
  1783. * Begin a new animation on a given node and its hierarchy
  1784. * @param target defines the root node where the animation will take place
  1785. * @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.
  1786. * @param animations defines the list of animations to start
  1787. * @param from defines the initial value
  1788. * @param to defines the final value
  1789. * @param loop defines if you want animation to loop (off by default)
  1790. * @param speedRatio defines the speed ratio to apply to all animations
  1791. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1792. * @returns the list of animatables created for all nodes
  1793. */
  1794. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1795. /**
  1796. * Gets the animatable associated with a specific target
  1797. * @param target defines the target of the animatable
  1798. * @returns the required animatable if found
  1799. */
  1800. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1801. /**
  1802. * Gets all animatables associated with a given target
  1803. * @param target defines the target to look animatables for
  1804. * @returns an array of Animatables
  1805. */
  1806. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1807. /**
  1808. * Gets all animatable attached to the scene
  1809. */
  1810. readonly animatables: Animatable[];
  1811. /**
  1812. * Will stop the animation of the given target
  1813. * @param target - the target
  1814. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1815. * @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)
  1816. */
  1817. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1818. /**
  1819. * Stops and removes all animations that have been applied to the scene
  1820. */
  1821. stopAllAnimations(): void;
  1822. private _animate;
  1823. /** @hidden */
  1824. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1825. private _processLateAnimationBindingsForMatrices;
  1826. private _processLateAnimationBindingsForQuaternions;
  1827. private _processLateAnimationBindings;
  1828. /** @hidden */
  1829. _switchToAlternateCameraConfiguration(active: boolean): void;
  1830. /**
  1831. * Gets the current view matrix
  1832. * @returns a Matrix
  1833. */
  1834. getViewMatrix(): Matrix;
  1835. /**
  1836. * Gets the current projection matrix
  1837. * @returns a Matrix
  1838. */
  1839. getProjectionMatrix(): Matrix;
  1840. /**
  1841. * Gets the current transform matrix
  1842. * @returns a Matrix made of View * Projection
  1843. */
  1844. getTransformMatrix(): Matrix;
  1845. /**
  1846. * Sets the current transform matrix
  1847. * @param view defines the View matrix to use
  1848. * @param projection defines the Projection matrix to use
  1849. */
  1850. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1851. /** @hidden */
  1852. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1853. /**
  1854. * Gets the uniform buffer used to store scene data
  1855. * @returns a UniformBuffer
  1856. */
  1857. getSceneUniformBuffer(): UniformBuffer;
  1858. /**
  1859. * Gets an unique (relatively to the current scene) Id
  1860. * @returns an unique number for the scene
  1861. */
  1862. getUniqueId(): number;
  1863. /**
  1864. * Add a mesh to the list of scene's meshes
  1865. * @param newMesh defines the mesh to add
  1866. * @param recursive if all child meshes should also be added to the scene
  1867. */
  1868. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1869. /**
  1870. * Remove a mesh for the list of scene's meshes
  1871. * @param toRemove defines the mesh to remove
  1872. * @param recursive if all child meshes should also be removed from the scene
  1873. * @returns the index where the mesh was in the mesh list
  1874. */
  1875. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1876. /**
  1877. * Add a transform node to the list of scene's transform nodes
  1878. * @param newTransformNode defines the transform node to add
  1879. */
  1880. addTransformNode(newTransformNode: TransformNode): void;
  1881. /**
  1882. * Remove a transform node for the list of scene's transform nodes
  1883. * @param toRemove defines the transform node to remove
  1884. * @returns the index where the transform node was in the transform node list
  1885. */
  1886. removeTransformNode(toRemove: TransformNode): number;
  1887. /**
  1888. * Remove a skeleton for the list of scene's skeletons
  1889. * @param toRemove defines the skeleton to remove
  1890. * @returns the index where the skeleton was in the skeleton list
  1891. */
  1892. removeSkeleton(toRemove: Skeleton): number;
  1893. /**
  1894. * Remove a morph target for the list of scene's morph targets
  1895. * @param toRemove defines the morph target to remove
  1896. * @returns the index where the morph target was in the morph target list
  1897. */
  1898. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1899. /**
  1900. * Remove a light for the list of scene's lights
  1901. * @param toRemove defines the light to remove
  1902. * @returns the index where the light was in the light list
  1903. */
  1904. removeLight(toRemove: Light): number;
  1905. /**
  1906. * Remove a camera for the list of scene's cameras
  1907. * @param toRemove defines the camera to remove
  1908. * @returns the index where the camera was in the camera list
  1909. */
  1910. removeCamera(toRemove: Camera): number;
  1911. /**
  1912. * Remove a particle system for the list of scene's particle systems
  1913. * @param toRemove defines the particle system to remove
  1914. * @returns the index where the particle system was in the particle system list
  1915. */
  1916. removeParticleSystem(toRemove: IParticleSystem): number;
  1917. /**
  1918. * Remove a animation for the list of scene's animations
  1919. * @param toRemove defines the animation to remove
  1920. * @returns the index where the animation was in the animation list
  1921. */
  1922. removeAnimation(toRemove: Animation): number;
  1923. /**
  1924. * Removes the given animation group from this scene.
  1925. * @param toRemove The animation group to remove
  1926. * @returns The index of the removed animation group
  1927. */
  1928. removeAnimationGroup(toRemove: AnimationGroup): number;
  1929. /**
  1930. * Removes the given multi-material from this scene.
  1931. * @param toRemove The multi-material to remove
  1932. * @returns The index of the removed multi-material
  1933. */
  1934. removeMultiMaterial(toRemove: MultiMaterial): number;
  1935. /**
  1936. * Removes the given material from this scene.
  1937. * @param toRemove The material to remove
  1938. * @returns The index of the removed material
  1939. */
  1940. removeMaterial(toRemove: Material): number;
  1941. /**
  1942. * Removes the given action manager from this scene.
  1943. * @param toRemove The action manager to remove
  1944. * @returns The index of the removed action manager
  1945. */
  1946. removeActionManager(toRemove: ActionManager): number;
  1947. /**
  1948. * Removes the given texture from this scene.
  1949. * @param toRemove The texture to remove
  1950. * @returns The index of the removed texture
  1951. */
  1952. removeTexture(toRemove: BaseTexture): number;
  1953. /**
  1954. * Adds the given light to this scene
  1955. * @param newLight The light to add
  1956. */
  1957. addLight(newLight: Light): void;
  1958. /**
  1959. * Sorts the list list based on light priorities
  1960. */
  1961. sortLightsByPriority(): void;
  1962. /**
  1963. * Adds the given camera to this scene
  1964. * @param newCamera The camera to add
  1965. */
  1966. addCamera(newCamera: Camera): void;
  1967. /**
  1968. * Adds the given skeleton to this scene
  1969. * @param newSkeleton The skeleton to add
  1970. */
  1971. addSkeleton(newSkeleton: Skeleton): void;
  1972. /**
  1973. * Adds the given particle system to this scene
  1974. * @param newParticleSystem The particle system to add
  1975. */
  1976. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1977. /**
  1978. * Adds the given animation to this scene
  1979. * @param newAnimation The animation to add
  1980. */
  1981. addAnimation(newAnimation: Animation): void;
  1982. /**
  1983. * Adds the given animation group to this scene.
  1984. * @param newAnimationGroup The animation group to add
  1985. */
  1986. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1987. /**
  1988. * Adds the given multi-material to this scene
  1989. * @param newMultiMaterial The multi-material to add
  1990. */
  1991. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1992. /**
  1993. * Adds the given material to this scene
  1994. * @param newMaterial The material to add
  1995. */
  1996. addMaterial(newMaterial: Material): void;
  1997. /**
  1998. * Adds the given morph target to this scene
  1999. * @param newMorphTargetManager The morph target to add
  2000. */
  2001. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  2002. /**
  2003. * Adds the given geometry to this scene
  2004. * @param newGeometry The geometry to add
  2005. */
  2006. addGeometry(newGeometry: Geometry): void;
  2007. /**
  2008. * Adds the given action manager to this scene
  2009. * @param newActionManager The action manager to add
  2010. */
  2011. addActionManager(newActionManager: ActionManager): void;
  2012. /**
  2013. * Adds the given texture to this scene.
  2014. * @param newTexture The texture to add
  2015. */
  2016. addTexture(newTexture: BaseTexture): void;
  2017. /**
  2018. * Switch active camera
  2019. * @param newCamera defines the new active camera
  2020. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2021. */
  2022. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2023. /**
  2024. * sets the active camera of the scene using its ID
  2025. * @param id defines the camera's ID
  2026. * @return the new active camera or null if none found.
  2027. */
  2028. setActiveCameraByID(id: string): Nullable<Camera>;
  2029. /**
  2030. * sets the active camera of the scene using its name
  2031. * @param name defines the camera's name
  2032. * @returns the new active camera or null if none found.
  2033. */
  2034. setActiveCameraByName(name: string): Nullable<Camera>;
  2035. /**
  2036. * get an animation group using its name
  2037. * @param name defines the material's name
  2038. * @return the animation group or null if none found.
  2039. */
  2040. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2041. /**
  2042. * get a material using its id
  2043. * @param id defines the material's ID
  2044. * @return the material or null if none found.
  2045. */
  2046. getMaterialByID(id: string): Nullable<Material>;
  2047. /**
  2048. * Gets a material using its name
  2049. * @param name defines the material's name
  2050. * @return the material or null if none found.
  2051. */
  2052. getMaterialByName(name: string): Nullable<Material>;
  2053. /**
  2054. * Gets a camera using its id
  2055. * @param id defines the id to look for
  2056. * @returns the camera or null if not found
  2057. */
  2058. getCameraByID(id: string): Nullable<Camera>;
  2059. /**
  2060. * Gets a camera using its unique id
  2061. * @param uniqueId defines the unique id to look for
  2062. * @returns the camera or null if not found
  2063. */
  2064. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2065. /**
  2066. * Gets a camera using its name
  2067. * @param name defines the camera's name
  2068. * @return the camera or null if none found.
  2069. */
  2070. getCameraByName(name: string): Nullable<Camera>;
  2071. /**
  2072. * Gets a bone using its id
  2073. * @param id defines the bone's id
  2074. * @return the bone or null if not found
  2075. */
  2076. getBoneByID(id: string): Nullable<Bone>;
  2077. /**
  2078. * Gets a bone using its id
  2079. * @param name defines the bone's name
  2080. * @return the bone or null if not found
  2081. */
  2082. getBoneByName(name: string): Nullable<Bone>;
  2083. /**
  2084. * Gets a light node using its name
  2085. * @param name defines the the light's name
  2086. * @return the light or null if none found.
  2087. */
  2088. getLightByName(name: string): Nullable<Light>;
  2089. /**
  2090. * Gets a light node using its id
  2091. * @param id defines the light's id
  2092. * @return the light or null if none found.
  2093. */
  2094. getLightByID(id: string): Nullable<Light>;
  2095. /**
  2096. * Gets a light node using its scene-generated unique ID
  2097. * @param uniqueId defines the light's unique id
  2098. * @return the light or null if none found.
  2099. */
  2100. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2101. /**
  2102. * Gets a particle system by id
  2103. * @param id defines the particle system id
  2104. * @return the corresponding system or null if none found
  2105. */
  2106. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2107. /**
  2108. * Gets a geometry using its ID
  2109. * @param id defines the geometry's id
  2110. * @return the geometry or null if none found.
  2111. */
  2112. getGeometryByID(id: string): Nullable<Geometry>;
  2113. /**
  2114. * Add a new geometry to this scene
  2115. * @param geometry defines the geometry to be added to the scene.
  2116. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2117. * @return a boolean defining if the geometry was added or not
  2118. */
  2119. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2120. /**
  2121. * Removes an existing geometry
  2122. * @param geometry defines the geometry to be removed from the scene
  2123. * @return a boolean defining if the geometry was removed or not
  2124. */
  2125. removeGeometry(geometry: Geometry): boolean;
  2126. /**
  2127. * Gets the list of geometries attached to the scene
  2128. * @returns an array of Geometry
  2129. */
  2130. getGeometries(): Geometry[];
  2131. /**
  2132. * Gets the first added mesh found of a given ID
  2133. * @param id defines the id to search for
  2134. * @return the mesh found or null if not found at all
  2135. */
  2136. getMeshByID(id: string): Nullable<AbstractMesh>;
  2137. /**
  2138. * Gets a list of meshes using their id
  2139. * @param id defines the id to search for
  2140. * @returns a list of meshes
  2141. */
  2142. getMeshesByID(id: string): Array<AbstractMesh>;
  2143. /**
  2144. * Gets the first added transform node found of a given ID
  2145. * @param id defines the id to search for
  2146. * @return the found transform node or null if not found at all.
  2147. */
  2148. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2149. /**
  2150. * Gets a list of transform nodes using their id
  2151. * @param id defines the id to search for
  2152. * @returns a list of transform nodes
  2153. */
  2154. getTransformNodesByID(id: string): Array<TransformNode>;
  2155. /**
  2156. * Gets a mesh with its auto-generated unique id
  2157. * @param uniqueId defines the unique id to search for
  2158. * @return the found mesh or null if not found at all.
  2159. */
  2160. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2161. /**
  2162. * Gets a the last added mesh using a given id
  2163. * @param id defines the id to search for
  2164. * @return the found mesh or null if not found at all.
  2165. */
  2166. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2167. /**
  2168. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2169. * @param id defines the id to search for
  2170. * @return the found node or null if not found at all
  2171. */
  2172. getLastEntryByID(id: string): Nullable<Node>;
  2173. /**
  2174. * Gets a node (Mesh, Camera, Light) using a given id
  2175. * @param id defines the id to search for
  2176. * @return the found node or null if not found at all
  2177. */
  2178. getNodeByID(id: string): Nullable<Node>;
  2179. /**
  2180. * Gets a node (Mesh, Camera, Light) using a given name
  2181. * @param name defines the name to search for
  2182. * @return the found node or null if not found at all.
  2183. */
  2184. getNodeByName(name: string): Nullable<Node>;
  2185. /**
  2186. * Gets a mesh using a given name
  2187. * @param name defines the name to search for
  2188. * @return the found mesh or null if not found at all.
  2189. */
  2190. getMeshByName(name: string): Nullable<AbstractMesh>;
  2191. /**
  2192. * Gets a transform node using a given name
  2193. * @param name defines the name to search for
  2194. * @return the found transform node or null if not found at all.
  2195. */
  2196. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2197. /**
  2198. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2199. * @param id defines the id to search for
  2200. * @return the found skeleton or null if not found at all.
  2201. */
  2202. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2203. /**
  2204. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2205. * @param id defines the id to search for
  2206. * @return the found skeleton or null if not found at all.
  2207. */
  2208. getSkeletonById(id: string): Nullable<Skeleton>;
  2209. /**
  2210. * Gets a skeleton using a given name
  2211. * @param name defines the name to search for
  2212. * @return the found skeleton or null if not found at all.
  2213. */
  2214. getSkeletonByName(name: string): Nullable<Skeleton>;
  2215. /**
  2216. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2217. * @param id defines the id to search for
  2218. * @return the found morph target manager or null if not found at all.
  2219. */
  2220. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2221. /**
  2222. * Gets a boolean indicating if the given mesh is active
  2223. * @param mesh defines the mesh to look for
  2224. * @returns true if the mesh is in the active list
  2225. */
  2226. isActiveMesh(mesh: AbstractMesh): boolean;
  2227. /**
  2228. * Return a unique id as a string which can serve as an identifier for the scene
  2229. */
  2230. readonly uid: string;
  2231. /**
  2232. * Add an externaly attached data from its key.
  2233. * This method call will fail and return false, if such key already exists.
  2234. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2235. * @param key the unique key that identifies the data
  2236. * @param data the data object to associate to the key for this Engine instance
  2237. * @return true if no such key were already present and the data was added successfully, false otherwise
  2238. */
  2239. addExternalData<T>(key: string, data: T): boolean;
  2240. /**
  2241. * Get an externaly attached data from its key
  2242. * @param key the unique key that identifies the data
  2243. * @return the associated data, if present (can be null), or undefined if not present
  2244. */
  2245. getExternalData<T>(key: string): Nullable<T>;
  2246. /**
  2247. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2248. * @param key the unique key that identifies the data
  2249. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2250. * @return the associated data, can be null if the factory returned null.
  2251. */
  2252. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2253. /**
  2254. * Remove an externaly attached data from the Engine instance
  2255. * @param key the unique key that identifies the data
  2256. * @return true if the data was successfully removed, false if it doesn't exist
  2257. */
  2258. removeExternalData(key: string): boolean;
  2259. private _evaluateSubMesh;
  2260. /**
  2261. * Clear the processed materials smart array preventing retention point in material dispose.
  2262. */
  2263. freeProcessedMaterials(): void;
  2264. private _preventFreeActiveMeshesAndRenderingGroups;
  2265. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2266. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2267. * when disposing several meshes in a row or a hierarchy of meshes.
  2268. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2269. */
  2270. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2271. /**
  2272. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2273. */
  2274. freeActiveMeshes(): void;
  2275. /**
  2276. * Clear the info related to rendering groups preventing retention points during dispose.
  2277. */
  2278. freeRenderingGroups(): void;
  2279. /** @hidden */
  2280. _isInIntermediateRendering(): boolean;
  2281. /**
  2282. * Lambda returning the list of potentially active meshes.
  2283. */
  2284. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2285. /**
  2286. * Lambda returning the list of potentially active sub meshes.
  2287. */
  2288. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2289. /**
  2290. * Lambda returning the list of potentially intersecting sub meshes.
  2291. */
  2292. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2293. /**
  2294. * Lambda returning the list of potentially colliding sub meshes.
  2295. */
  2296. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2297. private _activeMeshesFrozen;
  2298. /**
  2299. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2300. * @returns the current scene
  2301. */
  2302. freezeActiveMeshes(): Scene;
  2303. /**
  2304. * Use this function to restart evaluating active meshes on every frame
  2305. * @returns the current scene
  2306. */
  2307. unfreezeActiveMeshes(): Scene;
  2308. private _evaluateActiveMeshes;
  2309. private _activeMesh;
  2310. /**
  2311. * Update the transform matrix to update from the current active camera
  2312. * @param force defines a boolean used to force the update even if cache is up to date
  2313. */
  2314. updateTransformMatrix(force?: boolean): void;
  2315. /**
  2316. * 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)
  2317. * @param alternateCamera defines the camera to use
  2318. */
  2319. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2320. /** @hidden */
  2321. _allowPostProcessClearColor: boolean;
  2322. private _renderForCamera;
  2323. private _processSubCameras;
  2324. private _checkIntersections;
  2325. /** @hidden */
  2326. _advancePhysicsEngineStep(step: number): void;
  2327. /**
  2328. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2329. */
  2330. getDeterministicFrameTime: () => number;
  2331. /**
  2332. * Render the scene
  2333. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2334. */
  2335. render(updateCameras?: boolean): void;
  2336. /**
  2337. * Freeze all materials
  2338. * A frozen material will not be updatable but should be faster to render
  2339. */
  2340. freezeMaterials(): void;
  2341. /**
  2342. * Unfreeze all materials
  2343. * A frozen material will not be updatable but should be faster to render
  2344. */
  2345. unfreezeMaterials(): void;
  2346. /**
  2347. * Releases all held ressources
  2348. */
  2349. dispose(): void;
  2350. /**
  2351. * Gets if the scene is already disposed
  2352. */
  2353. readonly isDisposed: boolean;
  2354. /**
  2355. * Call this function to reduce memory footprint of the scene.
  2356. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2357. */
  2358. clearCachedVertexData(): void;
  2359. /**
  2360. * This function will remove the local cached buffer data from texture.
  2361. * It will save memory but will prevent the texture from being rebuilt
  2362. */
  2363. cleanCachedTextureBuffer(): void;
  2364. /**
  2365. * Get the world extend vectors with an optional filter
  2366. *
  2367. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2368. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2369. */
  2370. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2371. min: Vector3;
  2372. max: Vector3;
  2373. };
  2374. /**
  2375. * Creates a ray that can be used to pick in the scene
  2376. * @param x defines the x coordinate of the origin (on-screen)
  2377. * @param y defines the y coordinate of the origin (on-screen)
  2378. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2379. * @param camera defines the camera to use for the picking
  2380. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2381. * @returns a Ray
  2382. */
  2383. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2384. /**
  2385. * Creates a ray that can be used to pick in the scene
  2386. * @param x defines the x coordinate of the origin (on-screen)
  2387. * @param y defines the y coordinate of the origin (on-screen)
  2388. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2389. * @param result defines the ray where to store the picking ray
  2390. * @param camera defines the camera to use for the picking
  2391. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2392. * @returns the current scene
  2393. */
  2394. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2395. /**
  2396. * Creates a ray that can be used to pick in the scene
  2397. * @param x defines the x coordinate of the origin (on-screen)
  2398. * @param y defines the y coordinate of the origin (on-screen)
  2399. * @param camera defines the camera to use for the picking
  2400. * @returns a Ray
  2401. */
  2402. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2403. /**
  2404. * Creates a ray that can be used to pick in the scene
  2405. * @param x defines the x coordinate of the origin (on-screen)
  2406. * @param y defines the y coordinate of the origin (on-screen)
  2407. * @param result defines the ray where to store the picking ray
  2408. * @param camera defines the camera to use for the picking
  2409. * @returns the current scene
  2410. */
  2411. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2412. private _internalPick;
  2413. private _internalMultiPick;
  2414. private _tempPickingRay;
  2415. /** Launch a ray to try to pick a mesh in the scene
  2416. * @param x position on screen
  2417. * @param y position on screen
  2418. * @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
  2419. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2420. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2421. * @returns a PickingInfo
  2422. */
  2423. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2424. private _cachedRayForTransform;
  2425. /** Use the given ray to pick a mesh in the scene
  2426. * @param ray The ray to use to pick meshes
  2427. * @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
  2428. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2429. * @returns a PickingInfo
  2430. */
  2431. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2432. /**
  2433. * Launch a ray to try to pick a mesh in the scene
  2434. * @param x X position on screen
  2435. * @param y Y position on screen
  2436. * @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
  2437. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2438. * @returns an array of PickingInfo
  2439. */
  2440. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2441. /**
  2442. * Launch a ray to try to pick a mesh in the scene
  2443. * @param ray Ray to use
  2444. * @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
  2445. * @returns an array of PickingInfo
  2446. */
  2447. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2448. /**
  2449. * Force the value of meshUnderPointer
  2450. * @param mesh defines the mesh to use
  2451. */
  2452. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2453. /**
  2454. * Gets the mesh under the pointer
  2455. * @returns a Mesh or null if no mesh is under the pointer
  2456. */
  2457. getPointerOverMesh(): Nullable<AbstractMesh>;
  2458. /** @hidden */
  2459. _rebuildGeometries(): void;
  2460. /** @hidden */
  2461. _rebuildTextures(): void;
  2462. private _getByTags;
  2463. /**
  2464. * Get a list of meshes by tags
  2465. * @param tagsQuery defines the tags query to use
  2466. * @param forEach defines a predicate used to filter results
  2467. * @returns an array of Mesh
  2468. */
  2469. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2470. /**
  2471. * Get a list of cameras by tags
  2472. * @param tagsQuery defines the tags query to use
  2473. * @param forEach defines a predicate used to filter results
  2474. * @returns an array of Camera
  2475. */
  2476. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2477. /**
  2478. * Get a list of lights by tags
  2479. * @param tagsQuery defines the tags query to use
  2480. * @param forEach defines a predicate used to filter results
  2481. * @returns an array of Light
  2482. */
  2483. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2484. /**
  2485. * Get a list of materials by tags
  2486. * @param tagsQuery defines the tags query to use
  2487. * @param forEach defines a predicate used to filter results
  2488. * @returns an array of Material
  2489. */
  2490. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2491. /**
  2492. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2493. * This allowed control for front to back rendering or reversly depending of the special needs.
  2494. *
  2495. * @param renderingGroupId The rendering group id corresponding to its index
  2496. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2497. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2498. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2499. */
  2500. 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;
  2501. /**
  2502. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2503. *
  2504. * @param renderingGroupId The rendering group id corresponding to its index
  2505. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2506. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2507. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2508. */
  2509. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2510. /**
  2511. * Gets the current auto clear configuration for one rendering group of the rendering
  2512. * manager.
  2513. * @param index the rendering group index to get the information for
  2514. * @returns The auto clear setup for the requested rendering group
  2515. */
  2516. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2517. private _blockMaterialDirtyMechanism;
  2518. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2519. blockMaterialDirtyMechanism: boolean;
  2520. /**
  2521. * Will flag all materials as dirty to trigger new shader compilation
  2522. * @param flag defines the flag used to specify which material part must be marked as dirty
  2523. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2524. */
  2525. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2526. /** @hidden */
  2527. _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;
  2528. /** @hidden */
  2529. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2530. }
  2531. }
  2532. declare module BABYLON {
  2533. /**
  2534. * Groups all the scene component constants in one place to ease maintenance.
  2535. * @hidden
  2536. */
  2537. class SceneComponentConstants {
  2538. static readonly NAME_EFFECTLAYER: string;
  2539. static readonly NAME_LAYER: string;
  2540. static readonly NAME_LENSFLARESYSTEM: string;
  2541. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2542. static readonly NAME_PARTICLESYSTEM: string;
  2543. static readonly NAME_GAMEPAD: string;
  2544. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2545. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2546. static readonly NAME_DEPTHRENDERER: string;
  2547. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2548. static readonly NAME_SPRITE: string;
  2549. static readonly NAME_OUTLINERENDERER: string;
  2550. static readonly NAME_PROCEDURALTEXTURE: string;
  2551. static readonly NAME_SHADOWGENERATOR: string;
  2552. static readonly NAME_OCTREE: string;
  2553. static readonly NAME_PHYSICSENGINE: string;
  2554. static readonly NAME_AUDIO: string;
  2555. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2556. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2557. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2558. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2559. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2560. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2561. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2562. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2563. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2564. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2565. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2566. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2567. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2568. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2569. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2570. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2571. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2572. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2573. static readonly STEP_AFTERRENDER_AUDIO: number;
  2574. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2575. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2576. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2577. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2578. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2579. static readonly STEP_POINTERMOVE_SPRITE: number;
  2580. static readonly STEP_POINTERDOWN_SPRITE: number;
  2581. static readonly STEP_POINTERUP_SPRITE: number;
  2582. }
  2583. /**
  2584. * This represents a scene component.
  2585. *
  2586. * This is used to decouple the dependency the scene is having on the different workloads like
  2587. * layers, post processes...
  2588. */
  2589. interface ISceneComponent {
  2590. /**
  2591. * The name of the component. Each component must have a unique name.
  2592. */
  2593. name: string;
  2594. /**
  2595. * The scene the component belongs to.
  2596. */
  2597. scene: Scene;
  2598. /**
  2599. * Register the component to one instance of a scene.
  2600. */
  2601. register(): void;
  2602. /**
  2603. * Rebuilds the elements related to this component in case of
  2604. * context lost for instance.
  2605. */
  2606. rebuild(): void;
  2607. /**
  2608. * Disposes the component and the associated ressources.
  2609. */
  2610. dispose(): void;
  2611. }
  2612. /**
  2613. * This represents a SERIALIZABLE scene component.
  2614. *
  2615. * This extends Scene Component to add Serialization methods on top.
  2616. */
  2617. interface ISceneSerializableComponent extends ISceneComponent {
  2618. /**
  2619. * Adds all the element from the container to the scene
  2620. * @param container the container holding the elements
  2621. */
  2622. addFromContainer(container: AbstractScene): void;
  2623. /**
  2624. * Removes all the elements in the container from the scene
  2625. * @param container contains the elements to remove
  2626. */
  2627. removeFromContainer(container: AbstractScene): void;
  2628. /**
  2629. * Serializes the component data to the specified json object
  2630. * @param serializationObject The object to serialize to
  2631. */
  2632. serialize(serializationObject: any): void;
  2633. }
  2634. /**
  2635. * Strong typing of a Mesh related stage step action
  2636. */
  2637. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2638. /**
  2639. * Strong typing of a Evaluate Sub Mesh related stage step action
  2640. */
  2641. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2642. /**
  2643. * Strong typing of a Active Mesh related stage step action
  2644. */
  2645. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2646. /**
  2647. * Strong typing of a Camera related stage step action
  2648. */
  2649. type CameraStageAction = (camera: Camera) => void;
  2650. /**
  2651. * Strong typing of a RenderingGroup related stage step action
  2652. */
  2653. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2654. /**
  2655. * Strong typing of a Mesh Render related stage step action
  2656. */
  2657. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2658. /**
  2659. * Strong typing of a simple stage step action
  2660. */
  2661. type SimpleStageAction = () => void;
  2662. /**
  2663. * Strong typing of a render target action.
  2664. */
  2665. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2666. /**
  2667. * Strong typing of a pointer move action.
  2668. */
  2669. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2670. /**
  2671. * Strong typing of a pointer up/down action.
  2672. */
  2673. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2674. /**
  2675. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2676. * @hidden
  2677. */
  2678. class Stage<T extends Function> extends Array<{
  2679. index: number;
  2680. component: ISceneComponent;
  2681. action: T;
  2682. }> {
  2683. /**
  2684. * Hide ctor from the rest of the world.
  2685. * @param items The items to add.
  2686. */
  2687. private constructor();
  2688. /**
  2689. * Creates a new Stage.
  2690. * @returns A new instance of a Stage
  2691. */
  2692. static Create<T extends Function>(): Stage<T>;
  2693. /**
  2694. * Registers a step in an ordered way in the targeted stage.
  2695. * @param index Defines the position to register the step in
  2696. * @param component Defines the component attached to the step
  2697. * @param action Defines the action to launch during the step
  2698. */
  2699. registerStep(index: number, component: ISceneComponent, action: T): void;
  2700. /**
  2701. * Clears all the steps from the stage.
  2702. */
  2703. clear(): void;
  2704. }
  2705. }
  2706. declare module BABYLON {
  2707. /** Alias type for value that can be null */
  2708. type Nullable<T> = T | null;
  2709. /**
  2710. * Alias type for number that are floats
  2711. * @ignorenaming
  2712. */
  2713. type float = number;
  2714. /**
  2715. * Alias type for number that are doubles.
  2716. * @ignorenaming
  2717. */
  2718. type double = number;
  2719. /**
  2720. * Alias type for number that are integer
  2721. * @ignorenaming
  2722. */
  2723. type int = number;
  2724. /** Alias type for number array or Float32Array */
  2725. type FloatArray = number[] | Float32Array;
  2726. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2727. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2728. /**
  2729. * Alias for types that can be used by a Buffer or VertexBuffer.
  2730. */
  2731. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2732. }
  2733. declare module BABYLON {
  2734. /**
  2735. * The action to be carried out following a trigger
  2736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2737. */
  2738. class Action {
  2739. /** the trigger, with or without parameters, for the action */
  2740. triggerOptions: any;
  2741. /**
  2742. * Trigger for the action
  2743. */
  2744. trigger: number;
  2745. /**
  2746. * Internal only - manager for action
  2747. * @hidden
  2748. */
  2749. _actionManager: ActionManager;
  2750. private _nextActiveAction;
  2751. private _child;
  2752. private _condition?;
  2753. private _triggerParameter;
  2754. /**
  2755. * An event triggered prior to action being executed.
  2756. */
  2757. onBeforeExecuteObservable: Observable<Action>;
  2758. /**
  2759. * Creates a new Action
  2760. * @param triggerOptions the trigger, with or without parameters, for the action
  2761. * @param condition an optional determinant of action
  2762. */
  2763. constructor(
  2764. /** the trigger, with or without parameters, for the action */
  2765. triggerOptions: any, condition?: Condition);
  2766. /**
  2767. * Internal only
  2768. * @hidden
  2769. */
  2770. _prepare(): void;
  2771. /**
  2772. * Gets the trigger parameters
  2773. * @returns the trigger parameters
  2774. */
  2775. getTriggerParameter(): any;
  2776. /**
  2777. * Internal only - executes current action event
  2778. * @hidden
  2779. */
  2780. _executeCurrent(evt?: ActionEvent): void;
  2781. /**
  2782. * Execute placeholder for child classes
  2783. * @param evt optional action event
  2784. */
  2785. execute(evt?: ActionEvent): void;
  2786. /**
  2787. * Skips to next active action
  2788. */
  2789. skipToNextActiveAction(): void;
  2790. /**
  2791. * Adds action to chain of actions, may be a DoNothingAction
  2792. * @param action defines the next action to execute
  2793. * @returns The action passed in
  2794. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2795. */
  2796. then(action: Action): Action;
  2797. /**
  2798. * Internal only
  2799. * @hidden
  2800. */
  2801. _getProperty(propertyPath: string): string;
  2802. /**
  2803. * Internal only
  2804. * @hidden
  2805. */
  2806. _getEffectiveTarget(target: any, propertyPath: string): any;
  2807. /**
  2808. * Serialize placeholder for child classes
  2809. * @param parent of child
  2810. * @returns the serialized object
  2811. */
  2812. serialize(parent: any): any;
  2813. /**
  2814. * Internal only called by serialize
  2815. * @hidden
  2816. */
  2817. protected _serialize(serializedAction: any, parent?: any): any;
  2818. /**
  2819. * Internal only
  2820. * @hidden
  2821. */
  2822. static _SerializeValueAsString: (value: any) => string;
  2823. /**
  2824. * Internal only
  2825. * @hidden
  2826. */
  2827. static _GetTargetProperty: (target: Scene | Node) => {
  2828. name: string;
  2829. targetType: string;
  2830. value: string;
  2831. };
  2832. }
  2833. }
  2834. declare module BABYLON {
  2835. /**
  2836. * ActionEvent is the event being sent when an action is triggered.
  2837. */
  2838. class ActionEvent {
  2839. /** The mesh or sprite that triggered the action */
  2840. source: any;
  2841. /** The X mouse cursor position at the time of the event */
  2842. pointerX: number;
  2843. /** The Y mouse cursor position at the time of the event */
  2844. pointerY: number;
  2845. /** The mesh that is currently pointed at (can be null) */
  2846. meshUnderPointer: Nullable<AbstractMesh>;
  2847. /** the original (browser) event that triggered the ActionEvent */
  2848. sourceEvent?: any;
  2849. /** additional data for the event */
  2850. additionalData?: any;
  2851. /**
  2852. * Creates a new ActionEvent
  2853. * @param source The mesh or sprite that triggered the action
  2854. * @param pointerX The X mouse cursor position at the time of the event
  2855. * @param pointerY The Y mouse cursor position at the time of the event
  2856. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2857. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2858. * @param additionalData additional data for the event
  2859. */
  2860. constructor(
  2861. /** The mesh or sprite that triggered the action */
  2862. source: any,
  2863. /** The X mouse cursor position at the time of the event */
  2864. pointerX: number,
  2865. /** The Y mouse cursor position at the time of the event */
  2866. pointerY: number,
  2867. /** The mesh that is currently pointed at (can be null) */
  2868. meshUnderPointer: Nullable<AbstractMesh>,
  2869. /** the original (browser) event that triggered the ActionEvent */
  2870. sourceEvent?: any,
  2871. /** additional data for the event */
  2872. additionalData?: any);
  2873. /**
  2874. * Helper function to auto-create an ActionEvent from a source mesh.
  2875. * @param source The source mesh that triggered the event
  2876. * @param evt The original (browser) event
  2877. * @param additionalData additional data for the event
  2878. * @returns the new ActionEvent
  2879. */
  2880. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2881. /**
  2882. * Helper function to auto-create an ActionEvent from a source sprite
  2883. * @param source The source sprite that triggered the event
  2884. * @param scene Scene associated with the sprite
  2885. * @param evt The original (browser) event
  2886. * @param additionalData additional data for the event
  2887. * @returns the new ActionEvent
  2888. */
  2889. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2890. /**
  2891. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2892. * @param scene the scene where the event occurred
  2893. * @param evt The original (browser) event
  2894. * @returns the new ActionEvent
  2895. */
  2896. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2897. /**
  2898. * Helper function to auto-create an ActionEvent from a primitive
  2899. * @param prim defines the target primitive
  2900. * @param pointerPos defines the pointer position
  2901. * @param evt The original (browser) event
  2902. * @param additionalData additional data for the event
  2903. * @returns the new ActionEvent
  2904. */
  2905. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2906. }
  2907. /**
  2908. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2909. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2911. */
  2912. class ActionManager {
  2913. /**
  2914. * Nothing
  2915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2916. */
  2917. static readonly NothingTrigger: number;
  2918. /**
  2919. * On pick
  2920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2921. */
  2922. static readonly OnPickTrigger: number;
  2923. /**
  2924. * On left pick
  2925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2926. */
  2927. static readonly OnLeftPickTrigger: number;
  2928. /**
  2929. * On right pick
  2930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2931. */
  2932. static readonly OnRightPickTrigger: number;
  2933. /**
  2934. * On center pick
  2935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2936. */
  2937. static readonly OnCenterPickTrigger: number;
  2938. /**
  2939. * On pick down
  2940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2941. */
  2942. static readonly OnPickDownTrigger: number;
  2943. /**
  2944. * On double pick
  2945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2946. */
  2947. static readonly OnDoublePickTrigger: number;
  2948. /**
  2949. * On pick up
  2950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2951. */
  2952. static readonly OnPickUpTrigger: number;
  2953. /**
  2954. * On pick out.
  2955. * This trigger will only be raised if you also declared a OnPickDown
  2956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2957. */
  2958. static readonly OnPickOutTrigger: number;
  2959. /**
  2960. * On long press
  2961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2962. */
  2963. static readonly OnLongPressTrigger: number;
  2964. /**
  2965. * On pointer over
  2966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2967. */
  2968. static readonly OnPointerOverTrigger: number;
  2969. /**
  2970. * On pointer out
  2971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2972. */
  2973. static readonly OnPointerOutTrigger: number;
  2974. /**
  2975. * On every frame
  2976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2977. */
  2978. static readonly OnEveryFrameTrigger: number;
  2979. /**
  2980. * On intersection enter
  2981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2982. */
  2983. static readonly OnIntersectionEnterTrigger: number;
  2984. /**
  2985. * On intersection exit
  2986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2987. */
  2988. static readonly OnIntersectionExitTrigger: number;
  2989. /**
  2990. * On key down
  2991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2992. */
  2993. static readonly OnKeyDownTrigger: number;
  2994. /**
  2995. * On key up
  2996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2997. */
  2998. static readonly OnKeyUpTrigger: number;
  2999. /** Gets the list of active triggers */
  3000. static Triggers: {
  3001. [key: string]: number;
  3002. };
  3003. /** Gets the list of actions */
  3004. actions: Action[];
  3005. /** Gets the cursor to use when hovering items */
  3006. hoverCursor: string;
  3007. private _scene;
  3008. /**
  3009. * Creates a new action manager
  3010. * @param scene defines the hosting scene
  3011. */
  3012. constructor(scene: Scene);
  3013. /**
  3014. * Releases all associated resources
  3015. */
  3016. dispose(): void;
  3017. /**
  3018. * Gets hosting scene
  3019. * @returns the hosting scene
  3020. */
  3021. getScene(): Scene;
  3022. /**
  3023. * Does this action manager handles actions of any of the given triggers
  3024. * @param triggers defines the triggers to be tested
  3025. * @return a boolean indicating whether one (or more) of the triggers is handled
  3026. */
  3027. hasSpecificTriggers(triggers: number[]): boolean;
  3028. /**
  3029. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3030. * speed.
  3031. * @param triggerA defines the trigger to be tested
  3032. * @param triggerB defines the trigger to be tested
  3033. * @return a boolean indicating whether one (or more) of the triggers is handled
  3034. */
  3035. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3036. /**
  3037. * Does this action manager handles actions of a given trigger
  3038. * @param trigger defines the trigger to be tested
  3039. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3040. * @return whether the trigger is handled
  3041. */
  3042. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3043. /**
  3044. * Does this action manager has pointer triggers
  3045. */
  3046. readonly hasPointerTriggers: boolean;
  3047. /**
  3048. * Does this action manager has pick triggers
  3049. */
  3050. readonly hasPickTriggers: boolean;
  3051. /**
  3052. * Does exist one action manager with at least one trigger
  3053. **/
  3054. static readonly HasTriggers: boolean;
  3055. /**
  3056. * Does exist one action manager with at least one pick trigger
  3057. **/
  3058. static readonly HasPickTriggers: boolean;
  3059. /**
  3060. * Does exist one action manager that handles actions of a given trigger
  3061. * @param trigger defines the trigger to be tested
  3062. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3063. **/
  3064. static HasSpecificTrigger(trigger: number): boolean;
  3065. /**
  3066. * Registers an action to this action manager
  3067. * @param action defines the action to be registered
  3068. * @return the action amended (prepared) after registration
  3069. */
  3070. registerAction(action: Action): Nullable<Action>;
  3071. /**
  3072. * Unregisters an action to this action manager
  3073. * @param action defines the action to be unregistered
  3074. * @return a boolean indicating whether the action has been unregistered
  3075. */
  3076. unregisterAction(action: Action): Boolean;
  3077. /**
  3078. * Process a specific trigger
  3079. * @param trigger defines the trigger to process
  3080. * @param evt defines the event details to be processed
  3081. */
  3082. processTrigger(trigger: number, evt?: ActionEvent): void;
  3083. /** @hidden */
  3084. _getEffectiveTarget(target: any, propertyPath: string): any;
  3085. /** @hidden */
  3086. _getProperty(propertyPath: string): string;
  3087. /**
  3088. * Serialize this manager to a JSON object
  3089. * @param name defines the property name to store this manager
  3090. * @returns a JSON representation of this manager
  3091. */
  3092. serialize(name: string): any;
  3093. /**
  3094. * Creates a new ActionManager from a JSON data
  3095. * @param parsedActions defines the JSON data to read from
  3096. * @param object defines the hosting mesh
  3097. * @param scene defines the hosting scene
  3098. */
  3099. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3100. /**
  3101. * Get a trigger name by index
  3102. * @param trigger defines the trigger index
  3103. * @returns a trigger name
  3104. */
  3105. static GetTriggerName(trigger: number): string;
  3106. }
  3107. }
  3108. declare module BABYLON {
  3109. /**
  3110. * A Condition applied to an Action
  3111. */
  3112. class Condition {
  3113. /**
  3114. * Internal only - manager for action
  3115. * @hidden
  3116. */
  3117. _actionManager: ActionManager;
  3118. /**
  3119. * Internal only
  3120. * @hidden
  3121. */
  3122. _evaluationId: number;
  3123. /**
  3124. * Internal only
  3125. * @hidden
  3126. */
  3127. _currentResult: boolean;
  3128. /**
  3129. * Creates a new Condition
  3130. * @param actionManager the manager of the action the condition is applied to
  3131. */
  3132. constructor(actionManager: ActionManager);
  3133. /**
  3134. * Check if the current condition is valid
  3135. * @returns a boolean
  3136. */
  3137. isValid(): boolean;
  3138. /**
  3139. * Internal only
  3140. * @hidden
  3141. */
  3142. _getProperty(propertyPath: string): string;
  3143. /**
  3144. * Internal only
  3145. * @hidden
  3146. */
  3147. _getEffectiveTarget(target: any, propertyPath: string): any;
  3148. /**
  3149. * Serialize placeholder for child classes
  3150. * @returns the serialized object
  3151. */
  3152. serialize(): any;
  3153. /**
  3154. * Internal only
  3155. * @hidden
  3156. */
  3157. protected _serialize(serializedCondition: any): any;
  3158. }
  3159. /**
  3160. * Defines specific conditional operators as extensions of Condition
  3161. */
  3162. class ValueCondition extends Condition {
  3163. /** path to specify the property of the target the conditional operator uses */
  3164. propertyPath: string;
  3165. /** the value compared by the conditional operator against the current value of the property */
  3166. value: any;
  3167. /** the conditional operator, default ValueCondition.IsEqual */
  3168. operator: number;
  3169. /**
  3170. * Internal only
  3171. * @hidden
  3172. */
  3173. private static _IsEqual;
  3174. /**
  3175. * Internal only
  3176. * @hidden
  3177. */
  3178. private static _IsDifferent;
  3179. /**
  3180. * Internal only
  3181. * @hidden
  3182. */
  3183. private static _IsGreater;
  3184. /**
  3185. * Internal only
  3186. * @hidden
  3187. */
  3188. private static _IsLesser;
  3189. /**
  3190. * returns the number for IsEqual
  3191. */
  3192. static readonly IsEqual: number;
  3193. /**
  3194. * Returns the number for IsDifferent
  3195. */
  3196. static readonly IsDifferent: number;
  3197. /**
  3198. * Returns the number for IsGreater
  3199. */
  3200. static readonly IsGreater: number;
  3201. /**
  3202. * Returns the number for IsLesser
  3203. */
  3204. static readonly IsLesser: number;
  3205. /**
  3206. * Internal only The action manager for the condition
  3207. * @hidden
  3208. */
  3209. _actionManager: ActionManager;
  3210. /**
  3211. * Internal only
  3212. * @hidden
  3213. */
  3214. private _target;
  3215. /**
  3216. * Internal only
  3217. * @hidden
  3218. */
  3219. private _effectiveTarget;
  3220. /**
  3221. * Internal only
  3222. * @hidden
  3223. */
  3224. private _property;
  3225. /**
  3226. * Creates a new ValueCondition
  3227. * @param actionManager manager for the action the condition applies to
  3228. * @param target for the action
  3229. * @param propertyPath path to specify the property of the target the conditional operator uses
  3230. * @param value the value compared by the conditional operator against the current value of the property
  3231. * @param operator the conditional operator, default ValueCondition.IsEqual
  3232. */
  3233. constructor(actionManager: ActionManager, target: any,
  3234. /** path to specify the property of the target the conditional operator uses */
  3235. propertyPath: string,
  3236. /** the value compared by the conditional operator against the current value of the property */
  3237. value: any,
  3238. /** the conditional operator, default ValueCondition.IsEqual */
  3239. operator?: number);
  3240. /**
  3241. * Compares the given value with the property value for the specified conditional operator
  3242. * @returns the result of the comparison
  3243. */
  3244. isValid(): boolean;
  3245. /**
  3246. * Serialize the ValueCondition into a JSON compatible object
  3247. * @returns serialization object
  3248. */
  3249. serialize(): any;
  3250. /**
  3251. * Gets the name of the conditional operator for the ValueCondition
  3252. * @param operator the conditional operator
  3253. * @returns the name
  3254. */
  3255. static GetOperatorName(operator: number): string;
  3256. }
  3257. /**
  3258. * Defines a predicate condition as an extension of Condition
  3259. */
  3260. class PredicateCondition extends Condition {
  3261. /** defines the predicate function used to validate the condition */
  3262. predicate: () => boolean;
  3263. /**
  3264. * Internal only - manager for action
  3265. * @hidden
  3266. */
  3267. _actionManager: ActionManager;
  3268. /**
  3269. * Creates a new PredicateCondition
  3270. * @param actionManager manager for the action the condition applies to
  3271. * @param predicate defines the predicate function used to validate the condition
  3272. */
  3273. constructor(actionManager: ActionManager,
  3274. /** defines the predicate function used to validate the condition */
  3275. predicate: () => boolean);
  3276. /**
  3277. * @returns the validity of the predicate condition
  3278. */
  3279. isValid(): boolean;
  3280. }
  3281. /**
  3282. * Defines a state condition as an extension of Condition
  3283. */
  3284. class StateCondition extends Condition {
  3285. /** Value to compare with target state */
  3286. value: string;
  3287. /**
  3288. * Internal only - manager for action
  3289. * @hidden
  3290. */
  3291. _actionManager: ActionManager;
  3292. /**
  3293. * Internal only
  3294. * @hidden
  3295. */
  3296. private _target;
  3297. /**
  3298. * Creates a new StateCondition
  3299. * @param actionManager manager for the action the condition applies to
  3300. * @param target of the condition
  3301. * @param value to compare with target state
  3302. */
  3303. constructor(actionManager: ActionManager, target: any,
  3304. /** Value to compare with target state */
  3305. value: string);
  3306. /**
  3307. * Gets a boolean indicating if the current condition is met
  3308. * @returns the validity of the state
  3309. */
  3310. isValid(): boolean;
  3311. /**
  3312. * Serialize the StateCondition into a JSON compatible object
  3313. * @returns serialization object
  3314. */
  3315. serialize(): any;
  3316. }
  3317. }
  3318. declare module BABYLON {
  3319. /**
  3320. * This defines an action responsible to toggle a boolean once triggered.
  3321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3322. */
  3323. class SwitchBooleanAction extends Action {
  3324. /**
  3325. * The path to the boolean property in the target object
  3326. */
  3327. propertyPath: string;
  3328. private _target;
  3329. private _effectiveTarget;
  3330. private _property;
  3331. /**
  3332. * Instantiate the action
  3333. * @param triggerOptions defines the trigger options
  3334. * @param target defines the object containing the boolean
  3335. * @param propertyPath defines the path to the boolean property in the target object
  3336. * @param condition defines the trigger related conditions
  3337. */
  3338. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3339. /** @hidden */
  3340. _prepare(): void;
  3341. /**
  3342. * Execute the action toggle the boolean value.
  3343. */
  3344. execute(): void;
  3345. /**
  3346. * Serializes the actions and its related information.
  3347. * @param parent defines the object to serialize in
  3348. * @returns the serialized object
  3349. */
  3350. serialize(parent: any): any;
  3351. }
  3352. /**
  3353. * This defines an action responsible to set a the state field of the target
  3354. * to a desired value once triggered.
  3355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3356. */
  3357. class SetStateAction extends Action {
  3358. /**
  3359. * The value to store in the state field.
  3360. */
  3361. value: string;
  3362. private _target;
  3363. /**
  3364. * Instantiate the action
  3365. * @param triggerOptions defines the trigger options
  3366. * @param target defines the object containing the state property
  3367. * @param value defines the value to store in the state field
  3368. * @param condition defines the trigger related conditions
  3369. */
  3370. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3371. /**
  3372. * Execute the action and store the value on the target state property.
  3373. */
  3374. execute(): void;
  3375. /**
  3376. * Serializes the actions and its related information.
  3377. * @param parent defines the object to serialize in
  3378. * @returns the serialized object
  3379. */
  3380. serialize(parent: any): any;
  3381. }
  3382. /**
  3383. * This defines an action responsible to set a property of the target
  3384. * to a desired value once triggered.
  3385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3386. */
  3387. class SetValueAction extends Action {
  3388. /**
  3389. * The path of the property to set in the target.
  3390. */
  3391. propertyPath: string;
  3392. /**
  3393. * The value to set in the property
  3394. */
  3395. value: any;
  3396. private _target;
  3397. private _effectiveTarget;
  3398. private _property;
  3399. /**
  3400. * Instantiate the action
  3401. * @param triggerOptions defines the trigger options
  3402. * @param target defines the object containing the property
  3403. * @param propertyPath defines the path of the property to set in the target
  3404. * @param value defines the value to set in the property
  3405. * @param condition defines the trigger related conditions
  3406. */
  3407. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3408. /** @hidden */
  3409. _prepare(): void;
  3410. /**
  3411. * Execute the action and set the targetted property to the desired value.
  3412. */
  3413. execute(): void;
  3414. /**
  3415. * Serializes the actions and its related information.
  3416. * @param parent defines the object to serialize in
  3417. * @returns the serialized object
  3418. */
  3419. serialize(parent: any): any;
  3420. }
  3421. /**
  3422. * This defines an action responsible to increment the target value
  3423. * to a desired value once triggered.
  3424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3425. */
  3426. class IncrementValueAction extends Action {
  3427. /**
  3428. * The path of the property to increment in the target.
  3429. */
  3430. propertyPath: string;
  3431. /**
  3432. * The value we should increment the property by.
  3433. */
  3434. value: any;
  3435. private _target;
  3436. private _effectiveTarget;
  3437. private _property;
  3438. /**
  3439. * Instantiate the action
  3440. * @param triggerOptions defines the trigger options
  3441. * @param target defines the object containing the property
  3442. * @param propertyPath defines the path of the property to increment in the target
  3443. * @param value defines the value value we should increment the property by
  3444. * @param condition defines the trigger related conditions
  3445. */
  3446. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3447. /** @hidden */
  3448. _prepare(): void;
  3449. /**
  3450. * Execute the action and increment the target of the value amount.
  3451. */
  3452. execute(): void;
  3453. /**
  3454. * Serializes the actions and its related information.
  3455. * @param parent defines the object to serialize in
  3456. * @returns the serialized object
  3457. */
  3458. serialize(parent: any): any;
  3459. }
  3460. /**
  3461. * This defines an action responsible to start an animation once triggered.
  3462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3463. */
  3464. class PlayAnimationAction extends Action {
  3465. /**
  3466. * Where the animation should start (animation frame)
  3467. */
  3468. from: number;
  3469. /**
  3470. * Where the animation should stop (animation frame)
  3471. */
  3472. to: number;
  3473. /**
  3474. * Define if the animation should loop or stop after the first play.
  3475. */
  3476. loop?: boolean;
  3477. private _target;
  3478. /**
  3479. * Instantiate the action
  3480. * @param triggerOptions defines the trigger options
  3481. * @param target defines the target animation or animation name
  3482. * @param from defines from where the animation should start (animation frame)
  3483. * @param end defines where the animation should stop (animation frame)
  3484. * @param loop defines if the animation should loop or stop after the first play
  3485. * @param condition defines the trigger related conditions
  3486. */
  3487. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3488. /** @hidden */
  3489. _prepare(): void;
  3490. /**
  3491. * Execute the action and play the animation.
  3492. */
  3493. execute(): void;
  3494. /**
  3495. * Serializes the actions and its related information.
  3496. * @param parent defines the object to serialize in
  3497. * @returns the serialized object
  3498. */
  3499. serialize(parent: any): any;
  3500. }
  3501. /**
  3502. * This defines an action responsible to stop an animation once triggered.
  3503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3504. */
  3505. class StopAnimationAction extends Action {
  3506. private _target;
  3507. /**
  3508. * Instantiate the action
  3509. * @param triggerOptions defines the trigger options
  3510. * @param target defines the target animation or animation name
  3511. * @param condition defines the trigger related conditions
  3512. */
  3513. constructor(triggerOptions: any, target: any, condition?: Condition);
  3514. /** @hidden */
  3515. _prepare(): void;
  3516. /**
  3517. * Execute the action and stop the animation.
  3518. */
  3519. execute(): void;
  3520. /**
  3521. * Serializes the actions and its related information.
  3522. * @param parent defines the object to serialize in
  3523. * @returns the serialized object
  3524. */
  3525. serialize(parent: any): any;
  3526. }
  3527. /**
  3528. * This defines an action responsible that does nothing once triggered.
  3529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3530. */
  3531. class DoNothingAction extends Action {
  3532. /**
  3533. * Instantiate the action
  3534. * @param triggerOptions defines the trigger options
  3535. * @param condition defines the trigger related conditions
  3536. */
  3537. constructor(triggerOptions?: any, condition?: Condition);
  3538. /**
  3539. * Execute the action and do nothing.
  3540. */
  3541. execute(): void;
  3542. /**
  3543. * Serializes the actions and its related information.
  3544. * @param parent defines the object to serialize in
  3545. * @returns the serialized object
  3546. */
  3547. serialize(parent: any): any;
  3548. }
  3549. /**
  3550. * This defines an action responsible to trigger several actions once triggered.
  3551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3552. */
  3553. class CombineAction extends Action {
  3554. /**
  3555. * The list of aggregated animations to run.
  3556. */
  3557. children: Action[];
  3558. /**
  3559. * Instantiate the action
  3560. * @param triggerOptions defines the trigger options
  3561. * @param children defines the list of aggregated animations to run
  3562. * @param condition defines the trigger related conditions
  3563. */
  3564. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3565. /** @hidden */
  3566. _prepare(): void;
  3567. /**
  3568. * Execute the action and executes all the aggregated actions.
  3569. */
  3570. execute(evt: ActionEvent): void;
  3571. /**
  3572. * Serializes the actions and its related information.
  3573. * @param parent defines the object to serialize in
  3574. * @returns the serialized object
  3575. */
  3576. serialize(parent: any): any;
  3577. }
  3578. /**
  3579. * This defines an action responsible to run code (external event) once triggered.
  3580. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3581. */
  3582. class ExecuteCodeAction extends Action {
  3583. /**
  3584. * The callback function to run.
  3585. */
  3586. func: (evt: ActionEvent) => void;
  3587. /**
  3588. * Instantiate the action
  3589. * @param triggerOptions defines the trigger options
  3590. * @param func defines the callback function to run
  3591. * @param condition defines the trigger related conditions
  3592. */
  3593. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3594. /**
  3595. * Execute the action and run the attached code.
  3596. */
  3597. execute(evt: ActionEvent): void;
  3598. }
  3599. /**
  3600. * This defines an action responsible to set the parent property of the target once triggered.
  3601. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3602. */
  3603. class SetParentAction extends Action {
  3604. private _parent;
  3605. private _target;
  3606. /**
  3607. * Instantiate the action
  3608. * @param triggerOptions defines the trigger options
  3609. * @param target defines the target containing the parent property
  3610. * @param parent defines from where the animation should start (animation frame)
  3611. * @param condition defines the trigger related conditions
  3612. */
  3613. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3614. /** @hidden */
  3615. _prepare(): void;
  3616. /**
  3617. * Execute the action and set the parent property.
  3618. */
  3619. execute(): void;
  3620. /**
  3621. * Serializes the actions and its related information.
  3622. * @param parent defines the object to serialize in
  3623. * @returns the serialized object
  3624. */
  3625. serialize(parent: any): any;
  3626. }
  3627. }
  3628. declare module BABYLON {
  3629. /**
  3630. * This defines an action helpful to play a defined sound on a triggered action.
  3631. */
  3632. class PlaySoundAction extends Action {
  3633. private _sound;
  3634. /**
  3635. * Instantiate the action
  3636. * @param triggerOptions defines the trigger options
  3637. * @param sound defines the sound to play
  3638. * @param condition defines the trigger related conditions
  3639. */
  3640. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3641. /** @hidden */
  3642. _prepare(): void;
  3643. /**
  3644. * Execute the action and play the sound.
  3645. */
  3646. execute(): void;
  3647. /**
  3648. * Serializes the actions and its related information.
  3649. * @param parent defines the object to serialize in
  3650. * @returns the serialized object
  3651. */
  3652. serialize(parent: any): any;
  3653. }
  3654. /**
  3655. * This defines an action helpful to stop a defined sound on a triggered action.
  3656. */
  3657. class StopSoundAction extends Action {
  3658. private _sound;
  3659. /**
  3660. * Instantiate the action
  3661. * @param triggerOptions defines the trigger options
  3662. * @param sound defines the sound to stop
  3663. * @param condition defines the trigger related conditions
  3664. */
  3665. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3666. /** @hidden */
  3667. _prepare(): void;
  3668. /**
  3669. * Execute the action and stop the sound.
  3670. */
  3671. execute(): void;
  3672. /**
  3673. * Serializes the actions and its related information.
  3674. * @param parent defines the object to serialize in
  3675. * @returns the serialized object
  3676. */
  3677. serialize(parent: any): any;
  3678. }
  3679. }
  3680. declare module BABYLON {
  3681. /**
  3682. * This defines an action responsible to change the value of a property
  3683. * by interpolating between its current value and the newly set one once triggered.
  3684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3685. */
  3686. class InterpolateValueAction extends Action {
  3687. /**
  3688. * Defines the path of the property where the value should be interpolated
  3689. */
  3690. propertyPath: string;
  3691. /**
  3692. * Defines the target value at the end of the interpolation.
  3693. */
  3694. value: any;
  3695. /**
  3696. * Defines the time it will take for the property to interpolate to the value.
  3697. */
  3698. duration: number;
  3699. /**
  3700. * Defines if the other scene animations should be stopped when the action has been triggered
  3701. */
  3702. stopOtherAnimations?: boolean;
  3703. /**
  3704. * Defines a callback raised once the interpolation animation has been done.
  3705. */
  3706. onInterpolationDone?: () => void;
  3707. /**
  3708. * Observable triggered once the interpolation animation has been done.
  3709. */
  3710. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3711. private _target;
  3712. private _effectiveTarget;
  3713. private _property;
  3714. /**
  3715. * Instantiate the action
  3716. * @param triggerOptions defines the trigger options
  3717. * @param target defines the object containing the value to interpolate
  3718. * @param propertyPath defines the path to the property in the target object
  3719. * @param value defines the target value at the end of the interpolation
  3720. * @param duration deines the time it will take for the property to interpolate to the value.
  3721. * @param condition defines the trigger related conditions
  3722. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3723. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3724. */
  3725. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3726. /** @hidden */
  3727. _prepare(): void;
  3728. /**
  3729. * Execute the action starts the value interpolation.
  3730. */
  3731. execute(): void;
  3732. /**
  3733. * Serializes the actions and its related information.
  3734. * @param parent defines the object to serialize in
  3735. * @returns the serialized object
  3736. */
  3737. serialize(parent: any): any;
  3738. }
  3739. }
  3740. declare module BABYLON {
  3741. /**
  3742. * Class used to store an actual running animation
  3743. */
  3744. class Animatable {
  3745. /** defines the target object */
  3746. target: any;
  3747. /** defines the starting frame number (default is 0) */
  3748. fromFrame: number;
  3749. /** defines the ending frame number (default is 100) */
  3750. toFrame: number;
  3751. /** defines if the animation must loop (default is false) */
  3752. loopAnimation: boolean;
  3753. /** defines a callback to call when animation ends if it is not looping */
  3754. onAnimationEnd?: (() => void) | null | undefined;
  3755. private _localDelayOffset;
  3756. private _pausedDelay;
  3757. private _runtimeAnimations;
  3758. private _paused;
  3759. private _scene;
  3760. private _speedRatio;
  3761. private _weight;
  3762. private _syncRoot;
  3763. /**
  3764. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3765. * This will only apply for non looping animation (default is true)
  3766. */
  3767. disposeOnEnd: boolean;
  3768. /**
  3769. * Gets a boolean indicating if the animation has started
  3770. */
  3771. animationStarted: boolean;
  3772. /**
  3773. * Observer raised when the animation ends
  3774. */
  3775. onAnimationEndObservable: Observable<Animatable>;
  3776. /**
  3777. * Gets the root Animatable used to synchronize and normalize animations
  3778. */
  3779. readonly syncRoot: Animatable;
  3780. /**
  3781. * Gets the current frame of the first RuntimeAnimation
  3782. * Used to synchronize Animatables
  3783. */
  3784. readonly masterFrame: number;
  3785. /**
  3786. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3787. */
  3788. weight: number;
  3789. /**
  3790. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3791. */
  3792. speedRatio: number;
  3793. /**
  3794. * Creates a new Animatable
  3795. * @param scene defines the hosting scene
  3796. * @param target defines the target object
  3797. * @param fromFrame defines the starting frame number (default is 0)
  3798. * @param toFrame defines the ending frame number (default is 100)
  3799. * @param loopAnimation defines if the animation must loop (default is false)
  3800. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3801. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3802. * @param animations defines a group of animation to add to the new Animatable
  3803. */
  3804. constructor(scene: Scene,
  3805. /** defines the target object */
  3806. target: any,
  3807. /** defines the starting frame number (default is 0) */
  3808. fromFrame?: number,
  3809. /** defines the ending frame number (default is 100) */
  3810. toFrame?: number,
  3811. /** defines if the animation must loop (default is false) */
  3812. loopAnimation?: boolean, speedRatio?: number,
  3813. /** defines a callback to call when animation ends if it is not looping */
  3814. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3815. /**
  3816. * Synchronize and normalize current Animatable with a source Animatable
  3817. * This is useful when using animation weights and when animations are not of the same length
  3818. * @param root defines the root Animatable to synchronize with
  3819. * @returns the current Animatable
  3820. */
  3821. syncWith(root: Animatable): Animatable;
  3822. /**
  3823. * Gets the list of runtime animations
  3824. * @returns an array of RuntimeAnimation
  3825. */
  3826. getAnimations(): RuntimeAnimation[];
  3827. /**
  3828. * Adds more animations to the current animatable
  3829. * @param target defines the target of the animations
  3830. * @param animations defines the new animations to add
  3831. */
  3832. appendAnimations(target: any, animations: Animation[]): void;
  3833. /**
  3834. * Gets the source animation for a specific property
  3835. * @param property defines the propertyu to look for
  3836. * @returns null or the source animation for the given property
  3837. */
  3838. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3839. /**
  3840. * Gets the runtime animation for a specific property
  3841. * @param property defines the propertyu to look for
  3842. * @returns null or the runtime animation for the given property
  3843. */
  3844. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3845. /**
  3846. * Resets the animatable to its original state
  3847. */
  3848. reset(): void;
  3849. /**
  3850. * Allows the animatable to blend with current running animations
  3851. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3852. * @param blendingSpeed defines the blending speed to use
  3853. */
  3854. enableBlending(blendingSpeed: number): void;
  3855. /**
  3856. * Disable animation blending
  3857. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3858. */
  3859. disableBlending(): void;
  3860. /**
  3861. * Jump directly to a given frame
  3862. * @param frame defines the frame to jump to
  3863. */
  3864. goToFrame(frame: number): void;
  3865. /**
  3866. * Pause the animation
  3867. */
  3868. pause(): void;
  3869. /**
  3870. * Restart the animation
  3871. */
  3872. restart(): void;
  3873. private _raiseOnAnimationEnd;
  3874. /**
  3875. * Stop and delete the current animation
  3876. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3877. * @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)
  3878. */
  3879. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3880. /**
  3881. * Wait asynchronously for the animation to end
  3882. * @returns a promise which will be fullfilled when the animation ends
  3883. */
  3884. waitAsync(): Promise<Animatable>;
  3885. /** @hidden */
  3886. _animate(delay: number): boolean;
  3887. }
  3888. }
  3889. declare module BABYLON {
  3890. /**
  3891. * Represents the range of an animation
  3892. */
  3893. class AnimationRange {
  3894. /**The name of the animation range**/
  3895. name: string;
  3896. /**The starting frame of the animation */
  3897. from: number;
  3898. /**The ending frame of the animation*/
  3899. to: number;
  3900. /**
  3901. * Initializes the range of an animation
  3902. * @param name The name of the animation range
  3903. * @param from The starting frame of the animation
  3904. * @param to The ending frame of the animation
  3905. */
  3906. constructor(
  3907. /**The name of the animation range**/
  3908. name: string,
  3909. /**The starting frame of the animation */
  3910. from: number,
  3911. /**The ending frame of the animation*/
  3912. to: number);
  3913. /**
  3914. * Makes a copy of the animation range
  3915. * @returns A copy of the animation range
  3916. */
  3917. clone(): AnimationRange;
  3918. }
  3919. /**
  3920. * Composed of a frame, and an action function
  3921. */
  3922. class AnimationEvent {
  3923. /** The frame for which the event is triggered **/
  3924. frame: number;
  3925. /** The event to perform when triggered **/
  3926. action: (currentFrame: number) => void;
  3927. /** Specifies if the event should be triggered only once**/
  3928. onlyOnce?: boolean | undefined;
  3929. /**
  3930. * Specifies if the animation event is done
  3931. */
  3932. isDone: boolean;
  3933. /**
  3934. * Initializes the animation event
  3935. * @param frame The frame for which the event is triggered
  3936. * @param action The event to perform when triggered
  3937. * @param onlyOnce Specifies if the event should be triggered only once
  3938. */
  3939. constructor(
  3940. /** The frame for which the event is triggered **/
  3941. frame: number,
  3942. /** The event to perform when triggered **/
  3943. action: (currentFrame: number) => void,
  3944. /** Specifies if the event should be triggered only once**/
  3945. onlyOnce?: boolean | undefined);
  3946. /** @hidden */
  3947. _clone(): AnimationEvent;
  3948. }
  3949. /**
  3950. * A cursor which tracks a point on a path
  3951. */
  3952. class PathCursor {
  3953. private path;
  3954. /**
  3955. * Stores path cursor callbacks for when an onchange event is triggered
  3956. */
  3957. private _onchange;
  3958. /**
  3959. * The value of the path cursor
  3960. */
  3961. value: number;
  3962. /**
  3963. * The animation array of the path cursor
  3964. */
  3965. animations: Animation[];
  3966. /**
  3967. * Initializes the path cursor
  3968. * @param path The path to track
  3969. */
  3970. constructor(path: Path2);
  3971. /**
  3972. * Gets the cursor point on the path
  3973. * @returns A point on the path cursor at the cursor location
  3974. */
  3975. getPoint(): Vector3;
  3976. /**
  3977. * Moves the cursor ahead by the step amount
  3978. * @param step The amount to move the cursor forward
  3979. * @returns This path cursor
  3980. */
  3981. moveAhead(step?: number): PathCursor;
  3982. /**
  3983. * Moves the cursor behind by the step amount
  3984. * @param step The amount to move the cursor back
  3985. * @returns This path cursor
  3986. */
  3987. moveBack(step?: number): PathCursor;
  3988. /**
  3989. * Moves the cursor by the step amount
  3990. * If the step amount is greater than one, an exception is thrown
  3991. * @param step The amount to move the cursor
  3992. * @returns This path cursor
  3993. */
  3994. move(step: number): PathCursor;
  3995. /**
  3996. * Ensures that the value is limited between zero and one
  3997. * @returns This path cursor
  3998. */
  3999. private ensureLimits;
  4000. /**
  4001. * Runs onchange callbacks on change (used by the animation engine)
  4002. * @returns This path cursor
  4003. */
  4004. private raiseOnChange;
  4005. /**
  4006. * Executes a function on change
  4007. * @param f A path cursor onchange callback
  4008. * @returns This path cursor
  4009. */
  4010. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4011. }
  4012. /**
  4013. * Defines an interface which represents an animation key frame
  4014. */
  4015. interface IAnimationKey {
  4016. /**
  4017. * Frame of the key frame
  4018. */
  4019. frame: number;
  4020. /**
  4021. * Value at the specifies key frame
  4022. */
  4023. value: any;
  4024. /**
  4025. * The input tangent for the cubic hermite spline
  4026. */
  4027. inTangent?: any;
  4028. /**
  4029. * The output tangent for the cubic hermite spline
  4030. */
  4031. outTangent?: any;
  4032. /**
  4033. * The animation interpolation type
  4034. */
  4035. interpolation?: AnimationKeyInterpolation;
  4036. }
  4037. /**
  4038. * Enum for the animation key frame interpolation type
  4039. */
  4040. enum AnimationKeyInterpolation {
  4041. /**
  4042. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4043. */
  4044. STEP = 1
  4045. }
  4046. /**
  4047. * Class used to store any kind of animation
  4048. */
  4049. class Animation {
  4050. /**Name of the animation */
  4051. name: string;
  4052. /**Property to animate */
  4053. targetProperty: string;
  4054. /**The frames per second of the animation */
  4055. framePerSecond: number;
  4056. /**The data type of the animation */
  4057. dataType: number;
  4058. /**The loop mode of the animation */
  4059. loopMode?: number | undefined;
  4060. /**Specifies if blending should be enabled */
  4061. enableBlending?: boolean | undefined;
  4062. /**
  4063. * Use matrix interpolation instead of using direct key value when animating matrices
  4064. */
  4065. static AllowMatricesInterpolation: boolean;
  4066. /**
  4067. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4068. */
  4069. static AllowMatrixDecomposeForInterpolation: boolean;
  4070. /**
  4071. * Stores the key frames of the animation
  4072. */
  4073. private _keys;
  4074. /**
  4075. * Stores the easing function of the animation
  4076. */
  4077. private _easingFunction;
  4078. /**
  4079. * @hidden Internal use only
  4080. */
  4081. _runtimeAnimations: RuntimeAnimation[];
  4082. /**
  4083. * The set of event that will be linked to this animation
  4084. */
  4085. private _events;
  4086. /**
  4087. * Stores an array of target property paths
  4088. */
  4089. targetPropertyPath: string[];
  4090. /**
  4091. * Stores the blending speed of the animation
  4092. */
  4093. blendingSpeed: number;
  4094. /**
  4095. * Stores the animation ranges for the animation
  4096. */
  4097. private _ranges;
  4098. /**
  4099. * @hidden Internal use
  4100. */
  4101. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4102. /**
  4103. * Sets up an animation
  4104. * @param property The property to animate
  4105. * @param animationType The animation type to apply
  4106. * @param framePerSecond The frames per second of the animation
  4107. * @param easingFunction The easing function used in the animation
  4108. * @returns The created animation
  4109. */
  4110. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4111. /**
  4112. * Create and start an animation on a node
  4113. * @param name defines the name of the global animation that will be run on all nodes
  4114. * @param node defines the root node where the animation will take place
  4115. * @param targetProperty defines property to animate
  4116. * @param framePerSecond defines the number of frame per second yo use
  4117. * @param totalFrame defines the number of frames in total
  4118. * @param from defines the initial value
  4119. * @param to defines the final value
  4120. * @param loopMode defines which loop mode you want to use (off by default)
  4121. * @param easingFunction defines the easing function to use (linear by default)
  4122. * @param onAnimationEnd defines the callback to call when animation end
  4123. * @returns the animatable created for this animation
  4124. */
  4125. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4126. /**
  4127. * Create and start an animation on a node and its descendants
  4128. * @param name defines the name of the global animation that will be run on all nodes
  4129. * @param node defines the root node where the animation will take place
  4130. * @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
  4131. * @param targetProperty defines property to animate
  4132. * @param framePerSecond defines the number of frame per second to use
  4133. * @param totalFrame defines the number of frames in total
  4134. * @param from defines the initial value
  4135. * @param to defines the final value
  4136. * @param loopMode defines which loop mode you want to use (off by default)
  4137. * @param easingFunction defines the easing function to use (linear by default)
  4138. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4139. * @returns the list of animatables created for all nodes
  4140. * @example https://www.babylonjs-playground.com/#MH0VLI
  4141. */
  4142. 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[]>;
  4143. /**
  4144. * Creates a new animation, merges it with the existing animations and starts it
  4145. * @param name Name of the animation
  4146. * @param node Node which contains the scene that begins the animations
  4147. * @param targetProperty Specifies which property to animate
  4148. * @param framePerSecond The frames per second of the animation
  4149. * @param totalFrame The total number of frames
  4150. * @param from The frame at the beginning of the animation
  4151. * @param to The frame at the end of the animation
  4152. * @param loopMode Specifies the loop mode of the animation
  4153. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4154. * @param onAnimationEnd Callback to run once the animation is complete
  4155. * @returns Nullable animation
  4156. */
  4157. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4158. /**
  4159. * Transition property of an host to the target Value
  4160. * @param property The property to transition
  4161. * @param targetValue The target Value of the property
  4162. * @param host The object where the property to animate belongs
  4163. * @param scene Scene used to run the animation
  4164. * @param frameRate Framerate (in frame/s) to use
  4165. * @param transition The transition type we want to use
  4166. * @param duration The duration of the animation, in milliseconds
  4167. * @param onAnimationEnd Callback trigger at the end of the animation
  4168. * @returns Nullable animation
  4169. */
  4170. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4171. /**
  4172. * Return the array of runtime animations currently using this animation
  4173. */
  4174. readonly runtimeAnimations: RuntimeAnimation[];
  4175. /**
  4176. * Specifies if any of the runtime animations are currently running
  4177. */
  4178. readonly hasRunningRuntimeAnimations: boolean;
  4179. /**
  4180. * Initializes the animation
  4181. * @param name Name of the animation
  4182. * @param targetProperty Property to animate
  4183. * @param framePerSecond The frames per second of the animation
  4184. * @param dataType The data type of the animation
  4185. * @param loopMode The loop mode of the animation
  4186. * @param enableBlendings Specifies if blending should be enabled
  4187. */
  4188. constructor(
  4189. /**Name of the animation */
  4190. name: string,
  4191. /**Property to animate */
  4192. targetProperty: string,
  4193. /**The frames per second of the animation */
  4194. framePerSecond: number,
  4195. /**The data type of the animation */
  4196. dataType: number,
  4197. /**The loop mode of the animation */
  4198. loopMode?: number | undefined,
  4199. /**Specifies if blending should be enabled */
  4200. enableBlending?: boolean | undefined);
  4201. /**
  4202. * Converts the animation to a string
  4203. * @param fullDetails support for multiple levels of logging within scene loading
  4204. * @returns String form of the animation
  4205. */
  4206. toString(fullDetails?: boolean): string;
  4207. /**
  4208. * Add an event to this animation
  4209. * @param event Event to add
  4210. */
  4211. addEvent(event: AnimationEvent): void;
  4212. /**
  4213. * Remove all events found at the given frame
  4214. * @param frame The frame to remove events from
  4215. */
  4216. removeEvents(frame: number): void;
  4217. /**
  4218. * Retrieves all the events from the animation
  4219. * @returns Events from the animation
  4220. */
  4221. getEvents(): AnimationEvent[];
  4222. /**
  4223. * Creates an animation range
  4224. * @param name Name of the animation range
  4225. * @param from Starting frame of the animation range
  4226. * @param to Ending frame of the animation
  4227. */
  4228. createRange(name: string, from: number, to: number): void;
  4229. /**
  4230. * Deletes an animation range by name
  4231. * @param name Name of the animation range to delete
  4232. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4233. */
  4234. deleteRange(name: string, deleteFrames?: boolean): void;
  4235. /**
  4236. * Gets the animation range by name, or null if not defined
  4237. * @param name Name of the animation range
  4238. * @returns Nullable animation range
  4239. */
  4240. getRange(name: string): Nullable<AnimationRange>;
  4241. /**
  4242. * Gets the key frames from the animation
  4243. * @returns The key frames of the animation
  4244. */
  4245. getKeys(): Array<IAnimationKey>;
  4246. /**
  4247. * Gets the highest frame rate of the animation
  4248. * @returns Highest frame rate of the animation
  4249. */
  4250. getHighestFrame(): number;
  4251. /**
  4252. * Gets the easing function of the animation
  4253. * @returns Easing function of the animation
  4254. */
  4255. getEasingFunction(): IEasingFunction;
  4256. /**
  4257. * Sets the easing function of the animation
  4258. * @param easingFunction A custom mathematical formula for animation
  4259. */
  4260. setEasingFunction(easingFunction: EasingFunction): void;
  4261. /**
  4262. * Interpolates a scalar linearly
  4263. * @param startValue Start value of the animation curve
  4264. * @param endValue End value of the animation curve
  4265. * @param gradient Scalar amount to interpolate
  4266. * @returns Interpolated scalar value
  4267. */
  4268. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4269. /**
  4270. * Interpolates a scalar cubically
  4271. * @param startValue Start value of the animation curve
  4272. * @param outTangent End tangent of the animation
  4273. * @param endValue End value of the animation curve
  4274. * @param inTangent Start tangent of the animation curve
  4275. * @param gradient Scalar amount to interpolate
  4276. * @returns Interpolated scalar value
  4277. */
  4278. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4279. /**
  4280. * Interpolates a quaternion using a spherical linear interpolation
  4281. * @param startValue Start value of the animation curve
  4282. * @param endValue End value of the animation curve
  4283. * @param gradient Scalar amount to interpolate
  4284. * @returns Interpolated quaternion value
  4285. */
  4286. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4287. /**
  4288. * Interpolates a quaternion cubically
  4289. * @param startValue Start value of the animation curve
  4290. * @param outTangent End tangent of the animation curve
  4291. * @param endValue End value of the animation curve
  4292. * @param inTangent Start tangent of the animation curve
  4293. * @param gradient Scalar amount to interpolate
  4294. * @returns Interpolated quaternion value
  4295. */
  4296. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4297. /**
  4298. * Interpolates a Vector3 linearl
  4299. * @param startValue Start value of the animation curve
  4300. * @param endValue End value of the animation curve
  4301. * @param gradient Scalar amount to interpolate
  4302. * @returns Interpolated scalar value
  4303. */
  4304. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4305. /**
  4306. * Interpolates a Vector3 cubically
  4307. * @param startValue Start value of the animation curve
  4308. * @param outTangent End tangent of the animation
  4309. * @param endValue End value of the animation curve
  4310. * @param inTangent Start tangent of the animation curve
  4311. * @param gradient Scalar amount to interpolate
  4312. * @returns InterpolatedVector3 value
  4313. */
  4314. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4315. /**
  4316. * Interpolates a Vector2 linearly
  4317. * @param startValue Start value of the animation curve
  4318. * @param endValue End value of the animation curve
  4319. * @param gradient Scalar amount to interpolate
  4320. * @returns Interpolated Vector2 value
  4321. */
  4322. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4323. /**
  4324. * Interpolates a Vector2 cubically
  4325. * @param startValue Start value of the animation curve
  4326. * @param outTangent End tangent of the animation
  4327. * @param endValue End value of the animation curve
  4328. * @param inTangent Start tangent of the animation curve
  4329. * @param gradient Scalar amount to interpolate
  4330. * @returns Interpolated Vector2 value
  4331. */
  4332. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4333. /**
  4334. * Interpolates a size linearly
  4335. * @param startValue Start value of the animation curve
  4336. * @param endValue End value of the animation curve
  4337. * @param gradient Scalar amount to interpolate
  4338. * @returns Interpolated Size value
  4339. */
  4340. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4341. /**
  4342. * Interpolates a Color3 linearly
  4343. * @param startValue Start value of the animation curve
  4344. * @param endValue End value of the animation curve
  4345. * @param gradient Scalar amount to interpolate
  4346. * @returns Interpolated Color3 value
  4347. */
  4348. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4349. /**
  4350. * @hidden Internal use only
  4351. */
  4352. _getKeyValue(value: any): any;
  4353. /**
  4354. * @hidden Internal use only
  4355. */
  4356. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4357. /**
  4358. * Defines the function to use to interpolate matrices
  4359. * @param startValue defines the start matrix
  4360. * @param endValue defines the end matrix
  4361. * @param gradient defines the gradient between both matrices
  4362. * @param result defines an optional target matrix where to store the interpolation
  4363. * @returns the interpolated matrix
  4364. */
  4365. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4366. /**
  4367. * Makes a copy of the animation
  4368. * @returns Cloned animation
  4369. */
  4370. clone(): Animation;
  4371. /**
  4372. * Sets the key frames of the animation
  4373. * @param values The animation key frames to set
  4374. */
  4375. setKeys(values: Array<IAnimationKey>): void;
  4376. /**
  4377. * Serializes the animation to an object
  4378. * @returns Serialized object
  4379. */
  4380. serialize(): any;
  4381. /**
  4382. * Float animation type
  4383. */
  4384. private static _ANIMATIONTYPE_FLOAT;
  4385. /**
  4386. * Vector3 animation type
  4387. */
  4388. private static _ANIMATIONTYPE_VECTOR3;
  4389. /**
  4390. * Quaternion animation type
  4391. */
  4392. private static _ANIMATIONTYPE_QUATERNION;
  4393. /**
  4394. * Matrix animation type
  4395. */
  4396. private static _ANIMATIONTYPE_MATRIX;
  4397. /**
  4398. * Color3 animation type
  4399. */
  4400. private static _ANIMATIONTYPE_COLOR3;
  4401. /**
  4402. * Vector2 animation type
  4403. */
  4404. private static _ANIMATIONTYPE_VECTOR2;
  4405. /**
  4406. * Size animation type
  4407. */
  4408. private static _ANIMATIONTYPE_SIZE;
  4409. /**
  4410. * Relative Loop Mode
  4411. */
  4412. private static _ANIMATIONLOOPMODE_RELATIVE;
  4413. /**
  4414. * Cycle Loop Mode
  4415. */
  4416. private static _ANIMATIONLOOPMODE_CYCLE;
  4417. /**
  4418. * Constant Loop Mode
  4419. */
  4420. private static _ANIMATIONLOOPMODE_CONSTANT;
  4421. /**
  4422. * Get the float animation type
  4423. */
  4424. static readonly ANIMATIONTYPE_FLOAT: number;
  4425. /**
  4426. * Get the Vector3 animation type
  4427. */
  4428. static readonly ANIMATIONTYPE_VECTOR3: number;
  4429. /**
  4430. * Get the Vector2 animation type
  4431. */
  4432. static readonly ANIMATIONTYPE_VECTOR2: number;
  4433. /**
  4434. * Get the Size animation type
  4435. */
  4436. static readonly ANIMATIONTYPE_SIZE: number;
  4437. /**
  4438. * Get the Quaternion animation type
  4439. */
  4440. static readonly ANIMATIONTYPE_QUATERNION: number;
  4441. /**
  4442. * Get the Matrix animation type
  4443. */
  4444. static readonly ANIMATIONTYPE_MATRIX: number;
  4445. /**
  4446. * Get the Color3 animation type
  4447. */
  4448. static readonly ANIMATIONTYPE_COLOR3: number;
  4449. /**
  4450. * Get the Relative Loop Mode
  4451. */
  4452. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4453. /**
  4454. * Get the Cycle Loop Mode
  4455. */
  4456. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4457. /**
  4458. * Get the Constant Loop Mode
  4459. */
  4460. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4461. /** @hidden */
  4462. static _UniversalLerp(left: any, right: any, amount: number): any;
  4463. /**
  4464. * Parses an animation object and creates an animation
  4465. * @param parsedAnimation Parsed animation object
  4466. * @returns Animation object
  4467. */
  4468. static Parse(parsedAnimation: any): Animation;
  4469. /**
  4470. * Appends the serialized animations from the source animations
  4471. * @param source Source containing the animations
  4472. * @param destination Target to store the animations
  4473. */
  4474. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4475. }
  4476. }
  4477. declare module BABYLON {
  4478. /**
  4479. * This class defines the direct association between an animation and a target
  4480. */
  4481. class TargetedAnimation {
  4482. /**
  4483. * Animation to perform
  4484. */
  4485. animation: Animation;
  4486. /**
  4487. * Target to animate
  4488. */
  4489. target: any;
  4490. }
  4491. /**
  4492. * Use this class to create coordinated animations on multiple targets
  4493. */
  4494. class AnimationGroup implements IDisposable {
  4495. /** The name of the animation group */
  4496. name: string;
  4497. private _scene;
  4498. private _targetedAnimations;
  4499. private _animatables;
  4500. private _from;
  4501. private _to;
  4502. private _isStarted;
  4503. private _speedRatio;
  4504. /**
  4505. * This observable will notify when one animation have ended.
  4506. */
  4507. onAnimationEndObservable: Observable<TargetedAnimation>;
  4508. /**
  4509. * This observable will notify when all animations have ended.
  4510. */
  4511. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4512. /**
  4513. * This observable will notify when all animations have paused.
  4514. */
  4515. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4516. /**
  4517. * Gets the first frame
  4518. */
  4519. readonly from: number;
  4520. /**
  4521. * Gets the last frame
  4522. */
  4523. readonly to: number;
  4524. /**
  4525. * Define if the animations are started
  4526. */
  4527. readonly isStarted: boolean;
  4528. /**
  4529. * Gets or sets the speed ratio to use for all animations
  4530. */
  4531. /**
  4532. * Gets or sets the speed ratio to use for all animations
  4533. */
  4534. speedRatio: number;
  4535. /**
  4536. * Gets the targeted animations for this animation group
  4537. */
  4538. readonly targetedAnimations: Array<TargetedAnimation>;
  4539. /**
  4540. * returning the list of animatables controlled by this animation group.
  4541. */
  4542. readonly animatables: Array<Animatable>;
  4543. /**
  4544. * Instantiates a new Animation Group.
  4545. * This helps managing several animations at once.
  4546. * @see http://doc.babylonjs.com/how_to/group
  4547. * @param name Defines the name of the group
  4548. * @param scene Defines the scene the group belongs to
  4549. */
  4550. constructor(
  4551. /** The name of the animation group */
  4552. name: string, scene?: Nullable<Scene>);
  4553. /**
  4554. * Add an animation (with its target) in the group
  4555. * @param animation defines the animation we want to add
  4556. * @param target defines the target of the animation
  4557. * @returns the TargetedAnimation object
  4558. */
  4559. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4560. /**
  4561. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4562. * It can add constant keys at begin or end
  4563. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4564. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4565. * @returns the animation group
  4566. */
  4567. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4568. /**
  4569. * Start all animations on given targets
  4570. * @param loop defines if animations must loop
  4571. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4572. * @param from defines the from key (optional)
  4573. * @param to defines the to key (optional)
  4574. * @returns the current animation group
  4575. */
  4576. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4577. /**
  4578. * Pause all animations
  4579. * @returns the animation group
  4580. */
  4581. pause(): AnimationGroup;
  4582. /**
  4583. * Play all animations to initial state
  4584. * This function will start() the animations if they were not started or will restart() them if they were paused
  4585. * @param loop defines if animations must loop
  4586. * @returns the animation group
  4587. */
  4588. play(loop?: boolean): AnimationGroup;
  4589. /**
  4590. * Reset all animations to initial state
  4591. * @returns the animation group
  4592. */
  4593. reset(): AnimationGroup;
  4594. /**
  4595. * Restart animations from key 0
  4596. * @returns the animation group
  4597. */
  4598. restart(): AnimationGroup;
  4599. /**
  4600. * Stop all animations
  4601. * @returns the animation group
  4602. */
  4603. stop(): AnimationGroup;
  4604. /**
  4605. * Set animation weight for all animatables
  4606. * @param weight defines the weight to use
  4607. * @return the animationGroup
  4608. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4609. */
  4610. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4611. /**
  4612. * Synchronize and normalize all animatables with a source animatable
  4613. * @param root defines the root animatable to synchronize with
  4614. * @return the animationGroup
  4615. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4616. */
  4617. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4618. /**
  4619. * Goes to a specific frame in this animation group
  4620. * @param frame the frame number to go to
  4621. * @return the animationGroup
  4622. */
  4623. goToFrame(frame: number): AnimationGroup;
  4624. /**
  4625. * Dispose all associated resources
  4626. */
  4627. dispose(): void;
  4628. private _checkAnimationGroupEnded;
  4629. /**
  4630. * Returns a new AnimationGroup object parsed from the source provided.
  4631. * @param parsedAnimationGroup defines the source
  4632. * @param scene defines the scene that will receive the animationGroup
  4633. * @returns a new AnimationGroup
  4634. */
  4635. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4636. /**
  4637. * Returns the string "AnimationGroup"
  4638. * @returns "AnimationGroup"
  4639. */
  4640. getClassName(): string;
  4641. /**
  4642. * Creates a detailled string about the object
  4643. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4644. * @returns a string representing the object
  4645. */
  4646. toString(fullDetails?: boolean): string;
  4647. }
  4648. }
  4649. declare module BABYLON {
  4650. /**
  4651. * Class used to override all child animations of a given target
  4652. */
  4653. class AnimationPropertiesOverride {
  4654. /**
  4655. * Gets or sets a value indicating if animation blending must be used
  4656. */
  4657. enableBlending: boolean;
  4658. /**
  4659. * Gets or sets the blending speed to use when enableBlending is true
  4660. */
  4661. blendingSpeed: number;
  4662. /**
  4663. * Gets or sets the default loop mode to use
  4664. */
  4665. loopMode: number;
  4666. }
  4667. }
  4668. declare module BABYLON {
  4669. /**
  4670. * This represents the main contract an easing function should follow.
  4671. * Easing functions are used throughout the animation system.
  4672. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4673. */
  4674. interface IEasingFunction {
  4675. /**
  4676. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4677. * of the easing function.
  4678. * The link below provides some of the most common examples of easing functions.
  4679. * @see https://easings.net/
  4680. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4681. * @returns the corresponding value on the curve defined by the easing function
  4682. */
  4683. ease(gradient: number): number;
  4684. }
  4685. /**
  4686. * Base class used for every default easing function.
  4687. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4688. */
  4689. class EasingFunction implements IEasingFunction {
  4690. /**
  4691. * Interpolation follows the mathematical formula associated with the easing function.
  4692. */
  4693. static readonly EASINGMODE_EASEIN: number;
  4694. /**
  4695. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4696. */
  4697. static readonly EASINGMODE_EASEOUT: number;
  4698. /**
  4699. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4700. */
  4701. static readonly EASINGMODE_EASEINOUT: number;
  4702. private _easingMode;
  4703. /**
  4704. * Sets the easing mode of the current function.
  4705. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4706. */
  4707. setEasingMode(easingMode: number): void;
  4708. /**
  4709. * Gets the current easing mode.
  4710. * @returns the easing mode
  4711. */
  4712. getEasingMode(): number;
  4713. /**
  4714. * @hidden
  4715. */
  4716. easeInCore(gradient: number): number;
  4717. /**
  4718. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4719. * of the easing function.
  4720. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4721. * @returns the corresponding value on the curve defined by the easing function
  4722. */
  4723. ease(gradient: number): number;
  4724. }
  4725. /**
  4726. * Easing function with a circle shape (see link below).
  4727. * @see https://easings.net/#easeInCirc
  4728. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4729. */
  4730. class CircleEase extends EasingFunction implements IEasingFunction {
  4731. /** @hidden */
  4732. easeInCore(gradient: number): number;
  4733. }
  4734. /**
  4735. * Easing function with a ease back shape (see link below).
  4736. * @see https://easings.net/#easeInBack
  4737. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4738. */
  4739. class BackEase extends EasingFunction implements IEasingFunction {
  4740. /** Defines the amplitude of the function */
  4741. amplitude: number;
  4742. /**
  4743. * Instantiates a back ease easing
  4744. * @see https://easings.net/#easeInBack
  4745. * @param amplitude Defines the amplitude of the function
  4746. */
  4747. constructor(
  4748. /** Defines the amplitude of the function */
  4749. amplitude?: number);
  4750. /** @hidden */
  4751. easeInCore(gradient: number): number;
  4752. }
  4753. /**
  4754. * Easing function with a bouncing shape (see link below).
  4755. * @see https://easings.net/#easeInBounce
  4756. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4757. */
  4758. class BounceEase extends EasingFunction implements IEasingFunction {
  4759. /** Defines the number of bounces */
  4760. bounces: number;
  4761. /** Defines the amplitude of the bounce */
  4762. bounciness: number;
  4763. /**
  4764. * Instantiates a bounce easing
  4765. * @see https://easings.net/#easeInBounce
  4766. * @param bounces Defines the number of bounces
  4767. * @param bounciness Defines the amplitude of the bounce
  4768. */
  4769. constructor(
  4770. /** Defines the number of bounces */
  4771. bounces?: number,
  4772. /** Defines the amplitude of the bounce */
  4773. bounciness?: number);
  4774. /** @hidden */
  4775. easeInCore(gradient: number): number;
  4776. }
  4777. /**
  4778. * Easing function with a power of 3 shape (see link below).
  4779. * @see https://easings.net/#easeInCubic
  4780. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4781. */
  4782. class CubicEase extends EasingFunction implements IEasingFunction {
  4783. /** @hidden */
  4784. easeInCore(gradient: number): number;
  4785. }
  4786. /**
  4787. * Easing function with an elastic shape (see link below).
  4788. * @see https://easings.net/#easeInElastic
  4789. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4790. */
  4791. class ElasticEase extends EasingFunction implements IEasingFunction {
  4792. /** Defines the number of oscillations*/
  4793. oscillations: number;
  4794. /** Defines the amplitude of the oscillations*/
  4795. springiness: number;
  4796. /**
  4797. * Instantiates an elastic easing function
  4798. * @see https://easings.net/#easeInElastic
  4799. * @param oscillations Defines the number of oscillations
  4800. * @param springiness Defines the amplitude of the oscillations
  4801. */
  4802. constructor(
  4803. /** Defines the number of oscillations*/
  4804. oscillations?: number,
  4805. /** Defines the amplitude of the oscillations*/
  4806. springiness?: number);
  4807. /** @hidden */
  4808. easeInCore(gradient: number): number;
  4809. }
  4810. /**
  4811. * Easing function with an exponential shape (see link below).
  4812. * @see https://easings.net/#easeInExpo
  4813. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4814. */
  4815. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4816. /** Defines the exponent of the function */
  4817. exponent: number;
  4818. /**
  4819. * Instantiates an exponential easing function
  4820. * @see https://easings.net/#easeInExpo
  4821. * @param exponent Defines the exponent of the function
  4822. */
  4823. constructor(
  4824. /** Defines the exponent of the function */
  4825. exponent?: number);
  4826. /** @hidden */
  4827. easeInCore(gradient: number): number;
  4828. }
  4829. /**
  4830. * Easing function with a power shape (see link below).
  4831. * @see https://easings.net/#easeInQuad
  4832. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4833. */
  4834. class PowerEase extends EasingFunction implements IEasingFunction {
  4835. /** Defines the power of the function */
  4836. power: number;
  4837. /**
  4838. * Instantiates an power base easing function
  4839. * @see https://easings.net/#easeInQuad
  4840. * @param power Defines the power of the function
  4841. */
  4842. constructor(
  4843. /** Defines the power of the function */
  4844. power?: number);
  4845. /** @hidden */
  4846. easeInCore(gradient: number): number;
  4847. }
  4848. /**
  4849. * Easing function with a power of 2 shape (see link below).
  4850. * @see https://easings.net/#easeInQuad
  4851. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4852. */
  4853. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4854. /** @hidden */
  4855. easeInCore(gradient: number): number;
  4856. }
  4857. /**
  4858. * Easing function with a power of 4 shape (see link below).
  4859. * @see https://easings.net/#easeInQuart
  4860. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4861. */
  4862. class QuarticEase extends EasingFunction implements IEasingFunction {
  4863. /** @hidden */
  4864. easeInCore(gradient: number): number;
  4865. }
  4866. /**
  4867. * Easing function with a power of 5 shape (see link below).
  4868. * @see https://easings.net/#easeInQuint
  4869. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4870. */
  4871. class QuinticEase extends EasingFunction implements IEasingFunction {
  4872. /** @hidden */
  4873. easeInCore(gradient: number): number;
  4874. }
  4875. /**
  4876. * Easing function with a sin shape (see link below).
  4877. * @see https://easings.net/#easeInSine
  4878. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4879. */
  4880. class SineEase extends EasingFunction implements IEasingFunction {
  4881. /** @hidden */
  4882. easeInCore(gradient: number): number;
  4883. }
  4884. /**
  4885. * Easing function with a bezier shape (see link below).
  4886. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4887. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4888. */
  4889. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4890. /** Defines the x component of the start tangent in the bezier curve */
  4891. x1: number;
  4892. /** Defines the y component of the start tangent in the bezier curve */
  4893. y1: number;
  4894. /** Defines the x component of the end tangent in the bezier curve */
  4895. x2: number;
  4896. /** Defines the y component of the end tangent in the bezier curve */
  4897. y2: number;
  4898. /**
  4899. * Instantiates a bezier function
  4900. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4901. * @param x1 Defines the x component of the start tangent in the bezier curve
  4902. * @param y1 Defines the y component of the start tangent in the bezier curve
  4903. * @param x2 Defines the x component of the end tangent in the bezier curve
  4904. * @param y2 Defines the y component of the end tangent in the bezier curve
  4905. */
  4906. constructor(
  4907. /** Defines the x component of the start tangent in the bezier curve */
  4908. x1?: number,
  4909. /** Defines the y component of the start tangent in the bezier curve */
  4910. y1?: number,
  4911. /** Defines the x component of the end tangent in the bezier curve */
  4912. x2?: number,
  4913. /** Defines the y component of the end tangent in the bezier curve */
  4914. y2?: number);
  4915. /** @hidden */
  4916. easeInCore(gradient: number): number;
  4917. }
  4918. }
  4919. declare module BABYLON {
  4920. /**
  4921. * Defines a runtime animation
  4922. */
  4923. class RuntimeAnimation {
  4924. private _events;
  4925. /**
  4926. * The current frame of the runtime animation
  4927. */
  4928. private _currentFrame;
  4929. /**
  4930. * The animation used by the runtime animation
  4931. */
  4932. private _animation;
  4933. /**
  4934. * The target of the runtime animation
  4935. */
  4936. private _target;
  4937. /**
  4938. * The initiating animatable
  4939. */
  4940. private _host;
  4941. /**
  4942. * The original value of the runtime animation
  4943. */
  4944. private _originalValue;
  4945. /**
  4946. * The original blend value of the runtime animation
  4947. */
  4948. private _originalBlendValue;
  4949. /**
  4950. * The offsets cache of the runtime animation
  4951. */
  4952. private _offsetsCache;
  4953. /**
  4954. * The high limits cache of the runtime animation
  4955. */
  4956. private _highLimitsCache;
  4957. /**
  4958. * Specifies if the runtime animation has been stopped
  4959. */
  4960. private _stopped;
  4961. /**
  4962. * The blending factor of the runtime animation
  4963. */
  4964. private _blendingFactor;
  4965. /**
  4966. * The BabylonJS scene
  4967. */
  4968. private _scene;
  4969. /**
  4970. * The current value of the runtime animation
  4971. */
  4972. private _currentValue;
  4973. /** @hidden */
  4974. _workValue: any;
  4975. /**
  4976. * The active target of the runtime animation
  4977. */
  4978. private _activeTarget;
  4979. /**
  4980. * The target path of the runtime animation
  4981. */
  4982. private _targetPath;
  4983. /**
  4984. * The weight of the runtime animation
  4985. */
  4986. private _weight;
  4987. /**
  4988. * The ratio offset of the runtime animation
  4989. */
  4990. private _ratioOffset;
  4991. /**
  4992. * The previous delay of the runtime animation
  4993. */
  4994. private _previousDelay;
  4995. /**
  4996. * The previous ratio of the runtime animation
  4997. */
  4998. private _previousRatio;
  4999. /**
  5000. * Gets the current frame of the runtime animation
  5001. */
  5002. readonly currentFrame: number;
  5003. /**
  5004. * Gets the weight of the runtime animation
  5005. */
  5006. readonly weight: number;
  5007. /**
  5008. * Gets the current value of the runtime animation
  5009. */
  5010. readonly currentValue: any;
  5011. /**
  5012. * Gets the target path of the runtime animation
  5013. */
  5014. readonly targetPath: string;
  5015. /**
  5016. * Gets the actual target of the runtime animation
  5017. */
  5018. readonly target: any;
  5019. /**
  5020. * Create a new RuntimeAnimation object
  5021. * @param target defines the target of the animation
  5022. * @param animation defines the source animation object
  5023. * @param scene defines the hosting scene
  5024. * @param host defines the initiating Animatable
  5025. */
  5026. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5027. /**
  5028. * Gets the animation from the runtime animation
  5029. */
  5030. readonly animation: Animation;
  5031. /**
  5032. * Resets the runtime animation to the beginning
  5033. * @param restoreOriginal defines whether to restore the target property to the original value
  5034. */
  5035. reset(restoreOriginal?: boolean): void;
  5036. /**
  5037. * Specifies if the runtime animation is stopped
  5038. * @returns Boolean specifying if the runtime animation is stopped
  5039. */
  5040. isStopped(): boolean;
  5041. /**
  5042. * Disposes of the runtime animation
  5043. */
  5044. dispose(): void;
  5045. /**
  5046. * Interpolates the animation from the current frame
  5047. * @param currentFrame The frame to interpolate the animation to
  5048. * @param repeatCount The number of times that the animation should loop
  5049. * @param loopMode The type of looping mode to use
  5050. * @param offsetValue Animation offset value
  5051. * @param highLimitValue The high limit value
  5052. * @returns The interpolated value
  5053. */
  5054. private _interpolate;
  5055. /**
  5056. * Apply the interpolated value to the target
  5057. * @param currentValue defines the value computed by the animation
  5058. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5059. */
  5060. setValue(currentValue: any, weight?: number): void;
  5061. private _setValue;
  5062. /**
  5063. * Gets the loop pmode of the runtime animation
  5064. * @returns Loop Mode
  5065. */
  5066. private _getCorrectLoopMode;
  5067. /**
  5068. * Move the current animation to a given frame
  5069. * @param frame defines the frame to move to
  5070. */
  5071. goToFrame(frame: number): void;
  5072. /**
  5073. * @hidden Internal use only
  5074. */
  5075. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5076. /**
  5077. * Execute the current animation
  5078. * @param delay defines the delay to add to the current frame
  5079. * @param from defines the lower bound of the animation range
  5080. * @param to defines the upper bound of the animation range
  5081. * @param loop defines if the current animation must loop
  5082. * @param speedRatio defines the current speed ratio
  5083. * @param weight defines the weight of the animation (default is -1 so no weight)
  5084. * @returns a boolean indicating if the animation is running
  5085. */
  5086. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5087. }
  5088. }
  5089. declare module BABYLON {
  5090. /**
  5091. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5092. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5093. */
  5094. class Analyser {
  5095. /**
  5096. * Gets or sets the smoothing
  5097. * @ignorenaming
  5098. */
  5099. SMOOTHING: number;
  5100. /**
  5101. * Gets or sets the FFT table size
  5102. * @ignorenaming
  5103. */
  5104. FFT_SIZE: number;
  5105. /**
  5106. * Gets or sets the bar graph amplitude
  5107. * @ignorenaming
  5108. */
  5109. BARGRAPHAMPLITUDE: number;
  5110. /**
  5111. * Gets or sets the position of the debug canvas
  5112. * @ignorenaming
  5113. */
  5114. DEBUGCANVASPOS: {
  5115. x: number;
  5116. y: number;
  5117. };
  5118. /**
  5119. * Gets or sets the debug canvas size
  5120. * @ignorenaming
  5121. */
  5122. DEBUGCANVASSIZE: {
  5123. width: number;
  5124. height: number;
  5125. };
  5126. private _byteFreqs;
  5127. private _byteTime;
  5128. private _floatFreqs;
  5129. private _webAudioAnalyser;
  5130. private _debugCanvas;
  5131. private _debugCanvasContext;
  5132. private _scene;
  5133. private _registerFunc;
  5134. private _audioEngine;
  5135. /**
  5136. * Creates a new analyser
  5137. * @param scene defines hosting scene
  5138. */
  5139. constructor(scene: Scene);
  5140. /**
  5141. * Get the number of data values you will have to play with for the visualization
  5142. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5143. * @returns a number
  5144. */
  5145. getFrequencyBinCount(): number;
  5146. /**
  5147. * Gets the current frequency data as a byte array
  5148. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5149. * @returns a Uint8Array
  5150. */
  5151. getByteFrequencyData(): Uint8Array;
  5152. /**
  5153. * Gets the current waveform as a byte array
  5154. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5155. * @returns a Uint8Array
  5156. */
  5157. getByteTimeDomainData(): Uint8Array;
  5158. /**
  5159. * Gets the current frequency data as a float array
  5160. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5161. * @returns a Float32Array
  5162. */
  5163. getFloatFrequencyData(): Float32Array;
  5164. /**
  5165. * Renders the debug canvas
  5166. */
  5167. drawDebugCanvas(): void;
  5168. /**
  5169. * Stops rendering the debug canvas and removes it
  5170. */
  5171. stopDebugCanvas(): void;
  5172. /**
  5173. * Connects two audio nodes
  5174. * @param inputAudioNode defines first node to connect
  5175. * @param outputAudioNode defines second node to connect
  5176. */
  5177. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5178. /**
  5179. * Releases all associated resources
  5180. */
  5181. dispose(): void;
  5182. }
  5183. }
  5184. declare module BABYLON {
  5185. /**
  5186. * This represents an audio engine and it is responsible
  5187. * to play, synchronize and analyse sounds throughout the application.
  5188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5189. */
  5190. interface IAudioEngine extends IDisposable {
  5191. /**
  5192. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5193. */
  5194. readonly canUseWebAudio: boolean;
  5195. /**
  5196. * Gets the current AudioContext if available.
  5197. */
  5198. readonly audioContext: Nullable<AudioContext>;
  5199. /**
  5200. * The master gain node defines the global audio volume of your audio engine.
  5201. */
  5202. readonly masterGain: GainNode;
  5203. /**
  5204. * Gets whether or not mp3 are supported by your browser.
  5205. */
  5206. readonly isMP3supported: boolean;
  5207. /**
  5208. * Gets whether or not ogg are supported by your browser.
  5209. */
  5210. readonly isOGGsupported: boolean;
  5211. /**
  5212. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5213. * @ignoreNaming
  5214. */
  5215. WarnedWebAudioUnsupported: boolean;
  5216. /**
  5217. * Defines if the audio engine relies on a custom unlocked button.
  5218. * In this case, the embedded button will not be displayed.
  5219. */
  5220. useCustomUnlockedButton: boolean;
  5221. /**
  5222. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5223. */
  5224. readonly unlocked: boolean;
  5225. /**
  5226. * Event raised when audio has been unlocked on the browser.
  5227. */
  5228. onAudioUnlockedObservable: Observable<AudioEngine>;
  5229. /**
  5230. * Event raised when audio has been locked on the browser.
  5231. */
  5232. onAudioLockedObservable: Observable<AudioEngine>;
  5233. /**
  5234. * Flags the audio engine in Locked state.
  5235. * This happens due to new browser policies preventing audio to autoplay.
  5236. */
  5237. lock(): void;
  5238. /**
  5239. * Unlocks the audio engine once a user action has been done on the dom.
  5240. * This is helpful to resume play once browser policies have been satisfied.
  5241. */
  5242. unlock(): void;
  5243. }
  5244. /**
  5245. * This represents the default audio engine used in babylon.
  5246. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5248. */
  5249. class AudioEngine implements IAudioEngine {
  5250. private _audioContext;
  5251. private _audioContextInitialized;
  5252. private _muteButton;
  5253. private _hostElement;
  5254. /**
  5255. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5256. */
  5257. canUseWebAudio: boolean;
  5258. /**
  5259. * The master gain node defines the global audio volume of your audio engine.
  5260. */
  5261. masterGain: GainNode;
  5262. /**
  5263. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5264. * @ignoreNaming
  5265. */
  5266. WarnedWebAudioUnsupported: boolean;
  5267. /**
  5268. * Gets whether or not mp3 are supported by your browser.
  5269. */
  5270. isMP3supported: boolean;
  5271. /**
  5272. * Gets whether or not ogg are supported by your browser.
  5273. */
  5274. isOGGsupported: boolean;
  5275. /**
  5276. * Gets whether audio has been unlocked on the device.
  5277. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5278. * a user interaction has happened.
  5279. */
  5280. unlocked: boolean;
  5281. /**
  5282. * Defines if the audio engine relies on a custom unlocked button.
  5283. * In this case, the embedded button will not be displayed.
  5284. */
  5285. useCustomUnlockedButton: boolean;
  5286. /**
  5287. * Event raised when audio has been unlocked on the browser.
  5288. */
  5289. onAudioUnlockedObservable: Observable<AudioEngine>;
  5290. /**
  5291. * Event raised when audio has been locked on the browser.
  5292. */
  5293. onAudioLockedObservable: Observable<AudioEngine>;
  5294. /**
  5295. * Gets the current AudioContext if available.
  5296. */
  5297. readonly audioContext: Nullable<AudioContext>;
  5298. private _connectedAnalyser;
  5299. /**
  5300. * Instantiates a new audio engine.
  5301. *
  5302. * There should be only one per page as some browsers restrict the number
  5303. * of audio contexts you can create.
  5304. * @param hostElement defines the host element where to display the mute icon if necessary
  5305. */
  5306. constructor(hostElement?: Nullable<HTMLElement>);
  5307. /**
  5308. * Flags the audio engine in Locked state.
  5309. * This happens due to new browser policies preventing audio to autoplay.
  5310. */
  5311. lock(): void;
  5312. /**
  5313. * Unlocks the audio engine once a user action has been done on the dom.
  5314. * This is helpful to resume play once browser policies have been satisfied.
  5315. */
  5316. unlock(): void;
  5317. private _resumeAudioContext;
  5318. private _initializeAudioContext;
  5319. private _tryToRun;
  5320. private _triggerRunningState;
  5321. private _triggerSuspendedState;
  5322. private _displayMuteButton;
  5323. private _moveButtonToTopLeft;
  5324. private _onResize;
  5325. private _hideMuteButton;
  5326. /**
  5327. * Destroy and release the resources associated with the audio ccontext.
  5328. */
  5329. dispose(): void;
  5330. /**
  5331. * Gets the global volume sets on the master gain.
  5332. * @returns the global volume if set or -1 otherwise
  5333. */
  5334. getGlobalVolume(): number;
  5335. /**
  5336. * Sets the global volume of your experience (sets on the master gain).
  5337. * @param newVolume Defines the new global volume of the application
  5338. */
  5339. setGlobalVolume(newVolume: number): void;
  5340. /**
  5341. * Connect the audio engine to an audio analyser allowing some amazing
  5342. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5343. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5344. * @param analyser The analyser to connect to the engine
  5345. */
  5346. connectToAnalyser(analyser: Analyser): void;
  5347. }
  5348. }
  5349. declare module BABYLON {
  5350. interface AbstractScene {
  5351. /**
  5352. * The list of sounds used in the scene.
  5353. */
  5354. sounds: Nullable<Array<Sound>>;
  5355. }
  5356. interface Scene {
  5357. /**
  5358. * @hidden
  5359. * Backing field
  5360. */
  5361. _mainSoundTrack: SoundTrack;
  5362. /**
  5363. * The main sound track played by the scene.
  5364. * It cotains your primary collection of sounds.
  5365. */
  5366. mainSoundTrack: SoundTrack;
  5367. /**
  5368. * The list of sound tracks added to the scene
  5369. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5370. */
  5371. soundTracks: Nullable<Array<SoundTrack>>;
  5372. /**
  5373. * Gets a sound using a given name
  5374. * @param name defines the name to search for
  5375. * @return the found sound or null if not found at all.
  5376. */
  5377. getSoundByName(name: string): Nullable<Sound>;
  5378. /**
  5379. * Gets or sets if audio support is enabled
  5380. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5381. */
  5382. audioEnabled: boolean;
  5383. /**
  5384. * Gets or sets if audio will be output to headphones
  5385. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5386. */
  5387. headphone: boolean;
  5388. }
  5389. /**
  5390. * Defines the sound scene component responsible to manage any sounds
  5391. * in a given scene.
  5392. */
  5393. class AudioSceneComponent implements ISceneSerializableComponent {
  5394. /**
  5395. * The component name helpfull to identify the component in the list of scene components.
  5396. */
  5397. readonly name: string;
  5398. /**
  5399. * The scene the component belongs to.
  5400. */
  5401. scene: Scene;
  5402. private _audioEnabled;
  5403. /**
  5404. * Gets whether audio is enabled or not.
  5405. * Please use related enable/disable method to switch state.
  5406. */
  5407. readonly audioEnabled: boolean;
  5408. private _headphone;
  5409. /**
  5410. * Gets whether audio is outputing to headphone or not.
  5411. * Please use the according Switch methods to change output.
  5412. */
  5413. readonly headphone: boolean;
  5414. /**
  5415. * Creates a new instance of the component for the given scene
  5416. * @param scene Defines the scene to register the component in
  5417. */
  5418. constructor(scene: Scene);
  5419. /**
  5420. * Registers the component in a given scene
  5421. */
  5422. register(): void;
  5423. /**
  5424. * Rebuilds the elements related to this component in case of
  5425. * context lost for instance.
  5426. */
  5427. rebuild(): void;
  5428. /**
  5429. * Serializes the component data to the specified json object
  5430. * @param serializationObject The object to serialize to
  5431. */
  5432. serialize(serializationObject: any): void;
  5433. /**
  5434. * Adds all the element from the container to the scene
  5435. * @param container the container holding the elements
  5436. */
  5437. addFromContainer(container: AbstractScene): void;
  5438. /**
  5439. * Removes all the elements in the container from the scene
  5440. * @param container contains the elements to remove
  5441. */
  5442. removeFromContainer(container: AbstractScene): void;
  5443. /**
  5444. * Disposes the component and the associated ressources.
  5445. */
  5446. dispose(): void;
  5447. /**
  5448. * Disables audio in the associated scene.
  5449. */
  5450. disableAudio(): void;
  5451. /**
  5452. * Enables audio in the associated scene.
  5453. */
  5454. enableAudio(): void;
  5455. /**
  5456. * Switch audio to headphone output.
  5457. */
  5458. switchAudioModeForHeadphones(): void;
  5459. /**
  5460. * Switch audio to normal speakers.
  5461. */
  5462. switchAudioModeForNormalSpeakers(): void;
  5463. private _afterRender;
  5464. }
  5465. }
  5466. declare module BABYLON {
  5467. /**
  5468. * Defines a sound that can be played in the application.
  5469. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5471. */
  5472. class Sound {
  5473. /**
  5474. * The name of the sound in the scene.
  5475. */
  5476. name: string;
  5477. /**
  5478. * Does the sound autoplay once loaded.
  5479. */
  5480. autoplay: boolean;
  5481. /**
  5482. * Does the sound loop after it finishes playing once.
  5483. */
  5484. loop: boolean;
  5485. /**
  5486. * Does the sound use a custom attenuation curve to simulate the falloff
  5487. * happening when the source gets further away from the camera.
  5488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5489. */
  5490. useCustomAttenuation: boolean;
  5491. /**
  5492. * The sound track id this sound belongs to.
  5493. */
  5494. soundTrackId: number;
  5495. /**
  5496. * Is this sound currently played.
  5497. */
  5498. isPlaying: boolean;
  5499. /**
  5500. * Is this sound currently paused.
  5501. */
  5502. isPaused: boolean;
  5503. /**
  5504. * Does this sound enables spatial sound.
  5505. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5506. */
  5507. spatialSound: boolean;
  5508. /**
  5509. * Define the reference distance the sound should be heard perfectly.
  5510. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5511. */
  5512. refDistance: number;
  5513. /**
  5514. * Define the roll off factor of spatial sounds.
  5515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5516. */
  5517. rolloffFactor: number;
  5518. /**
  5519. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5520. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5521. */
  5522. maxDistance: number;
  5523. /**
  5524. * Define the distance attenuation model the sound will follow.
  5525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5526. */
  5527. distanceModel: string;
  5528. /**
  5529. * @hidden
  5530. * Back Compat
  5531. **/
  5532. onended: () => any;
  5533. /**
  5534. * Observable event when the current playing sound finishes.
  5535. */
  5536. onEndedObservable: Observable<Sound>;
  5537. private _panningModel;
  5538. private _playbackRate;
  5539. private _streaming;
  5540. private _startTime;
  5541. private _startOffset;
  5542. private _position;
  5543. /** @hidden */
  5544. _positionInEmitterSpace: boolean;
  5545. private _localDirection;
  5546. private _volume;
  5547. private _isReadyToPlay;
  5548. private _isDirectional;
  5549. private _readyToPlayCallback;
  5550. private _audioBuffer;
  5551. private _soundSource;
  5552. private _streamingSource;
  5553. private _soundPanner;
  5554. private _soundGain;
  5555. private _inputAudioNode;
  5556. private _outputAudioNode;
  5557. private _coneInnerAngle;
  5558. private _coneOuterAngle;
  5559. private _coneOuterGain;
  5560. private _scene;
  5561. private _connectedMesh;
  5562. private _customAttenuationFunction;
  5563. private _registerFunc;
  5564. private _isOutputConnected;
  5565. private _htmlAudioElement;
  5566. private _urlType;
  5567. /**
  5568. * Create a sound and attach it to a scene
  5569. * @param name Name of your sound
  5570. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5571. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5572. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5573. */
  5574. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5575. /**
  5576. * Release the sound and its associated resources
  5577. */
  5578. dispose(): void;
  5579. /**
  5580. * Gets if the sounds is ready to be played or not.
  5581. * @returns true if ready, otherwise false
  5582. */
  5583. isReady(): boolean;
  5584. private _soundLoaded;
  5585. /**
  5586. * Sets the data of the sound from an audiobuffer
  5587. * @param audioBuffer The audioBuffer containing the data
  5588. */
  5589. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5590. /**
  5591. * Updates the current sounds options such as maxdistance, loop...
  5592. * @param options A JSON object containing values named as the object properties
  5593. */
  5594. updateOptions(options: any): void;
  5595. private _createSpatialParameters;
  5596. private _updateSpatialParameters;
  5597. /**
  5598. * Switch the panning model to HRTF:
  5599. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5601. */
  5602. switchPanningModelToHRTF(): void;
  5603. /**
  5604. * Switch the panning model to Equal Power:
  5605. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5607. */
  5608. switchPanningModelToEqualPower(): void;
  5609. private _switchPanningModel;
  5610. /**
  5611. * Connect this sound to a sound track audio node like gain...
  5612. * @param soundTrackAudioNode the sound track audio node to connect to
  5613. */
  5614. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5615. /**
  5616. * Transform this sound into a directional source
  5617. * @param coneInnerAngle Size of the inner cone in degree
  5618. * @param coneOuterAngle Size of the outer cone in degree
  5619. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5620. */
  5621. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5622. /**
  5623. * Gets or sets the inner angle for the directional cone.
  5624. */
  5625. /**
  5626. * Gets or sets the inner angle for the directional cone.
  5627. */
  5628. directionalConeInnerAngle: number;
  5629. /**
  5630. * Gets or sets the outer angle for the directional cone.
  5631. */
  5632. /**
  5633. * Gets or sets the outer angle for the directional cone.
  5634. */
  5635. directionalConeOuterAngle: number;
  5636. /**
  5637. * Sets the position of the emitter if spatial sound is enabled
  5638. * @param newPosition Defines the new posisiton
  5639. */
  5640. setPosition(newPosition: Vector3): void;
  5641. /**
  5642. * Sets the local direction of the emitter if spatial sound is enabled
  5643. * @param newLocalDirection Defines the new local direction
  5644. */
  5645. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5646. private _updateDirection;
  5647. /** @hidden */
  5648. updateDistanceFromListener(): void;
  5649. /**
  5650. * Sets a new custom attenuation function for the sound.
  5651. * @param callback Defines the function used for the attenuation
  5652. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5653. */
  5654. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5655. /**
  5656. * Play the sound
  5657. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5658. * @param offset (optional) Start the sound setting it at a specific time
  5659. */
  5660. play(time?: number, offset?: number): void;
  5661. private _onended;
  5662. /**
  5663. * Stop the sound
  5664. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5665. */
  5666. stop(time?: number): void;
  5667. /**
  5668. * Put the sound in pause
  5669. */
  5670. pause(): void;
  5671. /**
  5672. * Sets a dedicated volume for this sounds
  5673. * @param newVolume Define the new volume of the sound
  5674. * @param time Define in how long the sound should be at this value
  5675. */
  5676. setVolume(newVolume: number, time?: number): void;
  5677. /**
  5678. * Set the sound play back rate
  5679. * @param newPlaybackRate Define the playback rate the sound should be played at
  5680. */
  5681. setPlaybackRate(newPlaybackRate: number): void;
  5682. /**
  5683. * Gets the volume of the sound.
  5684. * @returns the volume of the sound
  5685. */
  5686. getVolume(): number;
  5687. /**
  5688. * Attach the sound to a dedicated mesh
  5689. * @param meshToConnectTo The mesh to connect the sound with
  5690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5691. */
  5692. attachToMesh(meshToConnectTo: AbstractMesh): void;
  5693. /**
  5694. * Detach the sound from the previously attached mesh
  5695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5696. */
  5697. detachFromMesh(): void;
  5698. private _onRegisterAfterWorldMatrixUpdate;
  5699. /**
  5700. * Clone the current sound in the scene.
  5701. * @returns the new sound clone
  5702. */
  5703. clone(): Nullable<Sound>;
  5704. /**
  5705. * Gets the current underlying audio buffer containing the data
  5706. * @returns the audio buffer
  5707. */
  5708. getAudioBuffer(): Nullable<AudioBuffer>;
  5709. /**
  5710. * Serializes the Sound in a JSON representation
  5711. * @returns the JSON representation of the sound
  5712. */
  5713. serialize(): any;
  5714. /**
  5715. * Parse a JSON representation of a sound to innstantiate in a given scene
  5716. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5717. * @param scene Define the scene the new parsed sound should be created in
  5718. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5719. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5720. * @returns the newly parsed sound
  5721. */
  5722. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5723. }
  5724. }
  5725. declare module BABYLON {
  5726. /**
  5727. * Options allowed during the creation of a sound track.
  5728. */
  5729. interface ISoundTrackOptions {
  5730. /**
  5731. * The volume the sound track should take during creation
  5732. */
  5733. volume?: number;
  5734. /**
  5735. * Define if the sound track is the main sound track of the scene
  5736. */
  5737. mainTrack?: boolean;
  5738. }
  5739. /**
  5740. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5741. * It will be also used in a future release to apply effects on a specific track.
  5742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5743. */
  5744. class SoundTrack {
  5745. /**
  5746. * The unique identifier of the sound track in the scene.
  5747. */
  5748. id: number;
  5749. /**
  5750. * The list of sounds included in the sound track.
  5751. */
  5752. soundCollection: Array<Sound>;
  5753. private _outputAudioNode;
  5754. private _scene;
  5755. private _isMainTrack;
  5756. private _connectedAnalyser;
  5757. private _options;
  5758. private _isInitialized;
  5759. /**
  5760. * Creates a new sound track.
  5761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5762. * @param scene Define the scene the sound track belongs to
  5763. * @param options
  5764. */
  5765. constructor(scene: Scene, options?: ISoundTrackOptions);
  5766. private _initializeSoundTrackAudioGraph;
  5767. /**
  5768. * Release the sound track and its associated resources
  5769. */
  5770. dispose(): void;
  5771. /**
  5772. * Adds a sound to this sound track
  5773. * @param sound define the cound to add
  5774. * @ignoreNaming
  5775. */
  5776. AddSound(sound: Sound): void;
  5777. /**
  5778. * Removes a sound to this sound track
  5779. * @param sound define the cound to remove
  5780. * @ignoreNaming
  5781. */
  5782. RemoveSound(sound: Sound): void;
  5783. /**
  5784. * Set a global volume for the full sound track.
  5785. * @param newVolume Define the new volume of the sound track
  5786. */
  5787. setVolume(newVolume: number): void;
  5788. /**
  5789. * Switch the panning model to HRTF:
  5790. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5792. */
  5793. switchPanningModelToHRTF(): void;
  5794. /**
  5795. * Switch the panning model to Equal Power:
  5796. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5798. */
  5799. switchPanningModelToEqualPower(): void;
  5800. /**
  5801. * Connect the sound track to an audio analyser allowing some amazing
  5802. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5803. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5804. * @param analyser The analyser to connect to the engine
  5805. */
  5806. connectToAnalyser(analyser: Analyser): void;
  5807. }
  5808. }
  5809. declare module BABYLON {
  5810. /**
  5811. * Wraps one or more Sound objects and selects one with random weight for playback.
  5812. */
  5813. class WeightedSound {
  5814. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5815. loop: boolean;
  5816. private _coneInnerAngle;
  5817. private _coneOuterAngle;
  5818. private _volume;
  5819. /** A Sound is currently playing. */
  5820. isPlaying: boolean;
  5821. /** A Sound is currently paused. */
  5822. isPaused: boolean;
  5823. private _sounds;
  5824. private _weights;
  5825. private _currentIndex?;
  5826. /**
  5827. * Creates a new WeightedSound from the list of sounds given.
  5828. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5829. * @param sounds Array of Sounds that will be selected from.
  5830. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5831. */
  5832. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5833. /**
  5834. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5835. */
  5836. /**
  5837. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5838. */
  5839. directionalConeInnerAngle: number;
  5840. /**
  5841. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5842. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5843. */
  5844. /**
  5845. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5846. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5847. */
  5848. directionalConeOuterAngle: number;
  5849. /**
  5850. * Playback volume.
  5851. */
  5852. /**
  5853. * Playback volume.
  5854. */
  5855. volume: number;
  5856. private _onended;
  5857. /**
  5858. * Suspend playback
  5859. */
  5860. pause(): void;
  5861. /**
  5862. * Stop playback
  5863. */
  5864. stop(): void;
  5865. /**
  5866. * Start playback.
  5867. * @param startOffset Position the clip head at a specific time in seconds.
  5868. */
  5869. play(startOffset?: number): void;
  5870. }
  5871. }
  5872. declare module BABYLON {
  5873. /**
  5874. * Interface used to define a behavior
  5875. */
  5876. interface Behavior<T> {
  5877. /** gets or sets behavior's name */
  5878. name: string;
  5879. /**
  5880. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5881. */
  5882. init(): void;
  5883. /**
  5884. * Called when the behavior is attached to a target
  5885. * @param target defines the target where the behavior is attached to
  5886. */
  5887. attach(target: T): void;
  5888. /**
  5889. * Called when the behavior is detached from its target
  5890. */
  5891. detach(): void;
  5892. }
  5893. /**
  5894. * Interface implemented by classes supporting behaviors
  5895. */
  5896. interface IBehaviorAware<T> {
  5897. /**
  5898. * Attach a behavior
  5899. * @param behavior defines the behavior to attach
  5900. * @returns the current host
  5901. */
  5902. addBehavior(behavior: Behavior<T>): T;
  5903. /**
  5904. * Remove a behavior from the current object
  5905. * @param behavior defines the behavior to detach
  5906. * @returns the current host
  5907. */
  5908. removeBehavior(behavior: Behavior<T>): T;
  5909. /**
  5910. * Gets a behavior using its name to search
  5911. * @param name defines the name to search
  5912. * @returns the behavior or null if not found
  5913. */
  5914. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5915. }
  5916. }
  5917. declare module BABYLON {
  5918. /**
  5919. * Class used to store bone information
  5920. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5921. */
  5922. class Bone extends Node {
  5923. /**
  5924. * defines the bone name
  5925. */
  5926. name: string;
  5927. private static _tmpVecs;
  5928. private static _tmpQuat;
  5929. private static _tmpMats;
  5930. /**
  5931. * Gets the list of child bones
  5932. */
  5933. children: Bone[];
  5934. /** Gets the animations associated with this bone */
  5935. animations: Animation[];
  5936. /**
  5937. * Gets or sets bone length
  5938. */
  5939. length: number;
  5940. /**
  5941. * @hidden Internal only
  5942. * Set this value to map this bone to a different index in the transform matrices
  5943. * Set this value to -1 to exclude the bone from the transform matrices
  5944. */
  5945. _index: Nullable<number>;
  5946. private _skeleton;
  5947. private _localMatrix;
  5948. private _restPose;
  5949. private _baseMatrix;
  5950. private _absoluteTransform;
  5951. private _invertedAbsoluteTransform;
  5952. private _parent;
  5953. private _scalingDeterminant;
  5954. private _worldTransform;
  5955. private _localScaling;
  5956. private _localRotation;
  5957. private _localPosition;
  5958. private _needToDecompose;
  5959. private _needToCompose;
  5960. /** @hidden */
  5961. /** @hidden */
  5962. _matrix: Matrix;
  5963. /**
  5964. * Create a new bone
  5965. * @param name defines the bone name
  5966. * @param skeleton defines the parent skeleton
  5967. * @param parentBone defines the parent (can be null if the bone is the root)
  5968. * @param localMatrix defines the local matrix
  5969. * @param restPose defines the rest pose matrix
  5970. * @param baseMatrix defines the base matrix
  5971. * @param index defines index of the bone in the hiearchy
  5972. */
  5973. constructor(
  5974. /**
  5975. * defines the bone name
  5976. */
  5977. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  5978. /**
  5979. * Gets the parent skeleton
  5980. * @returns a skeleton
  5981. */
  5982. getSkeleton(): Skeleton;
  5983. /**
  5984. * Gets parent bone
  5985. * @returns a bone or null if the bone is the root of the bone hierarchy
  5986. */
  5987. getParent(): Nullable<Bone>;
  5988. /**
  5989. * Sets the parent bone
  5990. * @param parent defines the parent (can be null if the bone is the root)
  5991. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5992. */
  5993. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  5994. /**
  5995. * Gets the local matrix
  5996. * @returns a matrix
  5997. */
  5998. getLocalMatrix(): Matrix;
  5999. /**
  6000. * Gets the base matrix (initial matrix which remains unchanged)
  6001. * @returns a matrix
  6002. */
  6003. getBaseMatrix(): Matrix;
  6004. /**
  6005. * Gets the rest pose matrix
  6006. * @returns a matrix
  6007. */
  6008. getRestPose(): Matrix;
  6009. /**
  6010. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  6011. */
  6012. getWorldMatrix(): Matrix;
  6013. /**
  6014. * Sets the local matrix to rest pose matrix
  6015. */
  6016. returnToRest(): void;
  6017. /**
  6018. * Gets the inverse of the absolute transform matrix.
  6019. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6020. * @returns a matrix
  6021. */
  6022. getInvertedAbsoluteTransform(): Matrix;
  6023. /**
  6024. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6025. * @returns a matrix
  6026. */
  6027. getAbsoluteTransform(): Matrix;
  6028. /** Gets or sets current position (in local space) */
  6029. position: Vector3;
  6030. /** Gets or sets current rotation (in local space) */
  6031. rotation: Vector3;
  6032. /** Gets or sets current rotation quaternion (in local space) */
  6033. rotationQuaternion: Quaternion;
  6034. /** Gets or sets current scaling (in local space) */
  6035. scaling: Vector3;
  6036. /**
  6037. * Gets the animation properties override
  6038. */
  6039. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6040. private _decompose;
  6041. private _compose;
  6042. /**
  6043. * Update the base and local matrices
  6044. * @param matrix defines the new base or local matrix
  6045. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6046. * @param updateLocalMatrix defines if the local matrix should be updated
  6047. */
  6048. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6049. /** @hidden */
  6050. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6051. /**
  6052. * Flag the bone as dirty (Forcing it to update everything)
  6053. */
  6054. markAsDirty(): void;
  6055. private _markAsDirtyAndCompose;
  6056. private _markAsDirtyAndDecompose;
  6057. /**
  6058. * Copy an animation range from another bone
  6059. * @param source defines the source bone
  6060. * @param rangeName defines the range name to copy
  6061. * @param frameOffset defines the frame offset
  6062. * @param rescaleAsRequired defines if rescaling must be applied if required
  6063. * @param skelDimensionsRatio defines the scaling ratio
  6064. * @returns true if operation was successful
  6065. */
  6066. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6067. /**
  6068. * Translate the bone in local or world space
  6069. * @param vec The amount to translate the bone
  6070. * @param space The space that the translation is in
  6071. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6072. */
  6073. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6074. /**
  6075. * Set the postion of the bone in local or world space
  6076. * @param position The position to set the bone
  6077. * @param space The space that the position is in
  6078. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6079. */
  6080. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6081. /**
  6082. * Set the absolute position of the bone (world space)
  6083. * @param position The position to set the bone
  6084. * @param mesh The mesh that this bone is attached to
  6085. */
  6086. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6087. /**
  6088. * Scale the bone on the x, y and z axes (in local space)
  6089. * @param x The amount to scale the bone on the x axis
  6090. * @param y The amount to scale the bone on the y axis
  6091. * @param z The amount to scale the bone on the z axis
  6092. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6093. */
  6094. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6095. /**
  6096. * Set the bone scaling in local space
  6097. * @param scale defines the scaling vector
  6098. */
  6099. setScale(scale: Vector3): void;
  6100. /**
  6101. * Gets the current scaling in local space
  6102. * @returns the current scaling vector
  6103. */
  6104. getScale(): Vector3;
  6105. /**
  6106. * Gets the current scaling in local space and stores it in a target vector
  6107. * @param result defines the target vector
  6108. */
  6109. getScaleToRef(result: Vector3): void;
  6110. /**
  6111. * Set the yaw, pitch, and roll of the bone in local or world space
  6112. * @param yaw The rotation of the bone on the y axis
  6113. * @param pitch The rotation of the bone on the x axis
  6114. * @param roll The rotation of the bone on the z axis
  6115. * @param space The space that the axes of rotation are in
  6116. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6117. */
  6118. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6119. /**
  6120. * Add a rotation to the bone on an axis in local or world space
  6121. * @param axis The axis to rotate the bone on
  6122. * @param amount The amount to rotate the bone
  6123. * @param space The space that the axis is in
  6124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6125. */
  6126. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6127. /**
  6128. * Set the rotation of the bone to a particular axis angle in local or world space
  6129. * @param axis The axis to rotate the bone on
  6130. * @param angle The angle that the bone should be rotated to
  6131. * @param space The space that the axis is in
  6132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6133. */
  6134. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6135. /**
  6136. * Set the euler rotation of the bone in local of world space
  6137. * @param rotation The euler rotation that the bone should be set to
  6138. * @param space The space that the rotation is in
  6139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6140. */
  6141. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6142. /**
  6143. * Set the quaternion rotation of the bone in local of world space
  6144. * @param quat The quaternion rotation that the bone should be set to
  6145. * @param space The space that the rotation is in
  6146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6147. */
  6148. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6149. /**
  6150. * Set the rotation matrix of the bone in local of world space
  6151. * @param rotMat The rotation matrix that the bone should be set to
  6152. * @param space The space that the rotation is in
  6153. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6154. */
  6155. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6156. private _rotateWithMatrix;
  6157. private _getNegativeRotationToRef;
  6158. /**
  6159. * Get the position of the bone in local or world space
  6160. * @param space The space that the returned position is in
  6161. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6162. * @returns The position of the bone
  6163. */
  6164. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6165. /**
  6166. * Copy the position of the bone to a vector3 in local or world space
  6167. * @param space The space that the returned position is in
  6168. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6169. * @param result The vector3 to copy the position to
  6170. */
  6171. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6172. /**
  6173. * Get the absolute position of the bone (world space)
  6174. * @param mesh The mesh that this bone is attached to
  6175. * @returns The absolute position of the bone
  6176. */
  6177. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6178. /**
  6179. * Copy the absolute position of the bone (world space) to the result param
  6180. * @param mesh The mesh that this bone is attached to
  6181. * @param result The vector3 to copy the absolute position to
  6182. */
  6183. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6184. /**
  6185. * Compute the absolute transforms of this bone and its children
  6186. */
  6187. computeAbsoluteTransforms(): void;
  6188. /**
  6189. * Get the world direction from an axis that is in the local space of the bone
  6190. * @param localAxis The local direction that is used to compute the world direction
  6191. * @param mesh The mesh that this bone is attached to
  6192. * @returns The world direction
  6193. */
  6194. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6195. /**
  6196. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6197. * @param localAxis The local direction that is used to compute the world direction
  6198. * @param mesh The mesh that this bone is attached to
  6199. * @param result The vector3 that the world direction will be copied to
  6200. */
  6201. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6202. /**
  6203. * Get the euler rotation of the bone in local or world space
  6204. * @param space The space that the rotation should be in
  6205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6206. * @returns The euler rotation
  6207. */
  6208. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6209. /**
  6210. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6211. * @param space The space that the rotation should be in
  6212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6213. * @param result The vector3 that the rotation should be copied to
  6214. */
  6215. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6216. /**
  6217. * Get the quaternion rotation of the bone in either local or world space
  6218. * @param space The space that the rotation should be in
  6219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6220. * @returns The quaternion rotation
  6221. */
  6222. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6223. /**
  6224. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6225. * @param space The space that the rotation should be in
  6226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6227. * @param result The quaternion that the rotation should be copied to
  6228. */
  6229. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6230. /**
  6231. * Get the rotation matrix of the bone in local or world space
  6232. * @param space The space that the rotation should be in
  6233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6234. * @returns The rotation matrix
  6235. */
  6236. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6237. /**
  6238. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6239. * @param space The space that the rotation should be in
  6240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6241. * @param result The quaternion that the rotation should be copied to
  6242. */
  6243. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6244. /**
  6245. * Get the world position of a point that is in the local space of the bone
  6246. * @param position The local position
  6247. * @param mesh The mesh that this bone is attached to
  6248. * @returns The world position
  6249. */
  6250. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6251. /**
  6252. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6253. * @param position The local position
  6254. * @param mesh The mesh that this bone is attached to
  6255. * @param result The vector3 that the world position should be copied to
  6256. */
  6257. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6258. /**
  6259. * Get the local position of a point that is in world space
  6260. * @param position The world position
  6261. * @param mesh The mesh that this bone is attached to
  6262. * @returns The local position
  6263. */
  6264. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6265. /**
  6266. * Get the local position of a point that is in world space and copy it to the result param
  6267. * @param position The world position
  6268. * @param mesh The mesh that this bone is attached to
  6269. * @param result The vector3 that the local position should be copied to
  6270. */
  6271. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6272. }
  6273. }
  6274. declare module BABYLON {
  6275. /**
  6276. * Class used to apply inverse kinematics to bones
  6277. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6278. */
  6279. class BoneIKController {
  6280. private static _tmpVecs;
  6281. private static _tmpQuat;
  6282. private static _tmpMats;
  6283. /**
  6284. * Gets or sets the target mesh
  6285. */
  6286. targetMesh: AbstractMesh;
  6287. /** Gets or sets the mesh used as pole */
  6288. poleTargetMesh: AbstractMesh;
  6289. /**
  6290. * Gets or sets the bone used as pole
  6291. */
  6292. poleTargetBone: Nullable<Bone>;
  6293. /**
  6294. * Gets or sets the target position
  6295. */
  6296. targetPosition: Vector3;
  6297. /**
  6298. * Gets or sets the pole target position
  6299. */
  6300. poleTargetPosition: Vector3;
  6301. /**
  6302. * Gets or sets the pole target local offset
  6303. */
  6304. poleTargetLocalOffset: Vector3;
  6305. /**
  6306. * Gets or sets the pole angle
  6307. */
  6308. poleAngle: number;
  6309. /**
  6310. * Gets or sets the mesh associated with the controller
  6311. */
  6312. mesh: AbstractMesh;
  6313. /**
  6314. * 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)
  6315. */
  6316. slerpAmount: number;
  6317. private _bone1Quat;
  6318. private _bone1Mat;
  6319. private _bone2Ang;
  6320. private _bone1;
  6321. private _bone2;
  6322. private _bone1Length;
  6323. private _bone2Length;
  6324. private _maxAngle;
  6325. private _maxReach;
  6326. private _rightHandedSystem;
  6327. private _bendAxis;
  6328. private _slerping;
  6329. private _adjustRoll;
  6330. /**
  6331. * Gets or sets maximum allowed angle
  6332. */
  6333. maxAngle: number;
  6334. /**
  6335. * Creates a new BoneIKController
  6336. * @param mesh defines the mesh to control
  6337. * @param bone defines the bone to control
  6338. * @param options defines options to set up the controller
  6339. */
  6340. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6341. targetMesh?: AbstractMesh;
  6342. poleTargetMesh?: AbstractMesh;
  6343. poleTargetBone?: Bone;
  6344. poleTargetLocalOffset?: Vector3;
  6345. poleAngle?: number;
  6346. bendAxis?: Vector3;
  6347. maxAngle?: number;
  6348. slerpAmount?: number;
  6349. });
  6350. private _setMaxAngle;
  6351. /**
  6352. * Force the controller to update the bones
  6353. */
  6354. update(): void;
  6355. }
  6356. }
  6357. declare module BABYLON {
  6358. /**
  6359. * Class used to make a bone look toward a point in space
  6360. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6361. */
  6362. class BoneLookController {
  6363. private static _tmpVecs;
  6364. private static _tmpQuat;
  6365. private static _tmpMats;
  6366. /**
  6367. * The target Vector3 that the bone will look at
  6368. */
  6369. target: Vector3;
  6370. /**
  6371. * The mesh that the bone is attached to
  6372. */
  6373. mesh: AbstractMesh;
  6374. /**
  6375. * The bone that will be looking to the target
  6376. */
  6377. bone: Bone;
  6378. /**
  6379. * The up axis of the coordinate system that is used when the bone is rotated
  6380. */
  6381. upAxis: Vector3;
  6382. /**
  6383. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6384. */
  6385. upAxisSpace: Space;
  6386. /**
  6387. * Used to make an adjustment to the yaw of the bone
  6388. */
  6389. adjustYaw: number;
  6390. /**
  6391. * Used to make an adjustment to the pitch of the bone
  6392. */
  6393. adjustPitch: number;
  6394. /**
  6395. * Used to make an adjustment to the roll of the bone
  6396. */
  6397. adjustRoll: number;
  6398. /**
  6399. * 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)
  6400. */
  6401. slerpAmount: number;
  6402. private _minYaw;
  6403. private _maxYaw;
  6404. private _minPitch;
  6405. private _maxPitch;
  6406. private _minYawSin;
  6407. private _minYawCos;
  6408. private _maxYawSin;
  6409. private _maxYawCos;
  6410. private _midYawConstraint;
  6411. private _minPitchTan;
  6412. private _maxPitchTan;
  6413. private _boneQuat;
  6414. private _slerping;
  6415. private _transformYawPitch;
  6416. private _transformYawPitchInv;
  6417. private _firstFrameSkipped;
  6418. private _yawRange;
  6419. private _fowardAxis;
  6420. /**
  6421. * Gets or sets the minimum yaw angle that the bone can look to
  6422. */
  6423. minYaw: number;
  6424. /**
  6425. * Gets or sets the maximum yaw angle that the bone can look to
  6426. */
  6427. maxYaw: number;
  6428. /**
  6429. * Gets or sets the minimum pitch angle that the bone can look to
  6430. */
  6431. minPitch: number;
  6432. /**
  6433. * Gets or sets the maximum pitch angle that the bone can look to
  6434. */
  6435. maxPitch: number;
  6436. /**
  6437. * Create a BoneLookController
  6438. * @param mesh the mesh that the bone belongs to
  6439. * @param bone the bone that will be looking to the target
  6440. * @param target the target Vector3 to look at
  6441. * @param settings optional settings:
  6442. * * maxYaw: the maximum angle the bone will yaw to
  6443. * * minYaw: the minimum angle the bone will yaw to
  6444. * * maxPitch: the maximum angle the bone will pitch to
  6445. * * minPitch: the minimum angle the bone will yaw to
  6446. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6447. * * upAxis: the up axis of the coordinate system
  6448. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6449. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6450. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6451. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6452. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6453. * * adjustRoll: used to make an adjustment to the roll of the bone
  6454. **/
  6455. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6456. maxYaw?: number;
  6457. minYaw?: number;
  6458. maxPitch?: number;
  6459. minPitch?: number;
  6460. slerpAmount?: number;
  6461. upAxis?: Vector3;
  6462. upAxisSpace?: Space;
  6463. yawAxis?: Vector3;
  6464. pitchAxis?: Vector3;
  6465. adjustYaw?: number;
  6466. adjustPitch?: number;
  6467. adjustRoll?: number;
  6468. });
  6469. /**
  6470. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6471. */
  6472. update(): void;
  6473. private _getAngleDiff;
  6474. private _getAngleBetween;
  6475. private _isAngleBetween;
  6476. }
  6477. }
  6478. declare module BABYLON {
  6479. /**
  6480. * Class used to handle skinning animations
  6481. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6482. */
  6483. class Skeleton implements IAnimatable {
  6484. /** defines the skeleton name */
  6485. name: string;
  6486. /** defines the skeleton Id */
  6487. id: string;
  6488. /**
  6489. * Gets the list of child bones
  6490. */
  6491. bones: Bone[];
  6492. /**
  6493. * Gets an estimate of the dimension of the skeleton at rest
  6494. */
  6495. dimensionsAtRest: Vector3;
  6496. /**
  6497. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6498. */
  6499. needInitialSkinMatrix: boolean;
  6500. /**
  6501. * Gets the list of animations attached to this skeleton
  6502. */
  6503. animations: Array<Animation>;
  6504. private _scene;
  6505. private _isDirty;
  6506. private _transformMatrices;
  6507. private _transformMatrixTexture;
  6508. private _meshesWithPoseMatrix;
  6509. private _animatables;
  6510. private _identity;
  6511. private _synchronizedWithMesh;
  6512. private _ranges;
  6513. private _lastAbsoluteTransformsUpdateId;
  6514. private _canUseTextureForBones;
  6515. /**
  6516. * Specifies if the skeleton should be serialized
  6517. */
  6518. doNotSerialize: boolean;
  6519. /**
  6520. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  6521. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  6522. */
  6523. useTextureToStoreBoneMatrices: boolean;
  6524. private _animationPropertiesOverride;
  6525. /**
  6526. * Gets or sets the animation properties override
  6527. */
  6528. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6529. /**
  6530. * An observable triggered before computing the skeleton's matrices
  6531. */
  6532. onBeforeComputeObservable: Observable<Skeleton>;
  6533. /**
  6534. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  6535. */
  6536. readonly isUsingTextureForMatrices: boolean;
  6537. /**
  6538. * Creates a new skeleton
  6539. * @param name defines the skeleton name
  6540. * @param id defines the skeleton Id
  6541. * @param scene defines the hosting scene
  6542. */
  6543. constructor(
  6544. /** defines the skeleton name */
  6545. name: string,
  6546. /** defines the skeleton Id */
  6547. id: string, scene: Scene);
  6548. /**
  6549. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6550. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6551. * @returns a Float32Array containing matrices data
  6552. */
  6553. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6554. /**
  6555. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  6556. * @returns a raw texture containing the data
  6557. */
  6558. getTransformMatrixTexture(): Nullable<RawTexture>;
  6559. /**
  6560. * Gets the current hosting scene
  6561. * @returns a scene object
  6562. */
  6563. getScene(): Scene;
  6564. /**
  6565. * Gets a string representing the current skeleton data
  6566. * @param fullDetails defines a boolean indicating if we want a verbose version
  6567. * @returns a string representing the current skeleton data
  6568. */
  6569. toString(fullDetails?: boolean): string;
  6570. /**
  6571. * Get bone's index searching by name
  6572. * @param name defines bone's name to search for
  6573. * @return the indice of the bone. Returns -1 if not found
  6574. */
  6575. getBoneIndexByName(name: string): number;
  6576. /**
  6577. * Creater a new animation range
  6578. * @param name defines the name of the range
  6579. * @param from defines the start key
  6580. * @param to defines the end key
  6581. */
  6582. createAnimationRange(name: string, from: number, to: number): void;
  6583. /**
  6584. * Delete a specific animation range
  6585. * @param name defines the name of the range
  6586. * @param deleteFrames defines if frames must be removed as well
  6587. */
  6588. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6589. /**
  6590. * Gets a specific animation range
  6591. * @param name defines the name of the range to look for
  6592. * @returns the requested animation range or null if not found
  6593. */
  6594. getAnimationRange(name: string): Nullable<AnimationRange>;
  6595. /**
  6596. * Gets the list of all animation ranges defined on this skeleton
  6597. * @returns an array
  6598. */
  6599. getAnimationRanges(): Nullable<AnimationRange>[];
  6600. /**
  6601. * Copy animation range from a source skeleton.
  6602. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6603. * @param source defines the source skeleton
  6604. * @param name defines the name of the range to copy
  6605. * @param rescaleAsRequired defines if rescaling must be applied if required
  6606. * @returns true if operation was successful
  6607. */
  6608. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6609. /**
  6610. * Forces the skeleton to go to rest pose
  6611. */
  6612. returnToRest(): void;
  6613. private _getHighestAnimationFrame;
  6614. /**
  6615. * Begin a specific animation range
  6616. * @param name defines the name of the range to start
  6617. * @param loop defines if looping must be turned on (false by default)
  6618. * @param speedRatio defines the speed ratio to apply (1 by default)
  6619. * @param onAnimationEnd defines a callback which will be called when animation will end
  6620. * @returns a new animatable
  6621. */
  6622. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6623. /** @hidden */
  6624. _markAsDirty(): void;
  6625. /** @hidden */
  6626. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6627. /** @hidden */
  6628. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6629. private _computeTransformMatrices;
  6630. /**
  6631. * Build all resources required to render a skeleton
  6632. */
  6633. prepare(): void;
  6634. /**
  6635. * Gets the list of animatables currently running for this skeleton
  6636. * @returns an array of animatables
  6637. */
  6638. getAnimatables(): IAnimatable[];
  6639. /**
  6640. * Clone the current skeleton
  6641. * @param name defines the name of the new skeleton
  6642. * @param id defines the id of the enw skeleton
  6643. * @returns the new skeleton
  6644. */
  6645. clone(name: string, id: string): Skeleton;
  6646. /**
  6647. * Enable animation blending for this skeleton
  6648. * @param blendingSpeed defines the blending speed to apply
  6649. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6650. */
  6651. enableBlending(blendingSpeed?: number): void;
  6652. /**
  6653. * Releases all resources associated with the current skeleton
  6654. */
  6655. dispose(): void;
  6656. /**
  6657. * Serialize the skeleton in a JSON object
  6658. * @returns a JSON object
  6659. */
  6660. serialize(): any;
  6661. /**
  6662. * Creates a new skeleton from serialized data
  6663. * @param parsedSkeleton defines the serialized data
  6664. * @param scene defines the hosting scene
  6665. * @returns a new skeleton
  6666. */
  6667. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6668. /**
  6669. * Compute all node absolute transforms
  6670. * @param forceUpdate defines if computation must be done even if cache is up to date
  6671. */
  6672. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6673. /**
  6674. * Gets the root pose matrix
  6675. * @returns a matrix
  6676. */
  6677. getPoseMatrix(): Nullable<Matrix>;
  6678. /**
  6679. * Sorts bones per internal index
  6680. */
  6681. sortBones(): void;
  6682. private _sortBones;
  6683. }
  6684. }
  6685. declare module BABYLON {
  6686. /**
  6687. * This represents an orbital type of camera.
  6688. *
  6689. * 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.
  6690. * 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.
  6691. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  6692. */
  6693. class ArcRotateCamera extends TargetCamera {
  6694. /**
  6695. * Defines the rotation angle of the camera along the longitudinal axis.
  6696. */
  6697. alpha: number;
  6698. /**
  6699. * Defines the rotation angle of the camera along the latitudinal axis.
  6700. */
  6701. beta: number;
  6702. /**
  6703. * Defines the radius of the camera from it s target point.
  6704. */
  6705. radius: number;
  6706. protected _target: Vector3;
  6707. protected _targetHost: Nullable<AbstractMesh>;
  6708. /**
  6709. * Defines the target point of the camera.
  6710. * The camera looks towards it form the radius distance.
  6711. */
  6712. target: Vector3;
  6713. /**
  6714. * Current inertia value on the longitudinal axis.
  6715. * The bigger this number the longer it will take for the camera to stop.
  6716. */
  6717. inertialAlphaOffset: number;
  6718. /**
  6719. * Current inertia value on the latitudinal axis.
  6720. * The bigger this number the longer it will take for the camera to stop.
  6721. */
  6722. inertialBetaOffset: number;
  6723. /**
  6724. * Current inertia value on the radius axis.
  6725. * The bigger this number the longer it will take for the camera to stop.
  6726. */
  6727. inertialRadiusOffset: number;
  6728. /**
  6729. * Minimum allowed angle on the longitudinal axis.
  6730. * This can help limiting how the Camera is able to move in the scene.
  6731. */
  6732. lowerAlphaLimit: Nullable<number>;
  6733. /**
  6734. * Maximum allowed angle on the longitudinal axis.
  6735. * This can help limiting how the Camera is able to move in the scene.
  6736. */
  6737. upperAlphaLimit: Nullable<number>;
  6738. /**
  6739. * Minimum allowed angle on the latitudinal axis.
  6740. * This can help limiting how the Camera is able to move in the scene.
  6741. */
  6742. lowerBetaLimit: number;
  6743. /**
  6744. * Maximum allowed angle on the latitudinal axis.
  6745. * This can help limiting how the Camera is able to move in the scene.
  6746. */
  6747. upperBetaLimit: number;
  6748. /**
  6749. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  6750. * This can help limiting how the Camera is able to move in the scene.
  6751. */
  6752. lowerRadiusLimit: Nullable<number>;
  6753. /**
  6754. * Maximum allowed distance of the camera to the target (The camera can not get further).
  6755. * This can help limiting how the Camera is able to move in the scene.
  6756. */
  6757. upperRadiusLimit: Nullable<number>;
  6758. /**
  6759. * Defines the current inertia value used during panning of the camera along the X axis.
  6760. */
  6761. inertialPanningX: number;
  6762. /**
  6763. * Defines the current inertia value used during panning of the camera along the Y axis.
  6764. */
  6765. inertialPanningY: number;
  6766. /**
  6767. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  6768. * Basically if your fingers moves away from more than this distance you will be considered
  6769. * in pinch mode.
  6770. */
  6771. pinchToPanMaxDistance: number;
  6772. /**
  6773. * Defines the maximum distance the camera can pan.
  6774. * This could help keeping the cammera always in your scene.
  6775. */
  6776. panningDistanceLimit: Nullable<number>;
  6777. /**
  6778. * Defines the target of the camera before paning.
  6779. */
  6780. panningOriginTarget: Vector3;
  6781. /**
  6782. * Defines the value of the inertia used during panning.
  6783. * 0 would mean stop inertia and one would mean no decelleration at all.
  6784. */
  6785. panningInertia: number;
  6786. /**
  6787. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  6788. */
  6789. angularSensibilityX: number;
  6790. /**
  6791. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  6792. */
  6793. angularSensibilityY: number;
  6794. /**
  6795. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  6796. */
  6797. pinchPrecision: number;
  6798. /**
  6799. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  6800. * It will be used instead of pinchDeltaPrecision if different from 0.
  6801. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6802. */
  6803. pinchDeltaPercentage: number;
  6804. /**
  6805. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  6806. */
  6807. panningSensibility: number;
  6808. /**
  6809. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  6810. */
  6811. keysUp: number[];
  6812. /**
  6813. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  6814. */
  6815. keysDown: number[];
  6816. /**
  6817. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  6818. */
  6819. keysLeft: number[];
  6820. /**
  6821. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  6822. */
  6823. keysRight: number[];
  6824. /**
  6825. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  6826. */
  6827. wheelPrecision: number;
  6828. /**
  6829. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  6830. * It will be used instead of pinchDeltaPrecision if different from 0.
  6831. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6832. */
  6833. wheelDeltaPercentage: number;
  6834. /**
  6835. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  6836. */
  6837. zoomOnFactor: number;
  6838. /**
  6839. * Defines a screen offset for the camera position.
  6840. */
  6841. targetScreenOffset: Vector2;
  6842. /**
  6843. * Allows the camera to be completely reversed.
  6844. * If false the camera can not arrive upside down.
  6845. */
  6846. allowUpsideDown: boolean;
  6847. /**
  6848. * Define if double tap/click is used to restore the previously saved state of the camera.
  6849. */
  6850. useInputToRestoreState: boolean;
  6851. /** @hidden */
  6852. _viewMatrix: Matrix;
  6853. /** @hidden */
  6854. _useCtrlForPanning: boolean;
  6855. /** @hidden */
  6856. _panningMouseButton: number;
  6857. /**
  6858. * Defines the inpute associated to the camera.
  6859. */
  6860. inputs: ArcRotateCameraInputsManager;
  6861. /** @hidden */
  6862. _reset: () => void;
  6863. /**
  6864. * Defines the allowed panning axis.
  6865. */
  6866. panningAxis: Vector3;
  6867. protected _localDirection: Vector3;
  6868. protected _transformedDirection: Vector3;
  6869. private _bouncingBehavior;
  6870. /**
  6871. * Gets the bouncing behavior of the camera if it has been enabled.
  6872. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6873. */
  6874. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  6875. /**
  6876. * Defines if the bouncing behavior of the camera is enabled on the camera.
  6877. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6878. */
  6879. useBouncingBehavior: boolean;
  6880. private _framingBehavior;
  6881. /**
  6882. * Gets the framing behavior of the camera if it has been enabled.
  6883. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  6884. */
  6885. readonly framingBehavior: Nullable<FramingBehavior>;
  6886. /**
  6887. * Defines if the framing behavior of the camera is enabled on the camera.
  6888. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  6889. */
  6890. useFramingBehavior: boolean;
  6891. private _autoRotationBehavior;
  6892. /**
  6893. * Gets the auto rotation behavior of the camera if it has been enabled.
  6894. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  6895. */
  6896. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  6897. /**
  6898. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  6899. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  6900. */
  6901. useAutoRotationBehavior: boolean;
  6902. /**
  6903. * Observable triggered when the mesh target has been changed on the camera.
  6904. */
  6905. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  6906. /**
  6907. * Event raised when the camera is colliding with a mesh.
  6908. */
  6909. onCollide: (collidedMesh: AbstractMesh) => void;
  6910. /**
  6911. * Defines whether the camera should check collision with the objects oh the scene.
  6912. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  6913. */
  6914. checkCollisions: boolean;
  6915. /**
  6916. * Defines the collision radius of the camera.
  6917. * This simulates a sphere around the camera.
  6918. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  6919. */
  6920. collisionRadius: Vector3;
  6921. protected _collider: Collider;
  6922. protected _previousPosition: Vector3;
  6923. protected _collisionVelocity: Vector3;
  6924. protected _newPosition: Vector3;
  6925. protected _previousAlpha: number;
  6926. protected _previousBeta: number;
  6927. protected _previousRadius: number;
  6928. protected _collisionTriggered: boolean;
  6929. protected _targetBoundingCenter: Nullable<Vector3>;
  6930. private _computationVector;
  6931. /**
  6932. * Instantiates a new ArcRotateCamera in a given scene
  6933. * @param name Defines the name of the camera
  6934. * @param alpha Defines the camera rotation along the logitudinal axis
  6935. * @param beta Defines the camera rotation along the latitudinal axis
  6936. * @param radius Defines the camera distance from its target
  6937. * @param target Defines the camera target
  6938. * @param scene Defines the scene the camera belongs to
  6939. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  6940. */
  6941. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6942. /** @hidden */
  6943. _initCache(): void;
  6944. /** @hidden */
  6945. _updateCache(ignoreParentClass?: boolean): void;
  6946. protected _getTargetPosition(): Vector3;
  6947. private _storedAlpha;
  6948. private _storedBeta;
  6949. private _storedRadius;
  6950. private _storedTarget;
  6951. /**
  6952. * Stores the current state of the camera (alpha, beta, radius and target)
  6953. * @returns the camera itself
  6954. */
  6955. storeState(): Camera;
  6956. /**
  6957. * @hidden
  6958. * Restored camera state. You must call storeState() first
  6959. */
  6960. _restoreStateValues(): boolean;
  6961. /** @hidden */
  6962. _isSynchronizedViewMatrix(): boolean;
  6963. /**
  6964. * Attached controls to the current camera.
  6965. * @param element Defines the element the controls should be listened from
  6966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6967. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  6968. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  6969. */
  6970. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  6971. /**
  6972. * Detach the current controls from the camera.
  6973. * The camera will stop reacting to inputs.
  6974. * @param element Defines the element to stop listening the inputs from
  6975. */
  6976. detachControl(element: HTMLElement): void;
  6977. /** @hidden */
  6978. _checkInputs(): void;
  6979. protected _checkLimits(): void;
  6980. /**
  6981. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  6982. */
  6983. rebuildAnglesAndRadius(): void;
  6984. /**
  6985. * Use a position to define the current camera related information like aplha, beta and radius
  6986. * @param position Defines the position to set the camera at
  6987. */
  6988. setPosition(position: Vector3): void;
  6989. /**
  6990. * Defines the target the camera should look at.
  6991. * This will automatically adapt alpha beta and radius to fit within the new target.
  6992. * @param target Defines the new target as a Vector or a mesh
  6993. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  6994. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  6995. */
  6996. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  6997. /** @hidden */
  6998. _getViewMatrix(): Matrix;
  6999. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7000. /**
  7001. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7002. * @param meshes Defines the mesh to zoom on
  7003. * @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)
  7004. */
  7005. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7006. /**
  7007. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7008. * The target will be changed but the radius
  7009. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7010. * @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)
  7011. */
  7012. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7013. min: Vector3;
  7014. max: Vector3;
  7015. distance: number;
  7016. }, doNotUpdateMaxZ?: boolean): void;
  7017. /**
  7018. * @override
  7019. * Override Camera.createRigCamera
  7020. */
  7021. createRigCamera(name: string, cameraIndex: number): Camera;
  7022. /**
  7023. * @hidden
  7024. * @override
  7025. * Override Camera._updateRigCameras
  7026. */
  7027. _updateRigCameras(): void;
  7028. /**
  7029. * Destroy the camera and release the current resources hold by it.
  7030. */
  7031. dispose(): void;
  7032. /**
  7033. * Gets the current object class name.
  7034. * @return the class name
  7035. */
  7036. getClassName(): string;
  7037. }
  7038. }
  7039. declare module BABYLON {
  7040. /**
  7041. * Default Inputs manager for the ArcRotateCamera.
  7042. * It groups all the default supported inputs for ease of use.
  7043. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7044. */
  7045. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7046. /**
  7047. * Instantiates a new ArcRotateCameraInputsManager.
  7048. * @param camera Defines the camera the inputs belong to
  7049. */
  7050. constructor(camera: ArcRotateCamera);
  7051. /**
  7052. * Add mouse wheel input support to the input manager.
  7053. * @returns the current input manager
  7054. */
  7055. addMouseWheel(): ArcRotateCameraInputsManager;
  7056. /**
  7057. * Add pointers input support to the input manager.
  7058. * @returns the current input manager
  7059. */
  7060. addPointers(): ArcRotateCameraInputsManager;
  7061. /**
  7062. * Add keyboard input support to the input manager.
  7063. * @returns the current input manager
  7064. */
  7065. addKeyboard(): ArcRotateCameraInputsManager;
  7066. /**
  7067. * Add orientation input support to the input manager.
  7068. * @returns the current input manager
  7069. */
  7070. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7071. }
  7072. }
  7073. declare module BABYLON {
  7074. /**
  7075. * This is the base class of all the camera used in the application.
  7076. * @see http://doc.babylonjs.com/features/cameras
  7077. */
  7078. class Camera extends Node {
  7079. /**
  7080. * This is the default projection mode used by the cameras.
  7081. * It helps recreating a feeling of perspective and better appreciate depth.
  7082. * This is the best way to simulate real life cameras.
  7083. */
  7084. static readonly PERSPECTIVE_CAMERA: number;
  7085. /**
  7086. * This helps creating camera with an orthographic mode.
  7087. * 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.
  7088. */
  7089. static readonly ORTHOGRAPHIC_CAMERA: number;
  7090. /**
  7091. * This is the default FOV mode for perspective cameras.
  7092. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7093. */
  7094. static readonly FOVMODE_VERTICAL_FIXED: number;
  7095. /**
  7096. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7097. */
  7098. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7099. /**
  7100. * This specifies ther is no need for a camera rig.
  7101. * Basically only one eye is rendered corresponding to the camera.
  7102. */
  7103. static readonly RIG_MODE_NONE: number;
  7104. /**
  7105. * Simulates a camera Rig with one blue eye and one red eye.
  7106. * This can be use with 3d blue and red glasses.
  7107. */
  7108. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7109. /**
  7110. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7111. */
  7112. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7113. /**
  7114. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7115. */
  7116. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7117. /**
  7118. * Defines that both eyes of the camera will be rendered over under each other.
  7119. */
  7120. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7121. /**
  7122. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7123. */
  7124. static readonly RIG_MODE_VR: number;
  7125. /**
  7126. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7127. */
  7128. static readonly RIG_MODE_WEBVR: number;
  7129. /**
  7130. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  7131. */
  7132. static readonly RIG_MODE_CUSTOM: number;
  7133. /**
  7134. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7135. */
  7136. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7137. /**
  7138. * @hidden
  7139. * Might be removed once multiview will be a thing
  7140. */
  7141. static UseAlternateWebVRRendering: boolean;
  7142. /**
  7143. * Define the input manager associated with the camera.
  7144. */
  7145. inputs: CameraInputsManager<Camera>;
  7146. /**
  7147. * Define the current local position of the camera in the scene
  7148. */
  7149. position: Vector3;
  7150. /**
  7151. * The vector the camera should consider as up.
  7152. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7153. */
  7154. upVector: Vector3;
  7155. /**
  7156. * Define the current limit on the left side for an orthographic camera
  7157. * In scene unit
  7158. */
  7159. orthoLeft: Nullable<number>;
  7160. /**
  7161. * Define the current limit on the right side for an orthographic camera
  7162. * In scene unit
  7163. */
  7164. orthoRight: Nullable<number>;
  7165. /**
  7166. * Define the current limit on the bottom side for an orthographic camera
  7167. * In scene unit
  7168. */
  7169. orthoBottom: Nullable<number>;
  7170. /**
  7171. * Define the current limit on the top side for an orthographic camera
  7172. * In scene unit
  7173. */
  7174. orthoTop: Nullable<number>;
  7175. /**
  7176. * Field Of View is set in Radians. (default is 0.8)
  7177. */
  7178. fov: number;
  7179. /**
  7180. * Define the minimum distance the camera can see from.
  7181. * This is important to note that the depth buffer are not infinite and the closer it starts
  7182. * the more your scene might encounter depth fighting issue.
  7183. */
  7184. minZ: number;
  7185. /**
  7186. * Define the maximum distance the camera can see to.
  7187. * This is important to note that the depth buffer are not infinite and the further it end
  7188. * the more your scene might encounter depth fighting issue.
  7189. */
  7190. maxZ: number;
  7191. /**
  7192. * Define the default inertia of the camera.
  7193. * This helps giving a smooth feeling to the camera movement.
  7194. */
  7195. inertia: number;
  7196. /**
  7197. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7198. */
  7199. mode: number;
  7200. /**
  7201. * Define wether the camera is intermediate.
  7202. * This is usefull to not present the output directly to the screen in case of rig without post process for instance
  7203. */
  7204. isIntermediate: boolean;
  7205. /**
  7206. * Define the viewport of the camera.
  7207. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7208. */
  7209. viewport: Viewport;
  7210. /**
  7211. * Restricts the camera to viewing objects with the same layerMask.
  7212. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7213. */
  7214. layerMask: number;
  7215. /**
  7216. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7217. */
  7218. fovMode: number;
  7219. /**
  7220. * Rig mode of the camera.
  7221. * This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7222. * This is normally controlled byt the camera themselves as internal use.
  7223. */
  7224. cameraRigMode: number;
  7225. /**
  7226. * Defines the distance between both "eyes" in case of a RIG
  7227. */
  7228. interaxialDistance: number;
  7229. /**
  7230. * Defines if stereoscopic rendering is done side by side or over under.
  7231. */
  7232. isStereoscopicSideBySide: boolean;
  7233. /**
  7234. * 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
  7235. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7236. * else in the scene.
  7237. */
  7238. customRenderTargets: RenderTargetTexture[];
  7239. /**
  7240. * When set, the camera will render to this render target instead of the default canvas
  7241. */
  7242. outputRenderTarget: Nullable<RenderTargetTexture>;
  7243. /**
  7244. * Observable triggered when the camera view matrix has changed.
  7245. */
  7246. onViewMatrixChangedObservable: Observable<Camera>;
  7247. /**
  7248. * Observable triggered when the camera Projection matrix has changed.
  7249. */
  7250. onProjectionMatrixChangedObservable: Observable<Camera>;
  7251. /**
  7252. * Observable triggered when the inputs have been processed.
  7253. */
  7254. onAfterCheckInputsObservable: Observable<Camera>;
  7255. /**
  7256. * Observable triggered when reset has been called and applied to the camera.
  7257. */
  7258. onRestoreStateObservable: Observable<Camera>;
  7259. /** @hidden */
  7260. _cameraRigParams: any;
  7261. /** @hidden */
  7262. _rigCameras: Camera[];
  7263. /** @hidden */
  7264. _rigPostProcess: Nullable<PostProcess>;
  7265. protected _webvrViewMatrix: Matrix;
  7266. /** @hidden */
  7267. _skipRendering: boolean;
  7268. /** @hidden */
  7269. _alternateCamera: Camera;
  7270. /** @hidden */
  7271. _projectionMatrix: Matrix;
  7272. /** @hidden */
  7273. _postProcesses: Nullable<PostProcess>[];
  7274. /** @hidden */
  7275. _activeMeshes: SmartArray<AbstractMesh>;
  7276. protected _globalPosition: Vector3;
  7277. /** hidden */
  7278. _computedViewMatrix: Matrix;
  7279. private _doNotComputeProjectionMatrix;
  7280. private _transformMatrix;
  7281. private _frustumPlanes;
  7282. private _refreshFrustumPlanes;
  7283. private _storedFov;
  7284. private _stateStored;
  7285. /**
  7286. * Instantiates a new camera object.
  7287. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7288. * @see http://doc.babylonjs.com/features/cameras
  7289. * @param name Defines the name of the camera in the scene
  7290. * @param position Defines the position of the camera
  7291. * @param scene Defines the scene the camera belongs too
  7292. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7293. */
  7294. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7295. /**
  7296. * Store current camera state (fov, position, etc..)
  7297. * @returns the camera
  7298. */
  7299. storeState(): Camera;
  7300. /**
  7301. * Restores the camera state values if it has been stored. You must call storeState() first
  7302. */
  7303. protected _restoreStateValues(): boolean;
  7304. /**
  7305. * Restored camera state. You must call storeState() first.
  7306. * @returns true if restored and false otherwise
  7307. */
  7308. restoreState(): boolean;
  7309. /**
  7310. * Gets the class name of the camera.
  7311. * @returns the class name
  7312. */
  7313. getClassName(): string;
  7314. /**
  7315. * Gets a string representation of the camera usefull for debug purpose.
  7316. * @param fullDetails Defines that a more verboe level of logging is required
  7317. * @returns the string representation
  7318. */
  7319. toString(fullDetails?: boolean): string;
  7320. /**
  7321. * Gets the current world space position of the camera.
  7322. */
  7323. readonly globalPosition: Vector3;
  7324. /**
  7325. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7326. * @returns the active meshe list
  7327. */
  7328. getActiveMeshes(): SmartArray<AbstractMesh>;
  7329. /**
  7330. * Check wether a mesh is part of the current active mesh list of the camera
  7331. * @param mesh Defines the mesh to check
  7332. * @returns true if active, false otherwise
  7333. */
  7334. isActiveMesh(mesh: Mesh): boolean;
  7335. /**
  7336. * Is this camera ready to be used/rendered
  7337. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7338. * @return true if the camera is ready
  7339. */
  7340. isReady(completeCheck?: boolean): boolean;
  7341. /** @hidden */
  7342. _initCache(): void;
  7343. /** @hidden */
  7344. _updateCache(ignoreParentClass?: boolean): void;
  7345. /** @hidden */
  7346. _isSynchronized(): boolean;
  7347. /** @hidden */
  7348. _isSynchronizedViewMatrix(): boolean;
  7349. /** @hidden */
  7350. _isSynchronizedProjectionMatrix(): boolean;
  7351. /**
  7352. * Attach the input controls to a specific dom element to get the input from.
  7353. * @param element Defines the element the controls should be listened from
  7354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7355. */
  7356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7357. /**
  7358. * Detach the current controls from the specified dom element.
  7359. * @param element Defines the element to stop listening the inputs from
  7360. */
  7361. detachControl(element: HTMLElement): void;
  7362. /**
  7363. * Update the camera state according to the different inputs gathered during the frame.
  7364. */
  7365. update(): void;
  7366. /** @hidden */
  7367. _checkInputs(): void;
  7368. /** @hidden */
  7369. readonly rigCameras: Camera[];
  7370. /**
  7371. * Gets the post process used by the rig cameras
  7372. */
  7373. readonly rigPostProcess: Nullable<PostProcess>;
  7374. /**
  7375. * Internal, gets the first post proces.
  7376. * @returns the first post process to be run on this camera.
  7377. */
  7378. _getFirstPostProcess(): Nullable<PostProcess>;
  7379. private _cascadePostProcessesToRigCams;
  7380. /**
  7381. * Attach a post process to the camera.
  7382. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7383. * @param postProcess The post process to attach to the camera
  7384. * @param insertAt The position of the post process in case several of them are in use in the scene
  7385. * @returns the position the post process has been inserted at
  7386. */
  7387. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  7388. /**
  7389. * Detach a post process to the camera.
  7390. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7391. * @param postProcess The post process to detach from the camera
  7392. */
  7393. detachPostProcess(postProcess: PostProcess): void;
  7394. /**
  7395. * Gets the current world matrix of the camera
  7396. */
  7397. getWorldMatrix(): Matrix;
  7398. /** @hidden */
  7399. protected _getViewMatrix(): Matrix;
  7400. /**
  7401. * Gets the current view matrix of the camera.
  7402. * @param force forces the camera to recompute the matrix without looking at the cached state
  7403. * @returns the view matrix
  7404. */
  7405. getViewMatrix(force?: boolean): Matrix;
  7406. /**
  7407. * Freeze the projection matrix.
  7408. * It will prevent the cache check of the camera projection compute and can speed up perf
  7409. * if no parameter of the camera are meant to change
  7410. * @param projection Defines manually a projection if necessary
  7411. */
  7412. freezeProjectionMatrix(projection?: Matrix): void;
  7413. /**
  7414. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  7415. */
  7416. unfreezeProjectionMatrix(): void;
  7417. /**
  7418. * Gets the current projection matrix of the camera.
  7419. * @param force forces the camera to recompute the matrix without looking at the cached state
  7420. * @returns the projection matrix
  7421. */
  7422. getProjectionMatrix(force?: boolean): Matrix;
  7423. /**
  7424. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  7425. * @returns a Matrix
  7426. */
  7427. getTransformationMatrix(): Matrix;
  7428. private _updateFrustumPlanes;
  7429. /**
  7430. * Checks if a cullable object (mesh...) is in the camera frustum
  7431. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  7432. * @param target The object to check
  7433. * @returns true if the object is in frustum otherwise false
  7434. */
  7435. isInFrustum(target: ICullable): boolean;
  7436. /**
  7437. * Checks if a cullable object (mesh...) is in the camera frustum
  7438. * Unlike isInFrustum this cheks the full bounding box
  7439. * @param target The object to check
  7440. * @returns true if the object is in frustum otherwise false
  7441. */
  7442. isCompletelyInFrustum(target: ICullable): boolean;
  7443. /**
  7444. * Gets a ray in the forward direction from the camera.
  7445. * @param length Defines the length of the ray to create
  7446. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  7447. * @param origin Defines the start point of the ray which defaults to the camera position
  7448. * @returns the forward ray
  7449. */
  7450. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  7451. /**
  7452. * Releases resources associated with this node.
  7453. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7454. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7455. */
  7456. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7457. /**
  7458. * Gets the left camera of a rig setup in case of Rigged Camera
  7459. */
  7460. readonly leftCamera: Nullable<FreeCamera>;
  7461. /**
  7462. * Gets the right camera of a rig setup in case of Rigged Camera
  7463. */
  7464. readonly rightCamera: Nullable<FreeCamera>;
  7465. /**
  7466. * Gets the left camera target of a rig setup in case of Rigged Camera
  7467. * @returns the target position
  7468. */
  7469. getLeftTarget(): Nullable<Vector3>;
  7470. /**
  7471. * Gets the right camera target of a rig setup in case of Rigged Camera
  7472. * @returns the target position
  7473. */
  7474. getRightTarget(): Nullable<Vector3>;
  7475. /**
  7476. * @hidden
  7477. */
  7478. setCameraRigMode(mode: number, rigParams: any): void;
  7479. private _getVRProjectionMatrix;
  7480. protected _updateCameraRotationMatrix(): void;
  7481. protected _updateWebVRCameraRotationMatrix(): void;
  7482. /**
  7483. * This function MUST be overwritten by the different WebVR cameras available.
  7484. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7485. */
  7486. protected _getWebVRProjectionMatrix(): Matrix;
  7487. /**
  7488. * This function MUST be overwritten by the different WebVR cameras available.
  7489. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7490. */
  7491. protected _getWebVRViewMatrix(): Matrix;
  7492. /** @hidden */
  7493. setCameraRigParameter(name: string, value: any): void;
  7494. /**
  7495. * needs to be overridden by children so sub has required properties to be copied
  7496. * @hidden
  7497. */
  7498. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7499. /**
  7500. * May need to be overridden by children
  7501. * @hidden
  7502. */
  7503. _updateRigCameras(): void;
  7504. /** @hidden */
  7505. _setupInputs(): void;
  7506. /**
  7507. * Serialiaze the camera setup to a json represention
  7508. * @returns the JSON representation
  7509. */
  7510. serialize(): any;
  7511. /**
  7512. * Clones the current camera.
  7513. * @param name The cloned camera name
  7514. * @returns the cloned camera
  7515. */
  7516. clone(name: string): Camera;
  7517. /**
  7518. * Gets the direction of the camera relative to a given local axis.
  7519. * @param localAxis Defines the reference axis to provide a relative direction.
  7520. * @return the direction
  7521. */
  7522. getDirection(localAxis: Vector3): Vector3;
  7523. /**
  7524. * Gets the direction of the camera relative to a given local axis into a passed vector.
  7525. * @param localAxis Defines the reference axis to provide a relative direction.
  7526. * @param result Defines the vector to store the result in
  7527. */
  7528. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  7529. /**
  7530. * Gets a camera constructor for a given camera type
  7531. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  7532. * @param name The name of the camera the result will be able to instantiate
  7533. * @param scene The scene the result will construct the camera in
  7534. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  7535. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  7536. * @returns a factory method to construc the camera
  7537. */
  7538. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  7539. /**
  7540. * Compute the world matrix of the camera.
  7541. * @returns the camera workd matrix
  7542. */
  7543. computeWorldMatrix(): Matrix;
  7544. /**
  7545. * Parse a JSON and creates the camera from the parsed information
  7546. * @param parsedCamera The JSON to parse
  7547. * @param scene The scene to instantiate the camera in
  7548. * @returns the newly constructed camera
  7549. */
  7550. static Parse(parsedCamera: any, scene: Scene): Camera;
  7551. }
  7552. }
  7553. declare module BABYLON {
  7554. /**
  7555. * @ignore
  7556. * This is a list of all the different input types that are available in the application.
  7557. * Fo instance: ArcRotateCameraGamepadInput...
  7558. */
  7559. var CameraInputTypes: {};
  7560. /**
  7561. * This is the contract to implement in order to create a new input class.
  7562. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7563. */
  7564. interface ICameraInput<TCamera extends Camera> {
  7565. /**
  7566. * Defines the camera the input is attached to.
  7567. */
  7568. camera: Nullable<TCamera>;
  7569. /**
  7570. * Gets the class name of the current intput.
  7571. * @returns the class name
  7572. */
  7573. getClassName(): string;
  7574. /**
  7575. * Get the friendly name associated with the input class.
  7576. * @returns the input friendly name
  7577. */
  7578. getSimpleName(): string;
  7579. /**
  7580. * Attach the input controls to a specific dom element to get the input from.
  7581. * @param element Defines the element the controls should be listened from
  7582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7583. */
  7584. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7585. /**
  7586. * Detach the current controls from the specified dom element.
  7587. * @param element Defines the element to stop listening the inputs from
  7588. */
  7589. detachControl(element: Nullable<HTMLElement>): void;
  7590. /**
  7591. * Update the current camera state depending on the inputs that have been used this frame.
  7592. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7593. */
  7594. checkInputs?: () => void;
  7595. }
  7596. /**
  7597. * Represents a map of input types to input instance or input index to input instance.
  7598. */
  7599. interface CameraInputsMap<TCamera extends Camera> {
  7600. /**
  7601. * Accessor to the input by input type.
  7602. */
  7603. [name: string]: ICameraInput<TCamera>;
  7604. /**
  7605. * Accessor to the input by input index.
  7606. */
  7607. [idx: number]: ICameraInput<TCamera>;
  7608. }
  7609. /**
  7610. * This represents the input manager used within a camera.
  7611. * It helps dealing with all the different kind of input attached to a camera.
  7612. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7613. */
  7614. class CameraInputsManager<TCamera extends Camera> {
  7615. /**
  7616. * Defines the list of inputs attahed to the camera.
  7617. */
  7618. attached: CameraInputsMap<TCamera>;
  7619. /**
  7620. * Defines the dom element the camera is collecting inputs from.
  7621. * This is null if the controls have not been attached.
  7622. */
  7623. attachedElement: Nullable<HTMLElement>;
  7624. /**
  7625. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7626. */
  7627. noPreventDefault: boolean;
  7628. /**
  7629. * Defined the camera the input manager belongs to.
  7630. */
  7631. camera: TCamera;
  7632. /**
  7633. * Update the current camera state depending on the inputs that have been used this frame.
  7634. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7635. */
  7636. checkInputs: () => void;
  7637. /**
  7638. * Instantiate a new Camera Input Manager.
  7639. * @param camera Defines the camera the input manager blongs to
  7640. */
  7641. constructor(camera: TCamera);
  7642. /**
  7643. * Add an input method to a camera
  7644. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7645. * @param input camera input method
  7646. */
  7647. add(input: ICameraInput<TCamera>): void;
  7648. /**
  7649. * Remove a specific input method from a camera
  7650. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  7651. * @param inputToRemove camera input method
  7652. */
  7653. remove(inputToRemove: ICameraInput<TCamera>): void;
  7654. /**
  7655. * Remove a specific input type from a camera
  7656. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  7657. * @param inputType the type of the input to remove
  7658. */
  7659. removeByType(inputType: string): void;
  7660. private _addCheckInputs;
  7661. /**
  7662. * Attach the input controls to the currently attached dom element to listen the events from.
  7663. * @param input Defines the input to attach
  7664. */
  7665. attachInput(input: ICameraInput<TCamera>): void;
  7666. /**
  7667. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  7668. * @param element Defines the dom element to collect the events from
  7669. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7670. */
  7671. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  7672. /**
  7673. * Detach the current manager inputs controls from a specific dom element.
  7674. * @param element Defines the dom element to collect the events from
  7675. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  7676. */
  7677. detachElement(element: HTMLElement, disconnect?: boolean): void;
  7678. /**
  7679. * Rebuild the dynamic inputCheck function from the current list of
  7680. * defined inputs in the manager.
  7681. */
  7682. rebuildInputCheck(): void;
  7683. /**
  7684. * Remove all attached input methods from a camera
  7685. */
  7686. clear(): void;
  7687. /**
  7688. * Serialize the current input manager attached to a camera.
  7689. * This ensures than once parsed,
  7690. * the input associated to the camera will be identical to the current ones
  7691. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  7692. */
  7693. serialize(serializedCamera: any): void;
  7694. /**
  7695. * Parses an input manager serialized JSON to restore the previous list of inputs
  7696. * and states associated to a camera.
  7697. * @param parsedCamera Defines the JSON to parse
  7698. */
  7699. parse(parsedCamera: any): void;
  7700. }
  7701. }
  7702. declare module BABYLON {
  7703. /**
  7704. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  7705. * being tilted forward or back and left or right.
  7706. */
  7707. class DeviceOrientationCamera extends FreeCamera {
  7708. private _initialQuaternion;
  7709. private _quaternionCache;
  7710. /**
  7711. * Creates a new device orientation camera
  7712. * @param name The name of the camera
  7713. * @param position The start position camera
  7714. * @param scene The scene the camera belongs to
  7715. */
  7716. constructor(name: string, position: Vector3, scene: Scene);
  7717. /**
  7718. * Gets the current instance class name ("DeviceOrientationCamera").
  7719. * This helps avoiding instanceof at run time.
  7720. * @returns the class name
  7721. */
  7722. getClassName(): string;
  7723. /**
  7724. * @hidden
  7725. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  7726. */
  7727. _checkInputs(): void;
  7728. /**
  7729. * Reset the camera to its default orientation on the specified axis only.
  7730. * @param axis The axis to reset
  7731. */
  7732. resetToCurrentRotation(axis?: Axis): void;
  7733. }
  7734. }
  7735. declare module BABYLON {
  7736. /**
  7737. * This is a flying camera, designed for 3D movement and rotation in all directions,
  7738. * such as in a 3D Space Shooter or a Flight Simulator.
  7739. */
  7740. class FlyCamera extends TargetCamera {
  7741. /**
  7742. * Define the collision ellipsoid of the camera.
  7743. * This is helpful for simulating a camera body, like a player's body.
  7744. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7745. */
  7746. ellipsoid: Vector3;
  7747. /**
  7748. * Define an offset for the position of the ellipsoid around the camera.
  7749. * This can be helpful if the camera is attached away from the player's body center,
  7750. * such as at its head.
  7751. */
  7752. ellipsoidOffset: Vector3;
  7753. /**
  7754. * Enable or disable collisions of the camera with the rest of the scene objects.
  7755. */
  7756. checkCollisions: boolean;
  7757. /**
  7758. * Enable or disable gravity on the camera.
  7759. */
  7760. applyGravity: boolean;
  7761. /**
  7762. * Define the current direction the camera is moving to.
  7763. */
  7764. cameraDirection: Vector3;
  7765. /**
  7766. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  7767. * This overrides and empties cameraRotation.
  7768. */
  7769. rotationQuaternion: BABYLON.Quaternion;
  7770. /**
  7771. * Track Roll to maintain the wanted Rolling when looking around.
  7772. */
  7773. _trackRoll: number;
  7774. /**
  7775. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  7776. */
  7777. rollCorrect: number;
  7778. /**
  7779. * Mimic a banked turn, Rolling the camera when Yawing.
  7780. * It's recommended to use rollCorrect = 10 for faster banking correction.
  7781. */
  7782. bankedTurn: boolean;
  7783. /**
  7784. * Limit in radians for how much Roll banking will add. (Default: 90°)
  7785. */
  7786. bankedTurnLimit: number;
  7787. /**
  7788. * Value of 0 disables the banked Roll.
  7789. * Value of 1 is equal to the Yaw angle in radians.
  7790. */
  7791. bankedTurnMultiplier: number;
  7792. /**
  7793. * The inputs manager loads all the input sources, such as keyboard and mouse.
  7794. */
  7795. inputs: FlyCameraInputsManager;
  7796. /**
  7797. * Gets the input sensibility for mouse input.
  7798. * Higher values reduce sensitivity.
  7799. */
  7800. /**
  7801. * Sets the input sensibility for a mouse input.
  7802. * Higher values reduce sensitivity.
  7803. */
  7804. angularSensibility: number;
  7805. /**
  7806. * Get the keys for camera movement forward.
  7807. */
  7808. /**
  7809. * Set the keys for camera movement forward.
  7810. */
  7811. keysForward: number[];
  7812. /**
  7813. * Get the keys for camera movement backward.
  7814. */
  7815. keysBackward: number[];
  7816. /**
  7817. * Get the keys for camera movement up.
  7818. */
  7819. /**
  7820. * Set the keys for camera movement up.
  7821. */
  7822. keysUp: number[];
  7823. /**
  7824. * Get the keys for camera movement down.
  7825. */
  7826. /**
  7827. * Set the keys for camera movement down.
  7828. */
  7829. keysDown: number[];
  7830. /**
  7831. * Get the keys for camera movement left.
  7832. */
  7833. /**
  7834. * Set the keys for camera movement left.
  7835. */
  7836. keysLeft: number[];
  7837. /**
  7838. * Set the keys for camera movement right.
  7839. */
  7840. /**
  7841. * Set the keys for camera movement right.
  7842. */
  7843. keysRight: number[];
  7844. /**
  7845. * Event raised when the camera collides with a mesh in the scene.
  7846. */
  7847. onCollide: (collidedMesh: AbstractMesh) => void;
  7848. private _collider;
  7849. private _needMoveForGravity;
  7850. private _oldPosition;
  7851. private _diffPosition;
  7852. private _newPosition;
  7853. /** @hidden */
  7854. _localDirection: Vector3;
  7855. /** @hidden */
  7856. _transformedDirection: Vector3;
  7857. /**
  7858. * Instantiates a FlyCamera.
  7859. * This is a flying camera, designed for 3D movement and rotation in all directions,
  7860. * such as in a 3D Space Shooter or a Flight Simulator.
  7861. * @param name Define the name of the camera in the scene.
  7862. * @param position Define the starting position of the camera in the scene.
  7863. * @param scene Define the scene the camera belongs to.
  7864. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  7865. */
  7866. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7867. /**
  7868. * Attach a control to the HTML DOM element.
  7869. * @param element Defines the element that listens to the input events.
  7870. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  7871. */
  7872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7873. /**
  7874. * Detach a control from the HTML DOM element.
  7875. * The camera will stop reacting to that input.
  7876. * @param element Defines the element that listens to the input events.
  7877. */
  7878. detachControl(element: HTMLElement): void;
  7879. private _collisionMask;
  7880. /**
  7881. * Get the mask that the camera ignores in collision events.
  7882. */
  7883. /**
  7884. * Set the mask that the camera ignores in collision events.
  7885. */
  7886. collisionMask: number;
  7887. /** @hidden */
  7888. _collideWithWorld(displacement: Vector3): void;
  7889. /** @hidden */
  7890. private _onCollisionPositionChange;
  7891. /** @hidden */
  7892. _checkInputs(): void;
  7893. /** @hidden */
  7894. _decideIfNeedsToMove(): boolean;
  7895. /** @hidden */
  7896. _updatePosition(): void;
  7897. /**
  7898. * Restore the Roll to its target value at the rate specified.
  7899. * @param rate - Higher means slower restoring.
  7900. * @hidden
  7901. */
  7902. restoreRoll(rate: number): void;
  7903. /**
  7904. * Destroy the camera and release the current resources held by it.
  7905. */
  7906. dispose(): void;
  7907. /**
  7908. * Get the current object class name.
  7909. * @returns the class name.
  7910. */
  7911. getClassName(): string;
  7912. }
  7913. }
  7914. declare module BABYLON {
  7915. /**
  7916. * Default Inputs manager for the FlyCamera.
  7917. * It groups all the default supported inputs for ease of use.
  7918. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7919. */
  7920. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  7921. /**
  7922. * Instantiates a new FlyCameraInputsManager.
  7923. * @param camera Defines the camera the inputs belong to.
  7924. */
  7925. constructor(camera: FlyCamera);
  7926. /**
  7927. * Add keyboard input support to the input manager.
  7928. * @returns the new FlyCameraKeyboardMoveInput().
  7929. */
  7930. addKeyboard(): FlyCameraInputsManager;
  7931. /**
  7932. * Add mouse input support to the input manager.
  7933. * @param touchEnabled Enable touch screen support.
  7934. * @returns the new FlyCameraMouseInput().
  7935. */
  7936. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  7937. }
  7938. }
  7939. declare module BABYLON {
  7940. /**
  7941. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  7942. * an arc rotate version arcFollowCamera are available.
  7943. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7944. */
  7945. class FollowCamera extends TargetCamera {
  7946. /**
  7947. * Distance the follow camera should follow an object at
  7948. */
  7949. radius: number;
  7950. /**
  7951. * Define a rotation offset between the camera and the object it follows
  7952. */
  7953. rotationOffset: number;
  7954. /**
  7955. * Define a height offset between the camera and the object it follows.
  7956. * It can help following an object from the top (like a car chaing a plane)
  7957. */
  7958. heightOffset: number;
  7959. /**
  7960. * Define how fast the camera can accelerate to follow it s target.
  7961. */
  7962. cameraAcceleration: number;
  7963. /**
  7964. * Define the speed limit of the camera following an object.
  7965. */
  7966. maxCameraSpeed: number;
  7967. /**
  7968. * Define the target of the camera.
  7969. */
  7970. lockedTarget: Nullable<AbstractMesh>;
  7971. /**
  7972. * Instantiates the follow camera.
  7973. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7974. * @param name Define the name of the camera in the scene
  7975. * @param position Define the position of the camera
  7976. * @param scene Define the scene the camera belong to
  7977. * @param lockedTarget Define the target of the camera
  7978. */
  7979. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  7980. private _follow;
  7981. /** @hidden */
  7982. _checkInputs(): void;
  7983. /**
  7984. * Gets the camera class name.
  7985. * @returns the class name
  7986. */
  7987. getClassName(): string;
  7988. }
  7989. /**
  7990. * Arc Rotate version of the follow camera.
  7991. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  7992. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7993. */
  7994. class ArcFollowCamera extends TargetCamera {
  7995. /** The longitudinal angle of the camera */
  7996. alpha: number;
  7997. /** The latitudinal angle of the camera */
  7998. beta: number;
  7999. /** The radius of the camera from its target */
  8000. radius: number;
  8001. /** Define the camera target (the messh it should follow) */
  8002. target: Nullable<AbstractMesh>;
  8003. private _cartesianCoordinates;
  8004. /**
  8005. * Instantiates a new ArcFollowCamera
  8006. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8007. * @param name Define the name of the camera
  8008. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8009. * @param beta Define the rotation angle of the camera around the elevation axis
  8010. * @param radius Define the radius of the camera from its target point
  8011. * @param target Define the target of the camera
  8012. * @param scene Define the scene the camera belongs to
  8013. */
  8014. constructor(name: string,
  8015. /** The longitudinal angle of the camera */
  8016. alpha: number,
  8017. /** The latitudinal angle of the camera */
  8018. beta: number,
  8019. /** The radius of the camera from its target */
  8020. radius: number,
  8021. /** Define the camera target (the messh it should follow) */
  8022. target: Nullable<AbstractMesh>, scene: Scene);
  8023. private _follow;
  8024. /** @hidden */
  8025. _checkInputs(): void;
  8026. /**
  8027. * Returns the class name of the object.
  8028. * It is mostly used internally for serialization purposes.
  8029. */
  8030. getClassName(): string;
  8031. }
  8032. }
  8033. declare module BABYLON {
  8034. /**
  8035. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8036. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8037. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8038. */
  8039. class FreeCamera extends TargetCamera {
  8040. /**
  8041. * Define the collision ellipsoid of the camera.
  8042. * This is helpful to simulate a camera body like the player body around the camera
  8043. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8044. */
  8045. ellipsoid: Vector3;
  8046. /**
  8047. * Define an offset for the position of the ellipsoid around the camera.
  8048. * This can be helpful to determine the center of the body near the gravity center of the body
  8049. * instead of its head.
  8050. */
  8051. ellipsoidOffset: Vector3;
  8052. /**
  8053. * Enable or disable collisions of the camera with the rest of the scene objects.
  8054. */
  8055. checkCollisions: boolean;
  8056. /**
  8057. * Enable or disable gravity on the camera.
  8058. */
  8059. applyGravity: boolean;
  8060. /**
  8061. * Define the input manager associated to the camera.
  8062. */
  8063. inputs: FreeCameraInputsManager;
  8064. /**
  8065. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8066. * Higher values reduce sensitivity.
  8067. */
  8068. /**
  8069. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8070. * Higher values reduce sensitivity.
  8071. */
  8072. angularSensibility: number;
  8073. /**
  8074. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8075. */
  8076. keysUp: number[];
  8077. /**
  8078. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8079. */
  8080. keysDown: number[];
  8081. /**
  8082. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8083. */
  8084. keysLeft: number[];
  8085. /**
  8086. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8087. */
  8088. keysRight: number[];
  8089. /**
  8090. * Event raised when the camera collide with a mesh in the scene.
  8091. */
  8092. onCollide: (collidedMesh: AbstractMesh) => void;
  8093. private _collider;
  8094. private _needMoveForGravity;
  8095. private _oldPosition;
  8096. private _diffPosition;
  8097. private _newPosition;
  8098. /** @hidden */
  8099. _localDirection: Vector3;
  8100. /** @hidden */
  8101. _transformedDirection: Vector3;
  8102. /**
  8103. * Instantiates a Free Camera.
  8104. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8105. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8106. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8107. * @param name Define the name of the camera in the scene
  8108. * @param position Define the start position of the camera in the scene
  8109. * @param scene Define the scene the camera belongs to
  8110. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8111. */
  8112. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8113. /**
  8114. * Attached controls to the current camera.
  8115. * @param element Defines the element the controls should be listened from
  8116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8117. */
  8118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8119. /**
  8120. * Detach the current controls from the camera.
  8121. * The camera will stop reacting to inputs.
  8122. * @param element Defines the element to stop listening the inputs from
  8123. */
  8124. detachControl(element: HTMLElement): void;
  8125. private _collisionMask;
  8126. /**
  8127. * Define a collision mask to limit the list of object the camera can collide with
  8128. */
  8129. collisionMask: number;
  8130. /** @hidden */
  8131. _collideWithWorld(displacement: Vector3): void;
  8132. private _onCollisionPositionChange;
  8133. /** @hidden */
  8134. _checkInputs(): void;
  8135. /** @hidden */
  8136. _decideIfNeedsToMove(): boolean;
  8137. /** @hidden */
  8138. _updatePosition(): void;
  8139. /**
  8140. * Destroy the camera and release the current resources hold by it.
  8141. */
  8142. dispose(): void;
  8143. /**
  8144. * Gets the current object class name.
  8145. * @return the class name
  8146. */
  8147. getClassName(): string;
  8148. }
  8149. }
  8150. declare module BABYLON {
  8151. /**
  8152. * Default Inputs manager for the FreeCamera.
  8153. * It groups all the default supported inputs for ease of use.
  8154. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8155. */
  8156. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8157. /**
  8158. * Instantiates a new FreeCameraInputsManager.
  8159. * @param camera Defines the camera the inputs belong to
  8160. */
  8161. constructor(camera: FreeCamera);
  8162. /**
  8163. * Add keyboard input support to the input manager.
  8164. * @returns the current input manager
  8165. */
  8166. addKeyboard(): FreeCameraInputsManager;
  8167. /**
  8168. * Add mouse input support to the input manager.
  8169. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8170. * @returns the current input manager
  8171. */
  8172. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8173. /**
  8174. * Add orientation input support to the input manager.
  8175. * @returns the current input manager
  8176. */
  8177. addDeviceOrientation(): FreeCameraInputsManager;
  8178. /**
  8179. * Add touch input support to the input manager.
  8180. * @returns the current input manager
  8181. */
  8182. addTouch(): FreeCameraInputsManager;
  8183. /**
  8184. * Add virtual joystick input support to the input manager.
  8185. * @returns the current input manager
  8186. */
  8187. addVirtualJoystick(): FreeCameraInputsManager;
  8188. }
  8189. }
  8190. declare module BABYLON {
  8191. /**
  8192. * This represents a FPS type of camera. This is only here for back compat purpose.
  8193. * Please use the UniversalCamera instead as both are identical.
  8194. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8195. */
  8196. class GamepadCamera extends UniversalCamera {
  8197. /**
  8198. * Instantiates a new Gamepad Camera
  8199. * This represents a FPS type of camera. This is only here for back compat purpose.
  8200. * Please use the UniversalCamera instead as both are identical.
  8201. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8202. * @param name Define the name of the camera in the scene
  8203. * @param position Define the start position of the camera in the scene
  8204. * @param scene Define the scene the camera belongs to
  8205. */
  8206. constructor(name: string, position: Vector3, scene: Scene);
  8207. /**
  8208. * Gets the current object class name.
  8209. * @return the class name
  8210. */
  8211. getClassName(): string;
  8212. }
  8213. }
  8214. declare module BABYLON {
  8215. /**
  8216. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8217. * This is the base of the follow, arc rotate cameras and Free camera
  8218. * @see http://doc.babylonjs.com/features/cameras
  8219. */
  8220. class TargetCamera extends Camera {
  8221. /**
  8222. * Define the current direction the camera is moving to
  8223. */
  8224. cameraDirection: Vector3;
  8225. /**
  8226. * Define the current rotation the camera is rotating to
  8227. */
  8228. cameraRotation: Vector2;
  8229. /**
  8230. * Define the current rotation of the camera
  8231. */
  8232. rotation: Vector3;
  8233. /**
  8234. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8235. */
  8236. rotationQuaternion: Quaternion;
  8237. /**
  8238. * Define the current speed of the camera
  8239. */
  8240. speed: number;
  8241. /**
  8242. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8243. * around all axis.
  8244. */
  8245. noRotationConstraint: boolean;
  8246. /**
  8247. * Define the current target of the camera as an object or a position.
  8248. */
  8249. lockedTarget: any;
  8250. /** @hidden */
  8251. _currentTarget: Vector3;
  8252. /** @hidden */
  8253. _viewMatrix: Matrix;
  8254. /** @hidden */
  8255. _camMatrix: Matrix;
  8256. /** @hidden */
  8257. _cameraTransformMatrix: Matrix;
  8258. /** @hidden */
  8259. _cameraRotationMatrix: Matrix;
  8260. private _rigCamTransformMatrix;
  8261. /** @hidden */
  8262. _referencePoint: Vector3;
  8263. /** @hidden */
  8264. _transformedReferencePoint: Vector3;
  8265. protected _globalCurrentTarget: Vector3;
  8266. protected _globalCurrentUpVector: Vector3;
  8267. /** @hidden */
  8268. _reset: () => void;
  8269. private _defaultUp;
  8270. /**
  8271. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8272. * This is the base of the follow, arc rotate cameras and Free camera
  8273. * @see http://doc.babylonjs.com/features/cameras
  8274. * @param name Defines the name of the camera in the scene
  8275. * @param position Defines the start position of the camera in the scene
  8276. * @param scene Defines the scene the camera belongs to
  8277. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8278. */
  8279. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8280. /**
  8281. * Gets the position in front of the camera at a given distance.
  8282. * @param distance The distance from the camera we want the position to be
  8283. * @returns the position
  8284. */
  8285. getFrontPosition(distance: number): Vector3;
  8286. /** @hidden */
  8287. _getLockedTargetPosition(): Nullable<Vector3>;
  8288. private _storedPosition;
  8289. private _storedRotation;
  8290. private _storedRotationQuaternion;
  8291. /**
  8292. * Store current camera state of the camera (fov, position, rotation, etc..)
  8293. * @returns the camera
  8294. */
  8295. storeState(): Camera;
  8296. /**
  8297. * Restored camera state. You must call storeState() first
  8298. * @returns whether it was successful or not
  8299. * @hidden
  8300. */
  8301. _restoreStateValues(): boolean;
  8302. /** @hidden */
  8303. _initCache(): void;
  8304. /** @hidden */
  8305. _updateCache(ignoreParentClass?: boolean): void;
  8306. /** @hidden */
  8307. _isSynchronizedViewMatrix(): boolean;
  8308. /** @hidden */
  8309. _computeLocalCameraSpeed(): number;
  8310. /** @hidden */
  8311. setTarget(target: Vector3): void;
  8312. /**
  8313. * Return the current target position of the camera. This value is expressed in local space.
  8314. * @returns the target position
  8315. */
  8316. getTarget(): Vector3;
  8317. /** @hidden */
  8318. _decideIfNeedsToMove(): boolean;
  8319. /** @hidden */
  8320. _updatePosition(): void;
  8321. /** @hidden */
  8322. _checkInputs(): void;
  8323. protected _updateCameraRotationMatrix(): void;
  8324. /**
  8325. * 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)
  8326. * @returns the current camera
  8327. */
  8328. private _rotateUpVectorWithCameraRotationMatrix;
  8329. private _cachedRotationZ;
  8330. private _cachedQuaternionRotationZ;
  8331. /** @hidden */
  8332. _getViewMatrix(): Matrix;
  8333. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8334. /**
  8335. * @hidden
  8336. */
  8337. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8338. /**
  8339. * @hidden
  8340. */
  8341. _updateRigCameras(): void;
  8342. private _getRigCamPosition;
  8343. /**
  8344. * Gets the current object class name.
  8345. * @return the class name
  8346. */
  8347. getClassName(): string;
  8348. }
  8349. }
  8350. declare module BABYLON {
  8351. /**
  8352. * This represents a FPS type of camera controlled by touch.
  8353. * This is like a universal camera minus the Gamepad controls.
  8354. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8355. */
  8356. class TouchCamera extends FreeCamera {
  8357. /**
  8358. * Defines the touch sensibility for rotation.
  8359. * The higher the faster.
  8360. */
  8361. touchAngularSensibility: number;
  8362. /**
  8363. * Defines the touch sensibility for move.
  8364. * The higher the faster.
  8365. */
  8366. touchMoveSensibility: number;
  8367. /**
  8368. * Instantiates a new touch camera.
  8369. * This represents a FPS type of camera controlled by touch.
  8370. * This is like a universal camera minus the Gamepad controls.
  8371. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8372. * @param name Define the name of the camera in the scene
  8373. * @param position Define the start position of the camera in the scene
  8374. * @param scene Define the scene the camera belongs to
  8375. */
  8376. constructor(name: string, position: Vector3, scene: Scene);
  8377. /**
  8378. * Gets the current object class name.
  8379. * @return the class name
  8380. */
  8381. getClassName(): string;
  8382. /** @hidden */
  8383. _setupInputs(): void;
  8384. }
  8385. }
  8386. declare module BABYLON {
  8387. /**
  8388. * 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,
  8389. * which still works and will still be found in many Playgrounds.
  8390. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8391. */
  8392. class UniversalCamera extends TouchCamera {
  8393. /**
  8394. * Defines the gamepad rotation sensiblity.
  8395. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  8396. */
  8397. gamepadAngularSensibility: number;
  8398. /**
  8399. * Defines the gamepad move sensiblity.
  8400. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  8401. */
  8402. gamepadMoveSensibility: number;
  8403. /**
  8404. * 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,
  8405. * which still works and will still be found in many Playgrounds.
  8406. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8407. * @param name Define the name of the camera in the scene
  8408. * @param position Define the start position of the camera in the scene
  8409. * @param scene Define the scene the camera belongs to
  8410. */
  8411. constructor(name: string, position: Vector3, scene: Scene);
  8412. /**
  8413. * Gets the current object class name.
  8414. * @return the class name
  8415. */
  8416. getClassName(): string;
  8417. }
  8418. }
  8419. declare module BABYLON {
  8420. /**
  8421. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8422. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8423. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8424. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8425. */
  8426. class VirtualJoysticksCamera extends FreeCamera {
  8427. /**
  8428. * Intantiates a VirtualJoysticksCamera. It can be usefull in First Person Shooter game for instance.
  8429. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8430. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8431. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8432. * @param name Define the name of the camera in the scene
  8433. * @param position Define the start position of the camera in the scene
  8434. * @param scene Define the scene the camera belongs to
  8435. */
  8436. constructor(name: string, position: Vector3, scene: Scene);
  8437. /**
  8438. * Gets the current object class name.
  8439. * @return the class name
  8440. */
  8441. getClassName(): string;
  8442. }
  8443. }
  8444. interface VRDisplay extends EventTarget {
  8445. /**
  8446. * Dictionary of capabilities describing the VRDisplay.
  8447. */
  8448. readonly capabilities: VRDisplayCapabilities;
  8449. /**
  8450. * z-depth defining the far plane of the eye view frustum
  8451. * enables mapping of values in the render target depth
  8452. * attachment to scene coordinates. Initially set to 10000.0.
  8453. */
  8454. depthFar: number;
  8455. /**
  8456. * z-depth defining the near plane of the eye view frustum
  8457. * enables mapping of values in the render target depth
  8458. * attachment to scene coordinates. Initially set to 0.01.
  8459. */
  8460. depthNear: number;
  8461. /**
  8462. * An identifier for this distinct VRDisplay. Used as an
  8463. * association point in the Gamepad API.
  8464. */
  8465. readonly displayId: number;
  8466. /**
  8467. * A display name, a user-readable name identifying it.
  8468. */
  8469. readonly displayName: string;
  8470. readonly isConnected: boolean;
  8471. readonly isPresenting: boolean;
  8472. /**
  8473. * If this VRDisplay supports room-scale experiences, the optional
  8474. * stage attribute contains details on the room-scale parameters.
  8475. */
  8476. readonly stageParameters: VRStageParameters | null;
  8477. /**
  8478. * Passing the value returned by `requestAnimationFrame` to
  8479. * `cancelAnimationFrame` will unregister the callback.
  8480. * @param handle Define the hanle of the request to cancel
  8481. */
  8482. cancelAnimationFrame(handle: number): void;
  8483. /**
  8484. * Stops presenting to the VRDisplay.
  8485. * @returns a promise to know when it stopped
  8486. */
  8487. exitPresent(): Promise<void>;
  8488. /**
  8489. * Return the current VREyeParameters for the given eye.
  8490. * @param whichEye Define the eye we want the parameter for
  8491. * @returns the eye parameters
  8492. */
  8493. getEyeParameters(whichEye: string): VREyeParameters;
  8494. /**
  8495. * Populates the passed VRFrameData with the information required to render
  8496. * the current frame.
  8497. * @param frameData Define the data structure to populate
  8498. * @returns true if ok otherwise false
  8499. */
  8500. getFrameData(frameData: VRFrameData): boolean;
  8501. /**
  8502. * Get the layers currently being presented.
  8503. * @returns the list of VR layers
  8504. */
  8505. getLayers(): VRLayer[];
  8506. /**
  8507. * Return a VRPose containing the future predicted pose of the VRDisplay
  8508. * when the current frame will be presented. The value returned will not
  8509. * change until JavaScript has returned control to the browser.
  8510. *
  8511. * The VRPose will contain the position, orientation, velocity,
  8512. * and acceleration of each of these properties.
  8513. * @returns the pose object
  8514. */
  8515. getPose(): VRPose;
  8516. /**
  8517. * Return the current instantaneous pose of the VRDisplay, with no
  8518. * prediction applied.
  8519. * @returns the current instantaneous pose
  8520. */
  8521. getImmediatePose(): VRPose;
  8522. /**
  8523. * The callback passed to `requestAnimationFrame` will be called
  8524. * any time a new frame should be rendered. When the VRDisplay is
  8525. * presenting the callback will be called at the native refresh
  8526. * rate of the HMD. When not presenting this function acts
  8527. * identically to how window.requestAnimationFrame acts. Content should
  8528. * make no assumptions of frame rate or vsync behavior as the HMD runs
  8529. * asynchronously from other displays and at differing refresh rates.
  8530. * @param callback Define the eaction to run next frame
  8531. * @returns the request handle it
  8532. */
  8533. requestAnimationFrame(callback: FrameRequestCallback): number;
  8534. /**
  8535. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  8536. * Repeat calls while already presenting will update the VRLayers being displayed.
  8537. * @param layers Define the list of layer to present
  8538. * @returns a promise to know when the request has been fulfilled
  8539. */
  8540. requestPresent(layers: VRLayer[]): Promise<void>;
  8541. /**
  8542. * Reset the pose for this display, treating its current position and
  8543. * orientation as the "origin/zero" values. VRPose.position,
  8544. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  8545. * updated when calling resetPose(). This should be called in only
  8546. * sitting-space experiences.
  8547. */
  8548. resetPose(): void;
  8549. /**
  8550. * The VRLayer provided to the VRDisplay will be captured and presented
  8551. * in the HMD. Calling this function has the same effect on the source
  8552. * canvas as any other operation that uses its source image, and canvases
  8553. * created without preserveDrawingBuffer set to true will be cleared.
  8554. * @param pose Define the pose to submit
  8555. */
  8556. submitFrame(pose?: VRPose): void;
  8557. }
  8558. declare var VRDisplay: {
  8559. prototype: VRDisplay;
  8560. new (): VRDisplay;
  8561. };
  8562. interface VRLayer {
  8563. leftBounds?: number[] | Float32Array | null;
  8564. rightBounds?: number[] | Float32Array | null;
  8565. source?: HTMLCanvasElement | null;
  8566. }
  8567. interface VRDisplayCapabilities {
  8568. readonly canPresent: boolean;
  8569. readonly hasExternalDisplay: boolean;
  8570. readonly hasOrientation: boolean;
  8571. readonly hasPosition: boolean;
  8572. readonly maxLayers: number;
  8573. }
  8574. interface VREyeParameters {
  8575. /** @deprecated */
  8576. readonly fieldOfView: VRFieldOfView;
  8577. readonly offset: Float32Array;
  8578. readonly renderHeight: number;
  8579. readonly renderWidth: number;
  8580. }
  8581. interface VRFieldOfView {
  8582. readonly downDegrees: number;
  8583. readonly leftDegrees: number;
  8584. readonly rightDegrees: number;
  8585. readonly upDegrees: number;
  8586. }
  8587. interface VRFrameData {
  8588. readonly leftProjectionMatrix: Float32Array;
  8589. readonly leftViewMatrix: Float32Array;
  8590. readonly pose: VRPose;
  8591. readonly rightProjectionMatrix: Float32Array;
  8592. readonly rightViewMatrix: Float32Array;
  8593. readonly timestamp: number;
  8594. }
  8595. interface VRPose {
  8596. readonly angularAcceleration: Float32Array | null;
  8597. readonly angularVelocity: Float32Array | null;
  8598. readonly linearAcceleration: Float32Array | null;
  8599. readonly linearVelocity: Float32Array | null;
  8600. readonly orientation: Float32Array | null;
  8601. readonly position: Float32Array | null;
  8602. readonly timestamp: number;
  8603. }
  8604. interface VRStageParameters {
  8605. sittingToStandingTransform?: Float32Array;
  8606. sizeX?: number;
  8607. sizeY?: number;
  8608. }
  8609. interface Navigator {
  8610. getVRDisplays(): Promise<VRDisplay[]>;
  8611. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  8612. }
  8613. interface Window {
  8614. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  8615. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  8616. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  8617. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8618. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8619. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  8620. }
  8621. interface Gamepad {
  8622. readonly displayId: number;
  8623. }
  8624. declare module BABYLON {
  8625. /** @hidden */
  8626. class Collider {
  8627. /** Define if a collision was found */
  8628. collisionFound: boolean;
  8629. /**
  8630. * Define last intersection point in local space
  8631. */
  8632. intersectionPoint: Vector3;
  8633. /**
  8634. * Define last collided mesh
  8635. */
  8636. collidedMesh: Nullable<AbstractMesh>;
  8637. private _collisionPoint;
  8638. private _planeIntersectionPoint;
  8639. private _tempVector;
  8640. private _tempVector2;
  8641. private _tempVector3;
  8642. private _tempVector4;
  8643. private _edge;
  8644. private _baseToVertex;
  8645. private _destinationPoint;
  8646. private _slidePlaneNormal;
  8647. private _displacementVector;
  8648. /** @hidden */
  8649. _radius: Vector3;
  8650. /** @hidden */
  8651. _retry: number;
  8652. private _velocity;
  8653. private _basePoint;
  8654. private _epsilon;
  8655. /** @hidden */
  8656. _velocityWorldLength: number;
  8657. /** @hidden */
  8658. _basePointWorld: Vector3;
  8659. private _velocityWorld;
  8660. private _normalizedVelocity;
  8661. /** @hidden */
  8662. _initialVelocity: Vector3;
  8663. /** @hidden */
  8664. _initialPosition: Vector3;
  8665. private _nearestDistance;
  8666. private _collisionMask;
  8667. collisionMask: number;
  8668. /**
  8669. * Gets the plane normal used to compute the sliding response (in local space)
  8670. */
  8671. readonly slidePlaneNormal: Vector3;
  8672. /** @hidden */
  8673. _initialize(source: Vector3, dir: Vector3, e: number): void;
  8674. /** @hidden */
  8675. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  8676. /** @hidden */
  8677. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  8678. /** @hidden */
  8679. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  8680. /** @hidden */
  8681. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  8682. /** @hidden */
  8683. _getResponse(pos: Vector3, vel: Vector3): void;
  8684. }
  8685. }
  8686. declare module BABYLON {
  8687. /** @hidden */
  8688. var CollisionWorker: string;
  8689. /** @hidden */
  8690. interface ICollisionCoordinator {
  8691. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8692. init(scene: Scene): void;
  8693. destroy(): void;
  8694. onMeshAdded(mesh: AbstractMesh): void;
  8695. onMeshUpdated(mesh: AbstractMesh): void;
  8696. onMeshRemoved(mesh: AbstractMesh): void;
  8697. onGeometryAdded(geometry: Geometry): void;
  8698. onGeometryUpdated(geometry: Geometry): void;
  8699. onGeometryDeleted(geometry: Geometry): void;
  8700. }
  8701. /** @hidden */
  8702. interface SerializedMesh {
  8703. id: string;
  8704. name: string;
  8705. uniqueId: number;
  8706. geometryId: Nullable<string>;
  8707. sphereCenter: Array<number>;
  8708. sphereRadius: number;
  8709. boxMinimum: Array<number>;
  8710. boxMaximum: Array<number>;
  8711. worldMatrixFromCache: any;
  8712. subMeshes: Array<SerializedSubMesh>;
  8713. checkCollisions: boolean;
  8714. }
  8715. /** @hidden */
  8716. interface SerializedSubMesh {
  8717. position: number;
  8718. verticesStart: number;
  8719. verticesCount: number;
  8720. indexStart: number;
  8721. indexCount: number;
  8722. hasMaterial: boolean;
  8723. sphereCenter: Array<number>;
  8724. sphereRadius: number;
  8725. boxMinimum: Array<number>;
  8726. boxMaximum: Array<number>;
  8727. }
  8728. /**
  8729. * Interface describing the value associated with a geometry.
  8730. * @hidden
  8731. */
  8732. interface SerializedGeometry {
  8733. /**
  8734. * Defines the unique ID of the geometry
  8735. */
  8736. id: string;
  8737. /**
  8738. * Defines the array containing the positions
  8739. */
  8740. positions: Float32Array;
  8741. /**
  8742. * Defines the array containing the indices
  8743. */
  8744. indices: Uint32Array;
  8745. /**
  8746. * Defines the array containing the normals
  8747. */
  8748. normals: Float32Array;
  8749. }
  8750. /** @hidden */
  8751. interface BabylonMessage {
  8752. taskType: WorkerTaskType;
  8753. payload: InitPayload | CollidePayload | UpdatePayload;
  8754. }
  8755. /** @hidden */
  8756. interface SerializedColliderToWorker {
  8757. position: Array<number>;
  8758. velocity: Array<number>;
  8759. radius: Array<number>;
  8760. }
  8761. /** Defines supported task for worker process */
  8762. enum WorkerTaskType {
  8763. /** Initialization */
  8764. INIT = 0,
  8765. /** Update of geometry */
  8766. UPDATE = 1,
  8767. /** Evaluate collision */
  8768. COLLIDE = 2
  8769. }
  8770. /** @hidden */
  8771. interface WorkerReply {
  8772. error: WorkerReplyType;
  8773. taskType: WorkerTaskType;
  8774. payload?: any;
  8775. }
  8776. /** @hidden */
  8777. interface CollisionReplyPayload {
  8778. newPosition: Array<number>;
  8779. collisionId: number;
  8780. collidedMeshUniqueId: number;
  8781. }
  8782. /** @hidden */
  8783. interface InitPayload {
  8784. }
  8785. /** @hidden */
  8786. interface CollidePayload {
  8787. collisionId: number;
  8788. collider: SerializedColliderToWorker;
  8789. maximumRetry: number;
  8790. excludedMeshUniqueId: Nullable<number>;
  8791. }
  8792. /** @hidden */
  8793. interface UpdatePayload {
  8794. updatedMeshes: {
  8795. [n: number]: SerializedMesh;
  8796. };
  8797. updatedGeometries: {
  8798. [s: string]: SerializedGeometry;
  8799. };
  8800. removedMeshes: Array<number>;
  8801. removedGeometries: Array<string>;
  8802. }
  8803. /** Defines kind of replies returned by worker */
  8804. enum WorkerReplyType {
  8805. /** Success */
  8806. SUCCESS = 0,
  8807. /** Unkown error */
  8808. UNKNOWN_ERROR = 1
  8809. }
  8810. /** @hidden */
  8811. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  8812. private _scene;
  8813. private _scaledPosition;
  8814. private _scaledVelocity;
  8815. private _collisionsCallbackArray;
  8816. private _init;
  8817. private _runningUpdated;
  8818. private _worker;
  8819. private _addUpdateMeshesList;
  8820. private _addUpdateGeometriesList;
  8821. private _toRemoveMeshesArray;
  8822. private _toRemoveGeometryArray;
  8823. constructor();
  8824. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  8825. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  8826. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8827. init(scene: Scene): void;
  8828. destroy(): void;
  8829. onMeshAdded(mesh: AbstractMesh): void;
  8830. onMeshUpdated: (transformNode: TransformNode) => void;
  8831. onMeshRemoved(mesh: AbstractMesh): void;
  8832. onGeometryAdded(geometry: Geometry): void;
  8833. onGeometryUpdated: (geometry: Geometry) => void;
  8834. onGeometryDeleted(geometry: Geometry): void;
  8835. private _afterRender;
  8836. private _onMessageFromWorker;
  8837. }
  8838. /** @hidden */
  8839. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  8840. private _scene;
  8841. private _scaledPosition;
  8842. private _scaledVelocity;
  8843. private _finalPosition;
  8844. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8845. init(scene: Scene): void;
  8846. destroy(): void;
  8847. onMeshAdded(mesh: AbstractMesh): void;
  8848. onMeshUpdated(mesh: AbstractMesh): void;
  8849. onMeshRemoved(mesh: AbstractMesh): void;
  8850. onGeometryAdded(geometry: Geometry): void;
  8851. onGeometryUpdated(geometry: Geometry): void;
  8852. onGeometryDeleted(geometry: Geometry): void;
  8853. private _collideWithWorld;
  8854. }
  8855. }
  8856. declare function importScripts(...urls: string[]): void;
  8857. declare const safePostMessage: any;
  8858. declare module BABYLON {
  8859. /** @hidden */
  8860. var WorkerIncluded: boolean;
  8861. /** @hidden */
  8862. class CollisionCache {
  8863. private _meshes;
  8864. private _geometries;
  8865. getMeshes(): {
  8866. [n: number]: SerializedMesh;
  8867. };
  8868. getGeometries(): {
  8869. [s: number]: SerializedGeometry;
  8870. };
  8871. getMesh(id: any): SerializedMesh;
  8872. addMesh(mesh: SerializedMesh): void;
  8873. removeMesh(uniqueId: number): void;
  8874. getGeometry(id: string): SerializedGeometry;
  8875. addGeometry(geometry: SerializedGeometry): void;
  8876. removeGeometry(id: string): void;
  8877. }
  8878. /** @hidden */
  8879. class CollideWorker {
  8880. collider: Collider;
  8881. private _collisionCache;
  8882. private finalPosition;
  8883. private collisionsScalingMatrix;
  8884. private collisionTranformationMatrix;
  8885. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  8886. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  8887. private checkCollision;
  8888. private processCollisionsForSubMeshes;
  8889. private collideForSubMesh;
  8890. private checkSubmeshCollision;
  8891. }
  8892. /** @hidden */
  8893. interface ICollisionDetector {
  8894. onInit(payload: InitPayload): void;
  8895. onUpdate(payload: UpdatePayload): void;
  8896. onCollision(payload: CollidePayload): void;
  8897. }
  8898. /** @hidden */
  8899. class CollisionDetectorTransferable implements ICollisionDetector {
  8900. private _collisionCache;
  8901. onInit(payload: InitPayload): void;
  8902. onUpdate(payload: UpdatePayload): void;
  8903. onCollision(payload: CollidePayload): void;
  8904. }
  8905. }
  8906. declare module BABYLON {
  8907. /**
  8908. * @hidden
  8909. */
  8910. class IntersectionInfo {
  8911. bu: Nullable<number>;
  8912. bv: Nullable<number>;
  8913. distance: number;
  8914. faceId: number;
  8915. subMeshId: number;
  8916. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  8917. }
  8918. /**
  8919. * Information about the result of picking within a scene
  8920. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  8921. */
  8922. class PickingInfo {
  8923. /**
  8924. * If the pick collided with an object
  8925. */
  8926. hit: boolean;
  8927. /**
  8928. * Distance away where the pick collided
  8929. */
  8930. distance: number;
  8931. /**
  8932. * The location of pick collision
  8933. */
  8934. pickedPoint: Nullable<Vector3>;
  8935. /**
  8936. * The mesh corresponding the the pick collision
  8937. */
  8938. pickedMesh: Nullable<AbstractMesh>;
  8939. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  8940. bu: number;
  8941. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  8942. bv: number;
  8943. /** The id of the face on the mesh that was picked */
  8944. faceId: number;
  8945. /** Id of the the submesh that was picked */
  8946. subMeshId: number;
  8947. /** If a sprite was picked, this will be the sprite the pick collided with */
  8948. pickedSprite: Nullable<Sprite>;
  8949. /**
  8950. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  8951. */
  8952. originMesh: Nullable<AbstractMesh>;
  8953. /**
  8954. * The ray that was used to perform the picking.
  8955. */
  8956. ray: Nullable<Ray>;
  8957. /**
  8958. * Gets the normal correspodning to the face the pick collided with
  8959. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  8960. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  8961. * @returns The normal correspodning to the face the pick collided with
  8962. */
  8963. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  8964. /**
  8965. * Gets the texture coordinates of where the pick occured
  8966. * @returns the vector containing the coordnates of the texture
  8967. */
  8968. getTextureCoordinates(): Nullable<Vector2>;
  8969. }
  8970. }
  8971. declare module BABYLON {
  8972. /**
  8973. * Class used to store bounding box information
  8974. */
  8975. class BoundingBox implements ICullable {
  8976. /**
  8977. * Gets the 8 vectors representing the bounding box in local space
  8978. */
  8979. readonly vectors: Vector3[];
  8980. /**
  8981. * Gets the center of the bounding box in local space
  8982. */
  8983. readonly center: Vector3;
  8984. /**
  8985. * Gets the center of the bounding box in world space
  8986. */
  8987. readonly centerWorld: Vector3;
  8988. /**
  8989. * Gets the extend size in local space
  8990. */
  8991. readonly extendSize: Vector3;
  8992. /**
  8993. * Gets the extend size in world space
  8994. */
  8995. readonly extendSizeWorld: Vector3;
  8996. /**
  8997. * Gets the OBB (object bounding box) directions
  8998. */
  8999. readonly directions: Vector3[];
  9000. /**
  9001. * Gets the 8 vectors representing the bounding box in world space
  9002. */
  9003. readonly vectorsWorld: Vector3[];
  9004. /**
  9005. * Gets the minimum vector in world space
  9006. */
  9007. readonly minimumWorld: Vector3;
  9008. /**
  9009. * Gets the maximum vector in world space
  9010. */
  9011. readonly maximumWorld: Vector3;
  9012. /**
  9013. * Gets the minimum vector in local space
  9014. */
  9015. readonly minimum: Vector3;
  9016. /**
  9017. * Gets the maximum vector in local space
  9018. */
  9019. readonly maximum: Vector3;
  9020. private _worldMatrix;
  9021. private static readonly TmpVector3;
  9022. /**
  9023. * @hidden
  9024. */
  9025. _tag: number;
  9026. /**
  9027. * Creates a new bounding box
  9028. * @param min defines the minimum vector (in local space)
  9029. * @param max defines the maximum vector (in local space)
  9030. * @param worldMatrix defines the new world matrix
  9031. */
  9032. constructor(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>);
  9033. /**
  9034. * Recreates the entire bounding box from scratch as if we call the constructor in place
  9035. * @param min defines the new minimum vector (in local space)
  9036. * @param max defines the new maximum vector (in local space)
  9037. * @param worldMatrix defines the new world matrix
  9038. */
  9039. reConstruct(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>): void;
  9040. /**
  9041. * Scale the current bounding box by applying a scale factor
  9042. * @param factor defines the scale factor to apply
  9043. * @returns the current bounding box
  9044. */
  9045. scale(factor: number): BoundingBox;
  9046. /**
  9047. * Gets the world matrix of the bounding box
  9048. * @returns a matrix
  9049. */
  9050. getWorldMatrix(): Readonly<Matrix>;
  9051. /** @hidden */
  9052. _update(world: Readonly<Matrix>): void;
  9053. /**
  9054. * Tests if the bounding box is intersecting the frustum planes
  9055. * @param frustumPlanes defines the frustum planes to test
  9056. * @returns true if there is an intersection
  9057. */
  9058. isInFrustum(frustumPlanes: Array<Readonly<Plane>>): boolean;
  9059. /**
  9060. * Tests if the bounding box is entirely inside the frustum planes
  9061. * @param frustumPlanes defines the frustum planes to test
  9062. * @returns true if there is an inclusion
  9063. */
  9064. isCompletelyInFrustum(frustumPlanes: Array<Readonly<Plane>>): boolean;
  9065. /**
  9066. * Tests if a point is inside the bounding box
  9067. * @param point defines the point to test
  9068. * @returns true if the point is inside the bounding box
  9069. */
  9070. intersectsPoint(point: Readonly<Vector3>): boolean;
  9071. /**
  9072. * Tests if the bounding box intersects with a bounding sphere
  9073. * @param sphere defines the sphere to test
  9074. * @returns true if there is an intersection
  9075. */
  9076. intersectsSphere(sphere: Readonly<BoundingSphere>): boolean;
  9077. /**
  9078. * Tests if the bounding box intersects with a box defined by a min and max vectors
  9079. * @param min defines the min vector to use
  9080. * @param max defines the max vector to use
  9081. * @returns true if there is an intersection
  9082. */
  9083. intersectsMinMax(min: Readonly<Vector3>, max: Readonly<Vector3>): boolean;
  9084. /**
  9085. * Tests if two bounding boxes are intersections
  9086. * @param box0 defines the first box to test
  9087. * @param box1 defines the second box to test
  9088. * @returns true if there is an intersection
  9089. */
  9090. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  9091. /**
  9092. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  9093. * @param minPoint defines the minimum vector of the bounding box
  9094. * @param maxPoint defines the maximum vector of the bounding box
  9095. * @param sphereCenter defines the sphere center
  9096. * @param sphereRadius defines the sphere radius
  9097. * @returns true if there is an intersection
  9098. */
  9099. static IntersectsSphere(minPoint: Readonly<Vector3>, maxPoint: Readonly<Vector3>, sphereCenter: Readonly<Vector3>, sphereRadius: number): boolean;
  9100. /**
  9101. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  9102. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  9103. * @param frustumPlanes defines the frustum planes to test
  9104. * @return true if there is an inclusion
  9105. */
  9106. static IsCompletelyInFrustum(boundingVectors: Array<Readonly<Vector3>>, frustumPlanes: Array<Readonly<Plane>>): boolean;
  9107. /**
  9108. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  9109. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  9110. * @param frustumPlanes defines the frustum planes to test
  9111. * @return true if there is an intersection
  9112. */
  9113. static IsInFrustum(boundingVectors: Array<Readonly<Vector3>>, frustumPlanes: Array<Readonly<Plane>>): boolean;
  9114. }
  9115. }
  9116. declare module BABYLON {
  9117. /**
  9118. * Interface for cullable objects
  9119. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  9120. */
  9121. interface ICullable {
  9122. /**
  9123. * Checks if the object or part of the object is in the frustum
  9124. * @param frustumPlanes Camera near/planes
  9125. * @returns true if the object is in frustum otherwise false
  9126. */
  9127. isInFrustum(frustumPlanes: Plane[]): boolean;
  9128. /**
  9129. * Checks if a cullable object (mesh...) is in the camera frustum
  9130. * Unlike isInFrustum this cheks the full bounding box
  9131. * @param frustumPlanes Camera near/planes
  9132. * @returns true if the object is in frustum otherwise false
  9133. */
  9134. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  9135. }
  9136. /**
  9137. * Info for a bounding data of a mesh
  9138. */
  9139. class BoundingInfo implements ICullable {
  9140. /**
  9141. * Bounding box for the mesh
  9142. */
  9143. readonly boundingBox: BoundingBox;
  9144. /**
  9145. * Bounding sphere for the mesh
  9146. */
  9147. readonly boundingSphere: BoundingSphere;
  9148. private _isLocked;
  9149. private static readonly TmpVector3;
  9150. /**
  9151. * Constructs bounding info
  9152. * @param minimum min vector of the bounding box/sphere
  9153. * @param maximum max vector of the bounding box/sphere
  9154. * @param worldMatrix defines the new world matrix
  9155. */
  9156. constructor(minimum: Readonly<Vector3>, maximum: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>);
  9157. /**
  9158. * Recreates the entire bounding info from scratch as if we call the constructor in place
  9159. * @param min defines the new minimum vector (in local space)
  9160. * @param max defines the new maximum vector (in local space)
  9161. * @param worldMatrix defines the new world matrix
  9162. */
  9163. reConstruct(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>): void;
  9164. /**
  9165. * min vector of the bounding box/sphere
  9166. */
  9167. readonly minimum: Vector3;
  9168. /**
  9169. * max vector of the bounding box/sphere
  9170. */
  9171. readonly maximum: Vector3;
  9172. /**
  9173. * If the info is locked and won't be updated to avoid perf overhead
  9174. */
  9175. isLocked: boolean;
  9176. /**
  9177. * Updates the bounding sphere and box
  9178. * @param world world matrix to be used to update
  9179. */
  9180. update(world: Readonly<Matrix>): void;
  9181. /**
  9182. * Recreate the bounding info to be centered around a specific point given a specific extend.
  9183. * @param center New center of the bounding info
  9184. * @param extend New extend of the bounding info
  9185. * @returns the current bounding info
  9186. */
  9187. centerOn(center: Readonly<Vector3>, extend: Readonly<Vector3>): BoundingInfo;
  9188. /**
  9189. * Scale the current bounding info by applying a scale factor
  9190. * @param factor defines the scale factor to apply
  9191. * @returns the current bounding info
  9192. */
  9193. scale(factor: number): BoundingInfo;
  9194. /**
  9195. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  9196. * @param frustumPlanes defines the frustum to test
  9197. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  9198. * @returns true if the bounding info is in the frustum planes
  9199. */
  9200. isInFrustum(frustumPlanes: Array<Readonly<Plane>>, strategy?: number): boolean;
  9201. /**
  9202. * Gets the world distance between the min and max points of the bounding box
  9203. */
  9204. readonly diagonalLength: number;
  9205. /**
  9206. * Checks if a cullable object (mesh...) is in the camera frustum
  9207. * Unlike isInFrustum this cheks the full bounding box
  9208. * @param frustumPlanes Camera near/planes
  9209. * @returns true if the object is in frustum otherwise false
  9210. */
  9211. isCompletelyInFrustum(frustumPlanes: Array<Readonly<Plane>>): boolean;
  9212. /** @hidden */
  9213. _checkCollision(collider: Collider): boolean;
  9214. /**
  9215. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  9216. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  9217. * @param point the point to check intersection with
  9218. * @returns if the point intersects
  9219. */
  9220. intersectsPoint(point: Readonly<Vector3>): boolean;
  9221. /**
  9222. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  9223. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  9224. * @param boundingInfo the bounding info to check intersection with
  9225. * @param precise if the intersection should be done using OBB
  9226. * @returns if the bounding info intersects
  9227. */
  9228. intersects(boundingInfo: Readonly<BoundingInfo>, precise: boolean): boolean;
  9229. }
  9230. }
  9231. declare module BABYLON {
  9232. /**
  9233. * Class used to store bounding sphere information
  9234. */
  9235. class BoundingSphere {
  9236. /**
  9237. * Gets the center of the bounding sphere in local space
  9238. */
  9239. readonly center: Vector3;
  9240. /**
  9241. * Radius of the bounding sphere in local space
  9242. */
  9243. radius: number;
  9244. /**
  9245. * Gets the center of the bounding sphere in world space
  9246. */
  9247. readonly centerWorld: Vector3;
  9248. /**
  9249. * Radius of the bounding sphere in world space
  9250. */
  9251. radiusWorld: number;
  9252. /**
  9253. * Gets the minimum vector in local space
  9254. */
  9255. readonly minimum: Vector3;
  9256. /**
  9257. * Gets the maximum vector in local space
  9258. */
  9259. readonly maximum: Vector3;
  9260. private _worldMatrix;
  9261. private static readonly TmpVector3;
  9262. /**
  9263. * Creates a new bounding sphere
  9264. * @param min defines the minimum vector (in local space)
  9265. * @param max defines the maximum vector (in local space)
  9266. * @param worldMatrix defines the new world matrix
  9267. */
  9268. constructor(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>);
  9269. /**
  9270. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  9271. * @param min defines the new minimum vector (in local space)
  9272. * @param max defines the new maximum vector (in local space)
  9273. * @param worldMatrix defines the new world matrix
  9274. */
  9275. reConstruct(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>): void;
  9276. /**
  9277. * Scale the current bounding sphere by applying a scale factor
  9278. * @param factor defines the scale factor to apply
  9279. * @returns the current bounding box
  9280. */
  9281. scale(factor: number): BoundingSphere;
  9282. /**
  9283. * Gets the world matrix of the bounding box
  9284. * @returns a matrix
  9285. */
  9286. getWorldMatrix(): Readonly<Matrix>;
  9287. /** @hidden */
  9288. _update(worldMatrix: Readonly<Matrix>): void;
  9289. /**
  9290. * Tests if the bounding sphere is intersecting the frustum planes
  9291. * @param frustumPlanes defines the frustum planes to test
  9292. * @returns true if there is an intersection
  9293. */
  9294. isInFrustum(frustumPlanes: Array<Readonly<Plane>>): boolean;
  9295. /**
  9296. * Tests if a point is inside the bounding sphere
  9297. * @param point defines the point to test
  9298. * @returns true if the point is inside the bounding sphere
  9299. */
  9300. intersectsPoint(point: Readonly<Vector3>): boolean;
  9301. /**
  9302. * Checks if two sphere intersct
  9303. * @param sphere0 sphere 0
  9304. * @param sphere1 sphere 1
  9305. * @returns true if the speres intersect
  9306. */
  9307. static Intersects(sphere0: Readonly<BoundingSphere>, sphere1: Readonly<BoundingSphere>): boolean;
  9308. }
  9309. }
  9310. declare module BABYLON {
  9311. /**
  9312. * Class representing a ray with position and direction
  9313. */
  9314. class Ray {
  9315. /** origin point */
  9316. origin: Vector3;
  9317. /** direction */
  9318. direction: Vector3;
  9319. /** length of the ray */
  9320. length: number;
  9321. private static readonly TmpVector3;
  9322. private _tmpRay;
  9323. /**
  9324. * Creates a new ray
  9325. * @param origin origin point
  9326. * @param direction direction
  9327. * @param length length of the ray
  9328. */
  9329. constructor(
  9330. /** origin point */
  9331. origin: Vector3,
  9332. /** direction */
  9333. direction: Vector3,
  9334. /** length of the ray */
  9335. length?: number);
  9336. /**
  9337. * Checks if the ray intersects a box
  9338. * @param minimum bound of the box
  9339. * @param maximum bound of the box
  9340. * @param intersectionTreshold extra extend to be added to the box in all direction
  9341. * @returns if the box was hit
  9342. */
  9343. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3, intersectionTreshold?: number): boolean;
  9344. /**
  9345. * Checks if the ray intersects a box
  9346. * @param box the bounding box to check
  9347. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9348. * @returns if the box was hit
  9349. */
  9350. intersectsBox(box: BoundingBox, intersectionTreshold?: number): boolean;
  9351. /**
  9352. * If the ray hits a sphere
  9353. * @param sphere the bounding sphere to check
  9354. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9355. * @returns true if it hits the sphere
  9356. */
  9357. intersectsSphere(sphere: BoundingSphere, intersectionTreshold?: number): boolean;
  9358. /**
  9359. * If the ray hits a triange
  9360. * @param vertex0 triangle vertex
  9361. * @param vertex1 triangle vertex
  9362. * @param vertex2 triangle vertex
  9363. * @returns intersection information if hit
  9364. */
  9365. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  9366. /**
  9367. * Checks if ray intersects a plane
  9368. * @param plane the plane to check
  9369. * @returns the distance away it was hit
  9370. */
  9371. intersectsPlane(plane: Plane): Nullable<number>;
  9372. /**
  9373. * Checks if ray intersects a mesh
  9374. * @param mesh the mesh to check
  9375. * @param fastCheck if only the bounding box should checked
  9376. * @returns picking info of the intersecton
  9377. */
  9378. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  9379. /**
  9380. * Checks if ray intersects a mesh
  9381. * @param meshes the meshes to check
  9382. * @param fastCheck if only the bounding box should checked
  9383. * @param results array to store result in
  9384. * @returns Array of picking infos
  9385. */
  9386. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9387. private _comparePickingInfo;
  9388. private static smallnum;
  9389. private static rayl;
  9390. /**
  9391. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9392. * @param sega the first point of the segment to test the intersection against
  9393. * @param segb the second point of the segment to test the intersection against
  9394. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9395. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9396. */
  9397. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  9398. /**
  9399. * Update the ray from viewport position
  9400. * @param x position
  9401. * @param y y position
  9402. * @param viewportWidth viewport width
  9403. * @param viewportHeight viewport height
  9404. * @param world world matrix
  9405. * @param view view matrix
  9406. * @param projection projection matrix
  9407. * @returns this ray updated
  9408. */
  9409. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Readonly<Matrix>, view: Readonly<Matrix>, projection: Readonly<Matrix>): Ray;
  9410. /**
  9411. * Creates a ray with origin and direction of 0,0,0
  9412. * @returns the new ray
  9413. */
  9414. static Zero(): Ray;
  9415. /**
  9416. * Creates a new ray from screen space and viewport
  9417. * @param x position
  9418. * @param y y position
  9419. * @param viewportWidth viewport width
  9420. * @param viewportHeight viewport height
  9421. * @param world world matrix
  9422. * @param view view matrix
  9423. * @param projection projection matrix
  9424. * @returns new ray
  9425. */
  9426. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  9427. /**
  9428. * 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
  9429. * transformed to the given world matrix.
  9430. * @param origin The origin point
  9431. * @param end The end point
  9432. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9433. * @returns the new ray
  9434. */
  9435. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Readonly<Matrix>): Ray;
  9436. /**
  9437. * Transforms a ray by a matrix
  9438. * @param ray ray to transform
  9439. * @param matrix matrix to apply
  9440. * @returns the resulting new ray
  9441. */
  9442. static Transform(ray: Ray, matrix: Readonly<Matrix>): Ray;
  9443. /**
  9444. * Transforms a ray by a matrix
  9445. * @param ray ray to transform
  9446. * @param matrix matrix to apply
  9447. * @param result ray to store result in
  9448. */
  9449. static TransformToRef(ray: Ray, matrix: Readonly<Matrix>, result: Ray): void;
  9450. }
  9451. }
  9452. /**
  9453. * Module Debug contains the (visual) components to debug a scene correctly
  9454. */
  9455. declare module BABYLON.Debug {
  9456. /**
  9457. * The Axes viewer will show 3 axes in a specific point in space
  9458. */
  9459. class AxesViewer {
  9460. private _xline;
  9461. private _yline;
  9462. private _zline;
  9463. private _xmesh;
  9464. private _ymesh;
  9465. private _zmesh;
  9466. /**
  9467. * Gets the hosting scene
  9468. */
  9469. scene: Nullable<Scene>;
  9470. /**
  9471. * Gets or sets a number used to scale line length
  9472. */
  9473. scaleLines: number;
  9474. /**
  9475. * Creates a new AxesViewer
  9476. * @param scene defines the hosting scene
  9477. * @param scaleLines defines a number used to scale line length (1 by default)
  9478. */
  9479. constructor(scene: Scene, scaleLines?: number);
  9480. /**
  9481. * Force the viewer to update
  9482. * @param position defines the position of the viewer
  9483. * @param xaxis defines the x axis of the viewer
  9484. * @param yaxis defines the y axis of the viewer
  9485. * @param zaxis defines the z axis of the viewer
  9486. */
  9487. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9488. /** Releases resources */
  9489. dispose(): void;
  9490. }
  9491. }
  9492. declare module BABYLON.Debug {
  9493. /**
  9494. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9495. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9496. */
  9497. class BoneAxesViewer extends AxesViewer {
  9498. /**
  9499. * Gets or sets the target mesh where to display the axes viewer
  9500. */
  9501. mesh: Nullable<Mesh>;
  9502. /**
  9503. * Gets or sets the target bone where to display the axes viewer
  9504. */
  9505. bone: Nullable<Bone>;
  9506. /** Gets current position */
  9507. pos: Vector3;
  9508. /** Gets direction of X axis */
  9509. xaxis: Vector3;
  9510. /** Gets direction of Y axis */
  9511. yaxis: Vector3;
  9512. /** Gets direction of Z axis */
  9513. zaxis: Vector3;
  9514. /**
  9515. * Creates a new BoneAxesViewer
  9516. * @param scene defines the hosting scene
  9517. * @param bone defines the target bone
  9518. * @param mesh defines the target mesh
  9519. * @param scaleLines defines a scaling factor for line length (1 by default)
  9520. */
  9521. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9522. /**
  9523. * Force the viewer to update
  9524. */
  9525. update(): void;
  9526. /** Releases resources */
  9527. dispose(): void;
  9528. }
  9529. }
  9530. declare module BABYLON {
  9531. interface Scene {
  9532. /**
  9533. * @hidden
  9534. * Backing field
  9535. */
  9536. _debugLayer: DebugLayer;
  9537. /**
  9538. * Gets the debug layer (aka Inspector) associated with the scene
  9539. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9540. */
  9541. debugLayer: DebugLayer;
  9542. }
  9543. /**
  9544. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9545. * what is happening in your scene
  9546. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9547. */
  9548. class DebugLayer {
  9549. /**
  9550. * Define the url to get the inspector script from.
  9551. * By default it uses the babylonjs CDN.
  9552. * @ignoreNaming
  9553. */
  9554. static InspectorURL: string;
  9555. private _scene;
  9556. private _inspector;
  9557. private BJSINSPECTOR;
  9558. /**
  9559. * Observable triggered when a property is changed through the inspector.
  9560. */
  9561. onPropertyChangedObservable: Observable<{
  9562. object: any;
  9563. property: string;
  9564. value: any;
  9565. initialValue: any;
  9566. }>;
  9567. /**
  9568. * Instantiates a new debug layer.
  9569. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9570. * what is happening in your scene
  9571. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9572. * @param scene Defines the scene to inspect
  9573. */
  9574. constructor(scene: Scene);
  9575. /** Creates the inspector window. */
  9576. private _createInspector;
  9577. /**
  9578. * Get if the inspector is visible or not.
  9579. * @returns true if visible otherwise, false
  9580. */
  9581. isVisible(): boolean;
  9582. /**
  9583. * Hide the inspector and close its window.
  9584. */
  9585. hide(): void;
  9586. /**
  9587. *
  9588. * Launch the debugLayer.
  9589. *
  9590. * initialTab:
  9591. * | Value | Tab Name |
  9592. * | --- | --- |
  9593. * | 0 | Scene |
  9594. * | 1 | Console |
  9595. * | 2 | Stats |
  9596. * | 3 | Textures |
  9597. * | 4 | Mesh |
  9598. * | 5 | Light |
  9599. * | 6 | Material |
  9600. * | 7 | GLTF |
  9601. * | 8 | GUI |
  9602. * | 9 | Physics |
  9603. * | 10 | Camera |
  9604. * | 11 | Audio |
  9605. *
  9606. * @param config Define the configuration of the inspector
  9607. */
  9608. show(config?: {
  9609. popup?: boolean;
  9610. initialTab?: number | string;
  9611. parentElement?: HTMLElement;
  9612. newColors?: {
  9613. backgroundColor?: string;
  9614. backgroundColorLighter?: string;
  9615. backgroundColorLighter2?: string;
  9616. backgroundColorLighter3?: string;
  9617. color?: string;
  9618. colorTop?: string;
  9619. colorBot?: string;
  9620. };
  9621. }): void;
  9622. /**
  9623. * Gets the active tab
  9624. * @return the index of the active tab or -1 if the inspector is hidden
  9625. */
  9626. getActiveTab(): number;
  9627. }
  9628. }
  9629. declare module BABYLON.Debug {
  9630. /**
  9631. * Used to show the physics impostor around the specific mesh
  9632. */
  9633. class PhysicsViewer {
  9634. /** @hidden */
  9635. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9636. /** @hidden */
  9637. protected _meshes: Array<Nullable<AbstractMesh>>;
  9638. /** @hidden */
  9639. protected _scene: Nullable<Scene>;
  9640. /** @hidden */
  9641. protected _numMeshes: number;
  9642. /** @hidden */
  9643. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9644. private _renderFunction;
  9645. private _debugBoxMesh;
  9646. private _debugSphereMesh;
  9647. private _debugMaterial;
  9648. /**
  9649. * Creates a new PhysicsViewer
  9650. * @param scene defines the hosting scene
  9651. */
  9652. constructor(scene: Scene);
  9653. /** @hidden */
  9654. protected _updateDebugMeshes(): void;
  9655. /**
  9656. * Renders a specified physic impostor
  9657. * @param impostor defines the impostor to render
  9658. */
  9659. showImpostor(impostor: PhysicsImpostor): void;
  9660. /**
  9661. * Hides a specified physic impostor
  9662. * @param impostor defines the impostor to hide
  9663. */
  9664. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9665. private _getDebugMaterial;
  9666. private _getDebugBoxMesh;
  9667. private _getDebugSphereMesh;
  9668. private _getDebugMesh;
  9669. /** Releases all resources */
  9670. dispose(): void;
  9671. }
  9672. }
  9673. declare module BABYLON {
  9674. /**
  9675. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9676. * in order to better appreciate the issue one might have.
  9677. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9678. */
  9679. class RayHelper {
  9680. /**
  9681. * Defines the ray we are currently tryin to visualize.
  9682. */
  9683. ray: Nullable<Ray>;
  9684. private _renderPoints;
  9685. private _renderLine;
  9686. private _renderFunction;
  9687. private _scene;
  9688. private _updateToMeshFunction;
  9689. private _attachedToMesh;
  9690. private _meshSpaceDirection;
  9691. private _meshSpaceOrigin;
  9692. /**
  9693. * Helper function to create a colored helper in a scene in one line.
  9694. * @param ray Defines the ray we are currently tryin to visualize
  9695. * @param scene Defines the scene the ray is used in
  9696. * @param color Defines the color we want to see the ray in
  9697. * @returns The newly created ray helper.
  9698. */
  9699. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9700. /**
  9701. * Instantiate a new ray helper.
  9702. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9703. * in order to better appreciate the issue one might have.
  9704. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9705. * @param ray Defines the ray we are currently tryin to visualize
  9706. */
  9707. constructor(ray: Ray);
  9708. /**
  9709. * Shows the ray we are willing to debug.
  9710. * @param scene Defines the scene the ray needs to be rendered in
  9711. * @param color Defines the color the ray needs to be rendered in
  9712. */
  9713. show(scene: Scene, color?: Color3): void;
  9714. /**
  9715. * Hides the ray we are debugging.
  9716. */
  9717. hide(): void;
  9718. private _render;
  9719. /**
  9720. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9721. * @param mesh Defines the mesh we want the helper attached to
  9722. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9723. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9724. * @param length Defines the length of the ray
  9725. */
  9726. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9727. /**
  9728. * Detach the ray helper from the mesh it has previously been attached to.
  9729. */
  9730. detachFromMesh(): void;
  9731. private _updateToMesh;
  9732. /**
  9733. * Dispose the helper and release its associated resources.
  9734. */
  9735. dispose(): void;
  9736. }
  9737. }
  9738. declare module BABYLON.Debug {
  9739. /**
  9740. * Class used to render a debug view of a given skeleton
  9741. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9742. */
  9743. class SkeletonViewer {
  9744. /** defines the skeleton to render */
  9745. skeleton: Skeleton;
  9746. /** defines the mesh attached to the skeleton */
  9747. mesh: AbstractMesh;
  9748. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9749. autoUpdateBonesMatrices: boolean;
  9750. /** defines the rendering group id to use with the viewer */
  9751. renderingGroupId: number;
  9752. /** Gets or sets the color used to render the skeleton */
  9753. color: Color3;
  9754. private _scene;
  9755. private _debugLines;
  9756. private _debugMesh;
  9757. private _isEnabled;
  9758. private _renderFunction;
  9759. /**
  9760. * Creates a new SkeletonViewer
  9761. * @param skeleton defines the skeleton to render
  9762. * @param mesh defines the mesh attached to the skeleton
  9763. * @param scene defines the hosting scene
  9764. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9765. * @param renderingGroupId defines the rendering group id to use with the viewer
  9766. */
  9767. constructor(
  9768. /** defines the skeleton to render */
  9769. skeleton: Skeleton,
  9770. /** defines the mesh attached to the skeleton */
  9771. mesh: AbstractMesh, scene: Scene,
  9772. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9773. autoUpdateBonesMatrices?: boolean,
  9774. /** defines the rendering group id to use with the viewer */
  9775. renderingGroupId?: number);
  9776. /** Gets or sets a boolean indicating if the viewer is enabled */
  9777. isEnabled: boolean;
  9778. private _getBonePosition;
  9779. private _getLinesForBonesWithLength;
  9780. private _getLinesForBonesNoLength;
  9781. /** Update the viewer to sync with current skeleton state */
  9782. update(): void;
  9783. /** Release associated resources */
  9784. dispose(): void;
  9785. }
  9786. }
  9787. declare module BABYLON {
  9788. /**
  9789. * Interface for attribute information associated with buffer instanciation
  9790. */
  9791. class InstancingAttributeInfo {
  9792. /**
  9793. * Index/offset of the attribute in the vertex shader
  9794. */
  9795. index: number;
  9796. /**
  9797. * size of the attribute, 1, 2, 3 or 4
  9798. */
  9799. attributeSize: number;
  9800. /**
  9801. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9802. * default is FLOAT
  9803. */
  9804. attribyteType: number;
  9805. /**
  9806. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9807. */
  9808. normalized: boolean;
  9809. /**
  9810. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9811. */
  9812. offset: number;
  9813. /**
  9814. * Name of the GLSL attribute, for debugging purpose only
  9815. */
  9816. attributeName: string;
  9817. }
  9818. /**
  9819. * Define options used to create a render target texture
  9820. */
  9821. class RenderTargetCreationOptions {
  9822. /**
  9823. * Specifies is mipmaps must be generated
  9824. */
  9825. generateMipMaps?: boolean;
  9826. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9827. generateDepthBuffer?: boolean;
  9828. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9829. generateStencilBuffer?: boolean;
  9830. /** Defines texture type (int by default) */
  9831. type?: number;
  9832. /** Defines sampling mode (trilinear by default) */
  9833. samplingMode?: number;
  9834. /** Defines format (RGBA by default) */
  9835. format?: number;
  9836. }
  9837. /**
  9838. * Define options used to create a depth texture
  9839. */
  9840. class DepthTextureCreationOptions {
  9841. /** Specifies whether or not a stencil should be allocated in the texture */
  9842. generateStencil?: boolean;
  9843. /** Specifies whether or not bilinear filtering is enable on the texture */
  9844. bilinearFiltering?: boolean;
  9845. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9846. comparisonFunction?: number;
  9847. /** Specifies if the created texture is a cube texture */
  9848. isCube?: boolean;
  9849. }
  9850. /**
  9851. * Class used to describe the capabilities of the engine relatively to the current browser
  9852. */
  9853. class EngineCapabilities {
  9854. /** Maximum textures units per fragment shader */
  9855. maxTexturesImageUnits: number;
  9856. /** Maximum texture units per vertex shader */
  9857. maxVertexTextureImageUnits: number;
  9858. /** Maximum textures units in the entire pipeline */
  9859. maxCombinedTexturesImageUnits: number;
  9860. /** Maximum texture size */
  9861. maxTextureSize: number;
  9862. /** Maximum cube texture size */
  9863. maxCubemapTextureSize: number;
  9864. /** Maximum render texture size */
  9865. maxRenderTextureSize: number;
  9866. /** Maximum number of vertex attributes */
  9867. maxVertexAttribs: number;
  9868. /** Maximum number of varyings */
  9869. maxVaryingVectors: number;
  9870. /** Maximum number of uniforms per vertex shader */
  9871. maxVertexUniformVectors: number;
  9872. /** Maximum number of uniforms per fragment shader */
  9873. maxFragmentUniformVectors: number;
  9874. /** Defines if standard derivates (dx/dy) are supported */
  9875. standardDerivatives: boolean;
  9876. /** Defines if s3tc texture compression is supported */
  9877. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  9878. /** Defines if pvrtc texture compression is supported */
  9879. pvrtc: any;
  9880. /** Defines if etc1 texture compression is supported */
  9881. etc1: any;
  9882. /** Defines if etc2 texture compression is supported */
  9883. etc2: any;
  9884. /** Defines if astc texture compression is supported */
  9885. astc: any;
  9886. /** Defines if float textures are supported */
  9887. textureFloat: boolean;
  9888. /** Defines if vertex array objects are supported */
  9889. vertexArrayObject: boolean;
  9890. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  9891. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  9892. /** Gets the maximum level of anisotropy supported */
  9893. maxAnisotropy: number;
  9894. /** Defines if instancing is supported */
  9895. instancedArrays: boolean;
  9896. /** Defines if 32 bits indices are supported */
  9897. uintIndices: boolean;
  9898. /** Defines if high precision shaders are supported */
  9899. highPrecisionShaderSupported: boolean;
  9900. /** Defines if depth reading in the fragment shader is supported */
  9901. fragmentDepthSupported: boolean;
  9902. /** Defines if float texture linear filtering is supported*/
  9903. textureFloatLinearFiltering: boolean;
  9904. /** Defines if rendering to float textures is supported */
  9905. textureFloatRender: boolean;
  9906. /** Defines if half float textures are supported*/
  9907. textureHalfFloat: boolean;
  9908. /** Defines if half float texture linear filtering is supported*/
  9909. textureHalfFloatLinearFiltering: boolean;
  9910. /** Defines if rendering to half float textures is supported */
  9911. textureHalfFloatRender: boolean;
  9912. /** Defines if textureLOD shader command is supported */
  9913. textureLOD: boolean;
  9914. /** Defines if draw buffers extension is supported */
  9915. drawBuffersExtension: boolean;
  9916. /** Defines if depth textures are supported */
  9917. depthTextureExtension: boolean;
  9918. /** Defines if float color buffer are supported */
  9919. colorBufferFloat: boolean;
  9920. /** Gets disjoint timer query extension (null if not supported) */
  9921. timerQuery: EXT_disjoint_timer_query;
  9922. /** Defines if timestamp can be used with timer query */
  9923. canUseTimestampForTimerQuery: boolean;
  9924. /** Function used to let the system compiles shaders in background */
  9925. parallelShaderCompile: {
  9926. MAX_SHADER_COMPILER_THREADS_KHR: number;
  9927. maxShaderCompilerThreadsKHR: (thread: number) => void;
  9928. COMPLETION_STATUS_KHR: number;
  9929. };
  9930. }
  9931. /** Interface defining initialization parameters for Engine class */
  9932. interface EngineOptions extends WebGLContextAttributes {
  9933. /**
  9934. * Defines if the engine should no exceed a specified device ratio
  9935. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  9936. */
  9937. limitDeviceRatio?: number;
  9938. /**
  9939. * Defines if webvr should be enabled automatically
  9940. * @see http://doc.babylonjs.com/how_to/webvr_camera
  9941. */
  9942. autoEnableWebVR?: boolean;
  9943. /**
  9944. * Defines if webgl2 should be turned off even if supported
  9945. * @see http://doc.babylonjs.com/features/webgl2
  9946. */
  9947. disableWebGL2Support?: boolean;
  9948. /**
  9949. * Defines if webaudio should be initialized as well
  9950. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9951. */
  9952. audioEngine?: boolean;
  9953. /**
  9954. * Defines if animations should run using a deterministic lock step
  9955. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9956. */
  9957. deterministicLockstep?: boolean;
  9958. /** Defines the maximum steps to use with deterministic lock step mode */
  9959. lockstepMaxSteps?: number;
  9960. /**
  9961. * Defines that engine should ignore context lost events
  9962. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  9963. */
  9964. doNotHandleContextLost?: boolean;
  9965. }
  9966. /**
  9967. * Defines the interface used by display changed events
  9968. */
  9969. interface IDisplayChangedEventArgs {
  9970. /** Gets the vrDisplay object (if any) */
  9971. vrDisplay: Nullable<any>;
  9972. /** Gets a boolean indicating if webVR is supported */
  9973. vrSupported: boolean;
  9974. }
  9975. /**
  9976. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  9977. */
  9978. class Engine {
  9979. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  9980. static ExceptionList: ({
  9981. key: string;
  9982. capture: string;
  9983. captureConstraint: number;
  9984. targets: string[];
  9985. } | {
  9986. key: string;
  9987. capture: null;
  9988. captureConstraint: null;
  9989. targets: string[];
  9990. })[];
  9991. /** Gets the list of created engines */
  9992. static Instances: Engine[];
  9993. /**
  9994. * Gets the latest created engine
  9995. */
  9996. static readonly LastCreatedEngine: Nullable<Engine>;
  9997. /**
  9998. * Gets the latest created scene
  9999. */
  10000. static readonly LastCreatedScene: Nullable<Scene>;
  10001. /**
  10002. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10003. * @param flag defines which part of the materials must be marked as dirty
  10004. * @param predicate defines a predicate used to filter which materials should be affected
  10005. */
  10006. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10007. /**
  10008. * Hidden
  10009. */
  10010. static _TextureLoaders: IInternalTextureLoader[];
  10011. /** Defines that alpha blending is disabled */
  10012. static readonly ALPHA_DISABLE: number;
  10013. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10014. static readonly ALPHA_ADD: number;
  10015. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10016. static readonly ALPHA_COMBINE: number;
  10017. /** Defines that alpha blending to DEST - SRC * DEST */
  10018. static readonly ALPHA_SUBTRACT: number;
  10019. /** Defines that alpha blending to SRC * DEST */
  10020. static readonly ALPHA_MULTIPLY: number;
  10021. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10022. static readonly ALPHA_MAXIMIZED: number;
  10023. /** Defines that alpha blending to SRC + DEST */
  10024. static readonly ALPHA_ONEONE: number;
  10025. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10026. static readonly ALPHA_PREMULTIPLIED: number;
  10027. /**
  10028. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10029. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10030. */
  10031. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10032. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10033. static readonly ALPHA_INTERPOLATE: number;
  10034. /**
  10035. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10036. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10037. */
  10038. static readonly ALPHA_SCREENMODE: number;
  10039. /** Defines that the ressource is not delayed*/
  10040. static readonly DELAYLOADSTATE_NONE: number;
  10041. /** Defines that the ressource was successfully delay loaded */
  10042. static readonly DELAYLOADSTATE_LOADED: number;
  10043. /** Defines that the ressource is currently delay loading */
  10044. static readonly DELAYLOADSTATE_LOADING: number;
  10045. /** Defines that the ressource is delayed and has not started loading */
  10046. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10047. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10048. static readonly NEVER: number;
  10049. /** 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 */
  10050. static readonly ALWAYS: number;
  10051. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10052. static readonly LESS: number;
  10053. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10054. static readonly EQUAL: number;
  10055. /** 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 */
  10056. static readonly LEQUAL: number;
  10057. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10058. static readonly GREATER: number;
  10059. /** 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 */
  10060. static readonly GEQUAL: number;
  10061. /** 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 */
  10062. static readonly NOTEQUAL: number;
  10063. /** Passed to stencilOperation to specify that stencil value must be kept */
  10064. static readonly KEEP: number;
  10065. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10066. static readonly REPLACE: number;
  10067. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10068. static readonly INCR: number;
  10069. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10070. static readonly DECR: number;
  10071. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10072. static readonly INVERT: number;
  10073. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10074. static readonly INCR_WRAP: number;
  10075. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10076. static readonly DECR_WRAP: number;
  10077. /** Texture is not repeating outside of 0..1 UVs */
  10078. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10079. /** Texture is repeating outside of 0..1 UVs */
  10080. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10081. /** Texture is repeating and mirrored */
  10082. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10083. /** ALPHA */
  10084. static readonly TEXTUREFORMAT_ALPHA: number;
  10085. /** LUMINANCE */
  10086. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10087. /** LUMINANCE_ALPHA */
  10088. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10089. /** RGB */
  10090. static readonly TEXTUREFORMAT_RGB: number;
  10091. /** RGBA */
  10092. static readonly TEXTUREFORMAT_RGBA: number;
  10093. /** RED */
  10094. static readonly TEXTUREFORMAT_RED: number;
  10095. /** RED (2nd reference) */
  10096. static readonly TEXTUREFORMAT_R: number;
  10097. /** RG */
  10098. static readonly TEXTUREFORMAT_RG: number;
  10099. /** RED_INTEGER */
  10100. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10101. /** RED_INTEGER (2nd reference) */
  10102. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10103. /** RG_INTEGER */
  10104. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10105. /** RGB_INTEGER */
  10106. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10107. /** RGBA_INTEGER */
  10108. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10109. /** UNSIGNED_BYTE */
  10110. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10111. /** UNSIGNED_BYTE (2nd reference) */
  10112. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10113. /** FLOAT */
  10114. static readonly TEXTURETYPE_FLOAT: number;
  10115. /** HALF_FLOAT */
  10116. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10117. /** BYTE */
  10118. static readonly TEXTURETYPE_BYTE: number;
  10119. /** SHORT */
  10120. static readonly TEXTURETYPE_SHORT: number;
  10121. /** UNSIGNED_SHORT */
  10122. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10123. /** INT */
  10124. static readonly TEXTURETYPE_INT: number;
  10125. /** UNSIGNED_INT */
  10126. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10127. /** UNSIGNED_SHORT_4_4_4_4 */
  10128. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10129. /** UNSIGNED_SHORT_5_5_5_1 */
  10130. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10131. /** UNSIGNED_SHORT_5_6_5 */
  10132. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10133. /** UNSIGNED_INT_2_10_10_10_REV */
  10134. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10135. /** UNSIGNED_INT_24_8 */
  10136. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10137. /** UNSIGNED_INT_10F_11F_11F_REV */
  10138. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10139. /** UNSIGNED_INT_5_9_9_9_REV */
  10140. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10141. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10142. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10143. /** nearest is mag = nearest and min = nearest and mip = linear */
  10144. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10145. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10146. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10147. /** Trilinear is mag = linear and min = linear and mip = linear */
  10148. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10149. /** nearest is mag = nearest and min = nearest and mip = linear */
  10150. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10151. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10152. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10153. /** Trilinear is mag = linear and min = linear and mip = linear */
  10154. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10155. /** mag = nearest and min = nearest and mip = nearest */
  10156. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10157. /** mag = nearest and min = linear and mip = nearest */
  10158. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10159. /** mag = nearest and min = linear and mip = linear */
  10160. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10161. /** mag = nearest and min = linear and mip = none */
  10162. static readonly TEXTURE_NEAREST_LINEAR: number;
  10163. /** mag = nearest and min = nearest and mip = none */
  10164. static readonly TEXTURE_NEAREST_NEAREST: number;
  10165. /** mag = linear and min = nearest and mip = nearest */
  10166. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10167. /** mag = linear and min = nearest and mip = linear */
  10168. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10169. /** mag = linear and min = linear and mip = none */
  10170. static readonly TEXTURE_LINEAR_LINEAR: number;
  10171. /** mag = linear and min = nearest and mip = none */
  10172. static readonly TEXTURE_LINEAR_NEAREST: number;
  10173. /** Explicit coordinates mode */
  10174. static readonly TEXTURE_EXPLICIT_MODE: number;
  10175. /** Spherical coordinates mode */
  10176. static readonly TEXTURE_SPHERICAL_MODE: number;
  10177. /** Planar coordinates mode */
  10178. static readonly TEXTURE_PLANAR_MODE: number;
  10179. /** Cubic coordinates mode */
  10180. static readonly TEXTURE_CUBIC_MODE: number;
  10181. /** Projection coordinates mode */
  10182. static readonly TEXTURE_PROJECTION_MODE: number;
  10183. /** Skybox coordinates mode */
  10184. static readonly TEXTURE_SKYBOX_MODE: number;
  10185. /** Inverse Cubic coordinates mode */
  10186. static readonly TEXTURE_INVCUBIC_MODE: number;
  10187. /** Equirectangular coordinates mode */
  10188. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10189. /** Equirectangular Fixed coordinates mode */
  10190. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10191. /** Equirectangular Fixed Mirrored coordinates mode */
  10192. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10193. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10194. static readonly SCALEMODE_FLOOR: number;
  10195. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10196. static readonly SCALEMODE_NEAREST: number;
  10197. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10198. static readonly SCALEMODE_CEILING: number;
  10199. /**
  10200. * Returns the current version of the framework
  10201. */
  10202. static readonly Version: string;
  10203. /**
  10204. * Returns a string describing the current engine
  10205. */
  10206. readonly description: string;
  10207. /**
  10208. * Gets or sets the epsilon value used by collision engine
  10209. */
  10210. static CollisionsEpsilon: number;
  10211. /**
  10212. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10213. */
  10214. static CodeRepository: string;
  10215. /**
  10216. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10217. */
  10218. static ShadersRepository: string;
  10219. /**
  10220. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10221. */
  10222. forcePOTTextures: boolean;
  10223. /**
  10224. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10225. */
  10226. isFullscreen: boolean;
  10227. /**
  10228. * Gets a boolean indicating if the pointer is currently locked
  10229. */
  10230. isPointerLock: boolean;
  10231. /**
  10232. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10233. */
  10234. cullBackFaces: boolean;
  10235. /**
  10236. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10237. */
  10238. renderEvenInBackground: boolean;
  10239. /**
  10240. * Gets or sets a boolean indicating that cache can be kept between frames
  10241. */
  10242. preventCacheWipeBetweenFrames: boolean;
  10243. /**
  10244. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10245. **/
  10246. enableOfflineSupport: boolean;
  10247. /**
  10248. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (Babylon.js will always consider the database is up to date)
  10249. **/
  10250. disableManifestCheck: boolean;
  10251. /**
  10252. * Gets the list of created scenes
  10253. */
  10254. scenes: Scene[];
  10255. /**
  10256. * Gets the list of created postprocesses
  10257. */
  10258. postProcesses: PostProcess[];
  10259. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10260. validateShaderPrograms: boolean;
  10261. /**
  10262. * Observable event triggered each time the rendering canvas is resized
  10263. */
  10264. onResizeObservable: Observable<Engine>;
  10265. /**
  10266. * Observable event triggered each time the canvas loses focus
  10267. */
  10268. onCanvasBlurObservable: Observable<Engine>;
  10269. /**
  10270. * Observable event triggered each time the canvas gains focus
  10271. */
  10272. onCanvasFocusObservable: Observable<Engine>;
  10273. /**
  10274. * Observable event triggered each time the canvas receives pointerout event
  10275. */
  10276. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10277. /**
  10278. * Observable event triggered before each texture is initialized
  10279. */
  10280. onBeforeTextureInitObservable: Observable<Texture>;
  10281. private _vrDisplay;
  10282. private _vrSupported;
  10283. private _oldSize;
  10284. private _oldHardwareScaleFactor;
  10285. private _vrExclusivePointerMode;
  10286. private _webVRInitPromise;
  10287. /**
  10288. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10289. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10290. */
  10291. readonly isInVRExclusivePointerMode: boolean;
  10292. /**
  10293. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10294. */
  10295. disableUniformBuffers: boolean;
  10296. /** @hidden */
  10297. _uniformBuffers: UniformBuffer[];
  10298. /**
  10299. * Gets a boolean indicating that the engine supports uniform buffers
  10300. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10301. */
  10302. readonly supportsUniformBuffers: boolean;
  10303. /**
  10304. * Observable raised when the engine begins a new frame
  10305. */
  10306. onBeginFrameObservable: Observable<Engine>;
  10307. /**
  10308. * If set, will be used to request the next animation frame for the render loop
  10309. */
  10310. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10311. /**
  10312. * Observable raised when the engine ends the current frame
  10313. */
  10314. onEndFrameObservable: Observable<Engine>;
  10315. /**
  10316. * Observable raised when the engine is about to compile a shader
  10317. */
  10318. onBeforeShaderCompilationObservable: Observable<Engine>;
  10319. /**
  10320. * Observable raised when the engine has jsut compiled a shader
  10321. */
  10322. onAfterShaderCompilationObservable: Observable<Engine>;
  10323. /** @hidden */
  10324. _gl: WebGLRenderingContext;
  10325. private _renderingCanvas;
  10326. private _windowIsBackground;
  10327. private _webGLVersion;
  10328. /**
  10329. * Gets a boolean indicating that only power of 2 textures are supported
  10330. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10331. */
  10332. readonly needPOTTextures: boolean;
  10333. /** @hidden */
  10334. _badOS: boolean;
  10335. /** @hidden */
  10336. _badDesktopOS: boolean;
  10337. /**
  10338. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10339. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10340. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10341. */
  10342. disableTextureBindingOptimization: boolean;
  10343. /**
  10344. * Gets the audio engine
  10345. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10346. * @ignorenaming
  10347. */
  10348. static audioEngine: IAudioEngine;
  10349. /**
  10350. * Default AudioEngine factory responsible of creating the Audio Engine.
  10351. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10352. */
  10353. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10354. /**
  10355. * Default offline support factory responsible of creating a tool used to store data locally.
  10356. * By default, this will create a Database object if the workload has been embedded.
  10357. */
  10358. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10359. private _onFocus;
  10360. private _onBlur;
  10361. private _onCanvasPointerOut;
  10362. private _onCanvasBlur;
  10363. private _onCanvasFocus;
  10364. private _onFullscreenChange;
  10365. private _onPointerLockChange;
  10366. private _onVRDisplayPointerRestricted;
  10367. private _onVRDisplayPointerUnrestricted;
  10368. private _onVrDisplayConnect;
  10369. private _onVrDisplayDisconnect;
  10370. private _onVrDisplayPresentChange;
  10371. /**
  10372. * Observable signaled when VR display mode changes
  10373. */
  10374. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10375. /**
  10376. * Observable signaled when VR request present is complete
  10377. */
  10378. onVRRequestPresentComplete: Observable<boolean>;
  10379. /**
  10380. * Observable signaled when VR request present starts
  10381. */
  10382. onVRRequestPresentStart: Observable<Engine>;
  10383. private _hardwareScalingLevel;
  10384. /** @hidden */
  10385. protected _caps: EngineCapabilities;
  10386. private _pointerLockRequested;
  10387. private _isStencilEnable;
  10388. private _colorWrite;
  10389. private _loadingScreen;
  10390. /** @hidden */
  10391. _drawCalls: PerfCounter;
  10392. /** @hidden */
  10393. _textureCollisions: PerfCounter;
  10394. private _glVersion;
  10395. private _glRenderer;
  10396. private _glVendor;
  10397. private _videoTextureSupported;
  10398. private _renderingQueueLaunched;
  10399. private _activeRenderLoops;
  10400. private _deterministicLockstep;
  10401. private _lockstepMaxSteps;
  10402. /**
  10403. * Observable signaled when a context lost event is raised
  10404. */
  10405. onContextLostObservable: Observable<Engine>;
  10406. /**
  10407. * Observable signaled when a context restored event is raised
  10408. */
  10409. onContextRestoredObservable: Observable<Engine>;
  10410. private _onContextLost;
  10411. private _onContextRestored;
  10412. private _contextWasLost;
  10413. private _doNotHandleContextLost;
  10414. /**
  10415. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10416. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10417. */
  10418. doNotHandleContextLost: boolean;
  10419. private _performanceMonitor;
  10420. private _fps;
  10421. private _deltaTime;
  10422. /**
  10423. * Turn this value on if you want to pause FPS computation when in background
  10424. */
  10425. disablePerformanceMonitorInBackground: boolean;
  10426. /**
  10427. * Gets the performance monitor attached to this engine
  10428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10429. */
  10430. readonly performanceMonitor: PerformanceMonitor;
  10431. /** @hidden */
  10432. protected _depthCullingState: _DepthCullingState;
  10433. /** @hidden */
  10434. protected _stencilState: _StencilState;
  10435. /** @hidden */
  10436. protected _alphaState: _AlphaState;
  10437. /** @hidden */
  10438. protected _alphaMode: number;
  10439. protected _internalTexturesCache: InternalTexture[];
  10440. /** @hidden */
  10441. protected _activeChannel: number;
  10442. private _currentTextureChannel;
  10443. /** @hidden */
  10444. protected _boundTexturesCache: {
  10445. [key: string]: Nullable<InternalTexture>;
  10446. };
  10447. /** @hidden */
  10448. protected _currentEffect: Nullable<Effect>;
  10449. /** @hidden */
  10450. protected _currentProgram: Nullable<WebGLProgram>;
  10451. private _compiledEffects;
  10452. private _vertexAttribArraysEnabled;
  10453. /** @hidden */
  10454. protected _cachedViewport: Nullable<Viewport>;
  10455. private _cachedVertexArrayObject;
  10456. /** @hidden */
  10457. protected _cachedVertexBuffers: any;
  10458. /** @hidden */
  10459. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10460. /** @hidden */
  10461. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10462. /** @hidden */
  10463. protected _currentRenderTarget: Nullable<InternalTexture>;
  10464. private _uintIndicesCurrentlySet;
  10465. private _currentBoundBuffer;
  10466. /** @hidden */
  10467. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10468. private _currentBufferPointers;
  10469. private _currentInstanceLocations;
  10470. private _currentInstanceBuffers;
  10471. private _textureUnits;
  10472. private _firstBoundInternalTextureTracker;
  10473. private _lastBoundInternalTextureTracker;
  10474. private _workingCanvas;
  10475. private _workingContext;
  10476. private _rescalePostProcess;
  10477. private _dummyFramebuffer;
  10478. private _externalData;
  10479. private _bindedRenderFunction;
  10480. private _vaoRecordInProgress;
  10481. private _mustWipeVertexAttributes;
  10482. private _emptyTexture;
  10483. private _emptyCubeTexture;
  10484. private _emptyTexture3D;
  10485. /** @hidden */
  10486. _frameHandler: number;
  10487. private _nextFreeTextureSlots;
  10488. private _maxSimultaneousTextures;
  10489. private _activeRequests;
  10490. private _texturesSupported;
  10491. private _textureFormatInUse;
  10492. /**
  10493. * Gets the list of texture formats supported
  10494. */
  10495. readonly texturesSupported: Array<string>;
  10496. /**
  10497. * Gets the list of texture formats in use
  10498. */
  10499. readonly textureFormatInUse: Nullable<string>;
  10500. /**
  10501. * Gets the current viewport
  10502. */
  10503. readonly currentViewport: Nullable<Viewport>;
  10504. /**
  10505. * Gets the default empty texture
  10506. */
  10507. readonly emptyTexture: InternalTexture;
  10508. /**
  10509. * Gets the default empty 3D texture
  10510. */
  10511. readonly emptyTexture3D: InternalTexture;
  10512. /**
  10513. * Gets the default empty cube texture
  10514. */
  10515. readonly emptyCubeTexture: InternalTexture;
  10516. /**
  10517. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10518. */
  10519. readonly premultipliedAlpha: boolean;
  10520. /**
  10521. * Creates a new engine
  10522. * @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
  10523. * @param antialias defines enable antialiasing (default: false)
  10524. * @param options defines further options to be sent to the getContext() function
  10525. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10526. */
  10527. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10528. private _rebuildInternalTextures;
  10529. private _rebuildEffects;
  10530. /**
  10531. * Gets a boolean indicating if all created effects are ready
  10532. * @returns true if all effects are ready
  10533. */
  10534. areAllEffectsReady(): boolean;
  10535. private _rebuildBuffers;
  10536. private _initGLContext;
  10537. /**
  10538. * Gets version of the current webGL context
  10539. */
  10540. readonly webGLVersion: number;
  10541. /**
  10542. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10543. */
  10544. readonly isStencilEnable: boolean;
  10545. private _prepareWorkingCanvas;
  10546. /**
  10547. * Reset the texture cache to empty state
  10548. */
  10549. resetTextureCache(): void;
  10550. /**
  10551. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10552. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10553. * @returns true if engine is in deterministic lock step mode
  10554. */
  10555. isDeterministicLockStep(): boolean;
  10556. /**
  10557. * Gets the max steps when engine is running in deterministic lock step
  10558. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10559. * @returns the max steps
  10560. */
  10561. getLockstepMaxSteps(): number;
  10562. /**
  10563. * Gets an object containing information about the current webGL context
  10564. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10565. */
  10566. getGlInfo(): {
  10567. vendor: string;
  10568. renderer: string;
  10569. version: string;
  10570. };
  10571. /**
  10572. * Gets current aspect ratio
  10573. * @param camera defines the camera to use to get the aspect ratio
  10574. * @param useScreen defines if screen size must be used (or the current render target if any)
  10575. * @returns a number defining the aspect ratio
  10576. */
  10577. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10578. /**
  10579. * Gets current screen aspect ratio
  10580. * @returns a number defining the aspect ratio
  10581. */
  10582. getScreenAspectRatio(): number;
  10583. /**
  10584. * Gets the current render width
  10585. * @param useScreen defines if screen size must be used (or the current render target if any)
  10586. * @returns a number defining the current render width
  10587. */
  10588. getRenderWidth(useScreen?: boolean): number;
  10589. /**
  10590. * Gets the current render height
  10591. * @param useScreen defines if screen size must be used (or the current render target if any)
  10592. * @returns a number defining the current render height
  10593. */
  10594. getRenderHeight(useScreen?: boolean): number;
  10595. /**
  10596. * Gets the HTML canvas attached with the current webGL context
  10597. * @returns a HTML canvas
  10598. */
  10599. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10600. /**
  10601. * Gets the client rect of the HTML canvas attached with the current webGL context
  10602. * @returns a client rectanglee
  10603. */
  10604. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10605. /**
  10606. * Defines the hardware scaling level.
  10607. * By default the hardware scaling level is computed from the window device ratio.
  10608. * 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.
  10609. * @param level defines the level to use
  10610. */
  10611. setHardwareScalingLevel(level: number): void;
  10612. /**
  10613. * Gets the current hardware scaling level.
  10614. * By default the hardware scaling level is computed from the window device ratio.
  10615. * 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.
  10616. * @returns a number indicating the current hardware scaling level
  10617. */
  10618. getHardwareScalingLevel(): number;
  10619. /**
  10620. * Gets the list of loaded textures
  10621. * @returns an array containing all loaded textures
  10622. */
  10623. getLoadedTexturesCache(): InternalTexture[];
  10624. /**
  10625. * Gets the object containing all engine capabilities
  10626. * @returns the EngineCapabilities object
  10627. */
  10628. getCaps(): EngineCapabilities;
  10629. /**
  10630. * Gets the current depth function
  10631. * @returns a number defining the depth function
  10632. */
  10633. getDepthFunction(): Nullable<number>;
  10634. /**
  10635. * Sets the current depth function
  10636. * @param depthFunc defines the function to use
  10637. */
  10638. setDepthFunction(depthFunc: number): void;
  10639. /**
  10640. * Sets the current depth function to GREATER
  10641. */
  10642. setDepthFunctionToGreater(): void;
  10643. /**
  10644. * Sets the current depth function to GEQUAL
  10645. */
  10646. setDepthFunctionToGreaterOrEqual(): void;
  10647. /**
  10648. * Sets the current depth function to LESS
  10649. */
  10650. setDepthFunctionToLess(): void;
  10651. /**
  10652. * Sets the current depth function to LEQUAL
  10653. */
  10654. setDepthFunctionToLessOrEqual(): void;
  10655. /**
  10656. * Gets a boolean indicating if stencil buffer is enabled
  10657. * @returns the current stencil buffer state
  10658. */
  10659. getStencilBuffer(): boolean;
  10660. /**
  10661. * Enable or disable the stencil buffer
  10662. * @param enable defines if the stencil buffer must be enabled or disabled
  10663. */
  10664. setStencilBuffer(enable: boolean): void;
  10665. /**
  10666. * Gets the current stencil mask
  10667. * @returns a number defining the new stencil mask to use
  10668. */
  10669. getStencilMask(): number;
  10670. /**
  10671. * Sets the current stencil mask
  10672. * @param mask defines the new stencil mask to use
  10673. */
  10674. setStencilMask(mask: number): void;
  10675. /**
  10676. * Gets the current stencil function
  10677. * @returns a number defining the stencil function to use
  10678. */
  10679. getStencilFunction(): number;
  10680. /**
  10681. * Gets the current stencil reference value
  10682. * @returns a number defining the stencil reference value to use
  10683. */
  10684. getStencilFunctionReference(): number;
  10685. /**
  10686. * Gets the current stencil mask
  10687. * @returns a number defining the stencil mask to use
  10688. */
  10689. getStencilFunctionMask(): number;
  10690. /**
  10691. * Sets the current stencil function
  10692. * @param stencilFunc defines the new stencil function to use
  10693. */
  10694. setStencilFunction(stencilFunc: number): void;
  10695. /**
  10696. * Sets the current stencil reference
  10697. * @param reference defines the new stencil reference to use
  10698. */
  10699. setStencilFunctionReference(reference: number): void;
  10700. /**
  10701. * Sets the current stencil mask
  10702. * @param mask defines the new stencil mask to use
  10703. */
  10704. setStencilFunctionMask(mask: number): void;
  10705. /**
  10706. * Gets the current stencil operation when stencil fails
  10707. * @returns a number defining stencil operation to use when stencil fails
  10708. */
  10709. getStencilOperationFail(): number;
  10710. /**
  10711. * Gets the current stencil operation when depth fails
  10712. * @returns a number defining stencil operation to use when depth fails
  10713. */
  10714. getStencilOperationDepthFail(): number;
  10715. /**
  10716. * Gets the current stencil operation when stencil passes
  10717. * @returns a number defining stencil operation to use when stencil passes
  10718. */
  10719. getStencilOperationPass(): number;
  10720. /**
  10721. * Sets the stencil operation to use when stencil fails
  10722. * @param operation defines the stencil operation to use when stencil fails
  10723. */
  10724. setStencilOperationFail(operation: number): void;
  10725. /**
  10726. * Sets the stencil operation to use when depth fails
  10727. * @param operation defines the stencil operation to use when depth fails
  10728. */
  10729. setStencilOperationDepthFail(operation: number): void;
  10730. /**
  10731. * Sets the stencil operation to use when stencil passes
  10732. * @param operation defines the stencil operation to use when stencil passes
  10733. */
  10734. setStencilOperationPass(operation: number): void;
  10735. /**
  10736. * Sets a boolean indicating if the dithering state is enabled or disabled
  10737. * @param value defines the dithering state
  10738. */
  10739. setDitheringState(value: boolean): void;
  10740. /**
  10741. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10742. * @param value defines the rasterizer state
  10743. */
  10744. setRasterizerState(value: boolean): void;
  10745. /**
  10746. * stop executing a render loop function and remove it from the execution array
  10747. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10748. */
  10749. stopRenderLoop(renderFunction?: () => void): void;
  10750. /** @hidden */
  10751. _renderLoop(): void;
  10752. /**
  10753. * Register and execute a render loop. The engine can have more than one render function
  10754. * @param renderFunction defines the function to continuously execute
  10755. */
  10756. runRenderLoop(renderFunction: () => void): void;
  10757. /**
  10758. * Toggle full screen mode
  10759. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10760. */
  10761. switchFullscreen(requestPointerLock: boolean): void;
  10762. /**
  10763. * Clear the current render buffer or the current render target (if any is set up)
  10764. * @param color defines the color to use
  10765. * @param backBuffer defines if the back buffer must be cleared
  10766. * @param depth defines if the depth buffer must be cleared
  10767. * @param stencil defines if the stencil buffer must be cleared
  10768. */
  10769. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10770. /**
  10771. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10772. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10773. * @param y defines the y-coordinate of the corner of the clear rectangle
  10774. * @param width defines the width of the clear rectangle
  10775. * @param height defines the height of the clear rectangle
  10776. * @param clearColor defines the clear color
  10777. */
  10778. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10779. private _viewportCached;
  10780. /** @hidden */
  10781. _viewport(x: number, y: number, width: number, height: number): void;
  10782. /**
  10783. * Set the WebGL's viewport
  10784. * @param viewport defines the viewport element to be used
  10785. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10786. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10787. */
  10788. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10789. /**
  10790. * Directly set the WebGL Viewport
  10791. * @param x defines the x coordinate of the viewport (in screen space)
  10792. * @param y defines the y coordinate of the viewport (in screen space)
  10793. * @param width defines the width of the viewport (in screen space)
  10794. * @param height defines the height of the viewport (in screen space)
  10795. * @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
  10796. */
  10797. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10798. /**
  10799. * Begin a new frame
  10800. */
  10801. beginFrame(): void;
  10802. /**
  10803. * Enf the current frame
  10804. */
  10805. endFrame(): void;
  10806. /**
  10807. * Resize the view according to the canvas' size
  10808. */
  10809. resize(): void;
  10810. /**
  10811. * Force a specific size of the canvas
  10812. * @param width defines the new canvas' width
  10813. * @param height defines the new canvas' height
  10814. */
  10815. setSize(width: number, height: number): void;
  10816. /**
  10817. * Gets a boolean indicating if a webVR device was detected
  10818. * @returns true if a webVR device was detected
  10819. */
  10820. isVRDevicePresent(): boolean;
  10821. /**
  10822. * Gets the current webVR device
  10823. * @returns the current webVR device (or null)
  10824. */
  10825. getVRDevice(): any;
  10826. /**
  10827. * Initializes a webVR display and starts listening to display change events
  10828. * The onVRDisplayChangedObservable will be notified upon these changes
  10829. * @returns The onVRDisplayChangedObservable
  10830. */
  10831. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10832. /**
  10833. * Initializes a webVR display and starts listening to display change events
  10834. * The onVRDisplayChangedObservable will be notified upon these changes
  10835. * @returns A promise containing a VRDisplay and if vr is supported
  10836. */
  10837. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10838. /**
  10839. * Call this function to switch to webVR mode
  10840. * Will do nothing if webVR is not supported or if there is no webVR device
  10841. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10842. */
  10843. enableVR(): void;
  10844. /**
  10845. * Call this function to leave webVR mode
  10846. * Will do nothing if webVR is not supported or if there is no webVR device
  10847. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10848. */
  10849. disableVR(): void;
  10850. private _onVRFullScreenTriggered;
  10851. private _getVRDisplaysAsync;
  10852. /**
  10853. * Binds the frame buffer to the specified texture.
  10854. * @param texture The texture to render to or null for the default canvas
  10855. * @param faceIndex The face of the texture to render to in case of cube texture
  10856. * @param requiredWidth The width of the target to render to
  10857. * @param requiredHeight The height of the target to render to
  10858. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  10859. * @param depthStencilTexture The depth stencil texture to use to render
  10860. * @param lodLevel defines le lod level to bind to the frame buffer
  10861. */
  10862. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  10863. private bindUnboundFramebuffer;
  10864. /**
  10865. * Unbind the current render target texture from the webGL context
  10866. * @param texture defines the render target texture to unbind
  10867. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10868. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10869. */
  10870. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10871. /**
  10872. * Unbind a list of render target textures from the webGL context
  10873. * This is used only when drawBuffer extension or webGL2 are active
  10874. * @param textures defines the render target textures to unbind
  10875. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10876. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10877. */
  10878. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10879. /**
  10880. * Force the mipmap generation for the given render target texture
  10881. * @param texture defines the render target texture to use
  10882. */
  10883. generateMipMapsForCubemap(texture: InternalTexture): void;
  10884. /**
  10885. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  10886. */
  10887. flushFramebuffer(): void;
  10888. /**
  10889. * Unbind the current render target and bind the default framebuffer
  10890. */
  10891. restoreDefaultFramebuffer(): void;
  10892. /**
  10893. * Create an uniform buffer
  10894. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10895. * @param elements defines the content of the uniform buffer
  10896. * @returns the webGL uniform buffer
  10897. */
  10898. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  10899. /**
  10900. * Create a dynamic uniform buffer
  10901. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10902. * @param elements defines the content of the uniform buffer
  10903. * @returns the webGL uniform buffer
  10904. */
  10905. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  10906. /**
  10907. * Update an existing uniform buffer
  10908. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10909. * @param uniformBuffer defines the target uniform buffer
  10910. * @param elements defines the content to update
  10911. * @param offset defines the offset in the uniform buffer where update should start
  10912. * @param count defines the size of the data to update
  10913. */
  10914. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  10915. private _resetVertexBufferBinding;
  10916. /**
  10917. * Creates a vertex buffer
  10918. * @param data the data for the vertex buffer
  10919. * @returns the new WebGL static buffer
  10920. */
  10921. createVertexBuffer(data: DataArray): WebGLBuffer;
  10922. /**
  10923. * Creates a dynamic vertex buffer
  10924. * @param data the data for the dynamic vertex buffer
  10925. * @returns the new WebGL dynamic buffer
  10926. */
  10927. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  10928. /**
  10929. * Update a dynamic index buffer
  10930. * @param indexBuffer defines the target index buffer
  10931. * @param indices defines the data to update
  10932. * @param offset defines the offset in the target index buffer where update should start
  10933. */
  10934. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  10935. /**
  10936. * Updates a dynamic vertex buffer.
  10937. * @param vertexBuffer the vertex buffer to update
  10938. * @param data the data used to update the vertex buffer
  10939. * @param byteOffset the byte offset of the data
  10940. * @param byteLength the byte length of the data
  10941. */
  10942. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  10943. private _resetIndexBufferBinding;
  10944. /**
  10945. * Creates a new index buffer
  10946. * @param indices defines the content of the index buffer
  10947. * @param updatable defines if the index buffer must be updatable
  10948. * @returns a new webGL buffer
  10949. */
  10950. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  10951. /**
  10952. * Bind a webGL buffer to the webGL context
  10953. * @param buffer defines the buffer to bind
  10954. */
  10955. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  10956. /**
  10957. * Bind an uniform buffer to the current webGL context
  10958. * @param buffer defines the buffer to bind
  10959. */
  10960. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  10961. /**
  10962. * Bind a buffer to the current webGL context at a given location
  10963. * @param buffer defines the buffer to bind
  10964. * @param location defines the index where to bind the buffer
  10965. */
  10966. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  10967. /**
  10968. * Bind a specific block at a given index in a specific shader program
  10969. * @param shaderProgram defines the shader program
  10970. * @param blockName defines the block name
  10971. * @param index defines the index where to bind the block
  10972. */
  10973. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  10974. private bindIndexBuffer;
  10975. private bindBuffer;
  10976. /**
  10977. * update the bound buffer with the given data
  10978. * @param data defines the data to update
  10979. */
  10980. updateArrayBuffer(data: Float32Array): void;
  10981. private _vertexAttribPointer;
  10982. private _bindIndexBufferWithCache;
  10983. private _bindVertexBuffersAttributes;
  10984. /**
  10985. * Records a vertex array object
  10986. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10987. * @param vertexBuffers defines the list of vertex buffers to store
  10988. * @param indexBuffer defines the index buffer to store
  10989. * @param effect defines the effect to store
  10990. * @returns the new vertex array object
  10991. */
  10992. recordVertexArrayObject(vertexBuffers: {
  10993. [key: string]: VertexBuffer;
  10994. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  10995. /**
  10996. * Bind a specific vertex array object
  10997. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10998. * @param vertexArrayObject defines the vertex array object to bind
  10999. * @param indexBuffer defines the index buffer to bind
  11000. */
  11001. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11002. /**
  11003. * Bind webGl buffers directly to the webGL context
  11004. * @param vertexBuffer defines the vertex buffer to bind
  11005. * @param indexBuffer defines the index buffer to bind
  11006. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11007. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11008. * @param effect defines the effect associated with the vertex buffer
  11009. */
  11010. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11011. private _unbindVertexArrayObject;
  11012. /**
  11013. * Bind a list of vertex buffers to the webGL context
  11014. * @param vertexBuffers defines the list of vertex buffers to bind
  11015. * @param indexBuffer defines the index buffer to bind
  11016. * @param effect defines the effect associated with the vertex buffers
  11017. */
  11018. bindBuffers(vertexBuffers: {
  11019. [key: string]: Nullable<VertexBuffer>;
  11020. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11021. /**
  11022. * Unbind all instance attributes
  11023. */
  11024. unbindInstanceAttributes(): void;
  11025. /**
  11026. * Release and free the memory of a vertex array object
  11027. * @param vao defines the vertex array object to delete
  11028. */
  11029. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11030. /** @hidden */
  11031. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11032. /**
  11033. * Creates a webGL buffer to use with instanciation
  11034. * @param capacity defines the size of the buffer
  11035. * @returns the webGL buffer
  11036. */
  11037. createInstancesBuffer(capacity: number): WebGLBuffer;
  11038. /**
  11039. * Delete a webGL buffer used with instanciation
  11040. * @param buffer defines the webGL buffer to delete
  11041. */
  11042. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11043. /**
  11044. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11045. * @param instancesBuffer defines the webGL buffer to update and bind
  11046. * @param data defines the data to store in the buffer
  11047. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11048. */
  11049. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11050. /**
  11051. * Apply all cached states (depth, culling, stencil and alpha)
  11052. */
  11053. applyStates(): void;
  11054. /**
  11055. * Send a draw order
  11056. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11057. * @param indexStart defines the starting index
  11058. * @param indexCount defines the number of index to draw
  11059. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11060. */
  11061. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11062. /**
  11063. * Draw a list of points
  11064. * @param verticesStart defines the index of first vertex to draw
  11065. * @param verticesCount defines the count of vertices to draw
  11066. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11067. */
  11068. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11069. /**
  11070. * Draw a list of unindexed primitives
  11071. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11072. * @param verticesStart defines the index of first vertex to draw
  11073. * @param verticesCount defines the count of vertices to draw
  11074. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11075. */
  11076. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11077. /**
  11078. * Draw a list of indexed primitives
  11079. * @param fillMode defines the primitive to use
  11080. * @param indexStart defines the starting index
  11081. * @param indexCount defines the number of index to draw
  11082. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11083. */
  11084. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11085. /**
  11086. * Draw a list of unindexed primitives
  11087. * @param fillMode defines the primitive to use
  11088. * @param verticesStart defines the index of first vertex to draw
  11089. * @param verticesCount defines the count of vertices to draw
  11090. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11091. */
  11092. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11093. private _drawMode;
  11094. /** @hidden */
  11095. _releaseEffect(effect: Effect): void;
  11096. /** @hidden */
  11097. _deleteProgram(program: WebGLProgram): void;
  11098. /**
  11099. * Create a new effect (used to store vertex/fragment shaders)
  11100. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11101. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11102. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11103. * @param samplers defines an array of string used to represent textures
  11104. * @param defines defines the string containing the defines to use to compile the shaders
  11105. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11106. * @param onCompiled defines a function to call when the effect creation is successful
  11107. * @param onError defines a function to call when the effect creation has failed
  11108. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11109. * @returns the new Effect
  11110. */
  11111. 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;
  11112. private _compileShader;
  11113. private _compileRawShader;
  11114. /**
  11115. * Directly creates a webGL program
  11116. * @param vertexCode defines the vertex shader code to use
  11117. * @param fragmentCode defines the fragment shader code to use
  11118. * @param context defines the webGL context to use (if not set, the current one will be used)
  11119. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11120. * @returns the new webGL program
  11121. */
  11122. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11123. /**
  11124. * Creates a webGL program
  11125. * @param vertexCode defines the vertex shader code to use
  11126. * @param fragmentCode defines the fragment shader code to use
  11127. * @param defines defines the string containing the defines to use to compile the shaders
  11128. * @param context defines the webGL context to use (if not set, the current one will be used)
  11129. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11130. * @returns the new webGL program
  11131. */
  11132. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11133. private _createShaderProgram;
  11134. private _finalizeProgram;
  11135. /** @hidden */
  11136. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11137. /** @hidden */
  11138. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11139. /**
  11140. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11141. * @param shaderProgram defines the webGL program to use
  11142. * @param uniformsNames defines the list of uniform names
  11143. * @returns an array of webGL uniform locations
  11144. */
  11145. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11146. /**
  11147. * Gets the lsit of active attributes for a given webGL program
  11148. * @param shaderProgram defines the webGL program to use
  11149. * @param attributesNames defines the list of attribute names to get
  11150. * @returns an array of indices indicating the offset of each attribute
  11151. */
  11152. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11153. /**
  11154. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11155. * @param effect defines the effect to activate
  11156. */
  11157. enableEffect(effect: Nullable<Effect>): void;
  11158. /**
  11159. * Set the value of an uniform to an array of int32
  11160. * @param uniform defines the webGL uniform location where to store the value
  11161. * @param array defines the array of int32 to store
  11162. */
  11163. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11164. /**
  11165. * Set the value of an uniform to an array of int32 (stored as vec2)
  11166. * @param uniform defines the webGL uniform location where to store the value
  11167. * @param array defines the array of int32 to store
  11168. */
  11169. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11170. /**
  11171. * Set the value of an uniform to an array of int32 (stored as vec3)
  11172. * @param uniform defines the webGL uniform location where to store the value
  11173. * @param array defines the array of int32 to store
  11174. */
  11175. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11176. /**
  11177. * Set the value of an uniform to an array of int32 (stored as vec4)
  11178. * @param uniform defines the webGL uniform location where to store the value
  11179. * @param array defines the array of int32 to store
  11180. */
  11181. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11182. /**
  11183. * Set the value of an uniform to an array of float32
  11184. * @param uniform defines the webGL uniform location where to store the value
  11185. * @param array defines the array of float32 to store
  11186. */
  11187. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11188. /**
  11189. * Set the value of an uniform to an array of float32 (stored as vec2)
  11190. * @param uniform defines the webGL uniform location where to store the value
  11191. * @param array defines the array of float32 to store
  11192. */
  11193. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11194. /**
  11195. * Set the value of an uniform to an array of float32 (stored as vec3)
  11196. * @param uniform defines the webGL uniform location where to store the value
  11197. * @param array defines the array of float32 to store
  11198. */
  11199. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11200. /**
  11201. * Set the value of an uniform to an array of float32 (stored as vec4)
  11202. * @param uniform defines the webGL uniform location where to store the value
  11203. * @param array defines the array of float32 to store
  11204. */
  11205. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11206. /**
  11207. * Set the value of an uniform to an array of number
  11208. * @param uniform defines the webGL uniform location where to store the value
  11209. * @param array defines the array of number to store
  11210. */
  11211. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11212. /**
  11213. * Set the value of an uniform to an array of number (stored as vec2)
  11214. * @param uniform defines the webGL uniform location where to store the value
  11215. * @param array defines the array of number to store
  11216. */
  11217. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11218. /**
  11219. * Set the value of an uniform to an array of number (stored as vec3)
  11220. * @param uniform defines the webGL uniform location where to store the value
  11221. * @param array defines the array of number to store
  11222. */
  11223. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11224. /**
  11225. * Set the value of an uniform to an array of number (stored as vec4)
  11226. * @param uniform defines the webGL uniform location where to store the value
  11227. * @param array defines the array of number to store
  11228. */
  11229. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11230. /**
  11231. * Set the value of an uniform to an array of float32 (stored as matrices)
  11232. * @param uniform defines the webGL uniform location where to store the value
  11233. * @param matrices defines the array of float32 to store
  11234. */
  11235. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11236. /**
  11237. * Set the value of an uniform to a matrix
  11238. * @param uniform defines the webGL uniform location where to store the value
  11239. * @param matrix defines the matrix to store
  11240. */
  11241. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11242. /**
  11243. * Set the value of an uniform to a matrix (3x3)
  11244. * @param uniform defines the webGL uniform location where to store the value
  11245. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11246. */
  11247. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11248. /**
  11249. * Set the value of an uniform to a matrix (2x2)
  11250. * @param uniform defines the webGL uniform location where to store the value
  11251. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11252. */
  11253. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11254. /**
  11255. * Set the value of an uniform to a number (int)
  11256. * @param uniform defines the webGL uniform location where to store the value
  11257. * @param value defines the int number to store
  11258. */
  11259. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11260. /**
  11261. * Set the value of an uniform to a number (float)
  11262. * @param uniform defines the webGL uniform location where to store the value
  11263. * @param value defines the float number to store
  11264. */
  11265. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11266. /**
  11267. * Set the value of an uniform to a vec2
  11268. * @param uniform defines the webGL uniform location where to store the value
  11269. * @param x defines the 1st component of the value
  11270. * @param y defines the 2nd component of the value
  11271. */
  11272. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11273. /**
  11274. * Set the value of an uniform to a vec3
  11275. * @param uniform defines the webGL uniform location where to store the value
  11276. * @param x defines the 1st component of the value
  11277. * @param y defines the 2nd component of the value
  11278. * @param z defines the 3rd component of the value
  11279. */
  11280. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11281. /**
  11282. * Set the value of an uniform to a boolean
  11283. * @param uniform defines the webGL uniform location where to store the value
  11284. * @param bool defines the boolean to store
  11285. */
  11286. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11287. /**
  11288. * Set the value of an uniform to a vec4
  11289. * @param uniform defines the webGL uniform location where to store the value
  11290. * @param x defines the 1st component of the value
  11291. * @param y defines the 2nd component of the value
  11292. * @param z defines the 3rd component of the value
  11293. * @param w defines the 4th component of the value
  11294. */
  11295. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11296. /**
  11297. * Set the value of an uniform to a Color3
  11298. * @param uniform defines the webGL uniform location where to store the value
  11299. * @param color3 defines the color to store
  11300. */
  11301. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11302. /**
  11303. * Set the value of an uniform to a Color3 and an alpha value
  11304. * @param uniform defines the webGL uniform location where to store the value
  11305. * @param color3 defines the color to store
  11306. * @param alpha defines the alpha component to store
  11307. */
  11308. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11309. /**
  11310. * Sets a Color4 on a uniform variable
  11311. * @param uniform defines the uniform location
  11312. * @param color4 defines the value to be set
  11313. */
  11314. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11315. /**
  11316. * Set various states to the webGL context
  11317. * @param culling defines backface culling state
  11318. * @param zOffset defines the value to apply to zOffset (0 by default)
  11319. * @param force defines if states must be applied even if cache is up to date
  11320. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11321. */
  11322. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11323. /**
  11324. * Set the z offset to apply to current rendering
  11325. * @param value defines the offset to apply
  11326. */
  11327. setZOffset(value: number): void;
  11328. /**
  11329. * Gets the current value of the zOffset
  11330. * @returns the current zOffset state
  11331. */
  11332. getZOffset(): number;
  11333. /**
  11334. * Enable or disable depth buffering
  11335. * @param enable defines the state to set
  11336. */
  11337. setDepthBuffer(enable: boolean): void;
  11338. /**
  11339. * Gets a boolean indicating if depth writing is enabled
  11340. * @returns the current depth writing state
  11341. */
  11342. getDepthWrite(): boolean;
  11343. /**
  11344. * Enable or disable depth writing
  11345. * @param enable defines the state to set
  11346. */
  11347. setDepthWrite(enable: boolean): void;
  11348. /**
  11349. * Enable or disable color writing
  11350. * @param enable defines the state to set
  11351. */
  11352. setColorWrite(enable: boolean): void;
  11353. /**
  11354. * Gets a boolean indicating if color writing is enabled
  11355. * @returns the current color writing state
  11356. */
  11357. getColorWrite(): boolean;
  11358. /**
  11359. * Sets alpha constants used by some alpha blending modes
  11360. * @param r defines the red component
  11361. * @param g defines the green component
  11362. * @param b defines the blue component
  11363. * @param a defines the alpha component
  11364. */
  11365. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11366. /**
  11367. * Sets the current alpha mode
  11368. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11369. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11370. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11371. */
  11372. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11373. /**
  11374. * Gets the current alpha mode
  11375. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11376. * @returns the current alpha mode
  11377. */
  11378. getAlphaMode(): number;
  11379. /**
  11380. * Clears the list of texture accessible through engine.
  11381. * This can help preventing texture load conflict due to name collision.
  11382. */
  11383. clearInternalTexturesCache(): void;
  11384. /**
  11385. * Force the entire cache to be cleared
  11386. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11387. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11388. */
  11389. wipeCaches(bruteForce?: boolean): void;
  11390. /**
  11391. * Set the compressed texture format to use, based on the formats you have, and the formats
  11392. * supported by the hardware / browser.
  11393. *
  11394. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11395. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11396. * to API arguments needed to compressed textures. This puts the burden on the container
  11397. * generator to house the arcane code for determining these for current & future formats.
  11398. *
  11399. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11400. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11401. *
  11402. * Note: The result of this call is not taken into account when a texture is base64.
  11403. *
  11404. * @param formatsAvailable defines the list of those format families you have created
  11405. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11406. *
  11407. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11408. * @returns The extension selected.
  11409. */
  11410. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11411. private _getSamplingParameters;
  11412. private _partialLoadImg;
  11413. private _cascadeLoadImgs;
  11414. /** @hidden */
  11415. _createTexture(): WebGLTexture;
  11416. /**
  11417. * Usually called from BABYLON.Texture.ts.
  11418. * Passed information to create a WebGLTexture
  11419. * @param urlArg defines a value which contains one of the following:
  11420. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11421. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11422. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11423. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11424. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  11425. * @param scene needed for loading to the correct scene
  11426. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11427. * @param onLoad optional callback to be called upon successful completion
  11428. * @param onError optional callback to be called upon failure
  11429. * @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
  11430. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11431. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11432. * @param forcedExtension defines the extension to use to pick the right loader
  11433. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11434. */
  11435. 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>): InternalTexture;
  11436. private _rescaleTexture;
  11437. /**
  11438. * Update a raw texture
  11439. * @param texture defines the texture to update
  11440. * @param data defines the data to store in the texture
  11441. * @param format defines the format of the data
  11442. * @param invertY defines if data must be stored with Y axis inverted
  11443. * @param compression defines the compression used (null by default)
  11444. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11445. */
  11446. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11447. /**
  11448. * Creates a raw texture
  11449. * @param data defines the data to store in the texture
  11450. * @param width defines the width of the texture
  11451. * @param height defines the height of the texture
  11452. * @param format defines the format of the data
  11453. * @param generateMipMaps defines if the engine should generate the mip levels
  11454. * @param invertY defines if data must be stored with Y axis inverted
  11455. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11456. * @param compression defines the compression used (null by default)
  11457. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11458. * @returns the raw texture inside an InternalTexture
  11459. */
  11460. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11461. private _unpackFlipYCached;
  11462. /**
  11463. * In case you are sharing the context with other applications, it might
  11464. * be interested to not cache the unpack flip y state to ensure a consistent
  11465. * value would be set.
  11466. */
  11467. enableUnpackFlipYCached: boolean;
  11468. /** @hidden */
  11469. _unpackFlipY(value: boolean): void;
  11470. /** @hidden */
  11471. _getUnpackAlignement(): number;
  11472. /**
  11473. * Creates a dynamic texture
  11474. * @param width defines the width of the texture
  11475. * @param height defines the height of the texture
  11476. * @param generateMipMaps defines if the engine should generate the mip levels
  11477. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11478. * @returns the dynamic texture inside an InternalTexture
  11479. */
  11480. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11481. /**
  11482. * Update the sampling mode of a given texture
  11483. * @param samplingMode defines the required sampling mode
  11484. * @param texture defines the texture to update
  11485. */
  11486. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11487. /**
  11488. * Update the content of a dynamic texture
  11489. * @param texture defines the texture to update
  11490. * @param canvas defines the canvas containing the source
  11491. * @param invertY defines if data must be stored with Y axis inverted
  11492. * @param premulAlpha defines if alpha is stored as premultiplied
  11493. * @param format defines the format of the data
  11494. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11495. */
  11496. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11497. /**
  11498. * Update a video texture
  11499. * @param texture defines the texture to update
  11500. * @param video defines the video element to use
  11501. * @param invertY defines if data must be stored with Y axis inverted
  11502. */
  11503. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11504. /**
  11505. * Updates a depth texture Comparison Mode and Function.
  11506. * If the comparison Function is equal to 0, the mode will be set to none.
  11507. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11508. * @param texture The texture to set the comparison function for
  11509. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11510. */
  11511. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11512. private _setupDepthStencilTexture;
  11513. /**
  11514. * Creates a depth stencil texture.
  11515. * This is only available in WebGL 2 or with the depth texture extension available.
  11516. * @param size The size of face edge in the texture.
  11517. * @param options The options defining the texture.
  11518. * @returns The texture
  11519. */
  11520. createDepthStencilTexture(size: number | {
  11521. width: number;
  11522. height: number;
  11523. }, options: DepthTextureCreationOptions): InternalTexture;
  11524. /**
  11525. * Creates a depth stencil texture.
  11526. * This is only available in WebGL 2 or with the depth texture extension available.
  11527. * @param size The size of face edge in the texture.
  11528. * @param options The options defining the texture.
  11529. * @returns The texture
  11530. */
  11531. private _createDepthStencilTexture;
  11532. /**
  11533. * Creates a depth stencil cube texture.
  11534. * This is only available in WebGL 2.
  11535. * @param size The size of face edge in the cube texture.
  11536. * @param options The options defining the cube texture.
  11537. * @returns The cube texture
  11538. */
  11539. private _createDepthStencilCubeTexture;
  11540. /**
  11541. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11542. * @param renderTarget The render target to set the frame buffer for
  11543. */
  11544. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11545. /**
  11546. * Creates a new render target texture
  11547. * @param size defines the size of the texture
  11548. * @param options defines the options used to create the texture
  11549. * @returns a new render target texture stored in an InternalTexture
  11550. */
  11551. createRenderTargetTexture(size: number | {
  11552. width: number;
  11553. height: number;
  11554. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11555. /**
  11556. * Create a multi render target texture
  11557. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11558. * @param size defines the size of the texture
  11559. * @param options defines the creation options
  11560. * @returns the cube texture as an InternalTexture
  11561. */
  11562. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11563. private _setupFramebufferDepthAttachments;
  11564. /**
  11565. * Updates the sample count of a render target texture
  11566. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11567. * @param texture defines the texture to update
  11568. * @param samples defines the sample count to set
  11569. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11570. */
  11571. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11572. /**
  11573. * Update the sample count for a given multiple render target texture
  11574. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11575. * @param textures defines the textures to update
  11576. * @param samples defines the sample count to set
  11577. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11578. */
  11579. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11580. /** @hidden */
  11581. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11582. /** @hidden */
  11583. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11584. /** @hidden */
  11585. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11586. /** @hidden */
  11587. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11588. /**
  11589. * Creates a new render target cube texture
  11590. * @param size defines the size of the texture
  11591. * @param options defines the options used to create the texture
  11592. * @returns a new render target cube texture stored in an InternalTexture
  11593. */
  11594. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11595. /**
  11596. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11597. * @param rootUrl defines the url where the file to load is located
  11598. * @param scene defines the current scene
  11599. * @param lodScale defines scale to apply to the mip map selection
  11600. * @param lodOffset defines offset to apply to the mip map selection
  11601. * @param onLoad defines an optional callback raised when the texture is loaded
  11602. * @param onError defines an optional callback raised if there is an issue to load the texture
  11603. * @param format defines the format of the data
  11604. * @param forcedExtension defines the extension to use to pick the right loader
  11605. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11606. * @returns the cube texture as an InternalTexture
  11607. */
  11608. 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;
  11609. /**
  11610. * Creates a cube texture
  11611. * @param rootUrl defines the url where the files to load is located
  11612. * @param scene defines the current scene
  11613. * @param files defines the list of files to load (1 per face)
  11614. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11615. * @param onLoad defines an optional callback raised when the texture is loaded
  11616. * @param onError defines an optional callback raised if there is an issue to load the texture
  11617. * @param format defines the format of the data
  11618. * @param forcedExtension defines the extension to use to pick the right loader
  11619. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11620. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11621. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11622. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11623. * @returns the cube texture as an InternalTexture
  11624. */
  11625. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  11626. /**
  11627. * @hidden
  11628. */
  11629. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11630. /**
  11631. * Update a raw cube texture
  11632. * @param texture defines the texture to udpdate
  11633. * @param data defines the data to store
  11634. * @param format defines the data format
  11635. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11636. * @param invertY defines if data must be stored with Y axis inverted
  11637. * @param compression defines the compression used (null by default)
  11638. * @param level defines which level of the texture to update
  11639. */
  11640. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11641. /**
  11642. * Creates a new raw cube texture
  11643. * @param data defines the array of data to use to create each face
  11644. * @param size defines the size of the textures
  11645. * @param format defines the format of the data
  11646. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11647. * @param generateMipMaps defines if the engine should generate the mip levels
  11648. * @param invertY defines if data must be stored with Y axis inverted
  11649. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11650. * @param compression defines the compression used (null by default)
  11651. * @returns the cube texture as an InternalTexture
  11652. */
  11653. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11654. /**
  11655. * Creates a new raw cube texture from a specified url
  11656. * @param url defines the url where the data is located
  11657. * @param scene defines the current scene
  11658. * @param size defines the size of the textures
  11659. * @param format defines the format of the data
  11660. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11661. * @param noMipmap defines if the engine should avoid generating the mip levels
  11662. * @param callback defines a callback used to extract texture data from loaded data
  11663. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11664. * @param onLoad defines a callback called when texture is loaded
  11665. * @param onError defines a callback called if there is an error
  11666. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11667. * @param invertY defines if data must be stored with Y axis inverted
  11668. * @returns the cube texture as an InternalTexture
  11669. */
  11670. 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;
  11671. /**
  11672. * Update a raw 3D texture
  11673. * @param texture defines the texture to update
  11674. * @param data defines the data to store
  11675. * @param format defines the data format
  11676. * @param invertY defines if data must be stored with Y axis inverted
  11677. * @param compression defines the used compression (can be null)
  11678. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11679. */
  11680. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11681. /**
  11682. * Creates a new raw 3D texture
  11683. * @param data defines the data used to create the texture
  11684. * @param width defines the width of the texture
  11685. * @param height defines the height of the texture
  11686. * @param depth defines the depth of the texture
  11687. * @param format defines the format of the texture
  11688. * @param generateMipMaps defines if the engine must generate mip levels
  11689. * @param invertY defines if data must be stored with Y axis inverted
  11690. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11691. * @param compression defines the compressed used (can be null)
  11692. * @param textureType defines the compressed used (can be null)
  11693. * @returns a new raw 3D texture (stored in an InternalTexture)
  11694. */
  11695. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11696. private _prepareWebGLTextureContinuation;
  11697. private _prepareWebGLTexture;
  11698. private _convertRGBtoRGBATextureData;
  11699. /** @hidden */
  11700. _releaseFramebufferObjects(texture: InternalTexture): void;
  11701. /** @hidden */
  11702. _releaseTexture(texture: InternalTexture): void;
  11703. private setProgram;
  11704. private _boundUniforms;
  11705. /**
  11706. * Binds an effect to the webGL context
  11707. * @param effect defines the effect to bind
  11708. */
  11709. bindSamplers(effect: Effect): void;
  11710. private _moveBoundTextureOnTop;
  11711. private _getCorrectTextureChannel;
  11712. private _linkTrackers;
  11713. private _removeDesignatedSlot;
  11714. private _activateCurrentTexture;
  11715. /** @hidden */
  11716. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11717. /** @hidden */
  11718. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11719. /**
  11720. * Sets a texture to the webGL context from a postprocess
  11721. * @param channel defines the channel to use
  11722. * @param postProcess defines the source postprocess
  11723. */
  11724. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11725. /**
  11726. * Binds the output of the passed in post process to the texture channel specified
  11727. * @param channel The channel the texture should be bound to
  11728. * @param postProcess The post process which's output should be bound
  11729. */
  11730. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11731. /**
  11732. * Unbind all textures from the webGL context
  11733. */
  11734. unbindAllTextures(): void;
  11735. /**
  11736. * Sets a texture to the according uniform.
  11737. * @param channel The texture channel
  11738. * @param uniform The uniform to set
  11739. * @param texture The texture to apply
  11740. */
  11741. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11742. /**
  11743. * Sets a depth stencil texture from a render target to the according uniform.
  11744. * @param channel The texture channel
  11745. * @param uniform The uniform to set
  11746. * @param texture The render target texture containing the depth stencil texture to apply
  11747. */
  11748. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11749. private _bindSamplerUniformToChannel;
  11750. private _getTextureWrapMode;
  11751. private _setTexture;
  11752. /**
  11753. * Sets an array of texture to the webGL context
  11754. * @param channel defines the channel where the texture array must be set
  11755. * @param uniform defines the associated uniform location
  11756. * @param textures defines the array of textures to bind
  11757. */
  11758. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11759. /** @hidden */
  11760. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11761. private _setTextureParameterFloat;
  11762. private _setTextureParameterInteger;
  11763. /**
  11764. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11765. * @param x defines the x coordinate of the rectangle where pixels must be read
  11766. * @param y defines the y coordinate of the rectangle where pixels must be read
  11767. * @param width defines the width of the rectangle where pixels must be read
  11768. * @param height defines the height of the rectangle where pixels must be read
  11769. * @returns a Uint8Array containing RGBA colors
  11770. */
  11771. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11772. /**
  11773. * Add an externaly attached data from its key.
  11774. * This method call will fail and return false, if such key already exists.
  11775. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11776. * @param key the unique key that identifies the data
  11777. * @param data the data object to associate to the key for this Engine instance
  11778. * @return true if no such key were already present and the data was added successfully, false otherwise
  11779. */
  11780. addExternalData<T>(key: string, data: T): boolean;
  11781. /**
  11782. * Get an externaly attached data from its key
  11783. * @param key the unique key that identifies the data
  11784. * @return the associated data, if present (can be null), or undefined if not present
  11785. */
  11786. getExternalData<T>(key: string): T;
  11787. /**
  11788. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11789. * @param key the unique key that identifies the data
  11790. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11791. * @return the associated data, can be null if the factory returned null.
  11792. */
  11793. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11794. /**
  11795. * Remove an externaly attached data from the Engine instance
  11796. * @param key the unique key that identifies the data
  11797. * @return true if the data was successfully removed, false if it doesn't exist
  11798. */
  11799. removeExternalData(key: string): boolean;
  11800. /**
  11801. * Unbind all vertex attributes from the webGL context
  11802. */
  11803. unbindAllAttributes(): void;
  11804. /**
  11805. * 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
  11806. */
  11807. releaseEffects(): void;
  11808. /**
  11809. * Dispose and release all associated resources
  11810. */
  11811. dispose(): void;
  11812. /**
  11813. * Display the loading screen
  11814. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11815. */
  11816. displayLoadingUI(): void;
  11817. /**
  11818. * Hide the loading screen
  11819. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11820. */
  11821. hideLoadingUI(): void;
  11822. /**
  11823. * Gets the current loading screen object
  11824. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11825. */
  11826. /**
  11827. * Sets the current loading screen object
  11828. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11829. */
  11830. loadingScreen: ILoadingScreen;
  11831. /**
  11832. * Sets the current loading screen text
  11833. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11834. */
  11835. loadingUIText: string;
  11836. /**
  11837. * Sets the current loading screen background color
  11838. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11839. */
  11840. loadingUIBackgroundColor: string;
  11841. /**
  11842. * Attach a new callback raised when context lost event is fired
  11843. * @param callback defines the callback to call
  11844. */
  11845. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11846. /**
  11847. * Attach a new callback raised when context restored event is fired
  11848. * @param callback defines the callback to call
  11849. */
  11850. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11851. /**
  11852. * Gets the source code of the vertex shader associated with a specific webGL program
  11853. * @param program defines the program to use
  11854. * @returns a string containing the source code of the vertex shader associated with the program
  11855. */
  11856. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  11857. /**
  11858. * Gets the source code of the fragment shader associated with a specific webGL program
  11859. * @param program defines the program to use
  11860. * @returns a string containing the source code of the fragment shader associated with the program
  11861. */
  11862. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  11863. /**
  11864. * Get the current error code of the webGL context
  11865. * @returns the error code
  11866. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11867. */
  11868. getError(): number;
  11869. /**
  11870. * Gets the current framerate
  11871. * @returns a number representing the framerate
  11872. */
  11873. getFps(): number;
  11874. /**
  11875. * Gets the time spent between current and previous frame
  11876. * @returns a number representing the delta time in ms
  11877. */
  11878. getDeltaTime(): number;
  11879. private _measureFps;
  11880. /** @hidden */
  11881. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  11882. private _canRenderToFloatFramebuffer;
  11883. private _canRenderToHalfFloatFramebuffer;
  11884. private _canRenderToFramebuffer;
  11885. /** @hidden */
  11886. _getWebGLTextureType(type: number): number;
  11887. private _getInternalFormat;
  11888. /** @hidden */
  11889. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  11890. /** @hidden */
  11891. _getRGBAMultiSampleBufferFormat(type: number): number;
  11892. /** @hidden */
  11893. _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;
  11894. /** @hidden */
  11895. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  11896. private _partialLoadFile;
  11897. private _cascadeLoadFiles;
  11898. /**
  11899. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  11900. * @returns true if the engine can be created
  11901. * @ignorenaming
  11902. */
  11903. static isSupported(): boolean;
  11904. }
  11905. }
  11906. declare module BABYLON {
  11907. /**
  11908. * Options to create the null engine
  11909. */
  11910. class NullEngineOptions {
  11911. /**
  11912. * Render width (Default: 512)
  11913. */
  11914. renderWidth: number;
  11915. /**
  11916. * Render height (Default: 256)
  11917. */
  11918. renderHeight: number;
  11919. /**
  11920. * Texture size (Default: 512)
  11921. */
  11922. textureSize: number;
  11923. /**
  11924. * If delta time between frames should be constant
  11925. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11926. */
  11927. deterministicLockstep: boolean;
  11928. /**
  11929. * Maximum about of steps between frames (Default: 4)
  11930. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11931. */
  11932. lockstepMaxSteps: number;
  11933. }
  11934. /**
  11935. * The null engine class provides support for headless version of babylon.js.
  11936. * This can be used in server side scenario or for testing purposes
  11937. */
  11938. class NullEngine extends Engine {
  11939. private _options;
  11940. /**
  11941. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11942. */
  11943. isDeterministicLockStep(): boolean;
  11944. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  11945. getLockstepMaxSteps(): number;
  11946. /**
  11947. * Sets hardware scaling, used to save performance if needed
  11948. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  11949. */
  11950. getHardwareScalingLevel(): number;
  11951. constructor(options?: NullEngineOptions);
  11952. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11953. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  11954. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  11955. getRenderWidth(useScreen?: boolean): number;
  11956. getRenderHeight(useScreen?: boolean): number;
  11957. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  11958. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  11959. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  11960. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11961. bindSamplers(effect: Effect): void;
  11962. enableEffect(effect: Effect): void;
  11963. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11964. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  11965. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  11966. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  11967. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  11968. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  11969. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  11970. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  11971. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  11972. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  11973. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  11974. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  11975. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  11976. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  11977. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  11978. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11979. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11980. setFloat(uniform: WebGLUniformLocation, value: number): void;
  11981. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  11982. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  11983. setBool(uniform: WebGLUniformLocation, bool: number): void;
  11984. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  11985. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  11986. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  11987. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11988. bindBuffers(vertexBuffers: {
  11989. [key: string]: VertexBuffer;
  11990. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  11991. wipeCaches(bruteForce?: boolean): void;
  11992. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11993. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11994. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11995. /** @hidden */
  11996. _createTexture(): WebGLTexture;
  11997. /** @hidden */
  11998. _releaseTexture(texture: InternalTexture): void;
  11999. 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;
  12000. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12001. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12002. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12003. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12004. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12005. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12006. areAllEffectsReady(): boolean;
  12007. /**
  12008. * @hidden
  12009. * Get the current error code of the webGL context
  12010. * @returns the error code
  12011. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12012. */
  12013. getError(): number;
  12014. /** @hidden */
  12015. _getUnpackAlignement(): number;
  12016. /** @hidden */
  12017. _unpackFlipY(value: boolean): void;
  12018. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12019. /**
  12020. * Updates a dynamic vertex buffer.
  12021. * @param vertexBuffer the vertex buffer to update
  12022. * @param data the data used to update the vertex buffer
  12023. * @param byteOffset the byte offset of the data (optional)
  12024. * @param byteLength the byte length of the data (optional)
  12025. */
  12026. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12027. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12028. /** @hidden */
  12029. _bindTexture(channel: number, texture: InternalTexture): void;
  12030. /** @hidden */
  12031. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12032. releaseEffects(): void;
  12033. displayLoadingUI(): void;
  12034. hideLoadingUI(): void;
  12035. /** @hidden */
  12036. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12037. /** @hidden */
  12038. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12039. /** @hidden */
  12040. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12041. /** @hidden */
  12042. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12043. }
  12044. }
  12045. interface WebGLRenderingContext {
  12046. readonly RASTERIZER_DISCARD: number;
  12047. readonly DEPTH_COMPONENT24: number;
  12048. readonly TEXTURE_3D: number;
  12049. readonly TEXTURE_2D_ARRAY: number;
  12050. readonly TEXTURE_COMPARE_FUNC: number;
  12051. readonly TEXTURE_COMPARE_MODE: number;
  12052. readonly COMPARE_REF_TO_TEXTURE: number;
  12053. readonly TEXTURE_WRAP_R: number;
  12054. readonly HALF_FLOAT: number;
  12055. readonly RGB8: number;
  12056. readonly RED_INTEGER: number;
  12057. readonly RG_INTEGER: number;
  12058. readonly RGB_INTEGER: number;
  12059. readonly RGBA_INTEGER: number;
  12060. readonly R8_SNORM: number;
  12061. readonly RG8_SNORM: number;
  12062. readonly RGB8_SNORM: number;
  12063. readonly RGBA8_SNORM: number;
  12064. readonly R8I: number;
  12065. readonly RG8I: number;
  12066. readonly RGB8I: number;
  12067. readonly RGBA8I: number;
  12068. readonly R8UI: number;
  12069. readonly RG8UI: number;
  12070. readonly RGB8UI: number;
  12071. readonly RGBA8UI: number;
  12072. readonly R16I: number;
  12073. readonly RG16I: number;
  12074. readonly RGB16I: number;
  12075. readonly RGBA16I: number;
  12076. readonly R16UI: number;
  12077. readonly RG16UI: number;
  12078. readonly RGB16UI: number;
  12079. readonly RGBA16UI: number;
  12080. readonly R32I: number;
  12081. readonly RG32I: number;
  12082. readonly RGB32I: number;
  12083. readonly RGBA32I: number;
  12084. readonly R32UI: number;
  12085. readonly RG32UI: number;
  12086. readonly RGB32UI: number;
  12087. readonly RGBA32UI: number;
  12088. readonly RGB10_A2UI: number;
  12089. readonly R11F_G11F_B10F: number;
  12090. readonly RGB9_E5: number;
  12091. readonly RGB10_A2: number;
  12092. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12093. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12094. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12095. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12096. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12097. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12098. 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;
  12099. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12100. readonly TRANSFORM_FEEDBACK: number;
  12101. readonly INTERLEAVED_ATTRIBS: number;
  12102. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12103. createTransformFeedback(): WebGLTransformFeedback;
  12104. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12105. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12106. beginTransformFeedback(primitiveMode: number): void;
  12107. endTransformFeedback(): void;
  12108. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12109. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12110. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12111. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12112. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12113. }
  12114. interface ImageBitmap {
  12115. readonly width: number;
  12116. readonly height: number;
  12117. close(): void;
  12118. }
  12119. interface WebGLQuery extends WebGLObject {
  12120. }
  12121. declare var WebGLQuery: {
  12122. prototype: WebGLQuery;
  12123. new (): WebGLQuery;
  12124. };
  12125. interface WebGLSampler extends WebGLObject {
  12126. }
  12127. declare var WebGLSampler: {
  12128. prototype: WebGLSampler;
  12129. new (): WebGLSampler;
  12130. };
  12131. interface WebGLSync extends WebGLObject {
  12132. }
  12133. declare var WebGLSync: {
  12134. prototype: WebGLSync;
  12135. new (): WebGLSync;
  12136. };
  12137. interface WebGLTransformFeedback extends WebGLObject {
  12138. }
  12139. declare var WebGLTransformFeedback: {
  12140. prototype: WebGLTransformFeedback;
  12141. new (): WebGLTransformFeedback;
  12142. };
  12143. interface WebGLVertexArrayObject extends WebGLObject {
  12144. }
  12145. declare var WebGLVertexArrayObject: {
  12146. prototype: WebGLVertexArrayObject;
  12147. new (): WebGLVertexArrayObject;
  12148. };
  12149. declare module BABYLON {
  12150. /**
  12151. * Gather the list of keyboard event types as constants.
  12152. */
  12153. class KeyboardEventTypes {
  12154. /**
  12155. * The keydown event is fired when a key becomes active (pressed).
  12156. */
  12157. static readonly KEYDOWN: number;
  12158. /**
  12159. * The keyup event is fired when a key has been released.
  12160. */
  12161. static readonly KEYUP: number;
  12162. }
  12163. /**
  12164. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12165. */
  12166. class KeyboardInfo {
  12167. /**
  12168. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12169. */
  12170. type: number;
  12171. /**
  12172. * Defines the related dom event
  12173. */
  12174. event: KeyboardEvent;
  12175. /**
  12176. * Instantiates a new keyboard info.
  12177. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12178. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12179. * @param event Defines the related dom event
  12180. */
  12181. constructor(
  12182. /**
  12183. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12184. */
  12185. type: number,
  12186. /**
  12187. * Defines the related dom event
  12188. */
  12189. event: KeyboardEvent);
  12190. }
  12191. /**
  12192. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12193. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12194. */
  12195. class KeyboardInfoPre extends KeyboardInfo {
  12196. /**
  12197. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12198. */
  12199. type: number;
  12200. /**
  12201. * Defines the related dom event
  12202. */
  12203. event: KeyboardEvent;
  12204. /**
  12205. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12206. */
  12207. skipOnPointerObservable: boolean;
  12208. /**
  12209. * Instantiates a new keyboard pre info.
  12210. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12211. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12212. * @param event Defines the related dom event
  12213. */
  12214. constructor(
  12215. /**
  12216. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12217. */
  12218. type: number,
  12219. /**
  12220. * Defines the related dom event
  12221. */
  12222. event: KeyboardEvent);
  12223. }
  12224. }
  12225. declare module BABYLON {
  12226. /**
  12227. * Gather the list of pointer event types as constants.
  12228. */
  12229. class PointerEventTypes {
  12230. /**
  12231. * 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.
  12232. */
  12233. static readonly POINTERDOWN: number;
  12234. /**
  12235. * The pointerup event is fired when a pointer is no longer active.
  12236. */
  12237. static readonly POINTERUP: number;
  12238. /**
  12239. * The pointermove event is fired when a pointer changes coordinates.
  12240. */
  12241. static readonly POINTERMOVE: number;
  12242. /**
  12243. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12244. */
  12245. static readonly POINTERWHEEL: number;
  12246. /**
  12247. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12248. */
  12249. static readonly POINTERPICK: number;
  12250. /**
  12251. * The pointertap event is fired when a the object has been touched and released without drag.
  12252. */
  12253. static readonly POINTERTAP: number;
  12254. /**
  12255. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12256. */
  12257. static readonly POINTERDOUBLETAP: number;
  12258. }
  12259. /**
  12260. * Base class of pointer info types.
  12261. */
  12262. class PointerInfoBase {
  12263. /**
  12264. * Defines the type of event (BABYLON.PointerEventTypes)
  12265. */
  12266. type: number;
  12267. /**
  12268. * Defines the related dom event
  12269. */
  12270. event: PointerEvent | MouseWheelEvent;
  12271. /**
  12272. * Instantiates the base class of pointers info.
  12273. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12274. * @param event Defines the related dom event
  12275. */
  12276. constructor(
  12277. /**
  12278. * Defines the type of event (BABYLON.PointerEventTypes)
  12279. */
  12280. type: number,
  12281. /**
  12282. * Defines the related dom event
  12283. */
  12284. event: PointerEvent | MouseWheelEvent);
  12285. }
  12286. /**
  12287. * This class is used to store pointer related info for the onPrePointerObservable event.
  12288. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12289. */
  12290. class PointerInfoPre extends PointerInfoBase {
  12291. /**
  12292. * Ray from a pointer if availible (eg. 6dof controller)
  12293. */
  12294. ray: Nullable<Ray>;
  12295. /**
  12296. * Defines the local position of the pointer on the canvas.
  12297. */
  12298. localPosition: Vector2;
  12299. /**
  12300. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12301. */
  12302. skipOnPointerObservable: boolean;
  12303. /**
  12304. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12305. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12306. * @param event Defines the related dom event
  12307. * @param localX Defines the local x coordinates of the pointer when the event occured
  12308. * @param localY Defines the local y coordinates of the pointer when the event occured
  12309. */
  12310. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12311. }
  12312. /**
  12313. * This type contains all the data related to a pointer event in Babylon.js.
  12314. * 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.
  12315. */
  12316. class PointerInfo extends PointerInfoBase {
  12317. /**
  12318. * Defines the picking info associated to the info (if any)\
  12319. */
  12320. pickInfo: Nullable<PickingInfo>;
  12321. /**
  12322. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12323. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12324. * @param event Defines the related dom event
  12325. * @param pickInfo Defines the picking info associated to the info (if any)\
  12326. */
  12327. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12328. /**
  12329. * Defines the picking info associated to the info (if any)\
  12330. */
  12331. pickInfo: Nullable<PickingInfo>);
  12332. }
  12333. }
  12334. declare module BABYLON {
  12335. /**
  12336. * Represents a gamepad control stick position
  12337. */
  12338. class StickValues {
  12339. /**
  12340. * The x component of the control stick
  12341. */
  12342. x: number;
  12343. /**
  12344. * The y component of the control stick
  12345. */
  12346. y: number;
  12347. /**
  12348. * Initializes the gamepad x and y control stick values
  12349. * @param x The x component of the gamepad control stick value
  12350. * @param y The y component of the gamepad control stick value
  12351. */
  12352. constructor(
  12353. /**
  12354. * The x component of the control stick
  12355. */
  12356. x: number,
  12357. /**
  12358. * The y component of the control stick
  12359. */
  12360. y: number);
  12361. }
  12362. /**
  12363. * An interface which manages callbacks for gamepad button changes
  12364. */
  12365. interface GamepadButtonChanges {
  12366. /**
  12367. * Called when a gamepad has been changed
  12368. */
  12369. changed: boolean;
  12370. /**
  12371. * Called when a gamepad press event has been triggered
  12372. */
  12373. pressChanged: boolean;
  12374. /**
  12375. * Called when a touch event has been triggered
  12376. */
  12377. touchChanged: boolean;
  12378. /**
  12379. * Called when a value has changed
  12380. */
  12381. valueChanged: boolean;
  12382. }
  12383. /**
  12384. * Represents a gamepad
  12385. */
  12386. class Gamepad {
  12387. /**
  12388. * The id of the gamepad
  12389. */
  12390. id: string;
  12391. /**
  12392. * The index of the gamepad
  12393. */
  12394. index: number;
  12395. /**
  12396. * The browser gamepad
  12397. */
  12398. browserGamepad: any;
  12399. /**
  12400. * Specifies what type of gamepad this represents
  12401. */
  12402. type: number;
  12403. private _leftStick;
  12404. private _rightStick;
  12405. /** @hidden */
  12406. _isConnected: boolean;
  12407. private _leftStickAxisX;
  12408. private _leftStickAxisY;
  12409. private _rightStickAxisX;
  12410. private _rightStickAxisY;
  12411. /**
  12412. * Triggered when the left control stick has been changed
  12413. */
  12414. private _onleftstickchanged;
  12415. /**
  12416. * Triggered when the right control stick has been changed
  12417. */
  12418. private _onrightstickchanged;
  12419. /**
  12420. * Represents a gamepad controller
  12421. */
  12422. static GAMEPAD: number;
  12423. /**
  12424. * Represents a generic controller
  12425. */
  12426. static GENERIC: number;
  12427. /**
  12428. * Represents an XBox controller
  12429. */
  12430. static XBOX: number;
  12431. /**
  12432. * Represents a pose-enabled controller
  12433. */
  12434. static POSE_ENABLED: number;
  12435. /**
  12436. * Specifies whether the left control stick should be Y-inverted
  12437. */
  12438. protected _invertLeftStickY: boolean;
  12439. /**
  12440. * Specifies if the gamepad has been connected
  12441. */
  12442. readonly isConnected: boolean;
  12443. /**
  12444. * Initializes the gamepad
  12445. * @param id The id of the gamepad
  12446. * @param index The index of the gamepad
  12447. * @param browserGamepad The browser gamepad
  12448. * @param leftStickX The x component of the left joystick
  12449. * @param leftStickY The y component of the left joystick
  12450. * @param rightStickX The x component of the right joystick
  12451. * @param rightStickY The y component of the right joystick
  12452. */
  12453. constructor(
  12454. /**
  12455. * The id of the gamepad
  12456. */
  12457. id: string,
  12458. /**
  12459. * The index of the gamepad
  12460. */
  12461. index: number,
  12462. /**
  12463. * The browser gamepad
  12464. */
  12465. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12466. /**
  12467. * Callback triggered when the left joystick has changed
  12468. * @param callback
  12469. */
  12470. onleftstickchanged(callback: (values: StickValues) => void): void;
  12471. /**
  12472. * Callback triggered when the right joystick has changed
  12473. * @param callback
  12474. */
  12475. onrightstickchanged(callback: (values: StickValues) => void): void;
  12476. /**
  12477. * Gets the left joystick
  12478. */
  12479. /**
  12480. * Sets the left joystick values
  12481. */
  12482. leftStick: StickValues;
  12483. /**
  12484. * Gets the right joystick
  12485. */
  12486. /**
  12487. * Sets the right joystick value
  12488. */
  12489. rightStick: StickValues;
  12490. /**
  12491. * Updates the gamepad joystick positions
  12492. */
  12493. update(): void;
  12494. /**
  12495. * Disposes the gamepad
  12496. */
  12497. dispose(): void;
  12498. }
  12499. /**
  12500. * Represents a generic gamepad
  12501. */
  12502. class GenericPad extends Gamepad {
  12503. private _buttons;
  12504. private _onbuttondown;
  12505. private _onbuttonup;
  12506. /**
  12507. * Observable triggered when a button has been pressed
  12508. */
  12509. onButtonDownObservable: Observable<number>;
  12510. /**
  12511. * Observable triggered when a button has been released
  12512. */
  12513. onButtonUpObservable: Observable<number>;
  12514. /**
  12515. * Callback triggered when a button has been pressed
  12516. * @param callback Called when a button has been pressed
  12517. */
  12518. onbuttondown(callback: (buttonPressed: number) => void): void;
  12519. /**
  12520. * Callback triggered when a button has been released
  12521. * @param callback Called when a button has been released
  12522. */
  12523. onbuttonup(callback: (buttonReleased: number) => void): void;
  12524. /**
  12525. * Initializes the generic gamepad
  12526. * @param id The id of the generic gamepad
  12527. * @param index The index of the generic gamepad
  12528. * @param browserGamepad The browser gamepad
  12529. */
  12530. constructor(id: string, index: number, browserGamepad: any);
  12531. private _setButtonValue;
  12532. /**
  12533. * Updates the generic gamepad
  12534. */
  12535. update(): void;
  12536. /**
  12537. * Disposes the generic gamepad
  12538. */
  12539. dispose(): void;
  12540. }
  12541. }
  12542. declare module BABYLON {
  12543. /**
  12544. * Manager for handling gamepads
  12545. */
  12546. class GamepadManager {
  12547. private _scene?;
  12548. private _babylonGamepads;
  12549. private _oneGamepadConnected;
  12550. /** @hidden */
  12551. _isMonitoring: boolean;
  12552. private _gamepadEventSupported;
  12553. private _gamepadSupport;
  12554. /**
  12555. * observable to be triggered when the gamepad controller has been connected
  12556. */
  12557. onGamepadConnectedObservable: Observable<Gamepad>;
  12558. /**
  12559. * observable to be triggered when the gamepad controller has been disconnected
  12560. */
  12561. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12562. private _onGamepadConnectedEvent;
  12563. private _onGamepadDisconnectedEvent;
  12564. /**
  12565. * Initializes the gamepad manager
  12566. * @param _scene BabylonJS scene
  12567. */
  12568. constructor(_scene?: Scene | undefined);
  12569. /**
  12570. * The gamepads in the game pad manager
  12571. */
  12572. readonly gamepads: Gamepad[];
  12573. /**
  12574. * Get the gamepad controllers based on type
  12575. * @param type The type of gamepad controller
  12576. * @returns Nullable gamepad
  12577. */
  12578. getGamepadByType(type?: number): Nullable<Gamepad>;
  12579. /**
  12580. * Disposes the gamepad manager
  12581. */
  12582. dispose(): void;
  12583. private _addNewGamepad;
  12584. private _startMonitoringGamepads;
  12585. private _stopMonitoringGamepads;
  12586. /** @hidden */
  12587. _checkGamepadsStatus(): void;
  12588. private _updateGamepadObjects;
  12589. }
  12590. }
  12591. declare module BABYLON {
  12592. interface Scene {
  12593. /** @hidden */
  12594. _gamepadManager: Nullable<GamepadManager>;
  12595. /**
  12596. * Gets the gamepad manager associated with the scene
  12597. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12598. */
  12599. gamepadManager: GamepadManager;
  12600. }
  12601. /**
  12602. * Interface representing a free camera inputs manager
  12603. */
  12604. interface FreeCameraInputsManager {
  12605. /**
  12606. * Adds gamepad input support to the FreeCameraInputsManager.
  12607. * @returns the FreeCameraInputsManager
  12608. */
  12609. addGamepad(): FreeCameraInputsManager;
  12610. }
  12611. /**
  12612. * Interface representing an arc rotate camera inputs manager
  12613. */
  12614. interface ArcRotateCameraInputsManager {
  12615. /**
  12616. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12617. * @returns the camera inputs manager
  12618. */
  12619. addGamepad(): ArcRotateCameraInputsManager;
  12620. }
  12621. /**
  12622. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12623. */
  12624. class GamepadSystemSceneComponent implements ISceneComponent {
  12625. /**
  12626. * The component name helpfull to identify the component in the list of scene components.
  12627. */
  12628. readonly name: string;
  12629. /**
  12630. * The scene the component belongs to.
  12631. */
  12632. scene: Scene;
  12633. /**
  12634. * Creates a new instance of the component for the given scene
  12635. * @param scene Defines the scene to register the component in
  12636. */
  12637. constructor(scene: Scene);
  12638. /**
  12639. * Registers the component in a given scene
  12640. */
  12641. register(): void;
  12642. /**
  12643. * Rebuilds the elements related to this component in case of
  12644. * context lost for instance.
  12645. */
  12646. rebuild(): void;
  12647. /**
  12648. * Disposes the component and the associated ressources
  12649. */
  12650. dispose(): void;
  12651. private _beforeCameraUpdate;
  12652. }
  12653. }
  12654. declare module BABYLON {
  12655. /**
  12656. * Defines supported buttons for XBox360 compatible gamepads
  12657. */
  12658. enum Xbox360Button {
  12659. /** A */
  12660. A = 0,
  12661. /** B */
  12662. B = 1,
  12663. /** X */
  12664. X = 2,
  12665. /** Y */
  12666. Y = 3,
  12667. /** Start */
  12668. Start = 4,
  12669. /** Back */
  12670. Back = 5,
  12671. /** Left button */
  12672. LB = 6,
  12673. /** Right button */
  12674. RB = 7,
  12675. /** Left stick */
  12676. LeftStick = 8,
  12677. /** Right stick */
  12678. RightStick = 9
  12679. }
  12680. /** Defines values for XBox360 DPad */
  12681. enum Xbox360Dpad {
  12682. /** Up */
  12683. Up = 0,
  12684. /** Down */
  12685. Down = 1,
  12686. /** Left */
  12687. Left = 2,
  12688. /** Right */
  12689. Right = 3
  12690. }
  12691. /**
  12692. * Defines a XBox360 gamepad
  12693. */
  12694. class Xbox360Pad extends Gamepad {
  12695. private _leftTrigger;
  12696. private _rightTrigger;
  12697. private _onlefttriggerchanged;
  12698. private _onrighttriggerchanged;
  12699. private _onbuttondown;
  12700. private _onbuttonup;
  12701. private _ondpaddown;
  12702. private _ondpadup;
  12703. /** Observable raised when a button is pressed */
  12704. onButtonDownObservable: Observable<Xbox360Button>;
  12705. /** Observable raised when a button is released */
  12706. onButtonUpObservable: Observable<Xbox360Button>;
  12707. /** Observable raised when a pad is pressed */
  12708. onPadDownObservable: Observable<Xbox360Dpad>;
  12709. /** Observable raised when a pad is released */
  12710. onPadUpObservable: Observable<Xbox360Dpad>;
  12711. private _buttonA;
  12712. private _buttonB;
  12713. private _buttonX;
  12714. private _buttonY;
  12715. private _buttonBack;
  12716. private _buttonStart;
  12717. private _buttonLB;
  12718. private _buttonRB;
  12719. private _buttonLeftStick;
  12720. private _buttonRightStick;
  12721. private _dPadUp;
  12722. private _dPadDown;
  12723. private _dPadLeft;
  12724. private _dPadRight;
  12725. private _isXboxOnePad;
  12726. /**
  12727. * Creates a new XBox360 gamepad object
  12728. * @param id defines the id of this gamepad
  12729. * @param index defines its index
  12730. * @param gamepad defines the internal HTML gamepad object
  12731. * @param xboxOne defines if it is a XBox One gamepad
  12732. */
  12733. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12734. /**
  12735. * Defines the callback to call when left trigger is pressed
  12736. * @param callback defines the callback to use
  12737. */
  12738. onlefttriggerchanged(callback: (value: number) => void): void;
  12739. /**
  12740. * Defines the callback to call when right trigger is pressed
  12741. * @param callback defines the callback to use
  12742. */
  12743. onrighttriggerchanged(callback: (value: number) => void): void;
  12744. /**
  12745. * Gets the left trigger value
  12746. */
  12747. /**
  12748. * Sets the left trigger value
  12749. */
  12750. leftTrigger: number;
  12751. /**
  12752. * Gets the right trigger value
  12753. */
  12754. /**
  12755. * Sets the right trigger value
  12756. */
  12757. rightTrigger: number;
  12758. /**
  12759. * Defines the callback to call when a button is pressed
  12760. * @param callback defines the callback to use
  12761. */
  12762. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12763. /**
  12764. * Defines the callback to call when a button is released
  12765. * @param callback defines the callback to use
  12766. */
  12767. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12768. /**
  12769. * Defines the callback to call when a pad is pressed
  12770. * @param callback defines the callback to use
  12771. */
  12772. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12773. /**
  12774. * Defines the callback to call when a pad is released
  12775. * @param callback defines the callback to use
  12776. */
  12777. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12778. private _setButtonValue;
  12779. private _setDPadValue;
  12780. /**
  12781. * Gets the value of the `A` button
  12782. */
  12783. /**
  12784. * Sets the value of the `A` button
  12785. */
  12786. buttonA: number;
  12787. /**
  12788. * Gets the value of the `B` button
  12789. */
  12790. /**
  12791. * Sets the value of the `B` button
  12792. */
  12793. buttonB: number;
  12794. /**
  12795. * Gets the value of the `X` button
  12796. */
  12797. /**
  12798. * Sets the value of the `X` button
  12799. */
  12800. buttonX: number;
  12801. /**
  12802. * Gets the value of the `Y` button
  12803. */
  12804. /**
  12805. * Sets the value of the `Y` button
  12806. */
  12807. buttonY: number;
  12808. /**
  12809. * Gets the value of the `Start` button
  12810. */
  12811. /**
  12812. * Sets the value of the `Start` button
  12813. */
  12814. buttonStart: number;
  12815. /**
  12816. * Gets the value of the `Back` button
  12817. */
  12818. /**
  12819. * Sets the value of the `Back` button
  12820. */
  12821. buttonBack: number;
  12822. /**
  12823. * Gets the value of the `Left` button
  12824. */
  12825. /**
  12826. * Sets the value of the `Left` button
  12827. */
  12828. buttonLB: number;
  12829. /**
  12830. * Gets the value of the `Right` button
  12831. */
  12832. /**
  12833. * Sets the value of the `Right` button
  12834. */
  12835. buttonRB: number;
  12836. /**
  12837. * Gets the value of the Left joystick
  12838. */
  12839. /**
  12840. * Sets the value of the Left joystick
  12841. */
  12842. buttonLeftStick: number;
  12843. /**
  12844. * Gets the value of the Right joystick
  12845. */
  12846. /**
  12847. * Sets the value of the Right joystick
  12848. */
  12849. buttonRightStick: number;
  12850. /**
  12851. * Gets the value of D-pad up
  12852. */
  12853. /**
  12854. * Sets the value of D-pad up
  12855. */
  12856. dPadUp: number;
  12857. /**
  12858. * Gets the value of D-pad down
  12859. */
  12860. /**
  12861. * Sets the value of D-pad down
  12862. */
  12863. dPadDown: number;
  12864. /**
  12865. * Gets the value of D-pad left
  12866. */
  12867. /**
  12868. * Sets the value of D-pad left
  12869. */
  12870. dPadLeft: number;
  12871. /**
  12872. * Gets the value of D-pad right
  12873. */
  12874. /**
  12875. * Sets the value of D-pad right
  12876. */
  12877. dPadRight: number;
  12878. /**
  12879. * Force the gamepad to synchronize with device values
  12880. */
  12881. update(): void;
  12882. /**
  12883. * Disposes the gamepad
  12884. */
  12885. dispose(): void;
  12886. }
  12887. }
  12888. declare module BABYLON {
  12889. /**
  12890. * Single axis drag gizmo
  12891. */
  12892. class AxisDragGizmo extends Gizmo {
  12893. /**
  12894. * Drag behavior responsible for the gizmos dragging interactions
  12895. */
  12896. dragBehavior: PointerDragBehavior;
  12897. private _pointerObserver;
  12898. /**
  12899. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12900. */
  12901. snapDistance: number;
  12902. /**
  12903. * Event that fires each time the gizmo snaps to a new location.
  12904. * * snapDistance is the the change in distance
  12905. */
  12906. onSnapObservable: Observable<{
  12907. snapDistance: number;
  12908. }>;
  12909. /**
  12910. * Creates an AxisDragGizmo
  12911. * @param gizmoLayer The utility layer the gizmo will be added to
  12912. * @param dragAxis The axis which the gizmo will be able to drag on
  12913. * @param color The color of the gizmo
  12914. */
  12915. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12916. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12917. /**
  12918. * Disposes of the gizmo
  12919. */
  12920. dispose(): void;
  12921. }
  12922. }
  12923. declare module BABYLON {
  12924. /**
  12925. * Single axis scale gizmo
  12926. */
  12927. class AxisScaleGizmo extends Gizmo {
  12928. private _coloredMaterial;
  12929. /**
  12930. * Drag behavior responsible for the gizmos dragging interactions
  12931. */
  12932. dragBehavior: PointerDragBehavior;
  12933. private _pointerObserver;
  12934. /**
  12935. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12936. */
  12937. snapDistance: number;
  12938. /**
  12939. * Event that fires each time the gizmo snaps to a new location.
  12940. * * snapDistance is the the change in distance
  12941. */
  12942. onSnapObservable: Observable<{
  12943. snapDistance: number;
  12944. }>;
  12945. /**
  12946. * If the scaling operation should be done on all axis (default: false)
  12947. */
  12948. uniformScaling: boolean;
  12949. /**
  12950. * Creates an AxisScaleGizmo
  12951. * @param gizmoLayer The utility layer the gizmo will be added to
  12952. * @param dragAxis The axis which the gizmo will be able to scale on
  12953. * @param color The color of the gizmo
  12954. */
  12955. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12956. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12957. /**
  12958. * Disposes of the gizmo
  12959. */
  12960. dispose(): void;
  12961. /**
  12962. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  12963. * @param mesh The mesh to replace the default mesh of the gizmo
  12964. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  12965. */
  12966. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  12967. }
  12968. }
  12969. declare module BABYLON {
  12970. /**
  12971. * Bounding box gizmo
  12972. */
  12973. class BoundingBoxGizmo extends Gizmo {
  12974. private _lineBoundingBox;
  12975. private _rotateSpheresParent;
  12976. private _scaleBoxesParent;
  12977. private _boundingDimensions;
  12978. private _renderObserver;
  12979. private _pointerObserver;
  12980. private _scaleDragSpeed;
  12981. private _tmpQuaternion;
  12982. private _tmpVector;
  12983. private _tmpRotationMatrix;
  12984. /**
  12985. * 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)
  12986. */
  12987. ignoreChildren: boolean;
  12988. /**
  12989. * 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)
  12990. */
  12991. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  12992. /**
  12993. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  12994. */
  12995. rotationSphereSize: number;
  12996. /**
  12997. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  12998. */
  12999. scaleBoxSize: number;
  13000. /**
  13001. * 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)
  13002. */
  13003. fixedDragMeshScreenSize: boolean;
  13004. /**
  13005. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13006. */
  13007. fixedDragMeshScreenSizeDistanceFactor: number;
  13008. /**
  13009. * Fired when a rotation sphere or scale box is dragged
  13010. */
  13011. onDragStartObservable: Observable<{}>;
  13012. /**
  13013. * Fired when a scale box is dragged
  13014. */
  13015. onScaleBoxDragObservable: Observable<{}>;
  13016. /**
  13017. * Fired when a scale box drag is ended
  13018. */
  13019. onScaleBoxDragEndObservable: Observable<{}>;
  13020. /**
  13021. * Fired when a rotation sphere is dragged
  13022. */
  13023. onRotationSphereDragObservable: Observable<{}>;
  13024. /**
  13025. * Fired when a rotation sphere drag is ended
  13026. */
  13027. onRotationSphereDragEndObservable: Observable<{}>;
  13028. /**
  13029. * 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)
  13030. */
  13031. scalePivot: Nullable<Vector3>;
  13032. private _anchorMesh;
  13033. private _existingMeshScale;
  13034. private static _PivotCached;
  13035. private static _OldPivotPoint;
  13036. private static _PivotTranslation;
  13037. private static _PivotTmpVector;
  13038. /** @hidden */
  13039. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13040. /** @hidden */
  13041. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13042. /**
  13043. * Creates an BoundingBoxGizmo
  13044. * @param gizmoLayer The utility layer the gizmo will be added to
  13045. * @param color The color of the gizmo
  13046. */
  13047. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13048. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13049. private _selectNode;
  13050. /**
  13051. * Updates the bounding box information for the Gizmo
  13052. */
  13053. updateBoundingBox(): void;
  13054. /**
  13055. * Enables rotation on the specified axis and disables rotation on the others
  13056. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13057. */
  13058. setEnabledRotationAxis(axis: string): void;
  13059. /**
  13060. * Disposes of the gizmo
  13061. */
  13062. dispose(): void;
  13063. /**
  13064. * 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)
  13065. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13066. * @returns the bounding box mesh with the passed in mesh as a child
  13067. */
  13068. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13069. /**
  13070. * CustomMeshes are not supported by this gizmo
  13071. * @param mesh The mesh to replace the default mesh of the gizmo
  13072. */
  13073. setCustomMesh(mesh: Mesh): void;
  13074. }
  13075. }
  13076. declare module BABYLON {
  13077. /**
  13078. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13079. */
  13080. class Gizmo implements IDisposable {
  13081. /** The utility layer the gizmo will be added to */
  13082. gizmoLayer: UtilityLayerRenderer;
  13083. /**
  13084. * The root mesh of the gizmo
  13085. */
  13086. protected _rootMesh: Mesh;
  13087. private _attachedMesh;
  13088. /**
  13089. * Ratio for the scale of the gizmo (Default: 1)
  13090. */
  13091. scaleRatio: number;
  13092. private _tmpMatrix;
  13093. /**
  13094. * If a custom mesh has been set (Default: false)
  13095. */
  13096. protected _customMeshSet: boolean;
  13097. /**
  13098. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13099. * * When set, interactions will be enabled
  13100. */
  13101. attachedMesh: Nullable<AbstractMesh>;
  13102. /**
  13103. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13104. * @param mesh The mesh to replace the default mesh of the gizmo
  13105. */
  13106. setCustomMesh(mesh: Mesh): void;
  13107. /**
  13108. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13109. */
  13110. updateGizmoRotationToMatchAttachedMesh: boolean;
  13111. /**
  13112. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13113. */
  13114. updateGizmoPositionToMatchAttachedMesh: boolean;
  13115. /**
  13116. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13117. */
  13118. protected _updateScale: boolean;
  13119. protected _interactionsEnabled: boolean;
  13120. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13121. private _beforeRenderObserver;
  13122. /**
  13123. * Creates a gizmo
  13124. * @param gizmoLayer The utility layer the gizmo will be added to
  13125. */
  13126. constructor(
  13127. /** The utility layer the gizmo will be added to */
  13128. gizmoLayer?: UtilityLayerRenderer);
  13129. private _tempVector;
  13130. /**
  13131. * @hidden
  13132. * Updates the gizmo to match the attached mesh's position/rotation
  13133. */
  13134. protected _update(): void;
  13135. /**
  13136. * Disposes of the gizmo
  13137. */
  13138. dispose(): void;
  13139. }
  13140. }
  13141. declare module BABYLON {
  13142. /**
  13143. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13144. */
  13145. class GizmoManager implements IDisposable {
  13146. private scene;
  13147. /**
  13148. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13149. */
  13150. gizmos: {
  13151. positionGizmo: Nullable<PositionGizmo>;
  13152. rotationGizmo: Nullable<RotationGizmo>;
  13153. scaleGizmo: Nullable<ScaleGizmo>;
  13154. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13155. };
  13156. private _gizmosEnabled;
  13157. private _pointerObserver;
  13158. private _attachedMesh;
  13159. private _boundingBoxColor;
  13160. private _defaultUtilityLayer;
  13161. private _defaultKeepDepthUtilityLayer;
  13162. /**
  13163. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13164. */
  13165. boundingBoxDragBehavior: SixDofDragBehavior;
  13166. /**
  13167. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13168. */
  13169. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13170. /**
  13171. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13172. */
  13173. usePointerToAttachGizmos: boolean;
  13174. /**
  13175. * Instatiates a gizmo manager
  13176. * @param scene the scene to overlay the gizmos on top of
  13177. */
  13178. constructor(scene: Scene);
  13179. /**
  13180. * Attaches a set of gizmos to the specified mesh
  13181. * @param mesh The mesh the gizmo's should be attached to
  13182. */
  13183. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13184. /**
  13185. * If the position gizmo is enabled
  13186. */
  13187. positionGizmoEnabled: boolean;
  13188. /**
  13189. * If the rotation gizmo is enabled
  13190. */
  13191. rotationGizmoEnabled: boolean;
  13192. /**
  13193. * If the scale gizmo is enabled
  13194. */
  13195. scaleGizmoEnabled: boolean;
  13196. /**
  13197. * If the boundingBox gizmo is enabled
  13198. */
  13199. boundingBoxGizmoEnabled: boolean;
  13200. /**
  13201. * Disposes of the gizmo manager
  13202. */
  13203. dispose(): void;
  13204. }
  13205. }
  13206. declare module BABYLON {
  13207. /**
  13208. * Single plane rotation gizmo
  13209. */
  13210. class PlaneRotationGizmo extends Gizmo {
  13211. /**
  13212. * Drag behavior responsible for the gizmos dragging interactions
  13213. */
  13214. dragBehavior: PointerDragBehavior;
  13215. private _pointerObserver;
  13216. /**
  13217. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13218. */
  13219. snapDistance: number;
  13220. /**
  13221. * Event that fires each time the gizmo snaps to a new location.
  13222. * * snapDistance is the the change in distance
  13223. */
  13224. onSnapObservable: Observable<{
  13225. snapDistance: number;
  13226. }>;
  13227. /**
  13228. * Creates a PlaneRotationGizmo
  13229. * @param gizmoLayer The utility layer the gizmo will be added to
  13230. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13231. * @param color The color of the gizmo
  13232. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13233. */
  13234. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13235. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13236. /**
  13237. * Disposes of the gizmo
  13238. */
  13239. dispose(): void;
  13240. }
  13241. }
  13242. declare module BABYLON {
  13243. /**
  13244. * Gizmo that enables dragging a mesh along 3 axis
  13245. */
  13246. class PositionGizmo extends Gizmo {
  13247. /**
  13248. * Internal gizmo used for interactions on the x axis
  13249. */
  13250. xGizmo: AxisDragGizmo;
  13251. /**
  13252. * Internal gizmo used for interactions on the y axis
  13253. */
  13254. yGizmo: AxisDragGizmo;
  13255. /**
  13256. * Internal gizmo used for interactions on the z axis
  13257. */
  13258. zGizmo: AxisDragGizmo;
  13259. /** Fires an event when any of it's sub gizmos are dragged */
  13260. onDragStartObservable: Observable<{}>;
  13261. /** Fires an event when any of it's sub gizmos are released from dragging */
  13262. onDragEndObservable: Observable<{}>;
  13263. attachedMesh: Nullable<AbstractMesh>;
  13264. /**
  13265. * Creates a PositionGizmo
  13266. * @param gizmoLayer The utility layer the gizmo will be added to
  13267. */
  13268. constructor(gizmoLayer?: UtilityLayerRenderer);
  13269. updateGizmoRotationToMatchAttachedMesh: boolean;
  13270. /**
  13271. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13272. */
  13273. snapDistance: number;
  13274. /**
  13275. * Ratio for the scale of the gizmo (Default: 1)
  13276. */
  13277. scaleRatio: number;
  13278. /**
  13279. * Disposes of the gizmo
  13280. */
  13281. dispose(): void;
  13282. /**
  13283. * CustomMeshes are not supported by this gizmo
  13284. * @param mesh The mesh to replace the default mesh of the gizmo
  13285. */
  13286. setCustomMesh(mesh: Mesh): void;
  13287. }
  13288. }
  13289. declare module BABYLON {
  13290. /**
  13291. * Gizmo that enables rotating a mesh along 3 axis
  13292. */
  13293. class RotationGizmo extends Gizmo {
  13294. /**
  13295. * Internal gizmo used for interactions on the x axis
  13296. */
  13297. xGizmo: PlaneRotationGizmo;
  13298. /**
  13299. * Internal gizmo used for interactions on the y axis
  13300. */
  13301. yGizmo: PlaneRotationGizmo;
  13302. /**
  13303. * Internal gizmo used for interactions on the z axis
  13304. */
  13305. zGizmo: PlaneRotationGizmo;
  13306. /** Fires an event when any of it's sub gizmos are dragged */
  13307. onDragStartObservable: Observable<{}>;
  13308. /** Fires an event when any of it's sub gizmos are released from dragging */
  13309. onDragEndObservable: Observable<{}>;
  13310. attachedMesh: Nullable<AbstractMesh>;
  13311. /**
  13312. * Creates a RotationGizmo
  13313. * @param gizmoLayer The utility layer the gizmo will be added to
  13314. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13315. */
  13316. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13317. updateGizmoRotationToMatchAttachedMesh: boolean;
  13318. /**
  13319. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13320. */
  13321. snapDistance: number;
  13322. /**
  13323. * Ratio for the scale of the gizmo (Default: 1)
  13324. */
  13325. scaleRatio: number;
  13326. /**
  13327. * Disposes of the gizmo
  13328. */
  13329. dispose(): void;
  13330. /**
  13331. * CustomMeshes are not supported by this gizmo
  13332. * @param mesh The mesh to replace the default mesh of the gizmo
  13333. */
  13334. setCustomMesh(mesh: Mesh): void;
  13335. }
  13336. }
  13337. declare module BABYLON {
  13338. /**
  13339. * Gizmo that enables scaling a mesh along 3 axis
  13340. */
  13341. class ScaleGizmo extends Gizmo {
  13342. /**
  13343. * Internal gizmo used for interactions on the x axis
  13344. */
  13345. xGizmo: AxisScaleGizmo;
  13346. /**
  13347. * Internal gizmo used for interactions on the y axis
  13348. */
  13349. yGizmo: AxisScaleGizmo;
  13350. /**
  13351. * Internal gizmo used for interactions on the z axis
  13352. */
  13353. zGizmo: AxisScaleGizmo;
  13354. /**
  13355. * Internal gizmo used to scale all axis equally
  13356. */
  13357. uniformScaleGizmo: AxisScaleGizmo;
  13358. /** Fires an event when any of it's sub gizmos are dragged */
  13359. onDragStartObservable: Observable<{}>;
  13360. /** Fires an event when any of it's sub gizmos are released from dragging */
  13361. onDragEndObservable: Observable<{}>;
  13362. attachedMesh: Nullable<AbstractMesh>;
  13363. /**
  13364. * Creates a ScaleGizmo
  13365. * @param gizmoLayer The utility layer the gizmo will be added to
  13366. */
  13367. constructor(gizmoLayer?: UtilityLayerRenderer);
  13368. updateGizmoRotationToMatchAttachedMesh: boolean;
  13369. /**
  13370. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13371. */
  13372. snapDistance: number;
  13373. /**
  13374. * Ratio for the scale of the gizmo (Default: 1)
  13375. */
  13376. scaleRatio: number;
  13377. /**
  13378. * Disposes of the gizmo
  13379. */
  13380. dispose(): void;
  13381. }
  13382. }
  13383. declare module BABYLON {
  13384. /**
  13385. * Represents the different options available during the creation of
  13386. * a Environment helper.
  13387. *
  13388. * This can control the default ground, skybox and image processing setup of your scene.
  13389. */
  13390. interface IEnvironmentHelperOptions {
  13391. /**
  13392. * Specifies wether or not to create a ground.
  13393. * True by default.
  13394. */
  13395. createGround: boolean;
  13396. /**
  13397. * Specifies the ground size.
  13398. * 15 by default.
  13399. */
  13400. groundSize: number;
  13401. /**
  13402. * The texture used on the ground for the main color.
  13403. * Comes from the BabylonJS CDN by default.
  13404. *
  13405. * Remarks: Can be either a texture or a url.
  13406. */
  13407. groundTexture: string | BaseTexture;
  13408. /**
  13409. * The color mixed in the ground texture by default.
  13410. * BabylonJS clearColor by default.
  13411. */
  13412. groundColor: Color3;
  13413. /**
  13414. * Specifies the ground opacity.
  13415. * 1 by default.
  13416. */
  13417. groundOpacity: number;
  13418. /**
  13419. * Enables the ground to receive shadows.
  13420. * True by default.
  13421. */
  13422. enableGroundShadow: boolean;
  13423. /**
  13424. * Helps preventing the shadow to be fully black on the ground.
  13425. * 0.5 by default.
  13426. */
  13427. groundShadowLevel: number;
  13428. /**
  13429. * Creates a mirror texture attach to the ground.
  13430. * false by default.
  13431. */
  13432. enableGroundMirror: boolean;
  13433. /**
  13434. * Specifies the ground mirror size ratio.
  13435. * 0.3 by default as the default kernel is 64.
  13436. */
  13437. groundMirrorSizeRatio: number;
  13438. /**
  13439. * Specifies the ground mirror blur kernel size.
  13440. * 64 by default.
  13441. */
  13442. groundMirrorBlurKernel: number;
  13443. /**
  13444. * Specifies the ground mirror visibility amount.
  13445. * 1 by default
  13446. */
  13447. groundMirrorAmount: number;
  13448. /**
  13449. * Specifies the ground mirror reflectance weight.
  13450. * This uses the standard weight of the background material to setup the fresnel effect
  13451. * of the mirror.
  13452. * 1 by default.
  13453. */
  13454. groundMirrorFresnelWeight: number;
  13455. /**
  13456. * Specifies the ground mirror Falloff distance.
  13457. * This can helps reducing the size of the reflection.
  13458. * 0 by Default.
  13459. */
  13460. groundMirrorFallOffDistance: number;
  13461. /**
  13462. * Specifies the ground mirror texture type.
  13463. * Unsigned Int by Default.
  13464. */
  13465. groundMirrorTextureType: number;
  13466. /**
  13467. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13468. * the shown objects.
  13469. */
  13470. groundYBias: number;
  13471. /**
  13472. * Specifies wether or not to create a skybox.
  13473. * True by default.
  13474. */
  13475. createSkybox: boolean;
  13476. /**
  13477. * Specifies the skybox size.
  13478. * 20 by default.
  13479. */
  13480. skyboxSize: number;
  13481. /**
  13482. * The texture used on the skybox for the main color.
  13483. * Comes from the BabylonJS CDN by default.
  13484. *
  13485. * Remarks: Can be either a texture or a url.
  13486. */
  13487. skyboxTexture: string | BaseTexture;
  13488. /**
  13489. * The color mixed in the skybox texture by default.
  13490. * BabylonJS clearColor by default.
  13491. */
  13492. skyboxColor: Color3;
  13493. /**
  13494. * The background rotation around the Y axis of the scene.
  13495. * This helps aligning the key lights of your scene with the background.
  13496. * 0 by default.
  13497. */
  13498. backgroundYRotation: number;
  13499. /**
  13500. * Compute automatically the size of the elements to best fit with the scene.
  13501. */
  13502. sizeAuto: boolean;
  13503. /**
  13504. * Default position of the rootMesh if autoSize is not true.
  13505. */
  13506. rootPosition: Vector3;
  13507. /**
  13508. * Sets up the image processing in the scene.
  13509. * true by default.
  13510. */
  13511. setupImageProcessing: boolean;
  13512. /**
  13513. * The texture used as your environment texture in the scene.
  13514. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13515. *
  13516. * Remarks: Can be either a texture or a url.
  13517. */
  13518. environmentTexture: string | BaseTexture;
  13519. /**
  13520. * The value of the exposure to apply to the scene.
  13521. * 0.6 by default if setupImageProcessing is true.
  13522. */
  13523. cameraExposure: number;
  13524. /**
  13525. * The value of the contrast to apply to the scene.
  13526. * 1.6 by default if setupImageProcessing is true.
  13527. */
  13528. cameraContrast: number;
  13529. /**
  13530. * Specifies wether or not tonemapping should be enabled in the scene.
  13531. * true by default if setupImageProcessing is true.
  13532. */
  13533. toneMappingEnabled: boolean;
  13534. }
  13535. /**
  13536. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13537. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13538. * It also helps with the default setup of your imageProcessing configuration.
  13539. */
  13540. class EnvironmentHelper {
  13541. /**
  13542. * Default ground texture URL.
  13543. */
  13544. private static _groundTextureCDNUrl;
  13545. /**
  13546. * Default skybox texture URL.
  13547. */
  13548. private static _skyboxTextureCDNUrl;
  13549. /**
  13550. * Default environment texture URL.
  13551. */
  13552. private static _environmentTextureCDNUrl;
  13553. /**
  13554. * Creates the default options for the helper.
  13555. */
  13556. private static _getDefaultOptions;
  13557. private _rootMesh;
  13558. /**
  13559. * Gets the root mesh created by the helper.
  13560. */
  13561. readonly rootMesh: Mesh;
  13562. private _skybox;
  13563. /**
  13564. * Gets the skybox created by the helper.
  13565. */
  13566. readonly skybox: Nullable<Mesh>;
  13567. private _skyboxTexture;
  13568. /**
  13569. * Gets the skybox texture created by the helper.
  13570. */
  13571. readonly skyboxTexture: Nullable<BaseTexture>;
  13572. private _skyboxMaterial;
  13573. /**
  13574. * Gets the skybox material created by the helper.
  13575. */
  13576. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13577. private _ground;
  13578. /**
  13579. * Gets the ground mesh created by the helper.
  13580. */
  13581. readonly ground: Nullable<Mesh>;
  13582. private _groundTexture;
  13583. /**
  13584. * Gets the ground texture created by the helper.
  13585. */
  13586. readonly groundTexture: Nullable<BaseTexture>;
  13587. private _groundMirror;
  13588. /**
  13589. * Gets the ground mirror created by the helper.
  13590. */
  13591. readonly groundMirror: Nullable<MirrorTexture>;
  13592. /**
  13593. * Gets the ground mirror render list to helps pushing the meshes
  13594. * you wish in the ground reflection.
  13595. */
  13596. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13597. private _groundMaterial;
  13598. /**
  13599. * Gets the ground material created by the helper.
  13600. */
  13601. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13602. /**
  13603. * Stores the creation options.
  13604. */
  13605. private readonly _scene;
  13606. private _options;
  13607. /**
  13608. * This observable will be notified with any error during the creation of the environment,
  13609. * mainly texture creation errors.
  13610. */
  13611. onErrorObservable: Observable<{
  13612. message?: string;
  13613. exception?: any;
  13614. }>;
  13615. /**
  13616. * constructor
  13617. * @param options
  13618. * @param scene The scene to add the material to
  13619. */
  13620. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13621. /**
  13622. * Updates the background according to the new options
  13623. * @param options
  13624. */
  13625. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13626. /**
  13627. * Sets the primary color of all the available elements.
  13628. * @param color the main color to affect to the ground and the background
  13629. */
  13630. setMainColor(color: Color3): void;
  13631. /**
  13632. * Setup the image processing according to the specified options.
  13633. */
  13634. private _setupImageProcessing;
  13635. /**
  13636. * Setup the environment texture according to the specified options.
  13637. */
  13638. private _setupEnvironmentTexture;
  13639. /**
  13640. * Setup the background according to the specified options.
  13641. */
  13642. private _setupBackground;
  13643. /**
  13644. * Get the scene sizes according to the setup.
  13645. */
  13646. private _getSceneSize;
  13647. /**
  13648. * Setup the ground according to the specified options.
  13649. */
  13650. private _setupGround;
  13651. /**
  13652. * Setup the ground material according to the specified options.
  13653. */
  13654. private _setupGroundMaterial;
  13655. /**
  13656. * Setup the ground diffuse texture according to the specified options.
  13657. */
  13658. private _setupGroundDiffuseTexture;
  13659. /**
  13660. * Setup the ground mirror texture according to the specified options.
  13661. */
  13662. private _setupGroundMirrorTexture;
  13663. /**
  13664. * Setup the ground to receive the mirror texture.
  13665. */
  13666. private _setupMirrorInGroundMaterial;
  13667. /**
  13668. * Setup the skybox according to the specified options.
  13669. */
  13670. private _setupSkybox;
  13671. /**
  13672. * Setup the skybox material according to the specified options.
  13673. */
  13674. private _setupSkyboxMaterial;
  13675. /**
  13676. * Setup the skybox reflection texture according to the specified options.
  13677. */
  13678. private _setupSkyboxReflectionTexture;
  13679. private _errorHandler;
  13680. /**
  13681. * Dispose all the elements created by the Helper.
  13682. */
  13683. dispose(): void;
  13684. }
  13685. }
  13686. declare module BABYLON {
  13687. /**
  13688. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13689. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13690. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13691. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13692. */
  13693. class PhotoDome extends TransformNode {
  13694. private _useDirectMapping;
  13695. /**
  13696. * The texture being displayed on the sphere
  13697. */
  13698. protected _photoTexture: Texture;
  13699. /**
  13700. * Gets or sets the texture being displayed on the sphere
  13701. */
  13702. photoTexture: Texture;
  13703. /**
  13704. * Observable raised when an error occured while loading the 360 image
  13705. */
  13706. onLoadErrorObservable: Observable<string>;
  13707. /**
  13708. * The skybox material
  13709. */
  13710. protected _material: BackgroundMaterial;
  13711. /**
  13712. * The surface used for the skybox
  13713. */
  13714. protected _mesh: Mesh;
  13715. /**
  13716. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13717. * Also see the options.resolution property.
  13718. */
  13719. fovMultiplier: number;
  13720. /**
  13721. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13722. * @param name Element's name, child elements will append suffixes for their own names.
  13723. * @param urlsOfPhoto defines the url of the photo to display
  13724. * @param options defines an object containing optional or exposed sub element properties
  13725. * @param onError defines a callback called when an error occured while loading the texture
  13726. */
  13727. constructor(name: string, urlOfPhoto: string, options: {
  13728. resolution?: number;
  13729. size?: number;
  13730. useDirectMapping?: boolean;
  13731. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13732. /**
  13733. * Releases resources associated with this node.
  13734. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13735. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13736. */
  13737. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13738. }
  13739. }
  13740. declare module BABYLON {
  13741. interface Scene {
  13742. /**
  13743. * Creates a default light for the scene.
  13744. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13745. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13746. */
  13747. createDefaultLight(replace?: boolean): void;
  13748. /**
  13749. * Creates a default camera for the scene.
  13750. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13751. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13752. * @param replace has default false, when true replaces the active camera in the scene
  13753. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13754. */
  13755. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13756. /**
  13757. * Creates a default camera and a default light.
  13758. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13759. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13760. * @param replace has the default false, when true replaces the active camera/light in the scene
  13761. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13762. */
  13763. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13764. /**
  13765. * Creates a new sky box
  13766. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13767. * @param environmentTexture defines the texture to use as environment texture
  13768. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13769. * @param scale defines the overall scale of the skybox
  13770. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13771. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13772. * @returns a new mesh holding the sky box
  13773. */
  13774. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13775. /**
  13776. * Creates a new environment
  13777. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13778. * @param options defines the options you can use to configure the environment
  13779. * @returns the new EnvironmentHelper
  13780. */
  13781. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13782. /**
  13783. * Creates a new VREXperienceHelper
  13784. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13785. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13786. * @returns a new VREXperienceHelper
  13787. */
  13788. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  13789. /**
  13790. * Creates a new XREXperienceHelper
  13791. * @see http://doc.babylonjs.com/how_to/webxr
  13792. * @returns a promise for a new XREXperienceHelper
  13793. */
  13794. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  13795. }
  13796. }
  13797. declare module BABYLON {
  13798. /**
  13799. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  13800. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  13801. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  13802. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13803. */
  13804. class VideoDome extends TransformNode {
  13805. private _useDirectMapping;
  13806. /**
  13807. * The video texture being displayed on the sphere
  13808. */
  13809. protected _videoTexture: VideoTexture;
  13810. /**
  13811. * Gets the video texture being displayed on the sphere
  13812. */
  13813. readonly videoTexture: VideoTexture;
  13814. /**
  13815. * The skybox material
  13816. */
  13817. protected _material: BackgroundMaterial;
  13818. /**
  13819. * The surface used for the skybox
  13820. */
  13821. protected _mesh: Mesh;
  13822. /**
  13823. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13824. * Also see the options.resolution property.
  13825. */
  13826. fovMultiplier: number;
  13827. /**
  13828. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  13829. * @param name Element's name, child elements will append suffixes for their own names.
  13830. * @param urlsOrVideo defines the url(s) or the video element to use
  13831. * @param options An object containing optional or exposed sub element properties
  13832. */
  13833. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  13834. resolution?: number;
  13835. clickToPlay?: boolean;
  13836. autoPlay?: boolean;
  13837. loop?: boolean;
  13838. size?: number;
  13839. poster?: string;
  13840. useDirectMapping?: boolean;
  13841. }, scene: Scene);
  13842. /**
  13843. * Releases resources associated with this node.
  13844. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13845. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13846. */
  13847. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13848. }
  13849. }
  13850. declare module BABYLON {
  13851. /**
  13852. * This class can be used to get instrumentation data from a Babylon engine
  13853. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13854. */
  13855. class EngineInstrumentation implements IDisposable {
  13856. /**
  13857. * Define the instrumented engine.
  13858. */
  13859. engine: Engine;
  13860. private _captureGPUFrameTime;
  13861. private _gpuFrameTimeToken;
  13862. private _gpuFrameTime;
  13863. private _captureShaderCompilationTime;
  13864. private _shaderCompilationTime;
  13865. private _onBeginFrameObserver;
  13866. private _onEndFrameObserver;
  13867. private _onBeforeShaderCompilationObserver;
  13868. private _onAfterShaderCompilationObserver;
  13869. /**
  13870. * Gets the perf counter used for GPU frame time
  13871. */
  13872. readonly gpuFrameTimeCounter: PerfCounter;
  13873. /**
  13874. * Gets the GPU frame time capture status
  13875. */
  13876. /**
  13877. * Enable or disable the GPU frame time capture
  13878. */
  13879. captureGPUFrameTime: boolean;
  13880. /**
  13881. * Gets the perf counter used for shader compilation time
  13882. */
  13883. readonly shaderCompilationTimeCounter: PerfCounter;
  13884. /**
  13885. * Gets the shader compilation time capture status
  13886. */
  13887. /**
  13888. * Enable or disable the shader compilation time capture
  13889. */
  13890. captureShaderCompilationTime: boolean;
  13891. /**
  13892. * Instantiates a new engine instrumentation.
  13893. * This class can be used to get instrumentation data from a Babylon engine
  13894. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13895. * @param engine Defines the engine to instrument
  13896. */
  13897. constructor(
  13898. /**
  13899. * Define the instrumented engine.
  13900. */
  13901. engine: Engine);
  13902. /**
  13903. * Dispose and release associated resources.
  13904. */
  13905. dispose(): void;
  13906. }
  13907. }
  13908. declare module BABYLON {
  13909. /**
  13910. * This class can be used to get instrumentation data from a Babylon engine
  13911. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13912. */
  13913. class SceneInstrumentation implements IDisposable {
  13914. /**
  13915. * Defines the scene to instrument
  13916. */
  13917. scene: Scene;
  13918. private _captureActiveMeshesEvaluationTime;
  13919. private _activeMeshesEvaluationTime;
  13920. private _captureRenderTargetsRenderTime;
  13921. private _renderTargetsRenderTime;
  13922. private _captureFrameTime;
  13923. private _frameTime;
  13924. private _captureRenderTime;
  13925. private _renderTime;
  13926. private _captureInterFrameTime;
  13927. private _interFrameTime;
  13928. private _captureParticlesRenderTime;
  13929. private _particlesRenderTime;
  13930. private _captureSpritesRenderTime;
  13931. private _spritesRenderTime;
  13932. private _capturePhysicsTime;
  13933. private _physicsTime;
  13934. private _captureAnimationsTime;
  13935. private _animationsTime;
  13936. private _captureCameraRenderTime;
  13937. private _cameraRenderTime;
  13938. private _onBeforeActiveMeshesEvaluationObserver;
  13939. private _onAfterActiveMeshesEvaluationObserver;
  13940. private _onBeforeRenderTargetsRenderObserver;
  13941. private _onAfterRenderTargetsRenderObserver;
  13942. private _onAfterRenderObserver;
  13943. private _onBeforeDrawPhaseObserver;
  13944. private _onAfterDrawPhaseObserver;
  13945. private _onBeforeAnimationsObserver;
  13946. private _onBeforeParticlesRenderingObserver;
  13947. private _onAfterParticlesRenderingObserver;
  13948. private _onBeforeSpritesRenderingObserver;
  13949. private _onAfterSpritesRenderingObserver;
  13950. private _onBeforePhysicsObserver;
  13951. private _onAfterPhysicsObserver;
  13952. private _onAfterAnimationsObserver;
  13953. private _onBeforeCameraRenderObserver;
  13954. private _onAfterCameraRenderObserver;
  13955. /**
  13956. * Gets the perf counter used for active meshes evaluation time
  13957. */
  13958. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  13959. /**
  13960. * Gets the active meshes evaluation time capture status
  13961. */
  13962. /**
  13963. * Enable or disable the active meshes evaluation time capture
  13964. */
  13965. captureActiveMeshesEvaluationTime: boolean;
  13966. /**
  13967. * Gets the perf counter used for render targets render time
  13968. */
  13969. readonly renderTargetsRenderTimeCounter: PerfCounter;
  13970. /**
  13971. * Gets the render targets render time capture status
  13972. */
  13973. /**
  13974. * Enable or disable the render targets render time capture
  13975. */
  13976. captureRenderTargetsRenderTime: boolean;
  13977. /**
  13978. * Gets the perf counter used for particles render time
  13979. */
  13980. readonly particlesRenderTimeCounter: PerfCounter;
  13981. /**
  13982. * Gets the particles render time capture status
  13983. */
  13984. /**
  13985. * Enable or disable the particles render time capture
  13986. */
  13987. captureParticlesRenderTime: boolean;
  13988. /**
  13989. * Gets the perf counter used for sprites render time
  13990. */
  13991. readonly spritesRenderTimeCounter: PerfCounter;
  13992. /**
  13993. * Gets the sprites render time capture status
  13994. */
  13995. /**
  13996. * Enable or disable the sprites render time capture
  13997. */
  13998. captureSpritesRenderTime: boolean;
  13999. /**
  14000. * Gets the perf counter used for physics time
  14001. */
  14002. readonly physicsTimeCounter: PerfCounter;
  14003. /**
  14004. * Gets the physics time capture status
  14005. */
  14006. /**
  14007. * Enable or disable the physics time capture
  14008. */
  14009. capturePhysicsTime: boolean;
  14010. /**
  14011. * Gets the perf counter used for animations time
  14012. */
  14013. readonly animationsTimeCounter: PerfCounter;
  14014. /**
  14015. * Gets the animations time capture status
  14016. */
  14017. /**
  14018. * Enable or disable the animations time capture
  14019. */
  14020. captureAnimationsTime: boolean;
  14021. /**
  14022. * Gets the perf counter used for frame time capture
  14023. */
  14024. readonly frameTimeCounter: PerfCounter;
  14025. /**
  14026. * Gets the frame time capture status
  14027. */
  14028. /**
  14029. * Enable or disable the frame time capture
  14030. */
  14031. captureFrameTime: boolean;
  14032. /**
  14033. * Gets the perf counter used for inter-frames time capture
  14034. */
  14035. readonly interFrameTimeCounter: PerfCounter;
  14036. /**
  14037. * Gets the inter-frames time capture status
  14038. */
  14039. /**
  14040. * Enable or disable the inter-frames time capture
  14041. */
  14042. captureInterFrameTime: boolean;
  14043. /**
  14044. * Gets the perf counter used for render time capture
  14045. */
  14046. readonly renderTimeCounter: PerfCounter;
  14047. /**
  14048. * Gets the render time capture status
  14049. */
  14050. /**
  14051. * Enable or disable the render time capture
  14052. */
  14053. captureRenderTime: boolean;
  14054. /**
  14055. * Gets the perf counter used for camera render time capture
  14056. */
  14057. readonly cameraRenderTimeCounter: PerfCounter;
  14058. /**
  14059. * Gets the camera render time capture status
  14060. */
  14061. /**
  14062. * Enable or disable the camera render time capture
  14063. */
  14064. captureCameraRenderTime: boolean;
  14065. /**
  14066. * Gets the perf counter used for draw calls
  14067. */
  14068. readonly drawCallsCounter: PerfCounter;
  14069. /**
  14070. * Gets the perf counter used for texture collisions
  14071. */
  14072. readonly textureCollisionsCounter: PerfCounter;
  14073. /**
  14074. * Instantiates a new scene instrumentation.
  14075. * This class can be used to get instrumentation data from a Babylon engine
  14076. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14077. * @param scene Defines the scene to instrument
  14078. */
  14079. constructor(
  14080. /**
  14081. * Defines the scene to instrument
  14082. */
  14083. scene: Scene);
  14084. /**
  14085. * Dispose and release associated resources.
  14086. */
  14087. dispose(): void;
  14088. }
  14089. }
  14090. declare module BABYLON {
  14091. /**
  14092. * @hidden
  14093. **/
  14094. class _TimeToken {
  14095. _startTimeQuery: Nullable<WebGLQuery>;
  14096. _endTimeQuery: Nullable<WebGLQuery>;
  14097. _timeElapsedQuery: Nullable<WebGLQuery>;
  14098. _timeElapsedQueryEnded: boolean;
  14099. }
  14100. }
  14101. declare module BABYLON {
  14102. /**
  14103. * Effect layer options. This helps customizing the behaviour
  14104. * of the effect layer.
  14105. */
  14106. interface IEffectLayerOptions {
  14107. /**
  14108. * Multiplication factor apply to the canvas size to compute the render target size
  14109. * used to generated the objects (the smaller the faster).
  14110. */
  14111. mainTextureRatio: number;
  14112. /**
  14113. * Enforces a fixed size texture to ensure effect stability across devices.
  14114. */
  14115. mainTextureFixedSize?: number;
  14116. /**
  14117. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14118. */
  14119. alphaBlendingMode: number;
  14120. /**
  14121. * The camera attached to the layer.
  14122. */
  14123. camera: Nullable<Camera>;
  14124. /**
  14125. * The rendering group to draw the layer in.
  14126. */
  14127. renderingGroupId: number;
  14128. }
  14129. /**
  14130. * The effect layer Helps adding post process effect blended with the main pass.
  14131. *
  14132. * This can be for instance use to generate glow or higlight effects on the scene.
  14133. *
  14134. * The effect layer class can not be used directly and is intented to inherited from to be
  14135. * customized per effects.
  14136. */
  14137. abstract class EffectLayer {
  14138. private _vertexBuffers;
  14139. private _indexBuffer;
  14140. private _cachedDefines;
  14141. private _effectLayerMapGenerationEffect;
  14142. private _effectLayerOptions;
  14143. private _mergeEffect;
  14144. protected _scene: Scene;
  14145. protected _engine: Engine;
  14146. protected _maxSize: number;
  14147. protected _mainTextureDesiredSize: ISize;
  14148. protected _mainTexture: RenderTargetTexture;
  14149. protected _shouldRender: boolean;
  14150. protected _postProcesses: PostProcess[];
  14151. protected _textures: BaseTexture[];
  14152. protected _emissiveTextureAndColor: {
  14153. texture: Nullable<BaseTexture>;
  14154. color: Color4;
  14155. };
  14156. /**
  14157. * The name of the layer
  14158. */
  14159. name: string;
  14160. /**
  14161. * The clear color of the texture used to generate the glow map.
  14162. */
  14163. neutralColor: Color4;
  14164. /**
  14165. * Specifies wether the highlight layer is enabled or not.
  14166. */
  14167. isEnabled: boolean;
  14168. /**
  14169. * Gets the camera attached to the layer.
  14170. */
  14171. readonly camera: Nullable<Camera>;
  14172. /**
  14173. * Gets the rendering group id the layer should render in.
  14174. */
  14175. readonly renderingGroupId: number;
  14176. /**
  14177. * An event triggered when the effect layer has been disposed.
  14178. */
  14179. onDisposeObservable: Observable<EffectLayer>;
  14180. /**
  14181. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14182. */
  14183. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14184. /**
  14185. * An event triggered when the generated texture is being merged in the scene.
  14186. */
  14187. onBeforeComposeObservable: Observable<EffectLayer>;
  14188. /**
  14189. * An event triggered when the generated texture has been merged in the scene.
  14190. */
  14191. onAfterComposeObservable: Observable<EffectLayer>;
  14192. /**
  14193. * An event triggered when the efffect layer changes its size.
  14194. */
  14195. onSizeChangedObservable: Observable<EffectLayer>;
  14196. /**
  14197. * Instantiates a new effect Layer and references it in the scene.
  14198. * @param name The name of the layer
  14199. * @param scene The scene to use the layer in
  14200. */
  14201. constructor(
  14202. /** The Friendly of the effect in the scene */
  14203. name: string, scene: Scene);
  14204. /**
  14205. * Get the effect name of the layer.
  14206. * @return The effect name
  14207. */
  14208. abstract getEffectName(): string;
  14209. /**
  14210. * Checks for the readiness of the element composing the layer.
  14211. * @param subMesh the mesh to check for
  14212. * @param useInstances specify wether or not to use instances to render the mesh
  14213. * @return true if ready otherwise, false
  14214. */
  14215. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14216. /**
  14217. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14218. * @returns true if the effect requires stencil during the main canvas render pass.
  14219. */
  14220. abstract needStencil(): boolean;
  14221. /**
  14222. * Create the merge effect. This is the shader use to blit the information back
  14223. * to the main canvas at the end of the scene rendering.
  14224. * @returns The effect containing the shader used to merge the effect on the main canvas
  14225. */
  14226. protected abstract _createMergeEffect(): Effect;
  14227. /**
  14228. * Creates the render target textures and post processes used in the effect layer.
  14229. */
  14230. protected abstract _createTextureAndPostProcesses(): void;
  14231. /**
  14232. * Implementation specific of rendering the generating effect on the main canvas.
  14233. * @param effect The effect used to render through
  14234. */
  14235. protected abstract _internalRender(effect: Effect): void;
  14236. /**
  14237. * Sets the required values for both the emissive texture and and the main color.
  14238. */
  14239. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14240. /**
  14241. * Free any resources and references associated to a mesh.
  14242. * Internal use
  14243. * @param mesh The mesh to free.
  14244. */
  14245. abstract _disposeMesh(mesh: Mesh): void;
  14246. /**
  14247. * Serializes this layer (Glow or Highlight for example)
  14248. * @returns a serialized layer object
  14249. */
  14250. abstract serialize?(): any;
  14251. /**
  14252. * Initializes the effect layer with the required options.
  14253. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14254. */
  14255. protected _init(options: Partial<IEffectLayerOptions>): void;
  14256. /**
  14257. * Generates the index buffer of the full screen quad blending to the main canvas.
  14258. */
  14259. private _generateIndexBuffer;
  14260. /**
  14261. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14262. */
  14263. private _genrateVertexBuffer;
  14264. /**
  14265. * Sets the main texture desired size which is the closest power of two
  14266. * of the engine canvas size.
  14267. */
  14268. private _setMainTextureSize;
  14269. /**
  14270. * Creates the main texture for the effect layer.
  14271. */
  14272. protected _createMainTexture(): void;
  14273. /**
  14274. * Checks for the readiness of the element composing the layer.
  14275. * @param subMesh the mesh to check for
  14276. * @param useInstances specify wether or not to use instances to render the mesh
  14277. * @param emissiveTexture the associated emissive texture used to generate the glow
  14278. * @return true if ready otherwise, false
  14279. */
  14280. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14281. /**
  14282. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14283. */
  14284. render(): void;
  14285. /**
  14286. * Determine if a given mesh will be used in the current effect.
  14287. * @param mesh mesh to test
  14288. * @returns true if the mesh will be used
  14289. */
  14290. hasMesh(mesh: AbstractMesh): boolean;
  14291. /**
  14292. * Returns true if the layer contains information to display, otherwise false.
  14293. * @returns true if the glow layer should be rendered
  14294. */
  14295. shouldRender(): boolean;
  14296. /**
  14297. * Returns true if the mesh should render, otherwise false.
  14298. * @param mesh The mesh to render
  14299. * @returns true if it should render otherwise false
  14300. */
  14301. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14302. /**
  14303. * Returns true if the mesh should render, otherwise false.
  14304. * @param mesh The mesh to render
  14305. * @returns true if it should render otherwise false
  14306. */
  14307. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14308. /**
  14309. * Renders the submesh passed in parameter to the generation map.
  14310. */
  14311. protected _renderSubMesh(subMesh: SubMesh): void;
  14312. /**
  14313. * Rebuild the required buffers.
  14314. * @hidden Internal use only.
  14315. */
  14316. _rebuild(): void;
  14317. /**
  14318. * Dispose only the render target textures and post process.
  14319. */
  14320. private _disposeTextureAndPostProcesses;
  14321. /**
  14322. * Dispose the highlight layer and free resources.
  14323. */
  14324. dispose(): void;
  14325. /**
  14326. * Gets the class name of the effect layer
  14327. * @returns the string with the class name of the effect layer
  14328. */
  14329. getClassName(): string;
  14330. /**
  14331. * Creates an effect layer from parsed effect layer data
  14332. * @param parsedEffectLayer defines effect layer data
  14333. * @param scene defines the current scene
  14334. * @param rootUrl defines the root URL containing the effect layer information
  14335. * @returns a parsed effect Layer
  14336. */
  14337. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14338. }
  14339. }
  14340. declare module BABYLON {
  14341. interface AbstractScene {
  14342. /**
  14343. * The list of effect layers (highlights/glow) added to the scene
  14344. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14345. * @see http://doc.babylonjs.com/how_to/glow_layer
  14346. */
  14347. effectLayers: Array<EffectLayer>;
  14348. /**
  14349. * Removes the given effect layer from this scene.
  14350. * @param toRemove defines the effect layer to remove
  14351. * @returns the index of the removed effect layer
  14352. */
  14353. removeEffectLayer(toRemove: EffectLayer): number;
  14354. /**
  14355. * Adds the given effect layer to this scene
  14356. * @param newEffectLayer defines the effect layer to add
  14357. */
  14358. addEffectLayer(newEffectLayer: EffectLayer): void;
  14359. }
  14360. /**
  14361. * Defines the layer scene component responsible to manage any effect layers
  14362. * in a given scene.
  14363. */
  14364. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14365. /**
  14366. * The component name helpfull to identify the component in the list of scene components.
  14367. */
  14368. readonly name: string;
  14369. /**
  14370. * The scene the component belongs to.
  14371. */
  14372. scene: Scene;
  14373. private _engine;
  14374. private _renderEffects;
  14375. private _needStencil;
  14376. private _previousStencilState;
  14377. /**
  14378. * Creates a new instance of the component for the given scene
  14379. * @param scene Defines the scene to register the component in
  14380. */
  14381. constructor(scene: Scene);
  14382. /**
  14383. * Registers the component in a given scene
  14384. */
  14385. register(): void;
  14386. /**
  14387. * Rebuilds the elements related to this component in case of
  14388. * context lost for instance.
  14389. */
  14390. rebuild(): void;
  14391. /**
  14392. * Serializes the component data to the specified json object
  14393. * @param serializationObject The object to serialize to
  14394. */
  14395. serialize(serializationObject: any): void;
  14396. /**
  14397. * Adds all the element from the container to the scene
  14398. * @param container the container holding the elements
  14399. */
  14400. addFromContainer(container: AbstractScene): void;
  14401. /**
  14402. * Removes all the elements in the container from the scene
  14403. * @param container contains the elements to remove
  14404. */
  14405. removeFromContainer(container: AbstractScene): void;
  14406. /**
  14407. * Disposes the component and the associated ressources.
  14408. */
  14409. dispose(): void;
  14410. private _isReadyForMesh;
  14411. private _renderMainTexture;
  14412. private _setStencil;
  14413. private _setStencilBack;
  14414. private _draw;
  14415. private _drawCamera;
  14416. private _drawRenderingGroup;
  14417. }
  14418. }
  14419. declare module BABYLON {
  14420. interface AbstractScene {
  14421. /**
  14422. * Return a the first highlight layer of the scene with a given name.
  14423. * @param name The name of the highlight layer to look for.
  14424. * @return The highlight layer if found otherwise null.
  14425. */
  14426. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14427. }
  14428. /**
  14429. * Glow layer options. This helps customizing the behaviour
  14430. * of the glow layer.
  14431. */
  14432. interface IGlowLayerOptions {
  14433. /**
  14434. * Multiplication factor apply to the canvas size to compute the render target size
  14435. * used to generated the glowing objects (the smaller the faster).
  14436. */
  14437. mainTextureRatio: number;
  14438. /**
  14439. * Enforces a fixed size texture to ensure resize independant blur.
  14440. */
  14441. mainTextureFixedSize?: number;
  14442. /**
  14443. * How big is the kernel of the blur texture.
  14444. */
  14445. blurKernelSize: number;
  14446. /**
  14447. * The camera attached to the layer.
  14448. */
  14449. camera: Nullable<Camera>;
  14450. /**
  14451. * Enable MSAA by chosing the number of samples.
  14452. */
  14453. mainTextureSamples?: number;
  14454. /**
  14455. * The rendering group to draw the layer in.
  14456. */
  14457. renderingGroupId: number;
  14458. }
  14459. /**
  14460. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14461. *
  14462. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14463. * glowy meshes to your scene.
  14464. *
  14465. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14466. */
  14467. class GlowLayer extends EffectLayer {
  14468. /**
  14469. * Effect Name of the layer.
  14470. */
  14471. static readonly EffectName: string;
  14472. /**
  14473. * The default blur kernel size used for the glow.
  14474. */
  14475. static DefaultBlurKernelSize: number;
  14476. /**
  14477. * The default texture size ratio used for the glow.
  14478. */
  14479. static DefaultTextureRatio: number;
  14480. /**
  14481. * Sets the kernel size of the blur.
  14482. */
  14483. /**
  14484. * Gets the kernel size of the blur.
  14485. */
  14486. blurKernelSize: number;
  14487. /**
  14488. * Sets the glow intensity.
  14489. */
  14490. /**
  14491. * Gets the glow intensity.
  14492. */
  14493. intensity: number;
  14494. private _options;
  14495. private _intensity;
  14496. private _horizontalBlurPostprocess1;
  14497. private _verticalBlurPostprocess1;
  14498. private _horizontalBlurPostprocess2;
  14499. private _verticalBlurPostprocess2;
  14500. private _blurTexture1;
  14501. private _blurTexture2;
  14502. private _postProcesses1;
  14503. private _postProcesses2;
  14504. private _includedOnlyMeshes;
  14505. private _excludedMeshes;
  14506. /**
  14507. * Callback used to let the user override the color selection on a per mesh basis
  14508. */
  14509. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14510. /**
  14511. * Callback used to let the user override the texture selection on a per mesh basis
  14512. */
  14513. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14514. /**
  14515. * Instantiates a new glow Layer and references it to the scene.
  14516. * @param name The name of the layer
  14517. * @param scene The scene to use the layer in
  14518. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14519. */
  14520. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14521. /**
  14522. * Get the effect name of the layer.
  14523. * @return The effect name
  14524. */
  14525. getEffectName(): string;
  14526. /**
  14527. * Create the merge effect. This is the shader use to blit the information back
  14528. * to the main canvas at the end of the scene rendering.
  14529. */
  14530. protected _createMergeEffect(): Effect;
  14531. /**
  14532. * Creates the render target textures and post processes used in the glow layer.
  14533. */
  14534. protected _createTextureAndPostProcesses(): void;
  14535. /**
  14536. * Checks for the readiness of the element composing the layer.
  14537. * @param subMesh the mesh to check for
  14538. * @param useInstances specify wether or not to use instances to render the mesh
  14539. * @param emissiveTexture the associated emissive texture used to generate the glow
  14540. * @return true if ready otherwise, false
  14541. */
  14542. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14543. /**
  14544. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14545. */
  14546. needStencil(): boolean;
  14547. /**
  14548. * Implementation specific of rendering the generating effect on the main canvas.
  14549. * @param effect The effect used to render through
  14550. */
  14551. protected _internalRender(effect: Effect): void;
  14552. /**
  14553. * Sets the required values for both the emissive texture and and the main color.
  14554. */
  14555. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14556. /**
  14557. * Returns true if the mesh should render, otherwise false.
  14558. * @param mesh The mesh to render
  14559. * @returns true if it should render otherwise false
  14560. */
  14561. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14562. /**
  14563. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14564. * @param mesh The mesh to exclude from the glow layer
  14565. */
  14566. addExcludedMesh(mesh: Mesh): void;
  14567. /**
  14568. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14569. * @param mesh The mesh to remove
  14570. */
  14571. removeExcludedMesh(mesh: Mesh): void;
  14572. /**
  14573. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14574. * @param mesh The mesh to include in the glow layer
  14575. */
  14576. addIncludedOnlyMesh(mesh: Mesh): void;
  14577. /**
  14578. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14579. * @param mesh The mesh to remove
  14580. */
  14581. removeIncludedOnlyMesh(mesh: Mesh): void;
  14582. /**
  14583. * Determine if a given mesh will be used in the glow layer
  14584. * @param mesh The mesh to test
  14585. * @returns true if the mesh will be highlighted by the current glow layer
  14586. */
  14587. hasMesh(mesh: AbstractMesh): boolean;
  14588. /**
  14589. * Free any resources and references associated to a mesh.
  14590. * Internal use
  14591. * @param mesh The mesh to free.
  14592. * @hidden
  14593. */
  14594. _disposeMesh(mesh: Mesh): void;
  14595. /**
  14596. * Gets the class name of the effect layer
  14597. * @returns the string with the class name of the effect layer
  14598. */
  14599. getClassName(): string;
  14600. /**
  14601. * Serializes this glow layer
  14602. * @returns a serialized glow layer object
  14603. */
  14604. serialize(): any;
  14605. /**
  14606. * Creates a Glow Layer from parsed glow layer data
  14607. * @param parsedGlowLayer defines glow layer data
  14608. * @param scene defines the current scene
  14609. * @param rootUrl defines the root URL containing the glow layer information
  14610. * @returns a parsed Glow Layer
  14611. */
  14612. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14613. }
  14614. }
  14615. declare module BABYLON {
  14616. interface AbstractScene {
  14617. /**
  14618. * Return a the first highlight layer of the scene with a given name.
  14619. * @param name The name of the highlight layer to look for.
  14620. * @return The highlight layer if found otherwise null.
  14621. */
  14622. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14623. }
  14624. /**
  14625. * Highlight layer options. This helps customizing the behaviour
  14626. * of the highlight layer.
  14627. */
  14628. interface IHighlightLayerOptions {
  14629. /**
  14630. * Multiplication factor apply to the canvas size to compute the render target size
  14631. * used to generated the glowing objects (the smaller the faster).
  14632. */
  14633. mainTextureRatio: number;
  14634. /**
  14635. * Enforces a fixed size texture to ensure resize independant blur.
  14636. */
  14637. mainTextureFixedSize?: number;
  14638. /**
  14639. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14640. * of the picture to blur (the smaller the faster).
  14641. */
  14642. blurTextureSizeRatio: number;
  14643. /**
  14644. * How big in texel of the blur texture is the vertical blur.
  14645. */
  14646. blurVerticalSize: number;
  14647. /**
  14648. * How big in texel of the blur texture is the horizontal blur.
  14649. */
  14650. blurHorizontalSize: number;
  14651. /**
  14652. * Alpha blending mode used to apply the blur. Default is combine.
  14653. */
  14654. alphaBlendingMode: number;
  14655. /**
  14656. * The camera attached to the layer.
  14657. */
  14658. camera: Nullable<Camera>;
  14659. /**
  14660. * Should we display highlight as a solid stroke?
  14661. */
  14662. isStroke?: boolean;
  14663. /**
  14664. * The rendering group to draw the layer in.
  14665. */
  14666. renderingGroupId: number;
  14667. }
  14668. /**
  14669. * The highlight layer Helps adding a glow effect around a mesh.
  14670. *
  14671. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14672. * glowy meshes to your scene.
  14673. *
  14674. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14675. */
  14676. class HighlightLayer extends EffectLayer {
  14677. name: string;
  14678. /**
  14679. * Effect Name of the highlight layer.
  14680. */
  14681. static readonly EffectName: string;
  14682. /**
  14683. * The neutral color used during the preparation of the glow effect.
  14684. * This is black by default as the blend operation is a blend operation.
  14685. */
  14686. static NeutralColor: Color4;
  14687. /**
  14688. * Stencil value used for glowing meshes.
  14689. */
  14690. static GlowingMeshStencilReference: number;
  14691. /**
  14692. * Stencil value used for the other meshes in the scene.
  14693. */
  14694. static NormalMeshStencilReference: number;
  14695. /**
  14696. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14697. */
  14698. innerGlow: boolean;
  14699. /**
  14700. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14701. */
  14702. outerGlow: boolean;
  14703. /**
  14704. * Specifies the horizontal size of the blur.
  14705. */
  14706. /**
  14707. * Gets the horizontal size of the blur.
  14708. */
  14709. blurHorizontalSize: number;
  14710. /**
  14711. * Specifies the vertical size of the blur.
  14712. */
  14713. /**
  14714. * Gets the vertical size of the blur.
  14715. */
  14716. blurVerticalSize: number;
  14717. /**
  14718. * An event triggered when the highlight layer is being blurred.
  14719. */
  14720. onBeforeBlurObservable: Observable<HighlightLayer>;
  14721. /**
  14722. * An event triggered when the highlight layer has been blurred.
  14723. */
  14724. onAfterBlurObservable: Observable<HighlightLayer>;
  14725. private _instanceGlowingMeshStencilReference;
  14726. private _options;
  14727. private _downSamplePostprocess;
  14728. private _horizontalBlurPostprocess;
  14729. private _verticalBlurPostprocess;
  14730. private _blurTexture;
  14731. private _meshes;
  14732. private _excludedMeshes;
  14733. /**
  14734. * Instantiates a new highlight Layer and references it to the scene..
  14735. * @param name The name of the layer
  14736. * @param scene The scene to use the layer in
  14737. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14738. */
  14739. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14740. /**
  14741. * Get the effect name of the layer.
  14742. * @return The effect name
  14743. */
  14744. getEffectName(): string;
  14745. /**
  14746. * Create the merge effect. This is the shader use to blit the information back
  14747. * to the main canvas at the end of the scene rendering.
  14748. */
  14749. protected _createMergeEffect(): Effect;
  14750. /**
  14751. * Creates the render target textures and post processes used in the highlight layer.
  14752. */
  14753. protected _createTextureAndPostProcesses(): void;
  14754. /**
  14755. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14756. */
  14757. needStencil(): boolean;
  14758. /**
  14759. * Checks for the readiness of the element composing the layer.
  14760. * @param subMesh the mesh to check for
  14761. * @param useInstances specify wether or not to use instances to render the mesh
  14762. * @param emissiveTexture the associated emissive texture used to generate the glow
  14763. * @return true if ready otherwise, false
  14764. */
  14765. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14766. /**
  14767. * Implementation specific of rendering the generating effect on the main canvas.
  14768. * @param effect The effect used to render through
  14769. */
  14770. protected _internalRender(effect: Effect): void;
  14771. /**
  14772. * Returns true if the layer contains information to display, otherwise false.
  14773. */
  14774. shouldRender(): boolean;
  14775. /**
  14776. * Returns true if the mesh should render, otherwise false.
  14777. * @param mesh The mesh to render
  14778. * @returns true if it should render otherwise false
  14779. */
  14780. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14781. /**
  14782. * Sets the required values for both the emissive texture and and the main color.
  14783. */
  14784. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14785. /**
  14786. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  14787. * @param mesh The mesh to exclude from the highlight layer
  14788. */
  14789. addExcludedMesh(mesh: Mesh): void;
  14790. /**
  14791. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  14792. * @param mesh The mesh to highlight
  14793. */
  14794. removeExcludedMesh(mesh: Mesh): void;
  14795. /**
  14796. * Determine if a given mesh will be highlighted by the current HighlightLayer
  14797. * @param mesh mesh to test
  14798. * @returns true if the mesh will be highlighted by the current HighlightLayer
  14799. */
  14800. hasMesh(mesh: AbstractMesh): boolean;
  14801. /**
  14802. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  14803. * @param mesh The mesh to highlight
  14804. * @param color The color of the highlight
  14805. * @param glowEmissiveOnly Extract the glow from the emissive texture
  14806. */
  14807. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  14808. /**
  14809. * Remove a mesh from the highlight layer in order to make it stop glowing.
  14810. * @param mesh The mesh to highlight
  14811. */
  14812. removeMesh(mesh: Mesh): void;
  14813. /**
  14814. * Force the stencil to the normal expected value for none glowing parts
  14815. */
  14816. private _defaultStencilReference;
  14817. /**
  14818. * Free any resources and references associated to a mesh.
  14819. * Internal use
  14820. * @param mesh The mesh to free.
  14821. * @hidden
  14822. */
  14823. _disposeMesh(mesh: Mesh): void;
  14824. /**
  14825. * Dispose the highlight layer and free resources.
  14826. */
  14827. dispose(): void;
  14828. /**
  14829. * Gets the class name of the effect layer
  14830. * @returns the string with the class name of the effect layer
  14831. */
  14832. getClassName(): string;
  14833. /**
  14834. * Serializes this Highlight layer
  14835. * @returns a serialized Highlight layer object
  14836. */
  14837. serialize(): any;
  14838. /**
  14839. * Creates a Highlight layer from parsed Highlight layer data
  14840. * @param parsedHightlightLayer defines the Highlight layer data
  14841. * @param scene defines the current scene
  14842. * @param rootUrl defines the root URL containing the Highlight layer information
  14843. * @returns a parsed Highlight layer
  14844. */
  14845. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  14846. }
  14847. }
  14848. declare module BABYLON {
  14849. /**
  14850. * This represents a full screen 2d layer.
  14851. * This can be usefull to display a picture in the background of your scene for instance.
  14852. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14853. */
  14854. class Layer {
  14855. /**
  14856. * Define the name of the layer.
  14857. */
  14858. name: string;
  14859. /**
  14860. * Define the texture the layer should display.
  14861. */
  14862. texture: Nullable<Texture>;
  14863. /**
  14864. * Is the layer in background or foreground.
  14865. */
  14866. isBackground: boolean;
  14867. /**
  14868. * Define the color of the layer (instead of texture).
  14869. */
  14870. color: Color4;
  14871. /**
  14872. * Define the scale of the layer in order to zoom in out of the texture.
  14873. */
  14874. scale: Vector2;
  14875. /**
  14876. * Define an offset for the layer in order to shift the texture.
  14877. */
  14878. offset: Vector2;
  14879. /**
  14880. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14881. */
  14882. alphaBlendingMode: number;
  14883. /**
  14884. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14885. * Alpha test will not mix with the background color in case of transparency.
  14886. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14887. */
  14888. alphaTest: boolean;
  14889. /**
  14890. * Define a mask to restrict the layer to only some of the scene cameras.
  14891. */
  14892. layerMask: number;
  14893. private _scene;
  14894. private _vertexBuffers;
  14895. private _indexBuffer;
  14896. private _effect;
  14897. private _alphaTestEffect;
  14898. /**
  14899. * An event triggered when the layer is disposed.
  14900. */
  14901. onDisposeObservable: Observable<Layer>;
  14902. private _onDisposeObserver;
  14903. /**
  14904. * Back compatibility with callback before the onDisposeObservable existed.
  14905. * The set callback will be triggered when the layer has been disposed.
  14906. */
  14907. onDispose: () => void;
  14908. /**
  14909. * An event triggered before rendering the scene
  14910. */
  14911. onBeforeRenderObservable: Observable<Layer>;
  14912. private _onBeforeRenderObserver;
  14913. /**
  14914. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14915. * The set callback will be triggered just before rendering the layer.
  14916. */
  14917. onBeforeRender: () => void;
  14918. /**
  14919. * An event triggered after rendering the scene
  14920. */
  14921. onAfterRenderObservable: Observable<Layer>;
  14922. private _onAfterRenderObserver;
  14923. /**
  14924. * Back compatibility with callback before the onAfterRenderObservable existed.
  14925. * The set callback will be triggered just after rendering the layer.
  14926. */
  14927. onAfterRender: () => void;
  14928. /**
  14929. * Instantiates a new layer.
  14930. * This represents a full screen 2d layer.
  14931. * This can be usefull to display a picture in the background of your scene for instance.
  14932. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14933. * @param name Define the name of the layer in the scene
  14934. * @param imgUrl Define the url of the texture to display in the layer
  14935. * @param scene Define the scene the layer belongs to
  14936. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14937. * @param color Defines a color for the layer
  14938. */
  14939. constructor(
  14940. /**
  14941. * Define the name of the layer.
  14942. */
  14943. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14944. private _createIndexBuffer;
  14945. /** @hidden */
  14946. _rebuild(): void;
  14947. /**
  14948. * Renders the layer in the scene.
  14949. */
  14950. render(): void;
  14951. /**
  14952. * Disposes and releases the associated ressources.
  14953. */
  14954. dispose(): void;
  14955. }
  14956. }
  14957. declare module BABYLON {
  14958. interface AbstractScene {
  14959. /**
  14960. * The list of layers (background and foreground) of the scene
  14961. */
  14962. layers: Array<Layer>;
  14963. }
  14964. /**
  14965. * Defines the layer scene component responsible to manage any layers
  14966. * in a given scene.
  14967. */
  14968. class LayerSceneComponent implements ISceneComponent {
  14969. /**
  14970. * The component name helpfull to identify the component in the list of scene components.
  14971. */
  14972. readonly name: string;
  14973. /**
  14974. * The scene the component belongs to.
  14975. */
  14976. scene: Scene;
  14977. private _engine;
  14978. /**
  14979. * Creates a new instance of the component for the given scene
  14980. * @param scene Defines the scene to register the component in
  14981. */
  14982. constructor(scene: Scene);
  14983. /**
  14984. * Registers the component in a given scene
  14985. */
  14986. register(): void;
  14987. /**
  14988. * Rebuilds the elements related to this component in case of
  14989. * context lost for instance.
  14990. */
  14991. rebuild(): void;
  14992. /**
  14993. * Disposes the component and the associated ressources.
  14994. */
  14995. dispose(): void;
  14996. private _draw;
  14997. private _drawBackground;
  14998. private _drawForeground;
  14999. }
  15000. }
  15001. declare module BABYLON {
  15002. /**
  15003. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15004. * It controls one of the indiviual texture used in the effect.
  15005. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15006. */
  15007. class LensFlare {
  15008. /**
  15009. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15010. */
  15011. size: number;
  15012. /**
  15013. * 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.
  15014. */
  15015. position: number;
  15016. /**
  15017. * Define the lens color.
  15018. */
  15019. color: Color3;
  15020. /**
  15021. * Define the lens texture.
  15022. */
  15023. texture: Nullable<Texture>;
  15024. /**
  15025. * Define the alpha mode to render this particular lens.
  15026. */
  15027. alphaMode: number;
  15028. private _system;
  15029. /**
  15030. * Creates a new Lens Flare.
  15031. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15032. * It controls one of the indiviual texture used in the effect.
  15033. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15034. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  15035. * @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.
  15036. * @param color Define the lens color
  15037. * @param imgUrl Define the lens texture url
  15038. * @param system Define the `lensFlareSystem` this flare is part of
  15039. * @returns The newly created Lens Flare
  15040. */
  15041. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  15042. /**
  15043. * Instantiates a new Lens Flare.
  15044. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15045. * It controls one of the indiviual texture used in the effect.
  15046. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15047. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  15048. * @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.
  15049. * @param color Define the lens color
  15050. * @param imgUrl Define the lens texture url
  15051. * @param system Define the `lensFlareSystem` this flare is part of
  15052. */
  15053. constructor(
  15054. /**
  15055. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15056. */
  15057. size: number,
  15058. /**
  15059. * 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.
  15060. */
  15061. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  15062. /**
  15063. * Dispose and release the lens flare with its associated resources.
  15064. */
  15065. dispose(): void;
  15066. }
  15067. }
  15068. declare module BABYLON {
  15069. /**
  15070. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15071. * It is usually composed of several `BABYLON.lensFlare`.
  15072. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15073. */
  15074. class LensFlareSystem {
  15075. /**
  15076. * Define the name of the lens flare system
  15077. */
  15078. name: string;
  15079. /**
  15080. * List of lens flares used in this system.
  15081. */
  15082. lensFlares: LensFlare[];
  15083. /**
  15084. * Define a limit from the border the lens flare can be visible.
  15085. */
  15086. borderLimit: number;
  15087. /**
  15088. * Define a viewport border we do not want to see the lens flare in.
  15089. */
  15090. viewportBorder: number;
  15091. /**
  15092. * Define a predicate which could limit the list of meshes able to occlude the effect.
  15093. */
  15094. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15095. /**
  15096. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  15097. */
  15098. layerMask: number;
  15099. /**
  15100. * Define the id of the lens flare system in the scene.
  15101. * (equal to name by default)
  15102. */
  15103. id: string;
  15104. private _scene;
  15105. private _emitter;
  15106. private _vertexBuffers;
  15107. private _indexBuffer;
  15108. private _effect;
  15109. private _positionX;
  15110. private _positionY;
  15111. private _isEnabled;
  15112. /**
  15113. * Instantiates a lens flare system.
  15114. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15115. * It is usually composed of several `BABYLON.lensFlare`.
  15116. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15117. * @param name Define the name of the lens flare system in the scene
  15118. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  15119. * @param scene Define the scene the lens flare system belongs to
  15120. */
  15121. constructor(
  15122. /**
  15123. * Define the name of the lens flare system
  15124. */
  15125. name: string, emitter: any, scene: Scene);
  15126. /**
  15127. * Define if the lens flare system is enabled.
  15128. */
  15129. isEnabled: boolean;
  15130. /**
  15131. * Get the scene the effects belongs to.
  15132. * @returns the scene holding the lens flare system
  15133. */
  15134. getScene(): Scene;
  15135. /**
  15136. * Get the emitter of the lens flare system.
  15137. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15138. * @returns the emitter of the lens flare system
  15139. */
  15140. getEmitter(): any;
  15141. /**
  15142. * Set the emitter of the lens flare system.
  15143. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15144. * @param newEmitter Define the new emitter of the system
  15145. */
  15146. setEmitter(newEmitter: any): void;
  15147. /**
  15148. * Get the lens flare system emitter position.
  15149. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  15150. * @returns the position
  15151. */
  15152. getEmitterPosition(): Vector3;
  15153. /**
  15154. * @hidden
  15155. */
  15156. computeEffectivePosition(globalViewport: Viewport): boolean;
  15157. /** @hidden */
  15158. _isVisible(): boolean;
  15159. /**
  15160. * @hidden
  15161. */
  15162. render(): boolean;
  15163. /**
  15164. * Dispose and release the lens flare with its associated resources.
  15165. */
  15166. dispose(): void;
  15167. /**
  15168. * Parse a lens flare system from a JSON repressentation
  15169. * @param parsedLensFlareSystem Define the JSON to parse
  15170. * @param scene Define the scene the parsed system should be instantiated in
  15171. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  15172. * @returns the parsed system
  15173. */
  15174. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15175. /**
  15176. * Serialize the current Lens Flare System into a JSON representation.
  15177. * @returns the serialized JSON
  15178. */
  15179. serialize(): any;
  15180. }
  15181. }
  15182. declare module BABYLON {
  15183. interface AbstractScene {
  15184. /**
  15185. * The list of lens flare system added to the scene
  15186. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15187. */
  15188. lensFlareSystems: Array<LensFlareSystem>;
  15189. /**
  15190. * Removes the given lens flare system from this scene.
  15191. * @param toRemove The lens flare system to remove
  15192. * @returns The index of the removed lens flare system
  15193. */
  15194. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  15195. /**
  15196. * Adds the given lens flare system to this scene
  15197. * @param newLensFlareSystem The lens flare system to add
  15198. */
  15199. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  15200. /**
  15201. * Gets a lens flare system using its name
  15202. * @param name defines the name to look for
  15203. * @returns the lens flare system or null if not found
  15204. */
  15205. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  15206. /**
  15207. * Gets a lens flare system using its id
  15208. * @param id defines the id to look for
  15209. * @returns the lens flare system or null if not found
  15210. */
  15211. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  15212. }
  15213. /**
  15214. * Defines the lens flare scene component responsible to manage any lens flares
  15215. * in a given scene.
  15216. */
  15217. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  15218. /**
  15219. * The component name helpfull to identify the component in the list of scene components.
  15220. */
  15221. readonly name: string;
  15222. /**
  15223. * The scene the component belongs to.
  15224. */
  15225. scene: Scene;
  15226. /**
  15227. * Creates a new instance of the component for the given scene
  15228. * @param scene Defines the scene to register the component in
  15229. */
  15230. constructor(scene: Scene);
  15231. /**
  15232. * Registers the component in a given scene
  15233. */
  15234. register(): void;
  15235. /**
  15236. * Rebuilds the elements related to this component in case of
  15237. * context lost for instance.
  15238. */
  15239. rebuild(): void;
  15240. /**
  15241. * Adds all the element from the container to the scene
  15242. * @param container the container holding the elements
  15243. */
  15244. addFromContainer(container: AbstractScene): void;
  15245. /**
  15246. * Removes all the elements in the container from the scene
  15247. * @param container contains the elements to remove
  15248. */
  15249. removeFromContainer(container: AbstractScene): void;
  15250. /**
  15251. * Serializes the component data to the specified json object
  15252. * @param serializationObject The object to serialize to
  15253. */
  15254. serialize(serializationObject: any): void;
  15255. /**
  15256. * Disposes the component and the associated ressources.
  15257. */
  15258. dispose(): void;
  15259. private _draw;
  15260. }
  15261. }
  15262. declare module BABYLON {
  15263. /**
  15264. * A directional light is defined by a direction (what a surprise!).
  15265. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15266. * 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.
  15267. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15268. */
  15269. class DirectionalLight extends ShadowLight {
  15270. private _shadowFrustumSize;
  15271. /**
  15272. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15273. */
  15274. /**
  15275. * Specifies a fix frustum size for the shadow generation.
  15276. */
  15277. shadowFrustumSize: number;
  15278. private _shadowOrthoScale;
  15279. /**
  15280. * Gets the shadow projection scale against the optimal computed one.
  15281. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15282. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15283. */
  15284. /**
  15285. * Sets the shadow projection scale against the optimal computed one.
  15286. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15287. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15288. */
  15289. shadowOrthoScale: number;
  15290. /**
  15291. * Automatically compute the projection matrix to best fit (including all the casters)
  15292. * on each frame.
  15293. */
  15294. autoUpdateExtends: boolean;
  15295. private _orthoLeft;
  15296. private _orthoRight;
  15297. private _orthoTop;
  15298. private _orthoBottom;
  15299. /**
  15300. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15301. * The directional light is emitted from everywhere in the given direction.
  15302. * It can cast shadows.
  15303. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15304. * @param name The friendly name of the light
  15305. * @param direction The direction of the light
  15306. * @param scene The scene the light belongs to
  15307. */
  15308. constructor(name: string, direction: Vector3, scene: Scene);
  15309. /**
  15310. * Returns the string "DirectionalLight".
  15311. * @return The class name
  15312. */
  15313. getClassName(): string;
  15314. /**
  15315. * Returns the integer 1.
  15316. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15317. */
  15318. getTypeID(): number;
  15319. /**
  15320. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15321. * Returns the DirectionalLight Shadow projection matrix.
  15322. */
  15323. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15324. /**
  15325. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15326. * Returns the DirectionalLight Shadow projection matrix.
  15327. */
  15328. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15329. /**
  15330. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15331. * Returns the DirectionalLight Shadow projection matrix.
  15332. */
  15333. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15334. protected _buildUniformLayout(): void;
  15335. /**
  15336. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15337. * @param effect The effect to update
  15338. * @param lightIndex The index of the light in the effect to update
  15339. * @returns The directional light
  15340. */
  15341. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15342. /**
  15343. * Gets the minZ used for shadow according to both the scene and the light.
  15344. *
  15345. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15346. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15347. * @param activeCamera The camera we are returning the min for
  15348. * @returns the depth min z
  15349. */
  15350. getDepthMinZ(activeCamera: Camera): number;
  15351. /**
  15352. * Gets the maxZ used for shadow according to both the scene and the light.
  15353. *
  15354. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15355. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15356. * @param activeCamera The camera we are returning the max for
  15357. * @returns the depth max z
  15358. */
  15359. getDepthMaxZ(activeCamera: Camera): number;
  15360. /**
  15361. * Prepares the list of defines specific to the light type.
  15362. * @param defines the list of defines
  15363. * @param lightIndex defines the index of the light for the effect
  15364. */
  15365. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15366. }
  15367. }
  15368. declare module BABYLON {
  15369. /**
  15370. * The HemisphericLight simulates the ambient environment light,
  15371. * so the passed direction is the light reflection direction, not the incoming direction.
  15372. */
  15373. class HemisphericLight extends Light {
  15374. /**
  15375. * The groundColor is the light in the opposite direction to the one specified during creation.
  15376. * 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.
  15377. */
  15378. groundColor: Color3;
  15379. /**
  15380. * The light reflection direction, not the incoming direction.
  15381. */
  15382. direction: Vector3;
  15383. /**
  15384. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15385. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15386. * The HemisphericLight can't cast shadows.
  15387. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15388. * @param name The friendly name of the light
  15389. * @param direction The direction of the light reflection
  15390. * @param scene The scene the light belongs to
  15391. */
  15392. constructor(name: string, direction: Vector3, scene: Scene);
  15393. protected _buildUniformLayout(): void;
  15394. /**
  15395. * Returns the string "HemisphericLight".
  15396. * @return The class name
  15397. */
  15398. getClassName(): string;
  15399. /**
  15400. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15401. * Returns the updated direction.
  15402. * @param target The target the direction should point to
  15403. * @return The computed direction
  15404. */
  15405. setDirectionToTarget(target: Vector3): Vector3;
  15406. /**
  15407. * Returns the shadow generator associated to the light.
  15408. * @returns Always null for hemispheric lights because it does not support shadows.
  15409. */
  15410. getShadowGenerator(): Nullable<IShadowGenerator>;
  15411. /**
  15412. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15413. * @param effect The effect to update
  15414. * @param lightIndex The index of the light in the effect to update
  15415. * @returns The hemispheric light
  15416. */
  15417. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15418. /**
  15419. * Computes the world matrix of the node
  15420. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15421. * @param useWasUpdatedFlag defines a reserved property
  15422. * @returns the world matrix
  15423. */
  15424. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15425. /**
  15426. * Returns the integer 3.
  15427. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15428. */
  15429. getTypeID(): number;
  15430. /**
  15431. * Prepares the list of defines specific to the light type.
  15432. * @param defines the list of defines
  15433. * @param lightIndex defines the index of the light for the effect
  15434. */
  15435. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15436. }
  15437. }
  15438. declare module BABYLON {
  15439. /**
  15440. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15441. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15442. * 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.
  15443. */
  15444. abstract class Light extends Node {
  15445. /**
  15446. * Falloff Default: light is falling off following the material specification:
  15447. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15448. */
  15449. static readonly FALLOFF_DEFAULT: number;
  15450. /**
  15451. * Falloff Physical: light is falling off following the inverse squared distance law.
  15452. */
  15453. static readonly FALLOFF_PHYSICAL: number;
  15454. /**
  15455. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15456. * to enhance interoperability with other engines.
  15457. */
  15458. static readonly FALLOFF_GLTF: number;
  15459. /**
  15460. * Falloff Standard: light is falling off like in the standard material
  15461. * to enhance interoperability with other materials.
  15462. */
  15463. static readonly FALLOFF_STANDARD: number;
  15464. /**
  15465. * If every light affecting the material is in this lightmapMode,
  15466. * material.lightmapTexture adds or multiplies
  15467. * (depends on material.useLightmapAsShadowmap)
  15468. * after every other light calculations.
  15469. */
  15470. static readonly LIGHTMAP_DEFAULT: number;
  15471. /**
  15472. * material.lightmapTexture as only diffuse lighting from this light
  15473. * adds only specular lighting from this light
  15474. * adds dynamic shadows
  15475. */
  15476. static readonly LIGHTMAP_SPECULAR: number;
  15477. /**
  15478. * material.lightmapTexture as only lighting
  15479. * no light calculation from this light
  15480. * only adds dynamic shadows from this light
  15481. */
  15482. static readonly LIGHTMAP_SHADOWSONLY: number;
  15483. /**
  15484. * Each light type uses the default quantity according to its type:
  15485. * point/spot lights use luminous intensity
  15486. * directional lights use illuminance
  15487. */
  15488. static readonly INTENSITYMODE_AUTOMATIC: number;
  15489. /**
  15490. * lumen (lm)
  15491. */
  15492. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15493. /**
  15494. * candela (lm/sr)
  15495. */
  15496. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15497. /**
  15498. * lux (lm/m^2)
  15499. */
  15500. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15501. /**
  15502. * nit (cd/m^2)
  15503. */
  15504. static readonly INTENSITYMODE_LUMINANCE: number;
  15505. /**
  15506. * Light type const id of the point light.
  15507. */
  15508. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15509. /**
  15510. * Light type const id of the directional light.
  15511. */
  15512. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15513. /**
  15514. * Light type const id of the spot light.
  15515. */
  15516. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15517. /**
  15518. * Light type const id of the hemispheric light.
  15519. */
  15520. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15521. /**
  15522. * Diffuse gives the basic color to an object.
  15523. */
  15524. diffuse: Color3;
  15525. /**
  15526. * Specular produces a highlight color on an object.
  15527. * Note: This is note affecting PBR materials.
  15528. */
  15529. specular: Color3;
  15530. /**
  15531. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15532. * falling off base on range or angle.
  15533. * This can be set to any values in Light.FALLOFF_x.
  15534. *
  15535. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  15536. * other types of materials.
  15537. */
  15538. falloffType: number;
  15539. /**
  15540. * Strength of the light.
  15541. * Note: By default it is define in the framework own unit.
  15542. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15543. */
  15544. intensity: number;
  15545. private _range;
  15546. protected _inverseSquaredRange: number;
  15547. /**
  15548. * Defines how far from the source the light is impacting in scene units.
  15549. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15550. */
  15551. /**
  15552. * Defines how far from the source the light is impacting in scene units.
  15553. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15554. */
  15555. range: number;
  15556. /**
  15557. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15558. * of light.
  15559. */
  15560. private _photometricScale;
  15561. private _intensityMode;
  15562. /**
  15563. * Gets the photometric scale used to interpret the intensity.
  15564. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15565. */
  15566. /**
  15567. * Sets the photometric scale used to interpret the intensity.
  15568. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15569. */
  15570. intensityMode: number;
  15571. private _radius;
  15572. /**
  15573. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15574. */
  15575. /**
  15576. * sets the light radius used by PBR Materials to simulate soft area lights.
  15577. */
  15578. radius: number;
  15579. private _renderPriority;
  15580. /**
  15581. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15582. * exceeding the number allowed of the materials.
  15583. */
  15584. renderPriority: number;
  15585. private _shadowEnabled;
  15586. /**
  15587. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15588. * the current shadow generator.
  15589. */
  15590. /**
  15591. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15592. * the current shadow generator.
  15593. */
  15594. shadowEnabled: boolean;
  15595. private _includedOnlyMeshes;
  15596. /**
  15597. * Gets the only meshes impacted by this light.
  15598. */
  15599. /**
  15600. * Sets the only meshes impacted by this light.
  15601. */
  15602. includedOnlyMeshes: AbstractMesh[];
  15603. private _excludedMeshes;
  15604. /**
  15605. * Gets the meshes not impacted by this light.
  15606. */
  15607. /**
  15608. * Sets the meshes not impacted by this light.
  15609. */
  15610. excludedMeshes: AbstractMesh[];
  15611. private _excludeWithLayerMask;
  15612. /**
  15613. * Gets the layer id use to find what meshes are not impacted by the light.
  15614. * Inactive if 0
  15615. */
  15616. /**
  15617. * Sets the layer id use to find what meshes are not impacted by the light.
  15618. * Inactive if 0
  15619. */
  15620. excludeWithLayerMask: number;
  15621. private _includeOnlyWithLayerMask;
  15622. /**
  15623. * Gets the layer id use to find what meshes are impacted by the light.
  15624. * Inactive if 0
  15625. */
  15626. /**
  15627. * Sets the layer id use to find what meshes are impacted by the light.
  15628. * Inactive if 0
  15629. */
  15630. includeOnlyWithLayerMask: number;
  15631. private _lightmapMode;
  15632. /**
  15633. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15634. */
  15635. /**
  15636. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15637. */
  15638. lightmapMode: number;
  15639. /**
  15640. * Shadow generator associted to the light.
  15641. * @hidden Internal use only.
  15642. */
  15643. _shadowGenerator: Nullable<IShadowGenerator>;
  15644. /**
  15645. * @hidden Internal use only.
  15646. */
  15647. _excludedMeshesIds: string[];
  15648. /**
  15649. * @hidden Internal use only.
  15650. */
  15651. _includedOnlyMeshesIds: string[];
  15652. /**
  15653. * The current light unifom buffer.
  15654. * @hidden Internal use only.
  15655. */
  15656. _uniformBuffer: UniformBuffer;
  15657. /**
  15658. * Creates a Light object in the scene.
  15659. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15660. * @param name The firendly name of the light
  15661. * @param scene The scene the light belongs too
  15662. */
  15663. constructor(name: string, scene: Scene);
  15664. protected abstract _buildUniformLayout(): void;
  15665. /**
  15666. * Sets the passed Effect "effect" with the Light information.
  15667. * @param effect The effect to update
  15668. * @param lightIndex The index of the light in the effect to update
  15669. * @returns The light
  15670. */
  15671. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15672. /**
  15673. * Returns the string "Light".
  15674. * @returns the class name
  15675. */
  15676. getClassName(): string;
  15677. /**
  15678. * Converts the light information to a readable string for debug purpose.
  15679. * @param fullDetails Supports for multiple levels of logging within scene loading
  15680. * @returns the human readable light info
  15681. */
  15682. toString(fullDetails?: boolean): string;
  15683. /** @hidden */
  15684. protected _syncParentEnabledState(): void;
  15685. /**
  15686. * Set the enabled state of this node.
  15687. * @param value - the new enabled state
  15688. */
  15689. setEnabled(value: boolean): void;
  15690. /**
  15691. * Returns the Light associated shadow generator if any.
  15692. * @return the associated shadow generator.
  15693. */
  15694. getShadowGenerator(): Nullable<IShadowGenerator>;
  15695. /**
  15696. * Returns a Vector3, the absolute light position in the World.
  15697. * @returns the world space position of the light
  15698. */
  15699. getAbsolutePosition(): Vector3;
  15700. /**
  15701. * Specifies if the light will affect the passed mesh.
  15702. * @param mesh The mesh to test against the light
  15703. * @return true the mesh is affected otherwise, false.
  15704. */
  15705. canAffectMesh(mesh: AbstractMesh): boolean;
  15706. /**
  15707. * Sort function to order lights for rendering.
  15708. * @param a First Light object to compare to second.
  15709. * @param b Second Light object to compare first.
  15710. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15711. */
  15712. static CompareLightsPriority(a: Light, b: Light): number;
  15713. /**
  15714. * Releases resources associated with this node.
  15715. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15716. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15717. */
  15718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15719. /**
  15720. * Returns the light type ID (integer).
  15721. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15722. */
  15723. getTypeID(): number;
  15724. /**
  15725. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15726. * @returns the scaled intensity in intensity mode unit
  15727. */
  15728. getScaledIntensity(): number;
  15729. /**
  15730. * Returns a new Light object, named "name", from the current one.
  15731. * @param name The name of the cloned light
  15732. * @returns the new created light
  15733. */
  15734. clone(name: string): Nullable<Light>;
  15735. /**
  15736. * Serializes the current light into a Serialization object.
  15737. * @returns the serialized object.
  15738. */
  15739. serialize(): any;
  15740. /**
  15741. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15742. * This new light is named "name" and added to the passed scene.
  15743. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15744. * @param name The friendly name of the light
  15745. * @param scene The scene the new light will belong to
  15746. * @returns the constructor function
  15747. */
  15748. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15749. /**
  15750. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15751. * @param parsedLight The JSON representation of the light
  15752. * @param scene The scene to create the parsed light in
  15753. * @returns the created light after parsing
  15754. */
  15755. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15756. private _hookArrayForExcluded;
  15757. private _hookArrayForIncludedOnly;
  15758. private _resyncMeshes;
  15759. /**
  15760. * Forces the meshes to update their light related information in their rendering used effects
  15761. * @hidden Internal Use Only
  15762. */
  15763. _markMeshesAsLightDirty(): void;
  15764. /**
  15765. * Recomputes the cached photometric scale if needed.
  15766. */
  15767. private _computePhotometricScale;
  15768. /**
  15769. * Returns the Photometric Scale according to the light type and intensity mode.
  15770. */
  15771. private _getPhotometricScale;
  15772. /**
  15773. * Reorder the light in the scene according to their defined priority.
  15774. * @hidden Internal Use Only
  15775. */
  15776. _reorderLightsInScene(): void;
  15777. /**
  15778. * Prepares the list of defines specific to the light type.
  15779. * @param defines the list of defines
  15780. * @param lightIndex defines the index of the light for the effect
  15781. */
  15782. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15783. }
  15784. }
  15785. declare module BABYLON {
  15786. /**
  15787. * A point light is a light defined by an unique point in world space.
  15788. * The light is emitted in every direction from this point.
  15789. * A good example of a point light is a standard light bulb.
  15790. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15791. */
  15792. class PointLight extends ShadowLight {
  15793. private _shadowAngle;
  15794. /**
  15795. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15796. * This specifies what angle the shadow will use to be created.
  15797. *
  15798. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15799. */
  15800. /**
  15801. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15802. * This specifies what angle the shadow will use to be created.
  15803. *
  15804. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15805. */
  15806. shadowAngle: number;
  15807. /**
  15808. * Gets the direction if it has been set.
  15809. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15810. */
  15811. /**
  15812. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15813. */
  15814. direction: Vector3;
  15815. /**
  15816. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  15817. * A PointLight emits the light in every direction.
  15818. * It can cast shadows.
  15819. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  15820. * ```javascript
  15821. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  15822. * ```
  15823. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15824. * @param name The light friendly name
  15825. * @param position The position of the point light in the scene
  15826. * @param scene The scene the lights belongs to
  15827. */
  15828. constructor(name: string, position: Vector3, scene: Scene);
  15829. /**
  15830. * Returns the string "PointLight"
  15831. * @returns the class name
  15832. */
  15833. getClassName(): string;
  15834. /**
  15835. * Returns the integer 0.
  15836. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15837. */
  15838. getTypeID(): number;
  15839. /**
  15840. * Specifies wether or not the shadowmap should be a cube texture.
  15841. * @returns true if the shadowmap needs to be a cube texture.
  15842. */
  15843. needCube(): boolean;
  15844. /**
  15845. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  15846. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15847. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15848. */
  15849. getShadowDirection(faceIndex?: number): Vector3;
  15850. /**
  15851. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  15852. * - fov = PI / 2
  15853. * - aspect ratio : 1.0
  15854. * - z-near and far equal to the active camera minZ and maxZ.
  15855. * Returns the PointLight.
  15856. */
  15857. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15858. protected _buildUniformLayout(): void;
  15859. /**
  15860. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  15861. * @param effect The effect to update
  15862. * @param lightIndex The index of the light in the effect to update
  15863. * @returns The point light
  15864. */
  15865. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  15866. /**
  15867. * Prepares the list of defines specific to the light type.
  15868. * @param defines the list of defines
  15869. * @param lightIndex defines the index of the light for the effect
  15870. */
  15871. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15872. }
  15873. }
  15874. declare module BABYLON {
  15875. /**
  15876. * Interface describing all the common properties and methods a shadow light needs to implement.
  15877. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  15878. * as well as binding the different shadow properties to the effects.
  15879. */
  15880. interface IShadowLight extends Light {
  15881. /**
  15882. * The light id in the scene (used in scene.findLighById for instance)
  15883. */
  15884. id: string;
  15885. /**
  15886. * The position the shdow will be casted from.
  15887. */
  15888. position: Vector3;
  15889. /**
  15890. * In 2d mode (needCube being false), the direction used to cast the shadow.
  15891. */
  15892. direction: Vector3;
  15893. /**
  15894. * The transformed position. Position of the light in world space taking parenting in account.
  15895. */
  15896. transformedPosition: Vector3;
  15897. /**
  15898. * The transformed direction. Direction of the light in world space taking parenting in account.
  15899. */
  15900. transformedDirection: Vector3;
  15901. /**
  15902. * The friendly name of the light in the scene.
  15903. */
  15904. name: string;
  15905. /**
  15906. * Defines the shadow projection clipping minimum z value.
  15907. */
  15908. shadowMinZ: number;
  15909. /**
  15910. * Defines the shadow projection clipping maximum z value.
  15911. */
  15912. shadowMaxZ: number;
  15913. /**
  15914. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15915. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15916. */
  15917. computeTransformedInformation(): boolean;
  15918. /**
  15919. * Gets the scene the light belongs to.
  15920. * @returns The scene
  15921. */
  15922. getScene(): Scene;
  15923. /**
  15924. * Callback defining a custom Projection Matrix Builder.
  15925. * This can be used to override the default projection matrix computation.
  15926. */
  15927. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15928. /**
  15929. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15930. * @param matrix The materix to updated with the projection information
  15931. * @param viewMatrix The transform matrix of the light
  15932. * @param renderList The list of mesh to render in the map
  15933. * @returns The current light
  15934. */
  15935. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15936. /**
  15937. * Gets the current depth scale used in ESM.
  15938. * @returns The scale
  15939. */
  15940. getDepthScale(): number;
  15941. /**
  15942. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15943. * @returns true if a cube texture needs to be use
  15944. */
  15945. needCube(): boolean;
  15946. /**
  15947. * Detects if the projection matrix requires to be recomputed this frame.
  15948. * @returns true if it requires to be recomputed otherwise, false.
  15949. */
  15950. needProjectionMatrixCompute(): boolean;
  15951. /**
  15952. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15953. */
  15954. forceProjectionMatrixCompute(): void;
  15955. /**
  15956. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15957. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15958. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15959. */
  15960. getShadowDirection(faceIndex?: number): Vector3;
  15961. /**
  15962. * Gets the minZ used for shadow according to both the scene and the light.
  15963. * @param activeCamera The camera we are returning the min for
  15964. * @returns the depth min z
  15965. */
  15966. getDepthMinZ(activeCamera: Camera): number;
  15967. /**
  15968. * Gets the maxZ used for shadow according to both the scene and the light.
  15969. * @param activeCamera The camera we are returning the max for
  15970. * @returns the depth max z
  15971. */
  15972. getDepthMaxZ(activeCamera: Camera): number;
  15973. }
  15974. /**
  15975. * Base implementation IShadowLight
  15976. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  15977. */
  15978. abstract class ShadowLight extends Light implements IShadowLight {
  15979. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15980. protected _position: Vector3;
  15981. protected _setPosition(value: Vector3): void;
  15982. /**
  15983. * Sets the position the shadow will be casted from. Also use as the light position for both
  15984. * point and spot lights.
  15985. */
  15986. /**
  15987. * Sets the position the shadow will be casted from. Also use as the light position for both
  15988. * point and spot lights.
  15989. */
  15990. position: Vector3;
  15991. protected _direction: Vector3;
  15992. protected _setDirection(value: Vector3): void;
  15993. /**
  15994. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  15995. * Also use as the light direction on spot and directional lights.
  15996. */
  15997. /**
  15998. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  15999. * Also use as the light direction on spot and directional lights.
  16000. */
  16001. direction: Vector3;
  16002. private _shadowMinZ;
  16003. /**
  16004. * Gets the shadow projection clipping minimum z value.
  16005. */
  16006. /**
  16007. * Sets the shadow projection clipping minimum z value.
  16008. */
  16009. shadowMinZ: number;
  16010. private _shadowMaxZ;
  16011. /**
  16012. * Sets the shadow projection clipping maximum z value.
  16013. */
  16014. /**
  16015. * Gets the shadow projection clipping maximum z value.
  16016. */
  16017. shadowMaxZ: number;
  16018. /**
  16019. * Callback defining a custom Projection Matrix Builder.
  16020. * This can be used to override the default projection matrix computation.
  16021. */
  16022. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16023. /**
  16024. * The transformed position. Position of the light in world space taking parenting in account.
  16025. */
  16026. transformedPosition: Vector3;
  16027. /**
  16028. * The transformed direction. Direction of the light in world space taking parenting in account.
  16029. */
  16030. transformedDirection: Vector3;
  16031. private _needProjectionMatrixCompute;
  16032. /**
  16033. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16034. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16035. */
  16036. computeTransformedInformation(): boolean;
  16037. /**
  16038. * Return the depth scale used for the shadow map.
  16039. * @returns the depth scale.
  16040. */
  16041. getDepthScale(): number;
  16042. /**
  16043. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16044. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16045. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16046. */
  16047. getShadowDirection(faceIndex?: number): Vector3;
  16048. /**
  16049. * Returns the ShadowLight absolute position in the World.
  16050. * @returns the position vector in world space
  16051. */
  16052. getAbsolutePosition(): Vector3;
  16053. /**
  16054. * Sets the ShadowLight direction toward the passed target.
  16055. * @param target The point tot target in local space
  16056. * @returns the updated ShadowLight direction
  16057. */
  16058. setDirectionToTarget(target: Vector3): Vector3;
  16059. /**
  16060. * Returns the light rotation in euler definition.
  16061. * @returns the x y z rotation in local space.
  16062. */
  16063. getRotation(): Vector3;
  16064. /**
  16065. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16066. * @returns true if a cube texture needs to be use
  16067. */
  16068. needCube(): boolean;
  16069. /**
  16070. * Detects if the projection matrix requires to be recomputed this frame.
  16071. * @returns true if it requires to be recomputed otherwise, false.
  16072. */
  16073. needProjectionMatrixCompute(): boolean;
  16074. /**
  16075. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16076. */
  16077. forceProjectionMatrixCompute(): void;
  16078. /** @hidden */
  16079. _initCache(): void;
  16080. /** @hidden */
  16081. _isSynchronized(): boolean;
  16082. /**
  16083. * Computes the world matrix of the node
  16084. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16085. * @returns the world matrix
  16086. */
  16087. computeWorldMatrix(force?: boolean): Matrix;
  16088. /**
  16089. * Gets the minZ used for shadow according to both the scene and the light.
  16090. * @param activeCamera The camera we are returning the min for
  16091. * @returns the depth min z
  16092. */
  16093. getDepthMinZ(activeCamera: Camera): number;
  16094. /**
  16095. * Gets the maxZ used for shadow according to both the scene and the light.
  16096. * @param activeCamera The camera we are returning the max for
  16097. * @returns the depth max z
  16098. */
  16099. getDepthMaxZ(activeCamera: Camera): number;
  16100. /**
  16101. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16102. * @param matrix The materix to updated with the projection information
  16103. * @param viewMatrix The transform matrix of the light
  16104. * @param renderList The list of mesh to render in the map
  16105. * @returns The current light
  16106. */
  16107. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16108. }
  16109. }
  16110. declare module BABYLON {
  16111. /**
  16112. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16113. * These values define a cone of light starting from the position, emitting toward the direction.
  16114. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16115. * and the exponent defines the speed of the decay of the light with distance (reach).
  16116. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16117. */
  16118. class SpotLight extends ShadowLight {
  16119. private _angle;
  16120. private _innerAngle;
  16121. private _cosHalfAngle;
  16122. private _lightAngleScale;
  16123. private _lightAngleOffset;
  16124. /**
  16125. * Gets the cone angle of the spot light in Radians.
  16126. */
  16127. /**
  16128. * Sets the cone angle of the spot light in Radians.
  16129. */
  16130. angle: number;
  16131. /**
  16132. * Only used in gltf falloff mode, this defines the angle where
  16133. * the directional falloff will start before cutting at angle which could be seen
  16134. * as outer angle.
  16135. */
  16136. /**
  16137. * Only used in gltf falloff mode, this defines the angle where
  16138. * the directional falloff will start before cutting at angle which could be seen
  16139. * as outer angle.
  16140. */
  16141. innerAngle: number;
  16142. private _shadowAngleScale;
  16143. /**
  16144. * Allows scaling the angle of the light for shadow generation only.
  16145. */
  16146. /**
  16147. * Allows scaling the angle of the light for shadow generation only.
  16148. */
  16149. shadowAngleScale: number;
  16150. /**
  16151. * The light decay speed with the distance from the emission spot.
  16152. */
  16153. exponent: number;
  16154. private _projectionTextureMatrix;
  16155. /**
  16156. * Allows reading the projecton texture
  16157. */
  16158. readonly projectionTextureMatrix: Matrix;
  16159. protected _projectionTextureLightNear: number;
  16160. /**
  16161. * Gets the near clip of the Spotlight for texture projection.
  16162. */
  16163. /**
  16164. * Sets the near clip of the Spotlight for texture projection.
  16165. */
  16166. projectionTextureLightNear: number;
  16167. protected _projectionTextureLightFar: number;
  16168. /**
  16169. * Gets the far clip of the Spotlight for texture projection.
  16170. */
  16171. /**
  16172. * Sets the far clip of the Spotlight for texture projection.
  16173. */
  16174. projectionTextureLightFar: number;
  16175. protected _projectionTextureUpDirection: Vector3;
  16176. /**
  16177. * Gets the Up vector of the Spotlight for texture projection.
  16178. */
  16179. /**
  16180. * Sets the Up vector of the Spotlight for texture projection.
  16181. */
  16182. projectionTextureUpDirection: Vector3;
  16183. private _projectionTexture;
  16184. /**
  16185. * Gets the projection texture of the light.
  16186. */
  16187. /**
  16188. * Sets the projection texture of the light.
  16189. */
  16190. projectionTexture: Nullable<BaseTexture>;
  16191. private _projectionTextureViewLightDirty;
  16192. private _projectionTextureProjectionLightDirty;
  16193. private _projectionTextureDirty;
  16194. private _projectionTextureViewTargetVector;
  16195. private _projectionTextureViewLightMatrix;
  16196. private _projectionTextureProjectionLightMatrix;
  16197. private _projectionTextureScalingMatrix;
  16198. /**
  16199. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16200. * It can cast shadows.
  16201. * Documentation : http://doc.babylonjs.com/tutorials/lights
  16202. * @param name The light friendly name
  16203. * @param position The position of the spot light in the scene
  16204. * @param direction The direction of the light in the scene
  16205. * @param angle The cone angle of the light in Radians
  16206. * @param exponent The light decay speed with the distance from the emission spot
  16207. * @param scene The scene the lights belongs to
  16208. */
  16209. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16210. /**
  16211. * Returns the string "SpotLight".
  16212. * @returns the class name
  16213. */
  16214. getClassName(): string;
  16215. /**
  16216. * Returns the integer 2.
  16217. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16218. */
  16219. getTypeID(): number;
  16220. /**
  16221. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16222. */
  16223. protected _setDirection(value: Vector3): void;
  16224. /**
  16225. * Overrides the position setter to recompute the projection texture view light Matrix.
  16226. */
  16227. protected _setPosition(value: Vector3): void;
  16228. /**
  16229. * 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.
  16230. * Returns the SpotLight.
  16231. */
  16232. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16233. protected _computeProjectionTextureViewLightMatrix(): void;
  16234. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16235. /**
  16236. * Main function for light texture projection matrix computing.
  16237. */
  16238. protected _computeProjectionTextureMatrix(): void;
  16239. protected _buildUniformLayout(): void;
  16240. private _computeAngleValues;
  16241. /**
  16242. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16243. * @param effect The effect to update
  16244. * @param lightIndex The index of the light in the effect to update
  16245. * @returns The spot light
  16246. */
  16247. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16248. /**
  16249. * Disposes the light and the associated resources.
  16250. */
  16251. dispose(): void;
  16252. /**
  16253. * Prepares the list of defines specific to the light type.
  16254. * @param defines the list of defines
  16255. * @param lightIndex defines the index of the light for the effect
  16256. */
  16257. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16258. }
  16259. }
  16260. declare module BABYLON {
  16261. /**
  16262. * Interface used to present a loading screen while loading a scene
  16263. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16264. */
  16265. interface ILoadingScreen {
  16266. /**
  16267. * Function called to display the loading screen
  16268. */
  16269. displayLoadingUI: () => void;
  16270. /**
  16271. * Function called to hide the loading screen
  16272. */
  16273. hideLoadingUI: () => void;
  16274. /**
  16275. * Gets or sets the color to use for the background
  16276. */
  16277. loadingUIBackgroundColor: string;
  16278. /**
  16279. * Gets or sets the text to display while loading
  16280. */
  16281. loadingUIText: string;
  16282. }
  16283. /**
  16284. * Class used for the default loading screen
  16285. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16286. */
  16287. class DefaultLoadingScreen implements ILoadingScreen {
  16288. private _renderingCanvas;
  16289. private _loadingText;
  16290. private _loadingDivBackgroundColor;
  16291. private _loadingDiv;
  16292. private _loadingTextDiv;
  16293. /**
  16294. * Creates a new default loading screen
  16295. * @param _renderingCanvas defines the canvas used to render the scene
  16296. * @param _loadingText defines the default text to display
  16297. * @param _loadingDivBackgroundColor defines the default background color
  16298. */
  16299. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16300. /**
  16301. * Function called to display the loading screen
  16302. */
  16303. displayLoadingUI(): void;
  16304. /**
  16305. * Function called to hide the loading screen
  16306. */
  16307. hideLoadingUI(): void;
  16308. /**
  16309. * Gets or sets the text to display while loading
  16310. */
  16311. loadingUIText: string;
  16312. /**
  16313. * Gets or sets the color to use for the background
  16314. */
  16315. loadingUIBackgroundColor: string;
  16316. private _resizeLoadingUI;
  16317. }
  16318. }
  16319. declare module BABYLON {
  16320. /**
  16321. * Class used to represent data loading progression
  16322. */
  16323. class SceneLoaderProgressEvent {
  16324. /** defines if data length to load can be evaluated */
  16325. readonly lengthComputable: boolean;
  16326. /** defines the loaded data length */
  16327. readonly loaded: number;
  16328. /** defines the data length to load */
  16329. readonly total: number;
  16330. /**
  16331. * Create a new progress event
  16332. * @param lengthComputable defines if data length to load can be evaluated
  16333. * @param loaded defines the loaded data length
  16334. * @param total defines the data length to load
  16335. */
  16336. constructor(
  16337. /** defines if data length to load can be evaluated */
  16338. lengthComputable: boolean,
  16339. /** defines the loaded data length */
  16340. loaded: number,
  16341. /** defines the data length to load */
  16342. total: number);
  16343. /**
  16344. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16345. * @param event defines the source event
  16346. * @returns a new SceneLoaderProgressEvent
  16347. */
  16348. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16349. }
  16350. /**
  16351. * Interface used by SceneLoader plugins to define supported file extensions
  16352. */
  16353. interface ISceneLoaderPluginExtensions {
  16354. /**
  16355. * Defines the list of supported extensions
  16356. */
  16357. [extension: string]: {
  16358. isBinary: boolean;
  16359. };
  16360. }
  16361. /**
  16362. * Interface used by SceneLoader plugin factory
  16363. */
  16364. interface ISceneLoaderPluginFactory {
  16365. /**
  16366. * Defines the name of the factory
  16367. */
  16368. name: string;
  16369. /**
  16370. * Function called to create a new plugin
  16371. * @return the new plugin
  16372. */
  16373. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16374. /**
  16375. * Boolean indicating if the plugin can direct load specific data
  16376. */
  16377. canDirectLoad?: (data: string) => boolean;
  16378. }
  16379. /**
  16380. * Interface used to define a SceneLoader plugin
  16381. */
  16382. interface ISceneLoaderPlugin {
  16383. /**
  16384. * The friendly name of this plugin.
  16385. */
  16386. name: string;
  16387. /**
  16388. * The file extensions supported by this plugin.
  16389. */
  16390. extensions: string | ISceneLoaderPluginExtensions;
  16391. /**
  16392. * Import meshes into a scene.
  16393. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16394. * @param scene The scene to import into
  16395. * @param data The data to import
  16396. * @param rootUrl The root url for scene and resources
  16397. * @param meshes The meshes array to import into
  16398. * @param particleSystems The particle systems array to import into
  16399. * @param skeletons The skeletons array to import into
  16400. * @param onError The callback when import fails
  16401. * @returns True if successful or false otherwise
  16402. */
  16403. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16404. /**
  16405. * Load into a scene.
  16406. * @param scene The scene to load into
  16407. * @param data The data to import
  16408. * @param rootUrl The root url for scene and resources
  16409. * @param onError The callback when import fails
  16410. * @returns true if successful or false otherwise
  16411. */
  16412. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16413. /**
  16414. * The callback that returns true if the data can be directly loaded.
  16415. */
  16416. canDirectLoad?: (data: string) => boolean;
  16417. /**
  16418. * The callback that allows custom handling of the root url based on the response url.
  16419. */
  16420. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16421. /**
  16422. * Load into an asset container.
  16423. * @param scene The scene to load into
  16424. * @param data The data to import
  16425. * @param rootUrl The root url for scene and resources
  16426. * @param onError The callback when import fails
  16427. * @returns The loaded asset container
  16428. */
  16429. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16430. }
  16431. /**
  16432. * Interface used to define an async SceneLoader plugin
  16433. */
  16434. interface ISceneLoaderPluginAsync {
  16435. /**
  16436. * The friendly name of this plugin.
  16437. */
  16438. name: string;
  16439. /**
  16440. * The file extensions supported by this plugin.
  16441. */
  16442. extensions: string | ISceneLoaderPluginExtensions;
  16443. /**
  16444. * Import meshes into a scene.
  16445. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16446. * @param scene The scene to import into
  16447. * @param data The data to import
  16448. * @param rootUrl The root url for scene and resources
  16449. * @param onProgress The callback when the load progresses
  16450. * @param fileName Defines the name of the file to load
  16451. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16452. */
  16453. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16454. meshes: AbstractMesh[];
  16455. particleSystems: IParticleSystem[];
  16456. skeletons: Skeleton[];
  16457. animationGroups: AnimationGroup[];
  16458. }>;
  16459. /**
  16460. * Load into a scene.
  16461. * @param scene The scene to load into
  16462. * @param data The data to import
  16463. * @param rootUrl The root url for scene and resources
  16464. * @param onProgress The callback when the load progresses
  16465. * @param fileName Defines the name of the file to load
  16466. * @returns Nothing
  16467. */
  16468. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16469. /**
  16470. * The callback that returns true if the data can be directly loaded.
  16471. */
  16472. canDirectLoad?: (data: string) => boolean;
  16473. /**
  16474. * The callback that allows custom handling of the root url based on the response url.
  16475. */
  16476. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16477. /**
  16478. * Load into an asset container.
  16479. * @param scene The scene to load into
  16480. * @param data The data to import
  16481. * @param rootUrl The root url for scene and resources
  16482. * @param onProgress The callback when the load progresses
  16483. * @param fileName Defines the name of the file to load
  16484. * @returns The loaded asset container
  16485. */
  16486. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16487. }
  16488. /**
  16489. * Class used to load scene from various file formats using registered plugins
  16490. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16491. */
  16492. class SceneLoader {
  16493. private static _ForceFullSceneLoadingForIncremental;
  16494. private static _ShowLoadingScreen;
  16495. private static _CleanBoneMatrixWeights;
  16496. /**
  16497. * No logging while loading
  16498. */
  16499. static readonly NO_LOGGING: number;
  16500. /**
  16501. * Minimal logging while loading
  16502. */
  16503. static readonly MINIMAL_LOGGING: number;
  16504. /**
  16505. * Summary logging while loading
  16506. */
  16507. static readonly SUMMARY_LOGGING: number;
  16508. /**
  16509. * Detailled logging while loading
  16510. */
  16511. static readonly DETAILED_LOGGING: number;
  16512. private static _loggingLevel;
  16513. /**
  16514. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16515. */
  16516. static ForceFullSceneLoadingForIncremental: boolean;
  16517. /**
  16518. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16519. */
  16520. static ShowLoadingScreen: boolean;
  16521. /**
  16522. * Defines the current logging level (while loading the scene)
  16523. * @ignorenaming
  16524. */
  16525. static loggingLevel: number;
  16526. /**
  16527. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16528. */
  16529. static CleanBoneMatrixWeights: boolean;
  16530. /**
  16531. * Event raised when a plugin is used to load a scene
  16532. */
  16533. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16534. private static _registeredPlugins;
  16535. private static _getDefaultPlugin;
  16536. private static _getPluginForExtension;
  16537. private static _getPluginForDirectLoad;
  16538. private static _getPluginForFilename;
  16539. private static _getDirectLoad;
  16540. private static _loadData;
  16541. private static _getFileInfo;
  16542. /**
  16543. * Gets a plugin that can load the given extension
  16544. * @param extension defines the extension to load
  16545. * @returns a plugin or null if none works
  16546. */
  16547. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16548. /**
  16549. * Gets a boolean indicating that the given extension can be loaded
  16550. * @param extension defines the extension to load
  16551. * @returns true if the extension is supported
  16552. */
  16553. static IsPluginForExtensionAvailable(extension: string): boolean;
  16554. /**
  16555. * Adds a new plugin to the list of registered plugins
  16556. * @param plugin defines the plugin to add
  16557. */
  16558. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16559. /**
  16560. * Import meshes into a scene
  16561. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16562. * @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)
  16563. * @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)
  16564. * @param scene the instance of BABYLON.Scene to append to
  16565. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16566. * @param onProgress a callback with a progress event for each file being loaded
  16567. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16568. * @param pluginExtension the extension used to determine the plugin
  16569. * @returns The loaded plugin
  16570. */
  16571. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string, 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>;
  16572. /**
  16573. * Import meshes into a scene
  16574. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16575. * @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)
  16576. * @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)
  16577. * @param scene the instance of BABYLON.Scene to append to
  16578. * @param onProgress a callback with a progress event for each file being loaded
  16579. * @param pluginExtension the extension used to determine the plugin
  16580. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16581. */
  16582. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16583. meshes: AbstractMesh[];
  16584. particleSystems: IParticleSystem[];
  16585. skeletons: Skeleton[];
  16586. animationGroups: AnimationGroup[];
  16587. }>;
  16588. /**
  16589. * Load a scene
  16590. * @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)
  16591. * @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)
  16592. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16593. * @param onSuccess a callback with the scene when import succeeds
  16594. * @param onProgress a callback with a progress event for each file being loaded
  16595. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16596. * @param pluginExtension the extension used to determine the plugin
  16597. * @returns The loaded plugin
  16598. */
  16599. static Load(rootUrl: string, sceneFilename: string, engine: 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>;
  16600. /**
  16601. * Load a scene
  16602. * @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)
  16603. * @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)
  16604. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16605. * @param onProgress a callback with a progress event for each file being loaded
  16606. * @param pluginExtension the extension used to determine the plugin
  16607. * @returns The loaded scene
  16608. */
  16609. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16610. /**
  16611. * Append a scene
  16612. * @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)
  16613. * @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)
  16614. * @param scene is the instance of BABYLON.Scene to append to
  16615. * @param onSuccess a callback with the scene when import succeeds
  16616. * @param onProgress a callback with a progress event for each file being loaded
  16617. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16618. * @param pluginExtension the extension used to determine the plugin
  16619. * @returns The loaded plugin
  16620. */
  16621. static Append(rootUrl: string, sceneFilename?: string, 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>;
  16622. /**
  16623. * Append a scene
  16624. * @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)
  16625. * @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)
  16626. * @param scene is the instance of BABYLON.Scene to append to
  16627. * @param onProgress a callback with a progress event for each file being loaded
  16628. * @param pluginExtension the extension used to determine the plugin
  16629. * @returns The given scene
  16630. */
  16631. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16632. /**
  16633. * Load a scene into an asset container
  16634. * @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)
  16635. * @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)
  16636. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16637. * @param onSuccess a callback with the scene when import succeeds
  16638. * @param onProgress a callback with a progress event for each file being loaded
  16639. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16640. * @param pluginExtension the extension used to determine the plugin
  16641. * @returns The loaded plugin
  16642. */
  16643. static LoadAssetContainer(rootUrl: string, sceneFilename?: string, 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>;
  16644. /**
  16645. * Load a scene into an asset container
  16646. * @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)
  16647. * @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)
  16648. * @param scene is the instance of BABYLON.Scene to append to
  16649. * @param onProgress a callback with a progress event for each file being loaded
  16650. * @param pluginExtension the extension used to determine the plugin
  16651. * @returns The loaded asset container
  16652. */
  16653. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16654. }
  16655. }
  16656. declare module BABYLON {
  16657. /**
  16658. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16659. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16660. * 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;
  16661. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16662. */
  16663. class ColorCurves {
  16664. private _dirty;
  16665. private _tempColor;
  16666. private _globalCurve;
  16667. private _highlightsCurve;
  16668. private _midtonesCurve;
  16669. private _shadowsCurve;
  16670. private _positiveCurve;
  16671. private _negativeCurve;
  16672. private _globalHue;
  16673. private _globalDensity;
  16674. private _globalSaturation;
  16675. private _globalExposure;
  16676. /**
  16677. * Gets the global Hue value.
  16678. * 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).
  16679. */
  16680. /**
  16681. * Sets the global Hue value.
  16682. * 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).
  16683. */
  16684. globalHue: number;
  16685. /**
  16686. * Gets the global Density value.
  16687. * 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.
  16688. * Values less than zero provide a filter of opposite hue.
  16689. */
  16690. /**
  16691. * Sets the global Density value.
  16692. * 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.
  16693. * Values less than zero provide a filter of opposite hue.
  16694. */
  16695. globalDensity: number;
  16696. /**
  16697. * Gets the global Saturation value.
  16698. * 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.
  16699. */
  16700. /**
  16701. * Sets the global Saturation value.
  16702. * 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.
  16703. */
  16704. globalSaturation: number;
  16705. /**
  16706. * Gets the global Exposure value.
  16707. * 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.
  16708. */
  16709. /**
  16710. * Sets the global Exposure value.
  16711. * 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.
  16712. */
  16713. globalExposure: number;
  16714. private _highlightsHue;
  16715. private _highlightsDensity;
  16716. private _highlightsSaturation;
  16717. private _highlightsExposure;
  16718. /**
  16719. * Gets the highlights Hue value.
  16720. * 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).
  16721. */
  16722. /**
  16723. * Sets the highlights Hue value.
  16724. * 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).
  16725. */
  16726. highlightsHue: number;
  16727. /**
  16728. * Gets the highlights Density value.
  16729. * 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.
  16730. * Values less than zero provide a filter of opposite hue.
  16731. */
  16732. /**
  16733. * Sets the highlights Density value.
  16734. * 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.
  16735. * Values less than zero provide a filter of opposite hue.
  16736. */
  16737. highlightsDensity: number;
  16738. /**
  16739. * Gets the highlights Saturation value.
  16740. * 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.
  16741. */
  16742. /**
  16743. * Sets the highlights Saturation value.
  16744. * 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.
  16745. */
  16746. highlightsSaturation: number;
  16747. /**
  16748. * Gets the highlights Exposure value.
  16749. * 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.
  16750. */
  16751. /**
  16752. * Sets the highlights Exposure value.
  16753. * 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.
  16754. */
  16755. highlightsExposure: number;
  16756. private _midtonesHue;
  16757. private _midtonesDensity;
  16758. private _midtonesSaturation;
  16759. private _midtonesExposure;
  16760. /**
  16761. * Gets the midtones Hue value.
  16762. * 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).
  16763. */
  16764. /**
  16765. * Sets the midtones Hue value.
  16766. * 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).
  16767. */
  16768. midtonesHue: number;
  16769. /**
  16770. * Gets the midtones Density value.
  16771. * 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.
  16772. * Values less than zero provide a filter of opposite hue.
  16773. */
  16774. /**
  16775. * Sets the midtones Density value.
  16776. * 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.
  16777. * Values less than zero provide a filter of opposite hue.
  16778. */
  16779. midtonesDensity: number;
  16780. /**
  16781. * Gets the midtones Saturation value.
  16782. * 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.
  16783. */
  16784. /**
  16785. * Sets the midtones Saturation value.
  16786. * 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.
  16787. */
  16788. midtonesSaturation: number;
  16789. /**
  16790. * Gets the midtones Exposure value.
  16791. * 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.
  16792. */
  16793. /**
  16794. * Sets the midtones Exposure value.
  16795. * 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.
  16796. */
  16797. midtonesExposure: number;
  16798. private _shadowsHue;
  16799. private _shadowsDensity;
  16800. private _shadowsSaturation;
  16801. private _shadowsExposure;
  16802. /**
  16803. * Gets the shadows Hue value.
  16804. * 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).
  16805. */
  16806. /**
  16807. * Sets the shadows Hue value.
  16808. * 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).
  16809. */
  16810. shadowsHue: number;
  16811. /**
  16812. * Gets the shadows Density value.
  16813. * 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.
  16814. * Values less than zero provide a filter of opposite hue.
  16815. */
  16816. /**
  16817. * Sets the shadows Density value.
  16818. * 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.
  16819. * Values less than zero provide a filter of opposite hue.
  16820. */
  16821. shadowsDensity: number;
  16822. /**
  16823. * Gets the shadows Saturation value.
  16824. * 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.
  16825. */
  16826. /**
  16827. * Sets the shadows Saturation value.
  16828. * 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.
  16829. */
  16830. shadowsSaturation: number;
  16831. /**
  16832. * Gets the shadows Exposure value.
  16833. * 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.
  16834. */
  16835. /**
  16836. * Sets the shadows Exposure value.
  16837. * 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.
  16838. */
  16839. shadowsExposure: number;
  16840. /**
  16841. * Returns the class name
  16842. * @returns The class name
  16843. */
  16844. getClassName(): string;
  16845. /**
  16846. * Binds the color curves to the shader.
  16847. * @param colorCurves The color curve to bind
  16848. * @param effect The effect to bind to
  16849. * @param positiveUniform The positive uniform shader parameter
  16850. * @param neutralUniform The neutral uniform shader parameter
  16851. * @param negativeUniform The negative uniform shader parameter
  16852. */
  16853. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  16854. /**
  16855. * Prepare the list of uniforms associated with the ColorCurves effects.
  16856. * @param uniformsList The list of uniforms used in the effect
  16857. */
  16858. static PrepareUniforms(uniformsList: string[]): void;
  16859. /**
  16860. * Returns color grading data based on a hue, density, saturation and exposure value.
  16861. * @param filterHue The hue of the color filter.
  16862. * @param filterDensity The density of the color filter.
  16863. * @param saturation The saturation.
  16864. * @param exposure The exposure.
  16865. * @param result The result data container.
  16866. */
  16867. private getColorGradingDataToRef;
  16868. /**
  16869. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  16870. * @param value The input slider value in range [-100,100].
  16871. * @returns Adjusted value.
  16872. */
  16873. private static applyColorGradingSliderNonlinear;
  16874. /**
  16875. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  16876. * @param hue The hue (H) input.
  16877. * @param saturation The saturation (S) input.
  16878. * @param brightness The brightness (B) input.
  16879. * @result An RGBA color represented as Vector4.
  16880. */
  16881. private static fromHSBToRef;
  16882. /**
  16883. * Returns a value clamped between min and max
  16884. * @param value The value to clamp
  16885. * @param min The minimum of value
  16886. * @param max The maximum of value
  16887. * @returns The clamped value.
  16888. */
  16889. private static clamp;
  16890. /**
  16891. * Clones the current color curve instance.
  16892. * @return The cloned curves
  16893. */
  16894. clone(): ColorCurves;
  16895. /**
  16896. * Serializes the current color curve instance to a json representation.
  16897. * @return a JSON representation
  16898. */
  16899. serialize(): any;
  16900. /**
  16901. * Parses the color curve from a json representation.
  16902. * @param source the JSON source to parse
  16903. * @return The parsed curves
  16904. */
  16905. static Parse(source: any): ColorCurves;
  16906. }
  16907. }
  16908. declare module BABYLON {
  16909. /**
  16910. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  16911. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  16912. */
  16913. class EffectFallbacks {
  16914. private _defines;
  16915. private _currentRank;
  16916. private _maxRank;
  16917. private _mesh;
  16918. /**
  16919. * Removes the fallback from the bound mesh.
  16920. */
  16921. unBindMesh(): void;
  16922. /**
  16923. * Adds a fallback on the specified property.
  16924. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16925. * @param define The name of the define in the shader
  16926. */
  16927. addFallback(rank: number, define: string): void;
  16928. /**
  16929. * Sets the mesh to use CPU skinning when needing to fallback.
  16930. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16931. * @param mesh The mesh to use the fallbacks.
  16932. */
  16933. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  16934. /**
  16935. * Checks to see if more fallbacks are still availible.
  16936. */
  16937. readonly isMoreFallbacks: boolean;
  16938. /**
  16939. * Removes the defines that shoould be removed when falling back.
  16940. * @param currentDefines defines the current define statements for the shader.
  16941. * @param effect defines the current effect we try to compile
  16942. * @returns The resulting defines with defines of the current rank removed.
  16943. */
  16944. reduce(currentDefines: string, effect: Effect): string;
  16945. }
  16946. /**
  16947. * Options to be used when creating an effect.
  16948. */
  16949. class EffectCreationOptions {
  16950. /**
  16951. * Atrributes that will be used in the shader.
  16952. */
  16953. attributes: string[];
  16954. /**
  16955. * Uniform varible names that will be set in the shader.
  16956. */
  16957. uniformsNames: string[];
  16958. /**
  16959. * Uniform buffer varible names that will be set in the shader.
  16960. */
  16961. uniformBuffersNames: string[];
  16962. /**
  16963. * Sampler texture variable names that will be set in the shader.
  16964. */
  16965. samplers: string[];
  16966. /**
  16967. * Define statements that will be set in the shader.
  16968. */
  16969. defines: any;
  16970. /**
  16971. * Possible fallbacks for this effect to improve performance when needed.
  16972. */
  16973. fallbacks: Nullable<EffectFallbacks>;
  16974. /**
  16975. * Callback that will be called when the shader is compiled.
  16976. */
  16977. onCompiled: Nullable<(effect: Effect) => void>;
  16978. /**
  16979. * Callback that will be called if an error occurs during shader compilation.
  16980. */
  16981. onError: Nullable<(effect: Effect, errors: string) => void>;
  16982. /**
  16983. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16984. */
  16985. indexParameters: any;
  16986. /**
  16987. * Max number of lights that can be used in the shader.
  16988. */
  16989. maxSimultaneousLights: number;
  16990. /**
  16991. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  16992. */
  16993. transformFeedbackVaryings: Nullable<string[]>;
  16994. }
  16995. /**
  16996. * Effect containing vertex and fragment shader that can be executed on an object.
  16997. */
  16998. class Effect {
  16999. /**
  17000. * Name of the effect.
  17001. */
  17002. name: any;
  17003. /**
  17004. * String container all the define statements that should be set on the shader.
  17005. */
  17006. defines: string;
  17007. /**
  17008. * Callback that will be called when the shader is compiled.
  17009. */
  17010. onCompiled: Nullable<(effect: Effect) => void>;
  17011. /**
  17012. * Callback that will be called if an error occurs during shader compilation.
  17013. */
  17014. onError: Nullable<(effect: Effect, errors: string) => void>;
  17015. /**
  17016. * Callback that will be called when effect is bound.
  17017. */
  17018. onBind: Nullable<(effect: Effect) => void>;
  17019. /**
  17020. * Unique ID of the effect.
  17021. */
  17022. uniqueId: number;
  17023. /**
  17024. * Observable that will be called when the shader is compiled.
  17025. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  17026. */
  17027. onCompileObservable: Observable<Effect>;
  17028. /**
  17029. * Observable that will be called if an error occurs during shader compilation.
  17030. */
  17031. onErrorObservable: Observable<Effect>;
  17032. /** @hidden */
  17033. _onBindObservable: Nullable<Observable<Effect>>;
  17034. /**
  17035. * Observable that will be called when effect is bound.
  17036. */
  17037. readonly onBindObservable: Observable<Effect>;
  17038. /** @hidden */
  17039. _bonesComputationForcedToCPU: boolean;
  17040. private static _uniqueIdSeed;
  17041. private _engine;
  17042. private _uniformBuffersNames;
  17043. private _uniformsNames;
  17044. private _samplers;
  17045. private _isReady;
  17046. private _compilationError;
  17047. private _attributesNames;
  17048. private _attributes;
  17049. private _uniforms;
  17050. /**
  17051. * Key for the effect.
  17052. * @hidden
  17053. */
  17054. _key: string;
  17055. private _indexParameters;
  17056. private _fallbacks;
  17057. private _vertexSourceCode;
  17058. private _fragmentSourceCode;
  17059. private _vertexSourceCodeOverride;
  17060. private _fragmentSourceCodeOverride;
  17061. private _transformFeedbackVaryings;
  17062. /**
  17063. * Compiled shader to webGL program.
  17064. * @hidden
  17065. */
  17066. _program: WebGLProgram;
  17067. private _valueCache;
  17068. private static _baseCache;
  17069. /**
  17070. * Instantiates an effect.
  17071. * An effect can be used to create/manage/execute vertex and fragment shaders.
  17072. * @param baseName Name of the effect.
  17073. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  17074. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  17075. * @param samplers List of sampler variables that will be passed to the shader.
  17076. * @param engine Engine to be used to render the effect
  17077. * @param defines Define statements to be added to the shader.
  17078. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  17079. * @param onCompiled Callback that will be called when the shader is compiled.
  17080. * @param onError Callback that will be called if an error occurs during shader compilation.
  17081. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17082. */
  17083. 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);
  17084. /**
  17085. * Unique key for this effect
  17086. */
  17087. readonly key: string;
  17088. /**
  17089. * If the effect has been compiled and prepared.
  17090. * @returns if the effect is compiled and prepared.
  17091. */
  17092. isReady(): boolean;
  17093. /**
  17094. * The engine the effect was initialized with.
  17095. * @returns the engine.
  17096. */
  17097. getEngine(): Engine;
  17098. /**
  17099. * The compiled webGL program for the effect
  17100. * @returns the webGL program.
  17101. */
  17102. getProgram(): WebGLProgram;
  17103. /**
  17104. * The set of names of attribute variables for the shader.
  17105. * @returns An array of attribute names.
  17106. */
  17107. getAttributesNames(): string[];
  17108. /**
  17109. * Returns the attribute at the given index.
  17110. * @param index The index of the attribute.
  17111. * @returns The location of the attribute.
  17112. */
  17113. getAttributeLocation(index: number): number;
  17114. /**
  17115. * Returns the attribute based on the name of the variable.
  17116. * @param name of the attribute to look up.
  17117. * @returns the attribute location.
  17118. */
  17119. getAttributeLocationByName(name: string): number;
  17120. /**
  17121. * The number of attributes.
  17122. * @returns the numnber of attributes.
  17123. */
  17124. getAttributesCount(): number;
  17125. /**
  17126. * Gets the index of a uniform variable.
  17127. * @param uniformName of the uniform to look up.
  17128. * @returns the index.
  17129. */
  17130. getUniformIndex(uniformName: string): number;
  17131. /**
  17132. * Returns the attribute based on the name of the variable.
  17133. * @param uniformName of the uniform to look up.
  17134. * @returns the location of the uniform.
  17135. */
  17136. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  17137. /**
  17138. * Returns an array of sampler variable names
  17139. * @returns The array of sampler variable neames.
  17140. */
  17141. getSamplers(): string[];
  17142. /**
  17143. * The error from the last compilation.
  17144. * @returns the error string.
  17145. */
  17146. getCompilationError(): string;
  17147. /**
  17148. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  17149. * @param func The callback to be used.
  17150. */
  17151. executeWhenCompiled(func: (effect: Effect) => void): void;
  17152. private _checkIsReady;
  17153. /** @hidden */
  17154. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  17155. /** @hidden */
  17156. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  17157. /** @hidden */
  17158. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  17159. private _processShaderConversion;
  17160. private _processIncludes;
  17161. private _processPrecision;
  17162. /**
  17163. * Recompiles the webGL program
  17164. * @param vertexSourceCode The source code for the vertex shader.
  17165. * @param fragmentSourceCode The source code for the fragment shader.
  17166. * @param onCompiled Callback called when completed.
  17167. * @param onError Callback called on error.
  17168. * @hidden
  17169. */
  17170. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  17171. /**
  17172. * Gets the uniform locations of the the specified variable names
  17173. * @param names THe names of the variables to lookup.
  17174. * @returns Array of locations in the same order as variable names.
  17175. */
  17176. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  17177. /**
  17178. * Prepares the effect
  17179. * @hidden
  17180. */
  17181. _prepareEffect(): void;
  17182. /**
  17183. * Checks if the effect is supported. (Must be called after compilation)
  17184. */
  17185. readonly isSupported: boolean;
  17186. /**
  17187. * Binds a texture to the engine to be used as output of the shader.
  17188. * @param channel Name of the output variable.
  17189. * @param texture Texture to bind.
  17190. * @hidden
  17191. */
  17192. _bindTexture(channel: string, texture: InternalTexture): void;
  17193. /**
  17194. * Sets a texture on the engine to be used in the shader.
  17195. * @param channel Name of the sampler variable.
  17196. * @param texture Texture to set.
  17197. */
  17198. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  17199. /**
  17200. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  17201. * @param channel Name of the sampler variable.
  17202. * @param texture Texture to set.
  17203. */
  17204. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  17205. /**
  17206. * Sets an array of textures on the engine to be used in the shader.
  17207. * @param channel Name of the variable.
  17208. * @param textures Textures to set.
  17209. */
  17210. setTextureArray(channel: string, textures: BaseTexture[]): void;
  17211. /**
  17212. * 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)
  17213. * @param channel Name of the sampler variable.
  17214. * @param postProcess Post process to get the input texture from.
  17215. */
  17216. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  17217. /**
  17218. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  17219. * 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)
  17220. * @param channel Name of the sampler variable.
  17221. * @param postProcess Post process to get the output texture from.
  17222. */
  17223. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  17224. /** @hidden */
  17225. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  17226. /** @hidden */
  17227. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  17228. /** @hidden */
  17229. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  17230. /** @hidden */
  17231. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  17232. /**
  17233. * Binds a buffer to a uniform.
  17234. * @param buffer Buffer to bind.
  17235. * @param name Name of the uniform variable to bind to.
  17236. */
  17237. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  17238. /**
  17239. * Binds block to a uniform.
  17240. * @param blockName Name of the block to bind.
  17241. * @param index Index to bind.
  17242. */
  17243. bindUniformBlock(blockName: string, index: number): void;
  17244. /**
  17245. * Sets an interger value on a uniform variable.
  17246. * @param uniformName Name of the variable.
  17247. * @param value Value to be set.
  17248. * @returns this effect.
  17249. */
  17250. setInt(uniformName: string, value: number): Effect;
  17251. /**
  17252. * Sets an int array on a uniform variable.
  17253. * @param uniformName Name of the variable.
  17254. * @param array array to be set.
  17255. * @returns this effect.
  17256. */
  17257. setIntArray(uniformName: string, array: Int32Array): Effect;
  17258. /**
  17259. * 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)
  17260. * @param uniformName Name of the variable.
  17261. * @param array array to be set.
  17262. * @returns this effect.
  17263. */
  17264. setIntArray2(uniformName: string, array: Int32Array): Effect;
  17265. /**
  17266. * 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)
  17267. * @param uniformName Name of the variable.
  17268. * @param array array to be set.
  17269. * @returns this effect.
  17270. */
  17271. setIntArray3(uniformName: string, array: Int32Array): Effect;
  17272. /**
  17273. * 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)
  17274. * @param uniformName Name of the variable.
  17275. * @param array array to be set.
  17276. * @returns this effect.
  17277. */
  17278. setIntArray4(uniformName: string, array: Int32Array): Effect;
  17279. /**
  17280. * Sets an float array on a uniform variable.
  17281. * @param uniformName Name of the variable.
  17282. * @param array array to be set.
  17283. * @returns this effect.
  17284. */
  17285. setFloatArray(uniformName: string, array: Float32Array): Effect;
  17286. /**
  17287. * 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)
  17288. * @param uniformName Name of the variable.
  17289. * @param array array to be set.
  17290. * @returns this effect.
  17291. */
  17292. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  17293. /**
  17294. * 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)
  17295. * @param uniformName Name of the variable.
  17296. * @param array array to be set.
  17297. * @returns this effect.
  17298. */
  17299. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  17300. /**
  17301. * 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)
  17302. * @param uniformName Name of the variable.
  17303. * @param array array to be set.
  17304. * @returns this effect.
  17305. */
  17306. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  17307. /**
  17308. * Sets an array on a uniform variable.
  17309. * @param uniformName Name of the variable.
  17310. * @param array array to be set.
  17311. * @returns this effect.
  17312. */
  17313. setArray(uniformName: string, array: number[]): Effect;
  17314. /**
  17315. * 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)
  17316. * @param uniformName Name of the variable.
  17317. * @param array array to be set.
  17318. * @returns this effect.
  17319. */
  17320. setArray2(uniformName: string, array: number[]): Effect;
  17321. /**
  17322. * 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)
  17323. * @param uniformName Name of the variable.
  17324. * @param array array to be set.
  17325. * @returns this effect.
  17326. */
  17327. setArray3(uniformName: string, array: number[]): Effect;
  17328. /**
  17329. * 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)
  17330. * @param uniformName Name of the variable.
  17331. * @param array array to be set.
  17332. * @returns this effect.
  17333. */
  17334. setArray4(uniformName: string, array: number[]): Effect;
  17335. /**
  17336. * Sets matrices on a uniform variable.
  17337. * @param uniformName Name of the variable.
  17338. * @param matrices matrices to be set.
  17339. * @returns this effect.
  17340. */
  17341. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  17342. /**
  17343. * Sets matrix on a uniform variable.
  17344. * @param uniformName Name of the variable.
  17345. * @param matrix matrix to be set.
  17346. * @returns this effect.
  17347. */
  17348. setMatrix(uniformName: string, matrix: Matrix): Effect;
  17349. /**
  17350. * 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)
  17351. * @param uniformName Name of the variable.
  17352. * @param matrix matrix to be set.
  17353. * @returns this effect.
  17354. */
  17355. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  17356. /**
  17357. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  17358. * @param uniformName Name of the variable.
  17359. * @param matrix matrix to be set.
  17360. * @returns this effect.
  17361. */
  17362. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  17363. /**
  17364. * Sets a float on a uniform variable.
  17365. * @param uniformName Name of the variable.
  17366. * @param value value to be set.
  17367. * @returns this effect.
  17368. */
  17369. setFloat(uniformName: string, value: number): Effect;
  17370. /**
  17371. * Sets a boolean on a uniform variable.
  17372. * @param uniformName Name of the variable.
  17373. * @param bool value to be set.
  17374. * @returns this effect.
  17375. */
  17376. setBool(uniformName: string, bool: boolean): Effect;
  17377. /**
  17378. * Sets a Vector2 on a uniform variable.
  17379. * @param uniformName Name of the variable.
  17380. * @param vector2 vector2 to be set.
  17381. * @returns this effect.
  17382. */
  17383. setVector2(uniformName: string, vector2: Vector2): Effect;
  17384. /**
  17385. * Sets a float2 on a uniform variable.
  17386. * @param uniformName Name of the variable.
  17387. * @param x First float in float2.
  17388. * @param y Second float in float2.
  17389. * @returns this effect.
  17390. */
  17391. setFloat2(uniformName: string, x: number, y: number): Effect;
  17392. /**
  17393. * Sets a Vector3 on a uniform variable.
  17394. * @param uniformName Name of the variable.
  17395. * @param vector3 Value to be set.
  17396. * @returns this effect.
  17397. */
  17398. setVector3(uniformName: string, vector3: Vector3): Effect;
  17399. /**
  17400. * Sets a float3 on a uniform variable.
  17401. * @param uniformName Name of the variable.
  17402. * @param x First float in float3.
  17403. * @param y Second float in float3.
  17404. * @param z Third float in float3.
  17405. * @returns this effect.
  17406. */
  17407. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17408. /**
  17409. * Sets a Vector4 on a uniform variable.
  17410. * @param uniformName Name of the variable.
  17411. * @param vector4 Value to be set.
  17412. * @returns this effect.
  17413. */
  17414. setVector4(uniformName: string, vector4: Vector4): Effect;
  17415. /**
  17416. * Sets a float4 on a uniform variable.
  17417. * @param uniformName Name of the variable.
  17418. * @param x First float in float4.
  17419. * @param y Second float in float4.
  17420. * @param z Third float in float4.
  17421. * @param w Fourth float in float4.
  17422. * @returns this effect.
  17423. */
  17424. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17425. /**
  17426. * Sets a Color3 on a uniform variable.
  17427. * @param uniformName Name of the variable.
  17428. * @param color3 Value to be set.
  17429. * @returns this effect.
  17430. */
  17431. setColor3(uniformName: string, color3: Color3): Effect;
  17432. /**
  17433. * Sets a Color4 on a uniform variable.
  17434. * @param uniformName Name of the variable.
  17435. * @param color3 Value to be set.
  17436. * @param alpha Alpha value to be set.
  17437. * @returns this effect.
  17438. */
  17439. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17440. /**
  17441. * Sets a Color4 on a uniform variable
  17442. * @param uniformName defines the name of the variable
  17443. * @param color4 defines the value to be set
  17444. * @returns this effect.
  17445. */
  17446. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17447. /**
  17448. * This function will add a new shader to the shader store
  17449. * @param name the name of the shader
  17450. * @param pixelShader optional pixel shader content
  17451. * @param vertexShader optional vertex shader content
  17452. */
  17453. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17454. /**
  17455. * Store of each shader (The can be looked up using effect.key)
  17456. */
  17457. static ShadersStore: {
  17458. [key: string]: string;
  17459. };
  17460. /**
  17461. * Store of each included file for a shader (The can be looked up using effect.key)
  17462. */
  17463. static IncludesShadersStore: {
  17464. [key: string]: string;
  17465. };
  17466. /**
  17467. * Resets the cache of effects.
  17468. */
  17469. static ResetCache(): void;
  17470. }
  17471. }
  17472. declare module BABYLON {
  17473. /**
  17474. * This represents all the required information to add a fresnel effect on a material:
  17475. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  17476. */
  17477. class FresnelParameters {
  17478. private _isEnabled;
  17479. /**
  17480. * Define if the fresnel effect is enable or not.
  17481. */
  17482. isEnabled: boolean;
  17483. /**
  17484. * Define the color used on edges (grazing angle)
  17485. */
  17486. leftColor: Color3;
  17487. /**
  17488. * Define the color used on center
  17489. */
  17490. rightColor: Color3;
  17491. /**
  17492. * Define bias applied to computed fresnel term
  17493. */
  17494. bias: number;
  17495. /**
  17496. * Defined the power exponent applied to fresnel term
  17497. */
  17498. power: number;
  17499. /**
  17500. * Clones the current fresnel and its valuues
  17501. * @returns a clone fresnel configuration
  17502. */
  17503. clone(): FresnelParameters;
  17504. /**
  17505. * Serializes the current fresnel parameters to a JSON representation.
  17506. * @return the JSON serialization
  17507. */
  17508. serialize(): any;
  17509. /**
  17510. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  17511. * @param parsedFresnelParameters Define the JSON representation
  17512. * @returns the parsed parameters
  17513. */
  17514. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17515. }
  17516. }
  17517. declare module BABYLON {
  17518. /**
  17519. * Interface to follow in your material defines to integrate easily the
  17520. * Image proccessing functions.
  17521. * @hidden
  17522. */
  17523. interface IImageProcessingConfigurationDefines {
  17524. IMAGEPROCESSING: boolean;
  17525. VIGNETTE: boolean;
  17526. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17527. VIGNETTEBLENDMODEOPAQUE: boolean;
  17528. TONEMAPPING: boolean;
  17529. TONEMAPPING_ACES: boolean;
  17530. CONTRAST: boolean;
  17531. EXPOSURE: boolean;
  17532. COLORCURVES: boolean;
  17533. COLORGRADING: boolean;
  17534. COLORGRADING3D: boolean;
  17535. SAMPLER3DGREENDEPTH: boolean;
  17536. SAMPLER3DBGRMAP: boolean;
  17537. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17538. }
  17539. /**
  17540. * @hidden
  17541. */
  17542. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17543. IMAGEPROCESSING: boolean;
  17544. VIGNETTE: boolean;
  17545. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17546. VIGNETTEBLENDMODEOPAQUE: boolean;
  17547. TONEMAPPING: boolean;
  17548. TONEMAPPING_ACES: boolean;
  17549. CONTRAST: boolean;
  17550. COLORCURVES: boolean;
  17551. COLORGRADING: boolean;
  17552. COLORGRADING3D: boolean;
  17553. SAMPLER3DGREENDEPTH: boolean;
  17554. SAMPLER3DBGRMAP: boolean;
  17555. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17556. EXPOSURE: boolean;
  17557. constructor();
  17558. }
  17559. /**
  17560. * This groups together the common properties used for image processing either in direct forward pass
  17561. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17562. * or not.
  17563. */
  17564. class ImageProcessingConfiguration {
  17565. /**
  17566. * Default tone mapping applied in BabylonJS.
  17567. */
  17568. static readonly TONEMAPPING_STANDARD: number;
  17569. /**
  17570. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17571. * to other engines rendering to increase portability.
  17572. */
  17573. static readonly TONEMAPPING_ACES: number;
  17574. /**
  17575. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17576. */
  17577. colorCurves: Nullable<ColorCurves>;
  17578. private _colorCurvesEnabled;
  17579. /**
  17580. * Gets wether the color curves effect is enabled.
  17581. */
  17582. /**
  17583. * Sets wether the color curves effect is enabled.
  17584. */
  17585. colorCurvesEnabled: boolean;
  17586. private _colorGradingTexture;
  17587. /**
  17588. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17589. */
  17590. /**
  17591. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17592. */
  17593. colorGradingTexture: Nullable<BaseTexture>;
  17594. private _colorGradingEnabled;
  17595. /**
  17596. * Gets wether the color grading effect is enabled.
  17597. */
  17598. /**
  17599. * Sets wether the color grading effect is enabled.
  17600. */
  17601. colorGradingEnabled: boolean;
  17602. private _colorGradingWithGreenDepth;
  17603. /**
  17604. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17605. */
  17606. /**
  17607. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17608. */
  17609. colorGradingWithGreenDepth: boolean;
  17610. private _colorGradingBGR;
  17611. /**
  17612. * Gets wether the color grading texture contains BGR values.
  17613. */
  17614. /**
  17615. * Sets wether the color grading texture contains BGR values.
  17616. */
  17617. colorGradingBGR: boolean;
  17618. /** @hidden */
  17619. _exposure: number;
  17620. /**
  17621. * Gets the Exposure used in the effect.
  17622. */
  17623. /**
  17624. * Sets the Exposure used in the effect.
  17625. */
  17626. exposure: number;
  17627. private _toneMappingEnabled;
  17628. /**
  17629. * Gets wether the tone mapping effect is enabled.
  17630. */
  17631. /**
  17632. * Sets wether the tone mapping effect is enabled.
  17633. */
  17634. toneMappingEnabled: boolean;
  17635. private _toneMappingType;
  17636. /**
  17637. * Gets the type of tone mapping effect.
  17638. */
  17639. /**
  17640. * Sets the type of tone mapping effect used in BabylonJS.
  17641. */
  17642. toneMappingType: number;
  17643. protected _contrast: number;
  17644. /**
  17645. * Gets the contrast used in the effect.
  17646. */
  17647. /**
  17648. * Sets the contrast used in the effect.
  17649. */
  17650. contrast: number;
  17651. /**
  17652. * Vignette stretch size.
  17653. */
  17654. vignetteStretch: number;
  17655. /**
  17656. * Vignette centre X Offset.
  17657. */
  17658. vignetteCentreX: number;
  17659. /**
  17660. * Vignette centre Y Offset.
  17661. */
  17662. vignetteCentreY: number;
  17663. /**
  17664. * Vignette weight or intensity of the vignette effect.
  17665. */
  17666. vignetteWeight: number;
  17667. /**
  17668. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17669. * if vignetteEnabled is set to true.
  17670. */
  17671. vignetteColor: Color4;
  17672. /**
  17673. * Camera field of view used by the Vignette effect.
  17674. */
  17675. vignetteCameraFov: number;
  17676. private _vignetteBlendMode;
  17677. /**
  17678. * Gets the vignette blend mode allowing different kind of effect.
  17679. */
  17680. /**
  17681. * Sets the vignette blend mode allowing different kind of effect.
  17682. */
  17683. vignetteBlendMode: number;
  17684. private _vignetteEnabled;
  17685. /**
  17686. * Gets wether the vignette effect is enabled.
  17687. */
  17688. /**
  17689. * Sets wether the vignette effect is enabled.
  17690. */
  17691. vignetteEnabled: boolean;
  17692. private _applyByPostProcess;
  17693. /**
  17694. * Gets wether the image processing is applied through a post process or not.
  17695. */
  17696. /**
  17697. * Sets wether the image processing is applied through a post process or not.
  17698. */
  17699. applyByPostProcess: boolean;
  17700. private _isEnabled;
  17701. /**
  17702. * Gets wether the image processing is enabled or not.
  17703. */
  17704. /**
  17705. * Sets wether the image processing is enabled or not.
  17706. */
  17707. isEnabled: boolean;
  17708. /**
  17709. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17710. */
  17711. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17712. /**
  17713. * Method called each time the image processing information changes requires to recompile the effect.
  17714. */
  17715. protected _updateParameters(): void;
  17716. /**
  17717. * Gets the current class name.
  17718. * @return "ImageProcessingConfiguration"
  17719. */
  17720. getClassName(): string;
  17721. /**
  17722. * Prepare the list of uniforms associated with the Image Processing effects.
  17723. * @param uniforms The list of uniforms used in the effect
  17724. * @param defines the list of defines currently in use
  17725. */
  17726. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  17727. /**
  17728. * Prepare the list of samplers associated with the Image Processing effects.
  17729. * @param samplersList The list of uniforms used in the effect
  17730. * @param defines the list of defines currently in use
  17731. */
  17732. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  17733. /**
  17734. * Prepare the list of defines associated to the shader.
  17735. * @param defines the list of defines to complete
  17736. * @param forPostProcess Define if we are currently in post process mode or not
  17737. */
  17738. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  17739. /**
  17740. * Returns true if all the image processing information are ready.
  17741. * @returns True if ready, otherwise, false
  17742. */
  17743. isReady(): boolean;
  17744. /**
  17745. * Binds the image processing to the shader.
  17746. * @param effect The effect to bind to
  17747. * @param aspectRatio Define the current aspect ratio of the effect
  17748. */
  17749. bind(effect: Effect, aspectRatio?: number): void;
  17750. /**
  17751. * Clones the current image processing instance.
  17752. * @return The cloned image processing
  17753. */
  17754. clone(): ImageProcessingConfiguration;
  17755. /**
  17756. * Serializes the current image processing instance to a json representation.
  17757. * @return a JSON representation
  17758. */
  17759. serialize(): any;
  17760. /**
  17761. * Parses the image processing from a json representation.
  17762. * @param source the JSON source to parse
  17763. * @return The parsed image processing
  17764. */
  17765. static Parse(source: any): ImageProcessingConfiguration;
  17766. private static _VIGNETTEMODE_MULTIPLY;
  17767. private static _VIGNETTEMODE_OPAQUE;
  17768. /**
  17769. * Used to apply the vignette as a mix with the pixel color.
  17770. */
  17771. static readonly VIGNETTEMODE_MULTIPLY: number;
  17772. /**
  17773. * Used to apply the vignette as a replacement of the pixel color.
  17774. */
  17775. static readonly VIGNETTEMODE_OPAQUE: number;
  17776. }
  17777. }
  17778. declare module BABYLON {
  17779. /**
  17780. * Manages the defines for the Material
  17781. */
  17782. class MaterialDefines {
  17783. private _keys;
  17784. private _isDirty;
  17785. /** @hidden */
  17786. _renderId: number;
  17787. /** @hidden */
  17788. _areLightsDirty: boolean;
  17789. /** @hidden */
  17790. _areAttributesDirty: boolean;
  17791. /** @hidden */
  17792. _areTexturesDirty: boolean;
  17793. /** @hidden */
  17794. _areFresnelDirty: boolean;
  17795. /** @hidden */
  17796. _areMiscDirty: boolean;
  17797. /** @hidden */
  17798. _areImageProcessingDirty: boolean;
  17799. /** @hidden */
  17800. _normals: boolean;
  17801. /** @hidden */
  17802. _uvs: boolean;
  17803. /** @hidden */
  17804. _needNormals: boolean;
  17805. /** @hidden */
  17806. _needUVs: boolean;
  17807. /**
  17808. * Specifies if the material needs to be re-calculated
  17809. */
  17810. readonly isDirty: boolean;
  17811. /**
  17812. * Marks the material to indicate that it has been re-calculated
  17813. */
  17814. markAsProcessed(): void;
  17815. /**
  17816. * Marks the material to indicate that it needs to be re-calculated
  17817. */
  17818. markAsUnprocessed(): void;
  17819. /**
  17820. * Marks the material to indicate all of its defines need to be re-calculated
  17821. */
  17822. markAllAsDirty(): void;
  17823. /**
  17824. * Marks the material to indicate that image processing needs to be re-calculated
  17825. */
  17826. markAsImageProcessingDirty(): void;
  17827. /**
  17828. * Marks the material to indicate the lights need to be re-calculated
  17829. */
  17830. markAsLightDirty(): void;
  17831. /**
  17832. * Marks the attribute state as changed
  17833. */
  17834. markAsAttributesDirty(): void;
  17835. /**
  17836. * Marks the texture state as changed
  17837. */
  17838. markAsTexturesDirty(): void;
  17839. /**
  17840. * Marks the fresnel state as changed
  17841. */
  17842. markAsFresnelDirty(): void;
  17843. /**
  17844. * Marks the misc state as changed
  17845. */
  17846. markAsMiscDirty(): void;
  17847. /**
  17848. * Rebuilds the material defines
  17849. */
  17850. rebuild(): void;
  17851. /**
  17852. * Specifies if two material defines are equal
  17853. * @param other - A material define instance to compare to
  17854. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  17855. */
  17856. isEqual(other: MaterialDefines): boolean;
  17857. /**
  17858. * Clones this instance's defines to another instance
  17859. * @param other - material defines to clone values to
  17860. */
  17861. cloneTo(other: MaterialDefines): void;
  17862. /**
  17863. * Resets the material define values
  17864. */
  17865. reset(): void;
  17866. /**
  17867. * Converts the material define values to a string
  17868. * @returns - String of material define information
  17869. */
  17870. toString(): string;
  17871. }
  17872. /**
  17873. * Base class for the main features of a material in Babylon.js
  17874. */
  17875. class Material implements IAnimatable {
  17876. private static _TriangleFillMode;
  17877. private static _WireFrameFillMode;
  17878. private static _PointFillMode;
  17879. private static _PointListDrawMode;
  17880. private static _LineListDrawMode;
  17881. private static _LineLoopDrawMode;
  17882. private static _LineStripDrawMode;
  17883. private static _TriangleStripDrawMode;
  17884. private static _TriangleFanDrawMode;
  17885. /**
  17886. * Returns the triangle fill mode
  17887. */
  17888. static readonly TriangleFillMode: number;
  17889. /**
  17890. * Returns the wireframe mode
  17891. */
  17892. static readonly WireFrameFillMode: number;
  17893. /**
  17894. * Returns the point fill mode
  17895. */
  17896. static readonly PointFillMode: number;
  17897. /**
  17898. * Returns the point list draw mode
  17899. */
  17900. static readonly PointListDrawMode: number;
  17901. /**
  17902. * Returns the line list draw mode
  17903. */
  17904. static readonly LineListDrawMode: number;
  17905. /**
  17906. * Returns the line loop draw mode
  17907. */
  17908. static readonly LineLoopDrawMode: number;
  17909. /**
  17910. * Returns the line strip draw mode
  17911. */
  17912. static readonly LineStripDrawMode: number;
  17913. /**
  17914. * Returns the triangle strip draw mode
  17915. */
  17916. static readonly TriangleStripDrawMode: number;
  17917. /**
  17918. * Returns the triangle fan draw mode
  17919. */
  17920. static readonly TriangleFanDrawMode: number;
  17921. /**
  17922. * Stores the clock-wise side orientation
  17923. */
  17924. private static _ClockWiseSideOrientation;
  17925. /**
  17926. * Stores the counter clock-wise side orientation
  17927. */
  17928. private static _CounterClockWiseSideOrientation;
  17929. /**
  17930. * Returns the clock-wise side orientation
  17931. */
  17932. static readonly ClockWiseSideOrientation: number;
  17933. /**
  17934. * Returns the counter clock-wise side orientation
  17935. */
  17936. static readonly CounterClockWiseSideOrientation: number;
  17937. /**
  17938. * The dirty texture flag value
  17939. */
  17940. static readonly TextureDirtyFlag: number;
  17941. /**
  17942. * The dirty light flag value
  17943. */
  17944. static readonly LightDirtyFlag: number;
  17945. /**
  17946. * The dirty fresnel flag value
  17947. */
  17948. static readonly FresnelDirtyFlag: number;
  17949. /**
  17950. * The dirty attribute flag value
  17951. */
  17952. static readonly AttributesDirtyFlag: number;
  17953. /**
  17954. * The dirty misc flag value
  17955. */
  17956. static readonly MiscDirtyFlag: number;
  17957. /**
  17958. * The all dirty flag value
  17959. */
  17960. static readonly AllDirtyFlag: number;
  17961. /**
  17962. * The ID of the material
  17963. */
  17964. id: string;
  17965. /**
  17966. * Gets or sets the unique id of the material
  17967. */
  17968. uniqueId: number;
  17969. /**
  17970. * The name of the material
  17971. */
  17972. name: string;
  17973. /**
  17974. * Specifies if the ready state should be checked on each call
  17975. */
  17976. checkReadyOnEveryCall: boolean;
  17977. /**
  17978. * Specifies if the ready state should be checked once
  17979. */
  17980. checkReadyOnlyOnce: boolean;
  17981. /**
  17982. * The state of the material
  17983. */
  17984. state: string;
  17985. /**
  17986. * The alpha value of the material
  17987. */
  17988. protected _alpha: number;
  17989. /**
  17990. * Sets the alpha value of the material
  17991. */
  17992. /**
  17993. * Gets the alpha value of the material
  17994. */
  17995. alpha: number;
  17996. /**
  17997. * Specifies if back face culling is enabled
  17998. */
  17999. protected _backFaceCulling: boolean;
  18000. /**
  18001. * Sets the back-face culling state
  18002. */
  18003. /**
  18004. * Gets the back-face culling state
  18005. */
  18006. backFaceCulling: boolean;
  18007. /**
  18008. * Stores the value for side orientation
  18009. */
  18010. sideOrientation: number;
  18011. /**
  18012. * Callback triggered when the material is compiled
  18013. */
  18014. onCompiled: (effect: Effect) => void;
  18015. /**
  18016. * Callback triggered when an error occurs
  18017. */
  18018. onError: (effect: Effect, errors: string) => void;
  18019. /**
  18020. * Callback triggered to get the render target textures
  18021. */
  18022. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  18023. /**
  18024. * Gets a boolean indicating that current material needs to register RTT
  18025. */
  18026. readonly hasRenderTargetTextures: boolean;
  18027. /**
  18028. * Specifies if the material should be serialized
  18029. */
  18030. doNotSerialize: boolean;
  18031. /**
  18032. * @hidden
  18033. */
  18034. _storeEffectOnSubMeshes: boolean;
  18035. /**
  18036. * Stores the animations for the material
  18037. */
  18038. animations: Array<Animation>;
  18039. /**
  18040. * An event triggered when the material is disposed
  18041. */
  18042. onDisposeObservable: Observable<Material>;
  18043. /**
  18044. * An observer which watches for dispose events
  18045. */
  18046. private _onDisposeObserver;
  18047. private _onUnBindObservable;
  18048. /**
  18049. * Called during a dispose event
  18050. */
  18051. onDispose: () => void;
  18052. private _onBindObservable;
  18053. /**
  18054. * An event triggered when the material is bound
  18055. */
  18056. readonly onBindObservable: Observable<AbstractMesh>;
  18057. /**
  18058. * An observer which watches for bind events
  18059. */
  18060. private _onBindObserver;
  18061. /**
  18062. * Called during a bind event
  18063. */
  18064. onBind: (Mesh: AbstractMesh) => void;
  18065. /**
  18066. * An event triggered when the material is unbound
  18067. */
  18068. readonly onUnBindObservable: Observable<Material>;
  18069. /**
  18070. * Stores the value of the alpha mode
  18071. */
  18072. private _alphaMode;
  18073. /**
  18074. * Sets the value of the alpha mode.
  18075. *
  18076. * | Value | Type | Description |
  18077. * | --- | --- | --- |
  18078. * | 0 | ALPHA_DISABLE | |
  18079. * | 1 | ALPHA_ADD | |
  18080. * | 2 | ALPHA_COMBINE | |
  18081. * | 3 | ALPHA_SUBTRACT | |
  18082. * | 4 | ALPHA_MULTIPLY | |
  18083. * | 5 | ALPHA_MAXIMIZED | |
  18084. * | 6 | ALPHA_ONEONE | |
  18085. * | 7 | ALPHA_PREMULTIPLIED | |
  18086. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  18087. * | 9 | ALPHA_INTERPOLATE | |
  18088. * | 10 | ALPHA_SCREENMODE | |
  18089. *
  18090. */
  18091. /**
  18092. * Gets the value of the alpha mode
  18093. */
  18094. alphaMode: number;
  18095. /**
  18096. * Stores the state of the need depth pre-pass value
  18097. */
  18098. private _needDepthPrePass;
  18099. /**
  18100. * Sets the need depth pre-pass value
  18101. */
  18102. /**
  18103. * Gets the depth pre-pass value
  18104. */
  18105. needDepthPrePass: boolean;
  18106. /**
  18107. * Specifies if depth writing should be disabled
  18108. */
  18109. disableDepthWrite: boolean;
  18110. /**
  18111. * Specifies if depth writing should be forced
  18112. */
  18113. forceDepthWrite: boolean;
  18114. /**
  18115. * Specifies if there should be a separate pass for culling
  18116. */
  18117. separateCullingPass: boolean;
  18118. /**
  18119. * Stores the state specifing if fog should be enabled
  18120. */
  18121. private _fogEnabled;
  18122. /**
  18123. * Sets the state for enabling fog
  18124. */
  18125. /**
  18126. * Gets the value of the fog enabled state
  18127. */
  18128. fogEnabled: boolean;
  18129. /**
  18130. * Stores the size of points
  18131. */
  18132. pointSize: number;
  18133. /**
  18134. * Stores the z offset value
  18135. */
  18136. zOffset: number;
  18137. /**
  18138. * Gets a value specifying if wireframe mode is enabled
  18139. */
  18140. /**
  18141. * Sets the state of wireframe mode
  18142. */
  18143. wireframe: boolean;
  18144. /**
  18145. * Gets the value specifying if point clouds are enabled
  18146. */
  18147. /**
  18148. * Sets the state of point cloud mode
  18149. */
  18150. pointsCloud: boolean;
  18151. /**
  18152. * Gets the material fill mode
  18153. */
  18154. /**
  18155. * Sets the material fill mode
  18156. */
  18157. fillMode: number;
  18158. /**
  18159. * @hidden
  18160. * Stores the effects for the material
  18161. */
  18162. _effect: Nullable<Effect>;
  18163. /**
  18164. * @hidden
  18165. * Specifies if the material was previously ready
  18166. */
  18167. _wasPreviouslyReady: boolean;
  18168. /**
  18169. * Specifies if uniform buffers should be used
  18170. */
  18171. private _useUBO;
  18172. /**
  18173. * Stores a reference to the scene
  18174. */
  18175. private _scene;
  18176. /**
  18177. * Stores the fill mode state
  18178. */
  18179. private _fillMode;
  18180. /**
  18181. * Specifies if the depth write state should be cached
  18182. */
  18183. private _cachedDepthWriteState;
  18184. /**
  18185. * Stores the uniform buffer
  18186. */
  18187. protected _uniformBuffer: UniformBuffer;
  18188. /** @hidden */
  18189. _indexInSceneMaterialArray: number;
  18190. /** @hidden */
  18191. meshMap: Nullable<{
  18192. [id: string]: AbstractMesh | undefined;
  18193. }>;
  18194. /**
  18195. * Creates a material instance
  18196. * @param name defines the name of the material
  18197. * @param scene defines the scene to reference
  18198. * @param doNotAdd specifies if the material should be added to the scene
  18199. */
  18200. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  18201. /**
  18202. * Returns a string representation of the current material
  18203. * @param fullDetails defines a boolean indicating which levels of logging is desired
  18204. * @returns a string with material information
  18205. */
  18206. toString(fullDetails?: boolean): string;
  18207. /**
  18208. * Gets the class name of the material
  18209. * @returns a string with the class name of the material
  18210. */
  18211. getClassName(): string;
  18212. /**
  18213. * Specifies if updates for the material been locked
  18214. */
  18215. readonly isFrozen: boolean;
  18216. /**
  18217. * Locks updates for the material
  18218. */
  18219. freeze(): void;
  18220. /**
  18221. * Unlocks updates for the material
  18222. */
  18223. unfreeze(): void;
  18224. /**
  18225. * Specifies if the material is ready to be used
  18226. * @param mesh defines the mesh to check
  18227. * @param useInstances specifies if instances should be used
  18228. * @returns a boolean indicating if the material is ready to be used
  18229. */
  18230. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18231. /**
  18232. * Specifies that the submesh is ready to be used
  18233. * @param mesh defines the mesh to check
  18234. * @param subMesh defines which submesh to check
  18235. * @param useInstances specifies that instances should be used
  18236. * @returns a boolean indicating that the submesh is ready or not
  18237. */
  18238. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18239. /**
  18240. * Returns the material effect
  18241. * @returns the effect associated with the material
  18242. */
  18243. getEffect(): Nullable<Effect>;
  18244. /**
  18245. * Returns the current scene
  18246. * @returns a Scene
  18247. */
  18248. getScene(): Scene;
  18249. /**
  18250. * Specifies if the material will require alpha blending
  18251. * @returns a boolean specifying if alpha blending is needed
  18252. */
  18253. needAlphaBlending(): boolean;
  18254. /**
  18255. * Specifies if the mesh will require alpha blending
  18256. * @param mesh defines the mesh to check
  18257. * @returns a boolean specifying if alpha blending is needed for the mesh
  18258. */
  18259. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18260. /**
  18261. * Specifies if this material should be rendered in alpha test mode
  18262. * @returns a boolean specifying if an alpha test is needed.
  18263. */
  18264. needAlphaTesting(): boolean;
  18265. /**
  18266. * Gets the texture used for the alpha test
  18267. * @returns the texture to use for alpha testing
  18268. */
  18269. getAlphaTestTexture(): Nullable<BaseTexture>;
  18270. /**
  18271. * Marks the material to indicate that it needs to be re-calculated
  18272. */
  18273. markDirty(): void;
  18274. /** @hidden */
  18275. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18276. /**
  18277. * Binds the material to the mesh
  18278. * @param world defines the world transformation matrix
  18279. * @param mesh defines the mesh to bind the material to
  18280. */
  18281. bind(world: Matrix, mesh?: Mesh): void;
  18282. /**
  18283. * Binds the submesh to the material
  18284. * @param world defines the world transformation matrix
  18285. * @param mesh defines the mesh containing the submesh
  18286. * @param subMesh defines the submesh to bind the material to
  18287. */
  18288. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18289. /**
  18290. * Binds the world matrix to the material
  18291. * @param world defines the world transformation matrix
  18292. */
  18293. bindOnlyWorldMatrix(world: Matrix): void;
  18294. /**
  18295. * Binds the scene's uniform buffer to the effect.
  18296. * @param effect defines the effect to bind to the scene uniform buffer
  18297. * @param sceneUbo defines the uniform buffer storing scene data
  18298. */
  18299. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18300. /**
  18301. * Binds the view matrix to the effect
  18302. * @param effect defines the effect to bind the view matrix to
  18303. */
  18304. bindView(effect: Effect): void;
  18305. /**
  18306. * Binds the view projection matrix to the effect
  18307. * @param effect defines the effect to bind the view projection matrix to
  18308. */
  18309. bindViewProjection(effect: Effect): void;
  18310. /**
  18311. * Specifies if material alpha testing should be turned on for the mesh
  18312. * @param mesh defines the mesh to check
  18313. */
  18314. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18315. /**
  18316. * Processes to execute after binding the material to a mesh
  18317. * @param mesh defines the rendered mesh
  18318. */
  18319. protected _afterBind(mesh?: Mesh): void;
  18320. /**
  18321. * Unbinds the material from the mesh
  18322. */
  18323. unbind(): void;
  18324. /**
  18325. * Gets the active textures from the material
  18326. * @returns an array of textures
  18327. */
  18328. getActiveTextures(): BaseTexture[];
  18329. /**
  18330. * Specifies if the material uses a texture
  18331. * @param texture defines the texture to check against the material
  18332. * @returns a boolean specifying if the material uses the texture
  18333. */
  18334. hasTexture(texture: BaseTexture): boolean;
  18335. /**
  18336. * Makes a duplicate of the material, and gives it a new name
  18337. * @param name defines the new name for the duplicated material
  18338. * @returns the cloned material
  18339. */
  18340. clone(name: string): Nullable<Material>;
  18341. /**
  18342. * Gets the meshes bound to the material
  18343. * @returns an array of meshes bound to the material
  18344. */
  18345. getBindedMeshes(): AbstractMesh[];
  18346. /**
  18347. * Force shader compilation
  18348. * @param mesh defines the mesh associated with this material
  18349. * @param onCompiled defines a function to execute once the material is compiled
  18350. * @param options defines the options to configure the compilation
  18351. */
  18352. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18353. clipPlane: boolean;
  18354. }>): void;
  18355. /**
  18356. * Force shader compilation
  18357. * @param mesh defines the mesh that will use this material
  18358. * @param options defines additional options for compiling the shaders
  18359. * @returns a promise that resolves when the compilation completes
  18360. */
  18361. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18362. clipPlane: boolean;
  18363. }>): Promise<void>;
  18364. private static readonly _ImageProcessingDirtyCallBack;
  18365. private static readonly _TextureDirtyCallBack;
  18366. private static readonly _FresnelDirtyCallBack;
  18367. private static readonly _MiscDirtyCallBack;
  18368. private static readonly _LightsDirtyCallBack;
  18369. private static readonly _AttributeDirtyCallBack;
  18370. private static _FresnelAndMiscDirtyCallBack;
  18371. private static _TextureAndMiscDirtyCallBack;
  18372. private static readonly _DirtyCallbackArray;
  18373. private static readonly _RunDirtyCallBacks;
  18374. /**
  18375. * Marks a define in the material to indicate that it needs to be re-computed
  18376. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18377. */
  18378. markAsDirty(flag: number): void;
  18379. /**
  18380. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18381. * @param func defines a function which checks material defines against the submeshes
  18382. */
  18383. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18384. /**
  18385. * Indicates that image processing needs to be re-calculated for all submeshes
  18386. */
  18387. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18388. /**
  18389. * Indicates that textures need to be re-calculated for all submeshes
  18390. */
  18391. protected _markAllSubMeshesAsTexturesDirty(): void;
  18392. /**
  18393. * Indicates that fresnel needs to be re-calculated for all submeshes
  18394. */
  18395. protected _markAllSubMeshesAsFresnelDirty(): void;
  18396. /**
  18397. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18398. */
  18399. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18400. /**
  18401. * Indicates that lights need to be re-calculated for all submeshes
  18402. */
  18403. protected _markAllSubMeshesAsLightsDirty(): void;
  18404. /**
  18405. * Indicates that attributes need to be re-calculated for all submeshes
  18406. */
  18407. protected _markAllSubMeshesAsAttributesDirty(): void;
  18408. /**
  18409. * Indicates that misc needs to be re-calculated for all submeshes
  18410. */
  18411. protected _markAllSubMeshesAsMiscDirty(): void;
  18412. /**
  18413. * Indicates that textures and misc need to be re-calculated for all submeshes
  18414. */
  18415. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18416. /**
  18417. * Disposes the material
  18418. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18419. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18420. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18421. */
  18422. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18423. /** @hidden */
  18424. private releaseVertexArrayObject;
  18425. /**
  18426. * Serializes this material
  18427. * @returns the serialized material object
  18428. */
  18429. serialize(): any;
  18430. /**
  18431. * Creates a MultiMaterial from parsed MultiMaterial data.
  18432. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18433. * @param scene defines the hosting scene
  18434. * @returns a new MultiMaterial
  18435. */
  18436. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18437. /**
  18438. * Creates a material from parsed material data
  18439. * @param parsedMaterial defines parsed material data
  18440. * @param scene defines the hosting scene
  18441. * @param rootUrl defines the root URL to use to load textures
  18442. * @returns a new material
  18443. */
  18444. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18445. }
  18446. }
  18447. declare module BABYLON {
  18448. /**
  18449. * "Static Class" containing the most commonly used helper while dealing with material for
  18450. * rendering purpose.
  18451. *
  18452. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18453. *
  18454. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18455. */
  18456. class MaterialHelper {
  18457. /**
  18458. * Bind the current view position to an effect.
  18459. * @param effect The effect to be bound
  18460. * @param scene The scene the eyes position is used from
  18461. */
  18462. static BindEyePosition(effect: Effect, scene: Scene): void;
  18463. /**
  18464. * Helps preparing the defines values about the UVs in used in the effect.
  18465. * UVs are shared as much as we can accross channels in the shaders.
  18466. * @param texture The texture we are preparing the UVs for
  18467. * @param defines The defines to update
  18468. * @param key The channel key "diffuse", "specular"... used in the shader
  18469. */
  18470. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18471. /**
  18472. * Binds a texture matrix value to its corrsponding uniform
  18473. * @param texture The texture to bind the matrix for
  18474. * @param uniformBuffer The uniform buffer receivin the data
  18475. * @param key The channel key "diffuse", "specular"... used in the shader
  18476. */
  18477. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18478. /**
  18479. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18480. * @param mesh defines the current mesh
  18481. * @param scene defines the current scene
  18482. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18483. * @param pointsCloud defines if point cloud rendering has to be turned on
  18484. * @param fogEnabled defines if fog has to be turned on
  18485. * @param alphaTest defines if alpha testing has to be turned on
  18486. * @param defines defines the current list of defines
  18487. */
  18488. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18489. /**
  18490. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18491. * @param scene defines the current scene
  18492. * @param engine defines the current engine
  18493. * @param defines specifies the list of active defines
  18494. * @param useInstances defines if instances have to be turned on
  18495. * @param useClipPlane defines if clip plane have to be turned on
  18496. */
  18497. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18498. /**
  18499. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18500. * @param mesh The mesh containing the geometry data we will draw
  18501. * @param defines The defines to update
  18502. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18503. * @param useBones Precise whether bones should be used or not (override mesh info)
  18504. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18505. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18506. * @returns false if defines are considered not dirty and have not been checked
  18507. */
  18508. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18509. /**
  18510. * Prepares the defines related to the light information passed in parameter
  18511. * @param scene The scene we are intending to draw
  18512. * @param mesh The mesh the effect is compiling for
  18513. * @param defines The defines to update
  18514. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18515. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18516. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18517. * @returns true if normals will be required for the rest of the effect
  18518. */
  18519. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18520. /**
  18521. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18522. * that won t be acctive due to defines being turned off.
  18523. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18524. * @param samplersList The samplers list
  18525. * @param defines The defines helping in the list generation
  18526. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18527. */
  18528. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18529. /**
  18530. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18531. * @param defines The defines to update while falling back
  18532. * @param fallbacks The authorized effect fallbacks
  18533. * @param maxSimultaneousLights The maximum number of lights allowed
  18534. * @param rank the current rank of the Effect
  18535. * @returns The newly affected rank
  18536. */
  18537. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18538. /**
  18539. * Prepares the list of attributes required for morph targets according to the effect defines.
  18540. * @param attribs The current list of supported attribs
  18541. * @param mesh The mesh to prepare the morph targets attributes for
  18542. * @param defines The current Defines of the effect
  18543. */
  18544. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18545. /**
  18546. * Prepares the list of attributes required for bones according to the effect defines.
  18547. * @param attribs The current list of supported attribs
  18548. * @param mesh The mesh to prepare the bones attributes for
  18549. * @param defines The current Defines of the effect
  18550. * @param fallbacks The current efffect fallback strategy
  18551. */
  18552. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18553. /**
  18554. * Prepares the list of attributes required for instances according to the effect defines.
  18555. * @param attribs The current list of supported attribs
  18556. * @param defines The current Defines of the effect
  18557. */
  18558. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18559. /**
  18560. * Binds the light shadow information to the effect for the given mesh.
  18561. * @param light The light containing the generator
  18562. * @param scene The scene the lights belongs to
  18563. * @param mesh The mesh we are binding the information to render
  18564. * @param lightIndex The light index in the effect used to render the mesh
  18565. * @param effect The effect we are binding the data to
  18566. */
  18567. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18568. /**
  18569. * Binds the light information to the effect.
  18570. * @param light The light containing the generator
  18571. * @param effect The effect we are binding the data to
  18572. * @param lightIndex The light index in the effect used to render
  18573. */
  18574. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18575. /**
  18576. * Binds the lights information from the scene to the effect for the given mesh.
  18577. * @param scene The scene the lights belongs to
  18578. * @param mesh The mesh we are binding the information to render
  18579. * @param effect The effect we are binding the data to
  18580. * @param defines The generated defines for the effect
  18581. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18582. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18583. */
  18584. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18585. private static _tempFogColor;
  18586. /**
  18587. * Binds the fog information from the scene to the effect for the given mesh.
  18588. * @param scene The scene the lights belongs to
  18589. * @param mesh The mesh we are binding the information to render
  18590. * @param effect The effect we are binding the data to
  18591. * @param linearSpace Defines if the fog effect is applied in linear space
  18592. */
  18593. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  18594. /**
  18595. * Binds the bones information from the mesh to the effect.
  18596. * @param mesh The mesh we are binding the information to render
  18597. * @param effect The effect we are binding the data to
  18598. */
  18599. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18600. /**
  18601. * Binds the morph targets information from the mesh to the effect.
  18602. * @param abstractMesh The mesh we are binding the information to render
  18603. * @param effect The effect we are binding the data to
  18604. */
  18605. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18606. /**
  18607. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18608. * @param defines The generated defines used in the effect
  18609. * @param effect The effect we are binding the data to
  18610. * @param scene The scene we are willing to render with logarithmic scale for
  18611. */
  18612. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18613. /**
  18614. * Binds the clip plane information from the scene to the effect.
  18615. * @param scene The scene the clip plane information are extracted from
  18616. * @param effect The effect we are binding the data to
  18617. */
  18618. static BindClipPlane(effect: Effect, scene: Scene): void;
  18619. }
  18620. }
  18621. declare module BABYLON {
  18622. /**
  18623. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18624. * separate meshes. This can be use to improve performances.
  18625. * @see http://doc.babylonjs.com/how_to/multi_materials
  18626. */
  18627. class MultiMaterial extends Material {
  18628. private _subMaterials;
  18629. /**
  18630. * Gets or Sets the list of Materials used within the multi material.
  18631. * They need to be ordered according to the submeshes order in the associated mesh
  18632. */
  18633. subMaterials: Nullable<Material>[];
  18634. /**
  18635. * Instantiates a new Multi Material
  18636. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18637. * separate meshes. This can be use to improve performances.
  18638. * @see http://doc.babylonjs.com/how_to/multi_materials
  18639. * @param name Define the name in the scene
  18640. * @param scene Define the scene the material belongs to
  18641. */
  18642. constructor(name: string, scene: Scene);
  18643. private _hookArray;
  18644. /**
  18645. * Get one of the submaterial by its index in the submaterials array
  18646. * @param index The index to look the sub material at
  18647. * @returns The Material if the index has been defined
  18648. */
  18649. getSubMaterial(index: number): Nullable<Material>;
  18650. /**
  18651. * Get the list of active textures for the whole sub materials list.
  18652. * @returns All the textures that will be used during the rendering
  18653. */
  18654. getActiveTextures(): BaseTexture[];
  18655. /**
  18656. * Gets the current class name of the material e.g. "MultiMaterial"
  18657. * Mainly use in serialization.
  18658. * @returns the class name
  18659. */
  18660. getClassName(): string;
  18661. /**
  18662. * Checks if the material is ready to render the requested sub mesh
  18663. * @param mesh Define the mesh the submesh belongs to
  18664. * @param subMesh Define the sub mesh to look readyness for
  18665. * @param useInstances Define whether or not the material is used with instances
  18666. * @returns true if ready, otherwise false
  18667. */
  18668. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18669. /**
  18670. * Clones the current material and its related sub materials
  18671. * @param name Define the name of the newly cloned material
  18672. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18673. * @returns the cloned material
  18674. */
  18675. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18676. /**
  18677. * Serializes the materials into a JSON representation.
  18678. * @returns the JSON representation
  18679. */
  18680. serialize(): any;
  18681. /**
  18682. * Dispose the material and release its associated resources
  18683. * @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)
  18684. * @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)
  18685. */
  18686. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18687. }
  18688. }
  18689. declare module BABYLON {
  18690. /**
  18691. * Base class of materials working in push mode in babylon JS
  18692. * @hidden
  18693. */
  18694. class PushMaterial extends Material {
  18695. protected _activeEffect: Effect;
  18696. protected _normalMatrix: Matrix;
  18697. /**
  18698. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  18699. * This means that the material can keep using a previous shader while a new one is being compiled.
  18700. * This is mostly used when shader parallel compilation is supported (true by default)
  18701. */
  18702. allowShaderHotSwapping: boolean;
  18703. constructor(name: string, scene: Scene);
  18704. getEffect(): Effect;
  18705. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18706. /**
  18707. * Binds the given world matrix to the active effect
  18708. *
  18709. * @param world the matrix to bind
  18710. */
  18711. bindOnlyWorldMatrix(world: Matrix): void;
  18712. /**
  18713. * Binds the given normal matrix to the active effect
  18714. *
  18715. * @param normalMatrix the matrix to bind
  18716. */
  18717. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  18718. bind(world: Matrix, mesh?: Mesh): void;
  18719. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  18720. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  18721. }
  18722. }
  18723. declare module BABYLON {
  18724. /**
  18725. * Defines the options associated with the creation of a shader material.
  18726. */
  18727. interface IShaderMaterialOptions {
  18728. /**
  18729. * Does the material work in alpha blend mode
  18730. */
  18731. needAlphaBlending: boolean;
  18732. /**
  18733. * Does the material work in alpha test mode
  18734. */
  18735. needAlphaTesting: boolean;
  18736. /**
  18737. * The list of attribute names used in the shader
  18738. */
  18739. attributes: string[];
  18740. /**
  18741. * The list of unifrom names used in the shader
  18742. */
  18743. uniforms: string[];
  18744. /**
  18745. * The list of UBO names used in the shader
  18746. */
  18747. uniformBuffers: string[];
  18748. /**
  18749. * The list of sampler names used in the shader
  18750. */
  18751. samplers: string[];
  18752. /**
  18753. * The list of defines used in the shader
  18754. */
  18755. defines: string[];
  18756. }
  18757. /**
  18758. * 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.
  18759. *
  18760. * This returned material effects how the mesh will look based on the code in the shaders.
  18761. *
  18762. * @see http://doc.babylonjs.com/how_to/shader_material
  18763. */
  18764. class ShaderMaterial extends Material {
  18765. private _shaderPath;
  18766. private _options;
  18767. private _textures;
  18768. private _textureArrays;
  18769. private _floats;
  18770. private _ints;
  18771. private _floatsArrays;
  18772. private _colors3;
  18773. private _colors3Arrays;
  18774. private _colors4;
  18775. private _vectors2;
  18776. private _vectors3;
  18777. private _vectors4;
  18778. private _matrices;
  18779. private _matrices3x3;
  18780. private _matrices2x2;
  18781. private _vectors2Arrays;
  18782. private _vectors3Arrays;
  18783. private _cachedWorldViewMatrix;
  18784. private _renderId;
  18785. /**
  18786. * Instantiate a new shader material.
  18787. * 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.
  18788. * This returned material effects how the mesh will look based on the code in the shaders.
  18789. * @see http://doc.babylonjs.com/how_to/shader_material
  18790. * @param name Define the name of the material in the scene
  18791. * @param scene Define the scene the material belongs to
  18792. * @param shaderPath Defines the route to the shader code in one of three ways:
  18793. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  18794. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18795. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18796. * @param options Define the options used to create the shader
  18797. */
  18798. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18799. /**
  18800. * Gets the current class name of the material e.g. "ShaderMaterial"
  18801. * Mainly use in serialization.
  18802. * @returns the class name
  18803. */
  18804. getClassName(): string;
  18805. /**
  18806. * Specifies if the material will require alpha blending
  18807. * @returns a boolean specifying if alpha blending is needed
  18808. */
  18809. needAlphaBlending(): boolean;
  18810. /**
  18811. * Specifies if this material should be rendered in alpha test mode
  18812. * @returns a boolean specifying if an alpha test is needed.
  18813. */
  18814. needAlphaTesting(): boolean;
  18815. private _checkUniform;
  18816. /**
  18817. * Set a texture in the shader.
  18818. * @param name Define the name of the uniform samplers as defined in the shader
  18819. * @param texture Define the texture to bind to this sampler
  18820. * @return the material itself allowing "fluent" like uniform updates
  18821. */
  18822. setTexture(name: string, texture: Texture): ShaderMaterial;
  18823. /**
  18824. * Set a texture array in the shader.
  18825. * @param name Define the name of the uniform sampler array as defined in the shader
  18826. * @param textures Define the list of textures to bind to this sampler
  18827. * @return the material itself allowing "fluent" like uniform updates
  18828. */
  18829. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18830. /**
  18831. * Set a float in the shader.
  18832. * @param name Define the name of the uniform as defined in the shader
  18833. * @param value Define the value to give to the uniform
  18834. * @return the material itself allowing "fluent" like uniform updates
  18835. */
  18836. setFloat(name: string, value: number): ShaderMaterial;
  18837. /**
  18838. * Set a int in the shader.
  18839. * @param name Define the name of the uniform as defined in the shader
  18840. * @param value Define the value to give to the uniform
  18841. * @return the material itself allowing "fluent" like uniform updates
  18842. */
  18843. setInt(name: string, value: number): ShaderMaterial;
  18844. /**
  18845. * Set an array of floats in the shader.
  18846. * @param name Define the name of the uniform as defined in the shader
  18847. * @param value Define the value to give to the uniform
  18848. * @return the material itself allowing "fluent" like uniform updates
  18849. */
  18850. setFloats(name: string, value: number[]): ShaderMaterial;
  18851. /**
  18852. * Set a vec3 in the shader from a Color3.
  18853. * @param name Define the name of the uniform as defined in the shader
  18854. * @param value Define the value to give to the uniform
  18855. * @return the material itself allowing "fluent" like uniform updates
  18856. */
  18857. setColor3(name: string, value: Color3): ShaderMaterial;
  18858. /**
  18859. * Set a vec3 array in the shader from a Color3 array.
  18860. * @param name Define the name of the uniform as defined in the shader
  18861. * @param value Define the value to give to the uniform
  18862. * @return the material itself allowing "fluent" like uniform updates
  18863. */
  18864. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18865. /**
  18866. * Set a vec4 in the shader from a Color4.
  18867. * @param name Define the name of the uniform as defined in the shader
  18868. * @param value Define the value to give to the uniform
  18869. * @return the material itself allowing "fluent" like uniform updates
  18870. */
  18871. setColor4(name: string, value: Color4): ShaderMaterial;
  18872. /**
  18873. * Set a vec2 in the shader from a Vector2.
  18874. * @param name Define the name of the uniform as defined in the shader
  18875. * @param value Define the value to give to the uniform
  18876. * @return the material itself allowing "fluent" like uniform updates
  18877. */
  18878. setVector2(name: string, value: Vector2): ShaderMaterial;
  18879. /**
  18880. * Set a vec3 in the shader from a Vector3.
  18881. * @param name Define the name of the uniform as defined in the shader
  18882. * @param value Define the value to give to the uniform
  18883. * @return the material itself allowing "fluent" like uniform updates
  18884. */
  18885. setVector3(name: string, value: Vector3): ShaderMaterial;
  18886. /**
  18887. * Set a vec4 in the shader from a Vector4.
  18888. * @param name Define the name of the uniform as defined in the shader
  18889. * @param value Define the value to give to the uniform
  18890. * @return the material itself allowing "fluent" like uniform updates
  18891. */
  18892. setVector4(name: string, value: Vector4): ShaderMaterial;
  18893. /**
  18894. * Set a mat4 in the shader from a Matrix.
  18895. * @param name Define the name of the uniform as defined in the shader
  18896. * @param value Define the value to give to the uniform
  18897. * @return the material itself allowing "fluent" like uniform updates
  18898. */
  18899. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18900. /**
  18901. * Set a mat3 in the shader from a Float32Array.
  18902. * @param name Define the name of the uniform as defined in the shader
  18903. * @param value Define the value to give to the uniform
  18904. * @return the material itself allowing "fluent" like uniform updates
  18905. */
  18906. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18907. /**
  18908. * Set a mat2 in the shader from a Float32Array.
  18909. * @param name Define the name of the uniform as defined in the shader
  18910. * @param value Define the value to give to the uniform
  18911. * @return the material itself allowing "fluent" like uniform updates
  18912. */
  18913. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18914. /**
  18915. * Set a vec2 array in the shader from a number array.
  18916. * @param name Define the name of the uniform as defined in the shader
  18917. * @param value Define the value to give to the uniform
  18918. * @return the material itself allowing "fluent" like uniform updates
  18919. */
  18920. setArray2(name: string, value: number[]): ShaderMaterial;
  18921. /**
  18922. * Set a vec3 array in the shader from a number array.
  18923. * @param name Define the name of the uniform as defined in the shader
  18924. * @param value Define the value to give to the uniform
  18925. * @return the material itself allowing "fluent" like uniform updates
  18926. */
  18927. setArray3(name: string, value: number[]): ShaderMaterial;
  18928. private _checkCache;
  18929. /**
  18930. * Checks if the material is ready to render the requested mesh
  18931. * @param mesh Define the mesh to render
  18932. * @param useInstances Define whether or not the material is used with instances
  18933. * @returns true if ready, otherwise false
  18934. */
  18935. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18936. /**
  18937. * Binds the world matrix to the material
  18938. * @param world defines the world transformation matrix
  18939. */
  18940. bindOnlyWorldMatrix(world: Matrix): void;
  18941. /**
  18942. * Binds the material to the mesh
  18943. * @param world defines the world transformation matrix
  18944. * @param mesh defines the mesh to bind the material to
  18945. */
  18946. bind(world: Matrix, mesh?: Mesh): void;
  18947. /**
  18948. * Gets the active textures from the material
  18949. * @returns an array of textures
  18950. */
  18951. getActiveTextures(): BaseTexture[];
  18952. /**
  18953. * Specifies if the material uses a texture
  18954. * @param texture defines the texture to check against the material
  18955. * @returns a boolean specifying if the material uses the texture
  18956. */
  18957. hasTexture(texture: BaseTexture): boolean;
  18958. /**
  18959. * Makes a duplicate of the material, and gives it a new name
  18960. * @param name defines the new name for the duplicated material
  18961. * @returns the cloned material
  18962. */
  18963. clone(name: string): ShaderMaterial;
  18964. /**
  18965. * Disposes the material
  18966. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18967. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18968. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18969. */
  18970. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18971. /**
  18972. * Serializes this material in a JSON representation
  18973. * @returns the serialized material object
  18974. */
  18975. serialize(): any;
  18976. /**
  18977. * Creates a shader material from parsed shader material data
  18978. * @param source defines the JSON represnetation of the material
  18979. * @param scene defines the hosting scene
  18980. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18981. * @returns a new material
  18982. */
  18983. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18984. }
  18985. }
  18986. declare module BABYLON {
  18987. /** @hidden */
  18988. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  18989. MAINUV1: boolean;
  18990. MAINUV2: boolean;
  18991. DIFFUSE: boolean;
  18992. DIFFUSEDIRECTUV: number;
  18993. AMBIENT: boolean;
  18994. AMBIENTDIRECTUV: number;
  18995. OPACITY: boolean;
  18996. OPACITYDIRECTUV: number;
  18997. OPACITYRGB: boolean;
  18998. REFLECTION: boolean;
  18999. EMISSIVE: boolean;
  19000. EMISSIVEDIRECTUV: number;
  19001. SPECULAR: boolean;
  19002. SPECULARDIRECTUV: number;
  19003. BUMP: boolean;
  19004. BUMPDIRECTUV: number;
  19005. PARALLAX: boolean;
  19006. PARALLAXOCCLUSION: boolean;
  19007. SPECULAROVERALPHA: boolean;
  19008. CLIPPLANE: boolean;
  19009. CLIPPLANE2: boolean;
  19010. CLIPPLANE3: boolean;
  19011. CLIPPLANE4: boolean;
  19012. ALPHATEST: boolean;
  19013. DEPTHPREPASS: boolean;
  19014. ALPHAFROMDIFFUSE: boolean;
  19015. POINTSIZE: boolean;
  19016. FOG: boolean;
  19017. SPECULARTERM: boolean;
  19018. DIFFUSEFRESNEL: boolean;
  19019. OPACITYFRESNEL: boolean;
  19020. REFLECTIONFRESNEL: boolean;
  19021. REFRACTIONFRESNEL: boolean;
  19022. EMISSIVEFRESNEL: boolean;
  19023. FRESNEL: boolean;
  19024. NORMAL: boolean;
  19025. UV1: boolean;
  19026. UV2: boolean;
  19027. VERTEXCOLOR: boolean;
  19028. VERTEXALPHA: boolean;
  19029. NUM_BONE_INFLUENCERS: number;
  19030. BonesPerMesh: number;
  19031. BONETEXTURE: boolean;
  19032. INSTANCES: boolean;
  19033. GLOSSINESS: boolean;
  19034. ROUGHNESS: boolean;
  19035. EMISSIVEASILLUMINATION: boolean;
  19036. LINKEMISSIVEWITHDIFFUSE: boolean;
  19037. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19038. LIGHTMAP: boolean;
  19039. LIGHTMAPDIRECTUV: number;
  19040. OBJECTSPACE_NORMALMAP: boolean;
  19041. USELIGHTMAPASSHADOWMAP: boolean;
  19042. REFLECTIONMAP_3D: boolean;
  19043. REFLECTIONMAP_SPHERICAL: boolean;
  19044. REFLECTIONMAP_PLANAR: boolean;
  19045. REFLECTIONMAP_CUBIC: boolean;
  19046. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19047. REFLECTIONMAP_PROJECTION: boolean;
  19048. REFLECTIONMAP_SKYBOX: boolean;
  19049. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  19050. REFLECTIONMAP_EXPLICIT: boolean;
  19051. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19052. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19053. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19054. INVERTCUBICMAP: boolean;
  19055. LOGARITHMICDEPTH: boolean;
  19056. REFRACTION: boolean;
  19057. REFRACTIONMAP_3D: boolean;
  19058. REFLECTIONOVERALPHA: boolean;
  19059. TWOSIDEDLIGHTING: boolean;
  19060. SHADOWFLOAT: boolean;
  19061. MORPHTARGETS: boolean;
  19062. MORPHTARGETS_NORMAL: boolean;
  19063. MORPHTARGETS_TANGENT: boolean;
  19064. NUM_MORPH_INFLUENCERS: number;
  19065. NONUNIFORMSCALING: boolean;
  19066. PREMULTIPLYALPHA: boolean;
  19067. IMAGEPROCESSING: boolean;
  19068. VIGNETTE: boolean;
  19069. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19070. VIGNETTEBLENDMODEOPAQUE: boolean;
  19071. TONEMAPPING: boolean;
  19072. TONEMAPPING_ACES: boolean;
  19073. CONTRAST: boolean;
  19074. COLORCURVES: boolean;
  19075. COLORGRADING: boolean;
  19076. COLORGRADING3D: boolean;
  19077. SAMPLER3DGREENDEPTH: boolean;
  19078. SAMPLER3DBGRMAP: boolean;
  19079. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19080. /**
  19081. * If the reflection texture on this material is in linear color space
  19082. * @hidden
  19083. */
  19084. IS_REFLECTION_LINEAR: boolean;
  19085. /**
  19086. * If the refraction texture on this material is in linear color space
  19087. * @hidden
  19088. */
  19089. IS_REFRACTION_LINEAR: boolean;
  19090. EXPOSURE: boolean;
  19091. constructor();
  19092. setReflectionMode(modeToEnable: string): void;
  19093. }
  19094. /**
  19095. * This is the default material used in Babylon. It is the best trade off between quality
  19096. * and performances.
  19097. * @see http://doc.babylonjs.com/babylon101/materials
  19098. */
  19099. class StandardMaterial extends PushMaterial {
  19100. private _diffuseTexture;
  19101. /**
  19102. * The basic texture of the material as viewed under a light.
  19103. */
  19104. diffuseTexture: Nullable<BaseTexture>;
  19105. private _ambientTexture;
  19106. /**
  19107. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19108. */
  19109. ambientTexture: Nullable<BaseTexture>;
  19110. private _opacityTexture;
  19111. /**
  19112. * Define the transparency of the material from a texture.
  19113. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19114. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19115. */
  19116. opacityTexture: Nullable<BaseTexture>;
  19117. private _reflectionTexture;
  19118. /**
  19119. * Define the texture used to display the reflection.
  19120. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19121. */
  19122. reflectionTexture: Nullable<BaseTexture>;
  19123. private _emissiveTexture;
  19124. /**
  19125. * Define texture of the material as if self lit.
  19126. * This will be mixed in the final result even in the absence of light.
  19127. */
  19128. emissiveTexture: Nullable<BaseTexture>;
  19129. private _specularTexture;
  19130. /**
  19131. * Define how the color and intensity of the highlight given by the light in the material.
  19132. */
  19133. specularTexture: Nullable<BaseTexture>;
  19134. private _bumpTexture;
  19135. /**
  19136. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19137. * 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.
  19138. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  19139. */
  19140. bumpTexture: Nullable<BaseTexture>;
  19141. private _lightmapTexture;
  19142. /**
  19143. * Complex lighting can be computationally expensive to compute at runtime.
  19144. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19145. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  19146. */
  19147. lightmapTexture: Nullable<BaseTexture>;
  19148. private _refractionTexture;
  19149. /**
  19150. * Define the texture used to display the refraction.
  19151. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19152. */
  19153. refractionTexture: Nullable<BaseTexture>;
  19154. /**
  19155. * The color of the material lit by the environmental background lighting.
  19156. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19157. */
  19158. ambientColor: Color3;
  19159. /**
  19160. * The basic color of the material as viewed under a light.
  19161. */
  19162. diffuseColor: Color3;
  19163. /**
  19164. * Define how the color and intensity of the highlight given by the light in the material.
  19165. */
  19166. specularColor: Color3;
  19167. /**
  19168. * Define the color of the material as if self lit.
  19169. * This will be mixed in the final result even in the absence of light.
  19170. */
  19171. emissiveColor: Color3;
  19172. /**
  19173. * Defines how sharp are the highlights in the material.
  19174. * The bigger the value the sharper giving a more glossy feeling to the result.
  19175. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19176. */
  19177. specularPower: number;
  19178. private _useAlphaFromDiffuseTexture;
  19179. /**
  19180. * Does the transparency come from the diffuse texture alpha channel.
  19181. */
  19182. useAlphaFromDiffuseTexture: boolean;
  19183. private _useEmissiveAsIllumination;
  19184. /**
  19185. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19186. */
  19187. useEmissiveAsIllumination: boolean;
  19188. private _linkEmissiveWithDiffuse;
  19189. /**
  19190. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19191. * the emissive level when the final color is close to one.
  19192. */
  19193. linkEmissiveWithDiffuse: boolean;
  19194. private _useSpecularOverAlpha;
  19195. /**
  19196. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19197. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19198. */
  19199. useSpecularOverAlpha: boolean;
  19200. private _useReflectionOverAlpha;
  19201. /**
  19202. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19203. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19204. */
  19205. useReflectionOverAlpha: boolean;
  19206. private _disableLighting;
  19207. /**
  19208. * Does lights from the scene impacts this material.
  19209. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19210. */
  19211. disableLighting: boolean;
  19212. private _useObjectSpaceNormalMap;
  19213. /**
  19214. * Allows using an object space normal map (instead of tangent space).
  19215. */
  19216. useObjectSpaceNormalMap: boolean;
  19217. private _useParallax;
  19218. /**
  19219. * Is parallax enabled or not.
  19220. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19221. */
  19222. useParallax: boolean;
  19223. private _useParallaxOcclusion;
  19224. /**
  19225. * Is parallax occlusion enabled or not.
  19226. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19227. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19228. */
  19229. useParallaxOcclusion: boolean;
  19230. /**
  19231. * 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.
  19232. */
  19233. parallaxScaleBias: number;
  19234. private _roughness;
  19235. /**
  19236. * Helps to define how blurry the reflections should appears in the material.
  19237. */
  19238. roughness: number;
  19239. /**
  19240. * In case of refraction, define the value of the indice of refraction.
  19241. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19242. */
  19243. indexOfRefraction: number;
  19244. /**
  19245. * Invert the refraction texture alongside the y axis.
  19246. * It can be usefull with procedural textures or probe for instance.
  19247. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19248. */
  19249. invertRefractionY: boolean;
  19250. /**
  19251. * Defines the alpha limits in alpha test mode.
  19252. */
  19253. alphaCutOff: number;
  19254. private _useLightmapAsShadowmap;
  19255. /**
  19256. * In case of light mapping, define whether the map contains light or shadow informations.
  19257. */
  19258. useLightmapAsShadowmap: boolean;
  19259. private _diffuseFresnelParameters;
  19260. /**
  19261. * Define the diffuse fresnel parameters of the material.
  19262. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19263. */
  19264. diffuseFresnelParameters: FresnelParameters;
  19265. private _opacityFresnelParameters;
  19266. /**
  19267. * Define the opacity fresnel parameters of the material.
  19268. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19269. */
  19270. opacityFresnelParameters: FresnelParameters;
  19271. private _reflectionFresnelParameters;
  19272. /**
  19273. * Define the reflection fresnel parameters of the material.
  19274. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19275. */
  19276. reflectionFresnelParameters: FresnelParameters;
  19277. private _refractionFresnelParameters;
  19278. /**
  19279. * Define the refraction fresnel parameters of the material.
  19280. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19281. */
  19282. refractionFresnelParameters: FresnelParameters;
  19283. private _emissiveFresnelParameters;
  19284. /**
  19285. * Define the emissive fresnel parameters of the material.
  19286. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19287. */
  19288. emissiveFresnelParameters: FresnelParameters;
  19289. private _useReflectionFresnelFromSpecular;
  19290. /**
  19291. * If true automatically deducts the fresnels values from the material specularity.
  19292. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19293. */
  19294. useReflectionFresnelFromSpecular: boolean;
  19295. private _useGlossinessFromSpecularMapAlpha;
  19296. /**
  19297. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19298. */
  19299. useGlossinessFromSpecularMapAlpha: boolean;
  19300. private _maxSimultaneousLights;
  19301. /**
  19302. * Defines the maximum number of lights that can be used in the material
  19303. */
  19304. maxSimultaneousLights: number;
  19305. private _invertNormalMapX;
  19306. /**
  19307. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19308. */
  19309. invertNormalMapX: boolean;
  19310. private _invertNormalMapY;
  19311. /**
  19312. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19313. */
  19314. invertNormalMapY: boolean;
  19315. private _twoSidedLighting;
  19316. /**
  19317. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19318. */
  19319. twoSidedLighting: boolean;
  19320. /**
  19321. * Default configuration related to image processing available in the standard Material.
  19322. */
  19323. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19324. /**
  19325. * Gets the image processing configuration used either in this material.
  19326. */
  19327. /**
  19328. * Sets the Default image processing configuration used either in the this material.
  19329. *
  19330. * If sets to null, the scene one is in use.
  19331. */
  19332. imageProcessingConfiguration: ImageProcessingConfiguration;
  19333. /**
  19334. * Keep track of the image processing observer to allow dispose and replace.
  19335. */
  19336. private _imageProcessingObserver;
  19337. /**
  19338. * Attaches a new image processing configuration to the Standard Material.
  19339. * @param configuration
  19340. */
  19341. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19342. /**
  19343. * Gets wether the color curves effect is enabled.
  19344. */
  19345. /**
  19346. * Sets wether the color curves effect is enabled.
  19347. */
  19348. cameraColorCurvesEnabled: boolean;
  19349. /**
  19350. * Gets wether the color grading effect is enabled.
  19351. */
  19352. /**
  19353. * Gets wether the color grading effect is enabled.
  19354. */
  19355. cameraColorGradingEnabled: boolean;
  19356. /**
  19357. * Gets wether tonemapping is enabled or not.
  19358. */
  19359. /**
  19360. * Sets wether tonemapping is enabled or not
  19361. */
  19362. cameraToneMappingEnabled: boolean;
  19363. /**
  19364. * The camera exposure used on this material.
  19365. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19366. * This corresponds to a photographic exposure.
  19367. */
  19368. /**
  19369. * The camera exposure used on this material.
  19370. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19371. * This corresponds to a photographic exposure.
  19372. */
  19373. cameraExposure: number;
  19374. /**
  19375. * Gets The camera contrast used on this material.
  19376. */
  19377. /**
  19378. * Sets The camera contrast used on this material.
  19379. */
  19380. cameraContrast: number;
  19381. /**
  19382. * Gets the Color Grading 2D Lookup Texture.
  19383. */
  19384. /**
  19385. * Sets the Color Grading 2D Lookup Texture.
  19386. */
  19387. cameraColorGradingTexture: Nullable<BaseTexture>;
  19388. /**
  19389. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19390. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19391. * 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;
  19392. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19393. */
  19394. /**
  19395. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19396. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19397. * 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;
  19398. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19399. */
  19400. cameraColorCurves: Nullable<ColorCurves>;
  19401. /**
  19402. * Custom callback helping to override the default shader used in the material.
  19403. */
  19404. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19405. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19406. protected _worldViewProjectionMatrix: Matrix;
  19407. protected _globalAmbientColor: Color3;
  19408. protected _useLogarithmicDepth: boolean;
  19409. /**
  19410. * Instantiates a new standard material.
  19411. * This is the default material used in Babylon. It is the best trade off between quality
  19412. * and performances.
  19413. * @see http://doc.babylonjs.com/babylon101/materials
  19414. * @param name Define the name of the material in the scene
  19415. * @param scene Define the scene the material belong to
  19416. */
  19417. constructor(name: string, scene: Scene);
  19418. /**
  19419. * Gets a boolean indicating that current material needs to register RTT
  19420. */
  19421. readonly hasRenderTargetTextures: boolean;
  19422. /**
  19423. * Gets the current class name of the material e.g. "StandardMaterial"
  19424. * Mainly use in serialization.
  19425. * @returns the class name
  19426. */
  19427. getClassName(): string;
  19428. /**
  19429. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19430. * You can try switching to logarithmic depth.
  19431. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19432. */
  19433. useLogarithmicDepth: boolean;
  19434. /**
  19435. * Specifies if the material will require alpha blending
  19436. * @returns a boolean specifying if alpha blending is needed
  19437. */
  19438. needAlphaBlending(): boolean;
  19439. /**
  19440. * Specifies if this material should be rendered in alpha test mode
  19441. * @returns a boolean specifying if an alpha test is needed.
  19442. */
  19443. needAlphaTesting(): boolean;
  19444. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19445. /**
  19446. * Get the texture used for alpha test purpose.
  19447. * @returns the diffuse texture in case of the standard material.
  19448. */
  19449. getAlphaTestTexture(): Nullable<BaseTexture>;
  19450. /**
  19451. * Get if the submesh is ready to be used and all its information available.
  19452. * Child classes can use it to update shaders
  19453. * @param mesh defines the mesh to check
  19454. * @param subMesh defines which submesh to check
  19455. * @param useInstances specifies that instances should be used
  19456. * @returns a boolean indicating that the submesh is ready or not
  19457. */
  19458. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19459. /**
  19460. * Builds the material UBO layouts.
  19461. * Used internally during the effect preparation.
  19462. */
  19463. buildUniformLayout(): void;
  19464. /**
  19465. * Unbinds the material from the mesh
  19466. */
  19467. unbind(): void;
  19468. /**
  19469. * Binds the submesh to this material by preparing the effect and shader to draw
  19470. * @param world defines the world transformation matrix
  19471. * @param mesh defines the mesh containing the submesh
  19472. * @param subMesh defines the submesh to bind the material to
  19473. */
  19474. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19475. /**
  19476. * Get the list of animatables in the material.
  19477. * @returns the list of animatables object used in the material
  19478. */
  19479. getAnimatables(): IAnimatable[];
  19480. /**
  19481. * Gets the active textures from the material
  19482. * @returns an array of textures
  19483. */
  19484. getActiveTextures(): BaseTexture[];
  19485. /**
  19486. * Specifies if the material uses a texture
  19487. * @param texture defines the texture to check against the material
  19488. * @returns a boolean specifying if the material uses the texture
  19489. */
  19490. hasTexture(texture: BaseTexture): boolean;
  19491. /**
  19492. * Disposes the material
  19493. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19494. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19495. */
  19496. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19497. /**
  19498. * Makes a duplicate of the material, and gives it a new name
  19499. * @param name defines the new name for the duplicated material
  19500. * @returns the cloned material
  19501. */
  19502. clone(name: string): StandardMaterial;
  19503. /**
  19504. * Serializes this material in a JSON representation
  19505. * @returns the serialized material object
  19506. */
  19507. serialize(): any;
  19508. /**
  19509. * Creates a standard material from parsed material data
  19510. * @param source defines the JSON represnetation of the material
  19511. * @param scene defines the hosting scene
  19512. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19513. * @returns a new material
  19514. */
  19515. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19516. private static _DiffuseTextureEnabled;
  19517. /**
  19518. * Are diffuse textures enabled in the application.
  19519. */
  19520. static DiffuseTextureEnabled: boolean;
  19521. private static _AmbientTextureEnabled;
  19522. /**
  19523. * Are ambient textures enabled in the application.
  19524. */
  19525. static AmbientTextureEnabled: boolean;
  19526. private static _OpacityTextureEnabled;
  19527. /**
  19528. * Are opacity textures enabled in the application.
  19529. */
  19530. static OpacityTextureEnabled: boolean;
  19531. private static _ReflectionTextureEnabled;
  19532. /**
  19533. * Are reflection textures enabled in the application.
  19534. */
  19535. static ReflectionTextureEnabled: boolean;
  19536. private static _EmissiveTextureEnabled;
  19537. /**
  19538. * Are emissive textures enabled in the application.
  19539. */
  19540. static EmissiveTextureEnabled: boolean;
  19541. private static _SpecularTextureEnabled;
  19542. /**
  19543. * Are specular textures enabled in the application.
  19544. */
  19545. static SpecularTextureEnabled: boolean;
  19546. private static _BumpTextureEnabled;
  19547. /**
  19548. * Are bump textures enabled in the application.
  19549. */
  19550. static BumpTextureEnabled: boolean;
  19551. private static _LightmapTextureEnabled;
  19552. /**
  19553. * Are lightmap textures enabled in the application.
  19554. */
  19555. static LightmapTextureEnabled: boolean;
  19556. private static _RefractionTextureEnabled;
  19557. /**
  19558. * Are refraction textures enabled in the application.
  19559. */
  19560. static RefractionTextureEnabled: boolean;
  19561. private static _ColorGradingTextureEnabled;
  19562. /**
  19563. * Are color grading textures enabled in the application.
  19564. */
  19565. static ColorGradingTextureEnabled: boolean;
  19566. private static _FresnelEnabled;
  19567. /**
  19568. * Are fresnels enabled in the application.
  19569. */
  19570. static FresnelEnabled: boolean;
  19571. }
  19572. }
  19573. declare module BABYLON {
  19574. /**
  19575. * Uniform buffer objects.
  19576. *
  19577. * Handles blocks of uniform on the GPU.
  19578. *
  19579. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19580. *
  19581. * For more information, please refer to :
  19582. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19583. */
  19584. class UniformBuffer {
  19585. private _engine;
  19586. private _buffer;
  19587. private _data;
  19588. private _bufferData;
  19589. private _dynamic?;
  19590. private _uniformLocations;
  19591. private _uniformSizes;
  19592. private _uniformLocationPointer;
  19593. private _needSync;
  19594. private _noUBO;
  19595. private _currentEffect;
  19596. private static _MAX_UNIFORM_SIZE;
  19597. private static _tempBuffer;
  19598. /**
  19599. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  19600. * This is dynamic to allow compat with webgl 1 and 2.
  19601. * You will need to pass the name of the uniform as well as the value.
  19602. */
  19603. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19604. /**
  19605. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  19606. * This is dynamic to allow compat with webgl 1 and 2.
  19607. * You will need to pass the name of the uniform as well as the value.
  19608. */
  19609. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19610. /**
  19611. * Lambda to Update a single float in a uniform buffer.
  19612. * This is dynamic to allow compat with webgl 1 and 2.
  19613. * You will need to pass the name of the uniform as well as the value.
  19614. */
  19615. updateFloat: (name: string, x: number) => void;
  19616. /**
  19617. * Lambda to Update a vec2 of float in a uniform buffer.
  19618. * This is dynamic to allow compat with webgl 1 and 2.
  19619. * You will need to pass the name of the uniform as well as the value.
  19620. */
  19621. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19622. /**
  19623. * Lambda to Update a vec3 of float in a uniform buffer.
  19624. * This is dynamic to allow compat with webgl 1 and 2.
  19625. * You will need to pass the name of the uniform as well as the value.
  19626. */
  19627. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19628. /**
  19629. * Lambda to Update a vec4 of float in a uniform buffer.
  19630. * This is dynamic to allow compat with webgl 1 and 2.
  19631. * You will need to pass the name of the uniform as well as the value.
  19632. */
  19633. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19634. /**
  19635. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  19636. * This is dynamic to allow compat with webgl 1 and 2.
  19637. * You will need to pass the name of the uniform as well as the value.
  19638. */
  19639. updateMatrix: (name: string, mat: Matrix) => void;
  19640. /**
  19641. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  19642. * This is dynamic to allow compat with webgl 1 and 2.
  19643. * You will need to pass the name of the uniform as well as the value.
  19644. */
  19645. updateVector3: (name: string, vector: Vector3) => void;
  19646. /**
  19647. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  19648. * This is dynamic to allow compat with webgl 1 and 2.
  19649. * You will need to pass the name of the uniform as well as the value.
  19650. */
  19651. updateVector4: (name: string, vector: Vector4) => void;
  19652. /**
  19653. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  19654. * This is dynamic to allow compat with webgl 1 and 2.
  19655. * You will need to pass the name of the uniform as well as the value.
  19656. */
  19657. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19658. /**
  19659. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  19660. * This is dynamic to allow compat with webgl 1 and 2.
  19661. * You will need to pass the name of the uniform as well as the value.
  19662. */
  19663. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19664. /**
  19665. * Instantiates a new Uniform buffer objects.
  19666. *
  19667. * Handles blocks of uniform on the GPU.
  19668. *
  19669. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19670. *
  19671. * For more information, please refer to :
  19672. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19673. * @param engine Define the engine the buffer is associated with
  19674. * @param data Define the data contained in the buffer
  19675. * @param dynamic Define if the buffer is updatable
  19676. */
  19677. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19678. /**
  19679. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19680. * or just falling back on setUniformXXX calls.
  19681. */
  19682. readonly useUbo: boolean;
  19683. /**
  19684. * Indicates if the WebGL underlying uniform buffer is in sync
  19685. * with the javascript cache data.
  19686. */
  19687. readonly isSync: boolean;
  19688. /**
  19689. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19690. * Also, a dynamic UniformBuffer will disable cache verification and always
  19691. * update the underlying WebGL uniform buffer to the GPU.
  19692. * @returns if Dynamic, otherwise false
  19693. */
  19694. isDynamic(): boolean;
  19695. /**
  19696. * The data cache on JS side.
  19697. * @returns the underlying data as a float array
  19698. */
  19699. getData(): Float32Array;
  19700. /**
  19701. * The underlying WebGL Uniform buffer.
  19702. * @returns the webgl buffer
  19703. */
  19704. getBuffer(): Nullable<WebGLBuffer>;
  19705. /**
  19706. * std140 layout specifies how to align data within an UBO structure.
  19707. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  19708. * for specs.
  19709. */
  19710. private _fillAlignment;
  19711. /**
  19712. * Adds an uniform in the buffer.
  19713. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  19714. * for the layout to be correct !
  19715. * @param name Name of the uniform, as used in the uniform block in the shader.
  19716. * @param size Data size, or data directly.
  19717. */
  19718. addUniform(name: string, size: number | number[]): void;
  19719. /**
  19720. * Adds a Matrix 4x4 to the uniform buffer.
  19721. * @param name Name of the uniform, as used in the uniform block in the shader.
  19722. * @param mat A 4x4 matrix.
  19723. */
  19724. addMatrix(name: string, mat: Matrix): void;
  19725. /**
  19726. * Adds a vec2 to the uniform buffer.
  19727. * @param name Name of the uniform, as used in the uniform block in the shader.
  19728. * @param x Define the x component value of the vec2
  19729. * @param y Define the y component value of the vec2
  19730. */
  19731. addFloat2(name: string, x: number, y: number): void;
  19732. /**
  19733. * Adds a vec3 to the uniform buffer.
  19734. * @param name Name of the uniform, as used in the uniform block in the shader.
  19735. * @param x Define the x component value of the vec3
  19736. * @param y Define the y component value of the vec3
  19737. * @param z Define the z component value of the vec3
  19738. */
  19739. addFloat3(name: string, x: number, y: number, z: number): void;
  19740. /**
  19741. * Adds a vec3 to the uniform buffer.
  19742. * @param name Name of the uniform, as used in the uniform block in the shader.
  19743. * @param color Define the vec3 from a Color
  19744. */
  19745. addColor3(name: string, color: Color3): void;
  19746. /**
  19747. * Adds a vec4 to the uniform buffer.
  19748. * @param name Name of the uniform, as used in the uniform block in the shader.
  19749. * @param color Define the rgb components from a Color
  19750. * @param alpha Define the a component of the vec4
  19751. */
  19752. addColor4(name: string, color: Color3, alpha: number): void;
  19753. /**
  19754. * Adds a vec3 to the uniform buffer.
  19755. * @param name Name of the uniform, as used in the uniform block in the shader.
  19756. * @param vector Define the vec3 components from a Vector
  19757. */
  19758. addVector3(name: string, vector: Vector3): void;
  19759. /**
  19760. * Adds a Matrix 3x3 to the uniform buffer.
  19761. * @param name Name of the uniform, as used in the uniform block in the shader.
  19762. */
  19763. addMatrix3x3(name: string): void;
  19764. /**
  19765. * Adds a Matrix 2x2 to the uniform buffer.
  19766. * @param name Name of the uniform, as used in the uniform block in the shader.
  19767. */
  19768. addMatrix2x2(name: string): void;
  19769. /**
  19770. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  19771. */
  19772. create(): void;
  19773. /** @hidden */
  19774. _rebuild(): void;
  19775. /**
  19776. * Updates the WebGL Uniform Buffer on the GPU.
  19777. * If the `dynamic` flag is set to true, no cache comparison is done.
  19778. * Otherwise, the buffer will be updated only if the cache differs.
  19779. */
  19780. update(): void;
  19781. /**
  19782. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  19783. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19784. * @param data Define the flattened data
  19785. * @param size Define the size of the data.
  19786. */
  19787. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  19788. private _updateMatrix3x3ForUniform;
  19789. private _updateMatrix3x3ForEffect;
  19790. private _updateMatrix2x2ForEffect;
  19791. private _updateMatrix2x2ForUniform;
  19792. private _updateFloatForEffect;
  19793. private _updateFloatForUniform;
  19794. private _updateFloat2ForEffect;
  19795. private _updateFloat2ForUniform;
  19796. private _updateFloat3ForEffect;
  19797. private _updateFloat3ForUniform;
  19798. private _updateFloat4ForEffect;
  19799. private _updateFloat4ForUniform;
  19800. private _updateMatrixForEffect;
  19801. private _updateMatrixForUniform;
  19802. private _updateVector3ForEffect;
  19803. private _updateVector3ForUniform;
  19804. private _updateVector4ForEffect;
  19805. private _updateVector4ForUniform;
  19806. private _updateColor3ForEffect;
  19807. private _updateColor3ForUniform;
  19808. private _updateColor4ForEffect;
  19809. private _updateColor4ForUniform;
  19810. /**
  19811. * Sets a sampler uniform on the effect.
  19812. * @param name Define the name of the sampler.
  19813. * @param texture Define the texture to set in the sampler
  19814. */
  19815. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  19816. /**
  19817. * Directly updates the value of the uniform in the cache AND on the GPU.
  19818. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19819. * @param data Define the flattened data
  19820. */
  19821. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  19822. /**
  19823. * Binds this uniform buffer to an effect.
  19824. * @param effect Define the effect to bind the buffer to
  19825. * @param name Name of the uniform block in the shader.
  19826. */
  19827. bindToEffect(effect: Effect, name: string): void;
  19828. /**
  19829. * Disposes the uniform buffer.
  19830. */
  19831. dispose(): void;
  19832. }
  19833. }
  19834. declare module BABYLON {
  19835. /**
  19836. * Scalar computation library
  19837. */
  19838. class Scalar {
  19839. /**
  19840. * Two pi constants convenient for computation.
  19841. */
  19842. static TwoPi: number;
  19843. /**
  19844. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19845. * @param a number
  19846. * @param b number
  19847. * @param epsilon (default = 1.401298E-45)
  19848. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19849. */
  19850. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  19851. /**
  19852. * Returns a string : the upper case translation of the number i to hexadecimal.
  19853. * @param i number
  19854. * @returns the upper case translation of the number i to hexadecimal.
  19855. */
  19856. static ToHex(i: number): string;
  19857. /**
  19858. * Returns -1 if value is negative and +1 is value is positive.
  19859. * @param value the value
  19860. * @returns the value itself if it's equal to zero.
  19861. */
  19862. static Sign(value: number): number;
  19863. /**
  19864. * Returns the value itself if it's between min and max.
  19865. * Returns min if the value is lower than min.
  19866. * Returns max if the value is greater than max.
  19867. * @param value the value to clmap
  19868. * @param min the min value to clamp to (default: 0)
  19869. * @param max the max value to clamp to (default: 1)
  19870. * @returns the clamped value
  19871. */
  19872. static Clamp(value: number, min?: number, max?: number): number;
  19873. /**
  19874. * the log2 of value.
  19875. * @param value the value to compute log2 of
  19876. * @returns the log2 of value.
  19877. */
  19878. static Log2(value: number): number;
  19879. /**
  19880. * Loops the value, so that it is never larger than length and never smaller than 0.
  19881. *
  19882. * This is similar to the modulo operator but it works with floating point numbers.
  19883. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  19884. * With t = 5 and length = 2.5, the result would be 0.0.
  19885. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  19886. * @param value the value
  19887. * @param length the length
  19888. * @returns the looped value
  19889. */
  19890. static Repeat(value: number, length: number): number;
  19891. /**
  19892. * Normalize the value between 0.0 and 1.0 using min and max values
  19893. * @param value value to normalize
  19894. * @param min max to normalize between
  19895. * @param max min to normalize between
  19896. * @returns the normalized value
  19897. */
  19898. static Normalize(value: number, min: number, max: number): number;
  19899. /**
  19900. * Denormalize the value from 0.0 and 1.0 using min and max values
  19901. * @param normalized value to denormalize
  19902. * @param min max to denormalize between
  19903. * @param max min to denormalize between
  19904. * @returns the denormalized value
  19905. */
  19906. static Denormalize(normalized: number, min: number, max: number): number;
  19907. /**
  19908. * Calculates the shortest difference between two given angles given in degrees.
  19909. * @param current current angle in degrees
  19910. * @param target target angle in degrees
  19911. * @returns the delta
  19912. */
  19913. static DeltaAngle(current: number, target: number): number;
  19914. /**
  19915. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  19916. * @param tx value
  19917. * @param length length
  19918. * @returns The returned value will move back and forth between 0 and length
  19919. */
  19920. static PingPong(tx: number, length: number): number;
  19921. /**
  19922. * Interpolates between min and max with smoothing at the limits.
  19923. *
  19924. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  19925. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  19926. * @param from from
  19927. * @param to to
  19928. * @param tx value
  19929. * @returns the smooth stepped value
  19930. */
  19931. static SmoothStep(from: number, to: number, tx: number): number;
  19932. /**
  19933. * Moves a value current towards target.
  19934. *
  19935. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  19936. * Negative values of maxDelta pushes the value away from target.
  19937. * @param current current value
  19938. * @param target target value
  19939. * @param maxDelta max distance to move
  19940. * @returns resulting value
  19941. */
  19942. static MoveTowards(current: number, target: number, maxDelta: number): number;
  19943. /**
  19944. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19945. *
  19946. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  19947. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  19948. * @param current current value
  19949. * @param target target value
  19950. * @param maxDelta max distance to move
  19951. * @returns resulting angle
  19952. */
  19953. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  19954. /**
  19955. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  19956. * @param start start value
  19957. * @param end target value
  19958. * @param amount amount to lerp between
  19959. * @returns the lerped value
  19960. */
  19961. static Lerp(start: number, end: number, amount: number): number;
  19962. /**
  19963. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19964. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  19965. * @param start start value
  19966. * @param end target value
  19967. * @param amount amount to lerp between
  19968. * @returns the lerped value
  19969. */
  19970. static LerpAngle(start: number, end: number, amount: number): number;
  19971. /**
  19972. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  19973. * @param a start value
  19974. * @param b target value
  19975. * @param value value between a and b
  19976. * @returns the inverseLerp value
  19977. */
  19978. static InverseLerp(a: number, b: number, value: number): number;
  19979. /**
  19980. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  19981. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  19982. * @param value1 spline value
  19983. * @param tangent1 spline value
  19984. * @param value2 spline value
  19985. * @param tangent2 spline value
  19986. * @param amount input value
  19987. * @returns hermite result
  19988. */
  19989. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  19990. /**
  19991. * Returns a random float number between and min and max values
  19992. * @param min min value of random
  19993. * @param max max value of random
  19994. * @returns random value
  19995. */
  19996. static RandomRange(min: number, max: number): number;
  19997. /**
  19998. * This function returns percentage of a number in a given range.
  19999. *
  20000. * RangeToPercent(40,20,60) will return 0.5 (50%)
  20001. * RangeToPercent(34,0,100) will return 0.34 (34%)
  20002. * @param number to convert to percentage
  20003. * @param min min range
  20004. * @param max max range
  20005. * @returns the percentage
  20006. */
  20007. static RangeToPercent(number: number, min: number, max: number): number;
  20008. /**
  20009. * This function returns number that corresponds to the percentage in a given range.
  20010. *
  20011. * PercentToRange(0.34,0,100) will return 34.
  20012. * @param percent to convert to number
  20013. * @param min min range
  20014. * @param max max range
  20015. * @returns the number
  20016. */
  20017. static PercentToRange(percent: number, min: number, max: number): number;
  20018. /**
  20019. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  20020. * @param angle The angle to normalize in radian.
  20021. * @return The converted angle.
  20022. */
  20023. static NormalizeRadians(angle: number): number;
  20024. }
  20025. }
  20026. declare module BABYLON {
  20027. /**
  20028. * Constant used to convert a value to gamma space
  20029. * @ignorenaming
  20030. */
  20031. const ToGammaSpace: number;
  20032. /**
  20033. * Constant used to convert a value to linear space
  20034. * @ignorenaming
  20035. */
  20036. const ToLinearSpace = 2.2;
  20037. /**
  20038. * Constant used to define the minimal number value in Babylon.js
  20039. * @ignorenaming
  20040. */
  20041. const Epsilon = 0.001;
  20042. /**
  20043. * Class used to hold a RBG color
  20044. */
  20045. class Color3 {
  20046. /**
  20047. * Defines the red component (between 0 and 1, default is 0)
  20048. */
  20049. r: number;
  20050. /**
  20051. * Defines the green component (between 0 and 1, default is 0)
  20052. */
  20053. g: number;
  20054. /**
  20055. * Defines the blue component (between 0 and 1, default is 0)
  20056. */
  20057. b: number;
  20058. /**
  20059. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  20060. * @param r defines the red component (between 0 and 1, default is 0)
  20061. * @param g defines the green component (between 0 and 1, default is 0)
  20062. * @param b defines the blue component (between 0 and 1, default is 0)
  20063. */
  20064. constructor(
  20065. /**
  20066. * Defines the red component (between 0 and 1, default is 0)
  20067. */
  20068. r?: number,
  20069. /**
  20070. * Defines the green component (between 0 and 1, default is 0)
  20071. */
  20072. g?: number,
  20073. /**
  20074. * Defines the blue component (between 0 and 1, default is 0)
  20075. */
  20076. b?: number);
  20077. /**
  20078. * Creates a string with the Color3 current values
  20079. * @returns the string representation of the Color3 object
  20080. */
  20081. toString(): string;
  20082. /**
  20083. * Returns the string "Color3"
  20084. * @returns "Color3"
  20085. */
  20086. getClassName(): string;
  20087. /**
  20088. * Compute the Color3 hash code
  20089. * @returns an unique number that can be used to hash Color3 objects
  20090. */
  20091. getHashCode(): number;
  20092. /**
  20093. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  20094. * @param array defines the array where to store the r,g,b components
  20095. * @param index defines an optional index in the target array to define where to start storing values
  20096. * @returns the current Color3 object
  20097. */
  20098. toArray(array: FloatArray, index?: number): Color3;
  20099. /**
  20100. * Returns a new Color4 object from the current Color3 and the given alpha
  20101. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  20102. * @returns a new Color4 object
  20103. */
  20104. toColor4(alpha?: number): Color4;
  20105. /**
  20106. * Returns a new array populated with 3 numeric elements : red, green and blue values
  20107. * @returns the new array
  20108. */
  20109. asArray(): number[];
  20110. /**
  20111. * Returns the luminance value
  20112. * @returns a float value
  20113. */
  20114. toLuminance(): number;
  20115. /**
  20116. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  20117. * @param otherColor defines the second operand
  20118. * @returns the new Color3 object
  20119. */
  20120. multiply(otherColor: Color3): Color3;
  20121. /**
  20122. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  20123. * @param otherColor defines the second operand
  20124. * @param result defines the Color3 object where to store the result
  20125. * @returns the current Color3
  20126. */
  20127. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  20128. /**
  20129. * Determines equality between Color3 objects
  20130. * @param otherColor defines the second operand
  20131. * @returns true if the rgb values are equal to the given ones
  20132. */
  20133. equals(otherColor: Color3): boolean;
  20134. /**
  20135. * Determines equality between the current Color3 object and a set of r,b,g values
  20136. * @param r defines the red component to check
  20137. * @param g defines the green component to check
  20138. * @param b defines the blue component to check
  20139. * @returns true if the rgb values are equal to the given ones
  20140. */
  20141. equalsFloats(r: number, g: number, b: number): boolean;
  20142. /**
  20143. * Multiplies in place each rgb value by scale
  20144. * @param scale defines the scaling factor
  20145. * @returns the updated Color3
  20146. */
  20147. scale(scale: number): Color3;
  20148. /**
  20149. * Multiplies the rgb values by scale and stores the result into "result"
  20150. * @param scale defines the scaling factor
  20151. * @param result defines the Color3 object where to store the result
  20152. * @returns the unmodified current Color3
  20153. */
  20154. scaleToRef(scale: number, result: Color3): Color3;
  20155. /**
  20156. * Scale the current Color3 values by a factor and add the result to a given Color3
  20157. * @param scale defines the scale factor
  20158. * @param result defines color to store the result into
  20159. * @returns the unmodified current Color3
  20160. */
  20161. scaleAndAddToRef(scale: number, result: Color3): Color3;
  20162. /**
  20163. * Clamps the rgb values by the min and max values and stores the result into "result"
  20164. * @param min defines minimum clamping value (default is 0)
  20165. * @param max defines maximum clamping value (default is 1)
  20166. * @param result defines color to store the result into
  20167. * @returns the original Color3
  20168. */
  20169. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  20170. /**
  20171. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  20172. * @param otherColor defines the second operand
  20173. * @returns the new Color3
  20174. */
  20175. add(otherColor: Color3): Color3;
  20176. /**
  20177. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  20178. * @param otherColor defines the second operand
  20179. * @param result defines Color3 object to store the result into
  20180. * @returns the unmodified current Color3
  20181. */
  20182. addToRef(otherColor: Color3, result: Color3): Color3;
  20183. /**
  20184. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  20185. * @param otherColor defines the second operand
  20186. * @returns the new Color3
  20187. */
  20188. subtract(otherColor: Color3): Color3;
  20189. /**
  20190. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  20191. * @param otherColor defines the second operand
  20192. * @param result defines Color3 object to store the result into
  20193. * @returns the unmodified current Color3
  20194. */
  20195. subtractToRef(otherColor: Color3, result: Color3): Color3;
  20196. /**
  20197. * Copy the current object
  20198. * @returns a new Color3 copied the current one
  20199. */
  20200. clone(): Color3;
  20201. /**
  20202. * Copies the rgb values from the source in the current Color3
  20203. * @param source defines the source Color3 object
  20204. * @returns the updated Color3 object
  20205. */
  20206. copyFrom(source: Color3): Color3;
  20207. /**
  20208. * Updates the Color3 rgb values from the given floats
  20209. * @param r defines the red component to read from
  20210. * @param g defines the green component to read from
  20211. * @param b defines the blue component to read from
  20212. * @returns the current Color3 object
  20213. */
  20214. copyFromFloats(r: number, g: number, b: number): Color3;
  20215. /**
  20216. * Updates the Color3 rgb values from the given floats
  20217. * @param r defines the red component to read from
  20218. * @param g defines the green component to read from
  20219. * @param b defines the blue component to read from
  20220. * @returns the current Color3 object
  20221. */
  20222. set(r: number, g: number, b: number): Color3;
  20223. /**
  20224. * Compute the Color3 hexadecimal code as a string
  20225. * @returns a string containing the hexadecimal representation of the Color3 object
  20226. */
  20227. toHexString(): string;
  20228. /**
  20229. * Computes a new Color3 converted from the current one to linear space
  20230. * @returns a new Color3 object
  20231. */
  20232. toLinearSpace(): Color3;
  20233. /**
  20234. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  20235. * @param convertedColor defines the Color3 object where to store the linear space version
  20236. * @returns the unmodified Color3
  20237. */
  20238. toLinearSpaceToRef(convertedColor: Color3): Color3;
  20239. /**
  20240. * Computes a new Color3 converted from the current one to gamma space
  20241. * @returns a new Color3 object
  20242. */
  20243. toGammaSpace(): Color3;
  20244. /**
  20245. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  20246. * @param convertedColor defines the Color3 object where to store the gamma space version
  20247. * @returns the unmodified Color3
  20248. */
  20249. toGammaSpaceToRef(convertedColor: Color3): Color3;
  20250. /**
  20251. * Creates a new Color3 from the string containing valid hexadecimal values
  20252. * @param hex defines a string containing valid hexadecimal values
  20253. * @returns a new Color3 object
  20254. */
  20255. static FromHexString(hex: string): Color3;
  20256. /**
  20257. * Creates a new Vector3 from the starting index of the given array
  20258. * @param array defines the source array
  20259. * @param offset defines an offset in the source array
  20260. * @returns a new Color3 object
  20261. */
  20262. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  20263. /**
  20264. * Creates a new Color3 from integer values (< 256)
  20265. * @param r defines the red component to read from (value between 0 and 255)
  20266. * @param g defines the green component to read from (value between 0 and 255)
  20267. * @param b defines the blue component to read from (value between 0 and 255)
  20268. * @returns a new Color3 object
  20269. */
  20270. static FromInts(r: number, g: number, b: number): Color3;
  20271. /**
  20272. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20273. * @param start defines the start Color3 value
  20274. * @param end defines the end Color3 value
  20275. * @param amount defines the gradient value between start and end
  20276. * @returns a new Color3 object
  20277. */
  20278. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  20279. /**
  20280. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20281. * @param left defines the start value
  20282. * @param right defines the end value
  20283. * @param amount defines the gradient factor
  20284. * @param result defines the Color3 object where to store the result
  20285. */
  20286. static LerpToRef(left: Color3, right: Color3, amount: number, result: Color3): void;
  20287. /**
  20288. * Returns a Color3 value containing a red color
  20289. * @returns a new Color3 object
  20290. */
  20291. static Red(): Color3;
  20292. /**
  20293. * Returns a Color3 value containing a green color
  20294. * @returns a new Color3 object
  20295. */
  20296. static Green(): Color3;
  20297. /**
  20298. * Returns a Color3 value containing a blue color
  20299. * @returns a new Color3 object
  20300. */
  20301. static Blue(): Color3;
  20302. /**
  20303. * Returns a Color3 value containing a black color
  20304. * @returns a new Color3 object
  20305. */
  20306. static Black(): Color3;
  20307. /**
  20308. * Returns a Color3 value containing a white color
  20309. * @returns a new Color3 object
  20310. */
  20311. static White(): Color3;
  20312. /**
  20313. * Returns a Color3 value containing a purple color
  20314. * @returns a new Color3 object
  20315. */
  20316. static Purple(): Color3;
  20317. /**
  20318. * Returns a Color3 value containing a magenta color
  20319. * @returns a new Color3 object
  20320. */
  20321. static Magenta(): Color3;
  20322. /**
  20323. * Returns a Color3 value containing a yellow color
  20324. * @returns a new Color3 object
  20325. */
  20326. static Yellow(): Color3;
  20327. /**
  20328. * Returns a Color3 value containing a gray color
  20329. * @returns a new Color3 object
  20330. */
  20331. static Gray(): Color3;
  20332. /**
  20333. * Returns a Color3 value containing a teal color
  20334. * @returns a new Color3 object
  20335. */
  20336. static Teal(): Color3;
  20337. /**
  20338. * Returns a Color3 value containing a random color
  20339. * @returns a new Color3 object
  20340. */
  20341. static Random(): Color3;
  20342. }
  20343. /**
  20344. * Class used to hold a RBGA color
  20345. */
  20346. class Color4 {
  20347. /**
  20348. * Defines the red component (between 0 and 1, default is 0)
  20349. */
  20350. r: number;
  20351. /**
  20352. * Defines the green component (between 0 and 1, default is 0)
  20353. */
  20354. g: number;
  20355. /**
  20356. * Defines the blue component (between 0 and 1, default is 0)
  20357. */
  20358. b: number;
  20359. /**
  20360. * Defines the alpha component (between 0 and 1, default is 1)
  20361. */
  20362. a: number;
  20363. /**
  20364. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  20365. * @param r defines the red component (between 0 and 1, default is 0)
  20366. * @param g defines the green component (between 0 and 1, default is 0)
  20367. * @param b defines the blue component (between 0 and 1, default is 0)
  20368. * @param a defines the alpha component (between 0 and 1, default is 1)
  20369. */
  20370. constructor(
  20371. /**
  20372. * Defines the red component (between 0 and 1, default is 0)
  20373. */
  20374. r?: number,
  20375. /**
  20376. * Defines the green component (between 0 and 1, default is 0)
  20377. */
  20378. g?: number,
  20379. /**
  20380. * Defines the blue component (between 0 and 1, default is 0)
  20381. */
  20382. b?: number,
  20383. /**
  20384. * Defines the alpha component (between 0 and 1, default is 1)
  20385. */
  20386. a?: number);
  20387. /**
  20388. * Adds in place the given Color4 values to the current Color4 object
  20389. * @param right defines the second operand
  20390. * @returns the current updated Color4 object
  20391. */
  20392. addInPlace(right: Color4): Color4;
  20393. /**
  20394. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20395. * @returns the new array
  20396. */
  20397. asArray(): number[];
  20398. /**
  20399. * Stores from the starting index in the given array the Color4 successive values
  20400. * @param array defines the array where to store the r,g,b components
  20401. * @param index defines an optional index in the target array to define where to start storing values
  20402. * @returns the current Color4 object
  20403. */
  20404. toArray(array: number[], index?: number): Color4;
  20405. /**
  20406. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20407. * @param right defines the second operand
  20408. * @returns a new Color4 object
  20409. */
  20410. add(right: Color4): Color4;
  20411. /**
  20412. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20413. * @param right defines the second operand
  20414. * @returns a new Color4 object
  20415. */
  20416. subtract(right: Color4): Color4;
  20417. /**
  20418. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20419. * @param right defines the second operand
  20420. * @param result defines the Color4 object where to store the result
  20421. * @returns the current Color4 object
  20422. */
  20423. subtractToRef(right: Color4, result: Color4): Color4;
  20424. /**
  20425. * Creates a new Color4 with the current Color4 values multiplied by scale
  20426. * @param scale defines the scaling factor to apply
  20427. * @returns a new Color4 object
  20428. */
  20429. scale(scale: number): Color4;
  20430. /**
  20431. * Multiplies the current Color4 values by scale and stores the result in "result"
  20432. * @param scale defines the scaling factor to apply
  20433. * @param result defines the Color4 object where to store the result
  20434. * @returns the current unmodified Color4
  20435. */
  20436. scaleToRef(scale: number, result: Color4): Color4;
  20437. /**
  20438. * Scale the current Color4 values by a factor and add the result to a given Color4
  20439. * @param scale defines the scale factor
  20440. * @param result defines the Color4 object where to store the result
  20441. * @returns the unmodified current Color4
  20442. */
  20443. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20444. /**
  20445. * Clamps the rgb values by the min and max values and stores the result into "result"
  20446. * @param min defines minimum clamping value (default is 0)
  20447. * @param max defines maximum clamping value (default is 1)
  20448. * @param result defines color to store the result into.
  20449. * @returns the cuurent Color4
  20450. */
  20451. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20452. /**
  20453. * Multipy an Color4 value by another and return a new Color4 object
  20454. * @param color defines the Color4 value to multiply by
  20455. * @returns a new Color4 object
  20456. */
  20457. multiply(color: Color4): Color4;
  20458. /**
  20459. * Multipy a Color4 value by another and push the result in a reference value
  20460. * @param color defines the Color4 value to multiply by
  20461. * @param result defines the Color4 to fill the result in
  20462. * @returns the result Color4
  20463. */
  20464. multiplyToRef(color: Color4, result: Color4): Color4;
  20465. /**
  20466. * Creates a string with the Color4 current values
  20467. * @returns the string representation of the Color4 object
  20468. */
  20469. toString(): string;
  20470. /**
  20471. * Returns the string "Color4"
  20472. * @returns "Color4"
  20473. */
  20474. getClassName(): string;
  20475. /**
  20476. * Compute the Color4 hash code
  20477. * @returns an unique number that can be used to hash Color4 objects
  20478. */
  20479. getHashCode(): number;
  20480. /**
  20481. * Creates a new Color4 copied from the current one
  20482. * @returns a new Color4 object
  20483. */
  20484. clone(): Color4;
  20485. /**
  20486. * Copies the given Color4 values into the current one
  20487. * @param source defines the source Color4 object
  20488. * @returns the current updated Color4 object
  20489. */
  20490. copyFrom(source: Color4): Color4;
  20491. /**
  20492. * Copies the given float values into the current one
  20493. * @param r defines the red component to read from
  20494. * @param g defines the green component to read from
  20495. * @param b defines the blue component to read from
  20496. * @param a defines the alpha component to read from
  20497. * @returns the current updated Color4 object
  20498. */
  20499. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20500. /**
  20501. * Copies the given float values into the current one
  20502. * @param r defines the red component to read from
  20503. * @param g defines the green component to read from
  20504. * @param b defines the blue component to read from
  20505. * @param a defines the alpha component to read from
  20506. * @returns the current updated Color4 object
  20507. */
  20508. set(r: number, g: number, b: number, a: number): Color4;
  20509. /**
  20510. * Compute the Color4 hexadecimal code as a string
  20511. * @returns a string containing the hexadecimal representation of the Color4 object
  20512. */
  20513. toHexString(): string;
  20514. /**
  20515. * Computes a new Color4 converted from the current one to linear space
  20516. * @returns a new Color4 object
  20517. */
  20518. toLinearSpace(): Color4;
  20519. /**
  20520. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20521. * @param convertedColor defines the Color4 object where to store the linear space version
  20522. * @returns the unmodified Color4
  20523. */
  20524. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20525. /**
  20526. * Computes a new Color4 converted from the current one to gamma space
  20527. * @returns a new Color4 object
  20528. */
  20529. toGammaSpace(): Color4;
  20530. /**
  20531. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20532. * @param convertedColor defines the Color4 object where to store the gamma space version
  20533. * @returns the unmodified Color4
  20534. */
  20535. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20536. /**
  20537. * Creates a new Color4 from the string containing valid hexadecimal values
  20538. * @param hex defines a string containing valid hexadecimal values
  20539. * @returns a new Color4 object
  20540. */
  20541. static FromHexString(hex: string): Color4;
  20542. /**
  20543. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20544. * @param left defines the start value
  20545. * @param right defines the end value
  20546. * @param amount defines the gradient factor
  20547. * @returns a new Color4 object
  20548. */
  20549. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  20550. /**
  20551. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20552. * @param left defines the start value
  20553. * @param right defines the end value
  20554. * @param amount defines the gradient factor
  20555. * @param result defines the Color4 object where to store data
  20556. */
  20557. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  20558. /**
  20559. * Creates a new Color4 from a Color3 and an alpha value
  20560. * @param color3 defines the source Color3 to read from
  20561. * @param alpha defines the alpha component (1.0 by default)
  20562. * @returns a new Color4 object
  20563. */
  20564. static FromColor3(color3: Color3, alpha?: number): Color4;
  20565. /**
  20566. * Creates a new Color4 from the starting index element of the given array
  20567. * @param array defines the source array to read from
  20568. * @param offset defines the offset in the source array
  20569. * @returns a new Color4 object
  20570. */
  20571. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  20572. /**
  20573. * Creates a new Color3 from integer values (< 256)
  20574. * @param r defines the red component to read from (value between 0 and 255)
  20575. * @param g defines the green component to read from (value between 0 and 255)
  20576. * @param b defines the blue component to read from (value between 0 and 255)
  20577. * @param a defines the alpha component to read from (value between 0 and 255)
  20578. * @returns a new Color3 object
  20579. */
  20580. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20581. /**
  20582. * Check the content of a given array and convert it to an array containing RGBA data
  20583. * If the original array was already containing count * 4 values then it is returned directly
  20584. * @param colors defines the array to check
  20585. * @param count defines the number of RGBA data to expect
  20586. * @returns an array containing count * 4 values (RGBA)
  20587. */
  20588. static CheckColors4(colors: number[], count: number): number[];
  20589. }
  20590. /**
  20591. * Class representing a vector containing 2 coordinates
  20592. */
  20593. class Vector2 {
  20594. /** defines the first coordinate */
  20595. x: number;
  20596. /** defines the second coordinate */
  20597. y: number;
  20598. /**
  20599. * Creates a new Vector2 from the given x and y coordinates
  20600. * @param x defines the first coordinate
  20601. * @param y defines the second coordinate
  20602. */
  20603. constructor(
  20604. /** defines the first coordinate */
  20605. x?: number,
  20606. /** defines the second coordinate */
  20607. y?: number);
  20608. /**
  20609. * Gets a string with the Vector2 coordinates
  20610. * @returns a string with the Vector2 coordinates
  20611. */
  20612. toString(): string;
  20613. /**
  20614. * Gets class name
  20615. * @returns the string "Vector2"
  20616. */
  20617. getClassName(): string;
  20618. /**
  20619. * Gets current vector hash code
  20620. * @returns the Vector2 hash code as a number
  20621. */
  20622. getHashCode(): number;
  20623. /**
  20624. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20625. * @param array defines the source array
  20626. * @param index defines the offset in source array
  20627. * @returns the current Vector2
  20628. */
  20629. toArray(array: FloatArray, index?: number): Vector2;
  20630. /**
  20631. * Copy the current vector to an array
  20632. * @returns a new array with 2 elements: the Vector2 coordinates.
  20633. */
  20634. asArray(): number[];
  20635. /**
  20636. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20637. * @param source defines the source Vector2
  20638. * @returns the current updated Vector2
  20639. */
  20640. copyFrom(source: Vector2): Vector2;
  20641. /**
  20642. * Sets the Vector2 coordinates with the given floats
  20643. * @param x defines the first coordinate
  20644. * @param y defines the second coordinate
  20645. * @returns the current updated Vector2
  20646. */
  20647. copyFromFloats(x: number, y: number): Vector2;
  20648. /**
  20649. * Sets the Vector2 coordinates with the given floats
  20650. * @param x defines the first coordinate
  20651. * @param y defines the second coordinate
  20652. * @returns the current updated Vector2
  20653. */
  20654. set(x: number, y: number): Vector2;
  20655. /**
  20656. * Add another vector with the current one
  20657. * @param otherVector defines the other vector
  20658. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20659. */
  20660. add(otherVector: Vector2): Vector2;
  20661. /**
  20662. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20663. * @param otherVector defines the other vector
  20664. * @param result defines the target vector
  20665. * @returns the unmodified current Vector2
  20666. */
  20667. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  20668. /**
  20669. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20670. * @param otherVector defines the other vector
  20671. * @returns the current updated Vector2
  20672. */
  20673. addInPlace(otherVector: Vector2): Vector2;
  20674. /**
  20675. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20676. * @param otherVector defines the other vector
  20677. * @returns a new Vector2
  20678. */
  20679. addVector3(otherVector: Vector3): Vector2;
  20680. /**
  20681. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20682. * @param otherVector defines the other vector
  20683. * @returns a new Vector2
  20684. */
  20685. subtract(otherVector: Vector2): Vector2;
  20686. /**
  20687. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20688. * @param otherVector defines the other vector
  20689. * @param result defines the target vector
  20690. * @returns the unmodified current Vector2
  20691. */
  20692. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  20693. /**
  20694. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  20695. * @param otherVector defines the other vector
  20696. * @returns the current updated Vector2
  20697. */
  20698. subtractInPlace(otherVector: Vector2): Vector2;
  20699. /**
  20700. * Multiplies in place the current Vector2 coordinates by the given ones
  20701. * @param otherVector defines the other vector
  20702. * @returns the current updated Vector2
  20703. */
  20704. multiplyInPlace(otherVector: Vector2): Vector2;
  20705. /**
  20706. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  20707. * @param otherVector defines the other vector
  20708. * @returns a new Vector2
  20709. */
  20710. multiply(otherVector: Vector2): Vector2;
  20711. /**
  20712. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  20713. * @param otherVector defines the other vector
  20714. * @param result defines the target vector
  20715. * @returns the unmodified current Vector2
  20716. */
  20717. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  20718. /**
  20719. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  20720. * @param x defines the first coordinate
  20721. * @param y defines the second coordinate
  20722. * @returns a new Vector2
  20723. */
  20724. multiplyByFloats(x: number, y: number): Vector2;
  20725. /**
  20726. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  20727. * @param otherVector defines the other vector
  20728. * @returns a new Vector2
  20729. */
  20730. divide(otherVector: Vector2): Vector2;
  20731. /**
  20732. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  20733. * @param otherVector defines the other vector
  20734. * @param result defines the target vector
  20735. * @returns the unmodified current Vector2
  20736. */
  20737. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  20738. /**
  20739. * Divides the current Vector2 coordinates by the given ones
  20740. * @param otherVector defines the other vector
  20741. * @returns the current updated Vector2
  20742. */
  20743. divideInPlace(otherVector: Vector2): Vector2;
  20744. /**
  20745. * Gets a new Vector2 with current Vector2 negated coordinates
  20746. * @returns a new Vector2
  20747. */
  20748. negate(): Vector2;
  20749. /**
  20750. * Multiply the Vector2 coordinates by scale
  20751. * @param scale defines the scaling factor
  20752. * @returns the current updated Vector2
  20753. */
  20754. scaleInPlace(scale: number): Vector2;
  20755. /**
  20756. * Returns a new Vector2 scaled by "scale" from the current Vector2
  20757. * @param scale defines the scaling factor
  20758. * @returns a new Vector2
  20759. */
  20760. scale(scale: number): Vector2;
  20761. /**
  20762. * Scale the current Vector2 values by a factor to a given Vector2
  20763. * @param scale defines the scale factor
  20764. * @param result defines the Vector2 object where to store the result
  20765. * @returns the unmodified current Vector2
  20766. */
  20767. scaleToRef(scale: number, result: Vector2): Vector2;
  20768. /**
  20769. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  20770. * @param scale defines the scale factor
  20771. * @param result defines the Vector2 object where to store the result
  20772. * @returns the unmodified current Vector2
  20773. */
  20774. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  20775. /**
  20776. * Gets a boolean if two vectors are equals
  20777. * @param otherVector defines the other vector
  20778. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  20779. */
  20780. equals(otherVector: Vector2): boolean;
  20781. /**
  20782. * Gets a boolean if two vectors are equals (using an epsilon value)
  20783. * @param otherVector defines the other vector
  20784. * @param epsilon defines the minimal distance to consider equality
  20785. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  20786. */
  20787. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  20788. /**
  20789. * Gets a new Vector2 from current Vector2 floored values
  20790. * @returns a new Vector2
  20791. */
  20792. floor(): Vector2;
  20793. /**
  20794. * Gets a new Vector2 from current Vector2 floored values
  20795. * @returns a new Vector2
  20796. */
  20797. fract(): Vector2;
  20798. /**
  20799. * Gets the length of the vector
  20800. * @returns the vector length (float)
  20801. */
  20802. length(): number;
  20803. /**
  20804. * Gets the vector squared length
  20805. * @returns the vector squared length (float)
  20806. */
  20807. lengthSquared(): number;
  20808. /**
  20809. * Normalize the vector
  20810. * @returns the current updated Vector2
  20811. */
  20812. normalize(): Vector2;
  20813. /**
  20814. * Gets a new Vector2 copied from the Vector2
  20815. * @returns a new Vector2
  20816. */
  20817. clone(): Vector2;
  20818. /**
  20819. * Gets a new Vector2(0, 0)
  20820. * @returns a new Vector2
  20821. */
  20822. static Zero(): Vector2;
  20823. /**
  20824. * Gets a new Vector2(1, 1)
  20825. * @returns a new Vector2
  20826. */
  20827. static One(): Vector2;
  20828. /**
  20829. * Gets a new Vector2 set from the given index element of the given array
  20830. * @param array defines the data source
  20831. * @param offset defines the offset in the data source
  20832. * @returns a new Vector2
  20833. */
  20834. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  20835. /**
  20836. * Sets "result" from the given index element of the given array
  20837. * @param array defines the data source
  20838. * @param offset defines the offset in the data source
  20839. * @param result defines the target vector
  20840. */
  20841. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  20842. /**
  20843. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  20844. * @param value1 defines 1st point of control
  20845. * @param value2 defines 2nd point of control
  20846. * @param value3 defines 3rd point of control
  20847. * @param value4 defines 4th point of control
  20848. * @param amount defines the interpolation factor
  20849. * @returns a new Vector2
  20850. */
  20851. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  20852. /**
  20853. * 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".
  20854. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  20855. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  20856. * @param value defines the value to clamp
  20857. * @param min defines the lower limit
  20858. * @param max defines the upper limit
  20859. * @returns a new Vector2
  20860. */
  20861. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  20862. /**
  20863. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  20864. * @param value1 defines the 1st control point
  20865. * @param tangent1 defines the outgoing tangent
  20866. * @param value2 defines the 2nd control point
  20867. * @param tangent2 defines the incoming tangent
  20868. * @param amount defines the interpolation factor
  20869. * @returns a new Vector2
  20870. */
  20871. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  20872. /**
  20873. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  20874. * @param start defines the start vector
  20875. * @param end defines the end vector
  20876. * @param amount defines the interpolation factor
  20877. * @returns a new Vector2
  20878. */
  20879. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  20880. /**
  20881. * Gets the dot product of the vector "left" and the vector "right"
  20882. * @param left defines first vector
  20883. * @param right defines second vector
  20884. * @returns the dot product (float)
  20885. */
  20886. static Dot(left: Vector2, right: Vector2): number;
  20887. /**
  20888. * Returns a new Vector2 equal to the normalized given vector
  20889. * @param vector defines the vector to normalize
  20890. * @returns a new Vector2
  20891. */
  20892. static Normalize(vector: Vector2): Vector2;
  20893. /**
  20894. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  20895. * @param left defines 1st vector
  20896. * @param right defines 2nd vector
  20897. * @returns a new Vector2
  20898. */
  20899. static Minimize(left: Vector2, right: Vector2): Vector2;
  20900. /**
  20901. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  20902. * @param left defines 1st vector
  20903. * @param right defines 2nd vector
  20904. * @returns a new Vector2
  20905. */
  20906. static Maximize(left: Vector2, right: Vector2): Vector2;
  20907. /**
  20908. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  20909. * @param vector defines the vector to transform
  20910. * @param transformation defines the matrix to apply
  20911. * @returns a new Vector2
  20912. */
  20913. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  20914. /**
  20915. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  20916. * @param vector defines the vector to transform
  20917. * @param transformation defines the matrix to apply
  20918. * @param result defines the target vector
  20919. */
  20920. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  20921. /**
  20922. * Determines if a given vector is included in a triangle
  20923. * @param p defines the vector to test
  20924. * @param p0 defines 1st triangle point
  20925. * @param p1 defines 2nd triangle point
  20926. * @param p2 defines 3rd triangle point
  20927. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  20928. */
  20929. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  20930. /**
  20931. * Gets the distance between the vectors "value1" and "value2"
  20932. * @param value1 defines first vector
  20933. * @param value2 defines second vector
  20934. * @returns the distance between vectors
  20935. */
  20936. static Distance(value1: Vector2, value2: Vector2): number;
  20937. /**
  20938. * Returns the squared distance between the vectors "value1" and "value2"
  20939. * @param value1 defines first vector
  20940. * @param value2 defines second vector
  20941. * @returns the squared distance between vectors
  20942. */
  20943. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  20944. /**
  20945. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  20946. * @param value1 defines first vector
  20947. * @param value2 defines second vector
  20948. * @returns a new Vector2
  20949. */
  20950. static Center(value1: Vector2, value2: Vector2): Vector2;
  20951. /**
  20952. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  20953. * @param p defines the middle point
  20954. * @param segA defines one point of the segment
  20955. * @param segB defines the other point of the segment
  20956. * @returns the shortest distance
  20957. */
  20958. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  20959. }
  20960. /**
  20961. * Classed used to store (x,y,z) vector representation
  20962. * A Vector3 is the main object used in 3D geometry
  20963. * It can represent etiher the coordinates of a point the space, either a direction
  20964. * Reminder: Babylon.js uses a left handed forward facing system
  20965. */
  20966. class Vector3 {
  20967. /**
  20968. * Defines the first coordinates (on X axis)
  20969. */
  20970. x: number;
  20971. /**
  20972. * Defines the second coordinates (on Y axis)
  20973. */
  20974. y: number;
  20975. /**
  20976. * Defines the third coordinates (on Z axis)
  20977. */
  20978. z: number;
  20979. /**
  20980. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  20981. * @param x defines the first coordinates (on X axis)
  20982. * @param y defines the second coordinates (on Y axis)
  20983. * @param z defines the third coordinates (on Z axis)
  20984. */
  20985. constructor(
  20986. /**
  20987. * Defines the first coordinates (on X axis)
  20988. */
  20989. x?: number,
  20990. /**
  20991. * Defines the second coordinates (on Y axis)
  20992. */
  20993. y?: number,
  20994. /**
  20995. * Defines the third coordinates (on Z axis)
  20996. */
  20997. z?: number);
  20998. /**
  20999. * Creates a string representation of the Vector3
  21000. * @returns a string with the Vector3 coordinates.
  21001. */
  21002. toString(): string;
  21003. /**
  21004. * Gets the class name
  21005. * @returns the string "Vector3"
  21006. */
  21007. getClassName(): string;
  21008. /**
  21009. * Creates the Vector3 hash code
  21010. * @returns a number which tends to be unique between Vector3 instances
  21011. */
  21012. getHashCode(): number;
  21013. /**
  21014. * Creates an array containing three elements : the coordinates of the Vector3
  21015. * @returns a new array of numbers
  21016. */
  21017. asArray(): number[];
  21018. /**
  21019. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  21020. * @param array defines the destination array
  21021. * @param index defines the offset in the destination array
  21022. * @returns the current Vector3
  21023. */
  21024. toArray(array: FloatArray, index?: number): Vector3;
  21025. /**
  21026. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  21027. * @returns a new Quaternion object, computed from the Vector3 coordinates
  21028. */
  21029. toQuaternion(): Quaternion;
  21030. /**
  21031. * Adds the given vector to the current Vector3
  21032. * @param otherVector defines the second operand
  21033. * @returns the current updated Vector3
  21034. */
  21035. addInPlace(otherVector: Vector3): Vector3;
  21036. /**
  21037. * Adds the given coordinates to the current Vector3
  21038. * @param x defines the x coordinate of the operand
  21039. * @param y defines the y coordinate of the operand
  21040. * @param z defines the z coordinate of the operand
  21041. * @returns the current updated Vector3
  21042. */
  21043. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21044. /**
  21045. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  21046. * @param otherVector defines the second operand
  21047. * @returns the resulting Vector3
  21048. */
  21049. add(otherVector: Vector3): Vector3;
  21050. /**
  21051. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  21052. * @param otherVector defines the second operand
  21053. * @param result defines the Vector3 object where to store the result
  21054. * @returns the current Vector3
  21055. */
  21056. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  21057. /**
  21058. * Subtract the given vector from the current Vector3
  21059. * @param otherVector defines the second operand
  21060. * @returns the current updated Vector3
  21061. */
  21062. subtractInPlace(otherVector: Vector3): Vector3;
  21063. /**
  21064. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  21065. * @param otherVector defines the second operand
  21066. * @returns the resulting Vector3
  21067. */
  21068. subtract(otherVector: Vector3): Vector3;
  21069. /**
  21070. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  21071. * @param otherVector defines the second operand
  21072. * @param result defines the Vector3 object where to store the result
  21073. * @returns the current Vector3
  21074. */
  21075. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  21076. /**
  21077. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  21078. * @param x defines the x coordinate of the operand
  21079. * @param y defines the y coordinate of the operand
  21080. * @param z defines the z coordinate of the operand
  21081. * @returns the resulting Vector3
  21082. */
  21083. subtractFromFloats(x: number, y: number, z: number): Vector3;
  21084. /**
  21085. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  21086. * @param x defines the x coordinate of the operand
  21087. * @param y defines the y coordinate of the operand
  21088. * @param z defines the z coordinate of the operand
  21089. * @param result defines the Vector3 object where to store the result
  21090. * @returns the current Vector3
  21091. */
  21092. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  21093. /**
  21094. * Gets a new Vector3 set with the current Vector3 negated coordinates
  21095. * @returns a new Vector3
  21096. */
  21097. negate(): Vector3;
  21098. /**
  21099. * Multiplies the Vector3 coordinates by the float "scale"
  21100. * @param scale defines the multiplier factor
  21101. * @returns the current updated Vector3
  21102. */
  21103. scaleInPlace(scale: number): Vector3;
  21104. /**
  21105. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  21106. * @param scale defines the multiplier factor
  21107. * @returns a new Vector3
  21108. */
  21109. scale(scale: number): Vector3;
  21110. /**
  21111. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  21112. * @param scale defines the multiplier factor
  21113. * @param result defines the Vector3 object where to store the result
  21114. * @returns the current Vector3
  21115. */
  21116. scaleToRef(scale: number, result: Vector3): Vector3;
  21117. /**
  21118. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  21119. * @param scale defines the scale factor
  21120. * @param result defines the Vector3 object where to store the result
  21121. * @returns the unmodified current Vector3
  21122. */
  21123. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  21124. /**
  21125. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  21126. * @param otherVector defines the second operand
  21127. * @returns true if both vectors are equals
  21128. */
  21129. equals(otherVector: Vector3): boolean;
  21130. /**
  21131. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  21132. * @param otherVector defines the second operand
  21133. * @param epsilon defines the minimal distance to define values as equals
  21134. * @returns true if both vectors are distant less than epsilon
  21135. */
  21136. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  21137. /**
  21138. * Returns true if the current Vector3 coordinates equals the given floats
  21139. * @param x defines the x coordinate of the operand
  21140. * @param y defines the y coordinate of the operand
  21141. * @param z defines the z coordinate of the operand
  21142. * @returns true if both vectors are equals
  21143. */
  21144. equalsToFloats(x: number, y: number, z: number): boolean;
  21145. /**
  21146. * Multiplies the current Vector3 coordinates by the given ones
  21147. * @param otherVector defines the second operand
  21148. * @returns the current updated Vector3
  21149. */
  21150. multiplyInPlace(otherVector: Vector3): Vector3;
  21151. /**
  21152. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  21153. * @param otherVector defines the second operand
  21154. * @returns the new Vector3
  21155. */
  21156. multiply(otherVector: Vector3): Vector3;
  21157. /**
  21158. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  21159. * @param otherVector defines the second operand
  21160. * @param result defines the Vector3 object where to store the result
  21161. * @returns the current Vector3
  21162. */
  21163. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  21164. /**
  21165. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  21166. * @param x defines the x coordinate of the operand
  21167. * @param y defines the y coordinate of the operand
  21168. * @param z defines the z coordinate of the operand
  21169. * @returns the new Vector3
  21170. */
  21171. multiplyByFloats(x: number, y: number, z: number): Vector3;
  21172. /**
  21173. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  21174. * @param otherVector defines the second operand
  21175. * @returns the new Vector3
  21176. */
  21177. divide(otherVector: Vector3): Vector3;
  21178. /**
  21179. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  21180. * @param otherVector defines the second operand
  21181. * @param result defines the Vector3 object where to store the result
  21182. * @returns the current Vector3
  21183. */
  21184. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  21185. /**
  21186. * Divides the current Vector3 coordinates by the given ones.
  21187. * @param otherVector defines the second operand
  21188. * @returns the current updated Vector3
  21189. */
  21190. divideInPlace(otherVector: Vector3): Vector3;
  21191. /**
  21192. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  21193. * @param other defines the second operand
  21194. * @returns the current updated Vector3
  21195. */
  21196. minimizeInPlace(other: Vector3): Vector3;
  21197. /**
  21198. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  21199. * @param other defines the second operand
  21200. * @returns the current updated Vector3
  21201. */
  21202. maximizeInPlace(other: Vector3): Vector3;
  21203. /**
  21204. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  21205. * @param x defines the x coordinate of the operand
  21206. * @param y defines the y coordinate of the operand
  21207. * @param z defines the z coordinate of the operand
  21208. * @returns the current updated Vector3
  21209. */
  21210. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21211. /**
  21212. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  21213. * @param x defines the x coordinate of the operand
  21214. * @param y defines the y coordinate of the operand
  21215. * @param z defines the z coordinate of the operand
  21216. * @returns the current updated Vector3
  21217. */
  21218. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21219. /**
  21220. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  21221. */
  21222. readonly isNonUniform: boolean;
  21223. /**
  21224. * Gets a new Vector3 from current Vector3 floored values
  21225. * @returns a new Vector3
  21226. */
  21227. floor(): Vector3;
  21228. /**
  21229. * Gets a new Vector3 from current Vector3 floored values
  21230. * @returns a new Vector3
  21231. */
  21232. fract(): Vector3;
  21233. /**
  21234. * Gets the length of the Vector3
  21235. * @returns the length of the Vecto3
  21236. */
  21237. length(): number;
  21238. /**
  21239. * Gets the squared length of the Vector3
  21240. * @returns squared length of the Vector3
  21241. */
  21242. lengthSquared(): number;
  21243. /**
  21244. * Normalize the current Vector3.
  21245. * Please note that this is an in place operation.
  21246. * @returns the current updated Vector3
  21247. */
  21248. normalize(): Vector3;
  21249. /**
  21250. * Reorders the x y z properties of the vector in place
  21251. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  21252. * @returns the current updated vector
  21253. */
  21254. reorderInPlace(order: string): this;
  21255. /**
  21256. * Rotates the vector around 0,0,0 by a quaternion
  21257. * @param quaternion the rotation quaternion
  21258. * @param result vector to store the result
  21259. * @returns the resulting vector
  21260. */
  21261. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  21262. /**
  21263. * Rotates a vector around a given point
  21264. * @param quaternion the rotation quaternion
  21265. * @param point the point to rotate around
  21266. * @param result vector to store the result
  21267. * @returns the resulting vector
  21268. */
  21269. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  21270. /**
  21271. * Normalize the current Vector3 with the given input length.
  21272. * Please note that this is an in place operation.
  21273. * @param len the length of the vector
  21274. * @returns the current updated Vector3
  21275. */
  21276. normalizeFromLength(len: number): Vector3;
  21277. /**
  21278. * Normalize the current Vector3 to a new vector
  21279. * @returns the new Vector3
  21280. */
  21281. normalizeToNew(): Vector3;
  21282. /**
  21283. * Normalize the current Vector3 to the reference
  21284. * @param reference define the Vector3 to update
  21285. * @returns the updated Vector3
  21286. */
  21287. normalizeToRef(reference: Vector3): Vector3;
  21288. /**
  21289. * Creates a new Vector3 copied from the current Vector3
  21290. * @returns the new Vector3
  21291. */
  21292. clone(): Vector3;
  21293. /**
  21294. * Copies the given vector coordinates to the current Vector3 ones
  21295. * @param source defines the source Vector3
  21296. * @returns the current updated Vector3
  21297. */
  21298. copyFrom(source: Vector3): Vector3;
  21299. /**
  21300. * Copies the given floats to the current Vector3 coordinates
  21301. * @param x defines the x coordinate of the operand
  21302. * @param y defines the y coordinate of the operand
  21303. * @param z defines the z coordinate of the operand
  21304. * @returns the current updated Vector3
  21305. */
  21306. copyFromFloats(x: number, y: number, z: number): Vector3;
  21307. /**
  21308. * Copies the given floats to the current Vector3 coordinates
  21309. * @param x defines the x coordinate of the operand
  21310. * @param y defines the y coordinate of the operand
  21311. * @param z defines the z coordinate of the operand
  21312. * @returns the current updated Vector3
  21313. */
  21314. set(x: number, y: number, z: number): Vector3;
  21315. /**
  21316. * Copies the given float to the current Vector3 coordinates
  21317. * @param v defines the x, y and z coordinates of the operand
  21318. * @returns the current updated Vector3
  21319. */
  21320. setAll(v: number): Vector3;
  21321. /**
  21322. * Get the clip factor between two vectors
  21323. * @param vector0 defines the first operand
  21324. * @param vector1 defines the second operand
  21325. * @param axis defines the axis to use
  21326. * @param size defines the size along the axis
  21327. * @returns the clip factor
  21328. */
  21329. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  21330. /**
  21331. * Get angle between two vectors
  21332. * @param vector0 angle between vector0 and vector1
  21333. * @param vector1 angle between vector0 and vector1
  21334. * @param normal direction of the normal
  21335. * @return the angle between vector0 and vector1
  21336. */
  21337. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  21338. /**
  21339. * Returns a new Vector3 set from the index "offset" of the given array
  21340. * @param array defines the source array
  21341. * @param offset defines the offset in the source array
  21342. * @returns the new Vector3
  21343. */
  21344. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  21345. /**
  21346. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  21347. * This function is deprecated. Use FromArray instead
  21348. * @param array defines the source array
  21349. * @param offset defines the offset in the source array
  21350. * @returns the new Vector3
  21351. */
  21352. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  21353. /**
  21354. * Sets the given vector "result" with the element values from the index "offset" of the given array
  21355. * @param array defines the source array
  21356. * @param offset defines the offset in the source array
  21357. * @param result defines the Vector3 where to store the result
  21358. */
  21359. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  21360. /**
  21361. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  21362. * This function is deprecated. Use FromArrayToRef instead.
  21363. * @param array defines the source array
  21364. * @param offset defines the offset in the source array
  21365. * @param result defines the Vector3 where to store the result
  21366. */
  21367. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  21368. /**
  21369. * Sets the given vector "result" with the given floats.
  21370. * @param x defines the x coordinate of the source
  21371. * @param y defines the y coordinate of the source
  21372. * @param z defines the z coordinate of the source
  21373. * @param result defines the Vector3 where to store the result
  21374. */
  21375. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  21376. /**
  21377. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  21378. * @returns a new empty Vector3
  21379. */
  21380. static Zero(): Vector3;
  21381. /**
  21382. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  21383. * @returns a new unit Vector3
  21384. */
  21385. static One(): Vector3;
  21386. /**
  21387. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  21388. * @returns a new up Vector3
  21389. */
  21390. static Up(): Vector3;
  21391. /**
  21392. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  21393. * @returns a new down Vector3
  21394. */
  21395. static Down(): Vector3;
  21396. /**
  21397. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  21398. * @returns a new forward Vector3
  21399. */
  21400. static Forward(): Vector3;
  21401. /**
  21402. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  21403. * @returns a new forward Vector3
  21404. */
  21405. static Backward(): Vector3;
  21406. /**
  21407. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  21408. * @returns a new right Vector3
  21409. */
  21410. static Right(): Vector3;
  21411. /**
  21412. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21413. * @returns a new left Vector3
  21414. */
  21415. static Left(): Vector3;
  21416. /**
  21417. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21418. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21419. * @param vector defines the Vector3 to transform
  21420. * @param transformation defines the transformation matrix
  21421. * @returns the transformed Vector3
  21422. */
  21423. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  21424. /**
  21425. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21426. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21427. * @param vector defines the Vector3 to transform
  21428. * @param transformation defines the transformation matrix
  21429. * @param result defines the Vector3 where to store the result
  21430. */
  21431. static TransformCoordinatesToRef(vector: Vector3, transformation: Readonly<Matrix>, result: Vector3): void;
  21432. /**
  21433. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21434. * This method computes tranformed coordinates only, not transformed direction vectors
  21435. * @param x define the x coordinate of the source vector
  21436. * @param y define the y coordinate of the source vector
  21437. * @param z define the z coordinate of the source vector
  21438. * @param transformation defines the transformation matrix
  21439. * @param result defines the Vector3 where to store the result
  21440. */
  21441. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Readonly<Matrix>, result: Vector3): void;
  21442. /**
  21443. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21444. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21445. * @param vector defines the Vector3 to transform
  21446. * @param transformation defines the transformation matrix
  21447. * @returns the new Vector3
  21448. */
  21449. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  21450. /**
  21451. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21452. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21453. * @param vector defines the Vector3 to transform
  21454. * @param transformation defines the transformation matrix
  21455. * @param result defines the Vector3 where to store the result
  21456. */
  21457. static TransformNormalToRef(vector: Vector3, transformation: Readonly<Matrix>, result: Vector3): void;
  21458. /**
  21459. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21460. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21461. * @param x define the x coordinate of the source vector
  21462. * @param y define the y coordinate of the source vector
  21463. * @param z define the z coordinate of the source vector
  21464. * @param transformation defines the transformation matrix
  21465. * @param result defines the Vector3 where to store the result
  21466. */
  21467. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Readonly<Matrix>, result: Vector3): void;
  21468. /**
  21469. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21470. * @param value1 defines the first control point
  21471. * @param value2 defines the second control point
  21472. * @param value3 defines the third control point
  21473. * @param value4 defines the fourth control point
  21474. * @param amount defines the amount on the spline to use
  21475. * @returns the new Vector3
  21476. */
  21477. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  21478. /**
  21479. * 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"
  21480. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21481. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21482. * @param value defines the current value
  21483. * @param min defines the lower range value
  21484. * @param max defines the upper range value
  21485. * @returns the new Vector3
  21486. */
  21487. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  21488. /**
  21489. * 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"
  21490. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21491. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21492. * @param value defines the current value
  21493. * @param min defines the lower range value
  21494. * @param max defines the upper range value
  21495. * @param result defines the Vector3 where to store the result
  21496. */
  21497. static ClampToRef(value: Vector3, min: Vector3, max: Vector3, result: Vector3): void;
  21498. /**
  21499. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21500. * @param value1 defines the first control point
  21501. * @param tangent1 defines the first tangent vector
  21502. * @param value2 defines the second control point
  21503. * @param tangent2 defines the second tangent vector
  21504. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21505. * @returns the new Vector3
  21506. */
  21507. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  21508. /**
  21509. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21510. * @param start defines the start value
  21511. * @param end defines the end value
  21512. * @param amount max defines amount between both (between 0 and 1)
  21513. * @returns the new Vector3
  21514. */
  21515. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  21516. /**
  21517. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21518. * @param start defines the start value
  21519. * @param end defines the end value
  21520. * @param amount max defines amount between both (between 0 and 1)
  21521. * @param result defines the Vector3 where to store the result
  21522. */
  21523. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  21524. /**
  21525. * Returns the dot product (float) between the vectors "left" and "right"
  21526. * @param left defines the left operand
  21527. * @param right defines the right operand
  21528. * @returns the dot product
  21529. */
  21530. static Dot(left: Vector3, right: Vector3): number;
  21531. /**
  21532. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21533. * The cross product is then orthogonal to both "left" and "right"
  21534. * @param left defines the left operand
  21535. * @param right defines the right operand
  21536. * @returns the cross product
  21537. */
  21538. static Cross(left: Vector3, right: Vector3): Vector3;
  21539. /**
  21540. * Sets the given vector "result" with the cross product of "left" and "right"
  21541. * The cross product is then orthogonal to both "left" and "right"
  21542. * @param left defines the left operand
  21543. * @param right defines the right operand
  21544. * @param result defines the Vector3 where to store the result
  21545. */
  21546. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21547. /**
  21548. * Returns a new Vector3 as the normalization of the given vector
  21549. * @param vector defines the Vector3 to normalize
  21550. * @returns the new Vector3
  21551. */
  21552. static Normalize(vector: Vector3): Vector3;
  21553. /**
  21554. * Sets the given vector "result" with the normalization of the given first vector
  21555. * @param vector defines the Vector3 to normalize
  21556. * @param result defines the Vector3 where to store the result
  21557. */
  21558. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  21559. /**
  21560. * Project a Vector3 onto screen space
  21561. * @param vector defines the Vector3 to project
  21562. * @param world defines the world matrix to use
  21563. * @param transform defines the transform (view x projection) matrix to use
  21564. * @param viewport defines the screen viewport to use
  21565. * @returns the new Vector3
  21566. */
  21567. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  21568. /** @hidden */
  21569. private static UnprojectFromInvertedMatrixToRef;
  21570. /**
  21571. * Unproject from screen space to object space
  21572. * @param source defines the screen space Vector3 to use
  21573. * @param viewportWidth defines the current width of the viewport
  21574. * @param viewportHeight defines the current height of the viewport
  21575. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21576. * @param transform defines the transform (view x projection) matrix to use
  21577. * @returns the new Vector3
  21578. */
  21579. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  21580. /**
  21581. * Unproject from screen space to object space
  21582. * @param source defines the screen space Vector3 to use
  21583. * @param viewportWidth defines the current width of the viewport
  21584. * @param viewportHeight defines the current height of the viewport
  21585. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21586. * @param view defines the view matrix to use
  21587. * @param projection defines the projection matrix to use
  21588. * @returns the new Vector3
  21589. */
  21590. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  21591. /**
  21592. * Unproject from screen space to object space
  21593. * @param source defines the screen space Vector3 to use
  21594. * @param viewportWidth defines the current width of the viewport
  21595. * @param viewportHeight defines the current height of the viewport
  21596. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21597. * @param view defines the view matrix to use
  21598. * @param projection defines the projection matrix to use
  21599. * @param result defines the Vector3 where to store the result
  21600. */
  21601. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  21602. /**
  21603. * Unproject from screen space to object space
  21604. * @param sourceX defines the screen space x coordinate to use
  21605. * @param sourceY defines the screen space y coordinate to use
  21606. * @param sourceZ defines the screen space z coordinate to use
  21607. * @param viewportWidth defines the current width of the viewport
  21608. * @param viewportHeight defines the current height of the viewport
  21609. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21610. * @param view defines the view matrix to use
  21611. * @param projection defines the projection matrix to use
  21612. * @param result defines the Vector3 where to store the result
  21613. */
  21614. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  21615. /**
  21616. * Unproject a ray from screen space to object space
  21617. * @param sourceX defines the screen space x coordinate to use
  21618. * @param sourceY defines the screen space y coordinate to use
  21619. * @param viewportWidth defines the current width of the viewport
  21620. * @param viewportHeight defines the current height of the viewport
  21621. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21622. * @param view defines the view matrix to use
  21623. * @param projection defines the projection matrix to use
  21624. * @param ray defines the Ray where to store the result
  21625. */
  21626. static UnprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: Readonly<Matrix>, view: Readonly<Matrix>, projection: Readonly<Matrix>, ray: Ray): void;
  21627. /**
  21628. * Gets the minimal coordinate values between two Vector3
  21629. * @param left defines the first operand
  21630. * @param right defines the second operand
  21631. * @returns the new Vector3
  21632. */
  21633. static Minimize(left: Vector3, right: Vector3): Vector3;
  21634. /**
  21635. * Gets the maximal coordinate values between two Vector3
  21636. * @param left defines the first operand
  21637. * @param right defines the second operand
  21638. * @returns the new Vector3
  21639. */
  21640. static Maximize(left: Vector3, right: Vector3): Vector3;
  21641. /**
  21642. * Returns the distance between the vectors "value1" and "value2"
  21643. * @param value1 defines the first operand
  21644. * @param value2 defines the second operand
  21645. * @returns the distance
  21646. */
  21647. static Distance(value1: Vector3, value2: Vector3): number;
  21648. /**
  21649. * Returns the squared distance between the vectors "value1" and "value2"
  21650. * @param value1 defines the first operand
  21651. * @param value2 defines the second operand
  21652. * @returns the squared distance
  21653. */
  21654. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  21655. /**
  21656. * Returns a new Vector3 located at the center between "value1" and "value2"
  21657. * @param value1 defines the first operand
  21658. * @param value2 defines the second operand
  21659. * @returns the new Vector3
  21660. */
  21661. static Center(value1: Vector3, value2: Vector3): Vector3;
  21662. /**
  21663. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21664. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21665. * to something in order to rotate it from its local system to the given target system
  21666. * Note: axis1, axis2 and axis3 are normalized during this operation
  21667. * @param axis1 defines the first axis
  21668. * @param axis2 defines the second axis
  21669. * @param axis3 defines the third axis
  21670. * @returns a new Vector3
  21671. */
  21672. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  21673. /**
  21674. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21675. * @param axis1 defines the first axis
  21676. * @param axis2 defines the second axis
  21677. * @param axis3 defines the third axis
  21678. * @param ref defines the Vector3 where to store the result
  21679. */
  21680. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  21681. }
  21682. /**
  21683. * Vector4 class created for EulerAngle class conversion to Quaternion
  21684. */
  21685. class Vector4 {
  21686. /** x value of the vector */
  21687. x: number;
  21688. /** y value of the vector */
  21689. y: number;
  21690. /** z value of the vector */
  21691. z: number;
  21692. /** w value of the vector */
  21693. w: number;
  21694. /**
  21695. * Creates a Vector4 object from the given floats.
  21696. * @param x x value of the vector
  21697. * @param y y value of the vector
  21698. * @param z z value of the vector
  21699. * @param w w value of the vector
  21700. */
  21701. constructor(
  21702. /** x value of the vector */
  21703. x: number,
  21704. /** y value of the vector */
  21705. y: number,
  21706. /** z value of the vector */
  21707. z: number,
  21708. /** w value of the vector */
  21709. w: number);
  21710. /**
  21711. * Returns the string with the Vector4 coordinates.
  21712. * @returns a string containing all the vector values
  21713. */
  21714. toString(): string;
  21715. /**
  21716. * Returns the string "Vector4".
  21717. * @returns "Vector4"
  21718. */
  21719. getClassName(): string;
  21720. /**
  21721. * Returns the Vector4 hash code.
  21722. * @returns a unique hash code
  21723. */
  21724. getHashCode(): number;
  21725. /**
  21726. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  21727. * @returns the resulting array
  21728. */
  21729. asArray(): number[];
  21730. /**
  21731. * Populates the given array from the given index with the Vector4 coordinates.
  21732. * @param array array to populate
  21733. * @param index index of the array to start at (default: 0)
  21734. * @returns the Vector4.
  21735. */
  21736. toArray(array: FloatArray, index?: number): Vector4;
  21737. /**
  21738. * Adds the given vector to the current Vector4.
  21739. * @param otherVector the vector to add
  21740. * @returns the updated Vector4.
  21741. */
  21742. addInPlace(otherVector: Vector4): Vector4;
  21743. /**
  21744. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  21745. * @param otherVector the vector to add
  21746. * @returns the resulting vector
  21747. */
  21748. add(otherVector: Vector4): Vector4;
  21749. /**
  21750. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  21751. * @param otherVector the vector to add
  21752. * @param result the vector to store the result
  21753. * @returns the current Vector4.
  21754. */
  21755. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  21756. /**
  21757. * Subtract in place the given vector from the current Vector4.
  21758. * @param otherVector the vector to subtract
  21759. * @returns the updated Vector4.
  21760. */
  21761. subtractInPlace(otherVector: Vector4): Vector4;
  21762. /**
  21763. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  21764. * @param otherVector the vector to add
  21765. * @returns the new vector with the result
  21766. */
  21767. subtract(otherVector: Vector4): Vector4;
  21768. /**
  21769. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  21770. * @param otherVector the vector to subtract
  21771. * @param result the vector to store the result
  21772. * @returns the current Vector4.
  21773. */
  21774. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  21775. /**
  21776. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21777. */
  21778. /**
  21779. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21780. * @param x value to subtract
  21781. * @param y value to subtract
  21782. * @param z value to subtract
  21783. * @param w value to subtract
  21784. * @returns new vector containing the result
  21785. */
  21786. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21787. /**
  21788. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21789. * @param x value to subtract
  21790. * @param y value to subtract
  21791. * @param z value to subtract
  21792. * @param w value to subtract
  21793. * @param result the vector to store the result in
  21794. * @returns the current Vector4.
  21795. */
  21796. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  21797. /**
  21798. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  21799. * @returns a new vector with the negated values
  21800. */
  21801. negate(): Vector4;
  21802. /**
  21803. * Multiplies the current Vector4 coordinates by scale (float).
  21804. * @param scale the number to scale with
  21805. * @returns the updated Vector4.
  21806. */
  21807. scaleInPlace(scale: number): Vector4;
  21808. /**
  21809. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  21810. * @param scale the number to scale with
  21811. * @returns a new vector with the result
  21812. */
  21813. scale(scale: number): Vector4;
  21814. /**
  21815. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  21816. * @param scale the number to scale with
  21817. * @param result a vector to store the result in
  21818. * @returns the current Vector4.
  21819. */
  21820. scaleToRef(scale: number, result: Vector4): Vector4;
  21821. /**
  21822. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  21823. * @param scale defines the scale factor
  21824. * @param result defines the Vector4 object where to store the result
  21825. * @returns the unmodified current Vector4
  21826. */
  21827. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  21828. /**
  21829. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  21830. * @param otherVector the vector to compare against
  21831. * @returns true if they are equal
  21832. */
  21833. equals(otherVector: Vector4): boolean;
  21834. /**
  21835. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  21836. * @param otherVector vector to compare against
  21837. * @param epsilon (Default: very small number)
  21838. * @returns true if they are equal
  21839. */
  21840. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  21841. /**
  21842. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  21843. * @param x x value to compare against
  21844. * @param y y value to compare against
  21845. * @param z z value to compare against
  21846. * @param w w value to compare against
  21847. * @returns true if equal
  21848. */
  21849. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  21850. /**
  21851. * Multiplies in place the current Vector4 by the given one.
  21852. * @param otherVector vector to multiple with
  21853. * @returns the updated Vector4.
  21854. */
  21855. multiplyInPlace(otherVector: Vector4): Vector4;
  21856. /**
  21857. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  21858. * @param otherVector vector to multiple with
  21859. * @returns resulting new vector
  21860. */
  21861. multiply(otherVector: Vector4): Vector4;
  21862. /**
  21863. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  21864. * @param otherVector vector to multiple with
  21865. * @param result vector to store the result
  21866. * @returns the current Vector4.
  21867. */
  21868. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  21869. /**
  21870. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  21871. * @param x x value multiply with
  21872. * @param y y value multiply with
  21873. * @param z z value multiply with
  21874. * @param w w value multiply with
  21875. * @returns resulting new vector
  21876. */
  21877. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  21878. /**
  21879. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  21880. * @param otherVector vector to devide with
  21881. * @returns resulting new vector
  21882. */
  21883. divide(otherVector: Vector4): Vector4;
  21884. /**
  21885. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  21886. * @param otherVector vector to devide with
  21887. * @param result vector to store the result
  21888. * @returns the current Vector4.
  21889. */
  21890. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  21891. /**
  21892. * Divides the current Vector3 coordinates by the given ones.
  21893. * @param otherVector vector to devide with
  21894. * @returns the updated Vector3.
  21895. */
  21896. divideInPlace(otherVector: Vector4): Vector4;
  21897. /**
  21898. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  21899. * @param other defines the second operand
  21900. * @returns the current updated Vector4
  21901. */
  21902. minimizeInPlace(other: Vector4): Vector4;
  21903. /**
  21904. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  21905. * @param other defines the second operand
  21906. * @returns the current updated Vector4
  21907. */
  21908. maximizeInPlace(other: Vector4): Vector4;
  21909. /**
  21910. * Gets a new Vector4 from current Vector4 floored values
  21911. * @returns a new Vector4
  21912. */
  21913. floor(): Vector4;
  21914. /**
  21915. * Gets a new Vector4 from current Vector3 floored values
  21916. * @returns a new Vector4
  21917. */
  21918. fract(): Vector4;
  21919. /**
  21920. * Returns the Vector4 length (float).
  21921. * @returns the length
  21922. */
  21923. length(): number;
  21924. /**
  21925. * Returns the Vector4 squared length (float).
  21926. * @returns the length squared
  21927. */
  21928. lengthSquared(): number;
  21929. /**
  21930. * Normalizes in place the Vector4.
  21931. * @returns the updated Vector4.
  21932. */
  21933. normalize(): Vector4;
  21934. /**
  21935. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  21936. * @returns this converted to a new vector3
  21937. */
  21938. toVector3(): Vector3;
  21939. /**
  21940. * Returns a new Vector4 copied from the current one.
  21941. * @returns the new cloned vector
  21942. */
  21943. clone(): Vector4;
  21944. /**
  21945. * Updates the current Vector4 with the given one coordinates.
  21946. * @param source the source vector to copy from
  21947. * @returns the updated Vector4.
  21948. */
  21949. copyFrom(source: Vector4): Vector4;
  21950. /**
  21951. * Updates the current Vector4 coordinates with the given floats.
  21952. * @param x float to copy from
  21953. * @param y float to copy from
  21954. * @param z float to copy from
  21955. * @param w float to copy from
  21956. * @returns the updated Vector4.
  21957. */
  21958. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21959. /**
  21960. * Updates the current Vector4 coordinates with the given floats.
  21961. * @param x float to set from
  21962. * @param y float to set from
  21963. * @param z float to set from
  21964. * @param w float to set from
  21965. * @returns the updated Vector4.
  21966. */
  21967. set(x: number, y: number, z: number, w: number): Vector4;
  21968. /**
  21969. * Copies the given float to the current Vector3 coordinates
  21970. * @param v defines the x, y, z and w coordinates of the operand
  21971. * @returns the current updated Vector3
  21972. */
  21973. setAll(v: number): Vector4;
  21974. /**
  21975. * Returns a new Vector4 set from the starting index of the given array.
  21976. * @param array the array to pull values from
  21977. * @param offset the offset into the array to start at
  21978. * @returns the new vector
  21979. */
  21980. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  21981. /**
  21982. * Updates the given vector "result" from the starting index of the given array.
  21983. * @param array the array to pull values from
  21984. * @param offset the offset into the array to start at
  21985. * @param result the vector to store the result in
  21986. */
  21987. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  21988. /**
  21989. * Updates the given vector "result" from the starting index of the given Float32Array.
  21990. * @param array the array to pull values from
  21991. * @param offset the offset into the array to start at
  21992. * @param result the vector to store the result in
  21993. */
  21994. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  21995. /**
  21996. * Updates the given vector "result" coordinates from the given floats.
  21997. * @param x float to set from
  21998. * @param y float to set from
  21999. * @param z float to set from
  22000. * @param w float to set from
  22001. * @param result the vector to the floats in
  22002. */
  22003. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  22004. /**
  22005. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  22006. * @returns the new vector
  22007. */
  22008. static Zero(): Vector4;
  22009. /**
  22010. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  22011. * @returns the new vector
  22012. */
  22013. static One(): Vector4;
  22014. /**
  22015. * Returns a new normalized Vector4 from the given one.
  22016. * @param vector the vector to normalize
  22017. * @returns the vector
  22018. */
  22019. static Normalize(vector: Vector4): Vector4;
  22020. /**
  22021. * Updates the given vector "result" from the normalization of the given one.
  22022. * @param vector the vector to normalize
  22023. * @param result the vector to store the result in
  22024. */
  22025. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  22026. /**
  22027. * Returns a vector with the minimum values from the left and right vectors
  22028. * @param left left vector to minimize
  22029. * @param right right vector to minimize
  22030. * @returns a new vector with the minimum of the left and right vector values
  22031. */
  22032. static Minimize(left: Vector4, right: Vector4): Vector4;
  22033. /**
  22034. * Returns a vector with the maximum values from the left and right vectors
  22035. * @param left left vector to maximize
  22036. * @param right right vector to maximize
  22037. * @returns a new vector with the maximum of the left and right vector values
  22038. */
  22039. static Maximize(left: Vector4, right: Vector4): Vector4;
  22040. /**
  22041. * Returns the distance (float) between the vectors "value1" and "value2".
  22042. * @param value1 value to calulate the distance between
  22043. * @param value2 value to calulate the distance between
  22044. * @return the distance between the two vectors
  22045. */
  22046. static Distance(value1: Vector4, value2: Vector4): number;
  22047. /**
  22048. * Returns the squared distance (float) between the vectors "value1" and "value2".
  22049. * @param value1 value to calulate the distance between
  22050. * @param value2 value to calulate the distance between
  22051. * @return the distance between the two vectors squared
  22052. */
  22053. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  22054. /**
  22055. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  22056. * @param value1 value to calulate the center between
  22057. * @param value2 value to calulate the center between
  22058. * @return the center between the two vectors
  22059. */
  22060. static Center(value1: Vector4, value2: Vector4): Vector4;
  22061. /**
  22062. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  22063. * This methods computes transformed normalized direction vectors only.
  22064. * @param vector the vector to transform
  22065. * @param transformation the transformation matrix to apply
  22066. * @returns the new vector
  22067. */
  22068. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  22069. /**
  22070. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  22071. * This methods computes transformed normalized direction vectors only.
  22072. * @param vector the vector to transform
  22073. * @param transformation the transformation matrix to apply
  22074. * @param result the vector to store the result in
  22075. */
  22076. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  22077. /**
  22078. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  22079. * This methods computes transformed normalized direction vectors only.
  22080. * @param x value to transform
  22081. * @param y value to transform
  22082. * @param z value to transform
  22083. * @param w value to transform
  22084. * @param transformation the transformation matrix to apply
  22085. * @param result the vector to store the results in
  22086. */
  22087. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  22088. }
  22089. /**
  22090. * Interface for the size containing width and height
  22091. */
  22092. interface ISize {
  22093. /**
  22094. * Width
  22095. */
  22096. width: number;
  22097. /**
  22098. * Heighht
  22099. */
  22100. height: number;
  22101. }
  22102. /**
  22103. * Size containing widht and height
  22104. */
  22105. class Size implements ISize {
  22106. /**
  22107. * Width
  22108. */
  22109. width: number;
  22110. /**
  22111. * Height
  22112. */
  22113. height: number;
  22114. /**
  22115. * Creates a Size object from the given width and height (floats).
  22116. * @param width width of the new size
  22117. * @param height height of the new size
  22118. */
  22119. constructor(width: number, height: number);
  22120. /**
  22121. * Returns a string with the Size width and height
  22122. * @returns a string with the Size width and height
  22123. */
  22124. toString(): string;
  22125. /**
  22126. * "Size"
  22127. * @returns the string "Size"
  22128. */
  22129. getClassName(): string;
  22130. /**
  22131. * Returns the Size hash code.
  22132. * @returns a hash code for a unique width and height
  22133. */
  22134. getHashCode(): number;
  22135. /**
  22136. * Updates the current size from the given one.
  22137. * @param src the given size
  22138. */
  22139. copyFrom(src: Size): void;
  22140. /**
  22141. * Updates in place the current Size from the given floats.
  22142. * @param width width of the new size
  22143. * @param height height of the new size
  22144. * @returns the updated Size.
  22145. */
  22146. copyFromFloats(width: number, height: number): Size;
  22147. /**
  22148. * Updates in place the current Size from the given floats.
  22149. * @param width width to set
  22150. * @param height height to set
  22151. * @returns the updated Size.
  22152. */
  22153. set(width: number, height: number): Size;
  22154. /**
  22155. * Multiplies the width and height by numbers
  22156. * @param w factor to multiple the width by
  22157. * @param h factor to multiple the height by
  22158. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  22159. */
  22160. multiplyByFloats(w: number, h: number): Size;
  22161. /**
  22162. * Clones the size
  22163. * @returns a new Size copied from the given one.
  22164. */
  22165. clone(): Size;
  22166. /**
  22167. * True if the current Size and the given one width and height are strictly equal.
  22168. * @param other the other size to compare against
  22169. * @returns True if the current Size and the given one width and height are strictly equal.
  22170. */
  22171. equals(other: Size): boolean;
  22172. /**
  22173. * The surface of the Size : width * height (float).
  22174. */
  22175. readonly surface: number;
  22176. /**
  22177. * Create a new size of zero
  22178. * @returns a new Size set to (0.0, 0.0)
  22179. */
  22180. static Zero(): Size;
  22181. /**
  22182. * Sums the width and height of two sizes
  22183. * @param otherSize size to add to this size
  22184. * @returns a new Size set as the addition result of the current Size and the given one.
  22185. */
  22186. add(otherSize: Size): Size;
  22187. /**
  22188. * Subtracts the width and height of two
  22189. * @param otherSize size to subtract to this size
  22190. * @returns a new Size set as the subtraction result of the given one from the current Size.
  22191. */
  22192. subtract(otherSize: Size): Size;
  22193. /**
  22194. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  22195. * @param start starting size to lerp between
  22196. * @param end end size to lerp between
  22197. * @param amount amount to lerp between the start and end values
  22198. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  22199. */
  22200. static Lerp(start: Size, end: Size, amount: number): Size;
  22201. }
  22202. /**
  22203. * Class used to store quaternion data
  22204. * @see https://en.wikipedia.org/wiki/Quaternion
  22205. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  22206. */
  22207. class Quaternion {
  22208. /** defines the first component (0 by default) */
  22209. x: number;
  22210. /** defines the second component (0 by default) */
  22211. y: number;
  22212. /** defines the third component (0 by default) */
  22213. z: number;
  22214. /** defines the fourth component (1.0 by default) */
  22215. w: number;
  22216. /**
  22217. * Creates a new Quaternion from the given floats
  22218. * @param x defines the first component (0 by default)
  22219. * @param y defines the second component (0 by default)
  22220. * @param z defines the third component (0 by default)
  22221. * @param w defines the fourth component (1.0 by default)
  22222. */
  22223. constructor(
  22224. /** defines the first component (0 by default) */
  22225. x?: number,
  22226. /** defines the second component (0 by default) */
  22227. y?: number,
  22228. /** defines the third component (0 by default) */
  22229. z?: number,
  22230. /** defines the fourth component (1.0 by default) */
  22231. w?: number);
  22232. /**
  22233. * Gets a string representation for the current quaternion
  22234. * @returns a string with the Quaternion coordinates
  22235. */
  22236. toString(): string;
  22237. /**
  22238. * Gets the class name of the quaternion
  22239. * @returns the string "Quaternion"
  22240. */
  22241. getClassName(): string;
  22242. /**
  22243. * Gets a hash code for this quaternion
  22244. * @returns the quaternion hash code
  22245. */
  22246. getHashCode(): number;
  22247. /**
  22248. * Copy the quaternion to an array
  22249. * @returns a new array populated with 4 elements from the quaternion coordinates
  22250. */
  22251. asArray(): number[];
  22252. /**
  22253. * Check if two quaternions are equals
  22254. * @param otherQuaternion defines the second operand
  22255. * @return true if the current quaternion and the given one coordinates are strictly equals
  22256. */
  22257. equals(otherQuaternion: Quaternion): boolean;
  22258. /**
  22259. * Clone the current quaternion
  22260. * @returns a new quaternion copied from the current one
  22261. */
  22262. clone(): Quaternion;
  22263. /**
  22264. * Copy a quaternion to the current one
  22265. * @param other defines the other quaternion
  22266. * @returns the updated current quaternion
  22267. */
  22268. copyFrom(other: Quaternion): Quaternion;
  22269. /**
  22270. * Updates the current quaternion with the given float coordinates
  22271. * @param x defines the x coordinate
  22272. * @param y defines the y coordinate
  22273. * @param z defines the z coordinate
  22274. * @param w defines the w coordinate
  22275. * @returns the updated current quaternion
  22276. */
  22277. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  22278. /**
  22279. * Updates the current quaternion from the given float coordinates
  22280. * @param x defines the x coordinate
  22281. * @param y defines the y coordinate
  22282. * @param z defines the z coordinate
  22283. * @param w defines the w coordinate
  22284. * @returns the updated current quaternion
  22285. */
  22286. set(x: number, y: number, z: number, w: number): Quaternion;
  22287. /**
  22288. * Adds two quaternions
  22289. * @param other defines the second operand
  22290. * @returns a new quaternion as the addition result of the given one and the current quaternion
  22291. */
  22292. add(other: Quaternion): Quaternion;
  22293. /**
  22294. * Add a quaternion to the current one
  22295. * @param other defines the quaternion to add
  22296. * @returns the current quaternion
  22297. */
  22298. addInPlace(other: Quaternion): Quaternion;
  22299. /**
  22300. * Subtract two quaternions
  22301. * @param other defines the second operand
  22302. * @returns a new quaternion as the subtraction result of the given one from the current one
  22303. */
  22304. subtract(other: Quaternion): Quaternion;
  22305. /**
  22306. * Multiplies the current quaternion by a scale factor
  22307. * @param value defines the scale factor
  22308. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  22309. */
  22310. scale(value: number): Quaternion;
  22311. /**
  22312. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  22313. * @param scale defines the scale factor
  22314. * @param result defines the Quaternion object where to store the result
  22315. * @returns the unmodified current quaternion
  22316. */
  22317. scaleToRef(scale: number, result: Quaternion): Quaternion;
  22318. /**
  22319. * Multiplies in place the current quaternion by a scale factor
  22320. * @param value defines the scale factor
  22321. * @returns the current modified quaternion
  22322. */
  22323. scaleInPlace(value: number): Quaternion;
  22324. /**
  22325. * Scale the current quaternion values by a factor and add the result to a given quaternion
  22326. * @param scale defines the scale factor
  22327. * @param result defines the Quaternion object where to store the result
  22328. * @returns the unmodified current quaternion
  22329. */
  22330. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  22331. /**
  22332. * Multiplies two quaternions
  22333. * @param q1 defines the second operand
  22334. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  22335. */
  22336. multiply(q1: Quaternion): Quaternion;
  22337. /**
  22338. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  22339. * @param q1 defines the second operand
  22340. * @param result defines the target quaternion
  22341. * @returns the current quaternion
  22342. */
  22343. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  22344. /**
  22345. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  22346. * @param q1 defines the second operand
  22347. * @returns the currentupdated quaternion
  22348. */
  22349. multiplyInPlace(q1: Quaternion): Quaternion;
  22350. /**
  22351. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  22352. * @param ref defines the target quaternion
  22353. * @returns the current quaternion
  22354. */
  22355. conjugateToRef(ref: Quaternion): Quaternion;
  22356. /**
  22357. * Conjugates in place (1-q) the current quaternion
  22358. * @returns the current updated quaternion
  22359. */
  22360. conjugateInPlace(): Quaternion;
  22361. /**
  22362. * Conjugates in place (1-q) the current quaternion
  22363. * @returns a new quaternion
  22364. */
  22365. conjugate(): Quaternion;
  22366. /**
  22367. * Gets length of current quaternion
  22368. * @returns the quaternion length (float)
  22369. */
  22370. length(): number;
  22371. /**
  22372. * Normalize in place the current quaternion
  22373. * @returns the current updated quaternion
  22374. */
  22375. normalize(): Quaternion;
  22376. /**
  22377. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  22378. * @param order is a reserved parameter and is ignore for now
  22379. * @returns a new Vector3 containing the Euler angles
  22380. */
  22381. toEulerAngles(order?: string): Vector3;
  22382. /**
  22383. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  22384. * @param result defines the vector which will be filled with the Euler angles
  22385. * @param order is a reserved parameter and is ignore for now
  22386. * @returns the current unchanged quaternion
  22387. */
  22388. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  22389. /**
  22390. * Updates the given rotation matrix with the current quaternion values
  22391. * @param result defines the target matrix
  22392. * @returns the current unchanged quaternion
  22393. */
  22394. toRotationMatrix(result: Matrix): Quaternion;
  22395. /**
  22396. * Updates the current quaternion from the given rotation matrix values
  22397. * @param matrix defines the source matrix
  22398. * @returns the current updated quaternion
  22399. */
  22400. fromRotationMatrix(matrix: Matrix): Quaternion;
  22401. /**
  22402. * Creates a new quaternion from a rotation matrix
  22403. * @param matrix defines the source matrix
  22404. * @returns a new quaternion created from the given rotation matrix values
  22405. */
  22406. static FromRotationMatrix(matrix: Matrix): Quaternion;
  22407. /**
  22408. * Updates the given quaternion with the given rotation matrix values
  22409. * @param matrix defines the source matrix
  22410. * @param result defines the target quaternion
  22411. */
  22412. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  22413. /**
  22414. * Returns the dot product (float) between the quaternions "left" and "right"
  22415. * @param left defines the left operand
  22416. * @param right defines the right operand
  22417. * @returns the dot product
  22418. */
  22419. static Dot(left: Quaternion, right: Quaternion): number;
  22420. /**
  22421. * Checks if the two quaternions are close to each other
  22422. * @param quat0 defines the first quaternion to check
  22423. * @param quat1 defines the second quaternion to check
  22424. * @returns true if the two quaternions are close to each other
  22425. */
  22426. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  22427. /**
  22428. * Creates an empty quaternion
  22429. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  22430. */
  22431. static Zero(): Quaternion;
  22432. /**
  22433. * Inverse a given quaternion
  22434. * @param q defines the source quaternion
  22435. * @returns a new quaternion as the inverted current quaternion
  22436. */
  22437. static Inverse(q: Quaternion): Quaternion;
  22438. /**
  22439. * Inverse a given quaternion
  22440. * @param q defines the source quaternion
  22441. * @param result the quaternion the result will be stored in
  22442. * @returns the result quaternion
  22443. */
  22444. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  22445. /**
  22446. * Creates an identity quaternion
  22447. * @returns the identity quaternion
  22448. */
  22449. static Identity(): Quaternion;
  22450. /**
  22451. * Gets a boolean indicating if the given quaternion is identity
  22452. * @param quaternion defines the quaternion to check
  22453. * @returns true if the quaternion is identity
  22454. */
  22455. static IsIdentity(quaternion: Quaternion): boolean;
  22456. /**
  22457. * Creates a quaternion from a rotation around an axis
  22458. * @param axis defines the axis to use
  22459. * @param angle defines the angle to use
  22460. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22461. */
  22462. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  22463. /**
  22464. * Creates a rotation around an axis and stores it into the given quaternion
  22465. * @param axis defines the axis to use
  22466. * @param angle defines the angle to use
  22467. * @param result defines the target quaternion
  22468. * @returns the target quaternion
  22469. */
  22470. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  22471. /**
  22472. * Creates a new quaternion from data stored into an array
  22473. * @param array defines the data source
  22474. * @param offset defines the offset in the source array where the data starts
  22475. * @returns a new quaternion
  22476. */
  22477. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  22478. /**
  22479. * Create a quaternion from Euler rotation angles
  22480. * @param x Pitch
  22481. * @param y Yaw
  22482. * @param z Roll
  22483. * @returns the new Quaternion
  22484. */
  22485. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  22486. /**
  22487. * Updates a quaternion from Euler rotation angles
  22488. * @param x Pitch
  22489. * @param y Yaw
  22490. * @param z Roll
  22491. * @param result the quaternion to store the result
  22492. * @returns the updated quaternion
  22493. */
  22494. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  22495. /**
  22496. * Create a quaternion from Euler rotation vector
  22497. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22498. * @returns the new Quaternion
  22499. */
  22500. static FromEulerVector(vec: Vector3): Quaternion;
  22501. /**
  22502. * Updates a quaternion from Euler rotation vector
  22503. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22504. * @param result the quaternion to store the result
  22505. * @returns the updated quaternion
  22506. */
  22507. static FromEulerVectorToRef(vec: Vector3, result: Quaternion): Quaternion;
  22508. /**
  22509. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22510. * @param yaw defines the rotation around Y axis
  22511. * @param pitch defines the rotation around X axis
  22512. * @param roll defines the rotation around Z axis
  22513. * @returns the new quaternion
  22514. */
  22515. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22516. /**
  22517. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22518. * @param yaw defines the rotation around Y axis
  22519. * @param pitch defines the rotation around X axis
  22520. * @param roll defines the rotation around Z axis
  22521. * @param result defines the target quaternion
  22522. */
  22523. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22524. /**
  22525. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22526. * @param alpha defines the rotation around first axis
  22527. * @param beta defines the rotation around second axis
  22528. * @param gamma defines the rotation around third axis
  22529. * @returns the new quaternion
  22530. */
  22531. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22532. /**
  22533. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22534. * @param alpha defines the rotation around first axis
  22535. * @param beta defines the rotation around second axis
  22536. * @param gamma defines the rotation around third axis
  22537. * @param result defines the target quaternion
  22538. */
  22539. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22540. /**
  22541. * 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)
  22542. * @param axis1 defines the first axis
  22543. * @param axis2 defines the second axis
  22544. * @param axis3 defines the third axis
  22545. * @returns the new quaternion
  22546. */
  22547. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  22548. /**
  22549. * 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
  22550. * @param axis1 defines the first axis
  22551. * @param axis2 defines the second axis
  22552. * @param axis3 defines the third axis
  22553. * @param ref defines the target quaternion
  22554. */
  22555. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  22556. /**
  22557. * Interpolates between two quaternions
  22558. * @param left defines first quaternion
  22559. * @param right defines second quaternion
  22560. * @param amount defines the gradient to use
  22561. * @returns the new interpolated quaternion
  22562. */
  22563. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  22564. /**
  22565. * Interpolates between two quaternions and stores it into a target quaternion
  22566. * @param left defines first quaternion
  22567. * @param right defines second quaternion
  22568. * @param amount defines the gradient to use
  22569. * @param result defines the target quaternion
  22570. */
  22571. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  22572. /**
  22573. * Interpolate between two quaternions using Hermite interpolation
  22574. * @param value1 defines first quaternion
  22575. * @param tangent1 defines the incoming tangent
  22576. * @param value2 defines second quaternion
  22577. * @param tangent2 defines the outgoing tangent
  22578. * @param amount defines the target quaternion
  22579. * @returns the new interpolated quaternion
  22580. */
  22581. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  22582. }
  22583. /**
  22584. * Class used to store matrix data (4x4)
  22585. */
  22586. class Matrix {
  22587. private static _updateFlagSeed;
  22588. private static _identityReadOnly;
  22589. private _isIdentity;
  22590. private _isIdentityDirty;
  22591. private _isIdentity3x2;
  22592. private _isIdentity3x2Dirty;
  22593. /**
  22594. * Gets the update flag of the matrix which is an unique number for the matrix.
  22595. * It will be incremented every time the matrix data change.
  22596. * You can use it to speed the comparison between two versions of the same matrix.
  22597. */
  22598. updateFlag: number;
  22599. private readonly _m;
  22600. /**
  22601. * Gets the internal data of the matrix
  22602. */
  22603. readonly m: Readonly<Float32Array>;
  22604. /** @hidden */
  22605. _markAsUpdated(): void;
  22606. /** @hidden */
  22607. private _updateIdentityStatus;
  22608. /**
  22609. * Creates an empty matrix (filled with zeros)
  22610. */
  22611. constructor();
  22612. /**
  22613. * Check if the current matrix is identity
  22614. * @returns true is the matrix is the identity matrix
  22615. */
  22616. isIdentity(): boolean;
  22617. /**
  22618. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  22619. * @returns true is the matrix is the identity matrix
  22620. */
  22621. isIdentityAs3x2(): boolean;
  22622. /**
  22623. * Gets the determinant of the matrix
  22624. * @returns the matrix determinant
  22625. */
  22626. determinant(): number;
  22627. /**
  22628. * Returns the matrix as a Float32Array
  22629. * @returns the matrix underlying array
  22630. */
  22631. toArray(): Readonly<Float32Array>;
  22632. /**
  22633. * Returns the matrix as a Float32Array
  22634. * @returns the matrix underlying array.
  22635. */
  22636. asArray(): Readonly<Float32Array>;
  22637. /**
  22638. * Inverts the current matrix in place
  22639. * @returns the current inverted matrix
  22640. */
  22641. invert(): Matrix;
  22642. /**
  22643. * Sets all the matrix elements to zero
  22644. * @returns the current matrix
  22645. */
  22646. reset(): Matrix;
  22647. /**
  22648. * Adds the current matrix with a second one
  22649. * @param other defines the matrix to add
  22650. * @returns a new matrix as the addition of the current matrix and the given one
  22651. */
  22652. add(other: Matrix): Matrix;
  22653. /**
  22654. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22655. * @param other defines the matrix to add
  22656. * @param result defines the target matrix
  22657. * @returns the current matrix
  22658. */
  22659. addToRef(other: Matrix, result: Matrix): Matrix;
  22660. /**
  22661. * Adds in place the given matrix to the current matrix
  22662. * @param other defines the second operand
  22663. * @returns the current updated matrix
  22664. */
  22665. addToSelf(other: Matrix): Matrix;
  22666. /**
  22667. * Sets the given matrix to the current inverted Matrix
  22668. * @param other defines the target matrix
  22669. * @returns the unmodified current matrix
  22670. */
  22671. invertToRef(other: Matrix): Matrix;
  22672. /**
  22673. * add a value at the specified position in the current Matrix
  22674. * @param index the index of the value within the matrix. between 0 and 15.
  22675. * @param value the value to be added
  22676. * @returns the current updated matrix
  22677. */
  22678. addAtIndex(index: number, value: number): Matrix;
  22679. /**
  22680. * mutiply the specified position in the current Matrix by a value
  22681. * @param index the index of the value within the matrix. between 0 and 15.
  22682. * @param value the value to be added
  22683. * @returns the current updated matrix
  22684. */
  22685. multiplyAtIndex(index: number, value: number): Matrix;
  22686. /**
  22687. * Inserts the translation vector (using 3 floats) in the current matrix
  22688. * @param x defines the 1st component of the translation
  22689. * @param y defines the 2nd component of the translation
  22690. * @param z defines the 3rd component of the translation
  22691. * @returns the current updated matrix
  22692. */
  22693. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  22694. /**
  22695. * Inserts the translation vector in the current matrix
  22696. * @param vector3 defines the translation to insert
  22697. * @returns the current updated matrix
  22698. */
  22699. setTranslation(vector3: Vector3): Matrix;
  22700. /**
  22701. * Gets the translation value of the current matrix
  22702. * @returns a new Vector3 as the extracted translation from the matrix
  22703. */
  22704. getTranslation(): Vector3;
  22705. /**
  22706. * Fill a Vector3 with the extracted translation from the matrix
  22707. * @param result defines the Vector3 where to store the translation
  22708. * @returns the current matrix
  22709. */
  22710. getTranslationToRef(result: Vector3): Matrix;
  22711. /**
  22712. * Remove rotation and scaling part from the matrix
  22713. * @returns the updated matrix
  22714. */
  22715. removeRotationAndScaling(): Matrix;
  22716. /**
  22717. * Multiply two matrices
  22718. * @param other defines the second operand
  22719. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  22720. */
  22721. multiply(other: Readonly<Matrix>): Matrix;
  22722. /**
  22723. * Copy the current matrix from the given one
  22724. * @param other defines the source matrix
  22725. * @returns the current updated matrix
  22726. */
  22727. copyFrom(other: Readonly<Matrix>): Matrix;
  22728. /**
  22729. * Populates the given array from the starting index with the current matrix values
  22730. * @param array defines the target array
  22731. * @param offset defines the offset in the target array where to start storing values
  22732. * @returns the current matrix
  22733. */
  22734. copyToArray(array: Float32Array, offset?: number): Matrix;
  22735. /**
  22736. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  22737. * @param other defines the second operand
  22738. * @param result defines the matrix where to store the multiplication
  22739. * @returns the current matrix
  22740. */
  22741. multiplyToRef(other: Readonly<Matrix>, result: Matrix): Matrix;
  22742. /**
  22743. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  22744. * @param other defines the second operand
  22745. * @param result defines the array where to store the multiplication
  22746. * @param offset defines the offset in the target array where to start storing values
  22747. * @returns the current matrix
  22748. */
  22749. multiplyToArray(other: Readonly<Matrix>, result: Float32Array, offset: number): Matrix;
  22750. /**
  22751. * Check equality between this matrix and a second one
  22752. * @param value defines the second matrix to compare
  22753. * @returns true is the current matrix and the given one values are strictly equal
  22754. */
  22755. equals(value: Matrix): boolean;
  22756. /**
  22757. * Clone the current matrix
  22758. * @returns a new matrix from the current matrix
  22759. */
  22760. clone(): Matrix;
  22761. /**
  22762. * Returns the name of the current matrix class
  22763. * @returns the string "Matrix"
  22764. */
  22765. getClassName(): string;
  22766. /**
  22767. * Gets the hash code of the current matrix
  22768. * @returns the hash code
  22769. */
  22770. getHashCode(): number;
  22771. /**
  22772. * Decomposes the current Matrix into a translation, rotation and scaling components
  22773. * @param scale defines the scale vector3 given as a reference to update
  22774. * @param rotation defines the rotation quaternion given as a reference to update
  22775. * @param translation defines the translation vector3 given as a reference to update
  22776. * @returns true if operation was successful
  22777. */
  22778. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  22779. /**
  22780. * Gets specific row of the matrix
  22781. * @param index defines the number of the row to get
  22782. * @returns the index-th row of the current matrix as a new Vector4
  22783. */
  22784. getRow(index: number): Nullable<Vector4>;
  22785. /**
  22786. * Sets the index-th row of the current matrix to the vector4 values
  22787. * @param index defines the number of the row to set
  22788. * @param row defines the target vector4
  22789. * @returns the updated current matrix
  22790. */
  22791. setRow(index: number, row: Vector4): Matrix;
  22792. /**
  22793. * Compute the transpose of the matrix
  22794. * @returns the new transposed matrix
  22795. */
  22796. transpose(): Matrix;
  22797. /**
  22798. * Compute the transpose of the matrix and store it in a given matrix
  22799. * @param result defines the target matrix
  22800. * @returns the current matrix
  22801. */
  22802. transposeToRef(result: Matrix): Matrix;
  22803. /**
  22804. * Sets the index-th row of the current matrix with the given 4 x float values
  22805. * @param index defines the row index
  22806. * @param x defines the x component to set
  22807. * @param y defines the y component to set
  22808. * @param z defines the z component to set
  22809. * @param w defines the w component to set
  22810. * @returns the updated current matrix
  22811. */
  22812. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  22813. /**
  22814. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  22815. * @param scale defines the scale factor
  22816. * @returns a new matrix
  22817. */
  22818. scale(scale: number): Matrix;
  22819. /**
  22820. * Scale the current matrix values by a factor to a given result matrix
  22821. * @param scale defines the scale factor
  22822. * @param result defines the matrix to store the result
  22823. * @returns the current matrix
  22824. */
  22825. scaleToRef(scale: number, result: Matrix): Matrix;
  22826. /**
  22827. * Scale the current matrix values by a factor and add the result to a given matrix
  22828. * @param scale defines the scale factor
  22829. * @param result defines the Matrix to store the result
  22830. * @returns the current matrix
  22831. */
  22832. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  22833. /**
  22834. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  22835. * @param ref matrix to store the result
  22836. */
  22837. toNormalMatrix(ref: Matrix): void;
  22838. /**
  22839. * Gets only rotation part of the current matrix
  22840. * @returns a new matrix sets to the extracted rotation matrix from the current one
  22841. */
  22842. getRotationMatrix(): Matrix;
  22843. /**
  22844. * Extracts the rotation matrix from the current one and sets it as the given "result"
  22845. * @param result defines the target matrix to store data to
  22846. * @returns the current matrix
  22847. */
  22848. getRotationMatrixToRef(result: Matrix): Matrix;
  22849. /**
  22850. * Toggles model matrix from being right handed to left handed in place and vice versa
  22851. */
  22852. toggleModelMatrixHandInPlace(): void;
  22853. /**
  22854. * Toggles projection matrix from being right handed to left handed in place and vice versa
  22855. */
  22856. toggleProjectionMatrixHandInPlace(): void;
  22857. /**
  22858. * Creates a matrix from an array
  22859. * @param array defines the source array
  22860. * @param offset defines an offset in the source array
  22861. * @returns a new Matrix set from the starting index of the given array
  22862. */
  22863. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  22864. /**
  22865. * Copy the content of an array into a given matrix
  22866. * @param array defines the source array
  22867. * @param offset defines an offset in the source array
  22868. * @param result defines the target matrix
  22869. */
  22870. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  22871. /**
  22872. * Stores an array into a matrix after having multiplied each component by a given factor
  22873. * @param array defines the source array
  22874. * @param offset defines the offset in the source array
  22875. * @param scale defines the scaling factor
  22876. * @param result defines the target matrix
  22877. */
  22878. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  22879. /**
  22880. * Gets an identity matrix that must not be updated
  22881. */
  22882. static readonly IdentityReadOnly: Readonly<Matrix>;
  22883. /**
  22884. * Stores a list of values (16) inside a given matrix
  22885. * @param initialM11 defines 1st value of 1st row
  22886. * @param initialM12 defines 2nd value of 1st row
  22887. * @param initialM13 defines 3rd value of 1st row
  22888. * @param initialM14 defines 4th value of 1st row
  22889. * @param initialM21 defines 1st value of 2nd row
  22890. * @param initialM22 defines 2nd value of 2nd row
  22891. * @param initialM23 defines 3rd value of 2nd row
  22892. * @param initialM24 defines 4th value of 2nd row
  22893. * @param initialM31 defines 1st value of 3rd row
  22894. * @param initialM32 defines 2nd value of 3rd row
  22895. * @param initialM33 defines 3rd value of 3rd row
  22896. * @param initialM34 defines 4th value of 3rd row
  22897. * @param initialM41 defines 1st value of 4th row
  22898. * @param initialM42 defines 2nd value of 4th row
  22899. * @param initialM43 defines 3rd value of 4th row
  22900. * @param initialM44 defines 4th value of 4th row
  22901. * @param result defines the target matrix
  22902. */
  22903. 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;
  22904. /**
  22905. * Creates new matrix from a list of values (16)
  22906. * @param initialM11 defines 1st value of 1st row
  22907. * @param initialM12 defines 2nd value of 1st row
  22908. * @param initialM13 defines 3rd value of 1st row
  22909. * @param initialM14 defines 4th value of 1st row
  22910. * @param initialM21 defines 1st value of 2nd row
  22911. * @param initialM22 defines 2nd value of 2nd row
  22912. * @param initialM23 defines 3rd value of 2nd row
  22913. * @param initialM24 defines 4th value of 2nd row
  22914. * @param initialM31 defines 1st value of 3rd row
  22915. * @param initialM32 defines 2nd value of 3rd row
  22916. * @param initialM33 defines 3rd value of 3rd row
  22917. * @param initialM34 defines 4th value of 3rd row
  22918. * @param initialM41 defines 1st value of 4th row
  22919. * @param initialM42 defines 2nd value of 4th row
  22920. * @param initialM43 defines 3rd value of 4th row
  22921. * @param initialM44 defines 4th value of 4th row
  22922. * @returns the new matrix
  22923. */
  22924. 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;
  22925. /**
  22926. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22927. * @param scale defines the scale vector3
  22928. * @param rotation defines the rotation quaternion
  22929. * @param translation defines the translation vector3
  22930. * @returns a new matrix
  22931. */
  22932. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  22933. /**
  22934. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22935. * @param scale defines the scale vector3
  22936. * @param rotation defines the rotation quaternion
  22937. * @param translation defines the translation vector3
  22938. * @param result defines the target matrix
  22939. */
  22940. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  22941. /**
  22942. * Creates a new identity matrix
  22943. * @returns a new identity matrix
  22944. */
  22945. static Identity(): Matrix;
  22946. /**
  22947. * Creates a new identity matrix and stores the result in a given matrix
  22948. * @param result defines the target matrix
  22949. */
  22950. static IdentityToRef(result: Matrix): void;
  22951. /**
  22952. * Creates a new zero matrix
  22953. * @returns a new zero matrix
  22954. */
  22955. static Zero(): Matrix;
  22956. /**
  22957. * Creates a new rotation matrix for "angle" radians around the X axis
  22958. * @param angle defines the angle (in radians) to use
  22959. * @return the new matrix
  22960. */
  22961. static RotationX(angle: number): Matrix;
  22962. /**
  22963. * Creates a new matrix as the invert of a given matrix
  22964. * @param source defines the source matrix
  22965. * @returns the new matrix
  22966. */
  22967. static Invert(source: Matrix): Matrix;
  22968. /**
  22969. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  22970. * @param angle defines the angle (in radians) to use
  22971. * @param result defines the target matrix
  22972. */
  22973. static RotationXToRef(angle: number, result: Matrix): void;
  22974. /**
  22975. * Creates a new rotation matrix for "angle" radians around the Y axis
  22976. * @param angle defines the angle (in radians) to use
  22977. * @return the new matrix
  22978. */
  22979. static RotationY(angle: number): Matrix;
  22980. /**
  22981. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  22982. * @param angle defines the angle (in radians) to use
  22983. * @param result defines the target matrix
  22984. */
  22985. static RotationYToRef(angle: number, result: Matrix): void;
  22986. /**
  22987. * Creates a new rotation matrix for "angle" radians around the Z axis
  22988. * @param angle defines the angle (in radians) to use
  22989. * @return the new matrix
  22990. */
  22991. static RotationZ(angle: number): Matrix;
  22992. /**
  22993. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  22994. * @param angle defines the angle (in radians) to use
  22995. * @param result defines the target matrix
  22996. */
  22997. static RotationZToRef(angle: number, result: Matrix): void;
  22998. /**
  22999. * Creates a new rotation matrix for "angle" radians around the given axis
  23000. * @param axis defines the axis to use
  23001. * @param angle defines the angle (in radians) to use
  23002. * @return the new matrix
  23003. */
  23004. static RotationAxis(axis: Vector3, angle: number): Matrix;
  23005. /**
  23006. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  23007. * @param axis defines the axis to use
  23008. * @param angle defines the angle (in radians) to use
  23009. * @param result defines the target matrix
  23010. */
  23011. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  23012. /**
  23013. * Creates a rotation matrix
  23014. * @param yaw defines the yaw angle in radians (Y axis)
  23015. * @param pitch defines the pitch angle in radians (X axis)
  23016. * @param roll defines the roll angle in radians (X axis)
  23017. * @returns the new rotation matrix
  23018. */
  23019. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  23020. /**
  23021. * Creates a rotation matrix and stores it in a given matrix
  23022. * @param yaw defines the yaw angle in radians (Y axis)
  23023. * @param pitch defines the pitch angle in radians (X axis)
  23024. * @param roll defines the roll angle in radians (X axis)
  23025. * @param result defines the target matrix
  23026. */
  23027. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  23028. /**
  23029. * Creates a scaling matrix
  23030. * @param x defines the scale factor on X axis
  23031. * @param y defines the scale factor on Y axis
  23032. * @param z defines the scale factor on Z axis
  23033. * @returns the new matrix
  23034. */
  23035. static Scaling(x: number, y: number, z: number): Matrix;
  23036. /**
  23037. * Creates a scaling matrix and stores it in a given matrix
  23038. * @param x defines the scale factor on X axis
  23039. * @param y defines the scale factor on Y axis
  23040. * @param z defines the scale factor on Z axis
  23041. * @param result defines the target matrix
  23042. */
  23043. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  23044. /**
  23045. * Creates a translation matrix
  23046. * @param x defines the translation on X axis
  23047. * @param y defines the translation on Y axis
  23048. * @param z defines the translationon Z axis
  23049. * @returns the new matrix
  23050. */
  23051. static Translation(x: number, y: number, z: number): Matrix;
  23052. /**
  23053. * Creates a translation matrix and stores it in a given matrix
  23054. * @param x defines the translation on X axis
  23055. * @param y defines the translation on Y axis
  23056. * @param z defines the translationon Z axis
  23057. * @param result defines the target matrix
  23058. */
  23059. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  23060. /**
  23061. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23062. * @param startValue defines the start value
  23063. * @param endValue defines the end value
  23064. * @param gradient defines the gradient factor
  23065. * @returns the new matrix
  23066. */
  23067. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  23068. /**
  23069. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23070. * @param startValue defines the start value
  23071. * @param endValue defines the end value
  23072. * @param gradient defines the gradient factor
  23073. * @param result defines the Matrix object where to store data
  23074. */
  23075. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  23076. /**
  23077. * Builds a new matrix whose values are computed by:
  23078. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23079. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23080. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23081. * @param startValue defines the first matrix
  23082. * @param endValue defines the second matrix
  23083. * @param gradient defines the gradient between the two matrices
  23084. * @returns the new matrix
  23085. */
  23086. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  23087. /**
  23088. * Update a matrix to values which are computed by:
  23089. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23090. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23091. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23092. * @param startValue defines the first matrix
  23093. * @param endValue defines the second matrix
  23094. * @param gradient defines the gradient between the two matrices
  23095. * @param result defines the target matrix
  23096. */
  23097. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  23098. /**
  23099. * 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"
  23100. * This function works in left handed mode
  23101. * @param eye defines the final position of the entity
  23102. * @param target defines where the entity should look at
  23103. * @param up defines the up vector for the entity
  23104. * @returns the new matrix
  23105. */
  23106. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  23107. /**
  23108. * 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".
  23109. * This function works in left handed mode
  23110. * @param eye defines the final position of the entity
  23111. * @param target defines where the entity should look at
  23112. * @param up defines the up vector for the entity
  23113. * @param result defines the target matrix
  23114. */
  23115. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  23116. /**
  23117. * 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"
  23118. * This function works in right handed mode
  23119. * @param eye defines the final position of the entity
  23120. * @param target defines where the entity should look at
  23121. * @param up defines the up vector for the entity
  23122. * @returns the new matrix
  23123. */
  23124. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  23125. /**
  23126. * 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".
  23127. * This function works in right handed mode
  23128. * @param eye defines the final position of the entity
  23129. * @param target defines where the entity should look at
  23130. * @param up defines the up vector for the entity
  23131. * @param result defines the target matrix
  23132. */
  23133. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  23134. /**
  23135. * Create a left-handed orthographic projection matrix
  23136. * @param width defines the viewport width
  23137. * @param height defines the viewport height
  23138. * @param znear defines the near clip plane
  23139. * @param zfar defines the far clip plane
  23140. * @returns a new matrix as a left-handed orthographic projection matrix
  23141. */
  23142. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23143. /**
  23144. * Store a left-handed orthographic projection to a given matrix
  23145. * @param width defines the viewport width
  23146. * @param height defines the viewport height
  23147. * @param znear defines the near clip plane
  23148. * @param zfar defines the far clip plane
  23149. * @param result defines the target matrix
  23150. */
  23151. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  23152. /**
  23153. * Create a left-handed orthographic projection matrix
  23154. * @param left defines the viewport left coordinate
  23155. * @param right defines the viewport right coordinate
  23156. * @param bottom defines the viewport bottom coordinate
  23157. * @param top defines the viewport top coordinate
  23158. * @param znear defines the near clip plane
  23159. * @param zfar defines the far clip plane
  23160. * @returns a new matrix as a left-handed orthographic projection matrix
  23161. */
  23162. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23163. /**
  23164. * Stores a left-handed orthographic projection into a given matrix
  23165. * @param left defines the viewport left coordinate
  23166. * @param right defines the viewport right coordinate
  23167. * @param bottom defines the viewport bottom coordinate
  23168. * @param top defines the viewport top coordinate
  23169. * @param znear defines the near clip plane
  23170. * @param zfar defines the far clip plane
  23171. * @param result defines the target matrix
  23172. */
  23173. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23174. /**
  23175. * Creates a right-handed orthographic projection matrix
  23176. * @param left defines the viewport left coordinate
  23177. * @param right defines the viewport right coordinate
  23178. * @param bottom defines the viewport bottom coordinate
  23179. * @param top defines the viewport top coordinate
  23180. * @param znear defines the near clip plane
  23181. * @param zfar defines the far clip plane
  23182. * @returns a new matrix as a right-handed orthographic projection matrix
  23183. */
  23184. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23185. /**
  23186. * Stores a right-handed orthographic projection into a given matrix
  23187. * @param left defines the viewport left coordinate
  23188. * @param right defines the viewport right coordinate
  23189. * @param bottom defines the viewport bottom coordinate
  23190. * @param top defines the viewport top coordinate
  23191. * @param znear defines the near clip plane
  23192. * @param zfar defines the far clip plane
  23193. * @param result defines the target matrix
  23194. */
  23195. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23196. /**
  23197. * Creates a left-handed perspective projection matrix
  23198. * @param width defines the viewport width
  23199. * @param height defines the viewport height
  23200. * @param znear defines the near clip plane
  23201. * @param zfar defines the far clip plane
  23202. * @returns a new matrix as a left-handed perspective projection matrix
  23203. */
  23204. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23205. /**
  23206. * Creates a left-handed perspective projection matrix
  23207. * @param fov defines the horizontal field of view
  23208. * @param aspect defines the aspect ratio
  23209. * @param znear defines the near clip plane
  23210. * @param zfar defines the far clip plane
  23211. * @returns a new matrix as a left-handed perspective projection matrix
  23212. */
  23213. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23214. /**
  23215. * Stores a left-handed perspective projection into a given matrix
  23216. * @param fov defines the horizontal field of view
  23217. * @param aspect defines the aspect ratio
  23218. * @param znear defines the near clip plane
  23219. * @param zfar defines the far clip plane
  23220. * @param result defines the target matrix
  23221. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23222. */
  23223. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23224. /**
  23225. * Creates a right-handed perspective projection matrix
  23226. * @param fov defines the horizontal field of view
  23227. * @param aspect defines the aspect ratio
  23228. * @param znear defines the near clip plane
  23229. * @param zfar defines the far clip plane
  23230. * @returns a new matrix as a right-handed perspective projection matrix
  23231. */
  23232. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23233. /**
  23234. * Stores a right-handed perspective projection into a given matrix
  23235. * @param fov defines the horizontal field of view
  23236. * @param aspect defines the aspect ratio
  23237. * @param znear defines the near clip plane
  23238. * @param zfar defines the far clip plane
  23239. * @param result defines the target matrix
  23240. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23241. */
  23242. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23243. /**
  23244. * Stores a perspective projection for WebVR info a given matrix
  23245. * @param fov defines the field of view
  23246. * @param znear defines the near clip plane
  23247. * @param zfar defines the far clip plane
  23248. * @param result defines the target matrix
  23249. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  23250. */
  23251. static PerspectiveFovWebVRToRef(fov: {
  23252. upDegrees: number;
  23253. downDegrees: number;
  23254. leftDegrees: number;
  23255. rightDegrees: number;
  23256. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  23257. /**
  23258. * Computes a complete transformation matrix
  23259. * @param viewport defines the viewport to use
  23260. * @param world defines the world matrix
  23261. * @param view defines the view matrix
  23262. * @param projection defines the projection matrix
  23263. * @param zmin defines the near clip plane
  23264. * @param zmax defines the far clip plane
  23265. * @returns the transformation matrix
  23266. */
  23267. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  23268. /**
  23269. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  23270. * @param matrix defines the matrix to use
  23271. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  23272. */
  23273. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  23274. /**
  23275. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  23276. * @param matrix defines the matrix to use
  23277. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  23278. */
  23279. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  23280. /**
  23281. * Compute the transpose of a given matrix
  23282. * @param matrix defines the matrix to transpose
  23283. * @returns the new matrix
  23284. */
  23285. static Transpose(matrix: Matrix): Matrix;
  23286. /**
  23287. * Compute the transpose of a matrix and store it in a target matrix
  23288. * @param matrix defines the matrix to transpose
  23289. * @param result defines the target matrix
  23290. */
  23291. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  23292. /**
  23293. * Computes a reflection matrix from a plane
  23294. * @param plane defines the reflection plane
  23295. * @returns a new matrix
  23296. */
  23297. static Reflection(plane: Plane): Matrix;
  23298. /**
  23299. * Computes a reflection matrix from a plane
  23300. * @param plane defines the reflection plane
  23301. * @param result defines the target matrix
  23302. */
  23303. static ReflectionToRef(plane: Plane, result: Matrix): void;
  23304. /**
  23305. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  23306. * @param xaxis defines the value of the 1st axis
  23307. * @param yaxis defines the value of the 2nd axis
  23308. * @param zaxis defines the value of the 3rd axis
  23309. * @param result defines the target matrix
  23310. */
  23311. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  23312. /**
  23313. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  23314. * @param quat defines the quaternion to use
  23315. * @param result defines the target matrix
  23316. */
  23317. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  23318. }
  23319. /**
  23320. * Represens a plane by the equation ax + by + cz + d = 0
  23321. */
  23322. class Plane {
  23323. /**
  23324. * Normal of the plane (a,b,c)
  23325. */
  23326. normal: Vector3;
  23327. /**
  23328. * d component of the plane
  23329. */
  23330. d: number;
  23331. /**
  23332. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  23333. * @param a a component of the plane
  23334. * @param b b component of the plane
  23335. * @param c c component of the plane
  23336. * @param d d component of the plane
  23337. */
  23338. constructor(a: number, b: number, c: number, d: number);
  23339. /**
  23340. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  23341. */
  23342. asArray(): number[];
  23343. /**
  23344. * @returns a new plane copied from the current Plane.
  23345. */
  23346. clone(): Plane;
  23347. /**
  23348. * @returns the string "Plane".
  23349. */
  23350. getClassName(): string;
  23351. /**
  23352. * @returns the Plane hash code.
  23353. */
  23354. getHashCode(): number;
  23355. /**
  23356. * Normalize the current Plane in place.
  23357. * @returns the updated Plane.
  23358. */
  23359. normalize(): Plane;
  23360. /**
  23361. * Applies a transformation the plane and returns the result
  23362. * @param transformation the transformation matrix to be applied to the plane
  23363. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  23364. */
  23365. transform(transformation: Matrix): Plane;
  23366. /**
  23367. * Calcualtte the dot product between the point and the plane normal
  23368. * @param point point to calculate the dot product with
  23369. * @returns the dot product (float) of the point coordinates and the plane normal.
  23370. */
  23371. dotCoordinate(point: Vector3): number;
  23372. /**
  23373. * Updates the current Plane from the plane defined by the three given points.
  23374. * @param point1 one of the points used to contruct the plane
  23375. * @param point2 one of the points used to contruct the plane
  23376. * @param point3 one of the points used to contruct the plane
  23377. * @returns the updated Plane.
  23378. */
  23379. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  23380. /**
  23381. * Checks if the plane is facing a given direction
  23382. * @param direction the direction to check if the plane is facing
  23383. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  23384. * @returns True is the vector "direction" is the same side than the plane normal.
  23385. */
  23386. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  23387. /**
  23388. * Calculates the distance to a point
  23389. * @param point point to calculate distance to
  23390. * @returns the signed distance (float) from the given point to the Plane.
  23391. */
  23392. signedDistanceTo(point: Vector3): number;
  23393. /**
  23394. * Creates a plane from an array
  23395. * @param array the array to create a plane from
  23396. * @returns a new Plane from the given array.
  23397. */
  23398. static FromArray(array: ArrayLike<number>): Plane;
  23399. /**
  23400. * Creates a plane from three points
  23401. * @param point1 point used to create the plane
  23402. * @param point2 point used to create the plane
  23403. * @param point3 point used to create the plane
  23404. * @returns a new Plane defined by the three given points.
  23405. */
  23406. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  23407. /**
  23408. * Creates a plane from an origin point and a normal
  23409. * @param origin origin of the plane to be constructed
  23410. * @param normal normal of the plane to be constructed
  23411. * @returns a new Plane the normal vector to this plane at the given origin point.
  23412. * Note : the vector "normal" is updated because normalized.
  23413. */
  23414. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  23415. /**
  23416. * Calculates the distance from a plane and a point
  23417. * @param origin origin of the plane to be constructed
  23418. * @param normal normal of the plane to be constructed
  23419. * @param point point to calculate distance to
  23420. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  23421. */
  23422. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  23423. }
  23424. /**
  23425. * Class used to represent a viewport on screen
  23426. */
  23427. class Viewport {
  23428. /** viewport left coordinate */
  23429. x: number;
  23430. /** viewport top coordinate */
  23431. y: number;
  23432. /**viewport width */
  23433. width: number;
  23434. /** viewport height */
  23435. height: number;
  23436. /**
  23437. * Creates a Viewport object located at (x, y) and sized (width, height)
  23438. * @param x defines viewport left coordinate
  23439. * @param y defines viewport top coordinate
  23440. * @param width defines the viewport width
  23441. * @param height defines the viewport height
  23442. */
  23443. constructor(
  23444. /** viewport left coordinate */
  23445. x: number,
  23446. /** viewport top coordinate */
  23447. y: number,
  23448. /**viewport width */
  23449. width: number,
  23450. /** viewport height */
  23451. height: number);
  23452. /**
  23453. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  23454. * @param renderWidthOrEngine defines either an engine or the rendering width
  23455. * @param renderHeight defines the rendering height
  23456. * @returns a new Viewport
  23457. */
  23458. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  23459. /**
  23460. * Returns a new Viewport copied from the current one
  23461. * @returns a new Viewport
  23462. */
  23463. clone(): Viewport;
  23464. }
  23465. /**
  23466. * Reprasents a camera frustum
  23467. */
  23468. class Frustum {
  23469. /**
  23470. * Gets the planes representing the frustum
  23471. * @param transform matrix to be applied to the returned planes
  23472. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  23473. */
  23474. static GetPlanes(transform: Matrix): Plane[];
  23475. /**
  23476. * Gets the near frustum plane transformed by the transform matrix
  23477. * @param transform transformation matrix to be applied to the resulting frustum plane
  23478. * @param frustumPlane the resuling frustum plane
  23479. */
  23480. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23481. /**
  23482. * Gets the far frustum plane transformed by the transform matrix
  23483. * @param transform transformation matrix to be applied to the resulting frustum plane
  23484. * @param frustumPlane the resuling frustum plane
  23485. */
  23486. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23487. /**
  23488. * Gets the left frustum plane transformed by the transform matrix
  23489. * @param transform transformation matrix to be applied to the resulting frustum plane
  23490. * @param frustumPlane the resuling frustum plane
  23491. */
  23492. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23493. /**
  23494. * Gets the right frustum plane transformed by the transform matrix
  23495. * @param transform transformation matrix to be applied to the resulting frustum plane
  23496. * @param frustumPlane the resuling frustum plane
  23497. */
  23498. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23499. /**
  23500. * Gets the top frustum plane transformed by the transform matrix
  23501. * @param transform transformation matrix to be applied to the resulting frustum plane
  23502. * @param frustumPlane the resuling frustum plane
  23503. */
  23504. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23505. /**
  23506. * Gets the bottom frustum plane transformed by the transform matrix
  23507. * @param transform transformation matrix to be applied to the resulting frustum plane
  23508. * @param frustumPlane the resuling frustum plane
  23509. */
  23510. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23511. /**
  23512. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23513. * @param transform transformation matrix to be applied to the resulting frustum planes
  23514. * @param frustumPlanes the resuling frustum planes
  23515. */
  23516. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  23517. }
  23518. /** Defines supported spaces */
  23519. enum Space {
  23520. /** Local (object) space */
  23521. LOCAL = 0,
  23522. /** World space */
  23523. WORLD = 1,
  23524. /** Bone space */
  23525. BONE = 2
  23526. }
  23527. /** Defines the 3 main axes */
  23528. class Axis {
  23529. /** X axis */
  23530. static X: Vector3;
  23531. /** Y axis */
  23532. static Y: Vector3;
  23533. /** Z axis */
  23534. static Z: Vector3;
  23535. }
  23536. /** Class used to represent a Bezier curve */
  23537. class BezierCurve {
  23538. /**
  23539. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23540. * @param t defines the time
  23541. * @param x1 defines the left coordinate on X axis
  23542. * @param y1 defines the left coordinate on Y axis
  23543. * @param x2 defines the right coordinate on X axis
  23544. * @param y2 defines the right coordinate on Y axis
  23545. * @returns the interpolated value
  23546. */
  23547. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23548. }
  23549. /**
  23550. * Defines potential orientation for back face culling
  23551. */
  23552. enum Orientation {
  23553. /**
  23554. * Clockwise
  23555. */
  23556. CW = 0,
  23557. /** Counter clockwise */
  23558. CCW = 1
  23559. }
  23560. /**
  23561. * Defines angle representation
  23562. */
  23563. class Angle {
  23564. private _radians;
  23565. /**
  23566. * Creates an Angle object of "radians" radians (float).
  23567. */
  23568. constructor(radians: number);
  23569. /**
  23570. * Get value in degrees
  23571. * @returns the Angle value in degrees (float)
  23572. */
  23573. degrees(): number;
  23574. /**
  23575. * Get value in radians
  23576. * @returns the Angle value in radians (float)
  23577. */
  23578. radians(): number;
  23579. /**
  23580. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23581. * @param a defines first vector
  23582. * @param b defines second vector
  23583. * @returns a new Angle
  23584. */
  23585. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  23586. /**
  23587. * Gets a new Angle object from the given float in radians
  23588. * @param radians defines the angle value in radians
  23589. * @returns a new Angle
  23590. */
  23591. static FromRadians(radians: number): Angle;
  23592. /**
  23593. * Gets a new Angle object from the given float in degrees
  23594. * @param degrees defines the angle value in degrees
  23595. * @returns a new Angle
  23596. */
  23597. static FromDegrees(degrees: number): Angle;
  23598. }
  23599. /**
  23600. * This represents an arc in a 2d space.
  23601. */
  23602. class Arc2 {
  23603. /** Defines the start point of the arc */
  23604. startPoint: Vector2;
  23605. /** Defines the mid point of the arc */
  23606. midPoint: Vector2;
  23607. /** Defines the end point of the arc */
  23608. endPoint: Vector2;
  23609. /**
  23610. * Defines the center point of the arc.
  23611. */
  23612. centerPoint: Vector2;
  23613. /**
  23614. * Defines the radius of the arc.
  23615. */
  23616. radius: number;
  23617. /**
  23618. * Defines the angle of the arc (from mid point to end point).
  23619. */
  23620. angle: Angle;
  23621. /**
  23622. * Defines the start angle of the arc (from start point to middle point).
  23623. */
  23624. startAngle: Angle;
  23625. /**
  23626. * Defines the orientation of the arc (clock wise/counter clock wise).
  23627. */
  23628. orientation: Orientation;
  23629. /**
  23630. * Creates an Arc object from the three given points : start, middle and end.
  23631. * @param startPoint Defines the start point of the arc
  23632. * @param midPoint Defines the midlle point of the arc
  23633. * @param endPoint Defines the end point of the arc
  23634. */
  23635. constructor(
  23636. /** Defines the start point of the arc */
  23637. startPoint: Vector2,
  23638. /** Defines the mid point of the arc */
  23639. midPoint: Vector2,
  23640. /** Defines the end point of the arc */
  23641. endPoint: Vector2);
  23642. }
  23643. /**
  23644. * Represents a 2D path made up of multiple 2D points
  23645. */
  23646. class Path2 {
  23647. private _points;
  23648. private _length;
  23649. /**
  23650. * If the path start and end point are the same
  23651. */
  23652. closed: boolean;
  23653. /**
  23654. * Creates a Path2 object from the starting 2D coordinates x and y.
  23655. * @param x the starting points x value
  23656. * @param y the starting points y value
  23657. */
  23658. constructor(x: number, y: number);
  23659. /**
  23660. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23661. * @param x the added points x value
  23662. * @param y the added points y value
  23663. * @returns the updated Path2.
  23664. */
  23665. addLineTo(x: number, y: number): Path2;
  23666. /**
  23667. * 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.
  23668. * @param midX middle point x value
  23669. * @param midY middle point y value
  23670. * @param endX end point x value
  23671. * @param endY end point y value
  23672. * @param numberOfSegments (default: 36)
  23673. * @returns the updated Path2.
  23674. */
  23675. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23676. /**
  23677. * Closes the Path2.
  23678. * @returns the Path2.
  23679. */
  23680. close(): Path2;
  23681. /**
  23682. * Gets the sum of the distance between each sequential point in the path
  23683. * @returns the Path2 total length (float).
  23684. */
  23685. length(): number;
  23686. /**
  23687. * Gets the points which construct the path
  23688. * @returns the Path2 internal array of points.
  23689. */
  23690. getPoints(): Vector2[];
  23691. /**
  23692. * Retreives the point at the distance aways from the starting point
  23693. * @param normalizedLengthPosition the length along the path to retreive the point from
  23694. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  23695. */
  23696. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  23697. /**
  23698. * Creates a new path starting from an x and y position
  23699. * @param x starting x value
  23700. * @param y starting y value
  23701. * @returns a new Path2 starting at the coordinates (x, y).
  23702. */
  23703. static StartingAt(x: number, y: number): Path2;
  23704. }
  23705. /**
  23706. * Represents a 3D path made up of multiple 3D points
  23707. */
  23708. class Path3D {
  23709. /**
  23710. * an array of Vector3, the curve axis of the Path3D
  23711. */
  23712. path: Vector3[];
  23713. private _curve;
  23714. private _distances;
  23715. private _tangents;
  23716. private _normals;
  23717. private _binormals;
  23718. private _raw;
  23719. /**
  23720. * new Path3D(path, normal, raw)
  23721. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  23722. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  23723. * @param path an array of Vector3, the curve axis of the Path3D
  23724. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  23725. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  23726. */
  23727. constructor(
  23728. /**
  23729. * an array of Vector3, the curve axis of the Path3D
  23730. */
  23731. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  23732. /**
  23733. * Returns the Path3D array of successive Vector3 designing its curve.
  23734. * @returns the Path3D array of successive Vector3 designing its curve.
  23735. */
  23736. getCurve(): Vector3[];
  23737. /**
  23738. * Returns an array populated with tangent vectors on each Path3D curve point.
  23739. * @returns an array populated with tangent vectors on each Path3D curve point.
  23740. */
  23741. getTangents(): Vector3[];
  23742. /**
  23743. * Returns an array populated with normal vectors on each Path3D curve point.
  23744. * @returns an array populated with normal vectors on each Path3D curve point.
  23745. */
  23746. getNormals(): Vector3[];
  23747. /**
  23748. * Returns an array populated with binormal vectors on each Path3D curve point.
  23749. * @returns an array populated with binormal vectors on each Path3D curve point.
  23750. */
  23751. getBinormals(): Vector3[];
  23752. /**
  23753. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  23754. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  23755. */
  23756. getDistances(): number[];
  23757. /**
  23758. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  23759. * @param path path which all values are copied into the curves points
  23760. * @param firstNormal which should be projected onto the curve
  23761. * @returns the same object updated.
  23762. */
  23763. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  23764. private _compute;
  23765. private _getFirstNonNullVector;
  23766. private _getLastNonNullVector;
  23767. private _normalVector;
  23768. }
  23769. /**
  23770. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23771. * A Curve3 is designed from a series of successive Vector3.
  23772. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  23773. */
  23774. class Curve3 {
  23775. private _points;
  23776. private _length;
  23777. /**
  23778. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  23779. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  23780. * @param v1 (Vector3) the control point
  23781. * @param v2 (Vector3) the end point of the Quadratic Bezier
  23782. * @param nbPoints (integer) the wanted number of points in the curve
  23783. * @returns the created Curve3
  23784. */
  23785. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  23786. /**
  23787. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  23788. * @param v0 (Vector3) the origin point of the Cubic Bezier
  23789. * @param v1 (Vector3) the first control point
  23790. * @param v2 (Vector3) the second control point
  23791. * @param v3 (Vector3) the end point of the Cubic Bezier
  23792. * @param nbPoints (integer) the wanted number of points in the curve
  23793. * @returns the created Curve3
  23794. */
  23795. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  23796. /**
  23797. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  23798. * @param p1 (Vector3) the origin point of the Hermite Spline
  23799. * @param t1 (Vector3) the tangent vector at the origin point
  23800. * @param p2 (Vector3) the end point of the Hermite Spline
  23801. * @param t2 (Vector3) the tangent vector at the end point
  23802. * @param nbPoints (integer) the wanted number of points in the curve
  23803. * @returns the created Curve3
  23804. */
  23805. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  23806. /**
  23807. * Returns a Curve3 object along a CatmullRom Spline curve :
  23808. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  23809. * @param nbPoints (integer) the wanted number of points between each curve control points
  23810. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  23811. * @returns the created Curve3
  23812. */
  23813. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  23814. /**
  23815. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23816. * A Curve3 is designed from a series of successive Vector3.
  23817. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  23818. * @param points points which make up the curve
  23819. */
  23820. constructor(points: Vector3[]);
  23821. /**
  23822. * @returns the Curve3 stored array of successive Vector3
  23823. */
  23824. getPoints(): Vector3[];
  23825. /**
  23826. * @returns the computed length (float) of the curve.
  23827. */
  23828. length(): number;
  23829. /**
  23830. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  23831. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  23832. * curveA and curveB keep unchanged.
  23833. * @param curve the curve to continue from this curve
  23834. * @returns the newly constructed curve
  23835. */
  23836. continue(curve: Curve3): Curve3;
  23837. private _computeLength;
  23838. }
  23839. /**
  23840. * Contains position and normal vectors for a vertex
  23841. */
  23842. class PositionNormalVertex {
  23843. /** the position of the vertex (defaut: 0,0,0) */
  23844. position: Vector3;
  23845. /** the normal of the vertex (defaut: 0,1,0) */
  23846. normal: Vector3;
  23847. /**
  23848. * Creates a PositionNormalVertex
  23849. * @param position the position of the vertex (defaut: 0,0,0)
  23850. * @param normal the normal of the vertex (defaut: 0,1,0)
  23851. */
  23852. constructor(
  23853. /** the position of the vertex (defaut: 0,0,0) */
  23854. position?: Vector3,
  23855. /** the normal of the vertex (defaut: 0,1,0) */
  23856. normal?: Vector3);
  23857. /**
  23858. * Clones the PositionNormalVertex
  23859. * @returns the cloned PositionNormalVertex
  23860. */
  23861. clone(): PositionNormalVertex;
  23862. }
  23863. /**
  23864. * Contains position, normal and uv vectors for a vertex
  23865. */
  23866. class PositionNormalTextureVertex {
  23867. /** the position of the vertex (defaut: 0,0,0) */
  23868. position: Vector3;
  23869. /** the normal of the vertex (defaut: 0,1,0) */
  23870. normal: Vector3;
  23871. /** the uv of the vertex (default: 0,0) */
  23872. uv: Vector2;
  23873. /**
  23874. * Creates a PositionNormalTextureVertex
  23875. * @param position the position of the vertex (defaut: 0,0,0)
  23876. * @param normal the normal of the vertex (defaut: 0,1,0)
  23877. * @param uv the uv of the vertex (default: 0,0)
  23878. */
  23879. constructor(
  23880. /** the position of the vertex (defaut: 0,0,0) */
  23881. position?: Vector3,
  23882. /** the normal of the vertex (defaut: 0,1,0) */
  23883. normal?: Vector3,
  23884. /** the uv of the vertex (default: 0,0) */
  23885. uv?: Vector2);
  23886. /**
  23887. * Clones the PositionNormalTextureVertex
  23888. * @returns the cloned PositionNormalTextureVertex
  23889. */
  23890. clone(): PositionNormalTextureVertex;
  23891. }
  23892. /**
  23893. * @hidden
  23894. */
  23895. class Tmp {
  23896. static Color3: Color3[];
  23897. static Color4: Color4[];
  23898. static Vector2: Vector2[];
  23899. static Vector3: Vector3[];
  23900. static Vector4: Vector4[];
  23901. static Quaternion: Quaternion[];
  23902. static Matrix: Matrix[];
  23903. }
  23904. }
  23905. declare module BABYLON {
  23906. /**
  23907. * Class representing spherical polynomial coefficients to the 3rd degree
  23908. */
  23909. class SphericalPolynomial {
  23910. /**
  23911. * The x coefficients of the spherical polynomial
  23912. */
  23913. x: Vector3;
  23914. /**
  23915. * The y coefficients of the spherical polynomial
  23916. */
  23917. y: Vector3;
  23918. /**
  23919. * The z coefficients of the spherical polynomial
  23920. */
  23921. z: Vector3;
  23922. /**
  23923. * The xx coefficients of the spherical polynomial
  23924. */
  23925. xx: Vector3;
  23926. /**
  23927. * The yy coefficients of the spherical polynomial
  23928. */
  23929. yy: Vector3;
  23930. /**
  23931. * The zz coefficients of the spherical polynomial
  23932. */
  23933. zz: Vector3;
  23934. /**
  23935. * The xy coefficients of the spherical polynomial
  23936. */
  23937. xy: Vector3;
  23938. /**
  23939. * The yz coefficients of the spherical polynomial
  23940. */
  23941. yz: Vector3;
  23942. /**
  23943. * The zx coefficients of the spherical polynomial
  23944. */
  23945. zx: Vector3;
  23946. /**
  23947. * Adds an ambient color to the spherical polynomial
  23948. * @param color the color to add
  23949. */
  23950. addAmbient(color: Color3): void;
  23951. /**
  23952. * Scales the spherical polynomial by the given amount
  23953. * @param scale the amount to scale
  23954. */
  23955. scale(scale: number): void;
  23956. /**
  23957. * Gets the spherical polynomial from harmonics
  23958. * @param harmonics the spherical harmonics
  23959. * @returns the spherical polynomial
  23960. */
  23961. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  23962. /**
  23963. * Constructs a spherical polynomial from an array.
  23964. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  23965. * @returns the spherical polynomial
  23966. */
  23967. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  23968. }
  23969. /**
  23970. * Class representing spherical harmonics coefficients to the 3rd degree
  23971. */
  23972. class SphericalHarmonics {
  23973. /**
  23974. * The l0,0 coefficients of the spherical harmonics
  23975. */
  23976. l00: Vector3;
  23977. /**
  23978. * The l1,-1 coefficients of the spherical harmonics
  23979. */
  23980. l1_1: Vector3;
  23981. /**
  23982. * The l1,0 coefficients of the spherical harmonics
  23983. */
  23984. l10: Vector3;
  23985. /**
  23986. * The l1,1 coefficients of the spherical harmonics
  23987. */
  23988. l11: Vector3;
  23989. /**
  23990. * The l2,-2 coefficients of the spherical harmonics
  23991. */
  23992. l2_2: Vector3;
  23993. /**
  23994. * The l2,-1 coefficients of the spherical harmonics
  23995. */
  23996. l2_1: Vector3;
  23997. /**
  23998. * The l2,0 coefficients of the spherical harmonics
  23999. */
  24000. l20: Vector3;
  24001. /**
  24002. * The l2,1 coefficients of the spherical harmonics
  24003. */
  24004. l21: Vector3;
  24005. /**
  24006. * The l2,2 coefficients of the spherical harmonics
  24007. */
  24008. lL22: Vector3;
  24009. /**
  24010. * Adds a light to the spherical harmonics
  24011. * @param direction the direction of the light
  24012. * @param color the color of the light
  24013. * @param deltaSolidAngle the delta solid angle of the light
  24014. */
  24015. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  24016. /**
  24017. * Scales the spherical harmonics by the given amount
  24018. * @param scale the amount to scale
  24019. */
  24020. scale(scale: number): void;
  24021. /**
  24022. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  24023. *
  24024. * ```
  24025. * E_lm = A_l * L_lm
  24026. * ```
  24027. *
  24028. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  24029. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  24030. * the scaling factors are given in equation 9.
  24031. */
  24032. convertIncidentRadianceToIrradiance(): void;
  24033. /**
  24034. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  24035. *
  24036. * ```
  24037. * L = (1/pi) * E * rho
  24038. * ```
  24039. *
  24040. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  24041. */
  24042. convertIrradianceToLambertianRadiance(): void;
  24043. /**
  24044. * Gets the spherical harmonics from polynomial
  24045. * @param polynomial the spherical polynomial
  24046. * @returns the spherical harmonics
  24047. */
  24048. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  24049. /**
  24050. * Constructs a spherical harmonics from an array.
  24051. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  24052. * @returns the spherical harmonics
  24053. */
  24054. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  24055. }
  24056. }
  24057. declare module BABYLON {
  24058. /**
  24059. * Class used to store all common mesh properties
  24060. */
  24061. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24062. /** No occlusion */
  24063. static OCCLUSION_TYPE_NONE: number;
  24064. /** Occlusion set to optimisitic */
  24065. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24066. /** Occlusion set to strict */
  24067. static OCCLUSION_TYPE_STRICT: number;
  24068. /** Use an accurante occlusion algorithm */
  24069. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24070. /** Use a conservative occlusion algorithm */
  24071. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24072. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  24073. static readonly CULLINGSTRATEGY_STANDARD: number;
  24074. /** Culling strategy with bounding sphere only and then frustum culling */
  24075. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24076. /**
  24077. * No billboard
  24078. */
  24079. static readonly BILLBOARDMODE_NONE: number;
  24080. /** Billboard on X axis */
  24081. static readonly BILLBOARDMODE_X: number;
  24082. /** Billboard on Y axis */
  24083. static readonly BILLBOARDMODE_Y: number;
  24084. /** Billboard on Z axis */
  24085. static readonly BILLBOARDMODE_Z: number;
  24086. /** Billboard on all axes */
  24087. static readonly BILLBOARDMODE_ALL: number;
  24088. private _facetData;
  24089. /** Gets ot sets the culling strategy to use to find visible meshes */
  24090. cullingStrategy: number;
  24091. /**
  24092. * Gets the number of facets in the mesh
  24093. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24094. */
  24095. readonly facetNb: number;
  24096. /**
  24097. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24099. */
  24100. partitioningSubdivisions: number;
  24101. /**
  24102. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24103. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24105. */
  24106. partitioningBBoxRatio: number;
  24107. /**
  24108. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24109. * Works only for updatable meshes.
  24110. * Doesn't work with multi-materials
  24111. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24112. */
  24113. mustDepthSortFacets: boolean;
  24114. /**
  24115. * The location (Vector3) where the facet depth sort must be computed from.
  24116. * By default, the active camera position.
  24117. * Used only when facet depth sort is enabled
  24118. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24119. */
  24120. facetDepthSortFrom: Vector3;
  24121. /**
  24122. * gets a boolean indicating if facetData is enabled
  24123. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24124. */
  24125. readonly isFacetDataEnabled: boolean;
  24126. /** @hidden */
  24127. _updateNonUniformScalingState(value: boolean): boolean;
  24128. /**
  24129. * An event triggered when this mesh collides with another one
  24130. */
  24131. onCollideObservable: Observable<AbstractMesh>;
  24132. private _onCollideObserver;
  24133. /** Set a function to call when this mesh collides with another one */
  24134. onCollide: () => void;
  24135. /**
  24136. * An event triggered when the collision's position changes
  24137. */
  24138. onCollisionPositionChangeObservable: Observable<Vector3>;
  24139. private _onCollisionPositionChangeObserver;
  24140. /** Set a function to call when the collision's position changes */
  24141. onCollisionPositionChange: () => void;
  24142. /**
  24143. * An event triggered when material is changed
  24144. */
  24145. onMaterialChangedObservable: Observable<AbstractMesh>;
  24146. /**
  24147. * Gets or sets the orientation for POV movement & rotation
  24148. */
  24149. definedFacingForward: boolean;
  24150. /** @hidden */
  24151. _occlusionQuery: Nullable<WebGLQuery>;
  24152. private _visibility;
  24153. /**
  24154. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24155. */
  24156. /**
  24157. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24158. */
  24159. visibility: number;
  24160. /** Gets or sets the alpha index used to sort transparent meshes
  24161. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24162. */
  24163. alphaIndex: number;
  24164. /**
  24165. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24166. */
  24167. isVisible: boolean;
  24168. /**
  24169. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24170. */
  24171. isPickable: boolean;
  24172. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24173. showSubMeshesBoundingBox: boolean;
  24174. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24175. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24176. */
  24177. isBlocker: boolean;
  24178. /**
  24179. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24180. */
  24181. enablePointerMoveEvents: boolean;
  24182. /**
  24183. * Specifies the rendering group id for this mesh (0 by default)
  24184. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24185. */
  24186. renderingGroupId: number;
  24187. private _material;
  24188. /** Gets or sets current material */
  24189. material: Nullable<Material>;
  24190. private _receiveShadows;
  24191. /**
  24192. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24193. * @see http://doc.babylonjs.com/babylon101/shadows
  24194. */
  24195. receiveShadows: boolean;
  24196. /** Defines color to use when rendering outline */
  24197. outlineColor: Color3;
  24198. /** Define width to use when rendering outline */
  24199. outlineWidth: number;
  24200. /** Defines color to use when rendering overlay */
  24201. overlayColor: Color3;
  24202. /** Defines alpha to use when rendering overlay */
  24203. overlayAlpha: number;
  24204. private _hasVertexAlpha;
  24205. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24206. hasVertexAlpha: boolean;
  24207. private _useVertexColors;
  24208. /** 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) */
  24209. useVertexColors: boolean;
  24210. private _computeBonesUsingShaders;
  24211. /**
  24212. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24213. */
  24214. computeBonesUsingShaders: boolean;
  24215. private _numBoneInfluencers;
  24216. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24217. numBoneInfluencers: number;
  24218. private _applyFog;
  24219. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24220. applyFog: boolean;
  24221. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24222. useOctreeForRenderingSelection: boolean;
  24223. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24224. useOctreeForPicking: boolean;
  24225. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24226. useOctreeForCollisions: boolean;
  24227. private _layerMask;
  24228. /**
  24229. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24230. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24231. */
  24232. layerMask: number;
  24233. /**
  24234. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24235. */
  24236. alwaysSelectAsActiveMesh: boolean;
  24237. /**
  24238. * Gets or sets the current action manager
  24239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24240. */
  24241. actionManager: Nullable<ActionManager>;
  24242. private _checkCollisions;
  24243. private _collisionMask;
  24244. private _collisionGroup;
  24245. /**
  24246. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24247. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24248. */
  24249. ellipsoid: Vector3;
  24250. /**
  24251. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24252. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24253. */
  24254. ellipsoidOffset: Vector3;
  24255. private _collider;
  24256. private _oldPositionForCollisions;
  24257. private _diffPositionForCollisions;
  24258. /**
  24259. * Gets or sets a collision mask used to mask collisions (default is -1).
  24260. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24261. */
  24262. collisionMask: number;
  24263. /**
  24264. * Gets or sets the current collision group mask (-1 by default).
  24265. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24266. */
  24267. collisionGroup: number;
  24268. /**
  24269. * Defines edge width used when edgesRenderer is enabled
  24270. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24271. */
  24272. edgesWidth: number;
  24273. /**
  24274. * Defines edge color used when edgesRenderer is enabled
  24275. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24276. */
  24277. edgesColor: Color4;
  24278. /** @hidden */
  24279. _edgesRenderer: Nullable<IEdgesRenderer>;
  24280. /** @hidden */
  24281. _masterMesh: Nullable<AbstractMesh>;
  24282. /** @hidden */
  24283. _boundingInfo: Nullable<BoundingInfo>;
  24284. /** @hidden */
  24285. _renderId: number;
  24286. /**
  24287. * Gets or sets the list of subMeshes
  24288. * @see http://doc.babylonjs.com/how_to/multi_materials
  24289. */
  24290. subMeshes: SubMesh[];
  24291. /** @hidden */
  24292. _intersectionsInProgress: AbstractMesh[];
  24293. /** @hidden */
  24294. _unIndexed: boolean;
  24295. /** @hidden */
  24296. _lightSources: Light[];
  24297. /** @hidden */
  24298. readonly _positions: Nullable<Vector3[]>;
  24299. /** @hidden */
  24300. _waitingActions: any;
  24301. /** @hidden */
  24302. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24303. private _skeleton;
  24304. /** @hidden */
  24305. _bonesTransformMatrices: Nullable<Float32Array>;
  24306. /**
  24307. * Gets or sets a skeleton to apply skining transformations
  24308. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24309. */
  24310. skeleton: Nullable<Skeleton>;
  24311. /**
  24312. * An event triggered when the mesh is rebuilt.
  24313. */
  24314. onRebuildObservable: Observable<AbstractMesh>;
  24315. /**
  24316. * Creates a new AbstractMesh
  24317. * @param name defines the name of the mesh
  24318. * @param scene defines the hosting scene
  24319. */
  24320. constructor(name: string, scene?: Nullable<Scene>);
  24321. /**
  24322. * Returns the string "AbstractMesh"
  24323. * @returns "AbstractMesh"
  24324. */
  24325. getClassName(): string;
  24326. /**
  24327. * Gets a string representation of the current mesh
  24328. * @param fullDetails defines a boolean indicating if full details must be included
  24329. * @returns a string representation of the current mesh
  24330. */
  24331. toString(fullDetails?: boolean): string;
  24332. /** @hidden */
  24333. _rebuild(): void;
  24334. /** @hidden */
  24335. _resyncLightSources(): void;
  24336. /** @hidden */
  24337. _resyncLighSource(light: Light): void;
  24338. /** @hidden */
  24339. _unBindEffect(): void;
  24340. /** @hidden */
  24341. _removeLightSource(light: Light): void;
  24342. private _markSubMeshesAsDirty;
  24343. /** @hidden */
  24344. _markSubMeshesAsLightDirty(): void;
  24345. /** @hidden */
  24346. _markSubMeshesAsAttributesDirty(): void;
  24347. /** @hidden */
  24348. _markSubMeshesAsMiscDirty(): void;
  24349. /**
  24350. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24351. */
  24352. scaling: Vector3;
  24353. /**
  24354. * Returns true if the mesh is blocked. Implemented by child classes
  24355. */
  24356. readonly isBlocked: boolean;
  24357. /**
  24358. * Returns the mesh itself by default. Implemented by child classes
  24359. * @param camera defines the camera to use to pick the right LOD level
  24360. * @returns the currentAbstractMesh
  24361. */
  24362. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24363. /**
  24364. * Returns 0 by default. Implemented by child classes
  24365. * @returns an integer
  24366. */
  24367. getTotalVertices(): number;
  24368. /**
  24369. * Returns null by default. Implemented by child classes
  24370. * @returns null
  24371. */
  24372. getIndices(): Nullable<IndicesArray>;
  24373. /**
  24374. * Returns the array of the requested vertex data kind. Implemented by child classes
  24375. * @param kind defines the vertex data kind to use
  24376. * @returns null
  24377. */
  24378. getVerticesData(kind: string): Nullable<FloatArray>;
  24379. /**
  24380. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24381. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24382. * Note that a new underlying VertexBuffer object is created each call.
  24383. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24384. * @param kind defines vertex data kind:
  24385. * * BABYLON.VertexBuffer.PositionKind
  24386. * * BABYLON.VertexBuffer.UVKind
  24387. * * BABYLON.VertexBuffer.UV2Kind
  24388. * * BABYLON.VertexBuffer.UV3Kind
  24389. * * BABYLON.VertexBuffer.UV4Kind
  24390. * * BABYLON.VertexBuffer.UV5Kind
  24391. * * BABYLON.VertexBuffer.UV6Kind
  24392. * * BABYLON.VertexBuffer.ColorKind
  24393. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24394. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24395. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24396. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24397. * @param data defines the data source
  24398. * @param updatable defines if the data must be flagged as updatable (or static)
  24399. * @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
  24400. * @returns the current mesh
  24401. */
  24402. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24403. /**
  24404. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24405. * If the mesh has no geometry, it is simply returned as it is.
  24406. * @param kind defines vertex data kind:
  24407. * * BABYLON.VertexBuffer.PositionKind
  24408. * * BABYLON.VertexBuffer.UVKind
  24409. * * BABYLON.VertexBuffer.UV2Kind
  24410. * * BABYLON.VertexBuffer.UV3Kind
  24411. * * BABYLON.VertexBuffer.UV4Kind
  24412. * * BABYLON.VertexBuffer.UV5Kind
  24413. * * BABYLON.VertexBuffer.UV6Kind
  24414. * * BABYLON.VertexBuffer.ColorKind
  24415. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24416. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24417. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24418. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24419. * @param data defines the data source
  24420. * @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
  24421. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24422. * @returns the current mesh
  24423. */
  24424. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24425. /**
  24426. * Sets the mesh indices,
  24427. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24428. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24429. * @param totalVertices Defines the total number of vertices
  24430. * @returns the current mesh
  24431. */
  24432. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24433. /**
  24434. * Gets a boolean indicating if specific vertex data is present
  24435. * @param kind defines the vertex data kind to use
  24436. * @returns true is data kind is present
  24437. */
  24438. isVerticesDataPresent(kind: string): boolean;
  24439. /**
  24440. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24441. * @returns a BoundingInfo
  24442. */
  24443. getBoundingInfo(): BoundingInfo;
  24444. /**
  24445. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24446. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24447. * @returns the current mesh
  24448. */
  24449. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24450. /**
  24451. * Overwrite the current bounding info
  24452. * @param boundingInfo defines the new bounding info
  24453. * @returns the current mesh
  24454. */
  24455. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24456. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24457. readonly useBones: boolean;
  24458. /** @hidden */
  24459. _preActivate(): void;
  24460. /** @hidden */
  24461. _preActivateForIntermediateRendering(renderId: number): void;
  24462. /** @hidden */
  24463. _activate(renderId: number): void;
  24464. /**
  24465. * Gets the current world matrix
  24466. * @returns a Matrix
  24467. */
  24468. getWorldMatrix(): Matrix;
  24469. /** @hidden */
  24470. _getWorldMatrixDeterminant(): number;
  24471. /**
  24472. * Perform relative position change from the point of view of behind the front of the mesh.
  24473. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24474. * Supports definition of mesh facing forward or backward
  24475. * @param amountRight defines the distance on the right axis
  24476. * @param amountUp defines the distance on the up axis
  24477. * @param amountForward defines the distance on the forward axis
  24478. * @returns the current mesh
  24479. */
  24480. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24481. /**
  24482. * Calculate relative position change from the point of view of behind the front of the mesh.
  24483. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24484. * Supports definition of mesh facing forward or backward
  24485. * @param amountRight defines the distance on the right axis
  24486. * @param amountUp defines the distance on the up axis
  24487. * @param amountForward defines the distance on the forward axis
  24488. * @returns the new displacement vector
  24489. */
  24490. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24491. /**
  24492. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24493. * Supports definition of mesh facing forward or backward
  24494. * @param flipBack defines the flip
  24495. * @param twirlClockwise defines the twirl
  24496. * @param tiltRight defines the tilt
  24497. * @returns the current mesh
  24498. */
  24499. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24500. /**
  24501. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24502. * Supports definition of mesh facing forward or backward.
  24503. * @param flipBack defines the flip
  24504. * @param twirlClockwise defines the twirl
  24505. * @param tiltRight defines the tilt
  24506. * @returns the new rotation vector
  24507. */
  24508. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24509. /**
  24510. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24511. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24512. * @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
  24513. * @returns the new bounding vectors
  24514. */
  24515. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24516. min: Vector3;
  24517. max: Vector3;
  24518. };
  24519. /** @hidden */
  24520. _updateBoundingInfo(): AbstractMesh;
  24521. /** @hidden */
  24522. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  24523. /** @hidden */
  24524. protected _afterComputeWorldMatrix(): void;
  24525. /**
  24526. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24527. * A mesh is in the frustum if its bounding box intersects the frustum
  24528. * @param frustumPlanes defines the frustum to test
  24529. * @returns true if the mesh is in the frustum planes
  24530. */
  24531. isInFrustum(frustumPlanes: Plane[]): boolean;
  24532. /**
  24533. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24534. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24535. * @param frustumPlanes defines the frustum to test
  24536. * @returns true if the mesh is completely in the frustum planes
  24537. */
  24538. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24539. /**
  24540. * True if the mesh intersects another mesh or a SolidParticle object
  24541. * @param mesh defines a target mesh or SolidParticle to test
  24542. * @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)
  24543. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24544. * @returns true if there is an intersection
  24545. */
  24546. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24547. /**
  24548. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24549. * @param point defines the point to test
  24550. * @returns true if there is an intersection
  24551. */
  24552. intersectsPoint(point: Vector3): boolean;
  24553. /**
  24554. * Gets the position of the current mesh in camera space
  24555. * @param camera defines the camera to use
  24556. * @returns a position
  24557. */
  24558. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  24559. /**
  24560. * Returns the distance from the mesh to the active camera
  24561. * @param camera defines the camera to use
  24562. * @returns the distance
  24563. */
  24564. getDistanceToCamera(camera?: Nullable<Camera>): number;
  24565. /**
  24566. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24568. */
  24569. checkCollisions: boolean;
  24570. /**
  24571. * Gets Collider object used to compute collisions (not physics)
  24572. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24573. */
  24574. readonly collider: Collider;
  24575. /**
  24576. * Move the mesh using collision engine
  24577. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24578. * @param displacement defines the requested displacement vector
  24579. * @returns the current mesh
  24580. */
  24581. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24582. private _onCollisionPositionChange;
  24583. /** @hidden */
  24584. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24585. /** @hidden */
  24586. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24587. /** @hidden */
  24588. _checkCollision(collider: Collider): AbstractMesh;
  24589. /** @hidden */
  24590. _generatePointsArray(): boolean;
  24591. /**
  24592. * Checks if the passed Ray intersects with the mesh
  24593. * @param ray defines the ray to use
  24594. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24595. * @returns the picking info
  24596. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24597. */
  24598. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24599. /**
  24600. * Clones the current mesh
  24601. * @param name defines the mesh name
  24602. * @param newParent defines the new mesh parent
  24603. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24604. * @returns the new mesh
  24605. */
  24606. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24607. /**
  24608. * Disposes all the submeshes of the current meshnp
  24609. * @returns the current mesh
  24610. */
  24611. releaseSubMeshes(): AbstractMesh;
  24612. /**
  24613. * Releases resources associated with this abstract mesh.
  24614. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24615. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24616. */
  24617. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24618. /**
  24619. * Adds the passed mesh as a child to the current mesh
  24620. * @param mesh defines the child mesh
  24621. * @returns the current mesh
  24622. */
  24623. addChild(mesh: AbstractMesh): AbstractMesh;
  24624. /**
  24625. * Removes the passed mesh from the current mesh children list
  24626. * @param mesh defines the child mesh
  24627. * @returns the current mesh
  24628. */
  24629. removeChild(mesh: AbstractMesh): AbstractMesh;
  24630. /** @hidden */
  24631. private _initFacetData;
  24632. /**
  24633. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24634. * This method can be called within the render loop.
  24635. * 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
  24636. * @returns the current mesh
  24637. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24638. */
  24639. updateFacetData(): AbstractMesh;
  24640. /**
  24641. * Returns the facetLocalNormals array.
  24642. * The normals are expressed in the mesh local spac
  24643. * @returns an array of Vector3
  24644. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24645. */
  24646. getFacetLocalNormals(): Vector3[];
  24647. /**
  24648. * Returns the facetLocalPositions array.
  24649. * The facet positions are expressed in the mesh local space
  24650. * @returns an array of Vector3
  24651. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24652. */
  24653. getFacetLocalPositions(): Vector3[];
  24654. /**
  24655. * Returns the facetLocalPartioning array
  24656. * @returns an array of array of numbers
  24657. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24658. */
  24659. getFacetLocalPartitioning(): number[][];
  24660. /**
  24661. * Returns the i-th facet position in the world system.
  24662. * This method allocates a new Vector3 per call
  24663. * @param i defines the facet index
  24664. * @returns a new Vector3
  24665. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24666. */
  24667. getFacetPosition(i: number): Vector3;
  24668. /**
  24669. * Sets the reference Vector3 with the i-th facet position in the world system
  24670. * @param i defines the facet index
  24671. * @param ref defines the target vector
  24672. * @returns the current mesh
  24673. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24674. */
  24675. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24676. /**
  24677. * Returns the i-th facet normal in the world system.
  24678. * This method allocates a new Vector3 per call
  24679. * @param i defines the facet index
  24680. * @returns a new Vector3
  24681. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24682. */
  24683. getFacetNormal(i: number): Vector3;
  24684. /**
  24685. * Sets the reference Vector3 with the i-th facet normal in the world system
  24686. * @param i defines the facet index
  24687. * @param ref defines the target vector
  24688. * @returns the current mesh
  24689. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24690. */
  24691. getFacetNormalToRef(i: number, ref: Vector3): this;
  24692. /**
  24693. * 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)
  24694. * @param x defines x coordinate
  24695. * @param y defines y coordinate
  24696. * @param z defines z coordinate
  24697. * @returns the array of facet indexes
  24698. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24699. */
  24700. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24701. /**
  24702. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24703. * @param projected sets as the (x,y,z) world projection on the facet
  24704. * @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
  24705. * @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
  24706. * @param x defines x coordinate
  24707. * @param y defines y coordinate
  24708. * @param z defines z coordinate
  24709. * @returns the face index if found (or null instead)
  24710. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24711. */
  24712. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24713. /**
  24714. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24715. * @param projected sets as the (x,y,z) local projection on the facet
  24716. * @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
  24717. * @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
  24718. * @param x defines x coordinate
  24719. * @param y defines y coordinate
  24720. * @param z defines z coordinate
  24721. * @returns the face index if found (or null instead)
  24722. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24723. */
  24724. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24725. /**
  24726. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24727. * @returns the parameters
  24728. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24729. */
  24730. getFacetDataParameters(): any;
  24731. /**
  24732. * Disables the feature FacetData and frees the related memory
  24733. * @returns the current mesh
  24734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24735. */
  24736. disableFacetData(): AbstractMesh;
  24737. /**
  24738. * Updates the AbstractMesh indices array
  24739. * @param indices defines the data source
  24740. * @returns the current mesh
  24741. */
  24742. updateIndices(indices: IndicesArray): AbstractMesh;
  24743. /**
  24744. * Creates new normals data for the mesh
  24745. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24746. * @returns the current mesh
  24747. */
  24748. createNormals(updatable: boolean): AbstractMesh;
  24749. /**
  24750. * Align the mesh with a normal
  24751. * @param normal defines the normal to use
  24752. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24753. * @returns the current mesh
  24754. */
  24755. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24756. /** @hidden */
  24757. _checkOcclusionQuery(): boolean;
  24758. }
  24759. }
  24760. declare module BABYLON {
  24761. /**
  24762. * Class used to store data that will be store in GPU memory
  24763. */
  24764. class Buffer {
  24765. private _engine;
  24766. private _buffer;
  24767. /** @hidden */
  24768. _data: Nullable<DataArray>;
  24769. private _updatable;
  24770. private _instanced;
  24771. /**
  24772. * Gets the byte stride.
  24773. */
  24774. readonly byteStride: number;
  24775. /**
  24776. * Constructor
  24777. * @param engine the engine
  24778. * @param data the data to use for this buffer
  24779. * @param updatable whether the data is updatable
  24780. * @param stride the stride (optional)
  24781. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24782. * @param instanced whether the buffer is instanced (optional)
  24783. * @param useBytes set to true if the stride in in bytes (optional)
  24784. */
  24785. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  24786. /**
  24787. * Create a new VertexBuffer based on the current buffer
  24788. * @param kind defines the vertex buffer kind (position, normal, etc.)
  24789. * @param offset defines offset in the buffer (0 by default)
  24790. * @param size defines the size in floats of attributes (position is 3 for instance)
  24791. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  24792. * @param instanced defines if the vertex buffer contains indexed data
  24793. * @param useBytes defines if the offset and stride are in bytes
  24794. * @returns the new vertex buffer
  24795. */
  24796. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  24797. /**
  24798. * Gets a boolean indicating if the Buffer is updatable?
  24799. * @returns true if the buffer is updatable
  24800. */
  24801. isUpdatable(): boolean;
  24802. /**
  24803. * Gets current buffer's data
  24804. * @returns a DataArray or null
  24805. */
  24806. getData(): Nullable<DataArray>;
  24807. /**
  24808. * Gets underlying native buffer
  24809. * @returns underlying native buffer
  24810. */
  24811. getBuffer(): Nullable<WebGLBuffer>;
  24812. /**
  24813. * Gets the stride in float32 units (i.e. byte stride / 4).
  24814. * May not be an integer if the byte stride is not divisible by 4.
  24815. * DEPRECATED. Use byteStride instead.
  24816. * @returns the stride in float32 units
  24817. */
  24818. getStrideSize(): number;
  24819. /**
  24820. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  24821. * @param data defines the data to store
  24822. */
  24823. create(data?: Nullable<DataArray>): void;
  24824. /** @hidden */
  24825. _rebuild(): void;
  24826. /**
  24827. * Update current buffer data
  24828. * @param data defines the data to store
  24829. */
  24830. update(data: DataArray): void;
  24831. /**
  24832. * Updates the data directly.
  24833. * @param data the new data
  24834. * @param offset the new offset
  24835. * @param vertexCount the vertex count (optional)
  24836. * @param useBytes set to true if the offset is in bytes
  24837. */
  24838. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  24839. /**
  24840. * Release all resources
  24841. */
  24842. dispose(): void;
  24843. }
  24844. }
  24845. declare module BABYLON {
  24846. /**
  24847. * Class for building Constructive Solid Geometry
  24848. */
  24849. class CSG {
  24850. private polygons;
  24851. /**
  24852. * The world matrix
  24853. */
  24854. matrix: Matrix;
  24855. /**
  24856. * Stores the position
  24857. */
  24858. position: Vector3;
  24859. /**
  24860. * Stores the rotation
  24861. */
  24862. rotation: Vector3;
  24863. /**
  24864. * Stores the rotation quaternion
  24865. */
  24866. rotationQuaternion: Nullable<Quaternion>;
  24867. /**
  24868. * Stores the scaling vector
  24869. */
  24870. scaling: Vector3;
  24871. /**
  24872. * Convert the BABYLON.Mesh to BABYLON.CSG
  24873. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  24874. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  24875. */
  24876. static FromMesh(mesh: Mesh): CSG;
  24877. /**
  24878. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  24879. * @param polygons Polygons used to construct a BABYLON.CSG solid
  24880. */
  24881. private static FromPolygons;
  24882. /**
  24883. * Clones, or makes a deep copy, of the BABYLON.CSG
  24884. * @returns A new BABYLON.CSG
  24885. */
  24886. clone(): CSG;
  24887. /**
  24888. * Unions this CSG with another CSG
  24889. * @param csg The CSG to union against this CSG
  24890. * @returns The unioned CSG
  24891. */
  24892. union(csg: CSG): CSG;
  24893. /**
  24894. * Unions this CSG with another CSG in place
  24895. * @param csg The CSG to union against this CSG
  24896. */
  24897. unionInPlace(csg: CSG): void;
  24898. /**
  24899. * Subtracts this CSG with another CSG
  24900. * @param csg The CSG to subtract against this CSG
  24901. * @returns A new BABYLON.CSG
  24902. */
  24903. subtract(csg: CSG): CSG;
  24904. /**
  24905. * Subtracts this CSG with another CSG in place
  24906. * @param csg The CSG to subtact against this CSG
  24907. */
  24908. subtractInPlace(csg: CSG): void;
  24909. /**
  24910. * Intersect this CSG with another CSG
  24911. * @param csg The CSG to intersect against this CSG
  24912. * @returns A new BABYLON.CSG
  24913. */
  24914. intersect(csg: CSG): CSG;
  24915. /**
  24916. * Intersects this CSG with another CSG in place
  24917. * @param csg The CSG to intersect against this CSG
  24918. */
  24919. intersectInPlace(csg: CSG): void;
  24920. /**
  24921. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  24922. * not modified.
  24923. * @returns A new BABYLON.CSG solid with solid and empty space switched
  24924. */
  24925. inverse(): CSG;
  24926. /**
  24927. * Inverses the BABYLON.CSG in place
  24928. */
  24929. inverseInPlace(): void;
  24930. /**
  24931. * This is used to keep meshes transformations so they can be restored
  24932. * when we build back a Babylon Mesh
  24933. * NB : All CSG operations are performed in world coordinates
  24934. * @param csg The BABYLON.CSG to copy the transform attributes from
  24935. * @returns This BABYLON.CSG
  24936. */
  24937. copyTransformAttributes(csg: CSG): CSG;
  24938. /**
  24939. * Build Raw mesh from CSG
  24940. * Coordinates here are in world space
  24941. * @param name The name of the mesh geometry
  24942. * @param scene The BABYLON.Scene
  24943. * @param keepSubMeshes Specifies if the submeshes should be kept
  24944. * @returns A new BABYLON.Mesh
  24945. */
  24946. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  24947. /**
  24948. * Build Mesh from CSG taking material and transforms into account
  24949. * @param name The name of the BABYLON.Mesh
  24950. * @param material The material of the BABYLON.Mesh
  24951. * @param scene The BABYLON.Scene
  24952. * @param keepSubMeshes Specifies if submeshes should be kept
  24953. * @returns The new BABYLON.Mesh
  24954. */
  24955. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  24956. }
  24957. }
  24958. declare module BABYLON {
  24959. /**
  24960. * Class used to store geometry data (vertex buffers + index buffer)
  24961. */
  24962. class Geometry implements IGetSetVerticesData {
  24963. /**
  24964. * Gets or sets the unique ID of the geometry
  24965. */
  24966. id: string;
  24967. /**
  24968. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24969. */
  24970. delayLoadState: number;
  24971. /**
  24972. * Gets the file containing the data to load when running in delay load state
  24973. */
  24974. delayLoadingFile: Nullable<string>;
  24975. /**
  24976. * Callback called when the geometry is updated
  24977. */
  24978. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24979. private _scene;
  24980. private _engine;
  24981. private _meshes;
  24982. private _totalVertices;
  24983. /** @hidden */
  24984. _indices: IndicesArray;
  24985. /** @hidden */
  24986. _vertexBuffers: {
  24987. [key: string]: VertexBuffer;
  24988. };
  24989. private _isDisposed;
  24990. private _extend;
  24991. private _boundingBias;
  24992. /** @hidden */
  24993. _delayInfo: Array<string>;
  24994. private _indexBuffer;
  24995. private _indexBufferIsUpdatable;
  24996. /** @hidden */
  24997. _boundingInfo: Nullable<BoundingInfo>;
  24998. /** @hidden */
  24999. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25000. /** @hidden */
  25001. _softwareSkinningFrameId: number;
  25002. private _vertexArrayObjects;
  25003. private _updatable;
  25004. /** @hidden */
  25005. _positions: Nullable<Vector3[]>;
  25006. /**
  25007. * 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
  25008. */
  25009. /**
  25010. * 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
  25011. */
  25012. boundingBias: Vector2;
  25013. /**
  25014. * Static function used to attach a new empty geometry to a mesh
  25015. * @param mesh defines the mesh to attach the geometry to
  25016. * @returns the new Geometry
  25017. */
  25018. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25019. /**
  25020. * Creates a new geometry
  25021. * @param id defines the unique ID
  25022. * @param scene defines the hosting scene
  25023. * @param vertexData defines the VertexData used to get geometry data
  25024. * @param updatable defines if geometry must be updatable (false by default)
  25025. * @param mesh defines the mesh that will be associated with the geometry
  25026. */
  25027. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25028. /**
  25029. * Gets the current extend of the geometry
  25030. */
  25031. readonly extend: {
  25032. minimum: Vector3;
  25033. maximum: Vector3;
  25034. };
  25035. /**
  25036. * Gets the hosting scene
  25037. * @returns the hosting Scene
  25038. */
  25039. getScene(): Scene;
  25040. /**
  25041. * Gets the hosting engine
  25042. * @returns the hosting Engine
  25043. */
  25044. getEngine(): Engine;
  25045. /**
  25046. * Defines if the geometry is ready to use
  25047. * @returns true if the geometry is ready to be used
  25048. */
  25049. isReady(): boolean;
  25050. /**
  25051. * Gets a value indicating that the geometry should not be serialized
  25052. */
  25053. readonly doNotSerialize: boolean;
  25054. /** @hidden */
  25055. _rebuild(): void;
  25056. /**
  25057. * Affects all geometry data in one call
  25058. * @param vertexData defines the geometry data
  25059. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25060. */
  25061. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25062. /**
  25063. * Set specific vertex data
  25064. * @param kind defines the data kind (Position, normal, etc...)
  25065. * @param data defines the vertex data to use
  25066. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25067. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25068. */
  25069. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25070. /**
  25071. * Removes a specific vertex data
  25072. * @param kind defines the data kind (Position, normal, etc...)
  25073. */
  25074. removeVerticesData(kind: string): void;
  25075. /**
  25076. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25077. * @param buffer defines the vertex buffer to use
  25078. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25079. */
  25080. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25081. /**
  25082. * Update a specific vertex buffer
  25083. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25084. * It will do nothing if the buffer is not updatable
  25085. * @param kind defines the data kind (Position, normal, etc...)
  25086. * @param data defines the data to use
  25087. * @param offset defines the offset in the target buffer where to store the data
  25088. * @param useBytes set to true if the offset is in bytes
  25089. */
  25090. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25091. /**
  25092. * Update a specific vertex buffer
  25093. * This function will create a new buffer if the current one is not updatable
  25094. * @param kind defines the data kind (Position, normal, etc...)
  25095. * @param data defines the data to use
  25096. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25097. */
  25098. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25099. private _updateBoundingInfo;
  25100. /** @hidden */
  25101. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25102. /**
  25103. * Gets total number of vertices
  25104. * @returns the total number of vertices
  25105. */
  25106. getTotalVertices(): number;
  25107. /**
  25108. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25109. * @param kind defines the data kind (Position, normal, etc...)
  25110. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25111. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25112. * @returns a float array containing vertex data
  25113. */
  25114. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25115. /**
  25116. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25117. * @param kind defines the data kind (Position, normal, etc...)
  25118. * @returns true if the vertex buffer with the specified kind is updatable
  25119. */
  25120. isVertexBufferUpdatable(kind: string): boolean;
  25121. /**
  25122. * Gets a specific vertex buffer
  25123. * @param kind defines the data kind (Position, normal, etc...)
  25124. * @returns a VertexBuffer
  25125. */
  25126. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25127. /**
  25128. * Returns all vertex buffers
  25129. * @return an object holding all vertex buffers indexed by kind
  25130. */
  25131. getVertexBuffers(): Nullable<{
  25132. [key: string]: VertexBuffer;
  25133. }>;
  25134. /**
  25135. * Gets a boolean indicating if specific vertex buffer is present
  25136. * @param kind defines the data kind (Position, normal, etc...)
  25137. * @returns true if data is present
  25138. */
  25139. isVerticesDataPresent(kind: string): boolean;
  25140. /**
  25141. * Gets a list of all attached data kinds (Position, normal, etc...)
  25142. * @returns a list of string containing all kinds
  25143. */
  25144. getVerticesDataKinds(): string[];
  25145. /**
  25146. * Update index buffer
  25147. * @param indices defines the indices to store in the index buffer
  25148. * @param offset defines the offset in the target buffer where to store the data
  25149. */
  25150. updateIndices(indices: IndicesArray, offset?: number): void;
  25151. /**
  25152. * Creates a new index buffer
  25153. * @param indices defines the indices to store in the index buffer
  25154. * @param totalVertices defines the total number of vertices (could be null)
  25155. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25156. */
  25157. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25158. /**
  25159. * Return the total number of indices
  25160. * @returns the total number of indices
  25161. */
  25162. getTotalIndices(): number;
  25163. /**
  25164. * Gets the index buffer array
  25165. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25166. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25167. * @returns the index buffer array
  25168. */
  25169. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25170. /**
  25171. * Gets the index buffer
  25172. * @return the index buffer
  25173. */
  25174. getIndexBuffer(): Nullable<WebGLBuffer>;
  25175. /** @hidden */
  25176. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25177. /**
  25178. * Release the associated resources for a specific mesh
  25179. * @param mesh defines the source mesh
  25180. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25181. */
  25182. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25183. /**
  25184. * Apply current geometry to a given mesh
  25185. * @param mesh defines the mesh to apply geometry to
  25186. */
  25187. applyToMesh(mesh: Mesh): void;
  25188. private _updateExtend;
  25189. private _applyToMesh;
  25190. private notifyUpdate;
  25191. /**
  25192. * Load the geometry if it was flagged as delay loaded
  25193. * @param scene defines the hosting scene
  25194. * @param onLoaded defines a callback called when the geometry is loaded
  25195. */
  25196. load(scene: Scene, onLoaded?: () => void): void;
  25197. private _queueLoad;
  25198. /**
  25199. * Invert the geometry to move from a right handed system to a left handed one.
  25200. */
  25201. toLeftHanded(): void;
  25202. /** @hidden */
  25203. _resetPointsArrayCache(): void;
  25204. /** @hidden */
  25205. _generatePointsArray(): boolean;
  25206. /**
  25207. * Gets a value indicating if the geometry is disposed
  25208. * @returns true if the geometry was disposed
  25209. */
  25210. isDisposed(): boolean;
  25211. private _disposeVertexArrayObjects;
  25212. /**
  25213. * Free all associated resources
  25214. */
  25215. dispose(): void;
  25216. /**
  25217. * Clone the current geometry into a new geometry
  25218. * @param id defines the unique ID of the new geometry
  25219. * @returns a new geometry object
  25220. */
  25221. copy(id: string): Geometry;
  25222. /**
  25223. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25224. * @return a JSON representation of the current geometry data (without the vertices data)
  25225. */
  25226. serialize(): any;
  25227. private toNumberArray;
  25228. /**
  25229. * Serialize all vertices data into a JSON oject
  25230. * @returns a JSON representation of the current geometry data
  25231. */
  25232. serializeVerticeData(): any;
  25233. /**
  25234. * Extracts a clone of a mesh geometry
  25235. * @param mesh defines the source mesh
  25236. * @param id defines the unique ID of the new geometry object
  25237. * @returns the new geometry object
  25238. */
  25239. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25240. /**
  25241. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25242. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25243. * Be aware Math.random() could cause collisions, but:
  25244. * "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"
  25245. * @returns a string containing a new GUID
  25246. */
  25247. static RandomId(): string;
  25248. /** @hidden */
  25249. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25250. private static _CleanMatricesWeights;
  25251. /**
  25252. * Create a new geometry from persisted data (Using .babylon file format)
  25253. * @param parsedVertexData defines the persisted data
  25254. * @param scene defines the hosting scene
  25255. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25256. * @returns the new geometry object
  25257. */
  25258. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25259. }
  25260. /**
  25261. * Abstract class used to provide common services for all typed geometries
  25262. * @hidden
  25263. */
  25264. class _PrimitiveGeometry extends Geometry {
  25265. private _canBeRegenerated;
  25266. private _beingRegenerated;
  25267. /**
  25268. * Creates a new typed geometry
  25269. * @param id defines the unique ID of the geometry
  25270. * @param scene defines the hosting scene
  25271. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25272. * @param mesh defines the hosting mesh (can be null)
  25273. */
  25274. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25275. /**
  25276. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25277. * @returns true if the geometry can be regenerated
  25278. */
  25279. canBeRegenerated(): boolean;
  25280. /**
  25281. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25282. */
  25283. regenerate(): void;
  25284. /**
  25285. * Clone the geometry
  25286. * @param id defines the unique ID of the new geometry
  25287. * @returns the new geometry
  25288. */
  25289. asNewGeometry(id: string): Geometry;
  25290. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25291. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25292. /** @hidden */
  25293. _regenerateVertexData(): VertexData;
  25294. copy(id: string): Geometry;
  25295. serialize(): any;
  25296. }
  25297. /**
  25298. * Creates a ribbon geometry
  25299. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25300. */
  25301. class RibbonGeometry extends _PrimitiveGeometry {
  25302. /**
  25303. * Defines the array of paths to use
  25304. */
  25305. pathArray: Vector3[][];
  25306. /**
  25307. * Defines if the last and first points of each path in your pathArray must be joined
  25308. */
  25309. closeArray: boolean;
  25310. /**
  25311. * Defines if the last and first points of each path in your pathArray must be joined
  25312. */
  25313. closePath: boolean;
  25314. /**
  25315. * Defines the offset between points
  25316. */
  25317. offset: number;
  25318. /**
  25319. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25320. */
  25321. side: number;
  25322. /**
  25323. * Creates a ribbon geometry
  25324. * @param id defines the unique ID of the geometry
  25325. * @param scene defines the hosting scene
  25326. * @param pathArray defines the array of paths to use
  25327. * @param closeArray defines if the last path and the first path must be joined
  25328. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25329. * @param offset defines the offset between points
  25330. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25331. * @param mesh defines the hosting mesh (can be null)
  25332. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25333. */
  25334. constructor(id: string, scene: Scene,
  25335. /**
  25336. * Defines the array of paths to use
  25337. */
  25338. pathArray: Vector3[][],
  25339. /**
  25340. * Defines if the last and first points of each path in your pathArray must be joined
  25341. */
  25342. closeArray: boolean,
  25343. /**
  25344. * Defines if the last and first points of each path in your pathArray must be joined
  25345. */
  25346. closePath: boolean,
  25347. /**
  25348. * Defines the offset between points
  25349. */
  25350. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25351. /**
  25352. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25353. */
  25354. side?: number);
  25355. /** @hidden */
  25356. _regenerateVertexData(): VertexData;
  25357. copy(id: string): Geometry;
  25358. }
  25359. /**
  25360. * Creates a box geometry
  25361. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25362. */
  25363. class BoxGeometry extends _PrimitiveGeometry {
  25364. /**
  25365. * Defines the zise of the box (width, height and depth are the same)
  25366. */
  25367. size: number;
  25368. /**
  25369. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25370. */
  25371. side: number;
  25372. /**
  25373. * Creates a box geometry
  25374. * @param id defines the unique ID of the geometry
  25375. * @param scene defines the hosting scene
  25376. * @param size defines the zise of the box (width, height and depth are the same)
  25377. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25378. * @param mesh defines the hosting mesh (can be null)
  25379. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25380. */
  25381. constructor(id: string, scene: Scene,
  25382. /**
  25383. * Defines the zise of the box (width, height and depth are the same)
  25384. */
  25385. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25386. /**
  25387. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25388. */
  25389. side?: number);
  25390. /** @hidden */
  25391. _regenerateVertexData(): VertexData;
  25392. copy(id: string): Geometry;
  25393. serialize(): any;
  25394. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25395. }
  25396. /**
  25397. * Creates a sphere geometry
  25398. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25399. */
  25400. class SphereGeometry extends _PrimitiveGeometry {
  25401. /**
  25402. * Defines the number of segments to use to create the sphere
  25403. */
  25404. segments: number;
  25405. /**
  25406. * Defines the diameter of the sphere
  25407. */
  25408. diameter: number;
  25409. /**
  25410. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25411. */
  25412. side: number;
  25413. /**
  25414. * Create a new sphere geometry
  25415. * @param id defines the unique ID of the geometry
  25416. * @param scene defines the hosting scene
  25417. * @param segments defines the number of segments to use to create the sphere
  25418. * @param diameter defines the diameter of the sphere
  25419. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25420. * @param mesh defines the hosting mesh (can be null)
  25421. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25422. */
  25423. constructor(id: string, scene: Scene,
  25424. /**
  25425. * Defines the number of segments to use to create the sphere
  25426. */
  25427. segments: number,
  25428. /**
  25429. * Defines the diameter of the sphere
  25430. */
  25431. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25432. /**
  25433. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25434. */
  25435. side?: number);
  25436. /** @hidden */
  25437. _regenerateVertexData(): VertexData;
  25438. copy(id: string): Geometry;
  25439. serialize(): any;
  25440. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25441. }
  25442. /**
  25443. * Creates a disc geometry
  25444. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25445. */
  25446. class DiscGeometry extends _PrimitiveGeometry {
  25447. /**
  25448. * Defines the radius of the disc
  25449. */
  25450. radius: number;
  25451. /**
  25452. * Defines the tesselation factor to apply to the disc
  25453. */
  25454. tessellation: number;
  25455. /**
  25456. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25457. */
  25458. side: number;
  25459. /**
  25460. * Creates a new disc geometry
  25461. * @param id defines the unique ID of the geometry
  25462. * @param scene defines the hosting scene
  25463. * @param radius defines the radius of the disc
  25464. * @param tessellation defines the tesselation factor to apply to the disc
  25465. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25466. * @param mesh defines the hosting mesh (can be null)
  25467. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25468. */
  25469. constructor(id: string, scene: Scene,
  25470. /**
  25471. * Defines the radius of the disc
  25472. */
  25473. radius: number,
  25474. /**
  25475. * Defines the tesselation factor to apply to the disc
  25476. */
  25477. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25478. /**
  25479. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25480. */
  25481. side?: number);
  25482. /** @hidden */
  25483. _regenerateVertexData(): VertexData;
  25484. copy(id: string): Geometry;
  25485. }
  25486. /**
  25487. * Creates a new cylinder geometry
  25488. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25489. */
  25490. class CylinderGeometry extends _PrimitiveGeometry {
  25491. /**
  25492. * Defines the height of the cylinder
  25493. */
  25494. height: number;
  25495. /**
  25496. * Defines the diameter of the cylinder's top cap
  25497. */
  25498. diameterTop: number;
  25499. /**
  25500. * Defines the diameter of the cylinder's bottom cap
  25501. */
  25502. diameterBottom: number;
  25503. /**
  25504. * Defines the tessellation factor to apply to the cylinder
  25505. */
  25506. tessellation: number;
  25507. /**
  25508. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25509. */
  25510. subdivisions: number;
  25511. /**
  25512. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25513. */
  25514. side: number;
  25515. /**
  25516. * Creates a new cylinder geometry
  25517. * @param id defines the unique ID of the geometry
  25518. * @param scene defines the hosting scene
  25519. * @param height defines the height of the cylinder
  25520. * @param diameterTop defines the diameter of the cylinder's top cap
  25521. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25522. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25523. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25524. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25525. * @param mesh defines the hosting mesh (can be null)
  25526. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25527. */
  25528. constructor(id: string, scene: Scene,
  25529. /**
  25530. * Defines the height of the cylinder
  25531. */
  25532. height: number,
  25533. /**
  25534. * Defines the diameter of the cylinder's top cap
  25535. */
  25536. diameterTop: number,
  25537. /**
  25538. * Defines the diameter of the cylinder's bottom cap
  25539. */
  25540. diameterBottom: number,
  25541. /**
  25542. * Defines the tessellation factor to apply to the cylinder
  25543. */
  25544. tessellation: number,
  25545. /**
  25546. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25547. */
  25548. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25549. /**
  25550. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25551. */
  25552. side?: number);
  25553. /** @hidden */
  25554. _regenerateVertexData(): VertexData;
  25555. copy(id: string): Geometry;
  25556. serialize(): any;
  25557. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25558. }
  25559. /**
  25560. * Creates a new torus geometry
  25561. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25562. */
  25563. class TorusGeometry extends _PrimitiveGeometry {
  25564. /**
  25565. * Defines the diameter of the torus
  25566. */
  25567. diameter: number;
  25568. /**
  25569. * Defines the thickness of the torus (ie. internal diameter)
  25570. */
  25571. thickness: number;
  25572. /**
  25573. * Defines the tesselation factor to apply to the torus
  25574. */
  25575. tessellation: number;
  25576. /**
  25577. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25578. */
  25579. side: number;
  25580. /**
  25581. * Creates a new torus geometry
  25582. * @param id defines the unique ID of the geometry
  25583. * @param scene defines the hosting scene
  25584. * @param diameter defines the diameter of the torus
  25585. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25586. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25587. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25588. * @param mesh defines the hosting mesh (can be null)
  25589. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25590. */
  25591. constructor(id: string, scene: Scene,
  25592. /**
  25593. * Defines the diameter of the torus
  25594. */
  25595. diameter: number,
  25596. /**
  25597. * Defines the thickness of the torus (ie. internal diameter)
  25598. */
  25599. thickness: number,
  25600. /**
  25601. * Defines the tesselation factor to apply to the torus
  25602. */
  25603. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25604. /**
  25605. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25606. */
  25607. side?: number);
  25608. /** @hidden */
  25609. _regenerateVertexData(): VertexData;
  25610. copy(id: string): Geometry;
  25611. serialize(): any;
  25612. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25613. }
  25614. /**
  25615. * Creates a new ground geometry
  25616. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25617. */
  25618. class GroundGeometry extends _PrimitiveGeometry {
  25619. /**
  25620. * Defines the width of the ground
  25621. */
  25622. width: number;
  25623. /**
  25624. * Defines the height of the ground
  25625. */
  25626. height: number;
  25627. /**
  25628. * Defines the subdivisions to apply to the ground
  25629. */
  25630. subdivisions: number;
  25631. /**
  25632. * Creates a new ground geometry
  25633. * @param id defines the unique ID of the geometry
  25634. * @param scene defines the hosting scene
  25635. * @param width defines the width of the ground
  25636. * @param height defines the height of the ground
  25637. * @param subdivisions defines the subdivisions to apply to the ground
  25638. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25639. * @param mesh defines the hosting mesh (can be null)
  25640. */
  25641. constructor(id: string, scene: Scene,
  25642. /**
  25643. * Defines the width of the ground
  25644. */
  25645. width: number,
  25646. /**
  25647. * Defines the height of the ground
  25648. */
  25649. height: number,
  25650. /**
  25651. * Defines the subdivisions to apply to the ground
  25652. */
  25653. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25654. /** @hidden */
  25655. _regenerateVertexData(): VertexData;
  25656. copy(id: string): Geometry;
  25657. serialize(): any;
  25658. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25659. }
  25660. /**
  25661. * Creates a tiled ground geometry
  25662. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25663. */
  25664. class TiledGroundGeometry extends _PrimitiveGeometry {
  25665. /**
  25666. * Defines the minimum value on X axis
  25667. */
  25668. xmin: number;
  25669. /**
  25670. * Defines the minimum value on Z axis
  25671. */
  25672. zmin: number;
  25673. /**
  25674. * Defines the maximum value on X axis
  25675. */
  25676. xmax: number;
  25677. /**
  25678. * Defines the maximum value on Z axis
  25679. */
  25680. zmax: number;
  25681. /**
  25682. * Defines the subdivisions to apply to the ground
  25683. */
  25684. subdivisions: {
  25685. w: number;
  25686. h: number;
  25687. };
  25688. /**
  25689. * Defines the precision to use when computing the tiles
  25690. */
  25691. precision: {
  25692. w: number;
  25693. h: number;
  25694. };
  25695. /**
  25696. * Creates a tiled ground geometry
  25697. * @param id defines the unique ID of the geometry
  25698. * @param scene defines the hosting scene
  25699. * @param xmin defines the minimum value on X axis
  25700. * @param zmin defines the minimum value on Z axis
  25701. * @param xmax defines the maximum value on X axis
  25702. * @param zmax defines the maximum value on Z axis
  25703. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  25704. * @param precision defines the precision to use when computing the tiles
  25705. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25706. * @param mesh defines the hosting mesh (can be null)
  25707. */
  25708. constructor(id: string, scene: Scene,
  25709. /**
  25710. * Defines the minimum value on X axis
  25711. */
  25712. xmin: number,
  25713. /**
  25714. * Defines the minimum value on Z axis
  25715. */
  25716. zmin: number,
  25717. /**
  25718. * Defines the maximum value on X axis
  25719. */
  25720. xmax: number,
  25721. /**
  25722. * Defines the maximum value on Z axis
  25723. */
  25724. zmax: number,
  25725. /**
  25726. * Defines the subdivisions to apply to the ground
  25727. */
  25728. subdivisions: {
  25729. w: number;
  25730. h: number;
  25731. },
  25732. /**
  25733. * Defines the precision to use when computing the tiles
  25734. */
  25735. precision: {
  25736. w: number;
  25737. h: number;
  25738. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25739. /** @hidden */
  25740. _regenerateVertexData(): VertexData;
  25741. copy(id: string): Geometry;
  25742. }
  25743. /**
  25744. * Creates a plane geometry
  25745. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  25746. */
  25747. class PlaneGeometry extends _PrimitiveGeometry {
  25748. /**
  25749. * Defines the size of the plane (width === height)
  25750. */
  25751. size: number;
  25752. /**
  25753. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25754. */
  25755. side: number;
  25756. /**
  25757. * Creates a plane geometry
  25758. * @param id defines the unique ID of the geometry
  25759. * @param scene defines the hosting scene
  25760. * @param size defines the size of the plane (width === height)
  25761. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25762. * @param mesh defines the hosting mesh (can be null)
  25763. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25764. */
  25765. constructor(id: string, scene: Scene,
  25766. /**
  25767. * Defines the size of the plane (width === height)
  25768. */
  25769. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25770. /**
  25771. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25772. */
  25773. side?: number);
  25774. /** @hidden */
  25775. _regenerateVertexData(): VertexData;
  25776. copy(id: string): Geometry;
  25777. serialize(): any;
  25778. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  25779. }
  25780. /**
  25781. * Creates a torus knot geometry
  25782. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  25783. */
  25784. class TorusKnotGeometry extends _PrimitiveGeometry {
  25785. /**
  25786. * Defines the radius of the torus knot
  25787. */
  25788. radius: number;
  25789. /**
  25790. * Defines the thickness of the torus knot tube
  25791. */
  25792. tube: number;
  25793. /**
  25794. * Defines the number of radial segments
  25795. */
  25796. radialSegments: number;
  25797. /**
  25798. * Defines the number of tubular segments
  25799. */
  25800. tubularSegments: number;
  25801. /**
  25802. * Defines the first number of windings
  25803. */
  25804. p: number;
  25805. /**
  25806. * Defines the second number of windings
  25807. */
  25808. q: number;
  25809. /**
  25810. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25811. */
  25812. side: number;
  25813. /**
  25814. * Creates a torus knot geometry
  25815. * @param id defines the unique ID of the geometry
  25816. * @param scene defines the hosting scene
  25817. * @param radius defines the radius of the torus knot
  25818. * @param tube defines the thickness of the torus knot tube
  25819. * @param radialSegments defines the number of radial segments
  25820. * @param tubularSegments defines the number of tubular segments
  25821. * @param p defines the first number of windings
  25822. * @param q defines the second number of windings
  25823. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25824. * @param mesh defines the hosting mesh (can be null)
  25825. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25826. */
  25827. constructor(id: string, scene: Scene,
  25828. /**
  25829. * Defines the radius of the torus knot
  25830. */
  25831. radius: number,
  25832. /**
  25833. * Defines the thickness of the torus knot tube
  25834. */
  25835. tube: number,
  25836. /**
  25837. * Defines the number of radial segments
  25838. */
  25839. radialSegments: number,
  25840. /**
  25841. * Defines the number of tubular segments
  25842. */
  25843. tubularSegments: number,
  25844. /**
  25845. * Defines the first number of windings
  25846. */
  25847. p: number,
  25848. /**
  25849. * Defines the second number of windings
  25850. */
  25851. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25852. /**
  25853. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25854. */
  25855. side?: number);
  25856. /** @hidden */
  25857. _regenerateVertexData(): VertexData;
  25858. copy(id: string): Geometry;
  25859. serialize(): any;
  25860. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  25861. }
  25862. }
  25863. declare module BABYLON {
  25864. /**
  25865. * Mesh representing the gorund
  25866. */
  25867. class GroundMesh extends Mesh {
  25868. /** If octree should be generated */
  25869. generateOctree: boolean;
  25870. private _heightQuads;
  25871. /** @hidden */
  25872. _subdivisionsX: number;
  25873. /** @hidden */
  25874. _subdivisionsY: number;
  25875. /** @hidden */
  25876. _width: number;
  25877. /** @hidden */
  25878. _height: number;
  25879. /** @hidden */
  25880. _minX: number;
  25881. /** @hidden */
  25882. _maxX: number;
  25883. /** @hidden */
  25884. _minZ: number;
  25885. /** @hidden */
  25886. _maxZ: number;
  25887. constructor(name: string, scene: Scene);
  25888. /**
  25889. * "GroundMesh"
  25890. * @returns "GroundMesh"
  25891. */
  25892. getClassName(): string;
  25893. /**
  25894. * The minimum of x and y subdivisions
  25895. */
  25896. readonly subdivisions: number;
  25897. /**
  25898. * X subdivisions
  25899. */
  25900. readonly subdivisionsX: number;
  25901. /**
  25902. * Y subdivisions
  25903. */
  25904. readonly subdivisionsY: number;
  25905. /**
  25906. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25907. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25908. * @param chunksCount the number of subdivisions for x and y
  25909. * @param octreeBlocksSize (Default: 32)
  25910. */
  25911. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25912. /**
  25913. * Returns a height (y) value in the Worl system :
  25914. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25915. * @param x x coordinate
  25916. * @param z z coordinate
  25917. * @returns the ground y position if (x, z) are outside the ground surface.
  25918. */
  25919. getHeightAtCoordinates(x: number, z: number): number;
  25920. /**
  25921. * Returns a normalized vector (Vector3) orthogonal to the ground
  25922. * at the ground coordinates (x, z) expressed in the World system.
  25923. * @param x x coordinate
  25924. * @param z z coordinate
  25925. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25926. */
  25927. getNormalAtCoordinates(x: number, z: number): Vector3;
  25928. /**
  25929. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25930. * at the ground coordinates (x, z) expressed in the World system.
  25931. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25932. * @param x x coordinate
  25933. * @param z z coordinate
  25934. * @param ref vector to store the result
  25935. * @returns the GroundMesh.
  25936. */
  25937. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25938. /**
  25939. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25940. * if the ground has been updated.
  25941. * This can be used in the render loop.
  25942. * @returns the GroundMesh.
  25943. */
  25944. updateCoordinateHeights(): GroundMesh;
  25945. private _getFacetAt;
  25946. private _initHeightQuads;
  25947. private _computeHeightQuads;
  25948. /**
  25949. * Serializes this ground mesh
  25950. * @param serializationObject object to write serialization to
  25951. */
  25952. serialize(serializationObject: any): void;
  25953. /**
  25954. * Parses a serialized ground mesh
  25955. * @param parsedMesh the serialized mesh
  25956. * @param scene the scene to create the ground mesh in
  25957. * @returns the created ground mesh
  25958. */
  25959. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25960. }
  25961. }
  25962. declare module BABYLON {
  25963. /**
  25964. * Creates an instance based on a source mesh.
  25965. */
  25966. class InstancedMesh extends AbstractMesh {
  25967. private _sourceMesh;
  25968. private _currentLOD;
  25969. /** @hidden */
  25970. _indexInSourceMeshInstanceArray: number;
  25971. constructor(name: string, source: Mesh);
  25972. /**
  25973. * Returns the string "InstancedMesh".
  25974. */
  25975. getClassName(): string;
  25976. /**
  25977. * If the source mesh receives shadows
  25978. */
  25979. readonly receiveShadows: boolean;
  25980. /**
  25981. * The material of the source mesh
  25982. */
  25983. readonly material: Nullable<Material>;
  25984. /**
  25985. * Visibility of the source mesh
  25986. */
  25987. readonly visibility: number;
  25988. /**
  25989. * Skeleton of the source mesh
  25990. */
  25991. readonly skeleton: Nullable<Skeleton>;
  25992. /**
  25993. * Rendering ground id of the source mesh
  25994. */
  25995. renderingGroupId: number;
  25996. /**
  25997. * Returns the total number of vertices (integer).
  25998. */
  25999. getTotalVertices(): number;
  26000. /**
  26001. * The source mesh of the instance
  26002. */
  26003. readonly sourceMesh: Mesh;
  26004. /**
  26005. * Is this node ready to be used/rendered
  26006. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26007. * @return {boolean} is it ready
  26008. */
  26009. isReady(completeCheck?: boolean): boolean;
  26010. /**
  26011. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26012. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26013. * @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.
  26014. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26015. */
  26016. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26017. /**
  26018. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26019. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26020. * The `data` are either a numeric array either a Float32Array.
  26021. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26022. * 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).
  26023. * Note that a new underlying VertexBuffer object is created each call.
  26024. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26025. *
  26026. * Possible `kind` values :
  26027. * - BABYLON.VertexBuffer.PositionKind
  26028. * - BABYLON.VertexBuffer.UVKind
  26029. * - BABYLON.VertexBuffer.UV2Kind
  26030. * - BABYLON.VertexBuffer.UV3Kind
  26031. * - BABYLON.VertexBuffer.UV4Kind
  26032. * - BABYLON.VertexBuffer.UV5Kind
  26033. * - BABYLON.VertexBuffer.UV6Kind
  26034. * - BABYLON.VertexBuffer.ColorKind
  26035. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26036. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26037. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26038. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26039. *
  26040. * Returns the Mesh.
  26041. */
  26042. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26043. /**
  26044. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26045. * If the mesh has no geometry, it is simply returned as it is.
  26046. * The `data` are either a numeric array either a Float32Array.
  26047. * No new underlying VertexBuffer object is created.
  26048. * 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.
  26049. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26050. *
  26051. * Possible `kind` values :
  26052. * - BABYLON.VertexBuffer.PositionKind
  26053. * - BABYLON.VertexBuffer.UVKind
  26054. * - BABYLON.VertexBuffer.UV2Kind
  26055. * - BABYLON.VertexBuffer.UV3Kind
  26056. * - BABYLON.VertexBuffer.UV4Kind
  26057. * - BABYLON.VertexBuffer.UV5Kind
  26058. * - BABYLON.VertexBuffer.UV6Kind
  26059. * - BABYLON.VertexBuffer.ColorKind
  26060. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26061. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26062. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26063. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26064. *
  26065. * Returns the Mesh.
  26066. */
  26067. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26068. /**
  26069. * Sets the mesh indices.
  26070. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26071. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26072. * This method creates a new index buffer each call.
  26073. * Returns the Mesh.
  26074. */
  26075. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26076. /**
  26077. * Boolean : True if the mesh owns the requested kind of data.
  26078. */
  26079. isVerticesDataPresent(kind: string): boolean;
  26080. /**
  26081. * Returns an array of indices (IndicesArray).
  26082. */
  26083. getIndices(): Nullable<IndicesArray>;
  26084. readonly _positions: Nullable<Vector3[]>;
  26085. /**
  26086. * reconstructs and updates the BoundingInfo of the mesh.
  26087. * @returns the mesh.
  26088. */
  26089. refreshBoundingInfo(): InstancedMesh;
  26090. /** @hidden */
  26091. _preActivate(): InstancedMesh;
  26092. /** @hidden */
  26093. _activate(renderId: number): InstancedMesh;
  26094. /**
  26095. * Returns the current associated LOD AbstractMesh.
  26096. */
  26097. getLOD(camera: Camera): AbstractMesh;
  26098. /** @hidden */
  26099. _syncSubMeshes(): InstancedMesh;
  26100. /** @hidden */
  26101. _generatePointsArray(): boolean;
  26102. /**
  26103. * Creates a new InstancedMesh from the current mesh.
  26104. * - name (string) : the cloned mesh name
  26105. * - newParent (optional Node) : the optional Node to parent the clone to.
  26106. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26107. *
  26108. * Returns the clone.
  26109. */
  26110. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26111. /**
  26112. * Disposes the InstancedMesh.
  26113. * Returns nothing.
  26114. */
  26115. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26116. }
  26117. }
  26118. declare module BABYLON {
  26119. /**
  26120. * Line mesh
  26121. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26122. */
  26123. class LinesMesh extends Mesh {
  26124. /**
  26125. * If vertex color should be applied to the mesh
  26126. */
  26127. useVertexColor?: boolean | undefined;
  26128. /**
  26129. * If vertex alpha should be applied to the mesh
  26130. */
  26131. useVertexAlpha?: boolean | undefined;
  26132. /**
  26133. * Color of the line (Default: White)
  26134. */
  26135. color: Color3;
  26136. /**
  26137. * Alpha of the line (Default: 1)
  26138. */
  26139. alpha: number;
  26140. /**
  26141. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26142. * This margin is expressed in world space coordinates, so its value may vary.
  26143. * Default value is 0.1
  26144. * @returns the intersection Threshold value.
  26145. */
  26146. /**
  26147. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26148. * This margin is expressed in world space coordinates, so its value may vary.
  26149. */
  26150. intersectionThreshold: number;
  26151. private _intersectionThreshold;
  26152. private _colorShader;
  26153. /**
  26154. * Creates a new LinesMesh
  26155. * @param name defines the name
  26156. * @param scene defines the hosting scene
  26157. * @param parent defines the parent mesh if any
  26158. * @param source defines the optional source LinesMesh used to clone data from
  26159. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26160. * When false, achieved by calling a clone(), also passing False.
  26161. * This will make creation of children, recursive.
  26162. * @param useVertexColor defines if this LinesMesh supports vertex color
  26163. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26164. */
  26165. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26166. /**
  26167. * If vertex color should be applied to the mesh
  26168. */
  26169. useVertexColor?: boolean | undefined,
  26170. /**
  26171. * If vertex alpha should be applied to the mesh
  26172. */
  26173. useVertexAlpha?: boolean | undefined);
  26174. /**
  26175. * Returns the string "LineMesh"
  26176. */
  26177. getClassName(): string;
  26178. /**
  26179. * @hidden
  26180. */
  26181. /**
  26182. * @hidden
  26183. */
  26184. material: Material;
  26185. /**
  26186. * @hidden
  26187. */
  26188. readonly checkCollisions: boolean;
  26189. /** @hidden */
  26190. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26191. /** @hidden */
  26192. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26193. /**
  26194. * Disposes of the line mesh
  26195. * @param doNotRecurse If children should be disposed
  26196. */
  26197. dispose(doNotRecurse?: boolean): void;
  26198. /**
  26199. * Returns a new LineMesh object cloned from the current one.
  26200. */
  26201. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26202. }
  26203. }
  26204. declare module BABYLON {
  26205. /**
  26206. * @hidden
  26207. **/
  26208. class _CreationDataStorage {
  26209. closePath?: boolean;
  26210. closeArray?: boolean;
  26211. idx: number[];
  26212. dashSize: number;
  26213. gapSize: number;
  26214. path3D: Path3D;
  26215. pathArray: Vector3[][];
  26216. arc: number;
  26217. radius: number;
  26218. cap: number;
  26219. tessellation: number;
  26220. }
  26221. /**
  26222. * @hidden
  26223. **/
  26224. class _InstanceDataStorage {
  26225. visibleInstances: any;
  26226. renderIdForInstances: number[];
  26227. batchCache: _InstancesBatch;
  26228. instancesBufferSize: number;
  26229. instancesBuffer: Nullable<Buffer>;
  26230. instancesData: Float32Array;
  26231. overridenInstanceCount: number;
  26232. }
  26233. /**
  26234. * @hidden
  26235. **/
  26236. class _InstancesBatch {
  26237. mustReturn: boolean;
  26238. visibleInstances: Nullable<InstancedMesh[]>[];
  26239. renderSelf: boolean[];
  26240. }
  26241. /**
  26242. * Class used to represent renderable models
  26243. */
  26244. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26245. /**
  26246. * Mesh side orientation : usually the external or front surface
  26247. */
  26248. static readonly FRONTSIDE: number;
  26249. /**
  26250. * Mesh side orientation : usually the internal or back surface
  26251. */
  26252. static readonly BACKSIDE: number;
  26253. /**
  26254. * Mesh side orientation : both internal and external or front and back surfaces
  26255. */
  26256. static readonly DOUBLESIDE: number;
  26257. /**
  26258. * Mesh side orientation : by default, `FRONTSIDE`
  26259. */
  26260. static readonly DEFAULTSIDE: number;
  26261. /**
  26262. * Mesh cap setting : no cap
  26263. */
  26264. static readonly NO_CAP: number;
  26265. /**
  26266. * Mesh cap setting : one cap at the beginning of the mesh
  26267. */
  26268. static readonly CAP_START: number;
  26269. /**
  26270. * Mesh cap setting : one cap at the end of the mesh
  26271. */
  26272. static readonly CAP_END: number;
  26273. /**
  26274. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26275. */
  26276. static readonly CAP_ALL: number;
  26277. private _onBeforeRenderObservable;
  26278. private _onAfterRenderObservable;
  26279. private _onBeforeDrawObservable;
  26280. /**
  26281. * An event triggered before rendering the mesh
  26282. */
  26283. readonly onBeforeRenderObservable: Observable<Mesh>;
  26284. /**
  26285. * An event triggered after rendering the mesh
  26286. */
  26287. readonly onAfterRenderObservable: Observable<Mesh>;
  26288. /**
  26289. * An event triggered before drawing the mesh
  26290. */
  26291. readonly onBeforeDrawObservable: Observable<Mesh>;
  26292. private _onBeforeDrawObserver;
  26293. /**
  26294. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26295. */
  26296. onBeforeDraw: () => void;
  26297. /**
  26298. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26299. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26300. */
  26301. delayLoadState: number;
  26302. /**
  26303. * Gets the list of instances created from this mesh
  26304. * it is not supposed to be modified manually.
  26305. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26306. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26307. */
  26308. instances: InstancedMesh[];
  26309. /**
  26310. * Gets the file containing delay loading data for this mesh
  26311. */
  26312. delayLoadingFile: string;
  26313. /** @hidden */
  26314. _binaryInfo: any;
  26315. private _LODLevels;
  26316. /**
  26317. * User defined function used to change how LOD level selection is done
  26318. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26319. */
  26320. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26321. private _morphTargetManager;
  26322. /**
  26323. * Gets or sets the morph target manager
  26324. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26325. */
  26326. morphTargetManager: Nullable<MorphTargetManager>;
  26327. /** @hidden */
  26328. _creationDataStorage: Nullable<_CreationDataStorage>;
  26329. /** @hidden */
  26330. _geometry: Nullable<Geometry>;
  26331. /** @hidden */
  26332. _delayInfo: Array<string>;
  26333. /** @hidden */
  26334. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26335. /** @hidden */
  26336. _instanceDataStorage: _InstanceDataStorage;
  26337. private _effectiveMaterial;
  26338. /** @hidden */
  26339. _shouldGenerateFlatShading: boolean;
  26340. private _preActivateId;
  26341. /** @hidden */
  26342. _originalBuilderSideOrientation: number;
  26343. /**
  26344. * Use this property to change the original side orientation defined at construction time
  26345. */
  26346. overrideMaterialSideOrientation: Nullable<number>;
  26347. private _areNormalsFrozen;
  26348. private _sourcePositions;
  26349. private _sourceNormals;
  26350. private _source;
  26351. private meshMap;
  26352. /**
  26353. * Gets the source mesh (the one used to clone this one from)
  26354. */
  26355. readonly source: Nullable<Mesh>;
  26356. /**
  26357. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26358. */
  26359. isUnIndexed: boolean;
  26360. /**
  26361. * @constructor
  26362. * @param name The value used by scene.getMeshByName() to do a lookup.
  26363. * @param scene The scene to add this mesh to.
  26364. * @param parent The parent of this mesh, if it has one
  26365. * @param source An optional Mesh from which geometry is shared, cloned.
  26366. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26367. * When false, achieved by calling a clone(), also passing False.
  26368. * This will make creation of children, recursive.
  26369. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26370. */
  26371. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26372. /**
  26373. * Gets the class name
  26374. * @returns the string "Mesh".
  26375. */
  26376. getClassName(): string;
  26377. /**
  26378. * Returns a description of this mesh
  26379. * @param fullDetails define if full details about this mesh must be used
  26380. * @returns a descriptive string representing this mesh
  26381. */
  26382. toString(fullDetails?: boolean): string;
  26383. /** @hidden */
  26384. _unBindEffect(): void;
  26385. /**
  26386. * Gets a boolean indicating if this mesh has LOD
  26387. */
  26388. readonly hasLODLevels: boolean;
  26389. /**
  26390. * Gets the list of MeshLODLevel associated with the current mesh
  26391. * @returns an array of MeshLODLevel
  26392. */
  26393. getLODLevels(): MeshLODLevel[];
  26394. private _sortLODLevels;
  26395. /**
  26396. * Add a mesh as LOD level triggered at the given distance.
  26397. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26398. * @param distance The distance from the center of the object to show this level
  26399. * @param mesh The mesh to be added as LOD level (can be null)
  26400. * @return This mesh (for chaining)
  26401. */
  26402. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26403. /**
  26404. * Returns the LOD level mesh at the passed distance or null if not found.
  26405. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26406. * @param distance The distance from the center of the object to show this level
  26407. * @returns a Mesh or `null`
  26408. */
  26409. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26410. /**
  26411. * Remove a mesh from the LOD array
  26412. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26413. * @param mesh defines the mesh to be removed
  26414. * @return This mesh (for chaining)
  26415. */
  26416. removeLODLevel(mesh: Mesh): Mesh;
  26417. /**
  26418. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26419. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26420. * @param camera defines the camera to use to compute distance
  26421. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26422. * @return This mesh (for chaining)
  26423. */
  26424. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26425. /**
  26426. * Gets the mesh internal Geometry object
  26427. */
  26428. readonly geometry: Nullable<Geometry>;
  26429. /**
  26430. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26431. * @returns the total number of vertices
  26432. */
  26433. getTotalVertices(): number;
  26434. /**
  26435. * Returns the content of an associated vertex buffer
  26436. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26437. * - BABYLON.VertexBuffer.PositionKind
  26438. * - BABYLON.VertexBuffer.UVKind
  26439. * - BABYLON.VertexBuffer.UV2Kind
  26440. * - BABYLON.VertexBuffer.UV3Kind
  26441. * - BABYLON.VertexBuffer.UV4Kind
  26442. * - BABYLON.VertexBuffer.UV5Kind
  26443. * - BABYLON.VertexBuffer.UV6Kind
  26444. * - BABYLON.VertexBuffer.ColorKind
  26445. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26446. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26447. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26448. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26449. * @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
  26450. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26451. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26452. */
  26453. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26454. /**
  26455. * Returns the mesh VertexBuffer object from the requested `kind`
  26456. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26457. * - BABYLON.VertexBuffer.PositionKind
  26458. * - BABYLON.VertexBuffer.UVKind
  26459. * - BABYLON.VertexBuffer.UV2Kind
  26460. * - BABYLON.VertexBuffer.UV3Kind
  26461. * - BABYLON.VertexBuffer.UV4Kind
  26462. * - BABYLON.VertexBuffer.UV5Kind
  26463. * - BABYLON.VertexBuffer.UV6Kind
  26464. * - BABYLON.VertexBuffer.ColorKind
  26465. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26466. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26467. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26468. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26469. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26470. */
  26471. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26472. /**
  26473. * Tests if a specific vertex buffer is associated with this mesh
  26474. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26475. * - BABYLON.VertexBuffer.PositionKind
  26476. * - BABYLON.VertexBuffer.UVKind
  26477. * - BABYLON.VertexBuffer.UV2Kind
  26478. * - BABYLON.VertexBuffer.UV3Kind
  26479. * - BABYLON.VertexBuffer.UV4Kind
  26480. * - BABYLON.VertexBuffer.UV5Kind
  26481. * - BABYLON.VertexBuffer.UV6Kind
  26482. * - BABYLON.VertexBuffer.ColorKind
  26483. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26484. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26485. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26486. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26487. * @returns a boolean
  26488. */
  26489. isVerticesDataPresent(kind: string): boolean;
  26490. /**
  26491. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26492. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26493. * - BABYLON.VertexBuffer.PositionKind
  26494. * - BABYLON.VertexBuffer.UVKind
  26495. * - BABYLON.VertexBuffer.UV2Kind
  26496. * - BABYLON.VertexBuffer.UV3Kind
  26497. * - BABYLON.VertexBuffer.UV4Kind
  26498. * - BABYLON.VertexBuffer.UV5Kind
  26499. * - BABYLON.VertexBuffer.UV6Kind
  26500. * - BABYLON.VertexBuffer.ColorKind
  26501. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26502. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26503. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26504. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26505. * @returns a boolean
  26506. */
  26507. isVertexBufferUpdatable(kind: string): boolean;
  26508. /**
  26509. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26510. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26511. * - BABYLON.VertexBuffer.PositionKind
  26512. * - BABYLON.VertexBuffer.UVKind
  26513. * - BABYLON.VertexBuffer.UV2Kind
  26514. * - BABYLON.VertexBuffer.UV3Kind
  26515. * - BABYLON.VertexBuffer.UV4Kind
  26516. * - BABYLON.VertexBuffer.UV5Kind
  26517. * - BABYLON.VertexBuffer.UV6Kind
  26518. * - BABYLON.VertexBuffer.ColorKind
  26519. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26520. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26521. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26522. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26523. * @returns an array of strings
  26524. */
  26525. getVerticesDataKinds(): string[];
  26526. /**
  26527. * Returns a positive integer : the total number of indices in this mesh geometry.
  26528. * @returns the numner of indices or zero if the mesh has no geometry.
  26529. */
  26530. getTotalIndices(): number;
  26531. /**
  26532. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26533. * @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.
  26534. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26535. * @returns the indices array or an empty array if the mesh has no geometry
  26536. */
  26537. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26538. readonly isBlocked: boolean;
  26539. /**
  26540. * Determine if the current mesh is ready to be rendered
  26541. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26542. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26543. * @returns true if all associated assets are ready (material, textures, shaders)
  26544. */
  26545. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26546. /**
  26547. * 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.
  26548. */
  26549. readonly areNormalsFrozen: boolean;
  26550. /**
  26551. * 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.
  26552. * @returns the current mesh
  26553. */
  26554. freezeNormals(): Mesh;
  26555. /**
  26556. * 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
  26557. * @returns the current mesh
  26558. */
  26559. unfreezeNormals(): Mesh;
  26560. /**
  26561. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26562. */
  26563. overridenInstanceCount: number;
  26564. /** @hidden */
  26565. _preActivate(): Mesh;
  26566. /** @hidden */
  26567. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26568. /** @hidden */
  26569. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26570. /**
  26571. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26572. * This means the mesh underlying bounding box and sphere are recomputed.
  26573. * @returns the current mesh
  26574. */
  26575. refreshBoundingInfo(): Mesh;
  26576. /** @hidden */
  26577. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  26578. private _getPositionData;
  26579. /** @hidden */
  26580. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26581. /**
  26582. * This function will subdivide the mesh into multiple submeshes
  26583. * @param count defines the expected number of submeshes
  26584. */
  26585. subdivide(count: number): void;
  26586. /**
  26587. * Copy a FloatArray into a specific associated vertex buffer
  26588. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26589. * - BABYLON.VertexBuffer.PositionKind
  26590. * - BABYLON.VertexBuffer.UVKind
  26591. * - BABYLON.VertexBuffer.UV2Kind
  26592. * - BABYLON.VertexBuffer.UV3Kind
  26593. * - BABYLON.VertexBuffer.UV4Kind
  26594. * - BABYLON.VertexBuffer.UV5Kind
  26595. * - BABYLON.VertexBuffer.UV6Kind
  26596. * - BABYLON.VertexBuffer.ColorKind
  26597. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26598. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26599. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26600. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26601. * @param data defines the data source
  26602. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26603. * @param stride defines the data stride size (can be null)
  26604. * @returns the current mesh
  26605. */
  26606. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26607. /**
  26608. * Flags an associated vertex buffer as updatable
  26609. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26610. * - BABYLON.VertexBuffer.PositionKind
  26611. * - BABYLON.VertexBuffer.UVKind
  26612. * - BABYLON.VertexBuffer.UV2Kind
  26613. * - BABYLON.VertexBuffer.UV3Kind
  26614. * - BABYLON.VertexBuffer.UV4Kind
  26615. * - BABYLON.VertexBuffer.UV5Kind
  26616. * - BABYLON.VertexBuffer.UV6Kind
  26617. * - BABYLON.VertexBuffer.ColorKind
  26618. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26619. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26620. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26621. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26622. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26623. */
  26624. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26625. /**
  26626. * Sets the mesh global Vertex Buffer
  26627. * @param buffer defines the buffer to use
  26628. * @returns the current mesh
  26629. */
  26630. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26631. /**
  26632. * Update a specific associated vertex buffer
  26633. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26634. * - BABYLON.VertexBuffer.PositionKind
  26635. * - BABYLON.VertexBuffer.UVKind
  26636. * - BABYLON.VertexBuffer.UV2Kind
  26637. * - BABYLON.VertexBuffer.UV3Kind
  26638. * - BABYLON.VertexBuffer.UV4Kind
  26639. * - BABYLON.VertexBuffer.UV5Kind
  26640. * - BABYLON.VertexBuffer.UV6Kind
  26641. * - BABYLON.VertexBuffer.ColorKind
  26642. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26643. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26644. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26645. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26646. * @param data defines the data source
  26647. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26648. * @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)
  26649. * @returns the current mesh
  26650. */
  26651. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26652. /**
  26653. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26654. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26655. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26656. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26657. * @returns the current mesh
  26658. */
  26659. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26660. /**
  26661. * Creates a un-shared specific occurence of the geometry for the mesh.
  26662. * @returns the current mesh
  26663. */
  26664. makeGeometryUnique(): Mesh;
  26665. /**
  26666. * Set the index buffer of this mesh
  26667. * @param indices defines the source data
  26668. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26669. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26670. * @returns the current mesh
  26671. */
  26672. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  26673. /**
  26674. * Update the current index buffer
  26675. * @param indices defines the source data
  26676. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26677. * @returns the current mesh
  26678. */
  26679. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  26680. /**
  26681. * Invert the geometry to move from a right handed system to a left handed one.
  26682. * @returns the current mesh
  26683. */
  26684. toLeftHanded(): Mesh;
  26685. /** @hidden */
  26686. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  26687. /** @hidden */
  26688. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  26689. /**
  26690. * Registers for this mesh a javascript function called just before the rendering process
  26691. * @param func defines the function to call before rendering this mesh
  26692. * @returns the current mesh
  26693. */
  26694. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26695. /**
  26696. * Disposes a previously registered javascript function called before the rendering
  26697. * @param func defines the function to remove
  26698. * @returns the current mesh
  26699. */
  26700. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26701. /**
  26702. * Registers for this mesh a javascript function called just after the rendering is complete
  26703. * @param func defines the function to call after rendering this mesh
  26704. * @returns the current mesh
  26705. */
  26706. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26707. /**
  26708. * Disposes a previously registered javascript function called after the rendering.
  26709. * @param func defines the function to remove
  26710. * @returns the current mesh
  26711. */
  26712. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26713. /** @hidden */
  26714. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  26715. /** @hidden */
  26716. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  26717. /** @hidden */
  26718. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  26719. /**
  26720. * 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
  26721. * @param subMesh defines the subMesh to render
  26722. * @param enableAlphaMode defines if alpha mode can be changed
  26723. * @returns the current mesh
  26724. */
  26725. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  26726. private _onBeforeDraw;
  26727. /**
  26728. * Renormalize the mesh and patch it up if there are no weights
  26729. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26730. * However in the case of zero weights then we set just a single influence to 1.
  26731. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26732. */
  26733. cleanMatrixWeights(): void;
  26734. private normalizeSkinFourWeights;
  26735. private normalizeSkinWeightsAndExtra;
  26736. /**
  26737. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26738. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26739. * the user know there was an issue with importing the mesh
  26740. * @returns a validation object with skinned, valid and report string
  26741. */
  26742. validateSkinning(): {
  26743. skinned: boolean;
  26744. valid: boolean;
  26745. report: string;
  26746. };
  26747. /** @hidden */
  26748. _checkDelayState(): Mesh;
  26749. private _queueLoad;
  26750. /**
  26751. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26752. * A mesh is in the frustum if its bounding box intersects the frustum
  26753. * @param frustumPlanes defines the frustum to test
  26754. * @returns true if the mesh is in the frustum planes
  26755. */
  26756. isInFrustum(frustumPlanes: Plane[]): boolean;
  26757. /**
  26758. * Sets the mesh material by the material or multiMaterial `id` property
  26759. * @param id is a string identifying the material or the multiMaterial
  26760. * @returns the current mesh
  26761. */
  26762. setMaterialByID(id: string): Mesh;
  26763. /**
  26764. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26765. * @returns an array of IAnimatable
  26766. */
  26767. getAnimatables(): IAnimatable[];
  26768. /**
  26769. * Modifies the mesh geometry according to the passed transformation matrix.
  26770. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26771. * The mesh normals are modified using the same transformation.
  26772. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26773. * @param transform defines the transform matrix to use
  26774. * @see http://doc.babylonjs.com/resources/baking_transformations
  26775. * @returns the current mesh
  26776. */
  26777. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26778. /**
  26779. * Modifies the mesh geometry according to its own current World Matrix.
  26780. * The mesh World Matrix is then reset.
  26781. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26782. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26783. * @see http://doc.babylonjs.com/resources/baking_transformations
  26784. * @returns the current mesh
  26785. */
  26786. bakeCurrentTransformIntoVertices(): Mesh;
  26787. /** @hidden */
  26788. readonly _positions: Nullable<Vector3[]>;
  26789. /** @hidden */
  26790. _resetPointsArrayCache(): Mesh;
  26791. /** @hidden */
  26792. _generatePointsArray(): boolean;
  26793. /**
  26794. * Returns a new Mesh object generated from the current mesh properties.
  26795. * This method must not get confused with createInstance()
  26796. * @param name is a string, the name given to the new mesh
  26797. * @param newParent can be any Node object (default `null`)
  26798. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26799. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26800. * @returns a new mesh
  26801. */
  26802. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26803. /**
  26804. * Releases resources associated with this mesh.
  26805. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26806. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26807. */
  26808. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26809. /**
  26810. * Modifies the mesh geometry according to a displacement map.
  26811. * 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.
  26812. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26813. * @param url is a string, the URL from the image file is to be downloaded.
  26814. * @param minHeight is the lower limit of the displacement.
  26815. * @param maxHeight is the upper limit of the displacement.
  26816. * @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.
  26817. * @param uvOffset is an optional vector2 used to offset UV.
  26818. * @param uvScale is an optional vector2 used to scale UV.
  26819. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  26820. * @returns the Mesh.
  26821. */
  26822. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26823. /**
  26824. * Modifies the mesh geometry according to a displacementMap buffer.
  26825. * 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.
  26826. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26827. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26828. * @param heightMapWidth is the width of the buffer image.
  26829. * @param heightMapHeight is the height of the buffer image.
  26830. * @param minHeight is the lower limit of the displacement.
  26831. * @param maxHeight is the upper limit of the displacement.
  26832. * @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.
  26833. * @param uvOffset is an optional vector2 used to offset UV.
  26834. * @param uvScale is an optional vector2 used to scale UV.
  26835. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  26836. * @returns the Mesh.
  26837. */
  26838. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26839. /**
  26840. * Modify the mesh to get a flat shading rendering.
  26841. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26842. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26843. * @returns current mesh
  26844. */
  26845. convertToFlatShadedMesh(): Mesh;
  26846. /**
  26847. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26848. * In other words, more vertices, no more indices and a single bigger VBO.
  26849. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26850. * @returns current mesh
  26851. */
  26852. convertToUnIndexedMesh(): Mesh;
  26853. /**
  26854. * Inverses facet orientations.
  26855. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26856. * @param flipNormals will also inverts the normals
  26857. * @returns current mesh
  26858. */
  26859. flipFaces(flipNormals?: boolean): Mesh;
  26860. /**
  26861. * Creates a new InstancedMesh object from the mesh model.
  26862. * Warning : this method is not supported for Line mesh and LineSystem
  26863. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26864. * @param name defines the name of the new instance
  26865. * @returns a new InstancedMesh
  26866. */
  26867. createInstance(name: string): InstancedMesh;
  26868. /**
  26869. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26870. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26871. * @returns the current mesh
  26872. */
  26873. synchronizeInstances(): Mesh;
  26874. /**
  26875. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26876. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26877. * This should be used together with the simplification to avoid disappearing triangles.
  26878. * @param successCallback an optional success callback to be called after the optimization finished.
  26879. * @returns the current mesh
  26880. */
  26881. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26882. /**
  26883. * Serialize current mesh
  26884. * @param serializationObject defines the object which will receive the serialization data
  26885. */
  26886. serialize(serializationObject: any): void;
  26887. /** @hidden */
  26888. _syncGeometryWithMorphTargetManager(): void;
  26889. /**
  26890. * Returns a new Mesh object parsed from the source provided.
  26891. * @param parsedMesh is the source
  26892. * @param scene defines the hosting scene
  26893. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26894. * @returns a new Mesh
  26895. */
  26896. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26897. /**
  26898. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26899. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26900. * @param name defines the name of the mesh to create
  26901. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26902. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26903. * @param closePath creates a seam between the first and the last points of each path of the path array
  26904. * @param offset is taken in account only if the `pathArray` is containing a single path
  26905. * @param scene defines the hosting scene
  26906. * @param updatable defines if the mesh must be flagged as updatable
  26907. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26908. * @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)
  26909. * @returns a new Mesh
  26910. */
  26911. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26912. /**
  26913. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26914. * @param name defines the name of the mesh to create
  26915. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26916. * @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
  26917. * @param scene defines the hosting scene
  26918. * @param updatable defines if the mesh must be flagged as updatable
  26919. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26920. * @returns a new Mesh
  26921. */
  26922. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26923. /**
  26924. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26925. * @param name defines the name of the mesh to create
  26926. * @param size sets the size (float) of each box side (default 1)
  26927. * @param scene defines the hosting scene
  26928. * @param updatable defines if the mesh must be flagged as updatable
  26929. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26930. * @returns a new Mesh
  26931. */
  26932. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26933. /**
  26934. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26935. * @param name defines the name of the mesh to create
  26936. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26937. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26938. * @param scene defines the hosting scene
  26939. * @param updatable defines if the mesh must be flagged as updatable
  26940. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26941. * @returns a new Mesh
  26942. */
  26943. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26944. /**
  26945. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26946. * @param name defines the name of the mesh to create
  26947. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26948. * @param diameterTop set the top cap diameter (floats, default 1)
  26949. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26950. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26951. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26952. * @param scene defines the hosting scene
  26953. * @param updatable defines if the mesh must be flagged as updatable
  26954. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26955. * @returns a new Mesh
  26956. */
  26957. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26958. /**
  26959. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26960. * @param name defines the name of the mesh to create
  26961. * @param diameter sets the diameter size (float) of the torus (default 1)
  26962. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26963. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26964. * @param scene defines the hosting scene
  26965. * @param updatable defines if the mesh must be flagged as updatable
  26966. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26967. * @returns a new Mesh
  26968. */
  26969. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26970. /**
  26971. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26972. * @param name defines the name of the mesh to create
  26973. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26974. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26975. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26976. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26977. * @param p the number of windings on X axis (positive integers, default 2)
  26978. * @param q the number of windings on Y axis (positive integers, default 3)
  26979. * @param scene defines the hosting scene
  26980. * @param updatable defines if the mesh must be flagged as updatable
  26981. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26982. * @returns a new Mesh
  26983. */
  26984. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26985. /**
  26986. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26987. * @param name defines the name of the mesh to create
  26988. * @param points is an array successive Vector3
  26989. * @param scene defines the hosting scene
  26990. * @param updatable defines if the mesh must be flagged as updatable
  26991. * @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).
  26992. * @returns a new Mesh
  26993. */
  26994. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26995. /**
  26996. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26997. * @param name defines the name of the mesh to create
  26998. * @param points is an array successive Vector3
  26999. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27000. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27001. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27002. * @param scene defines the hosting scene
  27003. * @param updatable defines if the mesh must be flagged as updatable
  27004. * @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)
  27005. * @returns a new Mesh
  27006. */
  27007. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27008. /**
  27009. * Creates a polygon mesh.
  27010. * Please consider using the same method from the MeshBuilder class instead.
  27011. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27012. * 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.
  27013. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27014. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27015. * Remember you can only change the shape positions, not their number when updating a polygon.
  27016. */
  27017. /**
  27018. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27019. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27020. * @param name defines the name of the mesh to create
  27021. * @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
  27022. * @param scene defines the hosting scene
  27023. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27024. * @param updatable defines if the mesh must be flagged as updatable
  27025. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27026. * @returns a new Mesh
  27027. */
  27028. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27029. /**
  27030. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27031. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27032. * @param name defines the name of the mesh to create
  27033. * @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
  27034. * @param depth defines the height of extrusion
  27035. * @param scene defines the hosting scene
  27036. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27037. * @param updatable defines if the mesh must be flagged as updatable
  27038. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27039. * @returns a new Mesh
  27040. */
  27041. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27042. /**
  27043. * Creates an extruded shape mesh.
  27044. * 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
  27045. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27046. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27047. * @param name defines the name of the mesh to create
  27048. * @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
  27049. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27050. * @param scale is the value to scale the shape
  27051. * @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
  27052. * @param 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
  27053. * @param scene defines the hosting scene
  27054. * @param updatable defines if the mesh must be flagged as updatable
  27055. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27056. * @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)
  27057. * @returns a new Mesh
  27058. */
  27059. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27060. /**
  27061. * Creates an custom extruded shape mesh.
  27062. * The custom extrusion is a parametric shape.
  27063. * It has no predefined shape. Its final shape will depend on the input parameters.
  27064. * Please consider using the same method from the MeshBuilder class instead
  27065. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27066. * @param name defines the name of the mesh to create
  27067. * @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
  27068. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27069. * @param scaleFunction is a custom Javascript function called on each path point
  27070. * @param rotationFunction is a custom Javascript function called on each path point
  27071. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27072. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27073. * @param 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
  27074. * @param scene defines the hosting scene
  27075. * @param updatable defines if the mesh must be flagged as updatable
  27076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27077. * @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)
  27078. * @returns a new Mesh
  27079. */
  27080. 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;
  27081. /**
  27082. * Creates lathe mesh.
  27083. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27084. * Please consider using the same method from the MeshBuilder class instead
  27085. * @param name defines the name of the mesh to create
  27086. * @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
  27087. * @param radius is the radius value of the lathe
  27088. * @param tessellation is the side number of the lathe.
  27089. * @param scene defines the hosting scene
  27090. * @param updatable defines if the mesh must be flagged as updatable
  27091. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27092. * @returns a new Mesh
  27093. */
  27094. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27095. /**
  27096. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27097. * @param name defines the name of the mesh to create
  27098. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27099. * @param scene defines the hosting scene
  27100. * @param updatable defines if the mesh must be flagged as updatable
  27101. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27102. * @returns a new Mesh
  27103. */
  27104. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27105. /**
  27106. * Creates a ground mesh.
  27107. * Please consider using the same method from the MeshBuilder class instead
  27108. * @param name defines the name of the mesh to create
  27109. * @param width set the width of the ground
  27110. * @param height set the height of the ground
  27111. * @param subdivisions sets the number of subdivisions per side
  27112. * @param scene defines the hosting scene
  27113. * @param updatable defines if the mesh must be flagged as updatable
  27114. * @returns a new Mesh
  27115. */
  27116. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27117. /**
  27118. * Creates a tiled ground mesh.
  27119. * Please consider using the same method from the MeshBuilder class instead
  27120. * @param name defines the name of the mesh to create
  27121. * @param xmin set the ground minimum X coordinate
  27122. * @param zmin set the ground minimum Y coordinate
  27123. * @param xmax set the ground maximum X coordinate
  27124. * @param zmax set the ground maximum Z coordinate
  27125. * @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
  27126. * @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
  27127. * @param scene defines the hosting scene
  27128. * @param updatable defines if the mesh must be flagged as updatable
  27129. * @returns a new Mesh
  27130. */
  27131. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27132. w: number;
  27133. h: number;
  27134. }, precision: {
  27135. w: number;
  27136. h: number;
  27137. }, scene: Scene, updatable?: boolean): Mesh;
  27138. /**
  27139. * Creates a ground mesh from a height map.
  27140. * Please consider using the same method from the MeshBuilder class instead
  27141. * @see http://doc.babylonjs.com/babylon101/height_map
  27142. * @param name defines the name of the mesh to create
  27143. * @param url sets the URL of the height map image resource
  27144. * @param width set the ground width size
  27145. * @param height set the ground height size
  27146. * @param subdivisions sets the number of subdivision per side
  27147. * @param minHeight is the minimum altitude on the ground
  27148. * @param maxHeight is the maximum altitude on the ground
  27149. * @param scene defines the hosting scene
  27150. * @param updatable defines if the mesh must be flagged as updatable
  27151. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27152. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27153. * @returns a new Mesh
  27154. */
  27155. 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;
  27156. /**
  27157. * Creates a tube mesh.
  27158. * The tube is a parametric shape.
  27159. * It has no predefined shape. Its final shape will depend on the input parameters.
  27160. * Please consider using the same method from the MeshBuilder class instead
  27161. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27162. * @param name defines the name of the mesh to create
  27163. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27164. * @param radius sets the tube radius size
  27165. * @param tessellation is the number of sides on the tubular surface
  27166. * @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
  27167. * @param 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
  27168. * @param scene defines the hosting scene
  27169. * @param updatable defines if the mesh must be flagged as updatable
  27170. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27171. * @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)
  27172. * @returns a new Mesh
  27173. */
  27174. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27175. (i: number, distance: number): number;
  27176. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27177. /**
  27178. * Creates a polyhedron mesh.
  27179. * Please consider using the same method from the MeshBuilder class instead.
  27180. * * 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
  27181. * * The parameter `size` (positive float, default 1) sets the polygon size
  27182. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27183. * * 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`
  27184. * * 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
  27185. * * 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)`)
  27186. * * 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 : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  27187. * * 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
  27188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27189. * * 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
  27190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27191. * @param name defines the name of the mesh to create
  27192. * @param options defines the options used to create the mesh
  27193. * @param scene defines the hosting scene
  27194. * @returns a new Mesh
  27195. */
  27196. static CreatePolyhedron(name: string, options: {
  27197. type?: number;
  27198. size?: number;
  27199. sizeX?: number;
  27200. sizeY?: number;
  27201. sizeZ?: number;
  27202. custom?: any;
  27203. faceUV?: Vector4[];
  27204. faceColors?: Color4[];
  27205. updatable?: boolean;
  27206. sideOrientation?: number;
  27207. }, scene: Scene): Mesh;
  27208. /**
  27209. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27210. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27211. * * 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`)
  27212. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27213. * * 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
  27214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27215. * * 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
  27216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27217. * @param name defines the name of the mesh
  27218. * @param options defines the options used to create the mesh
  27219. * @param scene defines the hosting scene
  27220. * @returns a new Mesh
  27221. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27222. */
  27223. static CreateIcoSphere(name: string, options: {
  27224. radius?: number;
  27225. flat?: boolean;
  27226. subdivisions?: number;
  27227. sideOrientation?: number;
  27228. updatable?: boolean;
  27229. }, scene: Scene): Mesh;
  27230. /**
  27231. * Creates a decal mesh.
  27232. * Please consider using the same method from the MeshBuilder class instead.
  27233. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27234. * @param name defines the name of the mesh
  27235. * @param sourceMesh defines the mesh receiving the decal
  27236. * @param position sets the position of the decal in world coordinates
  27237. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27238. * @param size sets the decal scaling
  27239. * @param angle sets the angle to rotate the decal
  27240. * @returns a new Mesh
  27241. */
  27242. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27243. /**
  27244. * Prepare internal position array for software CPU skinning
  27245. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27246. */
  27247. setPositionsForCPUSkinning(): Float32Array;
  27248. /**
  27249. * Prepare internal normal array for software CPU skinning
  27250. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27251. */
  27252. setNormalsForCPUSkinning(): Float32Array;
  27253. /**
  27254. * Updates the vertex buffer by applying transformation from the bones
  27255. * @param skeleton defines the skeleton to apply to current mesh
  27256. * @returns the current mesh
  27257. */
  27258. applySkeleton(skeleton: Skeleton): Mesh;
  27259. /**
  27260. * 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
  27261. * @param meshes defines the list of meshes to scan
  27262. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27263. */
  27264. static MinMax(meshes: AbstractMesh[]): {
  27265. min: Vector3;
  27266. max: Vector3;
  27267. };
  27268. /**
  27269. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27270. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27271. * @returns a vector3
  27272. */
  27273. static Center(meshesOrMinMaxVector: {
  27274. min: Vector3;
  27275. max: Vector3;
  27276. } | AbstractMesh[]): Vector3;
  27277. /**
  27278. * Merge the array of meshes into a single mesh for performance reasons.
  27279. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27280. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27281. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27282. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27283. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27284. * @returns a new mesh
  27285. */
  27286. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27287. /** @hidden */
  27288. addInstance(instance: InstancedMesh): void;
  27289. /** @hidden */
  27290. removeInstance(instance: InstancedMesh): void;
  27291. }
  27292. }
  27293. declare module BABYLON {
  27294. /**
  27295. * Define an interface for all classes that will get and set the data on vertices
  27296. */
  27297. interface IGetSetVerticesData {
  27298. /**
  27299. * Gets a boolean indicating if specific vertex data is present
  27300. * @param kind defines the vertex data kind to use
  27301. * @returns true is data kind is present
  27302. */
  27303. isVerticesDataPresent(kind: string): boolean;
  27304. /**
  27305. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27306. * @param kind defines the data kind (Position, normal, etc...)
  27307. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27308. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27309. * @returns a float array containing vertex data
  27310. */
  27311. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27312. /**
  27313. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27314. * @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.
  27315. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27316. * @returns the indices array or an empty array if the mesh has no geometry
  27317. */
  27318. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27319. /**
  27320. * Set specific vertex data
  27321. * @param kind defines the data kind (Position, normal, etc...)
  27322. * @param data defines the vertex data to use
  27323. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27324. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27325. */
  27326. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27327. /**
  27328. * Update a specific associated vertex buffer
  27329. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27330. * - BABYLON.VertexBuffer.PositionKind
  27331. * - BABYLON.VertexBuffer.UVKind
  27332. * - BABYLON.VertexBuffer.UV2Kind
  27333. * - BABYLON.VertexBuffer.UV3Kind
  27334. * - BABYLON.VertexBuffer.UV4Kind
  27335. * - BABYLON.VertexBuffer.UV5Kind
  27336. * - BABYLON.VertexBuffer.UV6Kind
  27337. * - BABYLON.VertexBuffer.ColorKind
  27338. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27339. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27340. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27341. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27342. * @param data defines the data source
  27343. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27344. * @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)
  27345. */
  27346. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27347. /**
  27348. * Creates a new index buffer
  27349. * @param indices defines the indices to store in the index buffer
  27350. * @param totalVertices defines the total number of vertices (could be null)
  27351. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27352. */
  27353. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27354. }
  27355. /**
  27356. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27357. */
  27358. class VertexData {
  27359. /**
  27360. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27361. */
  27362. positions: Nullable<FloatArray>;
  27363. /**
  27364. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27365. */
  27366. normals: Nullable<FloatArray>;
  27367. /**
  27368. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27369. */
  27370. tangents: Nullable<FloatArray>;
  27371. /**
  27372. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27373. */
  27374. uvs: Nullable<FloatArray>;
  27375. /**
  27376. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27377. */
  27378. uvs2: Nullable<FloatArray>;
  27379. /**
  27380. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27381. */
  27382. uvs3: Nullable<FloatArray>;
  27383. /**
  27384. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27385. */
  27386. uvs4: Nullable<FloatArray>;
  27387. /**
  27388. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27389. */
  27390. uvs5: Nullable<FloatArray>;
  27391. /**
  27392. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27393. */
  27394. uvs6: Nullable<FloatArray>;
  27395. /**
  27396. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27397. */
  27398. colors: Nullable<FloatArray>;
  27399. /**
  27400. * 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).
  27401. */
  27402. matricesIndices: Nullable<FloatArray>;
  27403. /**
  27404. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27405. */
  27406. matricesWeights: Nullable<FloatArray>;
  27407. /**
  27408. * An array extending the number of possible indices
  27409. */
  27410. matricesIndicesExtra: Nullable<FloatArray>;
  27411. /**
  27412. * An array extending the number of possible weights when the number of indices is extended
  27413. */
  27414. matricesWeightsExtra: Nullable<FloatArray>;
  27415. /**
  27416. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27417. */
  27418. indices: Nullable<IndicesArray>;
  27419. /**
  27420. * Uses the passed data array to set the set the values for the specified kind of data
  27421. * @param data a linear array of floating numbers
  27422. * @param kind the type of data that is being set, eg positions, colors etc
  27423. */
  27424. set(data: FloatArray, kind: string): void;
  27425. /**
  27426. * Associates the vertexData to the passed Mesh.
  27427. * Sets it as updatable or not (default `false`)
  27428. * @param mesh the mesh the vertexData is applied to
  27429. * @param updatable when used and having the value true allows new data to update the vertexData
  27430. * @returns the VertexData
  27431. */
  27432. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27433. /**
  27434. * Associates the vertexData to the passed Geometry.
  27435. * Sets it as updatable or not (default `false`)
  27436. * @param geometry the geometry the vertexData is applied to
  27437. * @param updatable when used and having the value true allows new data to update the vertexData
  27438. * @returns VertexData
  27439. */
  27440. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27441. /**
  27442. * Updates the associated mesh
  27443. * @param mesh the mesh to be updated
  27444. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27445. * @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
  27446. * @returns VertexData
  27447. */
  27448. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27449. /**
  27450. * Updates the associated geometry
  27451. * @param geometry the geometry to be updated
  27452. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27453. * @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
  27454. * @returns VertexData.
  27455. */
  27456. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27457. private _applyTo;
  27458. private _update;
  27459. /**
  27460. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27461. * @param matrix the transforming matrix
  27462. * @returns the VertexData
  27463. */
  27464. transform(matrix: Matrix): VertexData;
  27465. /**
  27466. * Merges the passed VertexData into the current one
  27467. * @param other the VertexData to be merged into the current one
  27468. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27469. * @returns the modified VertexData
  27470. */
  27471. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27472. private _mergeElement;
  27473. private _validate;
  27474. /**
  27475. * Serializes the VertexData
  27476. * @returns a serialized object
  27477. */
  27478. serialize(): any;
  27479. /**
  27480. * Extracts the vertexData from a mesh
  27481. * @param mesh the mesh from which to extract the VertexData
  27482. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27483. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27484. * @returns the object VertexData associated to the passed mesh
  27485. */
  27486. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27487. /**
  27488. * Extracts the vertexData from the geometry
  27489. * @param geometry the geometry from which to extract the VertexData
  27490. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27491. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27492. * @returns the object VertexData associated to the passed mesh
  27493. */
  27494. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27495. private static _ExtractFrom;
  27496. /**
  27497. * Creates the VertexData for a Ribbon
  27498. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27499. * * pathArray array of paths, each of which an array of successive Vector3
  27500. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27501. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27502. * * 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
  27503. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27504. * * 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)
  27505. * * 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)
  27506. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27507. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27508. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27509. * @returns the VertexData of the ribbon
  27510. */
  27511. static CreateRibbon(options: {
  27512. pathArray: Vector3[][];
  27513. closeArray?: boolean;
  27514. closePath?: boolean;
  27515. offset?: number;
  27516. sideOrientation?: number;
  27517. frontUVs?: Vector4;
  27518. backUVs?: Vector4;
  27519. invertUV?: boolean;
  27520. uvs?: Vector2[];
  27521. colors?: Color4[];
  27522. }): VertexData;
  27523. /**
  27524. * Creates the VertexData for a box
  27525. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27526. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27527. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27528. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27529. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27530. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27531. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27532. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27533. * * 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)
  27534. * * 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)
  27535. * @returns the VertexData of the box
  27536. */
  27537. static CreateBox(options: {
  27538. size?: number;
  27539. width?: number;
  27540. height?: number;
  27541. depth?: number;
  27542. faceUV?: Vector4[];
  27543. faceColors?: Color4[];
  27544. sideOrientation?: number;
  27545. frontUVs?: Vector4;
  27546. backUVs?: Vector4;
  27547. }): VertexData;
  27548. /**
  27549. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27550. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27551. * * segments sets the number of horizontal strips optional, default 32
  27552. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27553. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27554. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27555. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27556. * * 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
  27557. * * 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
  27558. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27559. * * 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)
  27560. * * 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)
  27561. * @returns the VertexData of the ellipsoid
  27562. */
  27563. static CreateSphere(options: {
  27564. segments?: number;
  27565. diameter?: number;
  27566. diameterX?: number;
  27567. diameterY?: number;
  27568. diameterZ?: number;
  27569. arc?: number;
  27570. slice?: number;
  27571. sideOrientation?: number;
  27572. frontUVs?: Vector4;
  27573. backUVs?: Vector4;
  27574. }): VertexData;
  27575. /**
  27576. * Creates the VertexData for a cylinder, cone or prism
  27577. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27578. * * height sets the height (y direction) of the cylinder, optional, default 2
  27579. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27580. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27581. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27582. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27583. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27584. * * 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
  27585. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27586. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27587. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27588. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27589. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27590. * * 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)
  27591. * * 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)
  27592. * @returns the VertexData of the cylinder, cone or prism
  27593. */
  27594. static CreateCylinder(options: {
  27595. height?: number;
  27596. diameterTop?: number;
  27597. diameterBottom?: number;
  27598. diameter?: number;
  27599. tessellation?: number;
  27600. subdivisions?: number;
  27601. arc?: number;
  27602. faceColors?: Color4[];
  27603. faceUV?: Vector4[];
  27604. hasRings?: boolean;
  27605. enclose?: boolean;
  27606. sideOrientation?: number;
  27607. frontUVs?: Vector4;
  27608. backUVs?: Vector4;
  27609. }): VertexData;
  27610. /**
  27611. * Creates the VertexData for a torus
  27612. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27613. * * diameter the diameter of the torus, optional default 1
  27614. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27615. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27616. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27617. * * 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)
  27618. * * 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)
  27619. * @returns the VertexData of the torus
  27620. */
  27621. static CreateTorus(options: {
  27622. diameter?: number;
  27623. thickness?: number;
  27624. tessellation?: number;
  27625. sideOrientation?: number;
  27626. frontUVs?: Vector4;
  27627. backUVs?: Vector4;
  27628. }): VertexData;
  27629. /**
  27630. * Creates the VertexData of the LineSystem
  27631. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27632. * - lines an array of lines, each line being an array of successive Vector3
  27633. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27634. * @returns the VertexData of the LineSystem
  27635. */
  27636. static CreateLineSystem(options: {
  27637. lines: Vector3[][];
  27638. colors?: Nullable<Color4[][]>;
  27639. }): VertexData;
  27640. /**
  27641. * Create the VertexData for a DashedLines
  27642. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27643. * - points an array successive Vector3
  27644. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27645. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27646. * - dashNb the intended total number of dashes, optional, default 200
  27647. * @returns the VertexData for the DashedLines
  27648. */
  27649. static CreateDashedLines(options: {
  27650. points: Vector3[];
  27651. dashSize?: number;
  27652. gapSize?: number;
  27653. dashNb?: number;
  27654. }): VertexData;
  27655. /**
  27656. * Creates the VertexData for a Ground
  27657. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27658. * - width the width (x direction) of the ground, optional, default 1
  27659. * - height the height (z direction) of the ground, optional, default 1
  27660. * - subdivisions the number of subdivisions per side, optional, default 1
  27661. * @returns the VertexData of the Ground
  27662. */
  27663. static CreateGround(options: {
  27664. width?: number;
  27665. height?: number;
  27666. subdivisions?: number;
  27667. subdivisionsX?: number;
  27668. subdivisionsY?: number;
  27669. }): VertexData;
  27670. /**
  27671. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27672. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27673. * * xmin the ground minimum X coordinate, optional, default -1
  27674. * * zmin the ground minimum Z coordinate, optional, default -1
  27675. * * xmax the ground maximum X coordinate, optional, default 1
  27676. * * zmax the ground maximum Z coordinate, optional, default 1
  27677. * * 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}
  27678. * * 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}
  27679. * @returns the VertexData of the TiledGround
  27680. */
  27681. static CreateTiledGround(options: {
  27682. xmin: number;
  27683. zmin: number;
  27684. xmax: number;
  27685. zmax: number;
  27686. subdivisions?: {
  27687. w: number;
  27688. h: number;
  27689. };
  27690. precision?: {
  27691. w: number;
  27692. h: number;
  27693. };
  27694. }): VertexData;
  27695. /**
  27696. * Creates the VertexData of the Ground designed from a heightmap
  27697. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27698. * * width the width (x direction) of the ground
  27699. * * height the height (z direction) of the ground
  27700. * * subdivisions the number of subdivisions per side
  27701. * * minHeight the minimum altitude on the ground, optional, default 0
  27702. * * maxHeight the maximum altitude on the ground, optional default 1
  27703. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27704. * * buffer the array holding the image color data
  27705. * * bufferWidth the width of image
  27706. * * bufferHeight the height of image
  27707. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27708. * @returns the VertexData of the Ground designed from a heightmap
  27709. */
  27710. static CreateGroundFromHeightMap(options: {
  27711. width: number;
  27712. height: number;
  27713. subdivisions: number;
  27714. minHeight: number;
  27715. maxHeight: number;
  27716. colorFilter: Color3;
  27717. buffer: Uint8Array;
  27718. bufferWidth: number;
  27719. bufferHeight: number;
  27720. alphaFilter: number;
  27721. }): VertexData;
  27722. /**
  27723. * Creates the VertexData for a Plane
  27724. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27725. * * size sets the width and height of the plane to the value of size, optional default 1
  27726. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27727. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27728. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27729. * * 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)
  27730. * * 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)
  27731. * @returns the VertexData of the box
  27732. */
  27733. static CreatePlane(options: {
  27734. size?: number;
  27735. width?: number;
  27736. height?: number;
  27737. sideOrientation?: number;
  27738. frontUVs?: Vector4;
  27739. backUVs?: Vector4;
  27740. }): VertexData;
  27741. /**
  27742. * Creates the VertexData of the Disc or regular Polygon
  27743. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27744. * * radius the radius of the disc, optional default 0.5
  27745. * * tessellation the number of polygon sides, optional, default 64
  27746. * * 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
  27747. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27748. * * 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)
  27749. * * 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)
  27750. * @returns the VertexData of the box
  27751. */
  27752. static CreateDisc(options: {
  27753. radius?: number;
  27754. tessellation?: number;
  27755. arc?: number;
  27756. sideOrientation?: number;
  27757. frontUVs?: Vector4;
  27758. backUVs?: Vector4;
  27759. }): VertexData;
  27760. /**
  27761. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27762. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27763. * @param polygon a mesh built from polygonTriangulation.build()
  27764. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27765. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27766. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27767. * @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)
  27768. * @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)
  27769. * @returns the VertexData of the Polygon
  27770. */
  27771. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  27772. /**
  27773. * Creates the VertexData of the IcoSphere
  27774. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27775. * * radius the radius of the IcoSphere, optional default 1
  27776. * * radiusX allows stretching in the x direction, optional, default radius
  27777. * * radiusY allows stretching in the y direction, optional, default radius
  27778. * * radiusZ allows stretching in the z direction, optional, default radius
  27779. * * flat when true creates a flat shaded mesh, optional, default true
  27780. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27781. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27782. * * 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)
  27783. * * 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)
  27784. * @returns the VertexData of the IcoSphere
  27785. */
  27786. static CreateIcoSphere(options: {
  27787. radius?: number;
  27788. radiusX?: number;
  27789. radiusY?: number;
  27790. radiusZ?: number;
  27791. flat?: boolean;
  27792. subdivisions?: number;
  27793. sideOrientation?: number;
  27794. frontUVs?: Vector4;
  27795. backUVs?: Vector4;
  27796. }): VertexData;
  27797. /**
  27798. * Creates the VertexData for a Polyhedron
  27799. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27800. * * type provided types are:
  27801. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27802. * * 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)
  27803. * * size the size of the IcoSphere, optional default 1
  27804. * * sizeX allows stretching in the x direction, optional, default size
  27805. * * sizeY allows stretching in the y direction, optional, default size
  27806. * * sizeZ allows stretching in the z direction, optional, default size
  27807. * * 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
  27808. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27809. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27810. * * flat when true creates a flat shaded mesh, optional, default true
  27811. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27812. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27813. * * 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)
  27814. * * 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)
  27815. * @returns the VertexData of the Polyhedron
  27816. */
  27817. static CreatePolyhedron(options: {
  27818. type?: number;
  27819. size?: number;
  27820. sizeX?: number;
  27821. sizeY?: number;
  27822. sizeZ?: number;
  27823. custom?: any;
  27824. faceUV?: Vector4[];
  27825. faceColors?: Color4[];
  27826. flat?: boolean;
  27827. sideOrientation?: number;
  27828. frontUVs?: Vector4;
  27829. backUVs?: Vector4;
  27830. }): VertexData;
  27831. /**
  27832. * Creates the VertexData for a TorusKnot
  27833. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27834. * * radius the radius of the torus knot, optional, default 2
  27835. * * tube the thickness of the tube, optional, default 0.5
  27836. * * radialSegments the number of sides on each tube segments, optional, default 32
  27837. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27838. * * p the number of windings around the z axis, optional, default 2
  27839. * * q the number of windings around the x axis, optional, default 3
  27840. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27841. * * 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)
  27842. * * 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)
  27843. * @returns the VertexData of the Torus Knot
  27844. */
  27845. static CreateTorusKnot(options: {
  27846. radius?: number;
  27847. tube?: number;
  27848. radialSegments?: number;
  27849. tubularSegments?: number;
  27850. p?: number;
  27851. q?: number;
  27852. sideOrientation?: number;
  27853. frontUVs?: Vector4;
  27854. backUVs?: Vector4;
  27855. }): VertexData;
  27856. /**
  27857. * Compute normals for given positions and indices
  27858. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27859. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27860. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27861. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27862. * * facetNormals : optional array of facet normals (vector3)
  27863. * * facetPositions : optional array of facet positions (vector3)
  27864. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27865. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27866. * * bInfo : optional bounding info, required for facetPartitioning computation
  27867. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27868. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27869. * * useRightHandedSystem: optional boolean to for right handed system computation
  27870. * * depthSort : optional boolean to enable the facet depth sort computation
  27871. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27872. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27873. */
  27874. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27875. facetNormals?: any;
  27876. facetPositions?: any;
  27877. facetPartitioning?: any;
  27878. ratio?: number;
  27879. bInfo?: any;
  27880. bbSize?: Vector3;
  27881. subDiv?: any;
  27882. useRightHandedSystem?: boolean;
  27883. depthSort?: boolean;
  27884. distanceTo?: Vector3;
  27885. depthSortedFacets?: any;
  27886. }): void;
  27887. private static _ComputeSides;
  27888. /**
  27889. * Applies VertexData created from the imported parameters to the geometry
  27890. * @param parsedVertexData the parsed data from an imported file
  27891. * @param geometry the geometry to apply the VertexData to
  27892. */
  27893. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27894. }
  27895. }
  27896. declare module BABYLON {
  27897. /**
  27898. * Class containing static functions to help procedurally build meshes
  27899. */
  27900. class MeshBuilder {
  27901. private static updateSideOrientation;
  27902. /**
  27903. * Creates a box mesh
  27904. * * The parameter `size` sets the size (float) of each box side (default 1)
  27905. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  27906. * * 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)
  27907. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  27908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27909. * * 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
  27910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27911. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  27912. * @param name defines the name of the mesh
  27913. * @param options defines the options used to create the mesh
  27914. * @param scene defines the hosting scene
  27915. * @returns the box mesh
  27916. */
  27917. static CreateBox(name: string, options: {
  27918. size?: number;
  27919. width?: number;
  27920. height?: number;
  27921. depth?: number;
  27922. faceUV?: Vector4[];
  27923. faceColors?: Color4[];
  27924. sideOrientation?: number;
  27925. frontUVs?: Vector4;
  27926. backUVs?: Vector4;
  27927. updatable?: boolean;
  27928. }, scene?: Nullable<Scene>): Mesh;
  27929. /**
  27930. * Creates a sphere mesh
  27931. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  27932. * * 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`)
  27933. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  27934. * * 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
  27935. * * 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)
  27936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27937. * * 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
  27938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27939. * @param name defines the name of the mesh
  27940. * @param options defines the options used to create the mesh
  27941. * @param scene defines the hosting scene
  27942. * @returns the sphere mesh
  27943. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  27944. */
  27945. static CreateSphere(name: string, options: {
  27946. segments?: number;
  27947. diameter?: number;
  27948. diameterX?: number;
  27949. diameterY?: number;
  27950. diameterZ?: number;
  27951. arc?: number;
  27952. slice?: number;
  27953. sideOrientation?: number;
  27954. frontUVs?: Vector4;
  27955. backUVs?: Vector4;
  27956. updatable?: boolean;
  27957. }, scene: any): Mesh;
  27958. /**
  27959. * Creates a plane polygonal mesh. By default, this is a disc
  27960. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  27961. * * 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
  27962. * * 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
  27963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27964. * * 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
  27965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27966. * @param name defines the name of the mesh
  27967. * @param options defines the options used to create the mesh
  27968. * @param scene defines the hosting scene
  27969. * @returns the plane polygonal mesh
  27970. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  27971. */
  27972. static CreateDisc(name: string, options: {
  27973. radius?: number;
  27974. tessellation?: number;
  27975. arc?: number;
  27976. updatable?: boolean;
  27977. sideOrientation?: number;
  27978. frontUVs?: Vector4;
  27979. backUVs?: Vector4;
  27980. }, scene?: Nullable<Scene>): Mesh;
  27981. /**
  27982. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27983. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27984. * * 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`)
  27985. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27986. * * 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
  27987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27988. * * 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
  27989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27990. * @param name defines the name of the mesh
  27991. * @param options defines the options used to create the mesh
  27992. * @param scene defines the hosting scene
  27993. * @returns the icosahedron mesh
  27994. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27995. */
  27996. static CreateIcoSphere(name: string, options: {
  27997. radius?: number;
  27998. radiusX?: number;
  27999. radiusY?: number;
  28000. radiusZ?: number;
  28001. flat?: boolean;
  28002. subdivisions?: number;
  28003. sideOrientation?: number;
  28004. frontUVs?: Vector4;
  28005. backUVs?: Vector4;
  28006. updatable?: boolean;
  28007. }, scene: Scene): Mesh;
  28008. /**
  28009. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28010. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28011. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28012. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28013. * * 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
  28014. * * 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
  28015. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#ribbon
  28016. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28017. * * 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
  28018. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28019. * * 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
  28020. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28021. * * 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
  28022. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28024. * @param name defines the name of the mesh
  28025. * @param options defines the options used to create the mesh
  28026. * @param scene defines the hosting scene
  28027. * @returns the ribbon mesh
  28028. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  28029. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28030. */
  28031. static CreateRibbon(name: string, options: {
  28032. pathArray: Vector3[][];
  28033. closeArray?: boolean;
  28034. closePath?: boolean;
  28035. offset?: number;
  28036. updatable?: boolean;
  28037. sideOrientation?: number;
  28038. frontUVs?: Vector4;
  28039. backUVs?: Vector4;
  28040. instance?: Mesh;
  28041. invertUV?: boolean;
  28042. uvs?: Vector2[];
  28043. colors?: Color4[];
  28044. }, scene?: Nullable<Scene>): Mesh;
  28045. /**
  28046. * Creates a cylinder or a cone mesh
  28047. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28048. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28049. * * 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.
  28050. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28051. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28052. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28053. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28054. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28055. * * 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).
  28056. * * 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
  28057. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28058. * * 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
  28059. * * 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.
  28060. * * If `enclose` is false, a ring surface is one element.
  28061. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28062. * * Example how to set colors and textures on a sliced cylinder : http://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  28063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28064. * * 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
  28065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28066. * @param name defines the name of the mesh
  28067. * @param options defines the options used to create the mesh
  28068. * @param scene defines the hosting scene
  28069. * @returns the cylinder mesh
  28070. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  28071. */
  28072. static CreateCylinder(name: string, options: {
  28073. height?: number;
  28074. diameterTop?: number;
  28075. diameterBottom?: number;
  28076. diameter?: number;
  28077. tessellation?: number;
  28078. subdivisions?: number;
  28079. arc?: number;
  28080. faceColors?: Color4[];
  28081. faceUV?: Vector4[];
  28082. updatable?: boolean;
  28083. hasRings?: boolean;
  28084. enclose?: boolean;
  28085. sideOrientation?: number;
  28086. frontUVs?: Vector4;
  28087. backUVs?: Vector4;
  28088. }, scene: any): Mesh;
  28089. /**
  28090. * Creates a torus mesh
  28091. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28092. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28093. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28095. * * 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
  28096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28097. * @param name defines the name of the mesh
  28098. * @param options defines the options used to create the mesh
  28099. * @param scene defines the hosting scene
  28100. * @returns the torus mesh
  28101. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  28102. */
  28103. static CreateTorus(name: string, options: {
  28104. diameter?: number;
  28105. thickness?: number;
  28106. tessellation?: number;
  28107. updatable?: boolean;
  28108. sideOrientation?: number;
  28109. frontUVs?: Vector4;
  28110. backUVs?: Vector4;
  28111. }, scene: any): Mesh;
  28112. /**
  28113. * Creates a torus knot mesh
  28114. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28115. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28116. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28117. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28119. * * 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
  28120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28121. * @param name defines the name of the mesh
  28122. * @param options defines the options used to create the mesh
  28123. * @param scene defines the hosting scene
  28124. * @returns the torus knot mesh
  28125. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  28126. */
  28127. static CreateTorusKnot(name: string, options: {
  28128. radius?: number;
  28129. tube?: number;
  28130. radialSegments?: number;
  28131. tubularSegments?: number;
  28132. p?: number;
  28133. q?: number;
  28134. updatable?: boolean;
  28135. sideOrientation?: number;
  28136. frontUVs?: Vector4;
  28137. backUVs?: Vector4;
  28138. }, scene: any): Mesh;
  28139. /**
  28140. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28141. * * 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
  28142. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28143. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28144. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28145. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28146. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28147. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  28148. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28150. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28151. * @param name defines the name of the new line system
  28152. * @param options defines the options used to create the line system
  28153. * @param scene defines the hosting scene
  28154. * @returns a new line system mesh
  28155. */
  28156. static CreateLineSystem(name: string, options: {
  28157. lines: Vector3[][];
  28158. updatable?: boolean;
  28159. instance?: Nullable<LinesMesh>;
  28160. colors?: Nullable<Color4[][]>;
  28161. useVertexAlpha?: boolean;
  28162. }, scene: Nullable<Scene>): LinesMesh;
  28163. /**
  28164. * Creates a line mesh
  28165. * 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
  28166. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28167. * * The parameter `points` is an array successive Vector3
  28168. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  28169. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28170. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28171. * * When updating an instance, remember that only point positions can change, not the number of points
  28172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28173. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  28174. * @param name defines the name of the new line system
  28175. * @param options defines the options used to create the line system
  28176. * @param scene defines the hosting scene
  28177. * @returns a new line mesh
  28178. */
  28179. static CreateLines(name: string, options: {
  28180. points: Vector3[];
  28181. updatable?: boolean;
  28182. instance?: Nullable<LinesMesh>;
  28183. colors?: Color4[];
  28184. useVertexAlpha?: boolean;
  28185. }, scene?: Nullable<Scene>): LinesMesh;
  28186. /**
  28187. * Creates a dashed line mesh
  28188. * * 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
  28189. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28190. * * The parameter `points` is an array successive Vector3
  28191. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28192. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28193. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28194. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  28195. * * When updating an instance, remember that only point positions can change, not the number of points
  28196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28197. * @param name defines the name of the mesh
  28198. * @param options defines the options used to create the mesh
  28199. * @param scene defines the hosting scene
  28200. * @returns the dashed line mesh
  28201. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28202. */
  28203. static CreateDashedLines(name: string, options: {
  28204. points: Vector3[];
  28205. dashSize?: number;
  28206. gapSize?: number;
  28207. dashNb?: number;
  28208. updatable?: boolean;
  28209. instance?: LinesMesh;
  28210. }, scene?: Nullable<Scene>): LinesMesh;
  28211. /**
  28212. * 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.
  28213. * * 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.
  28214. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28215. * * 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.
  28216. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28217. * * 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
  28218. * * The optional parameter `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/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  28219. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28221. * * 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
  28222. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28224. * @param name defines the name of the mesh
  28225. * @param options defines the options used to create the mesh
  28226. * @param scene defines the hosting scene
  28227. * @returns the extruded shape mesh
  28228. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28229. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28230. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28231. */
  28232. static ExtrudeShape(name: string, options: {
  28233. shape: Vector3[];
  28234. path: Vector3[];
  28235. scale?: number;
  28236. rotation?: number;
  28237. cap?: number;
  28238. updatable?: boolean;
  28239. sideOrientation?: number;
  28240. frontUVs?: Vector4;
  28241. backUVs?: Vector4;
  28242. instance?: Mesh;
  28243. invertUV?: boolean;
  28244. }, scene?: Nullable<Scene>): Mesh;
  28245. /**
  28246. * Creates an custom extruded shape mesh.
  28247. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28248. * * 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.
  28249. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28250. * * 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
  28251. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28252. * * 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
  28253. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28254. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28255. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28256. * * 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
  28257. * * The optional parameter `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/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  28258. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28260. * * 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
  28261. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28263. * @param name defines the name of the mesh
  28264. * @param options defines the options used to create the mesh
  28265. * @param scene defines the hosting scene
  28266. * @returns the custom extruded shape mesh
  28267. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28268. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28269. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28270. */
  28271. static ExtrudeShapeCustom(name: string, options: {
  28272. shape: Vector3[];
  28273. path: Vector3[];
  28274. scaleFunction?: any;
  28275. rotationFunction?: any;
  28276. ribbonCloseArray?: boolean;
  28277. ribbonClosePath?: boolean;
  28278. cap?: number;
  28279. updatable?: boolean;
  28280. sideOrientation?: number;
  28281. frontUVs?: Vector4;
  28282. backUVs?: Vector4;
  28283. instance?: Mesh;
  28284. invertUV?: boolean;
  28285. }, scene: Scene): Mesh;
  28286. /**
  28287. * Creates lathe mesh.
  28288. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28289. * * 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
  28290. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28291. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28292. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28293. * * 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
  28294. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28295. * * 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
  28296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28297. * * 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
  28298. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28300. * @param name defines the name of the mesh
  28301. * @param options defines the options used to create the mesh
  28302. * @param scene defines the hosting scene
  28303. * @returns the lathe mesh
  28304. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28305. */
  28306. static CreateLathe(name: string, options: {
  28307. shape: Vector3[];
  28308. radius?: number;
  28309. tessellation?: number;
  28310. clip?: number;
  28311. arc?: number;
  28312. closed?: boolean;
  28313. updatable?: boolean;
  28314. sideOrientation?: number;
  28315. frontUVs?: Vector4;
  28316. backUVs?: Vector4;
  28317. cap?: number;
  28318. invertUV?: boolean;
  28319. }, scene: Scene): Mesh;
  28320. /**
  28321. * Creates a plane mesh
  28322. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28323. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28324. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28326. * * 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
  28327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28328. * @param name defines the name of the mesh
  28329. * @param options defines the options used to create the mesh
  28330. * @param scene defines the hosting scene
  28331. * @returns the plane mesh
  28332. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28333. */
  28334. static CreatePlane(name: string, options: {
  28335. size?: number;
  28336. width?: number;
  28337. height?: number;
  28338. sideOrientation?: number;
  28339. frontUVs?: Vector4;
  28340. backUVs?: Vector4;
  28341. updatable?: boolean;
  28342. sourcePlane?: Plane;
  28343. }, scene: Scene): Mesh;
  28344. /**
  28345. * Creates a ground mesh
  28346. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28347. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28349. * @param name defines the name of the mesh
  28350. * @param options defines the options used to create the mesh
  28351. * @param scene defines the hosting scene
  28352. * @returns the ground mesh
  28353. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28354. */
  28355. static CreateGround(name: string, options: {
  28356. width?: number;
  28357. height?: number;
  28358. subdivisions?: number;
  28359. subdivisionsX?: number;
  28360. subdivisionsY?: number;
  28361. updatable?: boolean;
  28362. }, scene: any): Mesh;
  28363. /**
  28364. * Creates a tiled ground mesh
  28365. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28366. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28367. * * 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
  28368. * * 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
  28369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28370. * @param name defines the name of the mesh
  28371. * @param options defines the options used to create the mesh
  28372. * @param scene defines the hosting scene
  28373. * @returns the tiled ground mesh
  28374. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  28375. */
  28376. static CreateTiledGround(name: string, options: {
  28377. xmin: number;
  28378. zmin: number;
  28379. xmax: number;
  28380. zmax: number;
  28381. subdivisions?: {
  28382. w: number;
  28383. h: number;
  28384. };
  28385. precision?: {
  28386. w: number;
  28387. h: number;
  28388. };
  28389. updatable?: boolean;
  28390. }, scene: Scene): Mesh;
  28391. /**
  28392. * Creates a ground mesh from a height map
  28393. * * The parameter `url` sets the URL of the height map image resource.
  28394. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28395. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28396. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28397. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28398. * * 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.
  28399. * * 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).
  28400. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28402. * @param name defines the name of the mesh
  28403. * @param url defines the url to the height map
  28404. * @param options defines the options used to create the mesh
  28405. * @param scene defines the hosting scene
  28406. * @returns the ground mesh
  28407. * @see http://doc.babylonjs.com/babylon101/height_map
  28408. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  28409. */
  28410. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28411. width?: number;
  28412. height?: number;
  28413. subdivisions?: number;
  28414. minHeight?: number;
  28415. maxHeight?: number;
  28416. colorFilter?: Color3;
  28417. alphaFilter?: number;
  28418. updatable?: boolean;
  28419. onReady?: (mesh: GroundMesh) => void;
  28420. }, scene: Scene): GroundMesh;
  28421. /**
  28422. * Creates a polygon mesh
  28423. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28424. * * 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
  28425. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28427. * * 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)
  28428. * * Remember you can only change the shape positions, not their number when updating a polygon
  28429. * @param name defines the name of the mesh
  28430. * @param options defines the options used to create the mesh
  28431. * @param scene defines the hosting scene
  28432. * @returns the polygon mesh
  28433. */
  28434. static CreatePolygon(name: string, options: {
  28435. shape: Vector3[];
  28436. holes?: Vector3[][];
  28437. depth?: number;
  28438. faceUV?: Vector4[];
  28439. faceColors?: Color4[];
  28440. updatable?: boolean;
  28441. sideOrientation?: number;
  28442. frontUVs?: Vector4;
  28443. backUVs?: Vector4;
  28444. }, scene: Scene): Mesh;
  28445. /**
  28446. * Creates an extruded polygon mesh, with depth in the Y direction.
  28447. * * 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)
  28448. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  28449. * @param name defines the name of the mesh
  28450. * @param options defines the options used to create the mesh
  28451. * @param scene defines the hosting scene
  28452. * @returns the polygon mesh
  28453. */
  28454. static ExtrudePolygon(name: string, options: {
  28455. shape: Vector3[];
  28456. holes?: Vector3[][];
  28457. depth?: number;
  28458. faceUV?: Vector4[];
  28459. faceColors?: Color4[];
  28460. updatable?: boolean;
  28461. sideOrientation?: number;
  28462. frontUVs?: Vector4;
  28463. backUVs?: Vector4;
  28464. }, scene: Scene): Mesh;
  28465. /**
  28466. * Creates a tube mesh.
  28467. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28468. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28469. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28470. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28471. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28472. * * 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)
  28473. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28474. * * 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
  28475. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#tube
  28476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28477. * * 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
  28478. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28480. * @param name defines the name of the mesh
  28481. * @param options defines the options used to create the mesh
  28482. * @param scene defines the hosting scene
  28483. * @returns the tube mesh
  28484. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28485. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  28486. */
  28487. static CreateTube(name: string, options: {
  28488. path: Vector3[];
  28489. radius?: number;
  28490. tessellation?: number;
  28491. radiusFunction?: {
  28492. (i: number, distance: number): number;
  28493. };
  28494. cap?: number;
  28495. arc?: number;
  28496. updatable?: boolean;
  28497. sideOrientation?: number;
  28498. frontUVs?: Vector4;
  28499. backUVs?: Vector4;
  28500. instance?: Mesh;
  28501. invertUV?: boolean;
  28502. }, scene: Scene): Mesh;
  28503. /**
  28504. * Creates a polyhedron mesh
  28505. * * 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
  28506. * * The parameter `size` (positive float, default 1) sets the polygon size
  28507. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28508. * * 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`
  28509. * * 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
  28510. * * 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)`)
  28511. * * 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 : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  28512. * * 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
  28513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28514. * * 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
  28515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28516. * @param name defines the name of the mesh
  28517. * @param options defines the options used to create the mesh
  28518. * @param scene defines the hosting scene
  28519. * @returns the polyhedron mesh
  28520. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  28521. */
  28522. static CreatePolyhedron(name: string, options: {
  28523. type?: number;
  28524. size?: number;
  28525. sizeX?: number;
  28526. sizeY?: number;
  28527. sizeZ?: number;
  28528. custom?: any;
  28529. faceUV?: Vector4[];
  28530. faceColors?: Color4[];
  28531. flat?: boolean;
  28532. updatable?: boolean;
  28533. sideOrientation?: number;
  28534. frontUVs?: Vector4;
  28535. backUVs?: Vector4;
  28536. }, scene: Scene): Mesh;
  28537. /**
  28538. * Creates a decal mesh.
  28539. * 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
  28540. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28541. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28542. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28543. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28544. * @param name defines the name of the mesh
  28545. * @param sourceMesh defines the mesh where the decal must be applied
  28546. * @param options defines the options used to create the mesh
  28547. * @param scene defines the hosting scene
  28548. * @returns the decal mesh
  28549. * @see http://doc.babylonjs.com/how_to/decals
  28550. */
  28551. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28552. position?: Vector3;
  28553. normal?: Vector3;
  28554. size?: Vector3;
  28555. angle?: number;
  28556. }): Mesh;
  28557. private static _ExtrudeShapeGeneric;
  28558. }
  28559. }
  28560. declare module BABYLON {
  28561. /**
  28562. * Class used to represent a specific level of detail of a mesh
  28563. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28564. */
  28565. class MeshLODLevel {
  28566. /** Defines the distance where this level should star being displayed */
  28567. distance: number;
  28568. /** Defines the mesh to use to render this level */
  28569. mesh: Nullable<Mesh>;
  28570. /**
  28571. * Creates a new LOD level
  28572. * @param distance defines the distance where this level should star being displayed
  28573. * @param mesh defines the mesh to use to render this level
  28574. */
  28575. constructor(
  28576. /** Defines the distance where this level should star being displayed */
  28577. distance: number,
  28578. /** Defines the mesh to use to render this level */
  28579. mesh: Nullable<Mesh>);
  28580. }
  28581. }
  28582. declare module BABYLON {
  28583. /**
  28584. * A simplifier interface for future simplification implementations
  28585. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28586. */
  28587. interface ISimplifier {
  28588. /**
  28589. * Simplification of a given mesh according to the given settings.
  28590. * Since this requires computation, it is assumed that the function runs async.
  28591. * @param settings The settings of the simplification, including quality and distance
  28592. * @param successCallback A callback that will be called after the mesh was simplified.
  28593. * @param errorCallback in case of an error, this callback will be called. optional.
  28594. */
  28595. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28596. }
  28597. /**
  28598. * Expected simplification settings.
  28599. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28600. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28601. */
  28602. interface ISimplificationSettings {
  28603. /**
  28604. * Gets or sets the expected quality
  28605. */
  28606. quality: number;
  28607. /**
  28608. * Gets or sets the distance when this optimized version should be used
  28609. */
  28610. distance: number;
  28611. /**
  28612. * Gets an already optimized mesh
  28613. */
  28614. optimizeMesh?: boolean;
  28615. }
  28616. /**
  28617. * Class used to specify simplification options
  28618. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28619. */
  28620. class SimplificationSettings implements ISimplificationSettings {
  28621. /** expected quality */
  28622. quality: number;
  28623. /** distance when this optimized version should be used */
  28624. distance: number;
  28625. /** already optimized mesh */
  28626. optimizeMesh?: boolean | undefined;
  28627. /**
  28628. * Creates a SimplificationSettings
  28629. * @param quality expected quality
  28630. * @param distance distance when this optimized version should be used
  28631. * @param optimizeMesh already optimized mesh
  28632. */
  28633. constructor(
  28634. /** expected quality */
  28635. quality: number,
  28636. /** distance when this optimized version should be used */
  28637. distance: number,
  28638. /** already optimized mesh */
  28639. optimizeMesh?: boolean | undefined);
  28640. }
  28641. /**
  28642. * Interface used to define a simplification task
  28643. */
  28644. interface ISimplificationTask {
  28645. /**
  28646. * Array of settings
  28647. */
  28648. settings: Array<ISimplificationSettings>;
  28649. /**
  28650. * Simplification type
  28651. */
  28652. simplificationType: SimplificationType;
  28653. /**
  28654. * Mesh to simplify
  28655. */
  28656. mesh: Mesh;
  28657. /**
  28658. * Callback called on success
  28659. */
  28660. successCallback?: () => void;
  28661. /**
  28662. * Defines if parallel processing can be used
  28663. */
  28664. parallelProcessing: boolean;
  28665. }
  28666. /**
  28667. * Queue used to order the simplification tasks
  28668. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28669. */
  28670. class SimplificationQueue {
  28671. private _simplificationArray;
  28672. /**
  28673. * Gets a boolean indicating that the process is still running
  28674. */
  28675. running: boolean;
  28676. /**
  28677. * Creates a new queue
  28678. */
  28679. constructor();
  28680. /**
  28681. * Adds a new simplification task
  28682. * @param task defines a task to add
  28683. */
  28684. addTask(task: ISimplificationTask): void;
  28685. /**
  28686. * Execute next task
  28687. */
  28688. executeNext(): void;
  28689. /**
  28690. * Execute a simplification task
  28691. * @param task defines the task to run
  28692. */
  28693. runSimplification(task: ISimplificationTask): void;
  28694. private getSimplifier;
  28695. }
  28696. /**
  28697. * The implemented types of simplification
  28698. * At the moment only Quadratic Error Decimation is implemented
  28699. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28700. */
  28701. enum SimplificationType {
  28702. /** Quadratic error decimation */
  28703. QUADRATIC = 0
  28704. }
  28705. }
  28706. declare module BABYLON {
  28707. interface Scene {
  28708. /** @hidden (Backing field) */
  28709. _simplificationQueue: SimplificationQueue;
  28710. /**
  28711. * Gets or sets the simplification queue attached to the scene
  28712. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28713. */
  28714. simplificationQueue: SimplificationQueue;
  28715. }
  28716. interface Mesh {
  28717. /**
  28718. * Simplify the mesh according to the given array of settings.
  28719. * Function will return immediately and will simplify async
  28720. * @param settings a collection of simplification settings
  28721. * @param parallelProcessing should all levels calculate parallel or one after the other
  28722. * @param simplificationType the type of simplification to run
  28723. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  28724. * @returns the current mesh
  28725. */
  28726. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  28727. }
  28728. /**
  28729. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  28730. * created in a scene
  28731. */
  28732. class SimplicationQueueSceneComponent implements ISceneComponent {
  28733. /**
  28734. * The component name helpfull to identify the component in the list of scene components.
  28735. */
  28736. readonly name: string;
  28737. /**
  28738. * The scene the component belongs to.
  28739. */
  28740. scene: Scene;
  28741. /**
  28742. * Creates a new instance of the component for the given scene
  28743. * @param scene Defines the scene to register the component in
  28744. */
  28745. constructor(scene: Scene);
  28746. /**
  28747. * Registers the component in a given scene
  28748. */
  28749. register(): void;
  28750. /**
  28751. * Rebuilds the elements related to this component in case of
  28752. * context lost for instance.
  28753. */
  28754. rebuild(): void;
  28755. /**
  28756. * Disposes the component and the associated ressources
  28757. */
  28758. dispose(): void;
  28759. private _beforeCameraUpdate;
  28760. }
  28761. }
  28762. declare module BABYLON {
  28763. /**
  28764. * Polygon
  28765. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28766. */
  28767. class Polygon {
  28768. /**
  28769. * Creates a rectangle
  28770. * @param xmin bottom X coord
  28771. * @param ymin bottom Y coord
  28772. * @param xmax top X coord
  28773. * @param ymax top Y coord
  28774. * @returns points that make the resulting rectation
  28775. */
  28776. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  28777. /**
  28778. * Creates a circle
  28779. * @param radius radius of circle
  28780. * @param cx scale in x
  28781. * @param cy scale in y
  28782. * @param numberOfSides number of sides that make up the circle
  28783. * @returns points that make the resulting circle
  28784. */
  28785. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  28786. /**
  28787. * Creates a polygon from input string
  28788. * @param input Input polygon data
  28789. * @returns the parsed points
  28790. */
  28791. static Parse(input: string): Vector2[];
  28792. /**
  28793. * Starts building a polygon from x and y coordinates
  28794. * @param x x coordinate
  28795. * @param y y coordinate
  28796. * @returns the started path2
  28797. */
  28798. static StartingAt(x: number, y: number): Path2;
  28799. }
  28800. /**
  28801. * Builds a polygon
  28802. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  28803. */
  28804. class PolygonMeshBuilder {
  28805. private _points;
  28806. private _outlinepoints;
  28807. private _holes;
  28808. private _name;
  28809. private _scene;
  28810. private _epoints;
  28811. private _eholes;
  28812. private _addToepoint;
  28813. /**
  28814. * Creates a PolygonMeshBuilder
  28815. * @param name name of the builder
  28816. * @param contours Path of the polygon
  28817. * @param scene scene to add to
  28818. */
  28819. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  28820. /**
  28821. * Adds a whole within the polygon
  28822. * @param hole Array of points defining the hole
  28823. * @returns this
  28824. */
  28825. addHole(hole: Vector2[]): PolygonMeshBuilder;
  28826. /**
  28827. * Creates the polygon
  28828. * @param updatable If the mesh should be updatable
  28829. * @param depth The depth of the mesh created
  28830. * @returns the created mesh
  28831. */
  28832. build(updatable?: boolean, depth?: number): Mesh;
  28833. /**
  28834. * Adds a side to the polygon
  28835. * @param positions points that make the polygon
  28836. * @param normals normals of the polygon
  28837. * @param uvs uvs of the polygon
  28838. * @param indices indices of the polygon
  28839. * @param bounds bounds of the polygon
  28840. * @param points points of the polygon
  28841. * @param depth depth of the polygon
  28842. * @param flip flip of the polygon
  28843. */
  28844. private addSide;
  28845. }
  28846. }
  28847. declare module BABYLON {
  28848. /**
  28849. * Base class for submeshes
  28850. */
  28851. class BaseSubMesh {
  28852. /** @hidden */
  28853. _materialDefines: Nullable<MaterialDefines>;
  28854. /** @hidden */
  28855. _materialEffect: Nullable<Effect>;
  28856. /**
  28857. * Gets associated effect
  28858. */
  28859. readonly effect: Nullable<Effect>;
  28860. /**
  28861. * Sets associated effect (effect used to render this submesh)
  28862. * @param effect defines the effect to associate with
  28863. * @param defines defines the set of defines used to compile this effect
  28864. */
  28865. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  28866. }
  28867. /**
  28868. * Defines a subdivision inside a mesh
  28869. */
  28870. class SubMesh extends BaseSubMesh implements ICullable {
  28871. /** the material index to use */
  28872. materialIndex: number;
  28873. /** vertex index start */
  28874. verticesStart: number;
  28875. /** vertices count */
  28876. verticesCount: number;
  28877. /** index start */
  28878. indexStart: number;
  28879. /** indices count */
  28880. indexCount: number;
  28881. /** @hidden */
  28882. _linesIndexCount: number;
  28883. private _mesh;
  28884. private _renderingMesh;
  28885. private _boundingInfo;
  28886. private _linesIndexBuffer;
  28887. /** @hidden */
  28888. _lastColliderWorldVertices: Nullable<Vector3[]>;
  28889. /** @hidden */
  28890. _trianglePlanes: Plane[];
  28891. /** @hidden */
  28892. _lastColliderTransformMatrix: Matrix;
  28893. /** @hidden */
  28894. _renderId: number;
  28895. /** @hidden */
  28896. _alphaIndex: number;
  28897. /** @hidden */
  28898. _distanceToCamera: number;
  28899. /** @hidden */
  28900. _id: number;
  28901. private _currentMaterial;
  28902. /**
  28903. * Add a new submesh to a mesh
  28904. * @param materialIndex defines the material index to use
  28905. * @param verticesStart defines vertex index start
  28906. * @param verticesCount defines vertices count
  28907. * @param indexStart defines index start
  28908. * @param indexCount defines indices count
  28909. * @param mesh defines the parent mesh
  28910. * @param renderingMesh defines an optional rendering mesh
  28911. * @param createBoundingBox defines if bounding box should be created for this submesh
  28912. * @returns the new submesh
  28913. */
  28914. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  28915. /**
  28916. * Creates a new submesh
  28917. * @param materialIndex defines the material index to use
  28918. * @param verticesStart defines vertex index start
  28919. * @param verticesCount defines vertices count
  28920. * @param indexStart defines index start
  28921. * @param indexCount defines indices count
  28922. * @param mesh defines the parent mesh
  28923. * @param renderingMesh defines an optional rendering mesh
  28924. * @param createBoundingBox defines if bounding box should be created for this submesh
  28925. */
  28926. constructor(
  28927. /** the material index to use */
  28928. materialIndex: number,
  28929. /** vertex index start */
  28930. verticesStart: number,
  28931. /** vertices count */
  28932. verticesCount: number,
  28933. /** index start */
  28934. indexStart: number,
  28935. /** indices count */
  28936. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  28937. /**
  28938. * Returns true if this submesh covers the entire parent mesh
  28939. * @ignorenaming
  28940. */
  28941. readonly IsGlobal: boolean;
  28942. /**
  28943. * Returns the submesh BoudingInfo object
  28944. * @returns current bounding info (or mesh's one if the submesh is global)
  28945. */
  28946. getBoundingInfo(): BoundingInfo;
  28947. /**
  28948. * Sets the submesh BoundingInfo
  28949. * @param boundingInfo defines the new bounding info to use
  28950. * @returns the SubMesh
  28951. */
  28952. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  28953. /**
  28954. * Returns the mesh of the current submesh
  28955. * @return the parent mesh
  28956. */
  28957. getMesh(): AbstractMesh;
  28958. /**
  28959. * Returns the rendering mesh of the submesh
  28960. * @returns the rendering mesh (could be different from parent mesh)
  28961. */
  28962. getRenderingMesh(): Mesh;
  28963. /**
  28964. * Returns the submesh material
  28965. * @returns null or the current material
  28966. */
  28967. getMaterial(): Nullable<Material>;
  28968. /**
  28969. * Sets a new updated BoundingInfo object to the submesh
  28970. * @returns the SubMesh
  28971. */
  28972. refreshBoundingInfo(): SubMesh;
  28973. /** @hidden */
  28974. _checkCollision(collider: Collider): boolean;
  28975. /**
  28976. * Updates the submesh BoundingInfo
  28977. * @param world defines the world matrix to use to update the bounding info
  28978. * @returns the submesh
  28979. */
  28980. updateBoundingInfo(world: Matrix): SubMesh;
  28981. /**
  28982. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  28983. * @param frustumPlanes defines the frustum planes
  28984. * @returns true if the submesh is intersecting with the frustum
  28985. */
  28986. isInFrustum(frustumPlanes: Plane[]): boolean;
  28987. /**
  28988. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  28989. * @param frustumPlanes defines the frustum planes
  28990. * @returns true if the submesh is inside the frustum
  28991. */
  28992. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28993. /**
  28994. * Renders the submesh
  28995. * @param enableAlphaMode defines if alpha needs to be used
  28996. * @returns the submesh
  28997. */
  28998. render(enableAlphaMode: boolean): SubMesh;
  28999. /**
  29000. * @hidden
  29001. */
  29002. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29003. /**
  29004. * Checks if the submesh intersects with a ray
  29005. * @param ray defines the ray to test
  29006. * @returns true is the passed ray intersects the submesh bounding box
  29007. */
  29008. canIntersects(ray: Ray): boolean;
  29009. /**
  29010. * Intersects current submesh with a ray
  29011. * @param ray defines the ray to test
  29012. * @param positions defines mesh's positions array
  29013. * @param indices defines mesh's indices array
  29014. * @param fastCheck defines if only bounding info should be used
  29015. * @returns intersection info or null if no intersection
  29016. */
  29017. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29018. /** @hidden */
  29019. private _intersectLines;
  29020. /** @hidden */
  29021. private _intersectTriangles;
  29022. /** @hidden */
  29023. _rebuild(): void;
  29024. /**
  29025. * Creates a new submesh from the passed mesh
  29026. * @param newMesh defines the new hosting mesh
  29027. * @param newRenderingMesh defines an optional rendering mesh
  29028. * @returns the new submesh
  29029. */
  29030. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29031. /**
  29032. * Release associated resources
  29033. */
  29034. dispose(): void;
  29035. /**
  29036. * Creates a new submesh from indices data
  29037. * @param materialIndex the index of the main mesh material
  29038. * @param startIndex the index where to start the copy in the mesh indices array
  29039. * @param indexCount the number of indices to copy then from the startIndex
  29040. * @param mesh the main mesh to create the submesh from
  29041. * @param renderingMesh the optional rendering mesh
  29042. * @returns a new submesh
  29043. */
  29044. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29045. }
  29046. }
  29047. declare module BABYLON {
  29048. /**
  29049. * 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.
  29050. * @see https://doc.babylonjs.com/how_to/transformnode
  29051. */
  29052. class TransformNode extends Node {
  29053. /**
  29054. * Object will not rotate to face the camera
  29055. */
  29056. static BILLBOARDMODE_NONE: number;
  29057. /**
  29058. * Object will rotate to face the camera but only on the x axis
  29059. */
  29060. static BILLBOARDMODE_X: number;
  29061. /**
  29062. * Object will rotate to face the camera but only on the y axis
  29063. */
  29064. static BILLBOARDMODE_Y: number;
  29065. /**
  29066. * Object will rotate to face the camera but only on the z axis
  29067. */
  29068. static BILLBOARDMODE_Z: number;
  29069. /**
  29070. * Object will rotate to face the camera
  29071. */
  29072. static BILLBOARDMODE_ALL: number;
  29073. private _forward;
  29074. private _forwardInverted;
  29075. private _up;
  29076. private _right;
  29077. private _rightInverted;
  29078. private _position;
  29079. private _rotation;
  29080. private _rotationQuaternion;
  29081. protected _scaling: Vector3;
  29082. protected _isDirty: boolean;
  29083. private _transformToBoneReferal;
  29084. /**
  29085. * Set the billboard mode. Default is 0.
  29086. *
  29087. * | Value | Type | Description |
  29088. * | --- | --- | --- |
  29089. * | 0 | BILLBOARDMODE_NONE | |
  29090. * | 1 | BILLBOARDMODE_X | |
  29091. * | 2 | BILLBOARDMODE_Y | |
  29092. * | 4 | BILLBOARDMODE_Z | |
  29093. * | 7 | BILLBOARDMODE_ALL | |
  29094. *
  29095. */
  29096. billboardMode: number;
  29097. /**
  29098. * 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
  29099. */
  29100. scalingDeterminant: number;
  29101. /**
  29102. * Sets the distance of the object to max, often used by skybox
  29103. */
  29104. infiniteDistance: boolean;
  29105. /**
  29106. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29107. * By default the system will update normals to compensate
  29108. */
  29109. ignoreNonUniformScaling: boolean;
  29110. /** @hidden */
  29111. _poseMatrix: Matrix;
  29112. private _localWorld;
  29113. private _absolutePosition;
  29114. private _pivotMatrix;
  29115. private _pivotMatrixInverse;
  29116. protected _postMultiplyPivotMatrix: boolean;
  29117. protected _isWorldMatrixFrozen: boolean;
  29118. /** @hidden */
  29119. _indexInSceneTransformNodesArray: number;
  29120. /**
  29121. * An event triggered after the world matrix is updated
  29122. */
  29123. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29124. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29125. /**
  29126. * Gets a string identifying the name of the class
  29127. * @returns "TransformNode" string
  29128. */
  29129. getClassName(): string;
  29130. /**
  29131. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29132. */
  29133. position: Vector3;
  29134. /**
  29135. * 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)).
  29136. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29137. */
  29138. rotation: Vector3;
  29139. /**
  29140. * 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)).
  29141. */
  29142. scaling: Vector3;
  29143. /**
  29144. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29145. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29146. */
  29147. rotationQuaternion: Nullable<Quaternion>;
  29148. /**
  29149. * The forward direction of that transform in world space.
  29150. */
  29151. readonly forward: Vector3;
  29152. /**
  29153. * The up direction of that transform in world space.
  29154. */
  29155. readonly up: Vector3;
  29156. /**
  29157. * The right direction of that transform in world space.
  29158. */
  29159. readonly right: Vector3;
  29160. /**
  29161. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29162. * @param matrix the matrix to copy the pose from
  29163. * @returns this TransformNode.
  29164. */
  29165. updatePoseMatrix(matrix: Matrix): TransformNode;
  29166. /**
  29167. * Returns the mesh Pose matrix.
  29168. * @returns the pose matrix
  29169. */
  29170. getPoseMatrix(): Matrix;
  29171. /** @hidden */
  29172. _isSynchronized(): boolean;
  29173. /** @hidden */
  29174. _initCache(): void;
  29175. /**
  29176. * Flag the transform node as dirty (Forcing it to update everything)
  29177. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29178. * @returns this transform node
  29179. */
  29180. markAsDirty(property: string): TransformNode;
  29181. /**
  29182. * Returns the current mesh absolute position.
  29183. * Returns a Vector3.
  29184. */
  29185. readonly absolutePosition: Vector3;
  29186. /**
  29187. * Sets a new matrix to apply before all other transformation
  29188. * @param matrix defines the transform matrix
  29189. * @returns the current TransformNode
  29190. */
  29191. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29192. /**
  29193. * Sets a new pivot matrix to the current node
  29194. * @param matrix defines the new pivot matrix to use
  29195. * @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
  29196. * @returns the current TransformNode
  29197. */
  29198. setPivotMatrix(matrix: Readonly<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29199. /**
  29200. * Returns the mesh pivot matrix.
  29201. * Default : Identity.
  29202. * @returns the matrix
  29203. */
  29204. getPivotMatrix(): Matrix;
  29205. /**
  29206. * Prevents the World matrix to be computed any longer.
  29207. * @returns the TransformNode.
  29208. */
  29209. freezeWorldMatrix(): TransformNode;
  29210. /**
  29211. * Allows back the World matrix computation.
  29212. * @returns the TransformNode.
  29213. */
  29214. unfreezeWorldMatrix(): this;
  29215. /**
  29216. * True if the World matrix has been frozen.
  29217. */
  29218. readonly isWorldMatrixFrozen: boolean;
  29219. /**
  29220. * Retuns the mesh absolute position in the World.
  29221. * @returns a Vector3.
  29222. */
  29223. getAbsolutePosition(): Vector3;
  29224. /**
  29225. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29226. * @param absolutePosition the absolute position to set
  29227. * @returns the TransformNode.
  29228. */
  29229. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29230. /**
  29231. * Sets the mesh position in its local space.
  29232. * @param vector3 the position to set in localspace
  29233. * @returns the TransformNode.
  29234. */
  29235. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29236. /**
  29237. * Returns the mesh position in the local space from the current World matrix values.
  29238. * @returns a new Vector3.
  29239. */
  29240. getPositionExpressedInLocalSpace(): Vector3;
  29241. /**
  29242. * Translates the mesh along the passed Vector3 in its local space.
  29243. * @param vector3 the distance to translate in localspace
  29244. * @returns the TransformNode.
  29245. */
  29246. locallyTranslate(vector3: Vector3): TransformNode;
  29247. private static _lookAtVectorCache;
  29248. /**
  29249. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29250. * @param targetPoint the position (must be in same space as current mesh) to look at
  29251. * @param yawCor optional yaw (y-axis) correction in radians
  29252. * @param pitchCor optional pitch (x-axis) correction in radians
  29253. * @param rollCor optional roll (z-axis) correction in radians
  29254. * @param space the choosen space of the target
  29255. * @returns the TransformNode.
  29256. */
  29257. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29258. /**
  29259. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29260. * This Vector3 is expressed in the World space.
  29261. * @param localAxis axis to rotate
  29262. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29263. */
  29264. getDirection(localAxis: Vector3): Vector3;
  29265. /**
  29266. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29267. * localAxis is expressed in the mesh local space.
  29268. * result is computed in the Wordl space from the mesh World matrix.
  29269. * @param localAxis axis to rotate
  29270. * @param result the resulting transformnode
  29271. * @returns this TransformNode.
  29272. */
  29273. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29274. /**
  29275. * Sets a new pivot point to the current node
  29276. * @param point defines the new pivot point to use
  29277. * @param space defines if the point is in world or local space (local by default)
  29278. * @returns the current TransformNode
  29279. */
  29280. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29281. /**
  29282. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29283. * @returns the pivot point
  29284. */
  29285. getPivotPoint(): Vector3;
  29286. /**
  29287. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29288. * @param result the vector3 to store the result
  29289. * @returns this TransformNode.
  29290. */
  29291. getPivotPointToRef(result: Vector3): TransformNode;
  29292. /**
  29293. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29294. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29295. */
  29296. getAbsolutePivotPoint(): Vector3;
  29297. /**
  29298. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29299. * @param result vector3 to store the result
  29300. * @returns this TransformNode.
  29301. */
  29302. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29303. /**
  29304. * Defines the passed node as the parent of the current node.
  29305. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29306. * @param node the node ot set as the parent
  29307. * @returns this TransformNode.
  29308. */
  29309. setParent(node: Nullable<Node>): TransformNode;
  29310. private _nonUniformScaling;
  29311. /**
  29312. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29313. */
  29314. readonly nonUniformScaling: boolean;
  29315. /** @hidden */
  29316. _updateNonUniformScalingState(value: boolean): boolean;
  29317. /**
  29318. * Attach the current TransformNode to another TransformNode associated with a bone
  29319. * @param bone Bone affecting the TransformNode
  29320. * @param affectedTransformNode TransformNode associated with the bone
  29321. * @returns this object
  29322. */
  29323. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29324. /**
  29325. * Detach the transform node if its associated with a bone
  29326. * @returns this object
  29327. */
  29328. detachFromBone(): TransformNode;
  29329. private static _rotationAxisCache;
  29330. /**
  29331. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29332. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29333. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29334. * The passed axis is also normalized.
  29335. * @param axis the axis to rotate around
  29336. * @param amount the amount to rotate in radians
  29337. * @param space Space to rotate in (Default: local)
  29338. * @returns the TransformNode.
  29339. */
  29340. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29341. /**
  29342. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29343. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29344. * The passed axis is also normalized. .
  29345. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29346. * @param point the point to rotate around
  29347. * @param axis the axis to rotate around
  29348. * @param amount the amount to rotate in radians
  29349. * @returns the TransformNode
  29350. */
  29351. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29352. /**
  29353. * Translates the mesh along the axis vector for the passed distance in the given space.
  29354. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29355. * @param axis the axis to translate in
  29356. * @param distance the distance to translate
  29357. * @param space Space to rotate in (Default: local)
  29358. * @returns the TransformNode.
  29359. */
  29360. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29361. /**
  29362. * Adds a rotation step to the mesh current rotation.
  29363. * x, y, z are Euler angles expressed in radians.
  29364. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29365. * This means this rotation is made in the mesh local space only.
  29366. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29367. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29368. * ```javascript
  29369. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29370. * ```
  29371. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29372. * 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.
  29373. * @param x Rotation to add
  29374. * @param y Rotation to add
  29375. * @param z Rotation to add
  29376. * @returns the TransformNode.
  29377. */
  29378. addRotation(x: number, y: number, z: number): TransformNode;
  29379. /**
  29380. * Computes the world matrix of the node
  29381. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29382. * @returns the world matrix
  29383. */
  29384. computeWorldMatrix(force?: boolean): Matrix;
  29385. protected _afterComputeWorldMatrix(): void;
  29386. /**
  29387. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29388. * @param func callback function to add
  29389. *
  29390. * @returns the TransformNode.
  29391. */
  29392. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29393. /**
  29394. * Removes a registered callback function.
  29395. * @param func callback function to remove
  29396. * @returns the TransformNode.
  29397. */
  29398. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29399. /**
  29400. * Clone the current transform node
  29401. * @param name Name of the new clone
  29402. * @param newParent New parent for the clone
  29403. * @param doNotCloneChildren Do not clone children hierarchy
  29404. * @returns the new transform node
  29405. */
  29406. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29407. /**
  29408. * Serializes the objects information.
  29409. * @param currentSerializationObject defines the object to serialize in
  29410. * @returns the serialized object
  29411. */
  29412. serialize(currentSerializationObject?: any): any;
  29413. /**
  29414. * Returns a new TransformNode object parsed from the source provided.
  29415. * @param parsedTransformNode is the source.
  29416. * @param scene the scne the object belongs to
  29417. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29418. * @returns a new TransformNode object parsed from the source provided.
  29419. */
  29420. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29421. /**
  29422. * Releases resources associated with this transform node.
  29423. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29424. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29425. */
  29426. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29427. }
  29428. }
  29429. declare module BABYLON {
  29430. /**
  29431. * Specialized buffer used to store vertex data
  29432. */
  29433. class VertexBuffer {
  29434. /** @hidden */
  29435. _buffer: Buffer;
  29436. private _kind;
  29437. private _size;
  29438. private _ownsBuffer;
  29439. private _instanced;
  29440. private _instanceDivisor;
  29441. /**
  29442. * The byte type.
  29443. */
  29444. static readonly BYTE: number;
  29445. /**
  29446. * The unsigned byte type.
  29447. */
  29448. static readonly UNSIGNED_BYTE: number;
  29449. /**
  29450. * The short type.
  29451. */
  29452. static readonly SHORT: number;
  29453. /**
  29454. * The unsigned short type.
  29455. */
  29456. static readonly UNSIGNED_SHORT: number;
  29457. /**
  29458. * The integer type.
  29459. */
  29460. static readonly INT: number;
  29461. /**
  29462. * The unsigned integer type.
  29463. */
  29464. static readonly UNSIGNED_INT: number;
  29465. /**
  29466. * The float type.
  29467. */
  29468. static readonly FLOAT: number;
  29469. /**
  29470. * Gets or sets the instance divisor when in instanced mode
  29471. */
  29472. instanceDivisor: number;
  29473. /**
  29474. * Gets the byte stride.
  29475. */
  29476. readonly byteStride: number;
  29477. /**
  29478. * Gets the byte offset.
  29479. */
  29480. readonly byteOffset: number;
  29481. /**
  29482. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29483. */
  29484. readonly normalized: boolean;
  29485. /**
  29486. * Gets the data type of each component in the array.
  29487. */
  29488. readonly type: number;
  29489. /**
  29490. * Constructor
  29491. * @param engine the engine
  29492. * @param data the data to use for this vertex buffer
  29493. * @param kind the vertex buffer kind
  29494. * @param updatable whether the data is updatable
  29495. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29496. * @param stride the stride (optional)
  29497. * @param instanced whether the buffer is instanced (optional)
  29498. * @param offset the offset of the data (optional)
  29499. * @param size the number of components (optional)
  29500. * @param type the type of the component (optional)
  29501. * @param normalized whether the data contains normalized data (optional)
  29502. * @param useBytes set to true if stride and offset are in bytes (optional)
  29503. */
  29504. 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);
  29505. /** @hidden */
  29506. _rebuild(): void;
  29507. /**
  29508. * Returns the kind of the VertexBuffer (string)
  29509. * @returns a string
  29510. */
  29511. getKind(): string;
  29512. /**
  29513. * Gets a boolean indicating if the VertexBuffer is updatable?
  29514. * @returns true if the buffer is updatable
  29515. */
  29516. isUpdatable(): boolean;
  29517. /**
  29518. * Gets current buffer's data
  29519. * @returns a DataArray or null
  29520. */
  29521. getData(): Nullable<DataArray>;
  29522. /**
  29523. * Gets underlying native buffer
  29524. * @returns underlying native buffer
  29525. */
  29526. getBuffer(): Nullable<WebGLBuffer>;
  29527. /**
  29528. * Gets the stride in float32 units (i.e. byte stride / 4).
  29529. * May not be an integer if the byte stride is not divisible by 4.
  29530. * DEPRECATED. Use byteStride instead.
  29531. * @returns the stride in float32 units
  29532. */
  29533. getStrideSize(): number;
  29534. /**
  29535. * Returns the offset as a multiple of the type byte length.
  29536. * DEPRECATED. Use byteOffset instead.
  29537. * @returns the offset in bytes
  29538. */
  29539. getOffset(): number;
  29540. /**
  29541. * Returns the number of components per vertex attribute (integer)
  29542. * @returns the size in float
  29543. */
  29544. getSize(): number;
  29545. /**
  29546. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29547. * @returns true if this buffer is instanced
  29548. */
  29549. getIsInstanced(): boolean;
  29550. /**
  29551. * Returns the instancing divisor, zero for non-instanced (integer).
  29552. * @returns a number
  29553. */
  29554. getInstanceDivisor(): number;
  29555. /**
  29556. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29557. * @param data defines the data to store
  29558. */
  29559. create(data?: DataArray): void;
  29560. /**
  29561. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29562. * This function will create a new buffer if the current one is not updatable
  29563. * @param data defines the data to store
  29564. */
  29565. update(data: DataArray): void;
  29566. /**
  29567. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29568. * Returns the directly updated WebGLBuffer.
  29569. * @param data the new data
  29570. * @param offset the new offset
  29571. * @param useBytes set to true if the offset is in bytes
  29572. */
  29573. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29574. /**
  29575. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29576. */
  29577. dispose(): void;
  29578. /**
  29579. * Enumerates each value of this vertex buffer as numbers.
  29580. * @param count the number of values to enumerate
  29581. * @param callback the callback function called for each value
  29582. */
  29583. forEach(count: number, callback: (value: number, index: number) => void): void;
  29584. /**
  29585. * Positions
  29586. */
  29587. static readonly PositionKind: string;
  29588. /**
  29589. * Normals
  29590. */
  29591. static readonly NormalKind: string;
  29592. /**
  29593. * Tangents
  29594. */
  29595. static readonly TangentKind: string;
  29596. /**
  29597. * Texture coordinates
  29598. */
  29599. static readonly UVKind: string;
  29600. /**
  29601. * Texture coordinates 2
  29602. */
  29603. static readonly UV2Kind: string;
  29604. /**
  29605. * Texture coordinates 3
  29606. */
  29607. static readonly UV3Kind: string;
  29608. /**
  29609. * Texture coordinates 4
  29610. */
  29611. static readonly UV4Kind: string;
  29612. /**
  29613. * Texture coordinates 5
  29614. */
  29615. static readonly UV5Kind: string;
  29616. /**
  29617. * Texture coordinates 6
  29618. */
  29619. static readonly UV6Kind: string;
  29620. /**
  29621. * Colors
  29622. */
  29623. static readonly ColorKind: string;
  29624. /**
  29625. * Matrix indices (for bones)
  29626. */
  29627. static readonly MatricesIndicesKind: string;
  29628. /**
  29629. * Matrix weights (for bones)
  29630. */
  29631. static readonly MatricesWeightsKind: string;
  29632. /**
  29633. * Additional matrix indices (for bones)
  29634. */
  29635. static readonly MatricesIndicesExtraKind: string;
  29636. /**
  29637. * Additional matrix weights (for bones)
  29638. */
  29639. static readonly MatricesWeightsExtraKind: string;
  29640. /**
  29641. * Deduces the stride given a kind.
  29642. * @param kind The kind string to deduce
  29643. * @returns The deduced stride
  29644. */
  29645. static DeduceStride(kind: string): number;
  29646. /**
  29647. * Gets the byte length of the given type.
  29648. * @param type the type
  29649. * @returns the number of bytes
  29650. */
  29651. static GetTypeByteLength(type: number): number;
  29652. /**
  29653. * Enumerates each value of the given parameters as numbers.
  29654. * @param data the data to enumerate
  29655. * @param byteOffset the byte offset of the data
  29656. * @param byteStride the byte stride of the data
  29657. * @param componentCount the number of components per element
  29658. * @param componentType the type of the component
  29659. * @param count the total number of components
  29660. * @param normalized whether the data is normalized
  29661. * @param callback the callback function called for each value
  29662. */
  29663. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  29664. private static _GetFloatValue;
  29665. }
  29666. }
  29667. declare module BABYLON {
  29668. /**
  29669. * Defines a target to use with MorphTargetManager
  29670. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29671. */
  29672. class MorphTarget implements IAnimatable {
  29673. /** defines the name of the target */
  29674. name: string;
  29675. /**
  29676. * Gets or sets the list of animations
  29677. */
  29678. animations: Animation[];
  29679. private _scene;
  29680. private _positions;
  29681. private _normals;
  29682. private _tangents;
  29683. private _influence;
  29684. /**
  29685. * Observable raised when the influence changes
  29686. */
  29687. onInfluenceChanged: Observable<boolean>;
  29688. /** @hidden */
  29689. _onDataLayoutChanged: Observable<void>;
  29690. /**
  29691. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  29692. */
  29693. influence: number;
  29694. private _animationPropertiesOverride;
  29695. /**
  29696. * Gets or sets the animation properties override
  29697. */
  29698. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29699. /**
  29700. * Creates a new MorphTarget
  29701. * @param name defines the name of the target
  29702. * @param influence defines the influence to use
  29703. */
  29704. constructor(
  29705. /** defines the name of the target */
  29706. name: string, influence?: number, scene?: Nullable<Scene>);
  29707. /**
  29708. * Gets a boolean defining if the target contains position data
  29709. */
  29710. readonly hasPositions: boolean;
  29711. /**
  29712. * Gets a boolean defining if the target contains normal data
  29713. */
  29714. readonly hasNormals: boolean;
  29715. /**
  29716. * Gets a boolean defining if the target contains tangent data
  29717. */
  29718. readonly hasTangents: boolean;
  29719. /**
  29720. * Affects position data to this target
  29721. * @param data defines the position data to use
  29722. */
  29723. setPositions(data: Nullable<FloatArray>): void;
  29724. /**
  29725. * Gets the position data stored in this target
  29726. * @returns a FloatArray containing the position data (or null if not present)
  29727. */
  29728. getPositions(): Nullable<FloatArray>;
  29729. /**
  29730. * Affects normal data to this target
  29731. * @param data defines the normal data to use
  29732. */
  29733. setNormals(data: Nullable<FloatArray>): void;
  29734. /**
  29735. * Gets the normal data stored in this target
  29736. * @returns a FloatArray containing the normal data (or null if not present)
  29737. */
  29738. getNormals(): Nullable<FloatArray>;
  29739. /**
  29740. * Affects tangent data to this target
  29741. * @param data defines the tangent data to use
  29742. */
  29743. setTangents(data: Nullable<FloatArray>): void;
  29744. /**
  29745. * Gets the tangent data stored in this target
  29746. * @returns a FloatArray containing the tangent data (or null if not present)
  29747. */
  29748. getTangents(): Nullable<FloatArray>;
  29749. /**
  29750. * Serializes the current target into a Serialization object
  29751. * @returns the serialized object
  29752. */
  29753. serialize(): any;
  29754. /**
  29755. * Creates a new target from serialized data
  29756. * @param serializationObject defines the serialized data to use
  29757. * @returns a new MorphTarget
  29758. */
  29759. static Parse(serializationObject: any): MorphTarget;
  29760. /**
  29761. * Creates a MorphTarget from mesh data
  29762. * @param mesh defines the source mesh
  29763. * @param name defines the name to use for the new target
  29764. * @param influence defines the influence to attach to the target
  29765. * @returns a new MorphTarget
  29766. */
  29767. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  29768. }
  29769. }
  29770. declare module BABYLON {
  29771. /**
  29772. * This class is used to deform meshes using morphing between different targets
  29773. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29774. */
  29775. class MorphTargetManager {
  29776. private _targets;
  29777. private _targetInfluenceChangedObservers;
  29778. private _targetDataLayoutChangedObservers;
  29779. private _activeTargets;
  29780. private _scene;
  29781. private _influences;
  29782. private _supportsNormals;
  29783. private _supportsTangents;
  29784. private _vertexCount;
  29785. private _uniqueId;
  29786. private _tempInfluences;
  29787. /**
  29788. * Creates a new MorphTargetManager
  29789. * @param scene defines the current scene
  29790. */
  29791. constructor(scene?: Nullable<Scene>);
  29792. /**
  29793. * Gets the unique ID of this manager
  29794. */
  29795. readonly uniqueId: number;
  29796. /**
  29797. * Gets the number of vertices handled by this manager
  29798. */
  29799. readonly vertexCount: number;
  29800. /**
  29801. * Gets a boolean indicating if this manager supports morphing of normals
  29802. */
  29803. readonly supportsNormals: boolean;
  29804. /**
  29805. * Gets a boolean indicating if this manager supports morphing of tangents
  29806. */
  29807. readonly supportsTangents: boolean;
  29808. /**
  29809. * Gets the number of targets stored in this manager
  29810. */
  29811. readonly numTargets: number;
  29812. /**
  29813. * Gets the number of influencers (ie. the number of targets with influences > 0)
  29814. */
  29815. readonly numInfluencers: number;
  29816. /**
  29817. * Gets the list of influences (one per target)
  29818. */
  29819. readonly influences: Float32Array;
  29820. /**
  29821. * Gets the active target at specified index. An active target is a target with an influence > 0
  29822. * @param index defines the index to check
  29823. * @returns the requested target
  29824. */
  29825. getActiveTarget(index: number): MorphTarget;
  29826. /**
  29827. * Gets the target at specified index
  29828. * @param index defines the index to check
  29829. * @returns the requested target
  29830. */
  29831. getTarget(index: number): MorphTarget;
  29832. /**
  29833. * Add a new target to this manager
  29834. * @param target defines the target to add
  29835. */
  29836. addTarget(target: MorphTarget): void;
  29837. /**
  29838. * Removes a target from the manager
  29839. * @param target defines the target to remove
  29840. */
  29841. removeTarget(target: MorphTarget): void;
  29842. /**
  29843. * Serializes the current manager into a Serialization object
  29844. * @returns the serialized object
  29845. */
  29846. serialize(): any;
  29847. private _syncActiveTargets;
  29848. /**
  29849. * Syncrhonize the targets with all the meshes using this morph target manager
  29850. */
  29851. synchronize(): void;
  29852. /**
  29853. * Creates a new MorphTargetManager from serialized data
  29854. * @param serializationObject defines the serialized data
  29855. * @param scene defines the hosting scene
  29856. * @returns the new MorphTargetManager
  29857. */
  29858. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  29859. }
  29860. }
  29861. declare module BABYLON {
  29862. /**
  29863. * Class used to enable access to IndexedDB
  29864. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  29865. */
  29866. class Database implements IOfflineProvider {
  29867. private _callbackManifestChecked;
  29868. private _currentSceneUrl;
  29869. private _db;
  29870. private _enableSceneOffline;
  29871. private _enableTexturesOffline;
  29872. private _manifestVersionFound;
  29873. private _mustUpdateRessources;
  29874. private _hasReachedQuota;
  29875. private _isSupported;
  29876. private _idbFactory;
  29877. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  29878. private static IsUASupportingBlobStorage;
  29879. /**
  29880. * Gets a boolean indicating if Database storate is enabled (off by default)
  29881. */
  29882. static IDBStorageEnabled: boolean;
  29883. /**
  29884. * Gets a boolean indicating if scene must be saved in the database
  29885. */
  29886. readonly enableSceneOffline: boolean;
  29887. /**
  29888. * Gets a boolean indicating if textures must be saved in the database
  29889. */
  29890. readonly enableTexturesOffline: boolean;
  29891. /**
  29892. * Creates a new Database
  29893. * @param urlToScene defines the url to load the scene
  29894. * @param callbackManifestChecked defines the callback to use when manifest is checked
  29895. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  29896. */
  29897. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  29898. private static _ParseURL;
  29899. private static _ReturnFullUrlLocation;
  29900. private _checkManifestFile;
  29901. /**
  29902. * Open the database and make it available
  29903. * @param successCallback defines the callback to call on success
  29904. * @param errorCallback defines the callback to call on error
  29905. */
  29906. open(successCallback: () => void, errorCallback: () => void): void;
  29907. /**
  29908. * Loads an image from the database
  29909. * @param url defines the url to load from
  29910. * @param image defines the target DOM image
  29911. */
  29912. loadImage(url: string, image: HTMLImageElement): void;
  29913. private _loadImageFromDBAsync;
  29914. private _saveImageIntoDBAsync;
  29915. private _checkVersionFromDB;
  29916. private _loadVersionFromDBAsync;
  29917. private _saveVersionIntoDBAsync;
  29918. /**
  29919. * Loads a file from database
  29920. * @param url defines the URL to load from
  29921. * @param sceneLoaded defines a callback to call on success
  29922. * @param progressCallBack defines a callback to call when progress changed
  29923. * @param errorCallback defines a callback to call on error
  29924. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  29925. */
  29926. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  29927. private _loadFileAsync;
  29928. private _saveFileAsync;
  29929. }
  29930. }
  29931. declare module BABYLON {
  29932. /**
  29933. * Class used to enable access to offline support
  29934. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  29935. */
  29936. interface IOfflineProvider {
  29937. /**
  29938. * Gets a boolean indicating if scene must be saved in the database
  29939. */
  29940. enableSceneOffline: boolean;
  29941. /**
  29942. * Gets a boolean indicating if textures must be saved in the database
  29943. */
  29944. enableTexturesOffline: boolean;
  29945. /**
  29946. * Open the offline support and make it available
  29947. * @param successCallback defines the callback to call on success
  29948. * @param errorCallback defines the callback to call on error
  29949. */
  29950. open(successCallback: () => void, errorCallback: () => void): void;
  29951. /**
  29952. * Loads an image from the offline support
  29953. * @param url defines the url to load from
  29954. * @param image defines the target DOM image
  29955. */
  29956. loadImage(url: string, image: HTMLImageElement): void;
  29957. /**
  29958. * Loads a file from offline support
  29959. * @param url defines the URL to load from
  29960. * @param sceneLoaded defines a callback to call on success
  29961. * @param progressCallBack defines a callback to call when progress changed
  29962. * @param errorCallback defines a callback to call on error
  29963. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  29964. */
  29965. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  29966. }
  29967. }
  29968. declare module BABYLON {
  29969. /**
  29970. * This represents the base class for particle system in Babylon.
  29971. * 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.
  29972. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  29973. * @example https://doc.babylonjs.com/babylon101/particles
  29974. */
  29975. class BaseParticleSystem {
  29976. /**
  29977. * Source color is added to the destination color without alpha affecting the result
  29978. */
  29979. static BLENDMODE_ONEONE: number;
  29980. /**
  29981. * Blend current color and particle color using particle’s alpha
  29982. */
  29983. static BLENDMODE_STANDARD: number;
  29984. /**
  29985. * Add current color and particle color multiplied by particle’s alpha
  29986. */
  29987. static BLENDMODE_ADD: number;
  29988. /**
  29989. * Multiply current color with particle color
  29990. */
  29991. static BLENDMODE_MULTIPLY: number;
  29992. /**
  29993. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  29994. */
  29995. static BLENDMODE_MULTIPLYADD: number;
  29996. /**
  29997. * List of animations used by the particle system.
  29998. */
  29999. animations: Animation[];
  30000. /**
  30001. * The id of the Particle system.
  30002. */
  30003. id: string;
  30004. /**
  30005. * The friendly name of the Particle system.
  30006. */
  30007. name: string;
  30008. /**
  30009. * The rendering group used by the Particle system to chose when to render.
  30010. */
  30011. renderingGroupId: number;
  30012. /**
  30013. * The emitter represents the Mesh or position we are attaching the particle system to.
  30014. */
  30015. emitter: Nullable<AbstractMesh | Vector3>;
  30016. /**
  30017. * The maximum number of particles to emit per frame
  30018. */
  30019. emitRate: number;
  30020. /**
  30021. * If you want to launch only a few particles at once, that can be done, as well.
  30022. */
  30023. manualEmitCount: number;
  30024. /**
  30025. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30026. */
  30027. updateSpeed: number;
  30028. /**
  30029. * The amount of time the particle system is running (depends of the overall update speed).
  30030. */
  30031. targetStopDuration: number;
  30032. /**
  30033. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30034. */
  30035. disposeOnStop: boolean;
  30036. /**
  30037. * Minimum power of emitting particles.
  30038. */
  30039. minEmitPower: number;
  30040. /**
  30041. * Maximum power of emitting particles.
  30042. */
  30043. maxEmitPower: number;
  30044. /**
  30045. * Minimum life time of emitting particles.
  30046. */
  30047. minLifeTime: number;
  30048. /**
  30049. * Maximum life time of emitting particles.
  30050. */
  30051. maxLifeTime: number;
  30052. /**
  30053. * Minimum Size of emitting particles.
  30054. */
  30055. minSize: number;
  30056. /**
  30057. * Maximum Size of emitting particles.
  30058. */
  30059. maxSize: number;
  30060. /**
  30061. * Minimum scale of emitting particles on X axis.
  30062. */
  30063. minScaleX: number;
  30064. /**
  30065. * Maximum scale of emitting particles on X axis.
  30066. */
  30067. maxScaleX: number;
  30068. /**
  30069. * Minimum scale of emitting particles on Y axis.
  30070. */
  30071. minScaleY: number;
  30072. /**
  30073. * Maximum scale of emitting particles on Y axis.
  30074. */
  30075. maxScaleY: number;
  30076. /**
  30077. * Gets or sets the minimal initial rotation in radians.
  30078. */
  30079. minInitialRotation: number;
  30080. /**
  30081. * Gets or sets the maximal initial rotation in radians.
  30082. */
  30083. maxInitialRotation: number;
  30084. /**
  30085. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30086. */
  30087. minAngularSpeed: number;
  30088. /**
  30089. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30090. */
  30091. maxAngularSpeed: number;
  30092. /**
  30093. * The texture used to render each particle. (this can be a spritesheet)
  30094. */
  30095. particleTexture: Nullable<Texture>;
  30096. /**
  30097. * The layer mask we are rendering the particles through.
  30098. */
  30099. layerMask: number;
  30100. /**
  30101. * This can help using your own shader to render the particle system.
  30102. * The according effect will be created
  30103. */
  30104. customShader: any;
  30105. /**
  30106. * By default particle system starts as soon as they are created. This prevents the
  30107. * automatic start to happen and let you decide when to start emitting particles.
  30108. */
  30109. preventAutoStart: boolean;
  30110. /**
  30111. * Gets or sets a texture used to add random noise to particle positions
  30112. */
  30113. noiseTexture: Nullable<ProceduralTexture>;
  30114. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30115. noiseStrength: Vector3;
  30116. /**
  30117. * Callback triggered when the particle animation is ending.
  30118. */
  30119. onAnimationEnd: Nullable<() => void>;
  30120. /**
  30121. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  30122. */
  30123. blendMode: number;
  30124. /**
  30125. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30126. * to override the particles.
  30127. */
  30128. forceDepthWrite: boolean;
  30129. /** 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 */
  30130. preWarmCycles: number;
  30131. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  30132. preWarmStepOffset: number;
  30133. /**
  30134. * 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)
  30135. */
  30136. spriteCellChangeSpeed: number;
  30137. /**
  30138. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30139. */
  30140. startSpriteCellID: number;
  30141. /**
  30142. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30143. */
  30144. endSpriteCellID: number;
  30145. /**
  30146. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30147. */
  30148. spriteCellWidth: number;
  30149. /**
  30150. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30151. */
  30152. spriteCellHeight: number;
  30153. /**
  30154. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30155. */
  30156. spriteRandomStartCell: boolean;
  30157. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30158. translationPivot: Vector2;
  30159. /** @hidden */
  30160. protected _isAnimationSheetEnabled: boolean;
  30161. /**
  30162. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30163. */
  30164. beginAnimationOnStart: boolean;
  30165. /**
  30166. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30167. */
  30168. beginAnimationFrom: number;
  30169. /**
  30170. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30171. */
  30172. beginAnimationTo: number;
  30173. /**
  30174. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30175. */
  30176. beginAnimationLoop: boolean;
  30177. /**
  30178. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  30179. */
  30180. isAnimationSheetEnabled: boolean;
  30181. /**
  30182. * Get hosting scene
  30183. * @returns the scene
  30184. */
  30185. getScene(): Scene;
  30186. /**
  30187. * You can use gravity if you want to give an orientation to your particles.
  30188. */
  30189. gravity: Vector3;
  30190. protected _colorGradients: Nullable<Array<ColorGradient>>;
  30191. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  30192. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  30193. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  30194. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  30195. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  30196. protected _dragGradients: Nullable<Array<FactorGradient>>;
  30197. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  30198. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  30199. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  30200. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  30201. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  30202. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  30203. /**
  30204. * Defines the delay in milliseconds before starting the system (0 by default)
  30205. */
  30206. startDelay: number;
  30207. /**
  30208. * Gets the current list of drag gradients.
  30209. * You must use addDragGradient and removeDragGradient to udpate this list
  30210. * @returns the list of drag gradients
  30211. */
  30212. getDragGradients(): Nullable<Array<FactorGradient>>;
  30213. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30214. limitVelocityDamping: number;
  30215. /**
  30216. * Gets the current list of limit velocity gradients.
  30217. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30218. * @returns the list of limit velocity gradients
  30219. */
  30220. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30221. /**
  30222. * Gets the current list of color gradients.
  30223. * You must use addColorGradient and removeColorGradient to udpate this list
  30224. * @returns the list of color gradients
  30225. */
  30226. getColorGradients(): Nullable<Array<ColorGradient>>;
  30227. /**
  30228. * Gets the current list of size gradients.
  30229. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30230. * @returns the list of size gradients
  30231. */
  30232. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30233. /**
  30234. * Gets the current list of color remap gradients.
  30235. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30236. * @returns the list of color remap gradients
  30237. */
  30238. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30239. /**
  30240. * Gets the current list of alpha remap gradients.
  30241. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30242. * @returns the list of alpha remap gradients
  30243. */
  30244. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30245. /**
  30246. * Gets the current list of life time gradients.
  30247. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30248. * @returns the list of life time gradients
  30249. */
  30250. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30251. /**
  30252. * Gets the current list of angular speed gradients.
  30253. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30254. * @returns the list of angular speed gradients
  30255. */
  30256. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30257. /**
  30258. * Gets the current list of velocity gradients.
  30259. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30260. * @returns the list of velocity gradients
  30261. */
  30262. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30263. /**
  30264. * Gets the current list of start size gradients.
  30265. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30266. * @returns the list of start size gradients
  30267. */
  30268. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30269. /**
  30270. * Gets the current list of emit rate gradients.
  30271. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30272. * @returns the list of emit rate gradients
  30273. */
  30274. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30275. /**
  30276. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30277. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30278. */
  30279. direction1: Vector3;
  30280. /**
  30281. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30282. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30283. */
  30284. direction2: Vector3;
  30285. /**
  30286. * 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.
  30287. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30288. */
  30289. minEmitBox: Vector3;
  30290. /**
  30291. * 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.
  30292. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30293. */
  30294. maxEmitBox: Vector3;
  30295. /**
  30296. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30297. */
  30298. color1: Color4;
  30299. /**
  30300. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30301. */
  30302. color2: Color4;
  30303. /**
  30304. * Color the particle will have at the end of its lifetime
  30305. */
  30306. colorDead: Color4;
  30307. /**
  30308. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  30309. */
  30310. textureMask: Color4;
  30311. /**
  30312. * The particle emitter type defines the emitter used by the particle system.
  30313. * It can be for example box, sphere, or cone...
  30314. */
  30315. particleEmitterType: IParticleEmitterType;
  30316. /** @hidden */
  30317. _isSubEmitter: boolean;
  30318. /**
  30319. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30320. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30321. */
  30322. billboardMode: number;
  30323. protected _isBillboardBased: boolean;
  30324. /**
  30325. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30326. */
  30327. isBillboardBased: boolean;
  30328. /**
  30329. * The scene the particle system belongs to.
  30330. */
  30331. protected _scene: Scene;
  30332. /**
  30333. * Local cache of defines for image processing.
  30334. */
  30335. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  30336. /**
  30337. * Default configuration related to image processing available in the standard Material.
  30338. */
  30339. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30340. /**
  30341. * Gets the image processing configuration used either in this material.
  30342. */
  30343. /**
  30344. * Sets the Default image processing configuration used either in the this material.
  30345. *
  30346. * If sets to null, the scene one is in use.
  30347. */
  30348. imageProcessingConfiguration: ImageProcessingConfiguration;
  30349. /**
  30350. * Attaches a new image processing configuration to the Standard Material.
  30351. * @param configuration
  30352. */
  30353. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30354. /** @hidden */
  30355. protected _reset(): void;
  30356. /** @hidden */
  30357. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  30358. /**
  30359. * Instantiates a particle system.
  30360. * 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.
  30361. * @param name The name of the particle system
  30362. */
  30363. constructor(name: string);
  30364. /**
  30365. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30366. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30367. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30368. * @returns the emitter
  30369. */
  30370. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30371. /**
  30372. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30373. * @param radius The radius of the hemisphere to emit from
  30374. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30375. * @returns the emitter
  30376. */
  30377. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  30378. /**
  30379. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30380. * @param radius The radius of the sphere to emit from
  30381. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30382. * @returns the emitter
  30383. */
  30384. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  30385. /**
  30386. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30387. * @param radius The radius of the sphere to emit from
  30388. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30389. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30390. * @returns the emitter
  30391. */
  30392. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  30393. /**
  30394. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30395. * @param radius The radius of the emission cylinder
  30396. * @param height The height of the emission cylinder
  30397. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30398. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30399. * @returns the emitter
  30400. */
  30401. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  30402. /**
  30403. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30404. * @param radius The radius of the cylinder to emit from
  30405. * @param height The height of the emission cylinder
  30406. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30407. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30408. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30409. * @returns the emitter
  30410. */
  30411. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  30412. /**
  30413. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30414. * @param radius The radius of the cone to emit from
  30415. * @param angle The base angle of the cone
  30416. * @returns the emitter
  30417. */
  30418. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  30419. /**
  30420. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30421. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30422. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30423. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30424. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30425. * @returns the emitter
  30426. */
  30427. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30428. }
  30429. }
  30430. declare module BABYLON {
  30431. /**
  30432. * This represents a GPU particle system in Babylon
  30433. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  30434. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  30435. */
  30436. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  30437. /**
  30438. * The layer mask we are rendering the particles through.
  30439. */
  30440. layerMask: number;
  30441. private _capacity;
  30442. private _activeCount;
  30443. private _currentActiveCount;
  30444. private _accumulatedCount;
  30445. private _renderEffect;
  30446. private _updateEffect;
  30447. private _buffer0;
  30448. private _buffer1;
  30449. private _spriteBuffer;
  30450. private _updateVAO;
  30451. private _renderVAO;
  30452. private _targetIndex;
  30453. private _sourceBuffer;
  30454. private _targetBuffer;
  30455. private _engine;
  30456. private _currentRenderId;
  30457. private _started;
  30458. private _stopped;
  30459. private _timeDelta;
  30460. private _randomTexture;
  30461. private _randomTexture2;
  30462. private _attributesStrideSize;
  30463. private _updateEffectOptions;
  30464. private _randomTextureSize;
  30465. private _actualFrame;
  30466. private readonly _rawTextureWidth;
  30467. /**
  30468. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  30469. */
  30470. static readonly IsSupported: boolean;
  30471. /**
  30472. * An event triggered when the system is disposed.
  30473. */
  30474. onDisposeObservable: Observable<GPUParticleSystem>;
  30475. /**
  30476. * Gets the maximum number of particles active at the same time.
  30477. * @returns The max number of active particles.
  30478. */
  30479. getCapacity(): number;
  30480. /**
  30481. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30482. * to override the particles.
  30483. */
  30484. forceDepthWrite: boolean;
  30485. /**
  30486. * Gets or set the number of active particles
  30487. */
  30488. activeParticleCount: number;
  30489. private _preWarmDone;
  30490. /**
  30491. * Is this system ready to be used/rendered
  30492. * @return true if the system is ready
  30493. */
  30494. isReady(): boolean;
  30495. /**
  30496. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30497. * @returns True if it has been started, otherwise false.
  30498. */
  30499. isStarted(): boolean;
  30500. /**
  30501. * Starts the particle system and begins to emit
  30502. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30503. */
  30504. start(delay?: number): void;
  30505. /**
  30506. * Stops the particle system.
  30507. */
  30508. stop(): void;
  30509. /**
  30510. * Remove all active particles
  30511. */
  30512. reset(): void;
  30513. /**
  30514. * Returns the string "GPUParticleSystem"
  30515. * @returns a string containing the class name
  30516. */
  30517. getClassName(): string;
  30518. private _colorGradientsTexture;
  30519. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  30520. /**
  30521. * Adds a new color gradient
  30522. * @param gradient defines the gradient to use (between 0 and 1)
  30523. * @param color1 defines the color to affect to the specified gradient
  30524. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30525. * @returns the current particle system
  30526. */
  30527. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  30528. /**
  30529. * Remove a specific color gradient
  30530. * @param gradient defines the gradient to remove
  30531. * @returns the current particle system
  30532. */
  30533. removeColorGradient(gradient: number): GPUParticleSystem;
  30534. private _angularSpeedGradientsTexture;
  30535. private _sizeGradientsTexture;
  30536. private _velocityGradientsTexture;
  30537. private _limitVelocityGradientsTexture;
  30538. private _dragGradientsTexture;
  30539. private _addFactorGradient;
  30540. /**
  30541. * Adds a new size gradient
  30542. * @param gradient defines the gradient to use (between 0 and 1)
  30543. * @param factor defines the size factor to affect to the specified gradient
  30544. * @returns the current particle system
  30545. */
  30546. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  30547. /**
  30548. * Remove a specific size gradient
  30549. * @param gradient defines the gradient to remove
  30550. * @returns the current particle system
  30551. */
  30552. removeSizeGradient(gradient: number): GPUParticleSystem;
  30553. /**
  30554. * Adds a new angular speed gradient
  30555. * @param gradient defines the gradient to use (between 0 and 1)
  30556. * @param factor defines the angular speed to affect to the specified gradient
  30557. * @returns the current particle system
  30558. */
  30559. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  30560. /**
  30561. * Remove a specific angular speed gradient
  30562. * @param gradient defines the gradient to remove
  30563. * @returns the current particle system
  30564. */
  30565. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  30566. /**
  30567. * Adds a new velocity gradient
  30568. * @param gradient defines the gradient to use (between 0 and 1)
  30569. * @param factor defines the velocity to affect to the specified gradient
  30570. * @returns the current particle system
  30571. */
  30572. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30573. /**
  30574. * Remove a specific velocity gradient
  30575. * @param gradient defines the gradient to remove
  30576. * @returns the current particle system
  30577. */
  30578. removeVelocityGradient(gradient: number): GPUParticleSystem;
  30579. /**
  30580. * Adds a new limit velocity gradient
  30581. * @param gradient defines the gradient to use (between 0 and 1)
  30582. * @param factor defines the limit velocity value to affect to the specified gradient
  30583. * @returns the current particle system
  30584. */
  30585. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30586. /**
  30587. * Remove a specific limit velocity gradient
  30588. * @param gradient defines the gradient to remove
  30589. * @returns the current particle system
  30590. */
  30591. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  30592. /**
  30593. * Adds a new drag gradient
  30594. * @param gradient defines the gradient to use (between 0 and 1)
  30595. * @param factor defines the drag value to affect to the specified gradient
  30596. * @returns the current particle system
  30597. */
  30598. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  30599. /**
  30600. * Remove a specific drag gradient
  30601. * @param gradient defines the gradient to remove
  30602. * @returns the current particle system
  30603. */
  30604. removeDragGradient(gradient: number): GPUParticleSystem;
  30605. /**
  30606. * Not supported by GPUParticleSystem
  30607. * @param gradient defines the gradient to use (between 0 and 1)
  30608. * @param factor defines the emit rate value to affect to the specified gradient
  30609. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30610. * @returns the current particle system
  30611. */
  30612. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30613. /**
  30614. * Not supported by GPUParticleSystem
  30615. * @param gradient defines the gradient to remove
  30616. * @returns the current particle system
  30617. */
  30618. removeEmitRateGradient(gradient: number): IParticleSystem;
  30619. /**
  30620. * Not supported by GPUParticleSystem
  30621. * @param gradient defines the gradient to use (between 0 and 1)
  30622. * @param factor defines the start size value to affect to the specified gradient
  30623. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30624. * @returns the current particle system
  30625. */
  30626. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30627. /**
  30628. * Not supported by GPUParticleSystem
  30629. * @param gradient defines the gradient to remove
  30630. * @returns the current particle system
  30631. */
  30632. removeStartSizeGradient(gradient: number): IParticleSystem;
  30633. /**
  30634. * Not supported by GPUParticleSystem
  30635. * @param gradient defines the gradient to use (between 0 and 1)
  30636. * @param min defines the color remap minimal range
  30637. * @param max defines the color remap maximal range
  30638. * @returns the current particle system
  30639. */
  30640. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30641. /**
  30642. * Not supported by GPUParticleSystem
  30643. * @param gradient defines the gradient to remove
  30644. * @returns the current particle system
  30645. */
  30646. removeColorRemapGradient(gradient: number): IParticleSystem;
  30647. /**
  30648. * Not supported by GPUParticleSystem
  30649. * @param gradient defines the gradient to use (between 0 and 1)
  30650. * @param min defines the alpha remap minimal range
  30651. * @param max defines the alpha remap maximal range
  30652. * @returns the current particle system
  30653. */
  30654. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30655. /**
  30656. * Not supported by GPUParticleSystem
  30657. * @param gradient defines the gradient to remove
  30658. * @returns the current particle system
  30659. */
  30660. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  30661. /**
  30662. * Not supported by GPUParticleSystem
  30663. * @param gradient defines the gradient to use (between 0 and 1)
  30664. * @param color defines the color to affect to the specified gradient
  30665. * @returns the current particle system
  30666. */
  30667. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  30668. /**
  30669. * Not supported by GPUParticleSystem
  30670. * @param gradient defines the gradient to remove
  30671. * @returns the current particle system
  30672. */
  30673. removeRampGradient(gradient: number): IParticleSystem;
  30674. /**
  30675. * Not supported by GPUParticleSystem
  30676. * @returns the list of ramp gradients
  30677. */
  30678. getRampGradients(): Nullable<Array<Color3Gradient>>;
  30679. /**
  30680. * Not supported by GPUParticleSystem
  30681. * Gets or sets a boolean indicating that ramp gradients must be used
  30682. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30683. */
  30684. useRampGradients: boolean;
  30685. /**
  30686. * Not supported by GPUParticleSystem
  30687. * @param gradient defines the gradient to use (between 0 and 1)
  30688. * @param factor defines the life time factor to affect to the specified gradient
  30689. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30690. * @returns the current particle system
  30691. */
  30692. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30693. /**
  30694. * Not supported by GPUParticleSystem
  30695. * @param gradient defines the gradient to remove
  30696. * @returns the current particle system
  30697. */
  30698. removeLifeTimeGradient(gradient: number): IParticleSystem;
  30699. /**
  30700. * Instantiates a GPU particle system.
  30701. * 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.
  30702. * @param name The name of the particle system
  30703. * @param options The options used to create the system
  30704. * @param scene The scene the particle system belongs to
  30705. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  30706. */
  30707. constructor(name: string, options: Partial<{
  30708. capacity: number;
  30709. randomTextureSize: number;
  30710. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  30711. protected _reset(): void;
  30712. private _createUpdateVAO;
  30713. private _createRenderVAO;
  30714. private _initialize;
  30715. /** @hidden */
  30716. _recreateUpdateEffect(): void;
  30717. /** @hidden */
  30718. _recreateRenderEffect(): void;
  30719. /**
  30720. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  30721. * @param preWarm defines if we are in the pre-warmimg phase
  30722. */
  30723. animate(preWarm?: boolean): void;
  30724. private _createFactorGradientTexture;
  30725. private _createSizeGradientTexture;
  30726. private _createAngularSpeedGradientTexture;
  30727. private _createVelocityGradientTexture;
  30728. private _createLimitVelocityGradientTexture;
  30729. private _createDragGradientTexture;
  30730. private _createColorGradientTexture;
  30731. /**
  30732. * Renders the particle system in its current state
  30733. * @param preWarm defines if the system should only update the particles but not render them
  30734. * @returns the current number of particles
  30735. */
  30736. render(preWarm?: boolean): number;
  30737. /**
  30738. * Rebuilds the particle system
  30739. */
  30740. rebuild(): void;
  30741. private _releaseBuffers;
  30742. private _releaseVAOs;
  30743. /**
  30744. * Disposes the particle system and free the associated resources
  30745. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  30746. */
  30747. dispose(disposeTexture?: boolean): void;
  30748. /**
  30749. * Clones the particle system.
  30750. * @param name The name of the cloned object
  30751. * @param newEmitter The new emitter to use
  30752. * @returns the cloned particle system
  30753. */
  30754. clone(name: string, newEmitter: any): GPUParticleSystem;
  30755. /**
  30756. * Serializes the particle system to a JSON object.
  30757. * @returns the JSON object
  30758. */
  30759. serialize(): any;
  30760. /**
  30761. * Parses a JSON object to create a GPU particle system.
  30762. * @param parsedParticleSystem The JSON object to parse
  30763. * @param scene The scene to create the particle system in
  30764. * @param rootUrl The root url to use to load external dependencies like texture
  30765. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  30766. * @returns the parsed GPU particle system
  30767. */
  30768. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  30769. }
  30770. }
  30771. declare module BABYLON {
  30772. /**
  30773. * Interface representing a particle system in Babylon.js.
  30774. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  30775. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  30776. */
  30777. interface IParticleSystem {
  30778. /**
  30779. * List of animations used by the particle system.
  30780. */
  30781. animations: Animation[];
  30782. /**
  30783. * The id of the Particle system.
  30784. */
  30785. id: string;
  30786. /**
  30787. * The name of the Particle system.
  30788. */
  30789. name: string;
  30790. /**
  30791. * The emitter represents the Mesh or position we are attaching the particle system to.
  30792. */
  30793. emitter: Nullable<AbstractMesh | Vector3>;
  30794. /**
  30795. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30796. */
  30797. isBillboardBased: boolean;
  30798. /**
  30799. * The rendering group used by the Particle system to chose when to render.
  30800. */
  30801. renderingGroupId: number;
  30802. /**
  30803. * The layer mask we are rendering the particles through.
  30804. */
  30805. layerMask: number;
  30806. /**
  30807. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30808. */
  30809. updateSpeed: number;
  30810. /**
  30811. * The amount of time the particle system is running (depends of the overall update speed).
  30812. */
  30813. targetStopDuration: number;
  30814. /**
  30815. * The texture used to render each particle. (this can be a spritesheet)
  30816. */
  30817. particleTexture: Nullable<Texture>;
  30818. /**
  30819. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  30820. */
  30821. blendMode: number;
  30822. /**
  30823. * Minimum life time of emitting particles.
  30824. */
  30825. minLifeTime: number;
  30826. /**
  30827. * Maximum life time of emitting particles.
  30828. */
  30829. maxLifeTime: number;
  30830. /**
  30831. * Minimum Size of emitting particles.
  30832. */
  30833. minSize: number;
  30834. /**
  30835. * Maximum Size of emitting particles.
  30836. */
  30837. maxSize: number;
  30838. /**
  30839. * Minimum scale of emitting particles on X axis.
  30840. */
  30841. minScaleX: number;
  30842. /**
  30843. * Maximum scale of emitting particles on X axis.
  30844. */
  30845. maxScaleX: number;
  30846. /**
  30847. * Minimum scale of emitting particles on Y axis.
  30848. */
  30849. minScaleY: number;
  30850. /**
  30851. * Maximum scale of emitting particles on Y axis.
  30852. */
  30853. maxScaleY: number;
  30854. /**
  30855. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  30856. */
  30857. color1: Color4;
  30858. /**
  30859. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  30860. */
  30861. color2: Color4;
  30862. /**
  30863. * Color the particle will have at the end of its lifetime.
  30864. */
  30865. colorDead: Color4;
  30866. /**
  30867. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  30868. */
  30869. emitRate: number;
  30870. /**
  30871. * You can use gravity if you want to give an orientation to your particles.
  30872. */
  30873. gravity: Vector3;
  30874. /**
  30875. * Minimum power of emitting particles.
  30876. */
  30877. minEmitPower: number;
  30878. /**
  30879. * Maximum power of emitting particles.
  30880. */
  30881. maxEmitPower: number;
  30882. /**
  30883. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30884. */
  30885. minAngularSpeed: number;
  30886. /**
  30887. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30888. */
  30889. maxAngularSpeed: number;
  30890. /**
  30891. * Gets or sets the minimal initial rotation in radians.
  30892. */
  30893. minInitialRotation: number;
  30894. /**
  30895. * Gets or sets the maximal initial rotation in radians.
  30896. */
  30897. maxInitialRotation: number;
  30898. /**
  30899. * The particle emitter type defines the emitter used by the particle system.
  30900. * It can be for example box, sphere, or cone...
  30901. */
  30902. particleEmitterType: Nullable<IParticleEmitterType>;
  30903. /**
  30904. * Defines the delay in milliseconds before starting the system (0 by default)
  30905. */
  30906. startDelay: number;
  30907. /**
  30908. * 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
  30909. */
  30910. preWarmCycles: number;
  30911. /**
  30912. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  30913. */
  30914. preWarmStepOffset: number;
  30915. /**
  30916. * 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)
  30917. */
  30918. spriteCellChangeSpeed: number;
  30919. /**
  30920. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30921. */
  30922. startSpriteCellID: number;
  30923. /**
  30924. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30925. */
  30926. endSpriteCellID: number;
  30927. /**
  30928. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30929. */
  30930. spriteCellWidth: number;
  30931. /**
  30932. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30933. */
  30934. spriteCellHeight: number;
  30935. /**
  30936. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30937. */
  30938. spriteRandomStartCell: boolean;
  30939. /**
  30940. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  30941. */
  30942. isAnimationSheetEnabled: boolean;
  30943. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30944. translationPivot: Vector2;
  30945. /**
  30946. * Gets or sets a texture used to add random noise to particle positions
  30947. */
  30948. noiseTexture: Nullable<BaseTexture>;
  30949. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30950. noiseStrength: Vector3;
  30951. /**
  30952. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30953. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30954. */
  30955. billboardMode: number;
  30956. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30957. limitVelocityDamping: number;
  30958. /**
  30959. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30960. */
  30961. beginAnimationOnStart: boolean;
  30962. /**
  30963. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30964. */
  30965. beginAnimationFrom: number;
  30966. /**
  30967. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30968. */
  30969. beginAnimationTo: number;
  30970. /**
  30971. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30972. */
  30973. beginAnimationLoop: boolean;
  30974. /**
  30975. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30976. */
  30977. disposeOnStop: boolean;
  30978. /**
  30979. * Gets the maximum number of particles active at the same time.
  30980. * @returns The max number of active particles.
  30981. */
  30982. getCapacity(): number;
  30983. /**
  30984. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30985. * @returns True if it has been started, otherwise false.
  30986. */
  30987. isStarted(): boolean;
  30988. /**
  30989. * Animates the particle system for this frame.
  30990. */
  30991. animate(): void;
  30992. /**
  30993. * Renders the particle system in its current state.
  30994. * @returns the current number of particles
  30995. */
  30996. render(): number;
  30997. /**
  30998. * Dispose the particle system and frees its associated resources.
  30999. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31000. */
  31001. dispose(disposeTexture?: boolean): void;
  31002. /**
  31003. * Clones the particle system.
  31004. * @param name The name of the cloned object
  31005. * @param newEmitter The new emitter to use
  31006. * @returns the cloned particle system
  31007. */
  31008. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  31009. /**
  31010. * Serializes the particle system to a JSON object.
  31011. * @returns the JSON object
  31012. */
  31013. serialize(): any;
  31014. /**
  31015. * Rebuild the particle system
  31016. */
  31017. rebuild(): void;
  31018. /**
  31019. * Starts the particle system and begins to emit
  31020. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  31021. */
  31022. start(delay?: number): void;
  31023. /**
  31024. * Stops the particle system.
  31025. */
  31026. stop(): void;
  31027. /**
  31028. * Remove all active particles
  31029. */
  31030. reset(): void;
  31031. /**
  31032. * Is this system ready to be used/rendered
  31033. * @return true if the system is ready
  31034. */
  31035. isReady(): boolean;
  31036. /**
  31037. * Adds a new color gradient
  31038. * @param gradient defines the gradient to use (between 0 and 1)
  31039. * @param color1 defines the color to affect to the specified gradient
  31040. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31041. * @returns the current particle system
  31042. */
  31043. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31044. /**
  31045. * Remove a specific color gradient
  31046. * @param gradient defines the gradient to remove
  31047. * @returns the current particle system
  31048. */
  31049. removeColorGradient(gradient: number): IParticleSystem;
  31050. /**
  31051. * Adds a new size gradient
  31052. * @param gradient defines the gradient to use (between 0 and 1)
  31053. * @param factor defines the size factor to affect to the specified gradient
  31054. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31055. * @returns the current particle system
  31056. */
  31057. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31058. /**
  31059. * Remove a specific size gradient
  31060. * @param gradient defines the gradient to remove
  31061. * @returns the current particle system
  31062. */
  31063. removeSizeGradient(gradient: number): IParticleSystem;
  31064. /**
  31065. * Gets the current list of color gradients.
  31066. * You must use addColorGradient and removeColorGradient to udpate this list
  31067. * @returns the list of color gradients
  31068. */
  31069. getColorGradients(): Nullable<Array<ColorGradient>>;
  31070. /**
  31071. * Gets the current list of size gradients.
  31072. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31073. * @returns the list of size gradients
  31074. */
  31075. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31076. /**
  31077. * Gets the current list of angular speed gradients.
  31078. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31079. * @returns the list of angular speed gradients
  31080. */
  31081. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31082. /**
  31083. * Adds a new angular speed gradient
  31084. * @param gradient defines the gradient to use (between 0 and 1)
  31085. * @param factor defines the angular speed to affect to the specified gradient
  31086. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31087. * @returns the current particle system
  31088. */
  31089. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31090. /**
  31091. * Remove a specific angular speed gradient
  31092. * @param gradient defines the gradient to remove
  31093. * @returns the current particle system
  31094. */
  31095. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31096. /**
  31097. * Gets the current list of velocity gradients.
  31098. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31099. * @returns the list of velocity gradients
  31100. */
  31101. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31102. /**
  31103. * Adds a new velocity gradient
  31104. * @param gradient defines the gradient to use (between 0 and 1)
  31105. * @param factor defines the velocity to affect to the specified gradient
  31106. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31107. * @returns the current particle system
  31108. */
  31109. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31110. /**
  31111. * Remove a specific velocity gradient
  31112. * @param gradient defines the gradient to remove
  31113. * @returns the current particle system
  31114. */
  31115. removeVelocityGradient(gradient: number): IParticleSystem;
  31116. /**
  31117. * Gets the current list of limit velocity gradients.
  31118. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31119. * @returns the list of limit velocity gradients
  31120. */
  31121. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31122. /**
  31123. * Adds a new limit velocity gradient
  31124. * @param gradient defines the gradient to use (between 0 and 1)
  31125. * @param factor defines the limit velocity to affect to the specified gradient
  31126. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31127. * @returns the current particle system
  31128. */
  31129. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31130. /**
  31131. * Remove a specific limit velocity gradient
  31132. * @param gradient defines the gradient to remove
  31133. * @returns the current particle system
  31134. */
  31135. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31136. /**
  31137. * Adds a new drag gradient
  31138. * @param gradient defines the gradient to use (between 0 and 1)
  31139. * @param factor defines the drag to affect to the specified gradient
  31140. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31141. * @returns the current particle system
  31142. */
  31143. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31144. /**
  31145. * Remove a specific drag gradient
  31146. * @param gradient defines the gradient to remove
  31147. * @returns the current particle system
  31148. */
  31149. removeDragGradient(gradient: number): IParticleSystem;
  31150. /**
  31151. * Gets the current list of drag gradients.
  31152. * You must use addDragGradient and removeDragGradient to udpate this list
  31153. * @returns the list of drag gradients
  31154. */
  31155. getDragGradients(): Nullable<Array<FactorGradient>>;
  31156. /**
  31157. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31158. * @param gradient defines the gradient to use (between 0 and 1)
  31159. * @param factor defines the emit rate to affect to the specified gradient
  31160. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31161. * @returns the current particle system
  31162. */
  31163. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31164. /**
  31165. * Remove a specific emit rate gradient
  31166. * @param gradient defines the gradient to remove
  31167. * @returns the current particle system
  31168. */
  31169. removeEmitRateGradient(gradient: number): IParticleSystem;
  31170. /**
  31171. * Gets the current list of emit rate gradients.
  31172. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31173. * @returns the list of emit rate gradients
  31174. */
  31175. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31176. /**
  31177. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31178. * @param gradient defines the gradient to use (between 0 and 1)
  31179. * @param factor defines the start size to affect to the specified gradient
  31180. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31181. * @returns the current particle system
  31182. */
  31183. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31184. /**
  31185. * Remove a specific start size gradient
  31186. * @param gradient defines the gradient to remove
  31187. * @returns the current particle system
  31188. */
  31189. removeStartSizeGradient(gradient: number): IParticleSystem;
  31190. /**
  31191. * Gets the current list of start size gradients.
  31192. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31193. * @returns the list of start size gradients
  31194. */
  31195. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31196. /**
  31197. * Adds a new life time gradient
  31198. * @param gradient defines the gradient to use (between 0 and 1)
  31199. * @param factor defines the life time factor to affect to the specified gradient
  31200. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31201. * @returns the current particle system
  31202. */
  31203. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31204. /**
  31205. * Remove a specific life time gradient
  31206. * @param gradient defines the gradient to remove
  31207. * @returns the current particle system
  31208. */
  31209. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31210. /**
  31211. * Gets the current list of life time gradients.
  31212. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31213. * @returns the list of life time gradients
  31214. */
  31215. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31216. /**
  31217. * Gets the current list of color gradients.
  31218. * You must use addColorGradient and removeColorGradient to udpate this list
  31219. * @returns the list of color gradients
  31220. */
  31221. getColorGradients(): Nullable<Array<ColorGradient>>;
  31222. /**
  31223. * Adds a new ramp gradient used to remap particle colors
  31224. * @param gradient defines the gradient to use (between 0 and 1)
  31225. * @param color defines the color to affect to the specified gradient
  31226. * @returns the current particle system
  31227. */
  31228. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31229. /**
  31230. * Gets the current list of ramp gradients.
  31231. * You must use addRampGradient and removeRampGradient to udpate this list
  31232. * @returns the list of ramp gradients
  31233. */
  31234. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31235. /** Gets or sets a boolean indicating that ramp gradients must be used
  31236. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31237. */
  31238. useRampGradients: boolean;
  31239. /**
  31240. * Adds a new color remap gradient
  31241. * @param gradient defines the gradient to use (between 0 and 1)
  31242. * @param min defines the color remap minimal range
  31243. * @param max defines the color remap maximal range
  31244. * @returns the current particle system
  31245. */
  31246. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31247. /**
  31248. * Gets the current list of color remap gradients.
  31249. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31250. * @returns the list of color remap gradients
  31251. */
  31252. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31253. /**
  31254. * Adds a new alpha remap gradient
  31255. * @param gradient defines the gradient to use (between 0 and 1)
  31256. * @param min defines the alpha remap minimal range
  31257. * @param max defines the alpha remap maximal range
  31258. * @returns the current particle system
  31259. */
  31260. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31261. /**
  31262. * Gets the current list of alpha remap gradients.
  31263. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31264. * @returns the list of alpha remap gradients
  31265. */
  31266. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31267. /**
  31268. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31269. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31270. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31271. * @returns the emitter
  31272. */
  31273. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31274. /**
  31275. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31276. * @param radius The radius of the hemisphere to emit from
  31277. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31278. * @returns the emitter
  31279. */
  31280. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  31281. /**
  31282. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31283. * @param radius The radius of the sphere to emit from
  31284. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31285. * @returns the emitter
  31286. */
  31287. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  31288. /**
  31289. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31290. * @param radius The radius of the sphere to emit from
  31291. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31292. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31293. * @returns the emitter
  31294. */
  31295. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31296. /**
  31297. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31298. * @param radius The radius of the emission cylinder
  31299. * @param height The height of the emission cylinder
  31300. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31301. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31302. * @returns the emitter
  31303. */
  31304. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  31305. /**
  31306. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31307. * @param radius The radius of the cylinder to emit from
  31308. * @param height The height of the emission cylinder
  31309. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31310. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31311. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31312. * @returns the emitter
  31313. */
  31314. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31315. /**
  31316. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31317. * @param radius The radius of the cone to emit from
  31318. * @param angle The base angle of the cone
  31319. * @returns the emitter
  31320. */
  31321. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  31322. /**
  31323. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31324. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31325. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31326. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31327. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31328. * @returns the emitter
  31329. */
  31330. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31331. /**
  31332. * Get hosting scene
  31333. * @returns the scene
  31334. */
  31335. getScene(): Scene;
  31336. }
  31337. }
  31338. declare module BABYLON {
  31339. /**
  31340. * A particle represents one of the element emitted by a particle system.
  31341. * This is mainly define by its coordinates, direction, velocity and age.
  31342. */
  31343. class Particle {
  31344. /**
  31345. * The particle system the particle belongs to.
  31346. */
  31347. particleSystem: ParticleSystem;
  31348. private static _Count;
  31349. /**
  31350. * Unique ID of the particle
  31351. */
  31352. id: number;
  31353. /**
  31354. * The world position of the particle in the scene.
  31355. */
  31356. position: Vector3;
  31357. /**
  31358. * The world direction of the particle in the scene.
  31359. */
  31360. direction: Vector3;
  31361. /**
  31362. * The color of the particle.
  31363. */
  31364. color: Color4;
  31365. /**
  31366. * The color change of the particle per step.
  31367. */
  31368. colorStep: Color4;
  31369. /**
  31370. * Defines how long will the life of the particle be.
  31371. */
  31372. lifeTime: number;
  31373. /**
  31374. * The current age of the particle.
  31375. */
  31376. age: number;
  31377. /**
  31378. * The current size of the particle.
  31379. */
  31380. size: number;
  31381. /**
  31382. * The current scale of the particle.
  31383. */
  31384. scale: Vector2;
  31385. /**
  31386. * The current angle of the particle.
  31387. */
  31388. angle: number;
  31389. /**
  31390. * Defines how fast is the angle changing.
  31391. */
  31392. angularSpeed: number;
  31393. /**
  31394. * Defines the cell index used by the particle to be rendered from a sprite.
  31395. */
  31396. cellIndex: number;
  31397. /**
  31398. * The information required to support color remapping
  31399. */
  31400. remapData: Vector4;
  31401. /** @hidden */
  31402. _randomCellOffset?: number;
  31403. /** @hidden */
  31404. _initialDirection: Nullable<Vector3>;
  31405. /** @hidden */
  31406. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  31407. /** @hidden */
  31408. _initialStartSpriteCellID: number;
  31409. /** @hidden */
  31410. _initialEndSpriteCellID: number;
  31411. /** @hidden */
  31412. _currentColorGradient: Nullable<ColorGradient>;
  31413. /** @hidden */
  31414. _currentColor1: Color4;
  31415. /** @hidden */
  31416. _currentColor2: Color4;
  31417. /** @hidden */
  31418. _currentSizeGradient: Nullable<FactorGradient>;
  31419. /** @hidden */
  31420. _currentSize1: number;
  31421. /** @hidden */
  31422. _currentSize2: number;
  31423. /** @hidden */
  31424. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  31425. /** @hidden */
  31426. _currentAngularSpeed1: number;
  31427. /** @hidden */
  31428. _currentAngularSpeed2: number;
  31429. /** @hidden */
  31430. _currentVelocityGradient: Nullable<FactorGradient>;
  31431. /** @hidden */
  31432. _currentVelocity1: number;
  31433. /** @hidden */
  31434. _currentVelocity2: number;
  31435. /** @hidden */
  31436. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  31437. /** @hidden */
  31438. _currentLimitVelocity1: number;
  31439. /** @hidden */
  31440. _currentLimitVelocity2: number;
  31441. /** @hidden */
  31442. _currentDragGradient: Nullable<FactorGradient>;
  31443. /** @hidden */
  31444. _currentDrag1: number;
  31445. /** @hidden */
  31446. _currentDrag2: number;
  31447. /** @hidden */
  31448. _randomNoiseCoordinates1: Vector3;
  31449. /** @hidden */
  31450. _randomNoiseCoordinates2: Vector3;
  31451. /**
  31452. * Creates a new instance Particle
  31453. * @param particleSystem the particle system the particle belongs to
  31454. */
  31455. constructor(
  31456. /**
  31457. * The particle system the particle belongs to.
  31458. */
  31459. particleSystem: ParticleSystem);
  31460. private updateCellInfoFromSystem;
  31461. /**
  31462. * Defines how the sprite cell index is updated for the particle
  31463. */
  31464. updateCellIndex(): void;
  31465. /** @hidden */
  31466. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  31467. /** @hidden */
  31468. _inheritParticleInfoToSubEmitters(): void;
  31469. /** @hidden */
  31470. _reset(): void;
  31471. /**
  31472. * Copy the properties of particle to another one.
  31473. * @param other the particle to copy the information to.
  31474. */
  31475. copyTo(other: Particle): void;
  31476. }
  31477. }
  31478. declare module BABYLON {
  31479. /**
  31480. * This class is made for on one-liner static method to help creating particle system set.
  31481. */
  31482. class ParticleHelper {
  31483. /**
  31484. * Gets or sets base Assets URL
  31485. */
  31486. static BaseAssetsUrl: string;
  31487. /**
  31488. * Create a default particle system that you can tweak
  31489. * @param emitter defines the emitter to use
  31490. * @param capacity defines the system capacity (default is 500 particles)
  31491. * @param scene defines the hosting scene
  31492. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  31493. * @returns the new Particle system
  31494. */
  31495. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  31496. /**
  31497. * This is the main static method (one-liner) of this helper to create different particle systems
  31498. * @param type This string represents the type to the particle system to create
  31499. * @param scene The scene where the particle system should live
  31500. * @param gpu If the system will use gpu
  31501. * @returns the ParticleSystemSet created
  31502. */
  31503. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  31504. /**
  31505. * Static function used to export a particle system to a ParticleSystemSet variable.
  31506. * Please note that the emitter shape is not exported
  31507. * @param systems defines the particle systems to export
  31508. * @returns the created particle system set
  31509. */
  31510. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  31511. }
  31512. }
  31513. declare module BABYLON {
  31514. /**
  31515. * This represents a particle system in Babylon.
  31516. * 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.
  31517. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31518. * @example https://doc.babylonjs.com/babylon101/particles
  31519. */
  31520. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  31521. /**
  31522. * Billboard mode will only apply to Y axis
  31523. */
  31524. static readonly BILLBOARDMODE_Y: number;
  31525. /**
  31526. * Billboard mode will apply to all axes
  31527. */
  31528. static readonly BILLBOARDMODE_ALL: number;
  31529. /**
  31530. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  31531. */
  31532. static readonly BILLBOARDMODE_STRETCHED: number;
  31533. /**
  31534. * This function can be defined to provide custom update for active particles.
  31535. * This function will be called instead of regular update (age, position, color, etc.).
  31536. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  31537. */
  31538. updateFunction: (particles: Particle[]) => void;
  31539. private _emitterWorldMatrix;
  31540. /**
  31541. * This function can be defined to specify initial direction for every new particle.
  31542. * It by default use the emitterType defined function
  31543. */
  31544. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  31545. /**
  31546. * This function can be defined to specify initial position for every new particle.
  31547. * It by default use the emitterType defined function
  31548. */
  31549. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  31550. /**
  31551. * @hidden
  31552. */
  31553. _inheritedVelocityOffset: Vector3;
  31554. /**
  31555. * An event triggered when the system is disposed
  31556. */
  31557. onDisposeObservable: Observable<ParticleSystem>;
  31558. private _onDisposeObserver;
  31559. /**
  31560. * Sets a callback that will be triggered when the system is disposed
  31561. */
  31562. onDispose: () => void;
  31563. private _particles;
  31564. private _epsilon;
  31565. private _capacity;
  31566. private _stockParticles;
  31567. private _newPartsExcess;
  31568. private _vertexData;
  31569. private _vertexBuffer;
  31570. private _vertexBuffers;
  31571. private _spriteBuffer;
  31572. private _indexBuffer;
  31573. private _effect;
  31574. private _customEffect;
  31575. private _cachedDefines;
  31576. private _scaledColorStep;
  31577. private _colorDiff;
  31578. private _scaledDirection;
  31579. private _scaledGravity;
  31580. private _currentRenderId;
  31581. private _alive;
  31582. private _useInstancing;
  31583. private _started;
  31584. private _stopped;
  31585. private _actualFrame;
  31586. private _scaledUpdateSpeed;
  31587. private _vertexBufferSize;
  31588. /** @hidden */
  31589. _currentEmitRateGradient: Nullable<FactorGradient>;
  31590. /** @hidden */
  31591. _currentEmitRate1: number;
  31592. /** @hidden */
  31593. _currentEmitRate2: number;
  31594. /** @hidden */
  31595. _currentStartSizeGradient: Nullable<FactorGradient>;
  31596. /** @hidden */
  31597. _currentStartSize1: number;
  31598. /** @hidden */
  31599. _currentStartSize2: number;
  31600. private readonly _rawTextureWidth;
  31601. private _rampGradientsTexture;
  31602. private _useRampGradients;
  31603. /** Gets or sets a boolean indicating that ramp gradients must be used
  31604. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31605. */
  31606. useRampGradients: boolean;
  31607. /**
  31608. * 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.
  31609. * 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: [])
  31610. */
  31611. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  31612. private _subEmitters;
  31613. /**
  31614. * @hidden
  31615. * If the particle systems emitter should be disposed when the particle system is disposed
  31616. */
  31617. _disposeEmitterOnDispose: boolean;
  31618. /**
  31619. * The current active Sub-systems, this property is used by the root particle system only.
  31620. */
  31621. activeSubSystems: Array<ParticleSystem>;
  31622. private _rootParticleSystem;
  31623. /**
  31624. * Gets the current list of active particles
  31625. */
  31626. readonly particles: Particle[];
  31627. /**
  31628. * Returns the string "ParticleSystem"
  31629. * @returns a string containing the class name
  31630. */
  31631. getClassName(): string;
  31632. /**
  31633. * Instantiates a particle system.
  31634. * 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.
  31635. * @param name The name of the particle system
  31636. * @param capacity The max number of particles alive at the same time
  31637. * @param scene The scene the particle system belongs to
  31638. * @param customEffect a custom effect used to change the way particles are rendered by default
  31639. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31640. * @param epsilon Offset used to render the particles
  31641. */
  31642. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  31643. private _addFactorGradient;
  31644. private _removeFactorGradient;
  31645. /**
  31646. * Adds a new life time gradient
  31647. * @param gradient defines the gradient to use (between 0 and 1)
  31648. * @param factor defines the life time factor to affect to the specified gradient
  31649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31650. * @returns the current particle system
  31651. */
  31652. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31653. /**
  31654. * Remove a specific life time gradient
  31655. * @param gradient defines the gradient to remove
  31656. * @returns the current particle system
  31657. */
  31658. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31659. /**
  31660. * Adds a new size gradient
  31661. * @param gradient defines the gradient to use (between 0 and 1)
  31662. * @param factor defines the size factor to affect to the specified gradient
  31663. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31664. * @returns the current particle system
  31665. */
  31666. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31667. /**
  31668. * Remove a specific size gradient
  31669. * @param gradient defines the gradient to remove
  31670. * @returns the current particle system
  31671. */
  31672. removeSizeGradient(gradient: number): IParticleSystem;
  31673. /**
  31674. * Adds a new color remap gradient
  31675. * @param gradient defines the gradient to use (between 0 and 1)
  31676. * @param min defines the color remap minimal range
  31677. * @param max defines the color remap maximal range
  31678. * @returns the current particle system
  31679. */
  31680. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31681. /**
  31682. * Remove a specific color remap gradient
  31683. * @param gradient defines the gradient to remove
  31684. * @returns the current particle system
  31685. */
  31686. removeColorRemapGradient(gradient: number): IParticleSystem;
  31687. /**
  31688. * Adds a new alpha remap gradient
  31689. * @param gradient defines the gradient to use (between 0 and 1)
  31690. * @param min defines the alpha remap minimal range
  31691. * @param max defines the alpha remap maximal range
  31692. * @returns the current particle system
  31693. */
  31694. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31695. /**
  31696. * Remove a specific alpha remap gradient
  31697. * @param gradient defines the gradient to remove
  31698. * @returns the current particle system
  31699. */
  31700. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31701. /**
  31702. * Adds a new angular speed gradient
  31703. * @param gradient defines the gradient to use (between 0 and 1)
  31704. * @param factor defines the angular speed to affect to the specified gradient
  31705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31706. * @returns the current particle system
  31707. */
  31708. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31709. /**
  31710. * Remove a specific angular speed gradient
  31711. * @param gradient defines the gradient to remove
  31712. * @returns the current particle system
  31713. */
  31714. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31715. /**
  31716. * Adds a new velocity gradient
  31717. * @param gradient defines the gradient to use (between 0 and 1)
  31718. * @param factor defines the velocity to affect to the specified gradient
  31719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31720. * @returns the current particle system
  31721. */
  31722. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31723. /**
  31724. * Remove a specific velocity gradient
  31725. * @param gradient defines the gradient to remove
  31726. * @returns the current particle system
  31727. */
  31728. removeVelocityGradient(gradient: number): IParticleSystem;
  31729. /**
  31730. * Adds a new limit velocity gradient
  31731. * @param gradient defines the gradient to use (between 0 and 1)
  31732. * @param factor defines the limit velocity value to affect to the specified gradient
  31733. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31734. * @returns the current particle system
  31735. */
  31736. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31737. /**
  31738. * Remove a specific limit velocity gradient
  31739. * @param gradient defines the gradient to remove
  31740. * @returns the current particle system
  31741. */
  31742. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31743. /**
  31744. * Adds a new drag gradient
  31745. * @param gradient defines the gradient to use (between 0 and 1)
  31746. * @param factor defines the drag value to affect to the specified gradient
  31747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31748. * @returns the current particle system
  31749. */
  31750. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31751. /**
  31752. * Remove a specific drag gradient
  31753. * @param gradient defines the gradient to remove
  31754. * @returns the current particle system
  31755. */
  31756. removeDragGradient(gradient: number): IParticleSystem;
  31757. /**
  31758. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31759. * @param gradient defines the gradient to use (between 0 and 1)
  31760. * @param factor defines the emit rate value to affect to the specified gradient
  31761. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31762. * @returns the current particle system
  31763. */
  31764. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31765. /**
  31766. * Remove a specific emit rate gradient
  31767. * @param gradient defines the gradient to remove
  31768. * @returns the current particle system
  31769. */
  31770. removeEmitRateGradient(gradient: number): IParticleSystem;
  31771. /**
  31772. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31773. * @param gradient defines the gradient to use (between 0 and 1)
  31774. * @param factor defines the start size value to affect to the specified gradient
  31775. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31776. * @returns the current particle system
  31777. */
  31778. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31779. /**
  31780. * Remove a specific start size gradient
  31781. * @param gradient defines the gradient to remove
  31782. * @returns the current particle system
  31783. */
  31784. removeStartSizeGradient(gradient: number): IParticleSystem;
  31785. private _createRampGradientTexture;
  31786. /**
  31787. * Gets the current list of ramp gradients.
  31788. * You must use addRampGradient and removeRampGradient to udpate this list
  31789. * @returns the list of ramp gradients
  31790. */
  31791. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31792. /**
  31793. * Adds a new ramp gradient used to remap particle colors
  31794. * @param gradient defines the gradient to use (between 0 and 1)
  31795. * @param color defines the color to affect to the specified gradient
  31796. * @returns the current particle system
  31797. */
  31798. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  31799. /**
  31800. * Remove a specific ramp gradient
  31801. * @param gradient defines the gradient to remove
  31802. * @returns the current particle system
  31803. */
  31804. removeRampGradient(gradient: number): ParticleSystem;
  31805. /**
  31806. * Adds a new color gradient
  31807. * @param gradient defines the gradient to use (between 0 and 1)
  31808. * @param color1 defines the color to affect to the specified gradient
  31809. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31810. * @returns this particle system
  31811. */
  31812. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31813. /**
  31814. * Remove a specific color gradient
  31815. * @param gradient defines the gradient to remove
  31816. * @returns this particle system
  31817. */
  31818. removeColorGradient(gradient: number): IParticleSystem;
  31819. private _fetchR;
  31820. protected _reset(): void;
  31821. private _resetEffect;
  31822. private _createVertexBuffers;
  31823. private _createIndexBuffer;
  31824. /**
  31825. * Gets the maximum number of particles active at the same time.
  31826. * @returns The max number of active particles.
  31827. */
  31828. getCapacity(): number;
  31829. /**
  31830. * Gets whether there are still active particles in the system.
  31831. * @returns True if it is alive, otherwise false.
  31832. */
  31833. isAlive(): boolean;
  31834. /**
  31835. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31836. * @returns True if it has been started, otherwise false.
  31837. */
  31838. isStarted(): boolean;
  31839. private _prepareSubEmitterInternalArray;
  31840. /**
  31841. * Starts the particle system and begins to emit
  31842. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  31843. */
  31844. start(delay?: number): void;
  31845. /**
  31846. * Stops the particle system.
  31847. * @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.
  31848. */
  31849. stop(stopSubEmitters?: boolean): void;
  31850. /**
  31851. * Remove all active particles
  31852. */
  31853. reset(): void;
  31854. /**
  31855. * @hidden (for internal use only)
  31856. */
  31857. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  31858. /**
  31859. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  31860. * Its lifetime will start back at 0.
  31861. */
  31862. recycleParticle: (particle: Particle) => void;
  31863. private _stopSubEmitters;
  31864. private _createParticle;
  31865. private _removeFromRoot;
  31866. private _emitFromParticle;
  31867. private _update;
  31868. /** @hidden */
  31869. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  31870. /** @hidden */
  31871. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  31872. /** @hidden */
  31873. private _getEffect;
  31874. /**
  31875. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  31876. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  31877. */
  31878. animate(preWarmOnly?: boolean): void;
  31879. private _appendParticleVertices;
  31880. /**
  31881. * Rebuilds the particle system.
  31882. */
  31883. rebuild(): void;
  31884. /**
  31885. * Is this system ready to be used/rendered
  31886. * @return true if the system is ready
  31887. */
  31888. isReady(): boolean;
  31889. private _render;
  31890. /**
  31891. * Renders the particle system in its current state.
  31892. * @returns the current number of particles
  31893. */
  31894. render(): number;
  31895. /**
  31896. * Disposes the particle system and free the associated resources
  31897. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31898. */
  31899. dispose(disposeTexture?: boolean): void;
  31900. /**
  31901. * Clones the particle system.
  31902. * @param name The name of the cloned object
  31903. * @param newEmitter The new emitter to use
  31904. * @returns the cloned particle system
  31905. */
  31906. clone(name: string, newEmitter: any): ParticleSystem;
  31907. /**
  31908. * Serializes the particle system to a JSON object.
  31909. * @returns the JSON object
  31910. */
  31911. serialize(): any;
  31912. /** @hidden */
  31913. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  31914. /** @hidden */
  31915. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  31916. /**
  31917. * Parses a JSON object to create a particle system.
  31918. * @param parsedParticleSystem The JSON object to parse
  31919. * @param scene The scene to create the particle system in
  31920. * @param rootUrl The root url to use to load external dependencies like texture
  31921. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  31922. * @returns the Parsed particle system
  31923. */
  31924. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  31925. }
  31926. }
  31927. declare module BABYLON {
  31928. interface Engine {
  31929. /**
  31930. * Create an effect to use with particle systems.
  31931. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  31932. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  31933. * @param uniformsNames defines a list of attribute names
  31934. * @param samplers defines an array of string used to represent textures
  31935. * @param defines defines the string containing the defines to use to compile the shaders
  31936. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31937. * @param onCompiled defines a function to call when the effect creation is successful
  31938. * @param onError defines a function to call when the effect creation has failed
  31939. * @returns the new Effect
  31940. */
  31941. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  31942. }
  31943. interface Mesh {
  31944. /**
  31945. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  31946. * @returns an array of IParticleSystem
  31947. */
  31948. getEmittedParticleSystems(): IParticleSystem[];
  31949. /**
  31950. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  31951. * @returns an array of IParticleSystem
  31952. */
  31953. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  31954. }
  31955. }
  31956. declare module BABYLON {
  31957. /**
  31958. * Represents a set of particle systems working together to create a specific effect
  31959. */
  31960. class ParticleSystemSet implements IDisposable {
  31961. private _emitterCreationOptions;
  31962. private _emitterNode;
  31963. /**
  31964. * Gets the particle system list
  31965. */
  31966. systems: IParticleSystem[];
  31967. /**
  31968. * Gets the emitter node used with this set
  31969. */
  31970. readonly emitterNode: Nullable<TransformNode>;
  31971. /**
  31972. * Creates a new emitter mesh as a sphere
  31973. * @param options defines the options used to create the sphere
  31974. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  31975. * @param scene defines the hosting scene
  31976. */
  31977. setEmitterAsSphere(options: {
  31978. diameter: number;
  31979. segments: number;
  31980. color: Color3;
  31981. }, renderingGroupId: number, scene: Scene): void;
  31982. /**
  31983. * Starts all particle systems of the set
  31984. * @param emitter defines an optional mesh to use as emitter for the particle systems
  31985. */
  31986. start(emitter?: AbstractMesh): void;
  31987. /**
  31988. * Release all associated resources
  31989. */
  31990. dispose(): void;
  31991. /**
  31992. * Serialize the set into a JSON compatible object
  31993. * @returns a JSON compatible representation of the set
  31994. */
  31995. serialize(): any;
  31996. /**
  31997. * Parse a new ParticleSystemSet from a serialized source
  31998. * @param data defines a JSON compatible representation of the set
  31999. * @param scene defines the hosting scene
  32000. * @param gpu defines if we want GPU particles or CPU particles
  32001. * @returns a new ParticleSystemSet
  32002. */
  32003. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  32004. }
  32005. }
  32006. declare module BABYLON {
  32007. /**
  32008. * Represents one particle of a solid particle system.
  32009. */
  32010. class SolidParticle {
  32011. /**
  32012. * particle global index
  32013. */
  32014. idx: number;
  32015. /**
  32016. * The color of the particle
  32017. */
  32018. color: Nullable<Color4>;
  32019. /**
  32020. * The world space position of the particle.
  32021. */
  32022. position: Vector3;
  32023. /**
  32024. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32025. */
  32026. rotation: Vector3;
  32027. /**
  32028. * The world space rotation quaternion of the particle.
  32029. */
  32030. rotationQuaternion: Nullable<Quaternion>;
  32031. /**
  32032. * The scaling of the particle.
  32033. */
  32034. scaling: Vector3;
  32035. /**
  32036. * The uvs of the particle.
  32037. */
  32038. uvs: Vector4;
  32039. /**
  32040. * The current speed of the particle.
  32041. */
  32042. velocity: Vector3;
  32043. /**
  32044. * The pivot point in the particle local space.
  32045. */
  32046. pivot: Vector3;
  32047. /**
  32048. * Must the particle be translated from its pivot point in its local space ?
  32049. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32050. * Default : false
  32051. */
  32052. translateFromPivot: boolean;
  32053. /**
  32054. * Is the particle active or not ?
  32055. */
  32056. alive: boolean;
  32057. /**
  32058. * Is the particle visible or not ?
  32059. */
  32060. isVisible: boolean;
  32061. /**
  32062. * Index of this particle in the global "positions" array (Internal use)
  32063. * @hidden
  32064. */
  32065. _pos: number;
  32066. /**
  32067. * @hidden Index of this particle in the global "indices" array (Internal use)
  32068. */
  32069. _ind: number;
  32070. /**
  32071. * @hidden ModelShape of this particle (Internal use)
  32072. */
  32073. _model: ModelShape;
  32074. /**
  32075. * ModelShape id of this particle
  32076. */
  32077. shapeId: number;
  32078. /**
  32079. * Index of the particle in its shape id (Internal use)
  32080. */
  32081. idxInShape: number;
  32082. /**
  32083. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32084. */
  32085. _modelBoundingInfo: BoundingInfo;
  32086. /**
  32087. * @hidden Particle BoundingInfo object (Internal use)
  32088. */
  32089. _boundingInfo: BoundingInfo;
  32090. /**
  32091. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32092. */
  32093. _sps: SolidParticleSystem;
  32094. /**
  32095. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32096. */
  32097. _stillInvisible: boolean;
  32098. /**
  32099. * @hidden Last computed particle rotation matrix
  32100. */
  32101. _rotationMatrix: number[];
  32102. /**
  32103. * Parent particle Id, if any.
  32104. * Default null.
  32105. */
  32106. parentId: Nullable<number>;
  32107. /**
  32108. * @hidden Internal global position in the SPS.
  32109. */
  32110. _globalPosition: Vector3;
  32111. /**
  32112. * Creates a Solid Particle object.
  32113. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32114. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  32115. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32116. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32117. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32118. * @param shapeId (integer) is the model shape identifier in the SPS.
  32119. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32120. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32121. */
  32122. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  32123. /**
  32124. * Legacy support, changed scale to scaling
  32125. */
  32126. /**
  32127. * Legacy support, changed scale to scaling
  32128. */
  32129. scale: Vector3;
  32130. /**
  32131. * Legacy support, changed quaternion to rotationQuaternion
  32132. */
  32133. /**
  32134. * Legacy support, changed quaternion to rotationQuaternion
  32135. */
  32136. quaternion: Nullable<Quaternion>;
  32137. /**
  32138. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32139. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32140. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32141. * @returns true if it intersects
  32142. */
  32143. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32144. /**
  32145. * get the rotation matrix of the particle
  32146. * @hidden
  32147. */
  32148. getRotationMatrix(m: Matrix): void;
  32149. }
  32150. /**
  32151. * Represents the shape of the model used by one particle of a solid particle system.
  32152. * SPS internal tool, don't use it manually.
  32153. */
  32154. class ModelShape {
  32155. /**
  32156. * The shape id
  32157. * @hidden
  32158. */
  32159. shapeID: number;
  32160. /**
  32161. * flat array of model positions (internal use)
  32162. * @hidden
  32163. */
  32164. _shape: Vector3[];
  32165. /**
  32166. * flat array of model UVs (internal use)
  32167. * @hidden
  32168. */
  32169. _shapeUV: number[];
  32170. /**
  32171. * length of the shape in the model indices array (internal use)
  32172. * @hidden
  32173. */
  32174. _indicesLength: number;
  32175. /**
  32176. * Custom position function (internal use)
  32177. * @hidden
  32178. */
  32179. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32180. /**
  32181. * Custom vertex function (internal use)
  32182. * @hidden
  32183. */
  32184. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32185. /**
  32186. * 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.
  32187. * SPS internal tool, don't use it manually.
  32188. * @hidden
  32189. */
  32190. 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>);
  32191. }
  32192. /**
  32193. * Represents a Depth Sorted Particle in the solid particle system.
  32194. */
  32195. class DepthSortedParticle {
  32196. /**
  32197. * Index of the particle in the "indices" array
  32198. */
  32199. ind: number;
  32200. /**
  32201. * Length of the particle shape in the "indices" array
  32202. */
  32203. indicesLength: number;
  32204. /**
  32205. * Squared distance from the particle to the camera
  32206. */
  32207. sqDistance: number;
  32208. }
  32209. }
  32210. declare module BABYLON {
  32211. /**
  32212. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32213. *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.
  32214. * The SPS is also a particle system. It provides some methods to manage the particles.
  32215. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32216. *
  32217. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  32218. */
  32219. class SolidParticleSystem implements IDisposable {
  32220. /**
  32221. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32222. * Example : var p = SPS.particles[i];
  32223. */
  32224. particles: SolidParticle[];
  32225. /**
  32226. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32227. */
  32228. nbParticles: number;
  32229. /**
  32230. * If the particles must ever face the camera (default false). Useful for planar particles.
  32231. */
  32232. billboard: boolean;
  32233. /**
  32234. * Recompute normals when adding a shape
  32235. */
  32236. recomputeNormals: boolean;
  32237. /**
  32238. * This a counter ofr your own usage. It's not set by any SPS functions.
  32239. */
  32240. counter: number;
  32241. /**
  32242. * The SPS name. This name is also given to the underlying mesh.
  32243. */
  32244. name: string;
  32245. /**
  32246. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32247. */
  32248. mesh: Mesh;
  32249. /**
  32250. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32251. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  32252. */
  32253. vars: any;
  32254. /**
  32255. * This array is populated when the SPS is set as 'pickable'.
  32256. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32257. * Each element of this array is an object `{idx: int, faceId: int}`.
  32258. * `idx` is the picked particle index in the `SPS.particles` array
  32259. * `faceId` is the picked face index counted within this particle.
  32260. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  32261. */
  32262. pickedParticles: {
  32263. idx: number;
  32264. faceId: number;
  32265. }[];
  32266. /**
  32267. * This array is populated when `enableDepthSort` is set to true.
  32268. * Each element of this array is an instance of the class DepthSortedParticle.
  32269. */
  32270. depthSortedParticles: DepthSortedParticle[];
  32271. /**
  32272. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32273. * @hidden
  32274. */
  32275. _bSphereOnly: boolean;
  32276. /**
  32277. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32278. * @hidden
  32279. */
  32280. _bSphereRadiusFactor: number;
  32281. private _scene;
  32282. private _positions;
  32283. private _indices;
  32284. private _normals;
  32285. private _colors;
  32286. private _uvs;
  32287. private _indices32;
  32288. private _positions32;
  32289. private _normals32;
  32290. private _fixedNormal32;
  32291. private _colors32;
  32292. private _uvs32;
  32293. private _index;
  32294. private _updatable;
  32295. private _pickable;
  32296. private _isVisibilityBoxLocked;
  32297. private _alwaysVisible;
  32298. private _depthSort;
  32299. private _shapeCounter;
  32300. private _copy;
  32301. private _color;
  32302. private _computeParticleColor;
  32303. private _computeParticleTexture;
  32304. private _computeParticleRotation;
  32305. private _computeParticleVertex;
  32306. private _computeBoundingBox;
  32307. private _depthSortParticles;
  32308. private _camera;
  32309. private _mustUnrotateFixedNormals;
  32310. private _particlesIntersect;
  32311. private _needs32Bits;
  32312. /**
  32313. * Creates a SPS (Solid Particle System) object.
  32314. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32315. * @param scene (Scene) is the scene in which the SPS is added.
  32316. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32317. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32318. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32319. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32320. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32321. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32322. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32323. */
  32324. constructor(name: string, scene: Scene, options?: {
  32325. updatable?: boolean;
  32326. isPickable?: boolean;
  32327. enableDepthSort?: boolean;
  32328. particleIntersection?: boolean;
  32329. boundingSphereOnly?: boolean;
  32330. bSphereRadiusFactor?: number;
  32331. });
  32332. /**
  32333. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32334. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32335. * @returns the created mesh
  32336. */
  32337. buildMesh(): Mesh;
  32338. /**
  32339. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32340. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32341. * Thus the particles generated from `digest()` have their property `position` set yet.
  32342. * @param mesh ( Mesh ) is the mesh to be digested
  32343. * @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
  32344. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32345. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32346. * @returns the current SPS
  32347. */
  32348. digest(mesh: Mesh, options?: {
  32349. facetNb?: number;
  32350. number?: number;
  32351. delta?: number;
  32352. }): SolidParticleSystem;
  32353. private _unrotateFixedNormals;
  32354. private _resetCopy;
  32355. private _meshBuilder;
  32356. private _posToShape;
  32357. private _uvsToShapeUV;
  32358. private _addParticle;
  32359. /**
  32360. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32361. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  32362. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32363. * @param nb (positive integer) the number of particles to be created from this model
  32364. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32365. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32366. * @returns the number of shapes in the system
  32367. */
  32368. addShape(mesh: Mesh, nb: number, options?: {
  32369. positionFunction?: any;
  32370. vertexFunction?: any;
  32371. }): number;
  32372. private _rebuildParticle;
  32373. /**
  32374. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32375. * @returns the SPS.
  32376. */
  32377. rebuildMesh(): SolidParticleSystem;
  32378. /**
  32379. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32380. * This method calls `updateParticle()` for each particle of the SPS.
  32381. * For an animated SPS, it is usually called within the render loop.
  32382. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32383. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32384. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32385. * @returns the SPS.
  32386. */
  32387. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32388. /**
  32389. * Disposes the SPS.
  32390. */
  32391. dispose(): void;
  32392. /**
  32393. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32394. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32395. * @returns the SPS.
  32396. */
  32397. refreshVisibleSize(): SolidParticleSystem;
  32398. /**
  32399. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32400. * @param size the size (float) of the visibility box
  32401. * note : this doesn't lock the SPS mesh bounding box.
  32402. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32403. */
  32404. setVisibilityBox(size: number): void;
  32405. /**
  32406. * Gets whether the SPS as always visible or not
  32407. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32408. */
  32409. /**
  32410. * Sets the SPS as always visible or not
  32411. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32412. */
  32413. isAlwaysVisible: boolean;
  32414. /**
  32415. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32416. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32417. */
  32418. /**
  32419. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32420. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32421. */
  32422. isVisibilityBoxLocked: boolean;
  32423. /**
  32424. * Tells to `setParticles()` to compute the particle rotations or not.
  32425. * Default value : true. The SPS is faster when it's set to false.
  32426. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32427. */
  32428. /**
  32429. * Gets if `setParticles()` computes the particle rotations or not.
  32430. * Default value : true. The SPS is faster when it's set to false.
  32431. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32432. */
  32433. computeParticleRotation: boolean;
  32434. /**
  32435. * Tells to `setParticles()` to compute the particle colors or not.
  32436. * Default value : true. The SPS is faster when it's set to false.
  32437. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32438. */
  32439. /**
  32440. * Gets if `setParticles()` computes the particle colors or not.
  32441. * Default value : true. The SPS is faster when it's set to false.
  32442. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32443. */
  32444. computeParticleColor: boolean;
  32445. /**
  32446. * Gets if `setParticles()` computes the particle textures or not.
  32447. * Default value : true. The SPS is faster when it's set to false.
  32448. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32449. */
  32450. computeParticleTexture: boolean;
  32451. /**
  32452. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32453. * Default value : false. The SPS is faster when it's set to false.
  32454. * Note : the particle custom vertex positions aren't stored values.
  32455. */
  32456. /**
  32457. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32458. * Default value : false. The SPS is faster when it's set to false.
  32459. * Note : the particle custom vertex positions aren't stored values.
  32460. */
  32461. computeParticleVertex: boolean;
  32462. /**
  32463. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32464. */
  32465. /**
  32466. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32467. */
  32468. computeBoundingBox: boolean;
  32469. /**
  32470. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32471. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32472. * Default : `true`
  32473. */
  32474. /**
  32475. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32476. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32477. * Default : `true`
  32478. */
  32479. depthSortParticles: boolean;
  32480. /**
  32481. * This function does nothing. It may be overwritten to set all the particle first values.
  32482. * The SPS doesn't call this function, you may have to call it by your own.
  32483. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32484. */
  32485. initParticles(): void;
  32486. /**
  32487. * This function does nothing. It may be overwritten to recycle a particle.
  32488. * The SPS doesn't call this function, you may have to call it by your own.
  32489. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32490. * @param particle The particle to recycle
  32491. * @returns the recycled particle
  32492. */
  32493. recycleParticle(particle: SolidParticle): SolidParticle;
  32494. /**
  32495. * Updates a particle : this function should be overwritten by the user.
  32496. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32497. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32498. * @example : just set a particle position or velocity and recycle conditions
  32499. * @param particle The particle to update
  32500. * @returns the updated particle
  32501. */
  32502. updateParticle(particle: SolidParticle): SolidParticle;
  32503. /**
  32504. * Updates a vertex of a particle : it can be overwritten by the user.
  32505. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32506. * @param particle the current particle
  32507. * @param vertex the current index of the current particle
  32508. * @param pt the index of the current vertex in the particle shape
  32509. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  32510. * @example : just set a vertex particle position
  32511. * @returns the updated vertex
  32512. */
  32513. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  32514. /**
  32515. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32516. * This does nothing and may be overwritten by the user.
  32517. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32518. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32519. * @param update the boolean update value actually passed to setParticles()
  32520. */
  32521. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32522. /**
  32523. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32524. * This will be passed three parameters.
  32525. * This does nothing and may be overwritten by the user.
  32526. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32527. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32528. * @param update the boolean update value actually passed to setParticles()
  32529. */
  32530. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32531. }
  32532. }
  32533. declare module BABYLON {
  32534. /**
  32535. * Type of sub emitter
  32536. */
  32537. enum SubEmitterType {
  32538. /**
  32539. * Attached to the particle over it's lifetime
  32540. */
  32541. ATTACHED = 0,
  32542. /**
  32543. * Created when the particle dies
  32544. */
  32545. END = 1
  32546. }
  32547. /**
  32548. * Sub emitter class used to emit particles from an existing particle
  32549. */
  32550. class SubEmitter {
  32551. /**
  32552. * the particle system to be used by the sub emitter
  32553. */
  32554. particleSystem: ParticleSystem;
  32555. /**
  32556. * Type of the submitter (Default: END)
  32557. */
  32558. type: SubEmitterType;
  32559. /**
  32560. * 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)
  32561. * Note: This only is supported when using an emitter of type Mesh
  32562. */
  32563. inheritDirection: boolean;
  32564. /**
  32565. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  32566. */
  32567. inheritedVelocityAmount: number;
  32568. /**
  32569. * Creates a sub emitter
  32570. * @param particleSystem the particle system to be used by the sub emitter
  32571. */
  32572. constructor(
  32573. /**
  32574. * the particle system to be used by the sub emitter
  32575. */
  32576. particleSystem: ParticleSystem);
  32577. /**
  32578. * Clones the sub emitter
  32579. * @returns the cloned sub emitter
  32580. */
  32581. clone(): SubEmitter;
  32582. /**
  32583. * Serialize current object to a JSON object
  32584. * @returns the serialized object
  32585. */
  32586. serialize(): any;
  32587. /**
  32588. * Creates a new SubEmitter from a serialized JSON version
  32589. * @param serializationObject defines the JSON object to read from
  32590. * @param scene defines the hosting scene
  32591. * @param rootUrl defines the rootUrl for data loading
  32592. * @returns a new SubEmitter
  32593. */
  32594. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  32595. /** Release associated resources */
  32596. dispose(): void;
  32597. }
  32598. }
  32599. declare module BABYLON {
  32600. /**
  32601. * Interface used to describe a physics joint
  32602. */
  32603. interface PhysicsImpostorJoint {
  32604. /** Defines the main impostor to which the joint is linked */
  32605. mainImpostor: PhysicsImpostor;
  32606. /** Defines the impostor that is connected to the main impostor using this joint */
  32607. connectedImpostor: PhysicsImpostor;
  32608. /** Defines the joint itself */
  32609. joint: PhysicsJoint;
  32610. }
  32611. /** @hidden */
  32612. interface IPhysicsEnginePlugin {
  32613. world: any;
  32614. name: string;
  32615. setGravity(gravity: Vector3): void;
  32616. setTimeStep(timeStep: number): void;
  32617. getTimeStep(): number;
  32618. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32619. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32620. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32621. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32622. removePhysicsBody(impostor: PhysicsImpostor): void;
  32623. generateJoint(joint: PhysicsImpostorJoint): void;
  32624. removeJoint(joint: PhysicsImpostorJoint): void;
  32625. isSupported(): boolean;
  32626. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32627. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32628. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32629. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32630. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32631. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32632. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32633. getBodyMass(impostor: PhysicsImpostor): number;
  32634. getBodyFriction(impostor: PhysicsImpostor): number;
  32635. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32636. getBodyRestitution(impostor: PhysicsImpostor): number;
  32637. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32638. sleepBody(impostor: PhysicsImpostor): void;
  32639. wakeUpBody(impostor: PhysicsImpostor): void;
  32640. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32641. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32642. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32643. getRadius(impostor: PhysicsImpostor): number;
  32644. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32645. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32646. dispose(): void;
  32647. }
  32648. /**
  32649. * Interface used to define a physics engine
  32650. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32651. */
  32652. interface IPhysicsEngine {
  32653. /**
  32654. * Gets the gravity vector used by the simulation
  32655. */
  32656. gravity: Vector3;
  32657. /**
  32658. * Sets the gravity vector used by the simulation
  32659. * @param gravity defines the gravity vector to use
  32660. */
  32661. setGravity(gravity: Vector3): void;
  32662. /**
  32663. * Set the time step of the physics engine.
  32664. * Default is 1/60.
  32665. * To slow it down, enter 1/600 for example.
  32666. * To speed it up, 1/30
  32667. * @param newTimeStep the new timestep to apply to this world.
  32668. */
  32669. setTimeStep(newTimeStep: number): void;
  32670. /**
  32671. * Get the time step of the physics engine.
  32672. * @returns the current time step
  32673. */
  32674. getTimeStep(): number;
  32675. /**
  32676. * Release all resources
  32677. */
  32678. dispose(): void;
  32679. /**
  32680. * Gets the name of the current physics plugin
  32681. * @returns the name of the plugin
  32682. */
  32683. getPhysicsPluginName(): string;
  32684. /**
  32685. * Adding a new impostor for the impostor tracking.
  32686. * This will be done by the impostor itself.
  32687. * @param impostor the impostor to add
  32688. */
  32689. addImpostor(impostor: PhysicsImpostor): void;
  32690. /**
  32691. * Remove an impostor from the engine.
  32692. * This impostor and its mesh will not longer be updated by the physics engine.
  32693. * @param impostor the impostor to remove
  32694. */
  32695. removeImpostor(impostor: PhysicsImpostor): void;
  32696. /**
  32697. * Add a joint to the physics engine
  32698. * @param mainImpostor defines the main impostor to which the joint is added.
  32699. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32700. * @param joint defines the joint that will connect both impostors.
  32701. */
  32702. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32703. /**
  32704. * Removes a joint from the simulation
  32705. * @param mainImpostor defines the impostor used with the joint
  32706. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32707. * @param joint defines the joint to remove
  32708. */
  32709. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32710. /**
  32711. * Gets the current plugin used to run the simulation
  32712. * @returns current plugin
  32713. */
  32714. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32715. /**
  32716. * Gets the list of physic impostors
  32717. * @returns an array of PhysicsImpostor
  32718. */
  32719. getImpostors(): Array<PhysicsImpostor>;
  32720. /**
  32721. * Gets the impostor for a physics enabled object
  32722. * @param object defines the object impersonated by the impostor
  32723. * @returns the PhysicsImpostor or null if not found
  32724. */
  32725. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32726. /**
  32727. * Gets the impostor for a physics body object
  32728. * @param body defines physics body used by the impostor
  32729. * @returns the PhysicsImpostor or null if not found
  32730. */
  32731. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32732. /**
  32733. * Called by the scene. No need to call it.
  32734. * @param delta defines the timespam between frames
  32735. */
  32736. _step(delta: number): void;
  32737. }
  32738. }
  32739. declare module BABYLON {
  32740. /**
  32741. * Class used to control physics engine
  32742. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32743. */
  32744. class PhysicsEngine implements IPhysicsEngine {
  32745. private _physicsPlugin;
  32746. /**
  32747. * Global value used to control the smallest number supported by the simulation
  32748. */
  32749. static Epsilon: number;
  32750. private _impostors;
  32751. private _joints;
  32752. /**
  32753. * Gets the gravity vector used by the simulation
  32754. */
  32755. gravity: Vector3;
  32756. /**
  32757. * Creates a new Physics Engine
  32758. * @param gravity defines the gravity vector used by the simulation
  32759. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  32760. */
  32761. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  32762. /**
  32763. * Sets the gravity vector used by the simulation
  32764. * @param gravity defines the gravity vector to use
  32765. */
  32766. setGravity(gravity: Vector3): void;
  32767. /**
  32768. * Set the time step of the physics engine.
  32769. * Default is 1/60.
  32770. * To slow it down, enter 1/600 for example.
  32771. * To speed it up, 1/30
  32772. * @param newTimeStep defines the new timestep to apply to this world.
  32773. */
  32774. setTimeStep(newTimeStep?: number): void;
  32775. /**
  32776. * Get the time step of the physics engine.
  32777. * @returns the current time step
  32778. */
  32779. getTimeStep(): number;
  32780. /**
  32781. * Release all resources
  32782. */
  32783. dispose(): void;
  32784. /**
  32785. * Gets the name of the current physics plugin
  32786. * @returns the name of the plugin
  32787. */
  32788. getPhysicsPluginName(): string;
  32789. /**
  32790. * Adding a new impostor for the impostor tracking.
  32791. * This will be done by the impostor itself.
  32792. * @param impostor the impostor to add
  32793. */
  32794. addImpostor(impostor: PhysicsImpostor): void;
  32795. /**
  32796. * Remove an impostor from the engine.
  32797. * This impostor and its mesh will not longer be updated by the physics engine.
  32798. * @param impostor the impostor to remove
  32799. */
  32800. removeImpostor(impostor: PhysicsImpostor): void;
  32801. /**
  32802. * Add a joint to the physics engine
  32803. * @param mainImpostor defines the main impostor to which the joint is added.
  32804. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32805. * @param joint defines the joint that will connect both impostors.
  32806. */
  32807. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32808. /**
  32809. * Removes a joint from the simulation
  32810. * @param mainImpostor defines the impostor used with the joint
  32811. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32812. * @param joint defines the joint to remove
  32813. */
  32814. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32815. /**
  32816. * Called by the scene. No need to call it.
  32817. * @param delta defines the timespam between frames
  32818. */
  32819. _step(delta: number): void;
  32820. /**
  32821. * Gets the current plugin used to run the simulation
  32822. * @returns current plugin
  32823. */
  32824. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32825. /**
  32826. * Gets the list of physic impostors
  32827. * @returns an array of PhysicsImpostor
  32828. */
  32829. getImpostors(): Array<PhysicsImpostor>;
  32830. /**
  32831. * Gets the impostor for a physics enabled object
  32832. * @param object defines the object impersonated by the impostor
  32833. * @returns the PhysicsImpostor or null if not found
  32834. */
  32835. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32836. /**
  32837. * Gets the impostor for a physics body object
  32838. * @param body defines physics body used by the impostor
  32839. * @returns the PhysicsImpostor or null if not found
  32840. */
  32841. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32842. }
  32843. }
  32844. declare module BABYLON {
  32845. interface Scene {
  32846. /** @hidden (Backing field) */
  32847. _physicsEngine: Nullable<IPhysicsEngine>;
  32848. /**
  32849. * Gets the current physics engine
  32850. * @returns a IPhysicsEngine or null if none attached
  32851. */
  32852. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  32853. /**
  32854. * Enables physics to the current scene
  32855. * @param gravity defines the scene's gravity for the physics engine
  32856. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  32857. * @return a boolean indicating if the physics engine was initialized
  32858. */
  32859. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  32860. /**
  32861. * Disables and disposes the physics engine associated with the scene
  32862. */
  32863. disablePhysicsEngine(): void;
  32864. /**
  32865. * Gets a boolean indicating if there is an active physics engine
  32866. * @returns a boolean indicating if there is an active physics engine
  32867. */
  32868. isPhysicsEnabled(): boolean;
  32869. /**
  32870. * Deletes a physics compound impostor
  32871. * @param compound defines the compound to delete
  32872. */
  32873. deleteCompoundImpostor(compound: any): void;
  32874. /**
  32875. * An event triggered when physic simulation is about to be run
  32876. */
  32877. onBeforePhysicsObservable: Observable<Scene>;
  32878. /**
  32879. * An event triggered when physic simulation has been done
  32880. */
  32881. onAfterPhysicsObservable: Observable<Scene>;
  32882. }
  32883. interface AbstractMesh {
  32884. /** @hidden */
  32885. _physicsImpostor: Nullable<PhysicsImpostor>;
  32886. /**
  32887. * Gets or sets impostor used for physic simulation
  32888. * @see http://doc.babylonjs.com/features/physics_engine
  32889. */
  32890. physicsImpostor: Nullable<PhysicsImpostor>;
  32891. /**
  32892. * Gets the current physics impostor
  32893. * @see http://doc.babylonjs.com/features/physics_engine
  32894. * @returns a physics impostor or null
  32895. */
  32896. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  32897. /** Apply a physic impulse to the mesh
  32898. * @param force defines the force to apply
  32899. * @param contactPoint defines where to apply the force
  32900. * @returns the current mesh
  32901. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32902. */
  32903. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  32904. /**
  32905. * Creates a physic joint between two meshes
  32906. * @param otherMesh defines the other mesh to use
  32907. * @param pivot1 defines the pivot to use on this mesh
  32908. * @param pivot2 defines the pivot to use on the other mesh
  32909. * @param options defines additional options (can be plugin dependent)
  32910. * @returns the current mesh
  32911. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  32912. */
  32913. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  32914. /** @hidden */
  32915. _disposePhysicsObserver: Nullable<Observer<Node>>;
  32916. }
  32917. /**
  32918. * Defines the physics engine scene component responsible to manage a physics engine
  32919. */
  32920. class PhysicsEngineSceneComponent implements ISceneComponent {
  32921. /**
  32922. * The component name helpful to identify the component in the list of scene components.
  32923. */
  32924. readonly name: string;
  32925. /**
  32926. * The scene the component belongs to.
  32927. */
  32928. scene: Scene;
  32929. /**
  32930. * Creates a new instance of the component for the given scene
  32931. * @param scene Defines the scene to register the component in
  32932. */
  32933. constructor(scene: Scene);
  32934. /**
  32935. * Registers the component in a given scene
  32936. */
  32937. register(): void;
  32938. /**
  32939. * Rebuilds the elements related to this component in case of
  32940. * context lost for instance.
  32941. */
  32942. rebuild(): void;
  32943. /**
  32944. * Disposes the component and the associated ressources
  32945. */
  32946. dispose(): void;
  32947. }
  32948. }
  32949. declare module BABYLON {
  32950. /**
  32951. * A helper for physics simulations
  32952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32953. */
  32954. class PhysicsHelper {
  32955. private _scene;
  32956. private _physicsEngine;
  32957. /**
  32958. * Initializes the Physics helper
  32959. * @param scene Babylon.js scene
  32960. */
  32961. constructor(scene: Scene);
  32962. /**
  32963. * Applies a radial explosion impulse
  32964. * @param origin the origin of the explosion
  32965. * @param radius the explosion radius
  32966. * @param strength the explosion strength
  32967. * @param falloff possible options: Constant & Linear. Defaults to Constant
  32968. * @returns A physics radial explosion event, or null
  32969. */
  32970. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  32971. /**
  32972. * Applies a radial explosion force
  32973. * @param origin the origin of the explosion
  32974. * @param radius the explosion radius
  32975. * @param strength the explosion strength
  32976. * @param falloff possible options: Constant & Linear. Defaults to Constant
  32977. * @returns A physics radial explosion event, or null
  32978. */
  32979. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  32980. /**
  32981. * Creates a gravitational field
  32982. * @param origin the origin of the explosion
  32983. * @param radius the explosion radius
  32984. * @param strength the explosion strength
  32985. * @param falloff possible options: Constant & Linear. Defaults to Constant
  32986. * @returns A physics gravitational field event, or null
  32987. */
  32988. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  32989. /**
  32990. * Creates a physics updraft event
  32991. * @param origin the origin of the updraft
  32992. * @param radius the radius of the updraft
  32993. * @param strength the strength of the updraft
  32994. * @param height the height of the updraft
  32995. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  32996. * @returns A physics updraft event, or null
  32997. */
  32998. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  32999. /**
  33000. * Creates a physics vortex event
  33001. * @param origin the of the vortex
  33002. * @param radius the radius of the vortex
  33003. * @param strength the strength of the vortex
  33004. * @param height the height of the vortex
  33005. * @returns a Physics vortex event, or null
  33006. * A physics vortex event or null
  33007. */
  33008. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  33009. }
  33010. /**
  33011. * Represents a physics radial explosion event
  33012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33013. */
  33014. class PhysicsRadialExplosionEvent {
  33015. private _scene;
  33016. private _sphere;
  33017. private _sphereOptions;
  33018. private _rays;
  33019. private _dataFetched;
  33020. /**
  33021. * Initializes a radial explosioin event
  33022. * @param scene BabylonJS scene
  33023. */
  33024. constructor(scene: Scene);
  33025. /**
  33026. * Returns the data related to the radial explosion event (sphere & rays).
  33027. * @returns The radial explosion event data
  33028. */
  33029. getData(): PhysicsRadialExplosionEventData;
  33030. /**
  33031. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  33032. * @param impostor A physics imposter
  33033. * @param origin the origin of the explosion
  33034. * @param radius the explosion radius
  33035. * @param strength the explosion strength
  33036. * @param falloff possible options: Constant & Linear
  33037. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  33038. */
  33039. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  33040. /**
  33041. * Disposes the sphere.
  33042. * @param force Specifies if the sphere should be disposed by force
  33043. */
  33044. dispose(force?: boolean): void;
  33045. /*** Helpers ***/
  33046. private _prepareSphere;
  33047. private _intersectsWithSphere;
  33048. }
  33049. /**
  33050. * Represents a gravitational field event
  33051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33052. */
  33053. class PhysicsGravitationalFieldEvent {
  33054. private _physicsHelper;
  33055. private _scene;
  33056. private _origin;
  33057. private _radius;
  33058. private _strength;
  33059. private _falloff;
  33060. private _tickCallback;
  33061. private _sphere;
  33062. private _dataFetched;
  33063. /**
  33064. * Initializes the physics gravitational field event
  33065. * @param physicsHelper A physics helper
  33066. * @param scene BabylonJS scene
  33067. * @param origin The origin position of the gravitational field event
  33068. * @param radius The radius of the gravitational field event
  33069. * @param strength The strength of the gravitational field event
  33070. * @param falloff The falloff for the gravitational field event
  33071. */
  33072. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  33073. /**
  33074. * Returns the data related to the gravitational field event (sphere).
  33075. * @returns A gravitational field event
  33076. */
  33077. getData(): PhysicsGravitationalFieldEventData;
  33078. /**
  33079. * Enables the gravitational field.
  33080. */
  33081. enable(): void;
  33082. /**
  33083. * Disables the gravitational field.
  33084. */
  33085. disable(): void;
  33086. /**
  33087. * Disposes the sphere.
  33088. * @param force The force to dispose from the gravitational field event
  33089. */
  33090. dispose(force?: boolean): void;
  33091. private _tick;
  33092. }
  33093. /**
  33094. * Represents a physics updraft event
  33095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33096. */
  33097. class PhysicsUpdraftEvent {
  33098. private _scene;
  33099. private _origin;
  33100. private _radius;
  33101. private _strength;
  33102. private _height;
  33103. private _updraftMode;
  33104. private _physicsEngine;
  33105. private _originTop;
  33106. private _originDirection;
  33107. private _tickCallback;
  33108. private _cylinder;
  33109. private _cylinderPosition;
  33110. private _dataFetched;
  33111. /**
  33112. * Initializes the physics updraft event
  33113. * @param _scene BabylonJS scene
  33114. * @param _origin The origin position of the updraft
  33115. * @param _radius The radius of the updraft
  33116. * @param _strength The strength of the updraft
  33117. * @param _height The height of the updraft
  33118. * @param _updraftMode The mode of the updraft
  33119. */
  33120. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  33121. /**
  33122. * Returns the data related to the updraft event (cylinder).
  33123. * @returns A physics updraft event
  33124. */
  33125. getData(): PhysicsUpdraftEventData;
  33126. /**
  33127. * Enables the updraft.
  33128. */
  33129. enable(): void;
  33130. /**
  33131. * Disables the cortex.
  33132. */
  33133. disable(): void;
  33134. /**
  33135. * Disposes the sphere.
  33136. * @param force Specifies if the updraft should be disposed by force
  33137. */
  33138. dispose(force?: boolean): void;
  33139. private getImpostorForceAndContactPoint;
  33140. private _tick;
  33141. /*** Helpers ***/
  33142. private _prepareCylinder;
  33143. private _intersectsWithCylinder;
  33144. }
  33145. /**
  33146. * Represents a physics vortex event
  33147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33148. */
  33149. class PhysicsVortexEvent {
  33150. private _scene;
  33151. private _origin;
  33152. private _radius;
  33153. private _strength;
  33154. private _height;
  33155. private _physicsEngine;
  33156. private _originTop;
  33157. private _centripetalForceThreshold;
  33158. private _updraftMultiplier;
  33159. private _tickCallback;
  33160. private _cylinder;
  33161. private _cylinderPosition;
  33162. private _dataFetched;
  33163. /**
  33164. * Initializes the physics vortex event
  33165. * @param _scene The BabylonJS scene
  33166. * @param _origin The origin position of the vortex
  33167. * @param _radius The radius of the vortex
  33168. * @param _strength The strength of the vortex
  33169. * @param _height The height of the vortex
  33170. */
  33171. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  33172. /**
  33173. * Returns the data related to the vortex event (cylinder).
  33174. * @returns The physics vortex event data
  33175. */
  33176. getData(): PhysicsVortexEventData;
  33177. /**
  33178. * Enables the vortex.
  33179. */
  33180. enable(): void;
  33181. /**
  33182. * Disables the cortex.
  33183. */
  33184. disable(): void;
  33185. /**
  33186. * Disposes the sphere.
  33187. * @param force
  33188. */
  33189. dispose(force?: boolean): void;
  33190. private getImpostorForceAndContactPoint;
  33191. private _tick;
  33192. /*** Helpers ***/
  33193. private _prepareCylinder;
  33194. private _intersectsWithCylinder;
  33195. }
  33196. /**
  33197. * The strenght of the force in correspondence to the distance of the affected object
  33198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33199. */
  33200. enum PhysicsRadialImpulseFalloff {
  33201. /** Defines that impulse is constant in strength across it's whole radius */
  33202. Constant = 0,
  33203. /** DEfines that impulse gets weaker if it's further from the origin */
  33204. Linear = 1
  33205. }
  33206. /**
  33207. * The strength of the force in correspondence to the distance of the affected object
  33208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33209. */
  33210. enum PhysicsUpdraftMode {
  33211. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  33212. Center = 0,
  33213. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  33214. Perpendicular = 1
  33215. }
  33216. /**
  33217. * Interface for a physics force and contact point
  33218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33219. */
  33220. interface PhysicsForceAndContactPoint {
  33221. /**
  33222. * The force applied at the contact point
  33223. */
  33224. force: Vector3;
  33225. /**
  33226. * The contact point
  33227. */
  33228. contactPoint: Vector3;
  33229. }
  33230. /**
  33231. * Interface for radial explosion event data
  33232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33233. */
  33234. interface PhysicsRadialExplosionEventData {
  33235. /**
  33236. * A sphere used for the radial explosion event
  33237. */
  33238. sphere: Mesh;
  33239. /**
  33240. * An array of rays for the radial explosion event
  33241. */
  33242. rays: Array<Ray>;
  33243. }
  33244. /**
  33245. * Interface for gravitational field event data
  33246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33247. */
  33248. interface PhysicsGravitationalFieldEventData {
  33249. /**
  33250. * A sphere mesh used for the gravitational field event
  33251. */
  33252. sphere: Mesh;
  33253. }
  33254. /**
  33255. * Interface for updraft event data
  33256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33257. */
  33258. interface PhysicsUpdraftEventData {
  33259. /**
  33260. * A cylinder used for the updraft event
  33261. */
  33262. cylinder: Mesh;
  33263. }
  33264. /**
  33265. * Interface for vortex event data
  33266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33267. */
  33268. interface PhysicsVortexEventData {
  33269. /**
  33270. * A cylinder used for the vortex event
  33271. */
  33272. cylinder: Mesh;
  33273. }
  33274. }
  33275. declare module BABYLON {
  33276. /**
  33277. * The interface for the physics imposter parameters
  33278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33279. */
  33280. interface PhysicsImpostorParameters {
  33281. /**
  33282. * The mass of the physics imposter
  33283. */
  33284. mass: number;
  33285. /**
  33286. * The friction of the physics imposter
  33287. */
  33288. friction?: number;
  33289. /**
  33290. * The coefficient of restitution of the physics imposter
  33291. */
  33292. restitution?: number;
  33293. /**
  33294. * The native options of the physics imposter
  33295. */
  33296. nativeOptions?: any;
  33297. /**
  33298. * Specifies if the parent should be ignored
  33299. */
  33300. ignoreParent?: boolean;
  33301. /**
  33302. * Specifies if bi-directional transformations should be disabled
  33303. */
  33304. disableBidirectionalTransformation?: boolean;
  33305. }
  33306. /**
  33307. * Interface for a physics-enabled object
  33308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33309. */
  33310. interface IPhysicsEnabledObject {
  33311. /**
  33312. * The position of the physics-enabled object
  33313. */
  33314. position: Vector3;
  33315. /**
  33316. * The rotation of the physics-enabled object
  33317. */
  33318. rotationQuaternion: Nullable<Quaternion>;
  33319. /**
  33320. * The scale of the physics-enabled object
  33321. */
  33322. scaling: Vector3;
  33323. /**
  33324. * The rotation of the physics-enabled object
  33325. */
  33326. rotation?: Vector3;
  33327. /**
  33328. * The parent of the physics-enabled object
  33329. */
  33330. parent?: any;
  33331. /**
  33332. * The bounding info of the physics-enabled object
  33333. * @returns The bounding info of the physics-enabled object
  33334. */
  33335. getBoundingInfo(): BoundingInfo;
  33336. /**
  33337. * Computes the world matrix
  33338. * @param force Specifies if the world matrix should be computed by force
  33339. * @returns A world matrix
  33340. */
  33341. computeWorldMatrix(force: boolean): Matrix;
  33342. /**
  33343. * Gets the world matrix
  33344. * @returns A world matrix
  33345. */
  33346. getWorldMatrix?(): Matrix;
  33347. /**
  33348. * Gets the child meshes
  33349. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33350. * @returns An array of abstract meshes
  33351. */
  33352. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33353. /**
  33354. * Gets the vertex data
  33355. * @param kind The type of vertex data
  33356. * @returns A nullable array of numbers, or a float32 array
  33357. */
  33358. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33359. /**
  33360. * Gets the indices from the mesh
  33361. * @returns A nullable array of index arrays
  33362. */
  33363. getIndices?(): Nullable<IndicesArray>;
  33364. /**
  33365. * Gets the scene from the mesh
  33366. * @returns the indices array or null
  33367. */
  33368. getScene?(): Scene;
  33369. /**
  33370. * Gets the absolute position from the mesh
  33371. * @returns the absolute position
  33372. */
  33373. getAbsolutePosition(): Vector3;
  33374. /**
  33375. * Gets the absolute pivot point from the mesh
  33376. * @returns the absolute pivot point
  33377. */
  33378. getAbsolutePivotPoint(): Vector3;
  33379. /**
  33380. * Rotates the mesh
  33381. * @param axis The axis of rotation
  33382. * @param amount The amount of rotation
  33383. * @param space The space of the rotation
  33384. * @returns The rotation transform node
  33385. */
  33386. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33387. /**
  33388. * Translates the mesh
  33389. * @param axis The axis of translation
  33390. * @param distance The distance of translation
  33391. * @param space The space of the translation
  33392. * @returns The transform node
  33393. */
  33394. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33395. /**
  33396. * Sets the absolute position of the mesh
  33397. * @param absolutePosition The absolute position of the mesh
  33398. * @returns The transform node
  33399. */
  33400. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33401. /**
  33402. * Gets the class name of the mesh
  33403. * @returns The class name
  33404. */
  33405. getClassName(): string;
  33406. }
  33407. /**
  33408. * Represents a physics imposter
  33409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33410. */
  33411. class PhysicsImpostor {
  33412. /**
  33413. * The physics-enabled object used as the physics imposter
  33414. */
  33415. object: IPhysicsEnabledObject;
  33416. /**
  33417. * The type of the physics imposter
  33418. */
  33419. type: number;
  33420. private _options;
  33421. private _scene?;
  33422. /**
  33423. * The default object size of the imposter
  33424. */
  33425. static DEFAULT_OBJECT_SIZE: Vector3;
  33426. /**
  33427. * The identity quaternion of the imposter
  33428. */
  33429. static IDENTITY_QUATERNION: Quaternion;
  33430. private _physicsEngine;
  33431. private _physicsBody;
  33432. private _bodyUpdateRequired;
  33433. private _onBeforePhysicsStepCallbacks;
  33434. private _onAfterPhysicsStepCallbacks;
  33435. private _onPhysicsCollideCallbacks;
  33436. private _deltaPosition;
  33437. private _deltaRotation;
  33438. private _deltaRotationConjugated;
  33439. private _parent;
  33440. private _isDisposed;
  33441. private static _tmpVecs;
  33442. private static _tmpQuat;
  33443. /**
  33444. * Specifies if the physics imposter is disposed
  33445. */
  33446. readonly isDisposed: boolean;
  33447. /**
  33448. * Gets the mass of the physics imposter
  33449. */
  33450. mass: number;
  33451. /**
  33452. * Gets the coefficient of friction
  33453. */
  33454. /**
  33455. * Sets the coefficient of friction
  33456. */
  33457. friction: number;
  33458. /**
  33459. * Gets the coefficient of restitution
  33460. */
  33461. /**
  33462. * Sets the coefficient of restitution
  33463. */
  33464. restitution: number;
  33465. /**
  33466. * The unique id of the physics imposter
  33467. * set by the physics engine when adding this impostor to the array
  33468. */
  33469. uniqueId: number;
  33470. private _joints;
  33471. /**
  33472. * Initializes the physics imposter
  33473. * @param object The physics-enabled object used as the physics imposter
  33474. * @param type The type of the physics imposter
  33475. * @param _options The options for the physics imposter
  33476. * @param _scene The Babylon scene
  33477. */
  33478. constructor(
  33479. /**
  33480. * The physics-enabled object used as the physics imposter
  33481. */
  33482. object: IPhysicsEnabledObject,
  33483. /**
  33484. * The type of the physics imposter
  33485. */
  33486. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33487. /**
  33488. * This function will completly initialize this impostor.
  33489. * It will create a new body - but only if this mesh has no parent.
  33490. * If it has, this impostor will not be used other than to define the impostor
  33491. * of the child mesh.
  33492. * @hidden
  33493. */
  33494. _init(): void;
  33495. private _getPhysicsParent;
  33496. /**
  33497. * Should a new body be generated.
  33498. * @returns boolean specifying if body initialization is required
  33499. */
  33500. isBodyInitRequired(): boolean;
  33501. /**
  33502. * Sets the updated scaling
  33503. * @param updated Specifies if the scaling is updated
  33504. */
  33505. setScalingUpdated(updated: boolean): void;
  33506. /**
  33507. * Force a regeneration of this or the parent's impostor's body.
  33508. * Use under cautious - This will remove all joints already implemented.
  33509. */
  33510. forceUpdate(): void;
  33511. /**
  33512. * Gets the body that holds this impostor. Either its own, or its parent.
  33513. */
  33514. /**
  33515. * Set the physics body. Used mainly by the physics engine/plugin
  33516. */
  33517. physicsBody: any;
  33518. /**
  33519. * Get the parent of the physics imposter
  33520. * @returns Physics imposter or null
  33521. */
  33522. /**
  33523. * Sets the parent of the physics imposter
  33524. */
  33525. parent: Nullable<PhysicsImpostor>;
  33526. /**
  33527. * Resets the update flags
  33528. */
  33529. resetUpdateFlags(): void;
  33530. /**
  33531. * Gets the object extend size
  33532. * @returns the object extend size
  33533. */
  33534. getObjectExtendSize(): Vector3;
  33535. /**
  33536. * Gets the object center
  33537. * @returns The object center
  33538. */
  33539. getObjectCenter(): Vector3;
  33540. /**
  33541. * Get a specific parametes from the options parameter
  33542. * @param paramName The object parameter name
  33543. * @returns The object parameter
  33544. */
  33545. getParam(paramName: string): any;
  33546. /**
  33547. * Sets a specific parameter in the options given to the physics plugin
  33548. * @param paramName The parameter name
  33549. * @param value The value of the parameter
  33550. */
  33551. setParam(paramName: string, value: number): void;
  33552. /**
  33553. * Specifically change the body's mass option. Won't recreate the physics body object
  33554. * @param mass The mass of the physics imposter
  33555. */
  33556. setMass(mass: number): void;
  33557. /**
  33558. * Gets the linear velocity
  33559. * @returns linear velocity or null
  33560. */
  33561. getLinearVelocity(): Nullable<Vector3>;
  33562. /**
  33563. * Sets the linear velocity
  33564. * @param velocity linear velocity or null
  33565. */
  33566. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33567. /**
  33568. * Gets the angular velocity
  33569. * @returns angular velocity or null
  33570. */
  33571. getAngularVelocity(): Nullable<Vector3>;
  33572. /**
  33573. * Sets the angular velocity
  33574. * @param velocity The velocity or null
  33575. */
  33576. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33577. /**
  33578. * Execute a function with the physics plugin native code
  33579. * Provide a function the will have two variables - the world object and the physics body object
  33580. * @param func The function to execute with the physics plugin native code
  33581. */
  33582. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33583. /**
  33584. * Register a function that will be executed before the physics world is stepping forward
  33585. * @param func The function to execute before the physics world is stepped forward
  33586. */
  33587. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33588. /**
  33589. * Unregister a function that will be executed before the physics world is stepping forward
  33590. * @param func The function to execute before the physics world is stepped forward
  33591. */
  33592. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33593. /**
  33594. * Register a function that will be executed after the physics step
  33595. * @param func The function to execute after physics step
  33596. */
  33597. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33598. /**
  33599. * Unregisters a function that will be executed after the physics step
  33600. * @param func The function to execute after physics step
  33601. */
  33602. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33603. /**
  33604. * register a function that will be executed when this impostor collides against a different body
  33605. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33606. * @param func Callback that is executed on collision
  33607. */
  33608. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33609. /**
  33610. * Unregisters the physics imposter on contact
  33611. * @param collideAgainst The physics object to collide against
  33612. * @param func Callback to execute on collision
  33613. */
  33614. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33615. private _tmpQuat;
  33616. private _tmpQuat2;
  33617. /**
  33618. * Get the parent rotation
  33619. * @returns The parent rotation
  33620. */
  33621. getParentsRotation(): Quaternion;
  33622. /**
  33623. * this function is executed by the physics engine.
  33624. */
  33625. beforeStep: () => void;
  33626. /**
  33627. * this function is executed by the physics engine
  33628. */
  33629. afterStep: () => void;
  33630. /**
  33631. * Legacy collision detection event support
  33632. */
  33633. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33634. /**
  33635. * event and body object due to cannon's event-based architecture.
  33636. */
  33637. onCollide: (e: {
  33638. body: any;
  33639. }) => void;
  33640. /**
  33641. * Apply a force
  33642. * @param force The force to apply
  33643. * @param contactPoint The contact point for the force
  33644. * @returns The physics imposter
  33645. */
  33646. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33647. /**
  33648. * Apply an impulse
  33649. * @param force The impulse force
  33650. * @param contactPoint The contact point for the impulse force
  33651. * @returns The physics imposter
  33652. */
  33653. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33654. /**
  33655. * A help function to create a joint
  33656. * @param otherImpostor A physics imposter used to create a joint
  33657. * @param jointType The type of joint
  33658. * @param jointData The data for the joint
  33659. * @returns The physics imposter
  33660. */
  33661. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33662. /**
  33663. * Add a joint to this impostor with a different impostor
  33664. * @param otherImpostor A physics imposter used to add a joint
  33665. * @param joint The joint to add
  33666. * @returns The physics imposter
  33667. */
  33668. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33669. /**
  33670. * Will keep this body still, in a sleep mode.
  33671. * @returns the physics imposter
  33672. */
  33673. sleep(): PhysicsImpostor;
  33674. /**
  33675. * Wake the body up.
  33676. * @returns The physics imposter
  33677. */
  33678. wakeUp(): PhysicsImpostor;
  33679. /**
  33680. * Clones the physics imposter
  33681. * @param newObject The physics imposter clones to this physics-enabled object
  33682. * @returns A nullable physics imposter
  33683. */
  33684. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33685. /**
  33686. * Disposes the physics imposter
  33687. */
  33688. dispose(): void;
  33689. /**
  33690. * Sets the delta position
  33691. * @param position The delta position amount
  33692. */
  33693. setDeltaPosition(position: Vector3): void;
  33694. /**
  33695. * Sets the delta rotation
  33696. * @param rotation The delta rotation amount
  33697. */
  33698. setDeltaRotation(rotation: Quaternion): void;
  33699. /**
  33700. * Gets the box size of the physics imposter and stores the result in the input parameter
  33701. * @param result Stores the box size
  33702. * @returns The physics imposter
  33703. */
  33704. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33705. /**
  33706. * Gets the radius of the physics imposter
  33707. * @returns Radius of the physics imposter
  33708. */
  33709. getRadius(): number;
  33710. /**
  33711. * Sync a bone with this impostor
  33712. * @param bone The bone to sync to the impostor.
  33713. * @param boneMesh The mesh that the bone is influencing.
  33714. * @param jointPivot The pivot of the joint / bone in local space.
  33715. * @param distToJoint Optional distance from the impostor to the joint.
  33716. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33717. */
  33718. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33719. /**
  33720. * Sync impostor to a bone
  33721. * @param bone The bone that the impostor will be synced to.
  33722. * @param boneMesh The mesh that the bone is influencing.
  33723. * @param jointPivot The pivot of the joint / bone in local space.
  33724. * @param distToJoint Optional distance from the impostor to the joint.
  33725. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33726. * @param boneAxis Optional vector3 axis the bone is aligned with
  33727. */
  33728. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33729. /**
  33730. * No-Imposter type
  33731. */
  33732. static NoImpostor: number;
  33733. /**
  33734. * Sphere-Imposter type
  33735. */
  33736. static SphereImpostor: number;
  33737. /**
  33738. * Box-Imposter type
  33739. */
  33740. static BoxImpostor: number;
  33741. /**
  33742. * Plane-Imposter type
  33743. */
  33744. static PlaneImpostor: number;
  33745. /**
  33746. * Mesh-imposter type
  33747. */
  33748. static MeshImpostor: number;
  33749. /**
  33750. * Cylinder-Imposter type
  33751. */
  33752. static CylinderImpostor: number;
  33753. /**
  33754. * Particle-Imposter type
  33755. */
  33756. static ParticleImpostor: number;
  33757. /**
  33758. * Heightmap-Imposter type
  33759. */
  33760. static HeightmapImpostor: number;
  33761. }
  33762. }
  33763. declare module BABYLON {
  33764. /**
  33765. * Interface for Physics-Joint data
  33766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33767. */
  33768. interface PhysicsJointData {
  33769. /**
  33770. * The main pivot of the joint
  33771. */
  33772. mainPivot?: Vector3;
  33773. /**
  33774. * The connected pivot of the joint
  33775. */
  33776. connectedPivot?: Vector3;
  33777. /**
  33778. * The main axis of the joint
  33779. */
  33780. mainAxis?: Vector3;
  33781. /**
  33782. * The connected axis of the joint
  33783. */
  33784. connectedAxis?: Vector3;
  33785. /**
  33786. * The collision of the joint
  33787. */
  33788. collision?: boolean;
  33789. /**
  33790. * Native Oimo/Cannon/Energy data
  33791. */
  33792. nativeParams?: any;
  33793. }
  33794. /**
  33795. * This is a holder class for the physics joint created by the physics plugin
  33796. * It holds a set of functions to control the underlying joint
  33797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33798. */
  33799. class PhysicsJoint {
  33800. /**
  33801. * The type of the physics joint
  33802. */
  33803. type: number;
  33804. /**
  33805. * The data for the physics joint
  33806. */
  33807. jointData: PhysicsJointData;
  33808. private _physicsJoint;
  33809. protected _physicsPlugin: IPhysicsEnginePlugin;
  33810. /**
  33811. * Initializes the physics joint
  33812. * @param type The type of the physics joint
  33813. * @param jointData The data for the physics joint
  33814. */
  33815. constructor(
  33816. /**
  33817. * The type of the physics joint
  33818. */
  33819. type: number,
  33820. /**
  33821. * The data for the physics joint
  33822. */
  33823. jointData: PhysicsJointData);
  33824. /**
  33825. * Gets the physics joint
  33826. */
  33827. /**
  33828. * Sets the physics joint
  33829. */
  33830. physicsJoint: any;
  33831. /**
  33832. * Sets the physics plugin
  33833. */
  33834. physicsPlugin: IPhysicsEnginePlugin;
  33835. /**
  33836. * Execute a function that is physics-plugin specific.
  33837. * @param {Function} func the function that will be executed.
  33838. * It accepts two parameters: the physics world and the physics joint
  33839. */
  33840. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  33841. /**
  33842. * Distance-Joint type
  33843. */
  33844. static DistanceJoint: number;
  33845. /**
  33846. * Hinge-Joint type
  33847. */
  33848. static HingeJoint: number;
  33849. /**
  33850. * Ball-and-Socket joint type
  33851. */
  33852. static BallAndSocketJoint: number;
  33853. /**
  33854. * Wheel-Joint type
  33855. */
  33856. static WheelJoint: number;
  33857. /**
  33858. * Slider-Joint type
  33859. */
  33860. static SliderJoint: number;
  33861. /**
  33862. * Prismatic-Joint type
  33863. */
  33864. static PrismaticJoint: number;
  33865. /**
  33866. * Universal-Joint type
  33867. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  33868. */
  33869. static UniversalJoint: number;
  33870. /**
  33871. * Hinge-Joint 2 type
  33872. */
  33873. static Hinge2Joint: number;
  33874. /**
  33875. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  33876. */
  33877. static PointToPointJoint: number;
  33878. /**
  33879. * Spring-Joint type
  33880. */
  33881. static SpringJoint: number;
  33882. /**
  33883. * Lock-Joint type
  33884. */
  33885. static LockJoint: number;
  33886. }
  33887. /**
  33888. * A class representing a physics distance joint
  33889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33890. */
  33891. class DistanceJoint extends PhysicsJoint {
  33892. /**
  33893. *
  33894. * @param jointData The data for the Distance-Joint
  33895. */
  33896. constructor(jointData: DistanceJointData);
  33897. /**
  33898. * Update the predefined distance.
  33899. * @param maxDistance The maximum preferred distance
  33900. * @param minDistance The minimum preferred distance
  33901. */
  33902. updateDistance(maxDistance: number, minDistance?: number): void;
  33903. }
  33904. /**
  33905. * Represents a Motor-Enabled Joint
  33906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33907. */
  33908. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  33909. /**
  33910. * Initializes the Motor-Enabled Joint
  33911. * @param type The type of the joint
  33912. * @param jointData The physica joint data for the joint
  33913. */
  33914. constructor(type: number, jointData: PhysicsJointData);
  33915. /**
  33916. * Set the motor values.
  33917. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33918. * @param force the force to apply
  33919. * @param maxForce max force for this motor.
  33920. */
  33921. setMotor(force?: number, maxForce?: number): void;
  33922. /**
  33923. * Set the motor's limits.
  33924. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33925. * @param upperLimit The upper limit of the motor
  33926. * @param lowerLimit The lower limit of the motor
  33927. */
  33928. setLimit(upperLimit: number, lowerLimit?: number): void;
  33929. }
  33930. /**
  33931. * This class represents a single physics Hinge-Joint
  33932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33933. */
  33934. class HingeJoint extends MotorEnabledJoint {
  33935. /**
  33936. * Initializes the Hinge-Joint
  33937. * @param jointData The joint data for the Hinge-Joint
  33938. */
  33939. constructor(jointData: PhysicsJointData);
  33940. /**
  33941. * Set the motor values.
  33942. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33943. * @param {number} force the force to apply
  33944. * @param {number} maxForce max force for this motor.
  33945. */
  33946. setMotor(force?: number, maxForce?: number): void;
  33947. /**
  33948. * Set the motor's limits.
  33949. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33950. * @param upperLimit The upper limit of the motor
  33951. * @param lowerLimit The lower limit of the motor
  33952. */
  33953. setLimit(upperLimit: number, lowerLimit?: number): void;
  33954. }
  33955. /**
  33956. * This class represents a dual hinge physics joint (same as wheel joint)
  33957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33958. */
  33959. class Hinge2Joint extends MotorEnabledJoint {
  33960. /**
  33961. * Initializes the Hinge2-Joint
  33962. * @param jointData The joint data for the Hinge2-Joint
  33963. */
  33964. constructor(jointData: PhysicsJointData);
  33965. /**
  33966. * Set the motor values.
  33967. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33968. * @param {number} force the force to apply
  33969. * @param {number} maxForce max force for this motor.
  33970. * @param {motorIndex} the motor's index, 0 or 1.
  33971. */
  33972. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  33973. /**
  33974. * Set the motor limits.
  33975. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33976. * @param {number} upperLimit the upper limit
  33977. * @param {number} lowerLimit lower limit
  33978. * @param {motorIndex} the motor's index, 0 or 1.
  33979. */
  33980. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33981. }
  33982. /**
  33983. * Interface for a motor enabled joint
  33984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33985. */
  33986. interface IMotorEnabledJoint {
  33987. /**
  33988. * Physics joint
  33989. */
  33990. physicsJoint: any;
  33991. /**
  33992. * Sets the motor of the motor-enabled joint
  33993. * @param force The force of the motor
  33994. * @param maxForce The maximum force of the motor
  33995. * @param motorIndex The index of the motor
  33996. */
  33997. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  33998. /**
  33999. * Sets the limit of the motor
  34000. * @param upperLimit The upper limit of the motor
  34001. * @param lowerLimit The lower limit of the motor
  34002. * @param motorIndex The index of the motor
  34003. */
  34004. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34005. }
  34006. /**
  34007. * Joint data for a Distance-Joint
  34008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34009. */
  34010. interface DistanceJointData extends PhysicsJointData {
  34011. /**
  34012. * Max distance the 2 joint objects can be apart
  34013. */
  34014. maxDistance: number;
  34015. }
  34016. /**
  34017. * Joint data from a spring joint
  34018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34019. */
  34020. interface SpringJointData extends PhysicsJointData {
  34021. /**
  34022. * Length of the spring
  34023. */
  34024. length: number;
  34025. /**
  34026. * Stiffness of the spring
  34027. */
  34028. stiffness: number;
  34029. /**
  34030. * Damping of the spring
  34031. */
  34032. damping: number;
  34033. /** this callback will be called when applying the force to the impostors. */
  34034. forceApplicationCallback: () => void;
  34035. }
  34036. }
  34037. declare module BABYLON {
  34038. /**
  34039. * Postprocess used to generate anaglyphic rendering
  34040. */
  34041. class AnaglyphPostProcess extends PostProcess {
  34042. private _passedProcess;
  34043. /**
  34044. * Creates a new AnaglyphPostProcess
  34045. * @param name defines postprocess name
  34046. * @param options defines creation options or target ratio scale
  34047. * @param rigCameras defines cameras using this postprocess
  34048. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  34049. * @param engine defines hosting engine
  34050. * @param reusable defines if the postprocess will be reused multiple times per frame
  34051. */
  34052. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  34053. }
  34054. }
  34055. declare module BABYLON {
  34056. /**
  34057. * Post process used to render in black and white
  34058. */
  34059. class BlackAndWhitePostProcess extends PostProcess {
  34060. /**
  34061. * Linear about to convert he result to black and white (default: 1)
  34062. */
  34063. degree: number;
  34064. /**
  34065. * Creates a black and white post process
  34066. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  34067. * @param name The name of the effect.
  34068. * @param options The required width/height ratio to downsize to before computing the render pass.
  34069. * @param camera The camera to apply the render pass to.
  34070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34071. * @param engine The engine which the post process will be applied. (default: current engine)
  34072. * @param reusable If the post process can be reused on the same frame. (default: false)
  34073. */
  34074. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34075. }
  34076. }
  34077. declare module BABYLON {
  34078. /**
  34079. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  34080. */
  34081. class BloomEffect extends PostProcessRenderEffect {
  34082. private bloomScale;
  34083. /**
  34084. * @hidden Internal
  34085. */
  34086. _effects: Array<PostProcess>;
  34087. /**
  34088. * @hidden Internal
  34089. */
  34090. _downscale: ExtractHighlightsPostProcess;
  34091. private _blurX;
  34092. private _blurY;
  34093. private _merge;
  34094. /**
  34095. * The luminance threshold to find bright areas of the image to bloom.
  34096. */
  34097. threshold: number;
  34098. /**
  34099. * The strength of the bloom.
  34100. */
  34101. weight: number;
  34102. /**
  34103. * Specifies the size of the bloom blur kernel, relative to the final output size
  34104. */
  34105. kernel: number;
  34106. /**
  34107. * Creates a new instance of @see BloomEffect
  34108. * @param scene The scene the effect belongs to.
  34109. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  34110. * @param bloomKernel The size of the kernel to be used when applying the blur.
  34111. * @param bloomWeight The the strength of bloom.
  34112. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34113. * @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)
  34114. */
  34115. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  34116. /**
  34117. * Disposes each of the internal effects for a given camera.
  34118. * @param camera The camera to dispose the effect on.
  34119. */
  34120. disposeEffects(camera: Camera): void;
  34121. /**
  34122. * @hidden Internal
  34123. */
  34124. _updateEffects(): void;
  34125. /**
  34126. * Internal
  34127. * @returns if all the contained post processes are ready.
  34128. * @hidden
  34129. */
  34130. _isReady(): boolean;
  34131. }
  34132. }
  34133. declare module BABYLON {
  34134. /**
  34135. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34136. */
  34137. class BloomMergePostProcess extends PostProcess {
  34138. /** Weight of the bloom to be added to the original input. */
  34139. weight: number;
  34140. /**
  34141. * Creates a new instance of @see BloomMergePostProcess
  34142. * @param name The name of the effect.
  34143. * @param originalFromInput Post process which's input will be used for the merge.
  34144. * @param blurred Blurred highlights post process which's output will be used.
  34145. * @param weight Weight of the bloom to be added to the original input.
  34146. * @param options The required width/height ratio to downsize to before computing the render pass.
  34147. * @param camera The camera to apply the render pass to.
  34148. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34149. * @param engine The engine which the post process will be applied. (default: current engine)
  34150. * @param reusable If the post process can be reused on the same frame. (default: false)
  34151. * @param textureType Type of textures used when performing the post process. (default: 0)
  34152. * @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)
  34153. */
  34154. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  34155. /** Weight of the bloom to be added to the original input. */
  34156. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34157. }
  34158. }
  34159. declare module BABYLON {
  34160. /**
  34161. * The Blur Post Process which blurs an image based on a kernel and direction.
  34162. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  34163. */
  34164. class BlurPostProcess extends PostProcess {
  34165. /** The direction in which to blur the image. */
  34166. direction: Vector2;
  34167. private blockCompilation;
  34168. protected _kernel: number;
  34169. protected _idealKernel: number;
  34170. protected _packedFloat: boolean;
  34171. private _staticDefines;
  34172. /**
  34173. * Sets the length in pixels of the blur sample region
  34174. */
  34175. /**
  34176. * Gets the length in pixels of the blur sample region
  34177. */
  34178. kernel: number;
  34179. /**
  34180. * Sets wether or not the blur needs to unpack/repack floats
  34181. */
  34182. /**
  34183. * Gets wether or not the blur is unpacking/repacking floats
  34184. */
  34185. packedFloat: boolean;
  34186. /**
  34187. * Creates a new instance BlurPostProcess
  34188. * @param name The name of the effect.
  34189. * @param direction The direction in which to blur the image.
  34190. * @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.
  34191. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34192. * @param camera The camera to apply the render pass to.
  34193. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34194. * @param engine The engine which the post process will be applied. (default: current engine)
  34195. * @param reusable If the post process can be reused on the same frame. (default: false)
  34196. * @param textureType Type of textures used when performing the post process. (default: 0)
  34197. * @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)
  34198. */
  34199. constructor(name: string,
  34200. /** The direction in which to blur the image. */
  34201. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  34202. /**
  34203. * Updates the effect with the current post process compile time values and recompiles the shader.
  34204. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34205. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34206. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34207. * @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
  34208. * @param onCompiled Called when the shader has been compiled.
  34209. * @param onError Called if there is an error when compiling a shader.
  34210. */
  34211. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34212. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34213. /**
  34214. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  34215. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  34216. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  34217. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  34218. * The gaps between physical kernels are compensated for in the weighting of the samples
  34219. * @param idealKernel Ideal blur kernel.
  34220. * @return Nearest best kernel.
  34221. */
  34222. protected _nearestBestKernel(idealKernel: number): number;
  34223. /**
  34224. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  34225. * @param x The point on the Gaussian distribution to sample.
  34226. * @return the value of the Gaussian function at x.
  34227. */
  34228. protected _gaussianWeight(x: number): number;
  34229. /**
  34230. * Generates a string that can be used as a floating point number in GLSL.
  34231. * @param x Value to print.
  34232. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  34233. * @return GLSL float string.
  34234. */
  34235. protected _glslFloat(x: number, decimalFigures?: number): string;
  34236. }
  34237. }
  34238. declare module BABYLON {
  34239. /**
  34240. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  34241. */
  34242. class ChromaticAberrationPostProcess extends PostProcess {
  34243. /**
  34244. * The amount of seperation of rgb channels (default: 30)
  34245. */
  34246. aberrationAmount: number;
  34247. /**
  34248. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  34249. */
  34250. radialIntensity: number;
  34251. /**
  34252. * 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))
  34253. */
  34254. direction: Vector2;
  34255. /**
  34256. * 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))
  34257. */
  34258. centerPosition: Vector2;
  34259. /**
  34260. * Creates a new instance ChromaticAberrationPostProcess
  34261. * @param name The name of the effect.
  34262. * @param screenWidth The width of the screen to apply the effect on.
  34263. * @param screenHeight The height of the screen to apply the effect on.
  34264. * @param options The required width/height ratio to downsize to before computing the render pass.
  34265. * @param camera The camera to apply the render pass to.
  34266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34267. * @param engine The engine which the post process will be applied. (default: current engine)
  34268. * @param reusable If the post process can be reused on the same frame. (default: false)
  34269. * @param textureType Type of textures used when performing the post process. (default: 0)
  34270. * @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)
  34271. */
  34272. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34273. }
  34274. }
  34275. declare module BABYLON {
  34276. /**
  34277. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  34278. */
  34279. class CircleOfConfusionPostProcess extends PostProcess {
  34280. /**
  34281. * 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.
  34282. */
  34283. lensSize: number;
  34284. /**
  34285. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34286. */
  34287. fStop: number;
  34288. /**
  34289. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34290. */
  34291. focusDistance: number;
  34292. /**
  34293. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  34294. */
  34295. focalLength: number;
  34296. private _depthTexture;
  34297. /**
  34298. * Creates a new instance CircleOfConfusionPostProcess
  34299. * @param name The name of the effect.
  34300. * @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.
  34301. * @param options The required width/height ratio to downsize to before computing the render pass.
  34302. * @param camera The camera to apply the render pass to.
  34303. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34304. * @param engine The engine which the post process will be applied. (default: current engine)
  34305. * @param reusable If the post process can be reused on the same frame. (default: false)
  34306. * @param textureType Type of textures used when performing the post process. (default: 0)
  34307. * @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)
  34308. */
  34309. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34310. /**
  34311. * 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.
  34312. */
  34313. depthTexture: RenderTargetTexture;
  34314. }
  34315. }
  34316. declare module BABYLON {
  34317. /**
  34318. *
  34319. * This post-process allows the modification of rendered colors by using
  34320. * a 'look-up table' (LUT). This effect is also called Color Grading.
  34321. *
  34322. * The object needs to be provided an url to a texture containing the color
  34323. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  34324. * Use an image editing software to tweak the LUT to match your needs.
  34325. *
  34326. * For an example of a color LUT, see here:
  34327. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  34328. * For explanations on color grading, see here:
  34329. * @see http://udn.epicgames.com/Three/ColorGrading.html
  34330. *
  34331. */
  34332. class ColorCorrectionPostProcess extends PostProcess {
  34333. private _colorTableTexture;
  34334. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34335. }
  34336. }
  34337. declare module BABYLON {
  34338. /**
  34339. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  34340. * input texture to perform effects such as edge detection or sharpening
  34341. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34342. */
  34343. class ConvolutionPostProcess extends PostProcess {
  34344. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34345. kernel: number[];
  34346. /**
  34347. * Creates a new instance ConvolutionPostProcess
  34348. * @param name The name of the effect.
  34349. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  34350. * @param options The required width/height ratio to downsize to before computing the render pass.
  34351. * @param camera The camera to apply the render pass to.
  34352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34353. * @param engine The engine which the post process will be applied. (default: current engine)
  34354. * @param reusable If the post process can be reused on the same frame. (default: false)
  34355. * @param textureType Type of textures used when performing the post process. (default: 0)
  34356. */
  34357. constructor(name: string,
  34358. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34359. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34360. /**
  34361. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34362. */
  34363. static EdgeDetect0Kernel: number[];
  34364. /**
  34365. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34366. */
  34367. static EdgeDetect1Kernel: number[];
  34368. /**
  34369. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34370. */
  34371. static EdgeDetect2Kernel: number[];
  34372. /**
  34373. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34374. */
  34375. static SharpenKernel: number[];
  34376. /**
  34377. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34378. */
  34379. static EmbossKernel: number[];
  34380. /**
  34381. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34382. */
  34383. static GaussianKernel: number[];
  34384. }
  34385. }
  34386. declare module BABYLON {
  34387. /**
  34388. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  34389. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  34390. * based on samples that have a large difference in distance than the center pixel.
  34391. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  34392. */
  34393. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  34394. direction: Vector2;
  34395. /**
  34396. * Creates a new instance CircleOfConfusionPostProcess
  34397. * @param name The name of the effect.
  34398. * @param scene The scene the effect belongs to.
  34399. * @param direction The direction the blur should be applied.
  34400. * @param kernel The size of the kernel used to blur.
  34401. * @param options The required width/height ratio to downsize to before computing the render pass.
  34402. * @param camera The camera to apply the render pass to.
  34403. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  34404. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  34405. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34406. * @param engine The engine which the post process will be applied. (default: current engine)
  34407. * @param reusable If the post process can be reused on the same frame. (default: false)
  34408. * @param textureType Type of textures used when performing the post process. (default: 0)
  34409. * @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)
  34410. */
  34411. 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);
  34412. }
  34413. }
  34414. declare module BABYLON {
  34415. /**
  34416. * Specifies the level of max blur that should be applied when using the depth of field effect
  34417. */
  34418. enum DepthOfFieldEffectBlurLevel {
  34419. /**
  34420. * Subtle blur
  34421. */
  34422. Low = 0,
  34423. /**
  34424. * Medium blur
  34425. */
  34426. Medium = 1,
  34427. /**
  34428. * Large blur
  34429. */
  34430. High = 2
  34431. }
  34432. /**
  34433. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  34434. */
  34435. class DepthOfFieldEffect extends PostProcessRenderEffect {
  34436. private _circleOfConfusion;
  34437. /**
  34438. * @hidden Internal, blurs from high to low
  34439. */
  34440. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  34441. private _depthOfFieldBlurY;
  34442. private _dofMerge;
  34443. /**
  34444. * @hidden Internal post processes in depth of field effect
  34445. */
  34446. _effects: Array<PostProcess>;
  34447. /**
  34448. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  34449. */
  34450. focalLength: number;
  34451. /**
  34452. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34453. */
  34454. fStop: number;
  34455. /**
  34456. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34457. */
  34458. focusDistance: number;
  34459. /**
  34460. * 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.
  34461. */
  34462. lensSize: number;
  34463. /**
  34464. * Creates a new instance DepthOfFieldEffect
  34465. * @param scene The scene the effect belongs to.
  34466. * @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.
  34467. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34468. * @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)
  34469. */
  34470. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  34471. /**
  34472. * 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.
  34473. */
  34474. depthTexture: RenderTargetTexture;
  34475. /**
  34476. * Disposes each of the internal effects for a given camera.
  34477. * @param camera The camera to dispose the effect on.
  34478. */
  34479. disposeEffects(camera: Camera): void;
  34480. /**
  34481. * @hidden Internal
  34482. */
  34483. _updateEffects(): void;
  34484. /**
  34485. * Internal
  34486. * @returns if all the contained post processes are ready.
  34487. * @hidden
  34488. */
  34489. _isReady(): boolean;
  34490. }
  34491. }
  34492. declare module BABYLON {
  34493. /**
  34494. * Options to be set when merging outputs from the default pipeline.
  34495. */
  34496. class DepthOfFieldMergePostProcessOptions {
  34497. /**
  34498. * The original image to merge on top of
  34499. */
  34500. originalFromInput: PostProcess;
  34501. /**
  34502. * Parameters to perform the merge of the depth of field effect
  34503. */
  34504. depthOfField?: {
  34505. circleOfConfusion: PostProcess;
  34506. blurSteps: Array<PostProcess>;
  34507. };
  34508. /**
  34509. * Parameters to perform the merge of bloom effect
  34510. */
  34511. bloom?: {
  34512. blurred: PostProcess;
  34513. weight: number;
  34514. };
  34515. }
  34516. /**
  34517. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34518. */
  34519. class DepthOfFieldMergePostProcess extends PostProcess {
  34520. private blurSteps;
  34521. /**
  34522. * Creates a new instance of DepthOfFieldMergePostProcess
  34523. * @param name The name of the effect.
  34524. * @param originalFromInput Post process which's input will be used for the merge.
  34525. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  34526. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  34527. * @param options The required width/height ratio to downsize to before computing the render pass.
  34528. * @param camera The camera to apply the render pass to.
  34529. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34530. * @param engine The engine which the post process will be applied. (default: current engine)
  34531. * @param reusable If the post process can be reused on the same frame. (default: false)
  34532. * @param textureType Type of textures used when performing the post process. (default: 0)
  34533. * @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)
  34534. */
  34535. 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);
  34536. /**
  34537. * Updates the effect with the current post process compile time values and recompiles the shader.
  34538. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34539. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34540. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34541. * @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
  34542. * @param onCompiled Called when the shader has been compiled.
  34543. * @param onError Called if there is an error when compiling a shader.
  34544. */
  34545. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34546. }
  34547. }
  34548. declare module BABYLON {
  34549. /**
  34550. * DisplayPassPostProcess which produces an output the same as it's input
  34551. */
  34552. class DisplayPassPostProcess extends PostProcess {
  34553. /**
  34554. * Creates the DisplayPassPostProcess
  34555. * @param name The name of the effect.
  34556. * @param options The required width/height ratio to downsize to before computing the render pass.
  34557. * @param camera The camera to apply the render pass to.
  34558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34559. * @param engine The engine which the post process will be applied. (default: current engine)
  34560. * @param reusable If the post process can be reused on the same frame. (default: false)
  34561. */
  34562. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34563. }
  34564. }
  34565. declare module BABYLON {
  34566. /**
  34567. * 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.
  34568. */
  34569. class ExtractHighlightsPostProcess extends PostProcess {
  34570. /**
  34571. * The luminance threshold, pixels below this value will be set to black.
  34572. */
  34573. threshold: number;
  34574. /** @hidden */
  34575. _exposure: number;
  34576. /**
  34577. * Post process which has the input texture to be used when performing highlight extraction
  34578. * @hidden
  34579. */
  34580. _inputPostProcess: Nullable<PostProcess>;
  34581. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34582. }
  34583. }
  34584. declare module BABYLON {
  34585. /**
  34586. * Applies a kernel filter to the image
  34587. */
  34588. class FilterPostProcess extends PostProcess {
  34589. /** The matrix to be applied to the image */
  34590. kernelMatrix: Matrix;
  34591. /**
  34592. *
  34593. * @param name The name of the effect.
  34594. * @param kernelMatrix The matrix to be applied to the image
  34595. * @param options The required width/height ratio to downsize to before computing the render pass.
  34596. * @param camera The camera to apply the render pass to.
  34597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34598. * @param engine The engine which the post process will be applied. (default: current engine)
  34599. * @param reusable If the post process can be reused on the same frame. (default: false)
  34600. */
  34601. constructor(name: string,
  34602. /** The matrix to be applied to the image */
  34603. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34604. }
  34605. }
  34606. declare module BABYLON {
  34607. /**
  34608. * Fxaa post process
  34609. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  34610. */
  34611. class FxaaPostProcess extends PostProcess {
  34612. /** @hidden */
  34613. texelWidth: number;
  34614. /** @hidden */
  34615. texelHeight: number;
  34616. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34617. private _getDefines;
  34618. }
  34619. }
  34620. declare module BABYLON {
  34621. /**
  34622. * The GrainPostProcess adds noise to the image at mid luminance levels
  34623. */
  34624. class GrainPostProcess extends PostProcess {
  34625. /**
  34626. * The intensity of the grain added (default: 30)
  34627. */
  34628. intensity: number;
  34629. /**
  34630. * If the grain should be randomized on every frame
  34631. */
  34632. animated: boolean;
  34633. /**
  34634. * Creates a new instance of @see GrainPostProcess
  34635. * @param name The name of the effect.
  34636. * @param options The required width/height ratio to downsize to before computing the render pass.
  34637. * @param camera The camera to apply the render pass to.
  34638. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34639. * @param engine The engine which the post process will be applied. (default: current engine)
  34640. * @param reusable If the post process can be reused on the same frame. (default: false)
  34641. * @param textureType Type of textures used when performing the post process. (default: 0)
  34642. * @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)
  34643. */
  34644. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34645. }
  34646. }
  34647. declare module BABYLON {
  34648. /**
  34649. * Extracts highlights from the image
  34650. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34651. */
  34652. class HighlightsPostProcess extends PostProcess {
  34653. /**
  34654. * Extracts highlights from the image
  34655. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34656. * @param name The name of the effect.
  34657. * @param options The required width/height ratio to downsize to before computing the render pass.
  34658. * @param camera The camera to apply the render pass to.
  34659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34660. * @param engine The engine which the post process will be applied. (default: current engine)
  34661. * @param reusable If the post process can be reused on the same frame. (default: false)
  34662. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  34663. */
  34664. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34665. }
  34666. }
  34667. declare module BABYLON {
  34668. /**
  34669. * ImageProcessingPostProcess
  34670. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  34671. */
  34672. class ImageProcessingPostProcess extends PostProcess {
  34673. /**
  34674. * Default configuration related to image processing available in the PBR Material.
  34675. */
  34676. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34677. /**
  34678. * Gets the image processing configuration used either in this material.
  34679. */
  34680. /**
  34681. * Sets the Default image processing configuration used either in the this material.
  34682. *
  34683. * If sets to null, the scene one is in use.
  34684. */
  34685. imageProcessingConfiguration: ImageProcessingConfiguration;
  34686. /**
  34687. * Keep track of the image processing observer to allow dispose and replace.
  34688. */
  34689. private _imageProcessingObserver;
  34690. /**
  34691. * Attaches a new image processing configuration to the PBR Material.
  34692. * @param configuration
  34693. */
  34694. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  34695. /**
  34696. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  34697. */
  34698. /**
  34699. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  34700. */
  34701. colorCurves: Nullable<ColorCurves>;
  34702. /**
  34703. * Gets wether the color curves effect is enabled.
  34704. */
  34705. /**
  34706. * Sets wether the color curves effect is enabled.
  34707. */
  34708. colorCurvesEnabled: boolean;
  34709. /**
  34710. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  34711. */
  34712. /**
  34713. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  34714. */
  34715. colorGradingTexture: Nullable<BaseTexture>;
  34716. /**
  34717. * Gets wether the color grading effect is enabled.
  34718. */
  34719. /**
  34720. * Gets wether the color grading effect is enabled.
  34721. */
  34722. colorGradingEnabled: boolean;
  34723. /**
  34724. * Gets exposure used in the effect.
  34725. */
  34726. /**
  34727. * Sets exposure used in the effect.
  34728. */
  34729. exposure: number;
  34730. /**
  34731. * Gets wether tonemapping is enabled or not.
  34732. */
  34733. /**
  34734. * Sets wether tonemapping is enabled or not
  34735. */
  34736. toneMappingEnabled: boolean;
  34737. /**
  34738. * Gets contrast used in the effect.
  34739. */
  34740. /**
  34741. * Sets contrast used in the effect.
  34742. */
  34743. contrast: number;
  34744. /**
  34745. * Gets Vignette stretch size.
  34746. */
  34747. /**
  34748. * Sets Vignette stretch size.
  34749. */
  34750. vignetteStretch: number;
  34751. /**
  34752. * Gets Vignette centre X Offset.
  34753. */
  34754. /**
  34755. * Sets Vignette centre X Offset.
  34756. */
  34757. vignetteCentreX: number;
  34758. /**
  34759. * Gets Vignette centre Y Offset.
  34760. */
  34761. /**
  34762. * Sets Vignette centre Y Offset.
  34763. */
  34764. vignetteCentreY: number;
  34765. /**
  34766. * Gets Vignette weight or intensity of the vignette effect.
  34767. */
  34768. /**
  34769. * Sets Vignette weight or intensity of the vignette effect.
  34770. */
  34771. vignetteWeight: number;
  34772. /**
  34773. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  34774. * if vignetteEnabled is set to true.
  34775. */
  34776. /**
  34777. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  34778. * if vignetteEnabled is set to true.
  34779. */
  34780. vignetteColor: Color4;
  34781. /**
  34782. * Gets Camera field of view used by the Vignette effect.
  34783. */
  34784. /**
  34785. * Sets Camera field of view used by the Vignette effect.
  34786. */
  34787. vignetteCameraFov: number;
  34788. /**
  34789. * Gets the vignette blend mode allowing different kind of effect.
  34790. */
  34791. /**
  34792. * Sets the vignette blend mode allowing different kind of effect.
  34793. */
  34794. vignetteBlendMode: number;
  34795. /**
  34796. * Gets wether the vignette effect is enabled.
  34797. */
  34798. /**
  34799. * Sets wether the vignette effect is enabled.
  34800. */
  34801. vignetteEnabled: boolean;
  34802. private _fromLinearSpace;
  34803. /**
  34804. * Gets wether the input of the processing is in Gamma or Linear Space.
  34805. */
  34806. /**
  34807. * Sets wether the input of the processing is in Gamma or Linear Space.
  34808. */
  34809. fromLinearSpace: boolean;
  34810. /**
  34811. * Defines cache preventing GC.
  34812. */
  34813. private _defines;
  34814. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  34815. /**
  34816. * "ImageProcessingPostProcess"
  34817. * @returns "ImageProcessingPostProcess"
  34818. */
  34819. getClassName(): string;
  34820. protected _updateParameters(): void;
  34821. dispose(camera?: Camera): void;
  34822. }
  34823. }
  34824. declare module BABYLON {
  34825. /**
  34826. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  34827. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  34828. * As an example, all you have to do is to create the post-process:
  34829. * var mb = new BABYLON.MotionBlurPostProcess(
  34830. * 'mb', // The name of the effect.
  34831. * scene, // The scene containing the objects to blur according to their velocity.
  34832. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  34833. * camera // The camera to apply the render pass to.
  34834. * );
  34835. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  34836. */
  34837. class MotionBlurPostProcess extends PostProcess {
  34838. /**
  34839. * Defines how much the image is blurred by the movement. Default value is equal to 1
  34840. */
  34841. motionStrength: number;
  34842. /**
  34843. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  34844. */
  34845. /**
  34846. * Sets the number of iterations to be used for motion blur quality
  34847. */
  34848. motionBlurSamples: number;
  34849. private _motionBlurSamples;
  34850. private _geometryBufferRenderer;
  34851. /**
  34852. * Creates a new instance MotionBlurPostProcess
  34853. * @param name The name of the effect.
  34854. * @param scene The scene containing the objects to blur according to their velocity.
  34855. * @param options The required width/height ratio to downsize to before computing the render pass.
  34856. * @param camera The camera to apply the render pass to.
  34857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34858. * @param engine The engine which the post process will be applied. (default: current engine)
  34859. * @param reusable If the post process can be reused on the same frame. (default: false)
  34860. * @param textureType Type of textures used when performing the post process. (default: 0)
  34861. * @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)
  34862. */
  34863. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34864. /**
  34865. * Disposes the post process.
  34866. * @param camera The camera to dispose the post process on.
  34867. */
  34868. dispose(camera?: Camera): void;
  34869. }
  34870. }
  34871. declare module BABYLON {
  34872. /**
  34873. * PassPostProcess which produces an output the same as it's input
  34874. */
  34875. class PassPostProcess extends PostProcess {
  34876. /**
  34877. * Creates the PassPostProcess
  34878. * @param name The name of the effect.
  34879. * @param options The required width/height ratio to downsize to before computing the render pass.
  34880. * @param camera The camera to apply the render pass to.
  34881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34882. * @param engine The engine which the post process will be applied. (default: current engine)
  34883. * @param reusable If the post process can be reused on the same frame. (default: false)
  34884. * @param textureType The type of texture to be used when performing the post processing.
  34885. * @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)
  34886. */
  34887. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34888. }
  34889. }
  34890. declare module BABYLON {
  34891. /**
  34892. * Size options for a post process
  34893. */
  34894. type PostProcessOptions = {
  34895. width: number;
  34896. height: number;
  34897. };
  34898. /**
  34899. * PostProcess can be used to apply a shader to a texture after it has been rendered
  34900. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34901. */
  34902. class PostProcess {
  34903. /** Name of the PostProcess. */
  34904. name: string;
  34905. /**
  34906. * Width of the texture to apply the post process on
  34907. */
  34908. width: number;
  34909. /**
  34910. * Height of the texture to apply the post process on
  34911. */
  34912. height: number;
  34913. /**
  34914. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  34915. * @hidden
  34916. */
  34917. _outputTexture: Nullable<InternalTexture>;
  34918. /**
  34919. * Sampling mode used by the shader
  34920. * See https://doc.babylonjs.com/classes/3.1/texture
  34921. */
  34922. renderTargetSamplingMode: number;
  34923. /**
  34924. * Clear color to use when screen clearing
  34925. */
  34926. clearColor: Color4;
  34927. /**
  34928. * If the buffer needs to be cleared before applying the post process. (default: true)
  34929. * Should be set to false if shader will overwrite all previous pixels.
  34930. */
  34931. autoClear: boolean;
  34932. /**
  34933. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  34934. */
  34935. alphaMode: number;
  34936. /**
  34937. * Sets the setAlphaBlendConstants of the babylon engine
  34938. */
  34939. alphaConstants: Color4;
  34940. /**
  34941. * Animations to be used for the post processing
  34942. */
  34943. animations: Animation[];
  34944. /**
  34945. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  34946. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  34947. */
  34948. enablePixelPerfectMode: boolean;
  34949. /**
  34950. * Force the postprocess to be applied without taking in account viewport
  34951. */
  34952. forceFullscreenViewport: boolean;
  34953. /**
  34954. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  34955. *
  34956. * | Value | Type | Description |
  34957. * | ----- | ----------------------------------- | ----------- |
  34958. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  34959. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  34960. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  34961. *
  34962. */
  34963. scaleMode: number;
  34964. /**
  34965. * Force textures to be a power of two (default: false)
  34966. */
  34967. alwaysForcePOT: boolean;
  34968. private _samples;
  34969. /**
  34970. * Number of sample textures (default: 1)
  34971. */
  34972. samples: number;
  34973. /**
  34974. * Modify the scale of the post process to be the same as the viewport (default: false)
  34975. */
  34976. adaptScaleToCurrentViewport: boolean;
  34977. private _camera;
  34978. private _scene;
  34979. private _engine;
  34980. private _options;
  34981. private _reusable;
  34982. private _textureType;
  34983. /**
  34984. * Smart array of input and output textures for the post process.
  34985. * @hidden
  34986. */
  34987. _textures: SmartArray<InternalTexture>;
  34988. /**
  34989. * The index in _textures that corresponds to the output texture.
  34990. * @hidden
  34991. */
  34992. _currentRenderTextureInd: number;
  34993. private _effect;
  34994. private _samplers;
  34995. private _fragmentUrl;
  34996. private _vertexUrl;
  34997. private _parameters;
  34998. private _scaleRatio;
  34999. protected _indexParameters: any;
  35000. private _shareOutputWithPostProcess;
  35001. private _texelSize;
  35002. private _forcedOutputTexture;
  35003. /**
  35004. * An event triggered when the postprocess is activated.
  35005. */
  35006. onActivateObservable: Observable<Camera>;
  35007. private _onActivateObserver;
  35008. /**
  35009. * A function that is added to the onActivateObservable
  35010. */
  35011. onActivate: Nullable<(camera: Camera) => void>;
  35012. /**
  35013. * An event triggered when the postprocess changes its size.
  35014. */
  35015. onSizeChangedObservable: Observable<PostProcess>;
  35016. private _onSizeChangedObserver;
  35017. /**
  35018. * A function that is added to the onSizeChangedObservable
  35019. */
  35020. onSizeChanged: (postProcess: PostProcess) => void;
  35021. /**
  35022. * An event triggered when the postprocess applies its effect.
  35023. */
  35024. onApplyObservable: Observable<Effect>;
  35025. private _onApplyObserver;
  35026. /**
  35027. * A function that is added to the onApplyObservable
  35028. */
  35029. onApply: (effect: Effect) => void;
  35030. /**
  35031. * An event triggered before rendering the postprocess
  35032. */
  35033. onBeforeRenderObservable: Observable<Effect>;
  35034. private _onBeforeRenderObserver;
  35035. /**
  35036. * A function that is added to the onBeforeRenderObservable
  35037. */
  35038. onBeforeRender: (effect: Effect) => void;
  35039. /**
  35040. * An event triggered after rendering the postprocess
  35041. */
  35042. onAfterRenderObservable: Observable<Effect>;
  35043. private _onAfterRenderObserver;
  35044. /**
  35045. * A function that is added to the onAfterRenderObservable
  35046. */
  35047. onAfterRender: (efect: Effect) => void;
  35048. /**
  35049. * 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
  35050. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  35051. */
  35052. inputTexture: InternalTexture;
  35053. /**
  35054. * Gets the camera which post process is applied to.
  35055. * @returns The camera the post process is applied to.
  35056. */
  35057. getCamera(): Camera;
  35058. /**
  35059. * Gets the texel size of the postprocess.
  35060. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  35061. */
  35062. readonly texelSize: Vector2;
  35063. /**
  35064. * Creates a new instance PostProcess
  35065. * @param name The name of the PostProcess.
  35066. * @param fragmentUrl The url of the fragment shader to be used.
  35067. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  35068. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  35069. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35070. * @param camera The camera to apply the render pass to.
  35071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35072. * @param engine The engine which the post process will be applied. (default: current engine)
  35073. * @param reusable If the post process can be reused on the same frame. (default: false)
  35074. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  35075. * @param textureType Type of textures used when performing the post process. (default: 0)
  35076. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  35077. * @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
  35078. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  35079. */
  35080. constructor(
  35081. /** Name of the PostProcess. */
  35082. 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);
  35083. /**
  35084. * Gets the engine which this post process belongs to.
  35085. * @returns The engine the post process was enabled with.
  35086. */
  35087. getEngine(): Engine;
  35088. /**
  35089. * The effect that is created when initializing the post process.
  35090. * @returns The created effect corrisponding the the postprocess.
  35091. */
  35092. getEffect(): Effect;
  35093. /**
  35094. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  35095. * @param postProcess The post process to share the output with.
  35096. * @returns This post process.
  35097. */
  35098. shareOutputWith(postProcess: PostProcess): PostProcess;
  35099. /**
  35100. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  35101. * This should be called if the post process that shares output with this post process is disabled/disposed.
  35102. */
  35103. useOwnOutput(): void;
  35104. /**
  35105. * Updates the effect with the current post process compile time values and recompiles the shader.
  35106. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35107. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35108. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35109. * @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
  35110. * @param onCompiled Called when the shader has been compiled.
  35111. * @param onError Called if there is an error when compiling a shader.
  35112. */
  35113. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35114. /**
  35115. * The post process is reusable if it can be used multiple times within one frame.
  35116. * @returns If the post process is reusable
  35117. */
  35118. isReusable(): boolean;
  35119. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  35120. markTextureDirty(): void;
  35121. /**
  35122. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  35123. * 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.
  35124. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  35125. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  35126. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  35127. * @returns The target texture that was bound to be written to.
  35128. */
  35129. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  35130. /**
  35131. * If the post process is supported.
  35132. */
  35133. readonly isSupported: boolean;
  35134. /**
  35135. * The aspect ratio of the output texture.
  35136. */
  35137. readonly aspectRatio: number;
  35138. /**
  35139. * Get a value indicating if the post-process is ready to be used
  35140. * @returns true if the post-process is ready (shader is compiled)
  35141. */
  35142. isReady(): boolean;
  35143. /**
  35144. * Binds all textures and uniforms to the shader, this will be run on every pass.
  35145. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  35146. */
  35147. apply(): Nullable<Effect>;
  35148. private _disposeTextures;
  35149. /**
  35150. * Disposes the post process.
  35151. * @param camera The camera to dispose the post process on.
  35152. */
  35153. dispose(camera?: Camera): void;
  35154. }
  35155. }
  35156. declare module BABYLON {
  35157. /**
  35158. * PostProcessManager is used to manage one or more post processes or post process pipelines
  35159. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35160. */
  35161. class PostProcessManager {
  35162. private _scene;
  35163. private _indexBuffer;
  35164. private _vertexBuffers;
  35165. /**
  35166. * Creates a new instance PostProcess
  35167. * @param scene The scene that the post process is associated with.
  35168. */
  35169. constructor(scene: Scene);
  35170. private _prepareBuffers;
  35171. private _buildIndexBuffer;
  35172. /**
  35173. * Rebuilds the vertex buffers of the manager.
  35174. * @hidden
  35175. */
  35176. _rebuild(): void;
  35177. /**
  35178. * Prepares a frame to be run through a post process.
  35179. * @param sourceTexture The input texture to the post procesess. (default: null)
  35180. * @param postProcesses An array of post processes to be run. (default: null)
  35181. * @returns True if the post processes were able to be run.
  35182. * @hidden
  35183. */
  35184. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  35185. /**
  35186. * Manually render a set of post processes to a texture.
  35187. * @param postProcesses An array of post processes to be run.
  35188. * @param targetTexture The target texture to render to.
  35189. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  35190. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  35191. * @param lodLevel defines which lod of the texture to render to
  35192. */
  35193. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  35194. /**
  35195. * Finalize the result of the output of the postprocesses.
  35196. * @param doNotPresent If true the result will not be displayed to the screen.
  35197. * @param targetTexture The target texture to render to.
  35198. * @param faceIndex The index of the face to bind the target texture to.
  35199. * @param postProcesses The array of post processes to render.
  35200. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  35201. * @hidden
  35202. */
  35203. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  35204. /**
  35205. * Disposes of the post process manager.
  35206. */
  35207. dispose(): void;
  35208. }
  35209. }
  35210. declare module BABYLON {
  35211. /**
  35212. * Post process which applies a refractin texture
  35213. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35214. */
  35215. class RefractionPostProcess extends PostProcess {
  35216. /** the base color of the refraction (used to taint the rendering) */
  35217. color: Color3;
  35218. /** simulated refraction depth */
  35219. depth: number;
  35220. /** the coefficient of the base color (0 to remove base color tainting) */
  35221. colorLevel: number;
  35222. private _refTexture;
  35223. private _ownRefractionTexture;
  35224. /**
  35225. * Gets or sets the refraction texture
  35226. * Please note that you are responsible for disposing the texture if you set it manually
  35227. */
  35228. refractionTexture: Texture;
  35229. /**
  35230. * Initializes the RefractionPostProcess
  35231. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35232. * @param name The name of the effect.
  35233. * @param refractionTextureUrl Url of the refraction texture to use
  35234. * @param color the base color of the refraction (used to taint the rendering)
  35235. * @param depth simulated refraction depth
  35236. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  35237. * @param camera The camera to apply the render pass to.
  35238. * @param options The required width/height ratio to downsize to before computing the render pass.
  35239. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35240. * @param engine The engine which the post process will be applied. (default: current engine)
  35241. * @param reusable If the post process can be reused on the same frame. (default: false)
  35242. */
  35243. constructor(name: string, refractionTextureUrl: string,
  35244. /** the base color of the refraction (used to taint the rendering) */
  35245. color: Color3,
  35246. /** simulated refraction depth */
  35247. depth: number,
  35248. /** the coefficient of the base color (0 to remove base color tainting) */
  35249. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35250. /**
  35251. * Disposes of the post process
  35252. * @param camera Camera to dispose post process on
  35253. */
  35254. dispose(camera: Camera): void;
  35255. }
  35256. }
  35257. declare module BABYLON {
  35258. /**
  35259. * The SharpenPostProcess applies a sharpen kernel to every pixel
  35260. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35261. */
  35262. class SharpenPostProcess extends PostProcess {
  35263. /**
  35264. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  35265. */
  35266. colorAmount: number;
  35267. /**
  35268. * How much sharpness should be applied (default: 0.3)
  35269. */
  35270. edgeAmount: number;
  35271. /**
  35272. * Creates a new instance ConvolutionPostProcess
  35273. * @param name The name of the effect.
  35274. * @param options The required width/height ratio to downsize to before computing the render pass.
  35275. * @param camera The camera to apply the render pass to.
  35276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35277. * @param engine The engine which the post process will be applied. (default: current engine)
  35278. * @param reusable If the post process can be reused on the same frame. (default: false)
  35279. * @param textureType Type of textures used when performing the post process. (default: 0)
  35280. * @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)
  35281. */
  35282. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35283. }
  35284. }
  35285. declare module BABYLON {
  35286. /**
  35287. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  35288. */
  35289. class StereoscopicInterlacePostProcess extends PostProcess {
  35290. private _stepSize;
  35291. private _passedProcess;
  35292. /**
  35293. * Initializes a StereoscopicInterlacePostProcess
  35294. * @param name The name of the effect.
  35295. * @param rigCameras The rig cameras to be appled to the post process
  35296. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  35297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35298. * @param engine The engine which the post process will be applied. (default: current engine)
  35299. * @param reusable If the post process can be reused on the same frame. (default: false)
  35300. */
  35301. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35302. }
  35303. }
  35304. declare module BABYLON {
  35305. /** Defines operator used for tonemapping */
  35306. enum TonemappingOperator {
  35307. /** Hable */
  35308. Hable = 0,
  35309. /** Reinhard */
  35310. Reinhard = 1,
  35311. /** HejiDawson */
  35312. HejiDawson = 2,
  35313. /** Photographic */
  35314. Photographic = 3
  35315. }
  35316. /**
  35317. * Defines a post process to apply tone mapping
  35318. */
  35319. class TonemapPostProcess extends PostProcess {
  35320. private _operator;
  35321. /** Defines the required exposure adjustement */
  35322. exposureAdjustment: number;
  35323. /**
  35324. * Creates a new TonemapPostProcess
  35325. * @param name defines the name of the postprocess
  35326. * @param _operator defines the operator to use
  35327. * @param exposureAdjustment defines the required exposure adjustement
  35328. * @param camera defines the camera to use (can be null)
  35329. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  35330. * @param engine defines the hosting engine (can be ignore if camera is set)
  35331. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35332. */
  35333. constructor(name: string, _operator: TonemappingOperator,
  35334. /** Defines the required exposure adjustement */
  35335. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  35336. }
  35337. }
  35338. declare module BABYLON {
  35339. /**
  35340. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  35341. */
  35342. class VolumetricLightScatteringPostProcess extends PostProcess {
  35343. private _volumetricLightScatteringPass;
  35344. private _volumetricLightScatteringRTT;
  35345. private _viewPort;
  35346. private _screenCoordinates;
  35347. private _cachedDefines;
  35348. /**
  35349. * If not undefined, the mesh position is computed from the attached node position
  35350. */
  35351. attachedNode: {
  35352. position: Vector3;
  35353. };
  35354. /**
  35355. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  35356. */
  35357. customMeshPosition: Vector3;
  35358. /**
  35359. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  35360. */
  35361. useCustomMeshPosition: boolean;
  35362. /**
  35363. * If the post-process should inverse the light scattering direction
  35364. */
  35365. invert: boolean;
  35366. /**
  35367. * The internal mesh used by the post-process
  35368. */
  35369. mesh: Mesh;
  35370. /**
  35371. * @hidden
  35372. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  35373. */
  35374. useDiffuseColor: boolean;
  35375. /**
  35376. * Array containing the excluded meshes not rendered in the internal pass
  35377. */
  35378. excludedMeshes: AbstractMesh[];
  35379. /**
  35380. * Controls the overall intensity of the post-process
  35381. */
  35382. exposure: number;
  35383. /**
  35384. * Dissipates each sample's contribution in range [0, 1]
  35385. */
  35386. decay: number;
  35387. /**
  35388. * Controls the overall intensity of each sample
  35389. */
  35390. weight: number;
  35391. /**
  35392. * Controls the density of each sample
  35393. */
  35394. density: number;
  35395. /**
  35396. * @constructor
  35397. * @param name The post-process name
  35398. * @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)
  35399. * @param camera The camera that the post-process will be attached to
  35400. * @param mesh The mesh used to create the light scattering
  35401. * @param samples The post-process quality, default 100
  35402. * @param samplingModeThe post-process filtering mode
  35403. * @param engine The babylon engine
  35404. * @param reusable If the post-process is reusable
  35405. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  35406. */
  35407. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  35408. /**
  35409. * Returns the string "VolumetricLightScatteringPostProcess"
  35410. * @returns "VolumetricLightScatteringPostProcess"
  35411. */
  35412. getClassName(): string;
  35413. private _isReady;
  35414. /**
  35415. * Sets the new light position for light scattering effect
  35416. * @param position The new custom light position
  35417. */
  35418. setCustomMeshPosition(position: Vector3): void;
  35419. /**
  35420. * Returns the light position for light scattering effect
  35421. * @return Vector3 The custom light position
  35422. */
  35423. getCustomMeshPosition(): Vector3;
  35424. /**
  35425. * Disposes the internal assets and detaches the post-process from the camera
  35426. */
  35427. dispose(camera: Camera): void;
  35428. /**
  35429. * Returns the render target texture used by the post-process
  35430. * @return the render target texture used by the post-process
  35431. */
  35432. getPass(): RenderTargetTexture;
  35433. private _meshExcluded;
  35434. private _createPass;
  35435. private _updateMeshScreenCoordinates;
  35436. /**
  35437. * Creates a default mesh for the Volumeric Light Scattering post-process
  35438. * @param name The mesh name
  35439. * @param scene The scene where to create the mesh
  35440. * @return the default mesh
  35441. */
  35442. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  35443. }
  35444. }
  35445. declare module BABYLON {
  35446. /**
  35447. * VRDistortionCorrectionPostProcess used for mobile VR
  35448. */
  35449. class VRDistortionCorrectionPostProcess extends PostProcess {
  35450. private _isRightEye;
  35451. private _distortionFactors;
  35452. private _postProcessScaleFactor;
  35453. private _lensCenterOffset;
  35454. private _scaleIn;
  35455. private _scaleFactor;
  35456. private _lensCenter;
  35457. /**
  35458. * Initializes the VRDistortionCorrectionPostProcess
  35459. * @param name The name of the effect.
  35460. * @param camera The camera to apply the render pass to.
  35461. * @param isRightEye If this is for the right eye distortion
  35462. * @param vrMetrics All the required metrics for the VR camera
  35463. */
  35464. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  35465. }
  35466. }
  35467. declare module BABYLON {
  35468. interface Scene {
  35469. /**
  35470. * The list of reflection probes added to the scene
  35471. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  35472. */
  35473. reflectionProbes: Array<ReflectionProbe>;
  35474. }
  35475. /**
  35476. * Class used to generate realtime reflection / refraction cube textures
  35477. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  35478. */
  35479. class ReflectionProbe {
  35480. /** defines the name of the probe */
  35481. name: string;
  35482. private _scene;
  35483. private _renderTargetTexture;
  35484. private _projectionMatrix;
  35485. private _viewMatrix;
  35486. private _target;
  35487. private _add;
  35488. private _attachedMesh;
  35489. private _invertYAxis;
  35490. /** Gets or sets probe position (center of the cube map) */
  35491. position: Vector3;
  35492. /**
  35493. * Creates a new reflection probe
  35494. * @param name defines the name of the probe
  35495. * @param size defines the texture resolution (for each face)
  35496. * @param scene defines the hosting scene
  35497. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  35498. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  35499. */
  35500. constructor(
  35501. /** defines the name of the probe */
  35502. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  35503. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  35504. samples: number;
  35505. /** Gets or sets the refresh rate to use (on every frame by default) */
  35506. refreshRate: number;
  35507. /**
  35508. * Gets the hosting scene
  35509. * @returns a Scene
  35510. */
  35511. getScene(): Scene;
  35512. /** Gets the internal CubeTexture used to render to */
  35513. readonly cubeTexture: RenderTargetTexture;
  35514. /** Gets the list of meshes to render */
  35515. readonly renderList: Nullable<AbstractMesh[]>;
  35516. /**
  35517. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  35518. * @param mesh defines the mesh to attach to
  35519. */
  35520. attachToMesh(mesh: AbstractMesh): void;
  35521. /**
  35522. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  35523. * @param renderingGroupId The rendering group id corresponding to its index
  35524. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35525. */
  35526. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  35527. /**
  35528. * Clean all associated resources
  35529. */
  35530. dispose(): void;
  35531. }
  35532. }
  35533. declare module BABYLON {
  35534. interface Scene {
  35535. /** @hidden (Backing field) */
  35536. _boundingBoxRenderer: BoundingBoxRenderer;
  35537. /** @hidden (Backing field) */
  35538. _forceShowBoundingBoxes: boolean;
  35539. /**
  35540. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  35541. */
  35542. forceShowBoundingBoxes: boolean;
  35543. /**
  35544. * Gets the bounding box renderer associated with the scene
  35545. * @returns a BoundingBoxRenderer
  35546. */
  35547. getBoundingBoxRenderer(): BoundingBoxRenderer;
  35548. }
  35549. interface AbstractMesh {
  35550. /** @hidden (Backing field) */
  35551. _showBoundingBox: boolean;
  35552. /**
  35553. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  35554. */
  35555. showBoundingBox: boolean;
  35556. }
  35557. /**
  35558. * Component responsible of rendering the bounding box of the meshes in a scene.
  35559. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  35560. */
  35561. class BoundingBoxRenderer implements ISceneComponent {
  35562. /**
  35563. * The component name helpfull to identify the component in the list of scene components.
  35564. */
  35565. readonly name: string;
  35566. /**
  35567. * The scene the component belongs to.
  35568. */
  35569. scene: Scene;
  35570. /**
  35571. * Color of the bounding box lines placed in front of an object
  35572. */
  35573. frontColor: Color3;
  35574. /**
  35575. * Color of the bounding box lines placed behind an object
  35576. */
  35577. backColor: Color3;
  35578. /**
  35579. * Defines if the renderer should show the back lines or not
  35580. */
  35581. showBackLines: boolean;
  35582. /**
  35583. * @hidden
  35584. */
  35585. renderList: SmartArray<BoundingBox>;
  35586. private _colorShader;
  35587. private _vertexBuffers;
  35588. private _indexBuffer;
  35589. /**
  35590. * Instantiates a new bounding box renderer in a scene.
  35591. * @param scene the scene the renderer renders in
  35592. */
  35593. constructor(scene: Scene);
  35594. /**
  35595. * Registers the component in a given scene
  35596. */
  35597. register(): void;
  35598. private _evaluateSubMesh;
  35599. private _activeMesh;
  35600. private _prepareRessources;
  35601. private _createIndexBuffer;
  35602. /**
  35603. * Rebuilds the elements related to this component in case of
  35604. * context lost for instance.
  35605. */
  35606. rebuild(): void;
  35607. /**
  35608. * @hidden
  35609. */
  35610. reset(): void;
  35611. /**
  35612. * Render the bounding boxes of a specific rendering group
  35613. * @param renderingGroupId defines the rendering group to render
  35614. */
  35615. render(renderingGroupId: number): void;
  35616. /**
  35617. * In case of occlusion queries, we can render the occlusion bounding box through this method
  35618. * @param mesh Define the mesh to render the occlusion bounding box for
  35619. */
  35620. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  35621. /**
  35622. * Dispose and release the resources attached to this renderer.
  35623. */
  35624. dispose(): void;
  35625. }
  35626. }
  35627. declare module BABYLON {
  35628. /**
  35629. * This represents a depth renderer in Babylon.
  35630. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  35631. */
  35632. class DepthRenderer {
  35633. private _scene;
  35634. private _depthMap;
  35635. private _effect;
  35636. private _cachedDefines;
  35637. private _camera;
  35638. /**
  35639. * Specifiess that the depth renderer will only be used within
  35640. * the camera it is created for.
  35641. * This can help forcing its rendering during the camera processing.
  35642. */
  35643. useOnlyInActiveCamera: boolean;
  35644. /**
  35645. * Instantiates a depth renderer
  35646. * @param scene The scene the renderer belongs to
  35647. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  35648. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  35649. */
  35650. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  35651. /**
  35652. * Creates the depth rendering effect and checks if the effect is ready.
  35653. * @param subMesh The submesh to be used to render the depth map of
  35654. * @param useInstances If multiple world instances should be used
  35655. * @returns if the depth renderer is ready to render the depth map
  35656. */
  35657. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35658. /**
  35659. * Gets the texture which the depth map will be written to.
  35660. * @returns The depth map texture
  35661. */
  35662. getDepthMap(): RenderTargetTexture;
  35663. /**
  35664. * Disposes of the depth renderer.
  35665. */
  35666. dispose(): void;
  35667. }
  35668. }
  35669. declare module BABYLON {
  35670. interface Scene {
  35671. /** @hidden (Backing field) */
  35672. _depthRenderer: {
  35673. [id: string]: DepthRenderer;
  35674. };
  35675. /**
  35676. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  35677. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  35678. * @returns the created depth renderer
  35679. */
  35680. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  35681. /**
  35682. * Disables a depth renderer for a given camera
  35683. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  35684. */
  35685. disableDepthRenderer(camera?: Nullable<Camera>): void;
  35686. }
  35687. /**
  35688. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  35689. * in several rendering techniques.
  35690. */
  35691. class DepthRendererSceneComponent implements ISceneComponent {
  35692. /**
  35693. * The component name helpfull to identify the component in the list of scene components.
  35694. */
  35695. readonly name: string;
  35696. /**
  35697. * The scene the component belongs to.
  35698. */
  35699. scene: Scene;
  35700. /**
  35701. * Creates a new instance of the component for the given scene
  35702. * @param scene Defines the scene to register the component in
  35703. */
  35704. constructor(scene: Scene);
  35705. /**
  35706. * Registers the component in a given scene
  35707. */
  35708. register(): void;
  35709. /**
  35710. * Rebuilds the elements related to this component in case of
  35711. * context lost for instance.
  35712. */
  35713. rebuild(): void;
  35714. /**
  35715. * Disposes the component and the associated ressources
  35716. */
  35717. dispose(): void;
  35718. private _gatherRenderTargets;
  35719. private _gatherActiveCameraRenderTargets;
  35720. }
  35721. }
  35722. declare module BABYLON {
  35723. interface AbstractMesh {
  35724. /**
  35725. * Disables the mesh edge rendering mode
  35726. * @returns the currentAbstractMesh
  35727. */
  35728. disableEdgesRendering(): AbstractMesh;
  35729. /**
  35730. * Enables the edge rendering mode on the mesh.
  35731. * This mode makes the mesh edges visible
  35732. * @param epsilon defines the maximal distance between two angles to detect a face
  35733. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35734. * @returns the currentAbstractMesh
  35735. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35736. */
  35737. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35738. /**
  35739. * Gets the edgesRenderer associated with the mesh
  35740. */
  35741. edgesRenderer: Nullable<EdgesRenderer>;
  35742. }
  35743. interface LinesMesh {
  35744. /**
  35745. * Enables the edge rendering mode on the mesh.
  35746. * This mode makes the mesh edges visible
  35747. * @param epsilon defines the maximal distance between two angles to detect a face
  35748. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35749. * @returns the currentAbstractMesh
  35750. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35751. */
  35752. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35753. }
  35754. interface InstancedMesh {
  35755. /**
  35756. * Enables the edge rendering mode on the mesh.
  35757. * This mode makes the mesh edges visible
  35758. * @param epsilon defines the maximal distance between two angles to detect a face
  35759. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35760. * @returns the currentInstancedMesh
  35761. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35762. */
  35763. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedMesh;
  35764. }
  35765. /**
  35766. * Defines the minimum contract an Edges renderer should follow.
  35767. */
  35768. interface IEdgesRenderer extends IDisposable {
  35769. /**
  35770. * Gets or sets a boolean indicating if the edgesRenderer is active
  35771. */
  35772. isEnabled: boolean;
  35773. /**
  35774. * Renders the edges of the attached mesh,
  35775. */
  35776. render(): void;
  35777. /**
  35778. * Checks wether or not the edges renderer is ready to render.
  35779. * @return true if ready, otherwise false.
  35780. */
  35781. isReady(): boolean;
  35782. }
  35783. /**
  35784. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  35785. */
  35786. class EdgesRenderer implements IEdgesRenderer {
  35787. /**
  35788. * Define the size of the edges with an orthographic camera
  35789. */
  35790. edgesWidthScalerForOrthographic: number;
  35791. /**
  35792. * Define the size of the edges with a perspective camera
  35793. */
  35794. edgesWidthScalerForPerspective: number;
  35795. protected _source: AbstractMesh;
  35796. protected _linesPositions: number[];
  35797. protected _linesNormals: number[];
  35798. protected _linesIndices: number[];
  35799. protected _epsilon: number;
  35800. protected _indicesCount: number;
  35801. protected _lineShader: ShaderMaterial;
  35802. protected _ib: WebGLBuffer;
  35803. protected _buffers: {
  35804. [key: string]: Nullable<VertexBuffer>;
  35805. };
  35806. protected _checkVerticesInsteadOfIndices: boolean;
  35807. private _meshRebuildObserver;
  35808. private _meshDisposeObserver;
  35809. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  35810. isEnabled: boolean;
  35811. /**
  35812. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  35813. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  35814. * @param source Mesh used to create edges
  35815. * @param epsilon sum of angles in adjacency to check for edge
  35816. * @param checkVerticesInsteadOfIndices
  35817. * @param generateEdgesLines - should generate Lines or only prepare resources.
  35818. */
  35819. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  35820. protected _prepareRessources(): void;
  35821. /** @hidden */
  35822. _rebuild(): void;
  35823. /**
  35824. * Releases the required resources for the edges renderer
  35825. */
  35826. dispose(): void;
  35827. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  35828. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  35829. /**
  35830. * Checks if the pair of p0 and p1 is en edge
  35831. * @param faceIndex
  35832. * @param edge
  35833. * @param faceNormals
  35834. * @param p0
  35835. * @param p1
  35836. * @private
  35837. */
  35838. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  35839. /**
  35840. * push line into the position, normal and index buffer
  35841. * @protected
  35842. */
  35843. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  35844. /**
  35845. * Generates lines edges from adjacencjes
  35846. * @private
  35847. */
  35848. _generateEdgesLines(): void;
  35849. /**
  35850. * Checks wether or not the edges renderer is ready to render.
  35851. * @return true if ready, otherwise false.
  35852. */
  35853. isReady(): boolean;
  35854. /**
  35855. * Renders the edges of the attached mesh,
  35856. */
  35857. render(): void;
  35858. }
  35859. }
  35860. declare module BABYLON {
  35861. /**
  35862. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  35863. */
  35864. class GeometryBufferRenderer {
  35865. /**
  35866. * Constant used to retrieve the position texture index in the G-Buffer textures array
  35867. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  35868. */
  35869. static readonly POSITION_TEXTURE_TYPE: number;
  35870. /**
  35871. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  35872. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  35873. */
  35874. static readonly VELOCITY_TEXTURE_TYPE: number;
  35875. /**
  35876. * Dictionary used to store the previous transformation matrices of each rendered mesh
  35877. * in order to compute objects velocities when enableVelocity is set to "true"
  35878. * @hidden
  35879. */
  35880. _previousTransformationMatrices: {
  35881. [index: number]: Matrix;
  35882. };
  35883. private _scene;
  35884. private _multiRenderTarget;
  35885. private _ratio;
  35886. private _enablePosition;
  35887. private _enableVelocity;
  35888. private _positionIndex;
  35889. private _velocityIndex;
  35890. protected _effect: Effect;
  35891. protected _cachedDefines: string;
  35892. /**
  35893. * Set the render list (meshes to be rendered) used in the G buffer.
  35894. */
  35895. renderList: Mesh[];
  35896. /**
  35897. * Gets wether or not G buffer are supported by the running hardware.
  35898. * This requires draw buffer supports
  35899. */
  35900. readonly isSupported: boolean;
  35901. /**
  35902. * Returns the index of the given texture type in the G-Buffer textures array
  35903. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  35904. * @returns the index of the given texture type in the G-Buffer textures array
  35905. */
  35906. getTextureIndex(textureType: number): number;
  35907. /**
  35908. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  35909. */
  35910. /**
  35911. * Sets whether or not objects positions are enabled for the G buffer.
  35912. */
  35913. enablePosition: boolean;
  35914. /**
  35915. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  35916. */
  35917. /**
  35918. * Sets wether or not objects velocities are enabled for the G buffer.
  35919. */
  35920. enableVelocity: boolean;
  35921. /**
  35922. * Gets the scene associated with the buffer.
  35923. */
  35924. readonly scene: Scene;
  35925. /**
  35926. * Gets the ratio used by the buffer during its creation.
  35927. * How big is the buffer related to the main canvas.
  35928. */
  35929. readonly ratio: number;
  35930. /**
  35931. * Creates a new G Buffer for the scene
  35932. * @param scene The scene the buffer belongs to
  35933. * @param ratio How big is the buffer related to the main canvas.
  35934. */
  35935. constructor(scene: Scene, ratio?: number);
  35936. /**
  35937. * Checks wether everything is ready to render a submesh to the G buffer.
  35938. * @param subMesh the submesh to check readiness for
  35939. * @param useInstances is the mesh drawn using instance or not
  35940. * @returns true if ready otherwise false
  35941. */
  35942. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35943. /**
  35944. * Gets the current underlying G Buffer.
  35945. * @returns the buffer
  35946. */
  35947. getGBuffer(): MultiRenderTarget;
  35948. /**
  35949. * Gets the number of samples used to render the buffer (anti aliasing).
  35950. */
  35951. /**
  35952. * Sets the number of samples used to render the buffer (anti aliasing).
  35953. */
  35954. samples: number;
  35955. /**
  35956. * Disposes the renderer and frees up associated resources.
  35957. */
  35958. dispose(): void;
  35959. protected _createRenderTargets(): void;
  35960. }
  35961. }
  35962. declare module BABYLON {
  35963. interface Scene {
  35964. /** @hidden (Backing field) */
  35965. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35966. /**
  35967. * Gets or Sets the current geometry buffer associated to the scene.
  35968. */
  35969. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35970. /**
  35971. * Enables a GeometryBufferRender and associates it with the scene
  35972. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  35973. * @returns the GeometryBufferRenderer
  35974. */
  35975. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  35976. /**
  35977. * Disables the GeometryBufferRender associated with the scene
  35978. */
  35979. disableGeometryBufferRenderer(): void;
  35980. }
  35981. /**
  35982. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  35983. * in several rendering techniques.
  35984. */
  35985. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  35986. /**
  35987. * The component name helpful to identify the component in the list of scene components.
  35988. */
  35989. readonly name: string;
  35990. /**
  35991. * The scene the component belongs to.
  35992. */
  35993. scene: Scene;
  35994. /**
  35995. * Creates a new instance of the component for the given scene
  35996. * @param scene Defines the scene to register the component in
  35997. */
  35998. constructor(scene: Scene);
  35999. /**
  36000. * Registers the component in a given scene
  36001. */
  36002. register(): void;
  36003. /**
  36004. * Rebuilds the elements related to this component in case of
  36005. * context lost for instance.
  36006. */
  36007. rebuild(): void;
  36008. /**
  36009. * Disposes the component and the associated ressources
  36010. */
  36011. dispose(): void;
  36012. private _gatherRenderTargets;
  36013. }
  36014. }
  36015. declare module BABYLON {
  36016. /**
  36017. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  36018. */
  36019. class LineEdgesRenderer extends EdgesRenderer {
  36020. /**
  36021. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  36022. * @param source LineMesh used to generate edges
  36023. * @param epsilon not important (specified angle for edge detection)
  36024. * @param checkVerticesInsteadOfIndices not important for LineMesh
  36025. */
  36026. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  36027. /**
  36028. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  36029. */
  36030. _generateEdgesLines(): void;
  36031. }
  36032. }
  36033. declare module BABYLON {
  36034. interface Scene {
  36035. /** @hidden */
  36036. _outlineRenderer: OutlineRenderer;
  36037. /**
  36038. * Gets the outline renderer associated with the scene
  36039. * @returns a OutlineRenderer
  36040. */
  36041. getOutlineRenderer(): OutlineRenderer;
  36042. }
  36043. interface AbstractMesh {
  36044. /** @hidden (Backing field) */
  36045. _renderOutline: boolean;
  36046. /**
  36047. * Gets or sets a boolean indicating if the outline must be rendered as well
  36048. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  36049. */
  36050. renderOutline: boolean;
  36051. /** @hidden (Backing field) */
  36052. _renderOverlay: boolean;
  36053. /**
  36054. * Gets or sets a boolean indicating if the overlay must be rendered as well
  36055. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  36056. */
  36057. renderOverlay: boolean;
  36058. }
  36059. /**
  36060. * This class is responsible to draw bothe outline/overlay of meshes.
  36061. * It should not be used directly but through the available method on mesh.
  36062. */
  36063. class OutlineRenderer implements ISceneComponent {
  36064. /**
  36065. * The name of the component. Each component must have a unique name.
  36066. */
  36067. name: string;
  36068. /**
  36069. * The scene the component belongs to.
  36070. */
  36071. scene: Scene;
  36072. /**
  36073. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  36074. */
  36075. zOffset: number;
  36076. private _engine;
  36077. private _effect;
  36078. private _cachedDefines;
  36079. private _savedDepthWrite;
  36080. /**
  36081. * Instantiates a new outline renderer. (There could be only one per scene).
  36082. * @param scene Defines the scene it belongs to
  36083. */
  36084. constructor(scene: Scene);
  36085. /**
  36086. * Register the component to one instance of a scene.
  36087. */
  36088. register(): void;
  36089. /**
  36090. * Rebuilds the elements related to this component in case of
  36091. * context lost for instance.
  36092. */
  36093. rebuild(): void;
  36094. /**
  36095. * Disposes the component and the associated ressources.
  36096. */
  36097. dispose(): void;
  36098. /**
  36099. * Renders the outline in the canvas.
  36100. * @param subMesh Defines the sumesh to render
  36101. * @param batch Defines the batch of meshes in case of instances
  36102. * @param useOverlay Defines if the rendering is for the overlay or the outline
  36103. */
  36104. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  36105. /**
  36106. * Returns whether or not the outline renderer is ready for a given submesh.
  36107. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  36108. * @param subMesh Defines the submesh to check readyness for
  36109. * @param useInstances Defines wheter wee are trying to render instances or not
  36110. * @returns true if ready otherwise false
  36111. */
  36112. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36113. private _beforeRenderingMesh;
  36114. private _afterRenderingMesh;
  36115. }
  36116. }
  36117. declare module BABYLON {
  36118. /**
  36119. * This represents the object necessary to create a rendering group.
  36120. * This is exclusively used and created by the rendering manager.
  36121. * To modify the behavior, you use the available helpers in your scene or meshes.
  36122. * @hidden
  36123. */
  36124. class RenderingGroup {
  36125. index: number;
  36126. private _scene;
  36127. private _opaqueSubMeshes;
  36128. private _transparentSubMeshes;
  36129. private _alphaTestSubMeshes;
  36130. private _depthOnlySubMeshes;
  36131. private _particleSystems;
  36132. private _spriteManagers;
  36133. private _opaqueSortCompareFn;
  36134. private _alphaTestSortCompareFn;
  36135. private _transparentSortCompareFn;
  36136. private _renderOpaque;
  36137. private _renderAlphaTest;
  36138. private _renderTransparent;
  36139. private _edgesRenderers;
  36140. onBeforeTransparentRendering: () => void;
  36141. /**
  36142. * Set the opaque sort comparison function.
  36143. * If null the sub meshes will be render in the order they were created
  36144. */
  36145. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36146. /**
  36147. * Set the alpha test sort comparison function.
  36148. * If null the sub meshes will be render in the order they were created
  36149. */
  36150. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36151. /**
  36152. * Set the transparent sort comparison function.
  36153. * If null the sub meshes will be render in the order they were created
  36154. */
  36155. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36156. /**
  36157. * Creates a new rendering group.
  36158. * @param index The rendering group index
  36159. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  36160. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  36161. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  36162. */
  36163. 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>);
  36164. /**
  36165. * Render all the sub meshes contained in the group.
  36166. * @param customRenderFunction Used to override the default render behaviour of the group.
  36167. * @returns true if rendered some submeshes.
  36168. */
  36169. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  36170. /**
  36171. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  36172. * @param subMeshes The submeshes to render
  36173. */
  36174. private renderOpaqueSorted;
  36175. /**
  36176. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  36177. * @param subMeshes The submeshes to render
  36178. */
  36179. private renderAlphaTestSorted;
  36180. /**
  36181. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  36182. * @param subMeshes The submeshes to render
  36183. */
  36184. private renderTransparentSorted;
  36185. /**
  36186. * Renders the submeshes in a specified order.
  36187. * @param subMeshes The submeshes to sort before render
  36188. * @param sortCompareFn The comparison function use to sort
  36189. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  36190. * @param transparent Specifies to activate blending if true
  36191. */
  36192. private static renderSorted;
  36193. /**
  36194. * Renders the submeshes in the order they were dispatched (no sort applied).
  36195. * @param subMeshes The submeshes to render
  36196. */
  36197. private static renderUnsorted;
  36198. /**
  36199. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36200. * are rendered back to front if in the same alpha index.
  36201. *
  36202. * @param a The first submesh
  36203. * @param b The second submesh
  36204. * @returns The result of the comparison
  36205. */
  36206. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  36207. /**
  36208. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36209. * are rendered back to front.
  36210. *
  36211. * @param a The first submesh
  36212. * @param b The second submesh
  36213. * @returns The result of the comparison
  36214. */
  36215. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  36216. /**
  36217. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36218. * are rendered front to back (prevent overdraw).
  36219. *
  36220. * @param a The first submesh
  36221. * @param b The second submesh
  36222. * @returns The result of the comparison
  36223. */
  36224. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  36225. /**
  36226. * Resets the different lists of submeshes to prepare a new frame.
  36227. */
  36228. prepare(): void;
  36229. dispose(): void;
  36230. /**
  36231. * Inserts the submesh in its correct queue depending on its material.
  36232. * @param subMesh The submesh to dispatch
  36233. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36234. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36235. */
  36236. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36237. dispatchSprites(spriteManager: ISpriteManager): void;
  36238. dispatchParticles(particleSystem: IParticleSystem): void;
  36239. private _renderParticles;
  36240. private _renderSprites;
  36241. }
  36242. }
  36243. declare module BABYLON {
  36244. /**
  36245. * Interface describing the different options available in the rendering manager
  36246. * regarding Auto Clear between groups.
  36247. */
  36248. interface IRenderingManagerAutoClearSetup {
  36249. /**
  36250. * Defines whether or not autoclear is enable.
  36251. */
  36252. autoClear: boolean;
  36253. /**
  36254. * Defines whether or not to autoclear the depth buffer.
  36255. */
  36256. depth: boolean;
  36257. /**
  36258. * Defines whether or not to autoclear the stencil buffer.
  36259. */
  36260. stencil: boolean;
  36261. }
  36262. /**
  36263. * This is the manager responsible of all the rendering for meshes sprites and particles.
  36264. * It is enable to manage the different groups as well as the different necessary sort functions.
  36265. * This should not be used directly aside of the few static configurations
  36266. */
  36267. class RenderingManager {
  36268. /**
  36269. * The max id used for rendering groups (not included)
  36270. */
  36271. static MAX_RENDERINGGROUPS: number;
  36272. /**
  36273. * The min id used for rendering groups (included)
  36274. */
  36275. static MIN_RENDERINGGROUPS: number;
  36276. /**
  36277. * Used to globally prevent autoclearing scenes.
  36278. */
  36279. static AUTOCLEAR: boolean;
  36280. /**
  36281. * @hidden
  36282. */
  36283. _useSceneAutoClearSetup: boolean;
  36284. private _scene;
  36285. private _renderingGroups;
  36286. private _depthStencilBufferAlreadyCleaned;
  36287. private _autoClearDepthStencil;
  36288. private _customOpaqueSortCompareFn;
  36289. private _customAlphaTestSortCompareFn;
  36290. private _customTransparentSortCompareFn;
  36291. private _renderingGroupInfo;
  36292. /**
  36293. * Instantiates a new rendering group for a particular scene
  36294. * @param scene Defines the scene the groups belongs to
  36295. */
  36296. constructor(scene: Scene);
  36297. private _clearDepthStencilBuffer;
  36298. /**
  36299. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  36300. * @hidden
  36301. */
  36302. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  36303. /**
  36304. * Resets the different information of the group to prepare a new frame
  36305. * @hidden
  36306. */
  36307. reset(): void;
  36308. /**
  36309. * Dispose and release the group and its associated resources.
  36310. * @hidden
  36311. */
  36312. dispose(): void;
  36313. /**
  36314. * Clear the info related to rendering groups preventing retention points during dispose.
  36315. */
  36316. freeRenderingGroups(): void;
  36317. private _prepareRenderingGroup;
  36318. /**
  36319. * Add a sprite manager to the rendering manager in order to render it this frame.
  36320. * @param spriteManager Define the sprite manager to render
  36321. */
  36322. dispatchSprites(spriteManager: ISpriteManager): void;
  36323. /**
  36324. * Add a particle system to the rendering manager in order to render it this frame.
  36325. * @param particleSystem Define the particle system to render
  36326. */
  36327. dispatchParticles(particleSystem: IParticleSystem): void;
  36328. /**
  36329. * Add a submesh to the manager in order to render it this frame
  36330. * @param subMesh The submesh to dispatch
  36331. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36332. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36333. */
  36334. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36335. /**
  36336. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36337. * This allowed control for front to back rendering or reversly depending of the special needs.
  36338. *
  36339. * @param renderingGroupId The rendering group id corresponding to its index
  36340. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36341. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36342. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36343. */
  36344. 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;
  36345. /**
  36346. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36347. *
  36348. * @param renderingGroupId The rendering group id corresponding to its index
  36349. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36350. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36351. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36352. */
  36353. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36354. /**
  36355. * Gets the current auto clear configuration for one rendering group of the rendering
  36356. * manager.
  36357. * @param index the rendering group index to get the information for
  36358. * @returns The auto clear setup for the requested rendering group
  36359. */
  36360. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36361. }
  36362. }
  36363. declare module BABYLON {
  36364. /**
  36365. * Renders a layer on top of an existing scene
  36366. */
  36367. class UtilityLayerRenderer implements IDisposable {
  36368. /** the original scene that will be rendered on top of */
  36369. originalScene: Scene;
  36370. private _pointerCaptures;
  36371. private _lastPointerEvents;
  36372. private static _DefaultUtilityLayer;
  36373. private static _DefaultKeepDepthUtilityLayer;
  36374. /**
  36375. * 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)
  36376. */
  36377. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  36378. /**
  36379. * 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)
  36380. */
  36381. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  36382. /**
  36383. * The scene that is rendered on top of the original scene
  36384. */
  36385. utilityLayerScene: Scene;
  36386. /**
  36387. * If the utility layer should automatically be rendered on top of existing scene
  36388. */
  36389. shouldRender: boolean;
  36390. /**
  36391. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  36392. */
  36393. onlyCheckPointerDownEvents: boolean;
  36394. /**
  36395. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  36396. */
  36397. processAllEvents: boolean;
  36398. /**
  36399. * Observable raised when the pointer move from the utility layer scene to the main scene
  36400. */
  36401. onPointerOutObservable: Observable<number>;
  36402. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  36403. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  36404. private _afterRenderObserver;
  36405. private _sceneDisposeObserver;
  36406. private _originalPointerObserver;
  36407. /**
  36408. * Instantiates a UtilityLayerRenderer
  36409. * @param originalScene the original scene that will be rendered on top of
  36410. */
  36411. constructor(
  36412. /** the original scene that will be rendered on top of */
  36413. originalScene: Scene);
  36414. private _notifyObservers;
  36415. /**
  36416. * Renders the utility layers scene on top of the original scene
  36417. */
  36418. render(): void;
  36419. /**
  36420. * Disposes of the renderer
  36421. */
  36422. dispose(): void;
  36423. private _updateCamera;
  36424. }
  36425. }
  36426. declare module BABYLON {
  36427. /**
  36428. * Class used to represent a sprite
  36429. * @see http://doc.babylonjs.com/babylon101/sprites
  36430. */
  36431. class Sprite {
  36432. /** defines the name */
  36433. name: string;
  36434. /** Gets or sets the current world position */
  36435. position: Vector3;
  36436. /** Gets or sets the main color */
  36437. color: Color4;
  36438. /** Gets or sets the width */
  36439. width: number;
  36440. /** Gets or sets the height */
  36441. height: number;
  36442. /** Gets or sets rotation angle */
  36443. angle: number;
  36444. /** Gets or sets the cell index in the sprite sheet */
  36445. cellIndex: number;
  36446. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36447. invertU: number;
  36448. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36449. invertV: number;
  36450. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36451. disposeWhenFinishedAnimating: boolean;
  36452. /** Gets the list of attached animations */
  36453. animations: Animation[];
  36454. /** Gets or sets a boolean indicating if the sprite can be picked */
  36455. isPickable: boolean;
  36456. /**
  36457. * Gets or sets the associated action manager
  36458. */
  36459. actionManager: Nullable<ActionManager>;
  36460. private _animationStarted;
  36461. private _loopAnimation;
  36462. private _fromIndex;
  36463. private _toIndex;
  36464. private _delay;
  36465. private _direction;
  36466. private _manager;
  36467. private _time;
  36468. private _onAnimationEnd;
  36469. /**
  36470. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36471. */
  36472. isVisible: boolean;
  36473. /**
  36474. * Gets or sets the sprite size
  36475. */
  36476. size: number;
  36477. /**
  36478. * Creates a new Sprite
  36479. * @param name defines the name
  36480. * @param manager defines the manager
  36481. */
  36482. constructor(
  36483. /** defines the name */
  36484. name: string, manager: ISpriteManager);
  36485. /**
  36486. * Starts an animation
  36487. * @param from defines the initial key
  36488. * @param to defines the end key
  36489. * @param loop defines if the animation must loop
  36490. * @param delay defines the start delay (in ms)
  36491. * @param onAnimationEnd defines a callback to call when animation ends
  36492. */
  36493. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  36494. /** Stops current animation (if any) */
  36495. stopAnimation(): void;
  36496. /** @hidden */
  36497. _animate(deltaTime: number): void;
  36498. /** Release associated resources */
  36499. dispose(): void;
  36500. }
  36501. }
  36502. declare module BABYLON {
  36503. /**
  36504. * Defines the minimum interface to fullfil in order to be a sprite manager.
  36505. */
  36506. interface ISpriteManager extends IDisposable {
  36507. /**
  36508. * Restricts the camera to viewing objects with the same layerMask.
  36509. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  36510. */
  36511. layerMask: number;
  36512. /**
  36513. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36514. */
  36515. isPickable: boolean;
  36516. /**
  36517. * Specifies the rendering group id for this mesh (0 by default)
  36518. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36519. */
  36520. renderingGroupId: number;
  36521. /**
  36522. * Defines the list of sprites managed by the manager.
  36523. */
  36524. sprites: Array<Sprite>;
  36525. /**
  36526. * Tests the intersection of a sprite with a specific ray.
  36527. * @param ray The ray we are sending to test the collision
  36528. * @param camera The camera space we are sending rays in
  36529. * @param predicate A predicate allowing excluding sprites from the list of object to test
  36530. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  36531. * @returns picking info or null.
  36532. */
  36533. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36534. /**
  36535. * Renders the list of sprites on screen.
  36536. */
  36537. render(): void;
  36538. }
  36539. /**
  36540. * Class used to manage multiple sprites on the same spritesheet
  36541. * @see http://doc.babylonjs.com/babylon101/sprites
  36542. */
  36543. class SpriteManager implements ISpriteManager {
  36544. /** defines the manager's name */
  36545. name: string;
  36546. /** Gets the list of sprites */
  36547. sprites: Sprite[];
  36548. /** Gets or sets the rendering group id (0 by default) */
  36549. renderingGroupId: number;
  36550. /** Gets or sets camera layer mask */
  36551. layerMask: number;
  36552. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  36553. fogEnabled: boolean;
  36554. /** Gets or sets a boolean indicating if the sprites are pickable */
  36555. isPickable: boolean;
  36556. /** Defines the default width of a cell in the spritesheet */
  36557. cellWidth: number;
  36558. /** Defines the default height of a cell in the spritesheet */
  36559. cellHeight: number;
  36560. /**
  36561. * An event triggered when the manager is disposed.
  36562. */
  36563. onDisposeObservable: Observable<SpriteManager>;
  36564. private _onDisposeObserver;
  36565. /**
  36566. * Callback called when the manager is disposed
  36567. */
  36568. onDispose: () => void;
  36569. private _capacity;
  36570. private _spriteTexture;
  36571. private _epsilon;
  36572. private _scene;
  36573. private _vertexData;
  36574. private _buffer;
  36575. private _vertexBuffers;
  36576. private _indexBuffer;
  36577. private _effectBase;
  36578. private _effectFog;
  36579. /**
  36580. * Gets or sets the spritesheet texture
  36581. */
  36582. texture: Texture;
  36583. /**
  36584. * Creates a new sprite manager
  36585. * @param name defines the manager's name
  36586. * @param imgUrl defines the sprite sheet url
  36587. * @param capacity defines the maximum allowed number of sprites
  36588. * @param cellSize defines the size of a sprite cell
  36589. * @param scene defines the hosting scene
  36590. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  36591. * @param samplingMode defines the smapling mode to use with spritesheet
  36592. */
  36593. constructor(
  36594. /** defines the manager's name */
  36595. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  36596. private _appendSpriteVertex;
  36597. /**
  36598. * Intersects the sprites with a ray
  36599. * @param ray defines the ray to intersect with
  36600. * @param camera defines the current active camera
  36601. * @param predicate defines a predicate used to select candidate sprites
  36602. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  36603. * @returns null if no hit or a PickingInfo
  36604. */
  36605. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36606. /**
  36607. * Render all child sprites
  36608. */
  36609. render(): void;
  36610. /**
  36611. * Release associated resources
  36612. */
  36613. dispose(): void;
  36614. }
  36615. }
  36616. declare module BABYLON {
  36617. interface Scene {
  36618. /** @hidden */
  36619. _pointerOverSprite: Nullable<Sprite>;
  36620. /** @hidden */
  36621. _pickedDownSprite: Nullable<Sprite>;
  36622. /** @hidden */
  36623. _tempSpritePickingRay: Nullable<Ray>;
  36624. /**
  36625. * All of the sprite managers added to this scene
  36626. * @see http://doc.babylonjs.com/babylon101/sprites
  36627. */
  36628. spriteManagers: Array<ISpriteManager>;
  36629. /**
  36630. * An event triggered when sprites rendering is about to start
  36631. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36632. */
  36633. onBeforeSpritesRenderingObservable: Observable<Scene>;
  36634. /**
  36635. * An event triggered when sprites rendering is done
  36636. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36637. */
  36638. onAfterSpritesRenderingObservable: Observable<Scene>;
  36639. /** @hidden */
  36640. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36641. /** Launch a ray to try to pick a sprite in the scene
  36642. * @param x position on screen
  36643. * @param y position on screen
  36644. * @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
  36645. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36646. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36647. * @returns a PickingInfo
  36648. */
  36649. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36650. /** Use the given ray to pick a sprite in the scene
  36651. * @param ray The ray (in world space) to use to pick meshes
  36652. * @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
  36653. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36654. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  36655. * @returns a PickingInfo
  36656. */
  36657. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36658. /**
  36659. * Force the sprite under the pointer
  36660. * @param sprite defines the sprite to use
  36661. */
  36662. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  36663. /**
  36664. * Gets the sprite under the pointer
  36665. * @returns a Sprite or null if no sprite is under the pointer
  36666. */
  36667. getPointerOverSprite(): Nullable<Sprite>;
  36668. }
  36669. /**
  36670. * Defines the sprite scene component responsible to manage sprites
  36671. * in a given scene.
  36672. */
  36673. class SpriteSceneComponent implements ISceneComponent {
  36674. /**
  36675. * The component name helpfull to identify the component in the list of scene components.
  36676. */
  36677. readonly name: string;
  36678. /**
  36679. * The scene the component belongs to.
  36680. */
  36681. scene: Scene;
  36682. /** @hidden */
  36683. private _spritePredicate;
  36684. /**
  36685. * Creates a new instance of the component for the given scene
  36686. * @param scene Defines the scene to register the component in
  36687. */
  36688. constructor(scene: Scene);
  36689. /**
  36690. * Registers the component in a given scene
  36691. */
  36692. register(): void;
  36693. /**
  36694. * Rebuilds the elements related to this component in case of
  36695. * context lost for instance.
  36696. */
  36697. rebuild(): void;
  36698. /**
  36699. * Disposes the component and the associated ressources.
  36700. */
  36701. dispose(): void;
  36702. private _pickSpriteButKeepRay;
  36703. private _pointerMove;
  36704. private _pointerDown;
  36705. private _pointerUp;
  36706. }
  36707. }
  36708. declare module BABYLON {
  36709. /**
  36710. * @hidden
  36711. **/
  36712. class _AlphaState {
  36713. private _isAlphaBlendDirty;
  36714. private _isBlendFunctionParametersDirty;
  36715. private _isBlendEquationParametersDirty;
  36716. private _isBlendConstantsDirty;
  36717. private _alphaBlend;
  36718. private _blendFunctionParameters;
  36719. private _blendEquationParameters;
  36720. private _blendConstants;
  36721. /**
  36722. * Initializes the state.
  36723. */
  36724. constructor();
  36725. readonly isDirty: boolean;
  36726. alphaBlend: boolean;
  36727. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36728. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36729. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36730. reset(): void;
  36731. apply(gl: WebGLRenderingContext): void;
  36732. }
  36733. }
  36734. declare module BABYLON {
  36735. /**
  36736. * @hidden
  36737. **/
  36738. class _DepthCullingState {
  36739. private _isDepthTestDirty;
  36740. private _isDepthMaskDirty;
  36741. private _isDepthFuncDirty;
  36742. private _isCullFaceDirty;
  36743. private _isCullDirty;
  36744. private _isZOffsetDirty;
  36745. private _isFrontFaceDirty;
  36746. private _depthTest;
  36747. private _depthMask;
  36748. private _depthFunc;
  36749. private _cull;
  36750. private _cullFace;
  36751. private _zOffset;
  36752. private _frontFace;
  36753. /**
  36754. * Initializes the state.
  36755. */
  36756. constructor();
  36757. readonly isDirty: boolean;
  36758. zOffset: number;
  36759. cullFace: Nullable<number>;
  36760. cull: Nullable<boolean>;
  36761. depthFunc: Nullable<number>;
  36762. depthMask: boolean;
  36763. depthTest: boolean;
  36764. frontFace: Nullable<number>;
  36765. reset(): void;
  36766. apply(gl: WebGLRenderingContext): void;
  36767. }
  36768. }
  36769. declare module BABYLON {
  36770. /**
  36771. * @hidden
  36772. **/
  36773. class _StencilState {
  36774. private _isStencilTestDirty;
  36775. private _isStencilMaskDirty;
  36776. private _isStencilFuncDirty;
  36777. private _isStencilOpDirty;
  36778. private _stencilTest;
  36779. private _stencilMask;
  36780. private _stencilFunc;
  36781. private _stencilFuncRef;
  36782. private _stencilFuncMask;
  36783. private _stencilOpStencilFail;
  36784. private _stencilOpDepthFail;
  36785. private _stencilOpStencilDepthPass;
  36786. readonly isDirty: boolean;
  36787. stencilFunc: number;
  36788. stencilFuncRef: number;
  36789. stencilFuncMask: number;
  36790. stencilOpStencilFail: number;
  36791. stencilOpDepthFail: number;
  36792. stencilOpStencilDepthPass: number;
  36793. stencilMask: number;
  36794. stencilTest: boolean;
  36795. constructor();
  36796. reset(): void;
  36797. apply(gl: WebGLRenderingContext): void;
  36798. }
  36799. }
  36800. declare module BABYLON {
  36801. /**
  36802. * Class used to evalaute queries containing `and` and `or` operators
  36803. */
  36804. class AndOrNotEvaluator {
  36805. /**
  36806. * Evaluate a query
  36807. * @param query defines the query to evaluate
  36808. * @param evaluateCallback defines the callback used to filter result
  36809. * @returns true if the query matches
  36810. */
  36811. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  36812. private static _HandleParenthesisContent;
  36813. private static _SimplifyNegation;
  36814. }
  36815. }
  36816. declare module BABYLON {
  36817. /**
  36818. * Defines the list of states available for a task inside a AssetsManager
  36819. */
  36820. enum AssetTaskState {
  36821. /**
  36822. * Initialization
  36823. */
  36824. INIT = 0,
  36825. /**
  36826. * Running
  36827. */
  36828. RUNNING = 1,
  36829. /**
  36830. * Done
  36831. */
  36832. DONE = 2,
  36833. /**
  36834. * Error
  36835. */
  36836. ERROR = 3
  36837. }
  36838. /**
  36839. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  36840. */
  36841. abstract class AbstractAssetTask {
  36842. /**
  36843. * Task name
  36844. */ name: string;
  36845. /**
  36846. * Callback called when the task is successful
  36847. */
  36848. onSuccess: (task: any) => void;
  36849. /**
  36850. * Callback called when the task is not successful
  36851. */
  36852. onError: (task: any, message?: string, exception?: any) => void;
  36853. /**
  36854. * Creates a new AssetsManager
  36855. * @param name defines the name of the task
  36856. */
  36857. constructor(
  36858. /**
  36859. * Task name
  36860. */ name: string);
  36861. private _isCompleted;
  36862. private _taskState;
  36863. private _errorObject;
  36864. /**
  36865. * Get if the task is completed
  36866. */
  36867. readonly isCompleted: boolean;
  36868. /**
  36869. * Gets the current state of the task
  36870. */
  36871. readonly taskState: AssetTaskState;
  36872. /**
  36873. * Gets the current error object (if task is in error)
  36874. */
  36875. readonly errorObject: {
  36876. message?: string;
  36877. exception?: any;
  36878. };
  36879. /**
  36880. * Internal only
  36881. * @hidden
  36882. */
  36883. _setErrorObject(message?: string, exception?: any): void;
  36884. /**
  36885. * Execute the current task
  36886. * @param scene defines the scene where you want your assets to be loaded
  36887. * @param onSuccess is a callback called when the task is successfully executed
  36888. * @param onError is a callback called if an error occurs
  36889. */
  36890. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36891. /**
  36892. * Execute the current task
  36893. * @param scene defines the scene where you want your assets to be loaded
  36894. * @param onSuccess is a callback called when the task is successfully executed
  36895. * @param onError is a callback called if an error occurs
  36896. */
  36897. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36898. /**
  36899. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  36900. * This can be used with failed tasks that have the reason for failure fixed.
  36901. */
  36902. reset(): void;
  36903. private onErrorCallback;
  36904. private onDoneCallback;
  36905. }
  36906. /**
  36907. * Define the interface used by progress events raised during assets loading
  36908. */
  36909. interface IAssetsProgressEvent {
  36910. /**
  36911. * Defines the number of remaining tasks to process
  36912. */
  36913. remainingCount: number;
  36914. /**
  36915. * Defines the total number of tasks
  36916. */
  36917. totalCount: number;
  36918. /**
  36919. * Defines the task that was just processed
  36920. */
  36921. task: AbstractAssetTask;
  36922. }
  36923. /**
  36924. * Class used to share progress information about assets loading
  36925. */
  36926. class AssetsProgressEvent implements IAssetsProgressEvent {
  36927. /**
  36928. * Defines the number of remaining tasks to process
  36929. */
  36930. remainingCount: number;
  36931. /**
  36932. * Defines the total number of tasks
  36933. */
  36934. totalCount: number;
  36935. /**
  36936. * Defines the task that was just processed
  36937. */
  36938. task: AbstractAssetTask;
  36939. /**
  36940. * Creates a AssetsProgressEvent
  36941. * @param remainingCount defines the number of remaining tasks to process
  36942. * @param totalCount defines the total number of tasks
  36943. * @param task defines the task that was just processed
  36944. */
  36945. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  36946. }
  36947. /**
  36948. * Define a task used by AssetsManager to load meshes
  36949. */
  36950. class MeshAssetTask extends AbstractAssetTask {
  36951. /**
  36952. * Defines the name of the task
  36953. */
  36954. name: string;
  36955. /**
  36956. * Defines the list of mesh's names you want to load
  36957. */
  36958. meshesNames: any;
  36959. /**
  36960. * Defines the root url to use as a base to load your meshes and associated resources
  36961. */
  36962. rootUrl: string;
  36963. /**
  36964. * Defines the filename of the scene to load from
  36965. */
  36966. sceneFilename: string;
  36967. /**
  36968. * Gets the list of loaded meshes
  36969. */
  36970. loadedMeshes: Array<AbstractMesh>;
  36971. /**
  36972. * Gets the list of loaded particle systems
  36973. */
  36974. loadedParticleSystems: Array<IParticleSystem>;
  36975. /**
  36976. * Gets the list of loaded skeletons
  36977. */
  36978. loadedSkeletons: Array<Skeleton>;
  36979. /**
  36980. * Callback called when the task is successful
  36981. */
  36982. onSuccess: (task: MeshAssetTask) => void;
  36983. /**
  36984. * Callback called when the task is successful
  36985. */
  36986. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  36987. /**
  36988. * Creates a new MeshAssetTask
  36989. * @param name defines the name of the task
  36990. * @param meshesNames defines the list of mesh's names you want to load
  36991. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  36992. * @param sceneFilename defines the filename of the scene to load from
  36993. */
  36994. constructor(
  36995. /**
  36996. * Defines the name of the task
  36997. */
  36998. name: string,
  36999. /**
  37000. * Defines the list of mesh's names you want to load
  37001. */
  37002. meshesNames: any,
  37003. /**
  37004. * Defines the root url to use as a base to load your meshes and associated resources
  37005. */
  37006. rootUrl: string,
  37007. /**
  37008. * Defines the filename of the scene to load from
  37009. */
  37010. sceneFilename: string);
  37011. /**
  37012. * Execute the current task
  37013. * @param scene defines the scene where you want your assets to be loaded
  37014. * @param onSuccess is a callback called when the task is successfully executed
  37015. * @param onError is a callback called if an error occurs
  37016. */
  37017. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37018. }
  37019. /**
  37020. * Define a task used by AssetsManager to load text content
  37021. */
  37022. class TextFileAssetTask extends AbstractAssetTask {
  37023. /**
  37024. * Defines the name of the task
  37025. */
  37026. name: string;
  37027. /**
  37028. * Defines the location of the file to load
  37029. */
  37030. url: string;
  37031. /**
  37032. * Gets the loaded text string
  37033. */
  37034. text: string;
  37035. /**
  37036. * Callback called when the task is successful
  37037. */
  37038. onSuccess: (task: TextFileAssetTask) => void;
  37039. /**
  37040. * Callback called when the task is successful
  37041. */
  37042. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  37043. /**
  37044. * Creates a new TextFileAssetTask object
  37045. * @param name defines the name of the task
  37046. * @param url defines the location of the file to load
  37047. */
  37048. constructor(
  37049. /**
  37050. * Defines the name of the task
  37051. */
  37052. name: string,
  37053. /**
  37054. * Defines the location of the file to load
  37055. */
  37056. url: string);
  37057. /**
  37058. * Execute the current task
  37059. * @param scene defines the scene where you want your assets to be loaded
  37060. * @param onSuccess is a callback called when the task is successfully executed
  37061. * @param onError is a callback called if an error occurs
  37062. */
  37063. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37064. }
  37065. /**
  37066. * Define a task used by AssetsManager to load binary data
  37067. */
  37068. class BinaryFileAssetTask extends AbstractAssetTask {
  37069. /**
  37070. * Defines the name of the task
  37071. */
  37072. name: string;
  37073. /**
  37074. * Defines the location of the file to load
  37075. */
  37076. url: string;
  37077. /**
  37078. * Gets the lodaded data (as an array buffer)
  37079. */
  37080. data: ArrayBuffer;
  37081. /**
  37082. * Callback called when the task is successful
  37083. */
  37084. onSuccess: (task: BinaryFileAssetTask) => void;
  37085. /**
  37086. * Callback called when the task is successful
  37087. */
  37088. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37089. /**
  37090. * Creates a new BinaryFileAssetTask object
  37091. * @param name defines the name of the new task
  37092. * @param url defines the location of the file to load
  37093. */
  37094. constructor(
  37095. /**
  37096. * Defines the name of the task
  37097. */
  37098. name: string,
  37099. /**
  37100. * Defines the location of the file to load
  37101. */
  37102. url: string);
  37103. /**
  37104. * Execute the current task
  37105. * @param scene defines the scene where you want your assets to be loaded
  37106. * @param onSuccess is a callback called when the task is successfully executed
  37107. * @param onError is a callback called if an error occurs
  37108. */
  37109. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37110. }
  37111. /**
  37112. * Define a task used by AssetsManager to load images
  37113. */
  37114. class ImageAssetTask extends AbstractAssetTask {
  37115. /**
  37116. * Defines the name of the task
  37117. */
  37118. name: string;
  37119. /**
  37120. * Defines the location of the image to load
  37121. */
  37122. url: string;
  37123. /**
  37124. * Gets the loaded images
  37125. */
  37126. image: HTMLImageElement;
  37127. /**
  37128. * Callback called when the task is successful
  37129. */
  37130. onSuccess: (task: ImageAssetTask) => void;
  37131. /**
  37132. * Callback called when the task is successful
  37133. */
  37134. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37135. /**
  37136. * Creates a new ImageAssetTask
  37137. * @param name defines the name of the task
  37138. * @param url defines the location of the image to load
  37139. */
  37140. constructor(
  37141. /**
  37142. * Defines the name of the task
  37143. */
  37144. name: string,
  37145. /**
  37146. * Defines the location of the image to load
  37147. */
  37148. url: string);
  37149. /**
  37150. * Execute the current task
  37151. * @param scene defines the scene where you want your assets to be loaded
  37152. * @param onSuccess is a callback called when the task is successfully executed
  37153. * @param onError is a callback called if an error occurs
  37154. */
  37155. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37156. }
  37157. /**
  37158. * Defines the interface used by texture loading tasks
  37159. */
  37160. interface ITextureAssetTask<TEX extends BaseTexture> {
  37161. /**
  37162. * Gets the loaded texture
  37163. */
  37164. texture: TEX;
  37165. }
  37166. /**
  37167. * Define a task used by AssetsManager to load 2D textures
  37168. */
  37169. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37170. /**
  37171. * Defines the name of the task
  37172. */
  37173. name: string;
  37174. /**
  37175. * Defines the location of the file to load
  37176. */
  37177. url: string;
  37178. /**
  37179. * Defines if mipmap should not be generated (default is false)
  37180. */
  37181. noMipmap?: boolean | undefined;
  37182. /**
  37183. * Defines if texture must be inverted on Y axis (default is false)
  37184. */
  37185. invertY?: boolean | undefined;
  37186. /**
  37187. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37188. */
  37189. samplingMode: number;
  37190. /**
  37191. * Gets the loaded texture
  37192. */
  37193. texture: Texture;
  37194. /**
  37195. * Callback called when the task is successful
  37196. */
  37197. onSuccess: (task: TextureAssetTask) => void;
  37198. /**
  37199. * Callback called when the task is successful
  37200. */
  37201. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37202. /**
  37203. * Creates a new TextureAssetTask object
  37204. * @param name defines the name of the task
  37205. * @param url defines the location of the file to load
  37206. * @param noMipmap defines if mipmap should not be generated (default is false)
  37207. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37208. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37209. */
  37210. constructor(
  37211. /**
  37212. * Defines the name of the task
  37213. */
  37214. name: string,
  37215. /**
  37216. * Defines the location of the file to load
  37217. */
  37218. url: string,
  37219. /**
  37220. * Defines if mipmap should not be generated (default is false)
  37221. */
  37222. noMipmap?: boolean | undefined,
  37223. /**
  37224. * Defines if texture must be inverted on Y axis (default is false)
  37225. */
  37226. invertY?: boolean | undefined,
  37227. /**
  37228. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37229. */
  37230. samplingMode?: number);
  37231. /**
  37232. * Execute the current task
  37233. * @param scene defines the scene where you want your assets to be loaded
  37234. * @param onSuccess is a callback called when the task is successfully executed
  37235. * @param onError is a callback called if an error occurs
  37236. */
  37237. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37238. }
  37239. /**
  37240. * Define a task used by AssetsManager to load cube textures
  37241. */
  37242. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37243. /**
  37244. * Defines the name of the task
  37245. */
  37246. name: string;
  37247. /**
  37248. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37249. */
  37250. url: string;
  37251. /**
  37252. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37253. */
  37254. extensions?: string[] | undefined;
  37255. /**
  37256. * Defines if mipmaps should not be generated (default is false)
  37257. */
  37258. noMipmap?: boolean | undefined;
  37259. /**
  37260. * Defines the explicit list of files (undefined by default)
  37261. */
  37262. files?: string[] | undefined;
  37263. /**
  37264. * Gets the loaded texture
  37265. */
  37266. texture: CubeTexture;
  37267. /**
  37268. * Callback called when the task is successful
  37269. */
  37270. onSuccess: (task: CubeTextureAssetTask) => void;
  37271. /**
  37272. * Callback called when the task is successful
  37273. */
  37274. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37275. /**
  37276. * Creates a new CubeTextureAssetTask
  37277. * @param name defines the name of the task
  37278. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37279. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37280. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37281. * @param files defines the explicit list of files (undefined by default)
  37282. */
  37283. constructor(
  37284. /**
  37285. * Defines the name of the task
  37286. */
  37287. name: string,
  37288. /**
  37289. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37290. */
  37291. url: string,
  37292. /**
  37293. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37294. */
  37295. extensions?: string[] | undefined,
  37296. /**
  37297. * Defines if mipmaps should not be generated (default is false)
  37298. */
  37299. noMipmap?: boolean | undefined,
  37300. /**
  37301. * Defines the explicit list of files (undefined by default)
  37302. */
  37303. files?: string[] | undefined);
  37304. /**
  37305. * Execute the current task
  37306. * @param scene defines the scene where you want your assets to be loaded
  37307. * @param onSuccess is a callback called when the task is successfully executed
  37308. * @param onError is a callback called if an error occurs
  37309. */
  37310. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37311. }
  37312. /**
  37313. * Define a task used by AssetsManager to load HDR cube textures
  37314. */
  37315. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37316. /**
  37317. * Defines the name of the task
  37318. */
  37319. name: string;
  37320. /**
  37321. * Defines the location of the file to load
  37322. */
  37323. url: string;
  37324. /**
  37325. * Defines the desired size (the more it increases the longer the generation will be)
  37326. */
  37327. size: number;
  37328. /**
  37329. * Defines if mipmaps should not be generated (default is false)
  37330. */
  37331. noMipmap: boolean;
  37332. /**
  37333. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37334. */
  37335. generateHarmonics: boolean;
  37336. /**
  37337. * 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)
  37338. */
  37339. gammaSpace: boolean;
  37340. /**
  37341. * Internal Use Only
  37342. */
  37343. reserved: boolean;
  37344. /**
  37345. * Gets the loaded texture
  37346. */
  37347. texture: HDRCubeTexture;
  37348. /**
  37349. * Callback called when the task is successful
  37350. */
  37351. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37352. /**
  37353. * Callback called when the task is successful
  37354. */
  37355. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37356. /**
  37357. * Creates a new HDRCubeTextureAssetTask object
  37358. * @param name defines the name of the task
  37359. * @param url defines the location of the file to load
  37360. * @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.
  37361. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37362. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37363. * @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)
  37364. * @param reserved Internal use only
  37365. */
  37366. constructor(
  37367. /**
  37368. * Defines the name of the task
  37369. */
  37370. name: string,
  37371. /**
  37372. * Defines the location of the file to load
  37373. */
  37374. url: string,
  37375. /**
  37376. * Defines the desired size (the more it increases the longer the generation will be)
  37377. */
  37378. size: number,
  37379. /**
  37380. * Defines if mipmaps should not be generated (default is false)
  37381. */
  37382. noMipmap?: boolean,
  37383. /**
  37384. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37385. */
  37386. generateHarmonics?: boolean,
  37387. /**
  37388. * 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)
  37389. */
  37390. gammaSpace?: boolean,
  37391. /**
  37392. * Internal Use Only
  37393. */
  37394. reserved?: boolean);
  37395. /**
  37396. * Execute the current task
  37397. * @param scene defines the scene where you want your assets to be loaded
  37398. * @param onSuccess is a callback called when the task is successfully executed
  37399. * @param onError is a callback called if an error occurs
  37400. */
  37401. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37402. }
  37403. /**
  37404. * This class can be used to easily import assets into a scene
  37405. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37406. */
  37407. class AssetsManager {
  37408. private _scene;
  37409. private _isLoading;
  37410. protected _tasks: AbstractAssetTask[];
  37411. protected _waitingTasksCount: number;
  37412. protected _totalTasksCount: number;
  37413. /**
  37414. * Callback called when all tasks are processed
  37415. */
  37416. onFinish: (tasks: AbstractAssetTask[]) => void;
  37417. /**
  37418. * Callback called when a task is successful
  37419. */
  37420. onTaskSuccess: (task: AbstractAssetTask) => void;
  37421. /**
  37422. * Callback called when a task had an error
  37423. */
  37424. onTaskError: (task: AbstractAssetTask) => void;
  37425. /**
  37426. * Callback called when a task is done (whatever the result is)
  37427. */
  37428. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37429. /**
  37430. * Observable called when all tasks are processed
  37431. */
  37432. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37433. /**
  37434. * Observable called when a task had an error
  37435. */
  37436. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37437. /**
  37438. * Observable called when a task is successful
  37439. */
  37440. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37441. /**
  37442. * Observable called when a task is done (whatever the result is)
  37443. */
  37444. onProgressObservable: Observable<IAssetsProgressEvent>;
  37445. /**
  37446. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37447. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37448. */
  37449. useDefaultLoadingScreen: boolean;
  37450. /**
  37451. * Creates a new AssetsManager
  37452. * @param scene defines the scene to work on
  37453. */
  37454. constructor(scene: Scene);
  37455. /**
  37456. * Add a MeshAssetTask to the list of active tasks
  37457. * @param taskName defines the name of the new task
  37458. * @param meshesNames defines the name of meshes to load
  37459. * @param rootUrl defines the root url to use to locate files
  37460. * @param sceneFilename defines the filename of the scene file
  37461. * @returns a new MeshAssetTask object
  37462. */
  37463. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37464. /**
  37465. * Add a TextFileAssetTask to the list of active tasks
  37466. * @param taskName defines the name of the new task
  37467. * @param url defines the url of the file to load
  37468. * @returns a new TextFileAssetTask object
  37469. */
  37470. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37471. /**
  37472. * Add a BinaryFileAssetTask to the list of active tasks
  37473. * @param taskName defines the name of the new task
  37474. * @param url defines the url of the file to load
  37475. * @returns a new BinaryFileAssetTask object
  37476. */
  37477. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37478. /**
  37479. * Add a ImageAssetTask to the list of active tasks
  37480. * @param taskName defines the name of the new task
  37481. * @param url defines the url of the file to load
  37482. * @returns a new ImageAssetTask object
  37483. */
  37484. addImageTask(taskName: string, url: string): ImageAssetTask;
  37485. /**
  37486. * Add a TextureAssetTask to the list of active tasks
  37487. * @param taskName defines the name of the new task
  37488. * @param url defines the url of the file to load
  37489. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37490. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37491. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37492. * @returns a new TextureAssetTask object
  37493. */
  37494. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37495. /**
  37496. * Add a CubeTextureAssetTask to the list of active tasks
  37497. * @param taskName defines the name of the new task
  37498. * @param url defines the url of the file to load
  37499. * @param extensions defines the extension to use to load the cube map (can be null)
  37500. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37501. * @param files defines the list of files to load (can be null)
  37502. * @returns a new CubeTextureAssetTask object
  37503. */
  37504. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  37505. /**
  37506. *
  37507. * Add a HDRCubeTextureAssetTask to the list of active tasks
  37508. * @param taskName defines the name of the new task
  37509. * @param url defines the url of the file to load
  37510. * @param size defines the size you want for the cubemap (can be null)
  37511. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37512. * @param generateHarmonics defines if you want to automatically generate (true by default)
  37513. * @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)
  37514. * @param reserved Internal use only
  37515. * @returns a new HDRCubeTextureAssetTask object
  37516. */
  37517. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  37518. /**
  37519. * Remove a task from the assets manager.
  37520. * @param task the task to remove
  37521. */
  37522. removeTask(task: AbstractAssetTask): void;
  37523. private _decreaseWaitingTasksCount;
  37524. private _runTask;
  37525. /**
  37526. * Reset the AssetsManager and remove all tasks
  37527. * @return the current instance of the AssetsManager
  37528. */
  37529. reset(): AssetsManager;
  37530. /**
  37531. * Start the loading process
  37532. * @return the current instance of the AssetsManager
  37533. */
  37534. load(): AssetsManager;
  37535. }
  37536. }
  37537. declare module BABYLON {
  37538. /**
  37539. * Direct draw surface info
  37540. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  37541. */
  37542. interface DDSInfo {
  37543. /**
  37544. * Width of the texture
  37545. */
  37546. width: number;
  37547. /**
  37548. * Width of the texture
  37549. */
  37550. height: number;
  37551. /**
  37552. * Number of Mipmaps for the texture
  37553. * @see https://en.wikipedia.org/wiki/Mipmap
  37554. */
  37555. mipmapCount: number;
  37556. /**
  37557. * If the textures format is a known fourCC format
  37558. * @see https://www.fourcc.org/
  37559. */
  37560. isFourCC: boolean;
  37561. /**
  37562. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  37563. */
  37564. isRGB: boolean;
  37565. /**
  37566. * If the texture is a lumincance format
  37567. */
  37568. isLuminance: boolean;
  37569. /**
  37570. * If this is a cube texture
  37571. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  37572. */
  37573. isCube: boolean;
  37574. /**
  37575. * If the texture is a compressed format eg. FOURCC_DXT1
  37576. */
  37577. isCompressed: boolean;
  37578. /**
  37579. * The dxgiFormat of the texture
  37580. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  37581. */
  37582. dxgiFormat: number;
  37583. /**
  37584. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  37585. */
  37586. textureType: number;
  37587. /**
  37588. * Sphericle polynomial created for the dds texture
  37589. */
  37590. sphericalPolynomial?: SphericalPolynomial;
  37591. }
  37592. /**
  37593. * Class used to provide DDS decompression tools
  37594. */
  37595. class DDSTools {
  37596. /**
  37597. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  37598. */
  37599. static StoreLODInAlphaChannel: boolean;
  37600. /**
  37601. * Gets DDS information from an array buffer
  37602. * @param arrayBuffer defines the array buffer to read data from
  37603. * @returns the DDS information
  37604. */
  37605. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  37606. private static _FloatView;
  37607. private static _Int32View;
  37608. private static _ToHalfFloat;
  37609. private static _FromHalfFloat;
  37610. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  37611. private static _GetHalfFloatRGBAArrayBuffer;
  37612. private static _GetFloatRGBAArrayBuffer;
  37613. private static _GetFloatAsUIntRGBAArrayBuffer;
  37614. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  37615. private static _GetRGBAArrayBuffer;
  37616. private static _ExtractLongWordOrder;
  37617. private static _GetRGBArrayBuffer;
  37618. private static _GetLuminanceArrayBuffer;
  37619. /**
  37620. * Uploads DDS Levels to a Babylon Texture
  37621. * @hidden
  37622. */
  37623. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  37624. }
  37625. }
  37626. declare module BABYLON {
  37627. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37628. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37629. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37630. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37631. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37632. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37633. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37634. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37635. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37636. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37637. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37638. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37639. /**
  37640. * Decorator used to define property that can be serialized as reference to a camera
  37641. * @param sourceName defines the name of the property to decorate
  37642. */
  37643. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37644. /**
  37645. * Class used to help serialization objects
  37646. */
  37647. class SerializationHelper {
  37648. /**
  37649. * Static function used to serialized a specific entity
  37650. * @param entity defines the entity to serialize
  37651. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37652. * @returns a JSON compatible object representing the serialization of the entity
  37653. */
  37654. static Serialize<T>(entity: T, serializationObject?: any): any;
  37655. /**
  37656. * Creates a new entity from a serialization data object
  37657. * @param creationFunction defines a function used to instanciated the new entity
  37658. * @param source defines the source serialization data
  37659. * @param scene defines the hosting scene
  37660. * @param rootUrl defines the root url for resources
  37661. * @returns a new entity
  37662. */
  37663. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37664. /**
  37665. * Clones an object
  37666. * @param creationFunction defines the function used to instanciate the new object
  37667. * @param source defines the source object
  37668. * @returns the cloned object
  37669. */
  37670. static Clone<T>(creationFunction: () => T, source: T): T;
  37671. /**
  37672. * Instanciates a new object based on a source one (some data will be shared between both object)
  37673. * @param creationFunction defines the function used to instanciate the new object
  37674. * @param source defines the source object
  37675. * @returns the new object
  37676. */
  37677. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37678. }
  37679. }
  37680. declare module BABYLON {
  37681. /**
  37682. * Wrapper class for promise with external resolve and reject.
  37683. */
  37684. class Deferred<T> {
  37685. /**
  37686. * The promise associated with this deferred object.
  37687. */
  37688. readonly promise: Promise<T>;
  37689. private _resolve;
  37690. private _reject;
  37691. /**
  37692. * The resolve method of the promise associated with this deferred object.
  37693. */
  37694. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  37695. /**
  37696. * The reject method of the promise associated with this deferred object.
  37697. */
  37698. readonly reject: (reason?: any) => void;
  37699. /**
  37700. * Constructor for this deferred object.
  37701. */
  37702. constructor();
  37703. }
  37704. }
  37705. declare module BABYLON {
  37706. /**
  37707. * Raw texture data and descriptor sufficient for WebGL texture upload
  37708. */
  37709. interface EnvironmentTextureInfo {
  37710. /**
  37711. * Version of the environment map
  37712. */
  37713. version: number;
  37714. /**
  37715. * Width of image
  37716. */
  37717. width: number;
  37718. /**
  37719. * Irradiance information stored in the file.
  37720. */
  37721. irradiance: any;
  37722. /**
  37723. * Specular information stored in the file.
  37724. */
  37725. specular: any;
  37726. }
  37727. /**
  37728. * Sets of helpers addressing the serialization and deserialization of environment texture
  37729. * stored in a BabylonJS env file.
  37730. * Those files are usually stored as .env files.
  37731. */
  37732. class EnvironmentTextureTools {
  37733. /**
  37734. * Magic number identifying the env file.
  37735. */
  37736. private static _MagicBytes;
  37737. /**
  37738. * Gets the environment info from an env file.
  37739. * @param data The array buffer containing the .env bytes.
  37740. * @returns the environment file info (the json header) if successfully parsed.
  37741. */
  37742. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  37743. /**
  37744. * Creates an environment texture from a loaded cube texture.
  37745. * @param texture defines the cube texture to convert in env file
  37746. * @return a promise containing the environment data if succesfull.
  37747. */
  37748. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  37749. /**
  37750. * Creates a JSON representation of the spherical data.
  37751. * @param texture defines the texture containing the polynomials
  37752. * @return the JSON representation of the spherical info
  37753. */
  37754. private static _CreateEnvTextureIrradiance;
  37755. /**
  37756. * Uploads the texture info contained in the env file to the GPU.
  37757. * @param texture defines the internal texture to upload to
  37758. * @param arrayBuffer defines the buffer cotaining the data to load
  37759. * @param info defines the texture info retrieved through the GetEnvInfo method
  37760. * @returns a promise
  37761. */
  37762. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  37763. /**
  37764. * Uploads the levels of image data to the GPU.
  37765. * @param texture defines the internal texture to upload to
  37766. * @param imageData defines the array buffer views of image data [mipmap][face]
  37767. * @returns a promise
  37768. */
  37769. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  37770. /**
  37771. * Uploads spherical polynomials information to the texture.
  37772. * @param texture defines the texture we are trying to upload the information to
  37773. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  37774. */
  37775. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  37776. }
  37777. }
  37778. declare module BABYLON {
  37779. /**
  37780. * Class used to help managing file picking and drag'n'drop
  37781. */
  37782. class FilesInput {
  37783. /**
  37784. * List of files ready to be loaded
  37785. */
  37786. static FilesToLoad: {
  37787. [key: string]: File;
  37788. };
  37789. /**
  37790. * Callback called when a file is processed
  37791. */
  37792. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  37793. private _engine;
  37794. private _currentScene;
  37795. private _sceneLoadedCallback;
  37796. private _progressCallback;
  37797. private _additionalRenderLoopLogicCallback;
  37798. private _textureLoadingCallback;
  37799. private _startingProcessingFilesCallback;
  37800. private _onReloadCallback;
  37801. private _errorCallback;
  37802. private _elementToMonitor;
  37803. private _sceneFileToLoad;
  37804. private _filesToLoad;
  37805. /**
  37806. * Creates a new FilesInput
  37807. * @param engine defines the rendering engine
  37808. * @param scene defines the hosting scene
  37809. * @param sceneLoadedCallback callback called when scene is loaded
  37810. * @param progressCallback callback called to track progress
  37811. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  37812. * @param textureLoadingCallback callback called when a texture is loading
  37813. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  37814. * @param onReloadCallback callback called when a reload is requested
  37815. * @param errorCallback callback call if an error occurs
  37816. */
  37817. 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);
  37818. private _dragEnterHandler;
  37819. private _dragOverHandler;
  37820. private _dropHandler;
  37821. /**
  37822. * Calls this function to listen to drag'n'drop events on a specific DOM element
  37823. * @param elementToMonitor defines the DOM element to track
  37824. */
  37825. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  37826. /**
  37827. * Release all associated resources
  37828. */
  37829. dispose(): void;
  37830. private renderFunction;
  37831. private drag;
  37832. private drop;
  37833. private _traverseFolder;
  37834. private _processFiles;
  37835. /**
  37836. * Load files from a drop event
  37837. * @param event defines the drop event to use as source
  37838. */
  37839. loadFiles(event: any): void;
  37840. private _processReload;
  37841. /**
  37842. * Reload the current scene from the loaded files
  37843. */
  37844. reload(): void;
  37845. }
  37846. }
  37847. declare module BABYLON {
  37848. /**
  37849. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  37850. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  37851. */
  37852. class KhronosTextureContainer {
  37853. /** contents of the KTX container file */
  37854. arrayBuffer: any;
  37855. private static HEADER_LEN;
  37856. private static COMPRESSED_2D;
  37857. private static COMPRESSED_3D;
  37858. private static TEX_2D;
  37859. private static TEX_3D;
  37860. /**
  37861. * Gets the openGL type
  37862. */
  37863. glType: number;
  37864. /**
  37865. * Gets the openGL type size
  37866. */
  37867. glTypeSize: number;
  37868. /**
  37869. * Gets the openGL format
  37870. */
  37871. glFormat: number;
  37872. /**
  37873. * Gets the openGL internal format
  37874. */
  37875. glInternalFormat: number;
  37876. /**
  37877. * Gets the base internal format
  37878. */
  37879. glBaseInternalFormat: number;
  37880. /**
  37881. * Gets image width in pixel
  37882. */
  37883. pixelWidth: number;
  37884. /**
  37885. * Gets image height in pixel
  37886. */
  37887. pixelHeight: number;
  37888. /**
  37889. * Gets image depth in pixels
  37890. */
  37891. pixelDepth: number;
  37892. /**
  37893. * Gets the number of array elements
  37894. */
  37895. numberOfArrayElements: number;
  37896. /**
  37897. * Gets the number of faces
  37898. */
  37899. numberOfFaces: number;
  37900. /**
  37901. * Gets the number of mipmap levels
  37902. */
  37903. numberOfMipmapLevels: number;
  37904. /**
  37905. * Gets the bytes of key value data
  37906. */
  37907. bytesOfKeyValueData: number;
  37908. /**
  37909. * Gets the load type
  37910. */
  37911. loadType: number;
  37912. /**
  37913. * Creates a new KhronosTextureContainer
  37914. * @param arrayBuffer contents of the KTX container file
  37915. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  37916. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  37917. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  37918. */
  37919. constructor(
  37920. /** contents of the KTX container file */
  37921. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  37922. /**
  37923. * Revert the endianness of a value.
  37924. * Not as fast hardware based, but will probably never need to use
  37925. * @param val defines the value to convert
  37926. * @returns the new value
  37927. */
  37928. switchEndianness(val: number): number;
  37929. /**
  37930. * Uploads KTX content to a Babylon Texture.
  37931. * It is assumed that the texture has already been created & is currently bound
  37932. * @hidden
  37933. */
  37934. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  37935. private _upload2DCompressedLevels;
  37936. }
  37937. }
  37938. declare module BABYLON {
  37939. /**
  37940. * A class serves as a medium between the observable and its observers
  37941. */
  37942. class EventState {
  37943. /**
  37944. * Create a new EventState
  37945. * @param mask defines the mask associated with this state
  37946. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  37947. * @param target defines the original target of the state
  37948. * @param currentTarget defines the current target of the state
  37949. */
  37950. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  37951. /**
  37952. * Initialize the current event state
  37953. * @param mask defines the mask associated with this state
  37954. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  37955. * @param target defines the original target of the state
  37956. * @param currentTarget defines the current target of the state
  37957. * @returns the current event state
  37958. */
  37959. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  37960. /**
  37961. * An Observer can set this property to true to prevent subsequent observers of being notified
  37962. */
  37963. skipNextObservers: boolean;
  37964. /**
  37965. * Get the mask value that were used to trigger the event corresponding to this EventState object
  37966. */
  37967. mask: number;
  37968. /**
  37969. * The object that originally notified the event
  37970. */
  37971. target?: any;
  37972. /**
  37973. * The current object in the bubbling phase
  37974. */
  37975. currentTarget?: any;
  37976. /**
  37977. * This will be populated with the return value of the last function that was executed.
  37978. * If it is the first function in the callback chain it will be the event data.
  37979. */
  37980. lastReturnValue?: any;
  37981. }
  37982. /**
  37983. * Represent an Observer registered to a given Observable object.
  37984. */
  37985. class Observer<T> {
  37986. /**
  37987. * Defines the callback to call when the observer is notified
  37988. */
  37989. callback: (eventData: T, eventState: EventState) => void;
  37990. /**
  37991. * Defines the mask of the observer (used to filter notifications)
  37992. */
  37993. mask: number;
  37994. /**
  37995. * Defines the current scope used to restore the JS context
  37996. */
  37997. scope: any;
  37998. /** @hidden */
  37999. _willBeUnregistered: boolean;
  38000. /**
  38001. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  38002. */
  38003. unregisterOnNextCall: boolean;
  38004. /**
  38005. * Creates a new observer
  38006. * @param callback defines the callback to call when the observer is notified
  38007. * @param mask defines the mask of the observer (used to filter notifications)
  38008. * @param scope defines the current scope used to restore the JS context
  38009. */
  38010. constructor(
  38011. /**
  38012. * Defines the callback to call when the observer is notified
  38013. */
  38014. callback: (eventData: T, eventState: EventState) => void,
  38015. /**
  38016. * Defines the mask of the observer (used to filter notifications)
  38017. */
  38018. mask: number,
  38019. /**
  38020. * Defines the current scope used to restore the JS context
  38021. */
  38022. scope?: any);
  38023. }
  38024. /**
  38025. * Represent a list of observers registered to multiple Observables object.
  38026. */
  38027. class MultiObserver<T> {
  38028. private _observers;
  38029. private _observables;
  38030. /**
  38031. * Release associated resources
  38032. */
  38033. dispose(): void;
  38034. /**
  38035. * Raise a callback when one of the observable will notify
  38036. * @param observables defines a list of observables to watch
  38037. * @param callback defines the callback to call on notification
  38038. * @param mask defines the mask used to filter notifications
  38039. * @param scope defines the current scope used to restore the JS context
  38040. * @returns the new MultiObserver
  38041. */
  38042. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  38043. }
  38044. /**
  38045. * The Observable class is a simple implementation of the Observable pattern.
  38046. *
  38047. * 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.
  38048. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  38049. * 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).
  38050. * 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.
  38051. */
  38052. class Observable<T> {
  38053. private _observers;
  38054. private _eventState;
  38055. private _onObserverAdded;
  38056. /**
  38057. * Creates a new observable
  38058. * @param onObserverAdded defines a callback to call when a new observer is added
  38059. */
  38060. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  38061. /**
  38062. * Create a new Observer with the specified callback
  38063. * @param callback the callback that will be executed for that Observer
  38064. * @param mask the mask used to filter observers
  38065. * @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.
  38066. * @param scope optional scope for the callback to be called from
  38067. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38068. * @returns the new observer created for the callback
  38069. */
  38070. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38071. /**
  38072. * Create a new Observer with the specified callback and unregisters after the next notification
  38073. * @param callback the callback that will be executed for that Observer
  38074. * @returns the new observer created for the callback
  38075. */
  38076. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38077. /**
  38078. * Remove an Observer from the Observable object
  38079. * @param observer the instance of the Observer to remove
  38080. * @returns false if it doesn't belong to this Observable
  38081. */
  38082. remove(observer: Nullable<Observer<T>>): boolean;
  38083. /**
  38084. * Remove a callback from the Observable object
  38085. * @param callback the callback to remove
  38086. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38087. * @returns false if it doesn't belong to this Observable
  38088. */
  38089. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38090. private _deferUnregister;
  38091. private _remove;
  38092. /**
  38093. * Notify all Observers by calling their respective callback with the given data
  38094. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38095. * @param eventData defines the data to send to all observers
  38096. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38097. * @param target defines the original target of the state
  38098. * @param currentTarget defines the current target of the state
  38099. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38100. */
  38101. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38102. /**
  38103. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38104. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38105. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38106. * and it is crucial that all callbacks will be executed.
  38107. * The order of the callbacks is kept, callbacks are not executed parallel.
  38108. *
  38109. * @param eventData The data to be sent to each callback
  38110. * @param mask is used to filter observers defaults to -1
  38111. * @param target defines the callback target (see EventState)
  38112. * @param currentTarget defines he current object in the bubbling phase
  38113. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38114. */
  38115. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38116. /**
  38117. * Notify a specific observer
  38118. * @param observer defines the observer to notify
  38119. * @param eventData defines the data to be sent to each callback
  38120. * @param mask is used to filter observers defaults to -1
  38121. */
  38122. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38123. /**
  38124. * Gets a boolean indicating if the observable has at least one observer
  38125. * @returns true is the Observable has at least one Observer registered
  38126. */
  38127. hasObservers(): boolean;
  38128. /**
  38129. * Clear the list of observers
  38130. */
  38131. clear(): void;
  38132. /**
  38133. * Clone the current observable
  38134. * @returns a new observable
  38135. */
  38136. clone(): Observable<T>;
  38137. /**
  38138. * Does this observable handles observer registered with a given mask
  38139. * @param mask defines the mask to be tested
  38140. * @return whether or not one observer registered with the given mask is handeled
  38141. **/
  38142. hasSpecificMask(mask?: number): boolean;
  38143. }
  38144. }
  38145. declare module BABYLON {
  38146. /**
  38147. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38148. */
  38149. class PerformanceMonitor {
  38150. private _enabled;
  38151. private _rollingFrameTime;
  38152. private _lastFrameTimeMs;
  38153. /**
  38154. * constructor
  38155. * @param frameSampleSize The number of samples required to saturate the sliding window
  38156. */
  38157. constructor(frameSampleSize?: number);
  38158. /**
  38159. * Samples current frame
  38160. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38161. */
  38162. sampleFrame(timeMs?: number): void;
  38163. /**
  38164. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38165. */
  38166. readonly averageFrameTime: number;
  38167. /**
  38168. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38169. */
  38170. readonly averageFrameTimeVariance: number;
  38171. /**
  38172. * Returns the frame time of the most recent frame
  38173. */
  38174. readonly instantaneousFrameTime: number;
  38175. /**
  38176. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38177. */
  38178. readonly averageFPS: number;
  38179. /**
  38180. * Returns the average framerate in frames per second using the most recent frame time
  38181. */
  38182. readonly instantaneousFPS: number;
  38183. /**
  38184. * Returns true if enough samples have been taken to completely fill the sliding window
  38185. */
  38186. readonly isSaturated: boolean;
  38187. /**
  38188. * Enables contributions to the sliding window sample set
  38189. */
  38190. enable(): void;
  38191. /**
  38192. * Disables contributions to the sliding window sample set
  38193. * Samples will not be interpolated over the disabled period
  38194. */
  38195. disable(): void;
  38196. /**
  38197. * Returns true if sampling is enabled
  38198. */
  38199. readonly isEnabled: boolean;
  38200. /**
  38201. * Resets performance monitor
  38202. */
  38203. reset(): void;
  38204. }
  38205. /**
  38206. * RollingAverage
  38207. *
  38208. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38209. */
  38210. class RollingAverage {
  38211. /**
  38212. * Current average
  38213. */
  38214. average: number;
  38215. /**
  38216. * Current variance
  38217. */
  38218. variance: number;
  38219. protected _samples: Array<number>;
  38220. protected _sampleCount: number;
  38221. protected _pos: number;
  38222. protected _m2: number;
  38223. /**
  38224. * constructor
  38225. * @param length The number of samples required to saturate the sliding window
  38226. */
  38227. constructor(length: number);
  38228. /**
  38229. * Adds a sample to the sample set
  38230. * @param v The sample value
  38231. */
  38232. add(v: number): void;
  38233. /**
  38234. * Returns previously added values or null if outside of history or outside the sliding window domain
  38235. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38236. * @return Value previously recorded with add() or null if outside of range
  38237. */
  38238. history(i: number): number;
  38239. /**
  38240. * Returns true if enough samples have been taken to completely fill the sliding window
  38241. * @return true if sample-set saturated
  38242. */
  38243. isSaturated(): boolean;
  38244. /**
  38245. * Resets the rolling average (equivalent to 0 samples taken so far)
  38246. */
  38247. reset(): void;
  38248. /**
  38249. * Wraps a value around the sample range boundaries
  38250. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38251. * @return Wrapped position in sample range
  38252. */
  38253. protected _wrapPosition(i: number): number;
  38254. }
  38255. }
  38256. declare module BABYLON {
  38257. /**
  38258. * Helper class that provides a small promise polyfill
  38259. */
  38260. class PromisePolyfill {
  38261. /**
  38262. * Static function used to check if the polyfill is required
  38263. * If this is the case then the function will inject the polyfill to window.Promise
  38264. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38265. */
  38266. static Apply(force?: boolean): void;
  38267. }
  38268. }
  38269. declare module BABYLON {
  38270. /**
  38271. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38272. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38273. */
  38274. class SceneOptimization {
  38275. /**
  38276. * Defines the priority of this optimization (0 by default which means first in the list)
  38277. */
  38278. priority: number;
  38279. /**
  38280. * Gets a string describing the action executed by the current optimization
  38281. * @returns description string
  38282. */
  38283. getDescription(): string;
  38284. /**
  38285. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38286. * @param scene defines the current scene where to apply this optimization
  38287. * @param optimizer defines the current optimizer
  38288. * @returns true if everything that can be done was applied
  38289. */
  38290. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38291. /**
  38292. * Creates the SceneOptimization object
  38293. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38294. * @param desc defines the description associated with the optimization
  38295. */
  38296. constructor(
  38297. /**
  38298. * Defines the priority of this optimization (0 by default which means first in the list)
  38299. */
  38300. priority?: number);
  38301. }
  38302. /**
  38303. * Defines an optimization used to reduce the size of render target textures
  38304. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38305. */
  38306. class TextureOptimization extends SceneOptimization {
  38307. /**
  38308. * Defines the priority of this optimization (0 by default which means first in the list)
  38309. */
  38310. priority: number;
  38311. /**
  38312. * 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
  38313. */
  38314. maximumSize: number;
  38315. /**
  38316. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38317. */
  38318. step: number;
  38319. /**
  38320. * Gets a string describing the action executed by the current optimization
  38321. * @returns description string
  38322. */
  38323. getDescription(): string;
  38324. /**
  38325. * Creates the TextureOptimization object
  38326. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38327. * @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
  38328. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38329. */
  38330. constructor(
  38331. /**
  38332. * Defines the priority of this optimization (0 by default which means first in the list)
  38333. */
  38334. priority?: number,
  38335. /**
  38336. * 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
  38337. */
  38338. maximumSize?: number,
  38339. /**
  38340. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38341. */
  38342. step?: number);
  38343. /**
  38344. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38345. * @param scene defines the current scene where to apply this optimization
  38346. * @param optimizer defines the current optimizer
  38347. * @returns true if everything that can be done was applied
  38348. */
  38349. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38350. }
  38351. /**
  38352. * Defines an optimization used to increase or decrease the rendering resolution
  38353. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38354. */
  38355. class HardwareScalingOptimization extends SceneOptimization {
  38356. /**
  38357. * Defines the priority of this optimization (0 by default which means first in the list)
  38358. */
  38359. priority: number;
  38360. /**
  38361. * Defines the maximum scale to use (2 by default)
  38362. */
  38363. maximumScale: number;
  38364. /**
  38365. * Defines the step to use between two passes (0.5 by default)
  38366. */
  38367. step: number;
  38368. private _currentScale;
  38369. private _directionOffset;
  38370. /**
  38371. * Gets a string describing the action executed by the current optimization
  38372. * @return description string
  38373. */
  38374. getDescription(): string;
  38375. /**
  38376. * Creates the HardwareScalingOptimization object
  38377. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38378. * @param maximumScale defines the maximum scale to use (2 by default)
  38379. * @param step defines the step to use between two passes (0.5 by default)
  38380. */
  38381. constructor(
  38382. /**
  38383. * Defines the priority of this optimization (0 by default which means first in the list)
  38384. */
  38385. priority?: number,
  38386. /**
  38387. * Defines the maximum scale to use (2 by default)
  38388. */
  38389. maximumScale?: number,
  38390. /**
  38391. * Defines the step to use between two passes (0.5 by default)
  38392. */
  38393. step?: number);
  38394. /**
  38395. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38396. * @param scene defines the current scene where to apply this optimization
  38397. * @param optimizer defines the current optimizer
  38398. * @returns true if everything that can be done was applied
  38399. */
  38400. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38401. }
  38402. /**
  38403. * Defines an optimization used to remove shadows
  38404. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38405. */
  38406. class ShadowsOptimization extends SceneOptimization {
  38407. /**
  38408. * Gets a string describing the action executed by the current optimization
  38409. * @return description string
  38410. */
  38411. getDescription(): string;
  38412. /**
  38413. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38414. * @param scene defines the current scene where to apply this optimization
  38415. * @param optimizer defines the current optimizer
  38416. * @returns true if everything that can be done was applied
  38417. */
  38418. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38419. }
  38420. /**
  38421. * Defines an optimization used to turn post-processes off
  38422. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38423. */
  38424. class PostProcessesOptimization extends SceneOptimization {
  38425. /**
  38426. * Gets a string describing the action executed by the current optimization
  38427. * @return description string
  38428. */
  38429. getDescription(): string;
  38430. /**
  38431. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38432. * @param scene defines the current scene where to apply this optimization
  38433. * @param optimizer defines the current optimizer
  38434. * @returns true if everything that can be done was applied
  38435. */
  38436. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38437. }
  38438. /**
  38439. * Defines an optimization used to turn lens flares off
  38440. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38441. */
  38442. class LensFlaresOptimization extends SceneOptimization {
  38443. /**
  38444. * Gets a string describing the action executed by the current optimization
  38445. * @return description string
  38446. */
  38447. getDescription(): string;
  38448. /**
  38449. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38450. * @param scene defines the current scene where to apply this optimization
  38451. * @param optimizer defines the current optimizer
  38452. * @returns true if everything that can be done was applied
  38453. */
  38454. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38455. }
  38456. /**
  38457. * Defines an optimization based on user defined callback.
  38458. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38459. */
  38460. class CustomOptimization extends SceneOptimization {
  38461. /**
  38462. * Callback called to apply the custom optimization.
  38463. */
  38464. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38465. /**
  38466. * Callback called to get custom description
  38467. */
  38468. onGetDescription: () => string;
  38469. /**
  38470. * Gets a string describing the action executed by the current optimization
  38471. * @returns description string
  38472. */
  38473. getDescription(): string;
  38474. /**
  38475. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38476. * @param scene defines the current scene where to apply this optimization
  38477. * @param optimizer defines the current optimizer
  38478. * @returns true if everything that can be done was applied
  38479. */
  38480. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38481. }
  38482. /**
  38483. * Defines an optimization used to turn particles off
  38484. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38485. */
  38486. class ParticlesOptimization extends SceneOptimization {
  38487. /**
  38488. * Gets a string describing the action executed by the current optimization
  38489. * @return description string
  38490. */
  38491. getDescription(): string;
  38492. /**
  38493. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38494. * @param scene defines the current scene where to apply this optimization
  38495. * @param optimizer defines the current optimizer
  38496. * @returns true if everything that can be done was applied
  38497. */
  38498. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38499. }
  38500. /**
  38501. * Defines an optimization used to turn render targets off
  38502. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38503. */
  38504. class RenderTargetsOptimization extends SceneOptimization {
  38505. /**
  38506. * Gets a string describing the action executed by the current optimization
  38507. * @return description string
  38508. */
  38509. getDescription(): string;
  38510. /**
  38511. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38512. * @param scene defines the current scene where to apply this optimization
  38513. * @param optimizer defines the current optimizer
  38514. * @returns true if everything that can be done was applied
  38515. */
  38516. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38517. }
  38518. /**
  38519. * Defines an optimization used to merge meshes with compatible materials
  38520. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38521. */
  38522. class MergeMeshesOptimization extends SceneOptimization {
  38523. private static _UpdateSelectionTree;
  38524. /**
  38525. * Gets or sets a boolean which defines if optimization octree has to be updated
  38526. */
  38527. /**
  38528. * Gets or sets a boolean which defines if optimization octree has to be updated
  38529. */
  38530. static UpdateSelectionTree: boolean;
  38531. /**
  38532. * Gets a string describing the action executed by the current optimization
  38533. * @return description string
  38534. */
  38535. getDescription(): string;
  38536. private _canBeMerged;
  38537. /**
  38538. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38539. * @param scene defines the current scene where to apply this optimization
  38540. * @param optimizer defines the current optimizer
  38541. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  38542. * @returns true if everything that can be done was applied
  38543. */
  38544. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  38545. }
  38546. /**
  38547. * Defines a list of options used by SceneOptimizer
  38548. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38549. */
  38550. class SceneOptimizerOptions {
  38551. /**
  38552. * Defines the target frame rate to reach (60 by default)
  38553. */
  38554. targetFrameRate: number;
  38555. /**
  38556. * Defines the interval between two checkes (2000ms by default)
  38557. */
  38558. trackerDuration: number;
  38559. /**
  38560. * Gets the list of optimizations to apply
  38561. */
  38562. optimizations: SceneOptimization[];
  38563. /**
  38564. * Creates a new list of options used by SceneOptimizer
  38565. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  38566. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  38567. */
  38568. constructor(
  38569. /**
  38570. * Defines the target frame rate to reach (60 by default)
  38571. */
  38572. targetFrameRate?: number,
  38573. /**
  38574. * Defines the interval between two checkes (2000ms by default)
  38575. */
  38576. trackerDuration?: number);
  38577. /**
  38578. * Add a new optimization
  38579. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  38580. * @returns the current SceneOptimizerOptions
  38581. */
  38582. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  38583. /**
  38584. * Add a new custom optimization
  38585. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  38586. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  38587. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38588. * @returns the current SceneOptimizerOptions
  38589. */
  38590. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  38591. /**
  38592. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  38593. * @param targetFrameRate defines the target frame rate (60 by default)
  38594. * @returns a SceneOptimizerOptions object
  38595. */
  38596. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38597. /**
  38598. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  38599. * @param targetFrameRate defines the target frame rate (60 by default)
  38600. * @returns a SceneOptimizerOptions object
  38601. */
  38602. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38603. /**
  38604. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  38605. * @param targetFrameRate defines the target frame rate (60 by default)
  38606. * @returns a SceneOptimizerOptions object
  38607. */
  38608. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38609. }
  38610. /**
  38611. * Class used to run optimizations in order to reach a target frame rate
  38612. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38613. */
  38614. class SceneOptimizer implements IDisposable {
  38615. private _isRunning;
  38616. private _options;
  38617. private _scene;
  38618. private _currentPriorityLevel;
  38619. private _targetFrameRate;
  38620. private _trackerDuration;
  38621. private _currentFrameRate;
  38622. private _sceneDisposeObserver;
  38623. private _improvementMode;
  38624. /**
  38625. * Defines an observable called when the optimizer reaches the target frame rate
  38626. */
  38627. onSuccessObservable: Observable<SceneOptimizer>;
  38628. /**
  38629. * Defines an observable called when the optimizer enables an optimization
  38630. */
  38631. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  38632. /**
  38633. * Defines an observable called when the optimizer is not able to reach the target frame rate
  38634. */
  38635. onFailureObservable: Observable<SceneOptimizer>;
  38636. /**
  38637. * Gets a boolean indicating if the optimizer is in improvement mode
  38638. */
  38639. readonly isInImprovementMode: boolean;
  38640. /**
  38641. * Gets the current priority level (0 at start)
  38642. */
  38643. readonly currentPriorityLevel: number;
  38644. /**
  38645. * Gets the current frame rate checked by the SceneOptimizer
  38646. */
  38647. readonly currentFrameRate: number;
  38648. /**
  38649. * Gets or sets the current target frame rate (60 by default)
  38650. */
  38651. /**
  38652. * Gets or sets the current target frame rate (60 by default)
  38653. */
  38654. targetFrameRate: number;
  38655. /**
  38656. * Gets or sets the current interval between two checks (every 2000ms by default)
  38657. */
  38658. /**
  38659. * Gets or sets the current interval between two checks (every 2000ms by default)
  38660. */
  38661. trackerDuration: number;
  38662. /**
  38663. * Gets the list of active optimizations
  38664. */
  38665. readonly optimizations: SceneOptimization[];
  38666. /**
  38667. * Creates a new SceneOptimizer
  38668. * @param scene defines the scene to work on
  38669. * @param options defines the options to use with the SceneOptimizer
  38670. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  38671. * @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)
  38672. */
  38673. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  38674. /**
  38675. * Stops the current optimizer
  38676. */
  38677. stop(): void;
  38678. /**
  38679. * Reset the optimizer to initial step (current priority level = 0)
  38680. */
  38681. reset(): void;
  38682. /**
  38683. * Start the optimizer. By default it will try to reach a specific framerate
  38684. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  38685. */
  38686. start(): void;
  38687. private _checkCurrentState;
  38688. /**
  38689. * Release all resources
  38690. */
  38691. dispose(): void;
  38692. /**
  38693. * Helper function to create a SceneOptimizer with one single line of code
  38694. * @param scene defines the scene to work on
  38695. * @param options defines the options to use with the SceneOptimizer
  38696. * @param onSuccess defines a callback to call on success
  38697. * @param onFailure defines a callback to call on failure
  38698. * @returns the new SceneOptimizer object
  38699. */
  38700. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  38701. }
  38702. }
  38703. declare module BABYLON {
  38704. /**
  38705. * Class used to serialize a scene into a string
  38706. */
  38707. class SceneSerializer {
  38708. /**
  38709. * Clear cache used by a previous serialization
  38710. */
  38711. static ClearCache(): void;
  38712. /**
  38713. * Serialize a scene into a JSON compatible object
  38714. * @param scene defines the scene to serialize
  38715. * @returns a JSON compatible object
  38716. */
  38717. static Serialize(scene: Scene): any;
  38718. /**
  38719. * Serialize a mesh into a JSON compatible object
  38720. * @param toSerialize defines the mesh to serialize
  38721. * @param withParents defines if parents must be serialized as well
  38722. * @param withChildren defines if children must be serialized as well
  38723. * @returns a JSON compatible object
  38724. */
  38725. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  38726. }
  38727. }
  38728. declare module BABYLON {
  38729. /**
  38730. * Defines an array and its length.
  38731. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  38732. */
  38733. interface ISmartArrayLike<T> {
  38734. /**
  38735. * The data of the array.
  38736. */
  38737. data: Array<T>;
  38738. /**
  38739. * The active length of the array.
  38740. */
  38741. length: number;
  38742. }
  38743. /**
  38744. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38745. */
  38746. class SmartArray<T> implements ISmartArrayLike<T> {
  38747. /**
  38748. * The full set of data from the array.
  38749. */
  38750. data: Array<T>;
  38751. /**
  38752. * The active length of the array.
  38753. */
  38754. length: number;
  38755. protected _id: number;
  38756. /**
  38757. * Instantiates a Smart Array.
  38758. * @param capacity defines the default capacity of the array.
  38759. */
  38760. constructor(capacity: number);
  38761. /**
  38762. * Pushes a value at the end of the active data.
  38763. * @param value defines the object to push in the array.
  38764. */
  38765. push(value: T): void;
  38766. /**
  38767. * Iterates over the active data and apply the lambda to them.
  38768. * @param func defines the action to apply on each value.
  38769. */
  38770. forEach(func: (content: T) => void): void;
  38771. /**
  38772. * Sorts the full sets of data.
  38773. * @param compareFn defines the comparison function to apply.
  38774. */
  38775. sort(compareFn: (a: T, b: T) => number): void;
  38776. /**
  38777. * Resets the active data to an empty array.
  38778. */
  38779. reset(): void;
  38780. /**
  38781. * Releases all the data from the array as well as the array.
  38782. */
  38783. dispose(): void;
  38784. /**
  38785. * Concats the active data with a given array.
  38786. * @param array defines the data to concatenate with.
  38787. */
  38788. concat(array: any): void;
  38789. /**
  38790. * Returns the position of a value in the active data.
  38791. * @param value defines the value to find the index for
  38792. * @returns the index if found in the active data otherwise -1
  38793. */
  38794. indexOf(value: T): number;
  38795. /**
  38796. * Returns whether an element is part of the active data.
  38797. * @param value defines the value to look for
  38798. * @returns true if found in the active data otherwise false
  38799. */
  38800. contains(value: T): boolean;
  38801. private static _GlobalId;
  38802. }
  38803. /**
  38804. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38805. * The data in this array can only be present once
  38806. */
  38807. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  38808. private _duplicateId;
  38809. /**
  38810. * Pushes a value at the end of the active data.
  38811. * THIS DOES NOT PREVENT DUPPLICATE DATA
  38812. * @param value defines the object to push in the array.
  38813. */
  38814. push(value: T): void;
  38815. /**
  38816. * Pushes a value at the end of the active data.
  38817. * If the data is already present, it won t be added again
  38818. * @param value defines the object to push in the array.
  38819. * @returns true if added false if it was already present
  38820. */
  38821. pushNoDuplicate(value: T): boolean;
  38822. /**
  38823. * Resets the active data to an empty array.
  38824. */
  38825. reset(): void;
  38826. /**
  38827. * Concats the active data with a given array.
  38828. * This ensures no dupplicate will be present in the result.
  38829. * @param array defines the data to concatenate with.
  38830. */
  38831. concatWithNoDuplicate(array: any): void;
  38832. }
  38833. }
  38834. declare module BABYLON {
  38835. /**
  38836. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38837. * The underlying implementation relies on an associative array to ensure the best performances.
  38838. * The value can be anything including 'null' but except 'undefined'
  38839. */
  38840. class StringDictionary<T> {
  38841. /**
  38842. * This will clear this dictionary and copy the content from the 'source' one.
  38843. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38844. * @param source the dictionary to take the content from and copy to this dictionary
  38845. */
  38846. copyFrom(source: StringDictionary<T>): void;
  38847. /**
  38848. * Get a value based from its key
  38849. * @param key the given key to get the matching value from
  38850. * @return the value if found, otherwise undefined is returned
  38851. */
  38852. get(key: string): T | undefined;
  38853. /**
  38854. * Get a value from its key or add it if it doesn't exist.
  38855. * This method will ensure you that a given key/data will be present in the dictionary.
  38856. * @param key the given key to get the matching value from
  38857. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38858. * The factory will only be invoked if there's no data for the given key.
  38859. * @return the value corresponding to the key.
  38860. */
  38861. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38862. /**
  38863. * Get a value from its key if present in the dictionary otherwise add it
  38864. * @param key the key to get the value from
  38865. * @param val if there's no such key/value pair in the dictionary add it with this value
  38866. * @return the value corresponding to the key
  38867. */
  38868. getOrAdd(key: string, val: T): T;
  38869. /**
  38870. * Check if there's a given key in the dictionary
  38871. * @param key the key to check for
  38872. * @return true if the key is present, false otherwise
  38873. */
  38874. contains(key: string): boolean;
  38875. /**
  38876. * Add a new key and its corresponding value
  38877. * @param key the key to add
  38878. * @param value the value corresponding to the key
  38879. * @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
  38880. */
  38881. add(key: string, value: T): boolean;
  38882. /**
  38883. * Update a specific value associated to a key
  38884. * @param key defines the key to use
  38885. * @param value defines the value to store
  38886. * @returns true if the value was updated (or false if the key was not found)
  38887. */
  38888. set(key: string, value: T): boolean;
  38889. /**
  38890. * Get the element of the given key and remove it from the dictionary
  38891. * @param key defines the key to search
  38892. * @returns the value associated with the key or null if not found
  38893. */
  38894. getAndRemove(key: string): Nullable<T>;
  38895. /**
  38896. * Remove a key/value from the dictionary.
  38897. * @param key the key to remove
  38898. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38899. */
  38900. remove(key: string): boolean;
  38901. /**
  38902. * Clear the whole content of the dictionary
  38903. */
  38904. clear(): void;
  38905. /**
  38906. * Gets the current count
  38907. */
  38908. readonly count: number;
  38909. /**
  38910. * Execute a callback on each key/val of the dictionary.
  38911. * Note that you can remove any element in this dictionary in the callback implementation
  38912. * @param callback the callback to execute on a given key/value pair
  38913. */
  38914. forEach(callback: (key: string, val: T) => void): void;
  38915. /**
  38916. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38917. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38918. * Note that you can remove any element in this dictionary in the callback implementation
  38919. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38920. * @returns the first item
  38921. */
  38922. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38923. private _count;
  38924. private _data;
  38925. }
  38926. }
  38927. declare module BABYLON {
  38928. /**
  38929. * Class used to store custom tags
  38930. */
  38931. class Tags {
  38932. /**
  38933. * Adds support for tags on the given object
  38934. * @param obj defines the object to use
  38935. */
  38936. static EnableFor(obj: any): void;
  38937. /**
  38938. * Removes tags support
  38939. * @param obj defines the object to use
  38940. */
  38941. static DisableFor(obj: any): void;
  38942. /**
  38943. * Gets a boolean indicating if the given object has tags
  38944. * @param obj defines the object to use
  38945. * @returns a boolean
  38946. */
  38947. static HasTags(obj: any): boolean;
  38948. /**
  38949. * Gets the tags available on a given object
  38950. * @param obj defines the object to use
  38951. * @param asString defines if the tags must be returned as a string instead of an array of strings
  38952. * @returns the tags
  38953. */
  38954. static GetTags(obj: any, asString?: boolean): any;
  38955. /**
  38956. * Adds tags to an object
  38957. * @param obj defines the object to use
  38958. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  38959. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  38960. */
  38961. static AddTagsTo(obj: any, tagsString: string): void;
  38962. /**
  38963. * @hidden
  38964. */
  38965. static _AddTagTo(obj: any, tag: string): void;
  38966. /**
  38967. * Removes specific tags from a specific object
  38968. * @param obj defines the object to use
  38969. * @param tagsString defines the tags to remove
  38970. */
  38971. static RemoveTagsFrom(obj: any, tagsString: string): void;
  38972. /**
  38973. * @hidden
  38974. */
  38975. static _RemoveTagFrom(obj: any, tag: string): void;
  38976. /**
  38977. * Defines if tags hosted on an object match a given query
  38978. * @param obj defines the object to use
  38979. * @param tagsQuery defines the tag query
  38980. * @returns a boolean
  38981. */
  38982. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  38983. }
  38984. }
  38985. declare module BABYLON {
  38986. /**
  38987. * Class used to host texture specific utilities
  38988. */
  38989. class TextureTools {
  38990. /**
  38991. * Uses the GPU to create a copy texture rescaled at a given size
  38992. * @param texture Texture to copy from
  38993. * @param width defines the desired width
  38994. * @param height defines the desired height
  38995. * @param useBilinearMode defines if bilinear mode has to be used
  38996. * @return the generated texture
  38997. */
  38998. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  38999. /**
  39000. * Gets an environment BRDF texture for a given scene
  39001. * @param scene defines the hosting scene
  39002. * @returns the environment BRDF texture
  39003. */
  39004. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  39005. private static _environmentBRDFBase64Texture;
  39006. }
  39007. }
  39008. declare module BABYLON {
  39009. /**
  39010. * Based on jsTGALoader - Javascript loader for TGA file
  39011. * By Vincent Thibault
  39012. * @see http://blog.robrowser.com/javascript-tga-loader.html
  39013. */
  39014. class TGATools {
  39015. private static _TYPE_INDEXED;
  39016. private static _TYPE_RGB;
  39017. private static _TYPE_GREY;
  39018. private static _TYPE_RLE_INDEXED;
  39019. private static _TYPE_RLE_RGB;
  39020. private static _TYPE_RLE_GREY;
  39021. private static _ORIGIN_MASK;
  39022. private static _ORIGIN_SHIFT;
  39023. private static _ORIGIN_BL;
  39024. private static _ORIGIN_BR;
  39025. private static _ORIGIN_UL;
  39026. private static _ORIGIN_UR;
  39027. /**
  39028. * Gets the header of a TGA file
  39029. * @param data defines the TGA data
  39030. * @returns the header
  39031. */
  39032. static GetTGAHeader(data: Uint8Array): any;
  39033. /**
  39034. * Uploads TGA content to a Babylon Texture
  39035. * @hidden
  39036. */
  39037. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  39038. /** @hidden */
  39039. 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;
  39040. /** @hidden */
  39041. 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;
  39042. /** @hidden */
  39043. 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;
  39044. /** @hidden */
  39045. 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;
  39046. /** @hidden */
  39047. 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;
  39048. /** @hidden */
  39049. 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;
  39050. }
  39051. }
  39052. declare module BABYLON {
  39053. /**
  39054. * Interface for any object that can request an animation frame
  39055. */
  39056. interface ICustomAnimationFrameRequester {
  39057. /**
  39058. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  39059. */
  39060. renderFunction?: Function;
  39061. /**
  39062. * Called to request the next frame to render to
  39063. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39064. */
  39065. requestAnimationFrame: Function;
  39066. /**
  39067. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39068. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39069. */
  39070. requestID?: number;
  39071. }
  39072. /**
  39073. * Interface containing an array of animations
  39074. */
  39075. interface IAnimatable {
  39076. /**
  39077. * Array of animations
  39078. */
  39079. animations: Array<Animation>;
  39080. }
  39081. /** Interface used by value gradients (color, factor, ...) */
  39082. interface IValueGradient {
  39083. /**
  39084. * Gets or sets the gradient value (between 0 and 1)
  39085. */
  39086. gradient: number;
  39087. }
  39088. /** Class used to store color4 gradient */
  39089. class ColorGradient implements IValueGradient {
  39090. /**
  39091. * Gets or sets the gradient value (between 0 and 1)
  39092. */
  39093. gradient: number;
  39094. /**
  39095. * Gets or sets first associated color
  39096. */
  39097. color1: Color4;
  39098. /**
  39099. * Gets or sets second associated color
  39100. */
  39101. color2?: Color4;
  39102. /**
  39103. * Will get a color picked randomly between color1 and color2.
  39104. * If color2 is undefined then color1 will be used
  39105. * @param result defines the target Color4 to store the result in
  39106. */
  39107. getColorToRef(result: Color4): void;
  39108. }
  39109. /** Class used to store color 3 gradient */
  39110. class Color3Gradient implements IValueGradient {
  39111. /**
  39112. * Gets or sets the gradient value (between 0 and 1)
  39113. */
  39114. gradient: number;
  39115. /**
  39116. * Gets or sets the associated color
  39117. */
  39118. color: Color3;
  39119. }
  39120. /** Class used to store factor gradient */
  39121. class FactorGradient implements IValueGradient {
  39122. /**
  39123. * Gets or sets the gradient value (between 0 and 1)
  39124. */
  39125. gradient: number;
  39126. /**
  39127. * Gets or sets first associated factor
  39128. */
  39129. factor1: number;
  39130. /**
  39131. * Gets or sets second associated factor
  39132. */
  39133. factor2?: number;
  39134. /**
  39135. * Will get a number picked randomly between factor1 and factor2.
  39136. * If factor2 is undefined then factor1 will be used
  39137. * @returns the picked number
  39138. */
  39139. getFactor(): number;
  39140. }
  39141. /**
  39142. * @ignore
  39143. * Application error to support additional information when loading a file
  39144. */
  39145. class LoadFileError extends Error {
  39146. /** defines the optional XHR request */
  39147. request?: XMLHttpRequest | undefined;
  39148. private static _setPrototypeOf;
  39149. /**
  39150. * Creates a new LoadFileError
  39151. * @param message defines the message of the error
  39152. * @param request defines the optional XHR request
  39153. */
  39154. constructor(message: string,
  39155. /** defines the optional XHR request */
  39156. request?: XMLHttpRequest | undefined);
  39157. }
  39158. /**
  39159. * Class used to define a retry strategy when error happens while loading assets
  39160. */
  39161. class RetryStrategy {
  39162. /**
  39163. * Function used to defines an exponential back off strategy
  39164. * @param maxRetries defines the maximum number of retries (3 by default)
  39165. * @param baseInterval defines the interval between retries
  39166. * @returns the strategy function to use
  39167. */
  39168. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39169. }
  39170. /**
  39171. * File request interface
  39172. */
  39173. interface IFileRequest {
  39174. /**
  39175. * Raised when the request is complete (success or error).
  39176. */
  39177. onCompleteObservable: Observable<IFileRequest>;
  39178. /**
  39179. * Aborts the request for a file.
  39180. */
  39181. abort: () => void;
  39182. }
  39183. /**
  39184. * Class containing a set of static utilities functions
  39185. */
  39186. class Tools {
  39187. /**
  39188. * Gets or sets the base URL to use to load assets
  39189. */
  39190. static BaseUrl: string;
  39191. /**
  39192. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39193. */
  39194. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39195. /**
  39196. * Default behaviour for cors in the application.
  39197. * It can be a string if the expected behavior is identical in the entire app.
  39198. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39199. */
  39200. static CorsBehavior: string | ((url: string | string[]) => string);
  39201. /**
  39202. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39203. * @ignorenaming
  39204. */
  39205. static UseFallbackTexture: boolean;
  39206. /**
  39207. * Use this object to register external classes like custom textures or material
  39208. * to allow the laoders to instantiate them
  39209. */
  39210. static RegisteredExternalClasses: {
  39211. [key: string]: Object;
  39212. };
  39213. /**
  39214. * Texture content used if a texture cannot loaded
  39215. * @ignorenaming
  39216. */
  39217. static fallbackTexture: string;
  39218. /**
  39219. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39220. * @param u defines the coordinate on X axis
  39221. * @param v defines the coordinate on Y axis
  39222. * @param width defines the width of the source data
  39223. * @param height defines the height of the source data
  39224. * @param pixels defines the source byte array
  39225. * @param color defines the output color
  39226. */
  39227. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39228. /**
  39229. * Interpolates between a and b via alpha
  39230. * @param a The lower value (returned when alpha = 0)
  39231. * @param b The upper value (returned when alpha = 1)
  39232. * @param alpha The interpolation-factor
  39233. * @return The mixed value
  39234. */
  39235. static Mix(a: number, b: number, alpha: number): number;
  39236. /**
  39237. * Tries to instantiate a new object from a given class name
  39238. * @param className defines the class name to instantiate
  39239. * @returns the new object or null if the system was not able to do the instantiation
  39240. */
  39241. static Instantiate(className: string): any;
  39242. /**
  39243. * Provides a slice function that will work even on IE
  39244. * @param data defines the array to slice
  39245. * @param start defines the start of the data (optional)
  39246. * @param end defines the end of the data (optional)
  39247. * @returns the new sliced array
  39248. */
  39249. static Slice<T>(data: T, start?: number, end?: number): T;
  39250. /**
  39251. * Polyfill for setImmediate
  39252. * @param action defines the action to execute after the current execution block
  39253. */
  39254. static SetImmediate(action: () => void): void;
  39255. /**
  39256. * Function indicating if a number is an exponent of 2
  39257. * @param value defines the value to test
  39258. * @returns true if the value is an exponent of 2
  39259. */
  39260. static IsExponentOfTwo(value: number): boolean;
  39261. private static _tmpFloatArray;
  39262. /**
  39263. * Returns the nearest 32-bit single precision float representation of a Number
  39264. * @param value A Number. If the parameter is of a different type, it will get converted
  39265. * to a number or to NaN if it cannot be converted
  39266. * @returns number
  39267. */
  39268. static FloatRound(value: number): number;
  39269. /**
  39270. * Find the next highest power of two.
  39271. * @param x Number to start search from.
  39272. * @return Next highest power of two.
  39273. */
  39274. static CeilingPOT(x: number): number;
  39275. /**
  39276. * Find the next lowest power of two.
  39277. * @param x Number to start search from.
  39278. * @return Next lowest power of two.
  39279. */
  39280. static FloorPOT(x: number): number;
  39281. /**
  39282. * Find the nearest power of two.
  39283. * @param x Number to start search from.
  39284. * @return Next nearest power of two.
  39285. */
  39286. static NearestPOT(x: number): number;
  39287. /**
  39288. * Get the closest exponent of two
  39289. * @param value defines the value to approximate
  39290. * @param max defines the maximum value to return
  39291. * @param mode defines how to define the closest value
  39292. * @returns closest exponent of two of the given value
  39293. */
  39294. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39295. /**
  39296. * Extracts the filename from a path
  39297. * @param path defines the path to use
  39298. * @returns the filename
  39299. */
  39300. static GetFilename(path: string): string;
  39301. /**
  39302. * Extracts the "folder" part of a path (everything before the filename).
  39303. * @param uri The URI to extract the info from
  39304. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39305. * @returns The "folder" part of the path
  39306. */
  39307. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39308. /**
  39309. * Extracts text content from a DOM element hierarchy
  39310. * @param element defines the root element
  39311. * @returns a string
  39312. */
  39313. static GetDOMTextContent(element: HTMLElement): string;
  39314. /**
  39315. * Convert an angle in radians to degrees
  39316. * @param angle defines the angle to convert
  39317. * @returns the angle in degrees
  39318. */
  39319. static ToDegrees(angle: number): number;
  39320. /**
  39321. * Convert an angle in degrees to radians
  39322. * @param angle defines the angle to convert
  39323. * @returns the angle in radians
  39324. */
  39325. static ToRadians(angle: number): number;
  39326. /**
  39327. * Encode a buffer to a base64 string
  39328. * @param buffer defines the buffer to encode
  39329. * @returns the encoded string
  39330. */
  39331. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39332. /**
  39333. * Extracts minimum and maximum values from a list of indexed positions
  39334. * @param positions defines the positions to use
  39335. * @param indices defines the indices to the positions
  39336. * @param indexStart defines the start index
  39337. * @param indexCount defines the end index
  39338. * @param bias defines bias value to add to the result
  39339. * @return minimum and maximum values
  39340. */
  39341. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39342. minimum: Vector3;
  39343. maximum: Vector3;
  39344. };
  39345. /**
  39346. * Extracts minimum and maximum values from a list of positions
  39347. * @param positions defines the positions to use
  39348. * @param start defines the start index in the positions array
  39349. * @param count defines the number of positions to handle
  39350. * @param bias defines bias value to add to the result
  39351. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39352. * @return minimum and maximum values
  39353. */
  39354. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39355. minimum: Vector3;
  39356. maximum: Vector3;
  39357. };
  39358. /**
  39359. * Returns an array if obj is not an array
  39360. * @param obj defines the object to evaluate as an array
  39361. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39362. * @returns either obj directly if obj is an array or a new array containing obj
  39363. */
  39364. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39365. /**
  39366. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39367. * @param size the number of element to construct and put in the array
  39368. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39369. * @returns a new array filled with new objects
  39370. */
  39371. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39372. /**
  39373. * Gets the pointer prefix to use
  39374. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39375. */
  39376. static GetPointerPrefix(): string;
  39377. /**
  39378. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39379. * @param func - the function to be called
  39380. * @param requester - the object that will request the next frame. Falls back to window.
  39381. * @returns frame number
  39382. */
  39383. static QueueNewFrame(func: () => void, requester?: any): number;
  39384. /**
  39385. * Ask the browser to promote the current element to fullscreen rendering mode
  39386. * @param element defines the DOM element to promote
  39387. */
  39388. static RequestFullscreen(element: HTMLElement): void;
  39389. /**
  39390. * Asks the browser to exit fullscreen mode
  39391. */
  39392. static ExitFullscreen(): void;
  39393. /**
  39394. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39395. * @param url define the url we are trying
  39396. * @param element define the dom element where to configure the cors policy
  39397. */
  39398. static SetCorsBehavior(url: string | string[], element: {
  39399. crossOrigin: string | null;
  39400. }): void;
  39401. /**
  39402. * Removes unwanted characters from an url
  39403. * @param url defines the url to clean
  39404. * @returns the cleaned url
  39405. */
  39406. static CleanUrl(url: string): string;
  39407. /**
  39408. * Gets or sets a function used to pre-process url before using them to load assets
  39409. */
  39410. static PreprocessUrl: (url: string) => string;
  39411. /**
  39412. * Loads an image as an HTMLImageElement.
  39413. * @param input url string, ArrayBuffer, or Blob to load
  39414. * @param onLoad callback called when the image successfully loads
  39415. * @param onError callback called when the image fails to load
  39416. * @param offlineProvider offline provider for caching
  39417. * @returns the HTMLImageElement of the loaded image
  39418. */
  39419. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39420. /**
  39421. * Loads a file
  39422. * @param url url string, ArrayBuffer, or Blob to load
  39423. * @param onSuccess callback called when the file successfully loads
  39424. * @param onProgress callback called while file is loading (if the server supports this mode)
  39425. * @param offlineProvider defines the offline provider for caching
  39426. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39427. * @param onError callback called when the file fails to load
  39428. * @returns a file request object
  39429. */
  39430. 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;
  39431. /**
  39432. * Load a script (identified by an url). When the url returns, the
  39433. * content of this file is added into a new script element, attached to the DOM (body element)
  39434. * @param scriptUrl defines the url of the script to laod
  39435. * @param onSuccess defines the callback called when the script is loaded
  39436. * @param onError defines the callback to call if an error occurs
  39437. */
  39438. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39439. /**
  39440. * Loads a file from a blob
  39441. * @param fileToLoad defines the blob to use
  39442. * @param callback defines the callback to call when data is loaded
  39443. * @param progressCallback defines the callback to call during loading process
  39444. * @returns a file request object
  39445. */
  39446. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39447. /**
  39448. * Loads a file
  39449. * @param fileToLoad defines the file to load
  39450. * @param callback defines the callback to call when data is loaded
  39451. * @param progressCallBack defines the callback to call during loading process
  39452. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39453. * @returns a file request object
  39454. */
  39455. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39456. /**
  39457. * Creates a data url from a given string content
  39458. * @param content defines the content to convert
  39459. * @returns the new data url link
  39460. */
  39461. static FileAsURL(content: string): string;
  39462. /**
  39463. * Format the given number to a specific decimal format
  39464. * @param value defines the number to format
  39465. * @param decimals defines the number of decimals to use
  39466. * @returns the formatted string
  39467. */
  39468. static Format(value: number, decimals?: number): string;
  39469. /**
  39470. * Checks if a given vector is inside a specific range
  39471. * @param v defines the vector to test
  39472. * @param min defines the minimum range
  39473. * @param max defines the maximum range
  39474. */
  39475. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39476. /**
  39477. * Tries to copy an object by duplicating every property
  39478. * @param source defines the source object
  39479. * @param destination defines the target object
  39480. * @param doNotCopyList defines a list of properties to avoid
  39481. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39482. */
  39483. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39484. /**
  39485. * Gets a boolean indicating if the given object has no own property
  39486. * @param obj defines the object to test
  39487. * @returns true if object has no own property
  39488. */
  39489. static IsEmpty(obj: any): boolean;
  39490. /**
  39491. * Function used to register events at window level
  39492. * @param events defines the events to register
  39493. */
  39494. static RegisterTopRootEvents(events: {
  39495. name: string;
  39496. handler: Nullable<(e: FocusEvent) => any>;
  39497. }[]): void;
  39498. /**
  39499. * Function used to unregister events from window level
  39500. * @param events defines the events to unregister
  39501. */
  39502. static UnregisterTopRootEvents(events: {
  39503. name: string;
  39504. handler: Nullable<(e: FocusEvent) => any>;
  39505. }[]): void;
  39506. /**
  39507. * Dumps the current bound framebuffer
  39508. * @param width defines the rendering width
  39509. * @param height defines the rendering height
  39510. * @param engine defines the hosting engine
  39511. * @param successCallback defines the callback triggered once the data are available
  39512. * @param mimeType defines the mime type of the result
  39513. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39514. */
  39515. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39516. /**
  39517. * Converts the canvas data to blob.
  39518. * This acts as a polyfill for browsers not supporting the to blob function.
  39519. * @param canvas Defines the canvas to extract the data from
  39520. * @param successCallback Defines the callback triggered once the data are available
  39521. * @param mimeType Defines the mime type of the result
  39522. */
  39523. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39524. /**
  39525. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39526. * @param successCallback defines the callback triggered once the data are available
  39527. * @param mimeType defines the mime type of the result
  39528. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39529. */
  39530. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39531. /**
  39532. * Downloads a blob in the browser
  39533. * @param blob defines the blob to download
  39534. * @param fileName defines the name of the downloaded file
  39535. */
  39536. static Download(blob: Blob, fileName: string): void;
  39537. /**
  39538. * Captures a screenshot of the current rendering
  39539. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39540. * @param engine defines the rendering engine
  39541. * @param camera defines the source camera
  39542. * @param size This parameter can be set to a single number or to an object with the
  39543. * following (optional) properties: precision, width, height. If a single number is passed,
  39544. * it will be used for both width and height. If an object is passed, the screenshot size
  39545. * will be derived from the parameters. The precision property is a multiplier allowing
  39546. * rendering at a higher or lower resolution
  39547. * @param successCallback defines the callback receives a single parameter which contains the
  39548. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39549. * src parameter of an <img> to display it
  39550. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39551. * Check your browser for supported MIME types
  39552. */
  39553. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  39554. /**
  39555. * Generates an image screenshot from the specified camera.
  39556. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39557. * @param engine The engine to use for rendering
  39558. * @param camera The camera to use for rendering
  39559. * @param size This parameter can be set to a single number or to an object with the
  39560. * following (optional) properties: precision, width, height. If a single number is passed,
  39561. * it will be used for both width and height. If an object is passed, the screenshot size
  39562. * will be derived from the parameters. The precision property is a multiplier allowing
  39563. * rendering at a higher or lower resolution
  39564. * @param successCallback The callback receives a single parameter which contains the
  39565. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39566. * src parameter of an <img> to display it
  39567. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39568. * Check your browser for supported MIME types
  39569. * @param samples Texture samples (default: 1)
  39570. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39571. * @param fileName A name for for the downloaded file.
  39572. */
  39573. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39574. /**
  39575. * Validates if xhr data is correct
  39576. * @param xhr defines the request to validate
  39577. * @param dataType defines the expected data type
  39578. * @returns true if data is correct
  39579. */
  39580. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  39581. /**
  39582. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39583. * Be aware Math.random() could cause collisions, but:
  39584. * "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"
  39585. * @returns a pseudo random id
  39586. */
  39587. static RandomId(): string;
  39588. /**
  39589. * Test if the given uri is a base64 string
  39590. * @param uri The uri to test
  39591. * @return True if the uri is a base64 string or false otherwise
  39592. */
  39593. static IsBase64(uri: string): boolean;
  39594. /**
  39595. * Decode the given base64 uri.
  39596. * @param uri The uri to decode
  39597. * @return The decoded base64 data.
  39598. */
  39599. static DecodeBase64(uri: string): ArrayBuffer;
  39600. /**
  39601. * No log
  39602. */
  39603. static readonly NoneLogLevel: number;
  39604. /**
  39605. * Only message logs
  39606. */
  39607. static readonly MessageLogLevel: number;
  39608. /**
  39609. * Only warning logs
  39610. */
  39611. static readonly WarningLogLevel: number;
  39612. /**
  39613. * Only error logs
  39614. */
  39615. static readonly ErrorLogLevel: number;
  39616. /**
  39617. * All logs
  39618. */
  39619. static readonly AllLogLevel: number;
  39620. private static _LogCache;
  39621. /**
  39622. * Gets a value indicating the number of loading errors
  39623. * @ignorenaming
  39624. */
  39625. static errorsCount: number;
  39626. /**
  39627. * Callback called when a new log is added
  39628. */
  39629. static OnNewCacheEntry: (entry: string) => void;
  39630. private static _AddLogEntry;
  39631. private static _FormatMessage;
  39632. private static _LogDisabled;
  39633. private static _LogEnabled;
  39634. private static _WarnDisabled;
  39635. private static _WarnEnabled;
  39636. private static _ErrorDisabled;
  39637. private static _ErrorEnabled;
  39638. /**
  39639. * Log a message to the console
  39640. */
  39641. static Log: (message: string) => void;
  39642. /**
  39643. * Write a warning message to the console
  39644. */
  39645. static Warn: (message: string) => void;
  39646. /**
  39647. * Write an error message to the console
  39648. */
  39649. static Error: (message: string) => void;
  39650. /**
  39651. * Gets current log cache (list of logs)
  39652. */
  39653. static readonly LogCache: string;
  39654. /**
  39655. * Clears the log cache
  39656. */
  39657. static ClearLogCache(): void;
  39658. /**
  39659. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39660. */
  39661. static LogLevels: number;
  39662. /**
  39663. * Checks if the loaded document was accessed via `file:`-Protocol.
  39664. * @returns boolean
  39665. */
  39666. static IsFileURL(): boolean;
  39667. /**
  39668. * Checks if the window object exists
  39669. * @returns true if the window object exists
  39670. */
  39671. static IsWindowObjectExist(): boolean;
  39672. /**
  39673. * No performance log
  39674. */
  39675. static readonly PerformanceNoneLogLevel: number;
  39676. /**
  39677. * Use user marks to log performance
  39678. */
  39679. static readonly PerformanceUserMarkLogLevel: number;
  39680. /**
  39681. * Log performance to the console
  39682. */
  39683. static readonly PerformanceConsoleLogLevel: number;
  39684. private static _performance;
  39685. /**
  39686. * Sets the current performance log level
  39687. */
  39688. static PerformanceLogLevel: number;
  39689. private static _StartPerformanceCounterDisabled;
  39690. private static _EndPerformanceCounterDisabled;
  39691. private static _StartUserMark;
  39692. private static _EndUserMark;
  39693. private static _StartPerformanceConsole;
  39694. private static _EndPerformanceConsole;
  39695. /**
  39696. * Starts a performance counter
  39697. */
  39698. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39699. /**
  39700. * Ends a specific performance coutner
  39701. */
  39702. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39703. /**
  39704. * Gets either window.performance.now() if supported or Date.now() else
  39705. */
  39706. static readonly Now: number;
  39707. /**
  39708. * This method will return the name of the class used to create the instance of the given object.
  39709. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39710. * @param object the object to get the class name from
  39711. * @param isType defines if the object is actually a type
  39712. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39713. */
  39714. static GetClassName(object: any, isType?: boolean): string;
  39715. /**
  39716. * Gets the first element of an array satisfying a given predicate
  39717. * @param array defines the array to browse
  39718. * @param predicate defines the predicate to use
  39719. * @returns null if not found or the element
  39720. */
  39721. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39722. /**
  39723. * This method will return the name of the full name of the class, including its owning module (if any).
  39724. * 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).
  39725. * @param object the object to get the class name from
  39726. * @param isType defines if the object is actually a type
  39727. * @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.
  39728. * @ignorenaming
  39729. */
  39730. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39731. /**
  39732. * Returns a promise that resolves after the given amount of time.
  39733. * @param delay Number of milliseconds to delay
  39734. * @returns Promise that resolves after the given amount of time
  39735. */
  39736. static DelayAsync(delay: number): Promise<void>;
  39737. /**
  39738. * Gets the current gradient from an array of IValueGradient
  39739. * @param ratio defines the current ratio to get
  39740. * @param gradients defines the array of IValueGradient
  39741. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  39742. */
  39743. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  39744. }
  39745. /**
  39746. * This class is used to track a performance counter which is number based.
  39747. * The user has access to many properties which give statistics of different nature.
  39748. *
  39749. * The implementer can track two kinds of Performance Counter: time and count.
  39750. * 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.
  39751. * 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.
  39752. */
  39753. class PerfCounter {
  39754. /**
  39755. * Gets or sets a global boolean to turn on and off all the counters
  39756. */
  39757. static Enabled: boolean;
  39758. /**
  39759. * Returns the smallest value ever
  39760. */
  39761. readonly min: number;
  39762. /**
  39763. * Returns the biggest value ever
  39764. */
  39765. readonly max: number;
  39766. /**
  39767. * Returns the average value since the performance counter is running
  39768. */
  39769. readonly average: number;
  39770. /**
  39771. * Returns the average value of the last second the counter was monitored
  39772. */
  39773. readonly lastSecAverage: number;
  39774. /**
  39775. * Returns the current value
  39776. */
  39777. readonly current: number;
  39778. /**
  39779. * Gets the accumulated total
  39780. */
  39781. readonly total: number;
  39782. /**
  39783. * Gets the total value count
  39784. */
  39785. readonly count: number;
  39786. /**
  39787. * Creates a new counter
  39788. */
  39789. constructor();
  39790. /**
  39791. * Call this method to start monitoring a new frame.
  39792. * 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.
  39793. */
  39794. fetchNewFrame(): void;
  39795. /**
  39796. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  39797. * @param newCount the count value to add to the monitored count
  39798. * @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.
  39799. */
  39800. addCount(newCount: number, fetchResult: boolean): void;
  39801. /**
  39802. * Start monitoring this performance counter
  39803. */
  39804. beginMonitoring(): void;
  39805. /**
  39806. * Compute the time lapsed since the previous beginMonitoring() call.
  39807. * @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
  39808. */
  39809. endMonitoring(newFrame?: boolean): void;
  39810. private _fetchResult;
  39811. private _startMonitoringTime;
  39812. private _min;
  39813. private _max;
  39814. private _average;
  39815. private _current;
  39816. private _totalValueCount;
  39817. private _totalAccumulated;
  39818. private _lastSecAverage;
  39819. private _lastSecAccumulated;
  39820. private _lastSecTime;
  39821. private _lastSecValueCount;
  39822. }
  39823. /**
  39824. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39825. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39826. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39827. * @param name The name of the class, case should be preserved
  39828. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39829. */
  39830. function className(name: string, module?: string): (target: Object) => void;
  39831. /**
  39832. * An implementation of a loop for asynchronous functions.
  39833. */
  39834. class AsyncLoop {
  39835. /**
  39836. * Defines the number of iterations for the loop
  39837. */
  39838. iterations: number;
  39839. /**
  39840. * Defines the current index of the loop.
  39841. */
  39842. index: number;
  39843. private _done;
  39844. private _fn;
  39845. private _successCallback;
  39846. /**
  39847. * Constructor.
  39848. * @param iterations the number of iterations.
  39849. * @param func the function to run each iteration
  39850. * @param successCallback the callback that will be called upon succesful execution
  39851. * @param offset starting offset.
  39852. */
  39853. constructor(
  39854. /**
  39855. * Defines the number of iterations for the loop
  39856. */
  39857. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39858. /**
  39859. * Execute the next iteration. Must be called after the last iteration was finished.
  39860. */
  39861. executeNext(): void;
  39862. /**
  39863. * Break the loop and run the success callback.
  39864. */
  39865. breakLoop(): void;
  39866. /**
  39867. * Create and run an async loop.
  39868. * @param iterations the number of iterations.
  39869. * @param fn the function to run each iteration
  39870. * @param successCallback the callback that will be called upon succesful execution
  39871. * @param offset starting offset.
  39872. * @returns the created async loop object
  39873. */
  39874. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39875. /**
  39876. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39877. * @param iterations total number of iterations
  39878. * @param syncedIterations number of synchronous iterations in each async iteration.
  39879. * @param fn the function to call each iteration.
  39880. * @param callback a success call back that will be called when iterating stops.
  39881. * @param breakFunction a break condition (optional)
  39882. * @param timeout timeout settings for the setTimeout function. default - 0.
  39883. * @returns the created async loop object
  39884. */
  39885. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39886. }
  39887. }
  39888. interface HTMLCanvasElement {
  39889. /** Track wether a record is in progress */
  39890. isRecording: boolean;
  39891. /** Capture Stream method defined by some browsers */
  39892. captureStream(fps?: number): MediaStream;
  39893. }
  39894. interface MediaRecorder {
  39895. /** Starts recording */
  39896. start(timeSlice: number): void;
  39897. /** Stops recording */
  39898. stop(): void;
  39899. /** Event raised when an error arised. */
  39900. onerror: (event: ErrorEvent) => void;
  39901. /** Event raised when the recording stops. */
  39902. onstop: (event: Event) => void;
  39903. /** Event raised when a new chunk of data is available and should be tracked. */
  39904. ondataavailable: (event: Event) => void;
  39905. }
  39906. interface MediaRecorderOptions {
  39907. /** The mime type you want to use as the recording container for the new MediaRecorder */
  39908. mimeType?: string;
  39909. /** The chosen bitrate for the audio component of the media. */
  39910. audioBitsPerSecond?: number;
  39911. /** The chosen bitrate for the video component of the media. */
  39912. videoBitsPerSecond?: number;
  39913. /** The chosen bitrate for the audio and video components of the media. This can be specified instead of the above two properties. If this is specified along with one or the other of the above properties, this will be used for the one that isn't specified. */
  39914. bitsPerSecond?: number;
  39915. }
  39916. interface MediaRecorderConstructor {
  39917. /**
  39918. * A reference to the prototype.
  39919. */
  39920. readonly prototype: MediaRecorder;
  39921. /**
  39922. * Creates a new MediaRecorder.
  39923. * @param stream Defines the stream to record.
  39924. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  39925. */
  39926. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  39927. }
  39928. /**
  39929. * MediaRecoreder object available in some browsers.
  39930. */
  39931. declare var MediaRecorder: MediaRecorderConstructor;
  39932. declare module BABYLON {
  39933. /**
  39934. * This represents the different options avilable for the video capture.
  39935. */
  39936. interface VideoRecorderOptions {
  39937. /** Defines the mime type of the video */
  39938. mimeType: string;
  39939. /** Defines the video the video should be recorded at */
  39940. fps: number;
  39941. /** Defines the chunk size for the recording data */
  39942. recordChunckSize: number;
  39943. }
  39944. /**
  39945. * This can helps recording videos from BabylonJS.
  39946. * This is based on the available WebRTC functionalities of the browser.
  39947. *
  39948. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  39949. */
  39950. class VideoRecorder {
  39951. private static readonly _defaultOptions;
  39952. /**
  39953. * Returns wehther or not the VideoRecorder is available in your browser.
  39954. * @param engine Defines the Babylon Engine to check the support for
  39955. * @returns true if supported otherwise false
  39956. */
  39957. static IsSupported(engine: Engine): boolean;
  39958. private readonly _options;
  39959. private _canvas;
  39960. private _mediaRecorder;
  39961. private _recordedChunks;
  39962. private _fileName;
  39963. private _resolve;
  39964. private _reject;
  39965. /**
  39966. * True wether a recording is already in progress.
  39967. */
  39968. readonly isRecording: boolean;
  39969. /**
  39970. * Create a new VideoCapture object which can help converting what you see in Babylon to
  39971. * a video file.
  39972. * @param engine Defines the BabylonJS Engine you wish to record
  39973. * @param options Defines options that can be used to customized the capture
  39974. */
  39975. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  39976. /**
  39977. * Stops the current recording before the default capture timeout passed in the startRecording
  39978. * functions.
  39979. */
  39980. stopRecording(): void;
  39981. /**
  39982. * Starts recording the canvas for a max duration specified in parameters.
  39983. * @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.
  39984. * @param maxDuration Defines the maximum recording time in seconds.
  39985. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  39986. * @return a promise callback at the end of the recording with the video data in Blob.
  39987. */
  39988. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  39989. /**
  39990. * Releases internal resources used during the recording.
  39991. */
  39992. dispose(): void;
  39993. private _handleDataAvailable;
  39994. private _handleError;
  39995. private _handleStop;
  39996. }
  39997. }
  39998. declare module BABYLON {
  39999. /**
  40000. * Defines the potential axis of a Joystick
  40001. */
  40002. enum JoystickAxis {
  40003. /** X axis */
  40004. X = 0,
  40005. /** Y axis */
  40006. Y = 1,
  40007. /** Z axis */
  40008. Z = 2
  40009. }
  40010. /**
  40011. * Class used to define virtual joystick (used in touch mode)
  40012. */
  40013. class VirtualJoystick {
  40014. /**
  40015. * Gets or sets a boolean indicating that left and right values must be inverted
  40016. */
  40017. reverseLeftRight: boolean;
  40018. /**
  40019. * Gets or sets a boolean indicating that up and down values must be inverted
  40020. */
  40021. reverseUpDown: boolean;
  40022. /**
  40023. * Gets the offset value for the position (ie. the change of the position value)
  40024. */
  40025. deltaPosition: Vector3;
  40026. /**
  40027. * Gets a boolean indicating if the virtual joystick was pressed
  40028. */
  40029. pressed: boolean;
  40030. private static _globalJoystickIndex;
  40031. private static vjCanvas;
  40032. private static vjCanvasContext;
  40033. private static vjCanvasWidth;
  40034. private static vjCanvasHeight;
  40035. private static halfWidth;
  40036. private _action;
  40037. private _axisTargetedByLeftAndRight;
  40038. private _axisTargetedByUpAndDown;
  40039. private _joystickSensibility;
  40040. private _inversedSensibility;
  40041. private _joystickPointerID;
  40042. private _joystickColor;
  40043. private _joystickPointerPos;
  40044. private _joystickPreviousPointerPos;
  40045. private _joystickPointerStartPos;
  40046. private _deltaJoystickVector;
  40047. private _leftJoystick;
  40048. private _touches;
  40049. private _onPointerDownHandlerRef;
  40050. private _onPointerMoveHandlerRef;
  40051. private _onPointerUpHandlerRef;
  40052. private _onResize;
  40053. /**
  40054. * Creates a new virtual joystick
  40055. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40056. */
  40057. constructor(leftJoystick?: boolean);
  40058. /**
  40059. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40060. * @param newJoystickSensibility defines the new sensibility
  40061. */
  40062. setJoystickSensibility(newJoystickSensibility: number): void;
  40063. private _onPointerDown;
  40064. private _onPointerMove;
  40065. private _onPointerUp;
  40066. /**
  40067. * Change the color of the virtual joystick
  40068. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40069. */
  40070. setJoystickColor(newColor: string): void;
  40071. /**
  40072. * Defines a callback to call when the joystick is touched
  40073. * @param action defines the callback
  40074. */
  40075. setActionOnTouch(action: () => any): void;
  40076. /**
  40077. * Defines which axis you'd like to control for left & right
  40078. * @param axis defines the axis to use
  40079. */
  40080. setAxisForLeftRight(axis: JoystickAxis): void;
  40081. /**
  40082. * Defines which axis you'd like to control for up & down
  40083. * @param axis defines the axis to use
  40084. */
  40085. setAxisForUpDown(axis: JoystickAxis): void;
  40086. private _drawVirtualJoystick;
  40087. /**
  40088. * Release internal HTML canvas
  40089. */
  40090. releaseCanvas(): void;
  40091. }
  40092. }
  40093. declare module BABYLON {
  40094. /**
  40095. * Helper class to push actions to a pool of workers.
  40096. */
  40097. class WorkerPool implements IDisposable {
  40098. private _workerInfos;
  40099. private _pendingActions;
  40100. /**
  40101. * Constructor
  40102. * @param workers Array of workers to use for actions
  40103. */
  40104. constructor(workers: Array<Worker>);
  40105. /**
  40106. * Terminates all workers and clears any pending actions.
  40107. */
  40108. dispose(): void;
  40109. /**
  40110. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40111. * pended until a worker has completed its action.
  40112. * @param action The action to perform. Call onComplete when the action is complete.
  40113. */
  40114. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40115. private _execute;
  40116. }
  40117. }
  40118. declare module BABYLON {
  40119. /**
  40120. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40121. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40122. */
  40123. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40124. /**
  40125. * Gets the name of the behavior.
  40126. */
  40127. readonly name: string;
  40128. private _zoomStopsAnimation;
  40129. private _idleRotationSpeed;
  40130. private _idleRotationWaitTime;
  40131. private _idleRotationSpinupTime;
  40132. /**
  40133. * Sets the flag that indicates if user zooming should stop animation.
  40134. */
  40135. /**
  40136. * Gets the flag that indicates if user zooming should stop animation.
  40137. */
  40138. zoomStopsAnimation: boolean;
  40139. /**
  40140. * Sets the default speed at which the camera rotates around the model.
  40141. */
  40142. /**
  40143. * Gets the default speed at which the camera rotates around the model.
  40144. */
  40145. idleRotationSpeed: number;
  40146. /**
  40147. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40148. */
  40149. /**
  40150. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40151. */
  40152. idleRotationWaitTime: number;
  40153. /**
  40154. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40155. */
  40156. /**
  40157. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40158. */
  40159. idleRotationSpinupTime: number;
  40160. /**
  40161. * Gets a value indicating if the camera is currently rotating because of this behavior
  40162. */
  40163. readonly rotationInProgress: boolean;
  40164. private _onPrePointerObservableObserver;
  40165. private _onAfterCheckInputsObserver;
  40166. private _attachedCamera;
  40167. private _isPointerDown;
  40168. private _lastFrameTime;
  40169. private _lastInteractionTime;
  40170. private _cameraRotationSpeed;
  40171. /**
  40172. * Initializes the behavior.
  40173. */
  40174. init(): void;
  40175. /**
  40176. * Attaches the behavior to its arc rotate camera.
  40177. * @param camera Defines the camera to attach the behavior to
  40178. */
  40179. attach(camera: ArcRotateCamera): void;
  40180. /**
  40181. * Detaches the behavior from its current arc rotate camera.
  40182. */
  40183. detach(): void;
  40184. /**
  40185. * Returns true if user is scrolling.
  40186. * @return true if user is scrolling.
  40187. */
  40188. private _userIsZooming;
  40189. private _lastFrameRadius;
  40190. private _shouldAnimationStopForInteraction;
  40191. /**
  40192. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40193. */
  40194. private _applyUserInteraction;
  40195. private _userIsMoving;
  40196. }
  40197. }
  40198. declare module BABYLON {
  40199. /**
  40200. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40201. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40202. */
  40203. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40204. /**
  40205. * Gets the name of the behavior.
  40206. */
  40207. readonly name: string;
  40208. /**
  40209. * The easing function used by animations
  40210. */
  40211. static EasingFunction: BackEase;
  40212. /**
  40213. * The easing mode used by animations
  40214. */
  40215. static EasingMode: number;
  40216. /**
  40217. * The duration of the animation, in milliseconds
  40218. */
  40219. transitionDuration: number;
  40220. /**
  40221. * Length of the distance animated by the transition when lower radius is reached
  40222. */
  40223. lowerRadiusTransitionRange: number;
  40224. /**
  40225. * Length of the distance animated by the transition when upper radius is reached
  40226. */
  40227. upperRadiusTransitionRange: number;
  40228. private _autoTransitionRange;
  40229. /**
  40230. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40231. */
  40232. /**
  40233. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40234. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40235. */
  40236. autoTransitionRange: boolean;
  40237. private _attachedCamera;
  40238. private _onAfterCheckInputsObserver;
  40239. private _onMeshTargetChangedObserver;
  40240. /**
  40241. * Initializes the behavior.
  40242. */
  40243. init(): void;
  40244. /**
  40245. * Attaches the behavior to its arc rotate camera.
  40246. * @param camera Defines the camera to attach the behavior to
  40247. */
  40248. attach(camera: ArcRotateCamera): void;
  40249. /**
  40250. * Detaches the behavior from its current arc rotate camera.
  40251. */
  40252. detach(): void;
  40253. private _radiusIsAnimating;
  40254. private _radiusBounceTransition;
  40255. private _animatables;
  40256. private _cachedWheelPrecision;
  40257. /**
  40258. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40259. * @param radiusLimit The limit to check against.
  40260. * @return Bool to indicate if at limit.
  40261. */
  40262. private _isRadiusAtLimit;
  40263. /**
  40264. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40265. * @param radiusDelta The delta by which to animate to. Can be negative.
  40266. */
  40267. private _applyBoundRadiusAnimation;
  40268. /**
  40269. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40270. */
  40271. protected _clearAnimationLocks(): void;
  40272. /**
  40273. * Stops and removes all animations that have been applied to the camera
  40274. */
  40275. stopAllAnimations(): void;
  40276. }
  40277. }
  40278. declare module BABYLON {
  40279. /**
  40280. * The framing behavior (BABYLON.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.
  40281. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40282. */
  40283. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40284. /**
  40285. * Gets the name of the behavior.
  40286. */
  40287. readonly name: string;
  40288. private _mode;
  40289. private _radiusScale;
  40290. private _positionScale;
  40291. private _defaultElevation;
  40292. private _elevationReturnTime;
  40293. private _elevationReturnWaitTime;
  40294. private _zoomStopsAnimation;
  40295. private _framingTime;
  40296. /**
  40297. * The easing function used by animations
  40298. */
  40299. static EasingFunction: ExponentialEase;
  40300. /**
  40301. * The easing mode used by animations
  40302. */
  40303. static EasingMode: number;
  40304. /**
  40305. * Sets the current mode used by the behavior
  40306. */
  40307. /**
  40308. * Gets current mode used by the behavior.
  40309. */
  40310. mode: number;
  40311. /**
  40312. * Sets the scale applied to the radius (1 by default)
  40313. */
  40314. /**
  40315. * Gets the scale applied to the radius
  40316. */
  40317. radiusScale: number;
  40318. /**
  40319. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40320. */
  40321. /**
  40322. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40323. */
  40324. positionScale: number;
  40325. /**
  40326. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40327. * behaviour is triggered, in radians.
  40328. */
  40329. /**
  40330. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40331. * behaviour is triggered, in radians.
  40332. */
  40333. defaultElevation: number;
  40334. /**
  40335. * Sets the time (in milliseconds) taken to return to the default beta position.
  40336. * Negative value indicates camera should not return to default.
  40337. */
  40338. /**
  40339. * Gets the time (in milliseconds) taken to return to the default beta position.
  40340. * Negative value indicates camera should not return to default.
  40341. */
  40342. elevationReturnTime: number;
  40343. /**
  40344. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40345. */
  40346. /**
  40347. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40348. */
  40349. elevationReturnWaitTime: number;
  40350. /**
  40351. * Sets the flag that indicates if user zooming should stop animation.
  40352. */
  40353. /**
  40354. * Gets the flag that indicates if user zooming should stop animation.
  40355. */
  40356. zoomStopsAnimation: boolean;
  40357. /**
  40358. * Sets the transition time when framing the mesh, in milliseconds
  40359. */
  40360. /**
  40361. * Gets the transition time when framing the mesh, in milliseconds
  40362. */
  40363. framingTime: number;
  40364. /**
  40365. * Define if the behavior should automatically change the configured
  40366. * camera limits and sensibilities.
  40367. */
  40368. autoCorrectCameraLimitsAndSensibility: boolean;
  40369. private _onPrePointerObservableObserver;
  40370. private _onAfterCheckInputsObserver;
  40371. private _onMeshTargetChangedObserver;
  40372. private _attachedCamera;
  40373. private _isPointerDown;
  40374. private _lastInteractionTime;
  40375. /**
  40376. * Initializes the behavior.
  40377. */
  40378. init(): void;
  40379. /**
  40380. * Attaches the behavior to its arc rotate camera.
  40381. * @param camera Defines the camera to attach the behavior to
  40382. */
  40383. attach(camera: ArcRotateCamera): void;
  40384. /**
  40385. * Detaches the behavior from its current arc rotate camera.
  40386. */
  40387. detach(): void;
  40388. private _animatables;
  40389. private _betaIsAnimating;
  40390. private _betaTransition;
  40391. private _radiusTransition;
  40392. private _vectorTransition;
  40393. /**
  40394. * Targets the given mesh and updates zoom level accordingly.
  40395. * @param mesh The mesh to target.
  40396. * @param radius Optional. If a cached radius position already exists, overrides default.
  40397. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40398. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40399. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40400. */
  40401. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40402. /**
  40403. * Targets the given mesh with its children and updates zoom level accordingly.
  40404. * @param mesh The mesh to target.
  40405. * @param radius Optional. If a cached radius position already exists, overrides default.
  40406. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40407. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40408. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40409. */
  40410. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40411. /**
  40412. * Targets the given meshes with their children and updates zoom level accordingly.
  40413. * @param meshes The mesh to target.
  40414. * @param radius Optional. If a cached radius position already exists, overrides default.
  40415. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40416. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40417. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40418. */
  40419. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40420. /**
  40421. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40422. * @param minimumWorld Determines the smaller position of the bounding box extend
  40423. * @param maximumWorld Determines the bigger position of the bounding box extend
  40424. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40425. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40426. */
  40427. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40428. /**
  40429. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40430. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40431. * frustum width.
  40432. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40433. * to fully enclose the mesh in the viewing frustum.
  40434. */
  40435. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40436. /**
  40437. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40438. * is automatically returned to its default position (expected to be above ground plane).
  40439. */
  40440. private _maintainCameraAboveGround;
  40441. /**
  40442. * Returns the frustum slope based on the canvas ratio and camera FOV
  40443. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40444. */
  40445. private _getFrustumSlope;
  40446. /**
  40447. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40448. */
  40449. private _clearAnimationLocks;
  40450. /**
  40451. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40452. */
  40453. private _applyUserInteraction;
  40454. /**
  40455. * Stops and removes all animations that have been applied to the camera
  40456. */
  40457. stopAllAnimations(): void;
  40458. /**
  40459. * Gets a value indicating if the user is moving the camera
  40460. */
  40461. readonly isUserIsMoving: boolean;
  40462. /**
  40463. * The camera can move all the way towards the mesh.
  40464. */
  40465. static IgnoreBoundsSizeMode: number;
  40466. /**
  40467. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40468. */
  40469. static FitFrustumSidesMode: number;
  40470. }
  40471. }
  40472. declare module BABYLON {
  40473. /**
  40474. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40475. */
  40476. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40477. private ui;
  40478. /**
  40479. * The name of the behavior
  40480. */
  40481. name: string;
  40482. /**
  40483. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40484. */
  40485. distanceAwayFromFace: number;
  40486. /**
  40487. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40488. */
  40489. distanceAwayFromBottomOfFace: number;
  40490. private _faceVectors;
  40491. private _target;
  40492. private _scene;
  40493. private _onRenderObserver;
  40494. private _tmpMatrix;
  40495. private _tmpVector;
  40496. /**
  40497. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40498. * @param ui The transform node that should be attched to the mesh
  40499. */
  40500. constructor(ui: BABYLON.TransformNode);
  40501. /**
  40502. * Initializes the behavior
  40503. */
  40504. init(): void;
  40505. private _closestFace;
  40506. private _zeroVector;
  40507. private _lookAtTmpMatrix;
  40508. private _lookAtToRef;
  40509. /**
  40510. * Attaches the AttachToBoxBehavior to the passed in mesh
  40511. * @param target The mesh that the specified node will be attached to
  40512. */
  40513. attach(target: BABYLON.Mesh): void;
  40514. /**
  40515. * Detaches the behavior from the mesh
  40516. */
  40517. detach(): void;
  40518. }
  40519. }
  40520. declare module BABYLON {
  40521. /**
  40522. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40523. */
  40524. class FadeInOutBehavior implements Behavior<Mesh> {
  40525. /**
  40526. * Time in milliseconds to delay before fading in (Default: 0)
  40527. */
  40528. delay: number;
  40529. /**
  40530. * Time in milliseconds for the mesh to fade in (Default: 300)
  40531. */
  40532. fadeInTime: number;
  40533. private _millisecondsPerFrame;
  40534. private _hovered;
  40535. private _hoverValue;
  40536. private _ownerNode;
  40537. /**
  40538. * Instatiates the FadeInOutBehavior
  40539. */
  40540. constructor();
  40541. /**
  40542. * The name of the behavior
  40543. */
  40544. readonly name: string;
  40545. /**
  40546. * Initializes the behavior
  40547. */
  40548. init(): void;
  40549. /**
  40550. * Attaches the fade behavior on the passed in mesh
  40551. * @param ownerNode The mesh that will be faded in/out once attached
  40552. */
  40553. attach(ownerNode: Mesh): void;
  40554. /**
  40555. * Detaches the behavior from the mesh
  40556. */
  40557. detach(): void;
  40558. /**
  40559. * Triggers the mesh to begin fading in or out
  40560. * @param value if the object should fade in or out (true to fade in)
  40561. */
  40562. fadeIn(value: boolean): void;
  40563. private _update;
  40564. private _setAllVisibility;
  40565. }
  40566. }
  40567. declare module BABYLON {
  40568. /**
  40569. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40570. */
  40571. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40572. private _dragBehaviorA;
  40573. private _dragBehaviorB;
  40574. private _startDistance;
  40575. private _initialScale;
  40576. private _targetScale;
  40577. private _ownerNode;
  40578. private _sceneRenderObserver;
  40579. /**
  40580. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40581. */
  40582. constructor();
  40583. /**
  40584. * The name of the behavior
  40585. */
  40586. readonly name: string;
  40587. /**
  40588. * Initializes the behavior
  40589. */
  40590. init(): void;
  40591. private _getCurrentDistance;
  40592. /**
  40593. * Attaches the scale behavior the passed in mesh
  40594. * @param ownerNode The mesh that will be scaled around once attached
  40595. */
  40596. attach(ownerNode: Mesh): void;
  40597. /**
  40598. * Detaches the behavior from the mesh
  40599. */
  40600. detach(): void;
  40601. }
  40602. }
  40603. declare module BABYLON {
  40604. /**
  40605. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40606. */
  40607. class PointerDragBehavior implements Behavior<Mesh> {
  40608. private static _AnyMouseID;
  40609. private _attachedNode;
  40610. private _dragPlane;
  40611. private _scene;
  40612. private _pointerObserver;
  40613. private _beforeRenderObserver;
  40614. private static _planeScene;
  40615. /**
  40616. * 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)
  40617. */
  40618. maxDragAngle: number;
  40619. /**
  40620. * @hidden
  40621. */
  40622. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40623. /**
  40624. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40625. */
  40626. currentDraggingPointerID: number;
  40627. /**
  40628. * The last position where the pointer hit the drag plane in world space
  40629. */
  40630. lastDragPosition: Vector3;
  40631. /**
  40632. * If the behavior is currently in a dragging state
  40633. */
  40634. dragging: boolean;
  40635. /**
  40636. * 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)
  40637. */
  40638. dragDeltaRatio: number;
  40639. /**
  40640. * If the drag plane orientation should be updated during the dragging (Default: true)
  40641. */
  40642. updateDragPlane: boolean;
  40643. private _debugMode;
  40644. private _moving;
  40645. /**
  40646. * Fires each time the attached mesh is dragged with the pointer
  40647. * * delta between last drag position and current drag position in world space
  40648. * * dragDistance along the drag axis
  40649. * * dragPlaneNormal normal of the current drag plane used during the drag
  40650. * * dragPlanePoint in world space where the drag intersects the drag plane
  40651. */
  40652. onDragObservable: Observable<{
  40653. delta: Vector3;
  40654. dragPlanePoint: Vector3;
  40655. dragPlaneNormal: Vector3;
  40656. dragDistance: number;
  40657. pointerId: number;
  40658. }>;
  40659. /**
  40660. * Fires each time a drag begins (eg. mouse down on mesh)
  40661. */
  40662. onDragStartObservable: Observable<{
  40663. dragPlanePoint: Vector3;
  40664. pointerId: number;
  40665. }>;
  40666. /**
  40667. * Fires each time a drag ends (eg. mouse release after drag)
  40668. */
  40669. onDragEndObservable: Observable<{
  40670. dragPlanePoint: Vector3;
  40671. pointerId: number;
  40672. }>;
  40673. /**
  40674. * If the attached mesh should be moved when dragged
  40675. */
  40676. moveAttached: boolean;
  40677. /**
  40678. * If the drag behavior will react to drag events (Default: true)
  40679. */
  40680. enabled: boolean;
  40681. /**
  40682. * If camera controls should be detached during the drag
  40683. */
  40684. detachCameraControls: boolean;
  40685. /**
  40686. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40687. */
  40688. useObjectOrienationForDragging: boolean;
  40689. private _options;
  40690. /**
  40691. * Creates a pointer drag behavior that can be attached to a mesh
  40692. * @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)
  40693. */
  40694. constructor(options?: {
  40695. dragAxis?: Vector3;
  40696. dragPlaneNormal?: Vector3;
  40697. });
  40698. /**
  40699. * The name of the behavior
  40700. */
  40701. readonly name: string;
  40702. /**
  40703. * Initializes the behavior
  40704. */
  40705. init(): void;
  40706. private _tmpVector;
  40707. private _alternatePickedPoint;
  40708. private _worldDragAxis;
  40709. private _targetPosition;
  40710. private _attachedElement;
  40711. /**
  40712. * Attaches the drag behavior the passed in mesh
  40713. * @param ownerNode The mesh that will be dragged around once attached
  40714. */
  40715. attach(ownerNode: Mesh): void;
  40716. /**
  40717. * Force relase the drag action by code.
  40718. */
  40719. releaseDrag(): void;
  40720. private _startDragRay;
  40721. private _lastPointerRay;
  40722. /**
  40723. * Simulates the start of a pointer drag event on the behavior
  40724. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40725. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40726. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40727. */
  40728. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40729. private _startDrag;
  40730. private _dragDelta;
  40731. private _moveDrag;
  40732. private _pickWithRayOnDragPlane;
  40733. private _pointA;
  40734. private _pointB;
  40735. private _pointC;
  40736. private _lineA;
  40737. private _lineB;
  40738. private _localAxis;
  40739. private _lookAt;
  40740. private _updateDragPlanePosition;
  40741. /**
  40742. * Detaches the behavior from the mesh
  40743. */
  40744. detach(): void;
  40745. }
  40746. }
  40747. declare module BABYLON {
  40748. /**
  40749. * 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
  40750. */
  40751. class SixDofDragBehavior implements Behavior<Mesh> {
  40752. private static _virtualScene;
  40753. private _ownerNode;
  40754. private _sceneRenderObserver;
  40755. private _scene;
  40756. private _targetPosition;
  40757. private _virtualOriginMesh;
  40758. private _virtualDragMesh;
  40759. private _pointerObserver;
  40760. private _moving;
  40761. private _startingOrientation;
  40762. /**
  40763. * 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)
  40764. */
  40765. private zDragFactor;
  40766. /**
  40767. * If the behavior is currently in a dragging state
  40768. */
  40769. dragging: boolean;
  40770. /**
  40771. * 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)
  40772. */
  40773. dragDeltaRatio: number;
  40774. /**
  40775. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40776. */
  40777. currentDraggingPointerID: number;
  40778. /**
  40779. * If camera controls should be detached during the drag
  40780. */
  40781. detachCameraControls: boolean;
  40782. /**
  40783. * Fires each time a drag starts
  40784. */
  40785. onDragStartObservable: Observable<{}>;
  40786. /**
  40787. * Fires each time a drag ends (eg. mouse release after drag)
  40788. */
  40789. onDragEndObservable: Observable<{}>;
  40790. /**
  40791. * 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
  40792. */
  40793. constructor();
  40794. /**
  40795. * The name of the behavior
  40796. */
  40797. readonly name: string;
  40798. /**
  40799. * Initializes the behavior
  40800. */
  40801. init(): void;
  40802. /**
  40803. * Attaches the scale behavior the passed in mesh
  40804. * @param ownerNode The mesh that will be scaled around once attached
  40805. */
  40806. attach(ownerNode: Mesh): void;
  40807. /**
  40808. * Detaches the behavior from the mesh
  40809. */
  40810. detach(): void;
  40811. }
  40812. }
  40813. declare module BABYLON {
  40814. /**
  40815. * Manage the gamepad inputs to control an arc rotate camera.
  40816. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40817. */
  40818. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40819. /**
  40820. * Defines the camera the input is attached to.
  40821. */
  40822. camera: ArcRotateCamera;
  40823. /**
  40824. * Defines the gamepad the input is gathering event from.
  40825. */
  40826. gamepad: Nullable<Gamepad>;
  40827. /**
  40828. * Defines the gamepad rotation sensiblity.
  40829. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40830. */
  40831. gamepadRotationSensibility: number;
  40832. /**
  40833. * Defines the gamepad move sensiblity.
  40834. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40835. */
  40836. gamepadMoveSensibility: number;
  40837. private _onGamepadConnectedObserver;
  40838. private _onGamepadDisconnectedObserver;
  40839. /**
  40840. * Attach the input controls to a specific dom element to get the input from.
  40841. * @param element Defines the element the controls should be listened from
  40842. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40843. */
  40844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40845. /**
  40846. * Detach the current controls from the specified dom element.
  40847. * @param element Defines the element to stop listening the inputs from
  40848. */
  40849. detachControl(element: Nullable<HTMLElement>): void;
  40850. /**
  40851. * Update the current camera state depending on the inputs that have been used this frame.
  40852. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40853. */
  40854. checkInputs(): void;
  40855. /**
  40856. * Gets the class name of the current intput.
  40857. * @returns the class name
  40858. */
  40859. getClassName(): string;
  40860. /**
  40861. * Get the friendly name associated with the input class.
  40862. * @returns the input friendly name
  40863. */
  40864. getSimpleName(): string;
  40865. }
  40866. }
  40867. declare module BABYLON {
  40868. /**
  40869. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  40870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40871. */
  40872. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  40873. /**
  40874. * Defines the camera the input is attached to.
  40875. */
  40876. camera: ArcRotateCamera;
  40877. /**
  40878. * Defines the list of key codes associated with the up action (increase alpha)
  40879. */
  40880. keysUp: number[];
  40881. /**
  40882. * Defines the list of key codes associated with the down action (decrease alpha)
  40883. */
  40884. keysDown: number[];
  40885. /**
  40886. * Defines the list of key codes associated with the left action (increase beta)
  40887. */
  40888. keysLeft: number[];
  40889. /**
  40890. * Defines the list of key codes associated with the right action (decrease beta)
  40891. */
  40892. keysRight: number[];
  40893. /**
  40894. * Defines the list of key codes associated with the reset action.
  40895. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  40896. */
  40897. keysReset: number[];
  40898. /**
  40899. * Defines the panning sensibility of the inputs.
  40900. * (How fast is the camera paning)
  40901. */
  40902. panningSensibility: number;
  40903. /**
  40904. * Defines the zooming sensibility of the inputs.
  40905. * (How fast is the camera zooming)
  40906. */
  40907. zoomingSensibility: number;
  40908. /**
  40909. * Defines wether maintaining the alt key down switch the movement mode from
  40910. * orientation to zoom.
  40911. */
  40912. useAltToZoom: boolean;
  40913. /**
  40914. * Rotation speed of the camera
  40915. */
  40916. angularSpeed: number;
  40917. private _keys;
  40918. private _ctrlPressed;
  40919. private _altPressed;
  40920. private _onCanvasBlurObserver;
  40921. private _onKeyboardObserver;
  40922. private _engine;
  40923. private _scene;
  40924. /**
  40925. * Attach the input controls to a specific dom element to get the input from.
  40926. * @param element Defines the element the controls should be listened from
  40927. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40928. */
  40929. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40930. /**
  40931. * Detach the current controls from the specified dom element.
  40932. * @param element Defines the element to stop listening the inputs from
  40933. */
  40934. detachControl(element: Nullable<HTMLElement>): void;
  40935. /**
  40936. * Update the current camera state depending on the inputs that have been used this frame.
  40937. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40938. */
  40939. checkInputs(): void;
  40940. /**
  40941. * Gets the class name of the current intput.
  40942. * @returns the class name
  40943. */
  40944. getClassName(): string;
  40945. /**
  40946. * Get the friendly name associated with the input class.
  40947. * @returns the input friendly name
  40948. */
  40949. getSimpleName(): string;
  40950. }
  40951. }
  40952. declare module BABYLON {
  40953. /**
  40954. * Manage the mouse wheel inputs to control an arc rotate camera.
  40955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40956. */
  40957. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40958. /**
  40959. * Defines the camera the input is attached to.
  40960. */
  40961. camera: ArcRotateCamera;
  40962. /**
  40963. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40964. */
  40965. wheelPrecision: number;
  40966. /**
  40967. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40968. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40969. */
  40970. wheelDeltaPercentage: number;
  40971. private _wheel;
  40972. private _observer;
  40973. /**
  40974. * Attach the input controls to a specific dom element to get the input from.
  40975. * @param element Defines the element the controls should be listened from
  40976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40977. */
  40978. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40979. /**
  40980. * Detach the current controls from the specified dom element.
  40981. * @param element Defines the element to stop listening the inputs from
  40982. */
  40983. detachControl(element: Nullable<HTMLElement>): void;
  40984. /**
  40985. * Gets the class name of the current intput.
  40986. * @returns the class name
  40987. */
  40988. getClassName(): string;
  40989. /**
  40990. * Get the friendly name associated with the input class.
  40991. * @returns the input friendly name
  40992. */
  40993. getSimpleName(): string;
  40994. }
  40995. }
  40996. declare module BABYLON {
  40997. /**
  40998. * Manage the pointers inputs to control an arc rotate camera.
  40999. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41000. */
  41001. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41002. /**
  41003. * Defines the camera the input is attached to.
  41004. */
  41005. camera: ArcRotateCamera;
  41006. /**
  41007. * Defines the buttons associated with the input to handle camera move.
  41008. */
  41009. buttons: number[];
  41010. /**
  41011. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41012. */
  41013. angularSensibilityX: number;
  41014. /**
  41015. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41016. */
  41017. angularSensibilityY: number;
  41018. /**
  41019. * Defines the pointer pinch precision or how fast is the camera zooming.
  41020. */
  41021. pinchPrecision: number;
  41022. /**
  41023. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41024. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41025. */
  41026. pinchDeltaPercentage: number;
  41027. /**
  41028. * Defines the pointer panning sensibility or how fast is the camera moving.
  41029. */
  41030. panningSensibility: number;
  41031. /**
  41032. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41033. */
  41034. multiTouchPanning: boolean;
  41035. /**
  41036. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41037. */
  41038. multiTouchPanAndZoom: boolean;
  41039. /**
  41040. * Revers pinch action direction.
  41041. */
  41042. pinchInwards: boolean;
  41043. private _isPanClick;
  41044. private _pointerInput;
  41045. private _observer;
  41046. private _onMouseMove;
  41047. private _onGestureStart;
  41048. private _onGesture;
  41049. private _MSGestureHandler;
  41050. private _onLostFocus;
  41051. private _onContextMenu;
  41052. /**
  41053. * Attach the input controls to a specific dom element to get the input from.
  41054. * @param element Defines the element the controls should be listened from
  41055. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41056. */
  41057. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41058. /**
  41059. * Detach the current controls from the specified dom element.
  41060. * @param element Defines the element to stop listening the inputs from
  41061. */
  41062. detachControl(element: Nullable<HTMLElement>): void;
  41063. /**
  41064. * Gets the class name of the current intput.
  41065. * @returns the class name
  41066. */
  41067. getClassName(): string;
  41068. /**
  41069. * Get the friendly name associated with the input class.
  41070. * @returns the input friendly name
  41071. */
  41072. getSimpleName(): string;
  41073. }
  41074. }
  41075. declare module BABYLON {
  41076. /**
  41077. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41079. */
  41080. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41081. /**
  41082. * Defines the camera the input is attached to.
  41083. */
  41084. camera: ArcRotateCamera;
  41085. /**
  41086. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41087. */
  41088. alphaCorrection: number;
  41089. /**
  41090. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41091. */
  41092. gammaCorrection: number;
  41093. private _alpha;
  41094. private _gamma;
  41095. private _dirty;
  41096. private _deviceOrientationHandler;
  41097. /**
  41098. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41099. */
  41100. constructor();
  41101. /**
  41102. * Attach the input controls to a specific dom element to get the input from.
  41103. * @param element Defines the element the controls should be listened from
  41104. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41105. */
  41106. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41107. /** @hidden */
  41108. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41109. /**
  41110. * Update the current camera state depending on the inputs that have been used this frame.
  41111. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41112. */
  41113. checkInputs(): void;
  41114. /**
  41115. * Detach the current controls from the specified dom element.
  41116. * @param element Defines the element to stop listening the inputs from
  41117. */
  41118. detachControl(element: Nullable<HTMLElement>): void;
  41119. /**
  41120. * Gets the class name of the current intput.
  41121. * @returns the class name
  41122. */
  41123. getClassName(): string;
  41124. /**
  41125. * Get the friendly name associated with the input class.
  41126. * @returns the input friendly name
  41127. */
  41128. getSimpleName(): string;
  41129. }
  41130. }
  41131. declare module BABYLON {
  41132. /**
  41133. * Listen to keyboard events to control the camera.
  41134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41135. */
  41136. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41137. /**
  41138. * Defines the camera the input is attached to.
  41139. */
  41140. camera: FlyCamera;
  41141. /**
  41142. * The list of keyboard keys used to control the forward move of the camera.
  41143. */
  41144. keysForward: number[];
  41145. /**
  41146. * The list of keyboard keys used to control the backward move of the camera.
  41147. */
  41148. keysBackward: number[];
  41149. /**
  41150. * The list of keyboard keys used to control the forward move of the camera.
  41151. */
  41152. keysUp: number[];
  41153. /**
  41154. * The list of keyboard keys used to control the backward move of the camera.
  41155. */
  41156. keysDown: number[];
  41157. /**
  41158. * The list of keyboard keys used to control the right strafe move of the camera.
  41159. */
  41160. keysRight: number[];
  41161. /**
  41162. * The list of keyboard keys used to control the left strafe move of the camera.
  41163. */
  41164. keysLeft: number[];
  41165. private _keys;
  41166. private _onCanvasBlurObserver;
  41167. private _onKeyboardObserver;
  41168. private _engine;
  41169. private _scene;
  41170. /**
  41171. * Attach the input controls to a specific dom element to get the input from.
  41172. * @param element Defines the element the controls should be listened from
  41173. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41174. */
  41175. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41176. /**
  41177. * Detach the current controls from the specified dom element.
  41178. * @param element Defines the element to stop listening the inputs from
  41179. */
  41180. detachControl(element: Nullable<HTMLElement>): void;
  41181. /**
  41182. * Gets the class name of the current intput.
  41183. * @returns the class name
  41184. */
  41185. getClassName(): string;
  41186. /** @hidden */
  41187. _onLostFocus(e: FocusEvent): void;
  41188. /**
  41189. * Get the friendly name associated with the input class.
  41190. * @returns the input friendly name
  41191. */
  41192. getSimpleName(): string;
  41193. /**
  41194. * Update the current camera state depending on the inputs that have been used this frame.
  41195. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41196. */
  41197. checkInputs(): void;
  41198. }
  41199. }
  41200. declare module BABYLON {
  41201. /**
  41202. * Listen to mouse events to control the camera.
  41203. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41204. */
  41205. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41206. /**
  41207. * Defines the camera the input is attached to.
  41208. */
  41209. camera: FlyCamera;
  41210. /**
  41211. * Defines if touch is enabled. (Default is true.)
  41212. */
  41213. touchEnabled: boolean;
  41214. /**
  41215. * Defines the buttons associated with the input to handle camera rotation.
  41216. */
  41217. buttons: number[];
  41218. /**
  41219. * Assign buttons for Yaw control.
  41220. */
  41221. buttonsYaw: number[];
  41222. /**
  41223. * Assign buttons for Pitch control.
  41224. */
  41225. buttonsPitch: number[];
  41226. /**
  41227. * Assign buttons for Roll control.
  41228. */
  41229. buttonsRoll: number[];
  41230. /**
  41231. * Detect if any button is being pressed while mouse is moved.
  41232. * -1 = Mouse locked.
  41233. * 0 = Left button.
  41234. * 1 = Middle Button.
  41235. * 2 = Right Button.
  41236. */
  41237. activeButton: number;
  41238. /**
  41239. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41240. * Higher values reduce its sensitivity.
  41241. */
  41242. angularSensibility: number;
  41243. private _mousemoveCallback;
  41244. private _observer;
  41245. private _rollObserver;
  41246. private previousPosition;
  41247. private noPreventDefault;
  41248. private element;
  41249. /**
  41250. * Listen to mouse events to control the camera.
  41251. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41252. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41253. */
  41254. constructor(touchEnabled?: boolean);
  41255. /**
  41256. * Attach the mouse control to the HTML DOM element.
  41257. * @param element Defines the element that listens to the input events.
  41258. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41259. */
  41260. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41261. /**
  41262. * Detach the current controls from the specified dom element.
  41263. * @param element Defines the element to stop listening the inputs from
  41264. */
  41265. detachControl(element: Nullable<HTMLElement>): void;
  41266. /**
  41267. * Gets the class name of the current input.
  41268. * @returns the class name.
  41269. */
  41270. getClassName(): string;
  41271. /**
  41272. * Get the friendly name associated with the input class.
  41273. * @returns the input's friendly name.
  41274. */
  41275. getSimpleName(): string;
  41276. private _pointerInput;
  41277. private _onMouseMove;
  41278. /**
  41279. * Rotate camera by mouse offset.
  41280. */
  41281. private rotateCamera;
  41282. }
  41283. }
  41284. declare module BABYLON {
  41285. /**
  41286. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41287. * Screen rotation is taken into account.
  41288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41289. */
  41290. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41291. private _camera;
  41292. private _screenOrientationAngle;
  41293. private _constantTranform;
  41294. private _screenQuaternion;
  41295. private _alpha;
  41296. private _beta;
  41297. private _gamma;
  41298. /**
  41299. * Instantiates a new input
  41300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41301. */
  41302. constructor();
  41303. /**
  41304. * Define the camera controlled by the input.
  41305. */
  41306. camera: FreeCamera;
  41307. /**
  41308. * Attach the input controls to a specific dom element to get the input from.
  41309. * @param element Defines the element the controls should be listened from
  41310. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41311. */
  41312. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41313. private _orientationChanged;
  41314. private _deviceOrientation;
  41315. /**
  41316. * Detach the current controls from the specified dom element.
  41317. * @param element Defines the element to stop listening the inputs from
  41318. */
  41319. detachControl(element: Nullable<HTMLElement>): void;
  41320. /**
  41321. * Update the current camera state depending on the inputs that have been used this frame.
  41322. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41323. */
  41324. checkInputs(): void;
  41325. /**
  41326. * Gets the class name of the current intput.
  41327. * @returns the class name
  41328. */
  41329. getClassName(): string;
  41330. /**
  41331. * Get the friendly name associated with the input class.
  41332. * @returns the input friendly name
  41333. */
  41334. getSimpleName(): string;
  41335. }
  41336. }
  41337. declare module BABYLON {
  41338. /**
  41339. * Manage the gamepad inputs to control a free camera.
  41340. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41341. */
  41342. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41343. /**
  41344. * Define the camera the input is attached to.
  41345. */
  41346. camera: FreeCamera;
  41347. /**
  41348. * Define the Gamepad controlling the input
  41349. */
  41350. gamepad: Nullable<Gamepad>;
  41351. /**
  41352. * Defines the gamepad rotation sensiblity.
  41353. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41354. */
  41355. gamepadAngularSensibility: number;
  41356. /**
  41357. * Defines the gamepad move sensiblity.
  41358. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41359. */
  41360. gamepadMoveSensibility: number;
  41361. private _onGamepadConnectedObserver;
  41362. private _onGamepadDisconnectedObserver;
  41363. private _cameraTransform;
  41364. private _deltaTransform;
  41365. private _vector3;
  41366. private _vector2;
  41367. /**
  41368. * Attach the input controls to a specific dom element to get the input from.
  41369. * @param element Defines the element the controls should be listened from
  41370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41371. */
  41372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41373. /**
  41374. * Detach the current controls from the specified dom element.
  41375. * @param element Defines the element to stop listening the inputs from
  41376. */
  41377. detachControl(element: Nullable<HTMLElement>): void;
  41378. /**
  41379. * Update the current camera state depending on the inputs that have been used this frame.
  41380. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41381. */
  41382. checkInputs(): void;
  41383. /**
  41384. * Gets the class name of the current intput.
  41385. * @returns the class name
  41386. */
  41387. getClassName(): string;
  41388. /**
  41389. * Get the friendly name associated with the input class.
  41390. * @returns the input friendly name
  41391. */
  41392. getSimpleName(): string;
  41393. }
  41394. }
  41395. declare module BABYLON {
  41396. /**
  41397. * Manage the keyboard inputs to control the movement of a free camera.
  41398. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41399. */
  41400. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  41401. /**
  41402. * Defines the camera the input is attached to.
  41403. */
  41404. camera: FreeCamera;
  41405. /**
  41406. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  41407. */
  41408. keysUp: number[];
  41409. /**
  41410. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  41411. */
  41412. keysDown: number[];
  41413. /**
  41414. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  41415. */
  41416. keysLeft: number[];
  41417. /**
  41418. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  41419. */
  41420. keysRight: number[];
  41421. private _keys;
  41422. private _onCanvasBlurObserver;
  41423. private _onKeyboardObserver;
  41424. private _engine;
  41425. private _scene;
  41426. /**
  41427. * Attach the input controls to a specific dom element to get the input from.
  41428. * @param element Defines the element the controls should be listened from
  41429. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41430. */
  41431. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41432. /**
  41433. * Detach the current controls from the specified dom element.
  41434. * @param element Defines the element to stop listening the inputs from
  41435. */
  41436. detachControl(element: Nullable<HTMLElement>): void;
  41437. /**
  41438. * Update the current camera state depending on the inputs that have been used this frame.
  41439. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41440. */
  41441. checkInputs(): void;
  41442. /**
  41443. * Gets the class name of the current intput.
  41444. * @returns the class name
  41445. */
  41446. getClassName(): string;
  41447. /** @hidden */
  41448. _onLostFocus(e: FocusEvent): void;
  41449. /**
  41450. * Get the friendly name associated with the input class.
  41451. * @returns the input friendly name
  41452. */
  41453. getSimpleName(): string;
  41454. }
  41455. }
  41456. declare module BABYLON {
  41457. /**
  41458. * Manage the mouse inputs to control the movement of a free camera.
  41459. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41460. */
  41461. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  41462. /**
  41463. * Define if touch is enabled in the mouse input
  41464. */
  41465. touchEnabled: boolean;
  41466. /**
  41467. * Defines the camera the input is attached to.
  41468. */
  41469. camera: FreeCamera;
  41470. /**
  41471. * Defines the buttons associated with the input to handle camera move.
  41472. */
  41473. buttons: number[];
  41474. /**
  41475. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  41476. */
  41477. angularSensibility: number;
  41478. private _pointerInput;
  41479. private _onMouseMove;
  41480. private _observer;
  41481. private previousPosition;
  41482. /**
  41483. * Manage the mouse inputs to control the movement of a free camera.
  41484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41485. * @param touchEnabled Defines if touch is enabled or not
  41486. */
  41487. constructor(
  41488. /**
  41489. * Define if touch is enabled in the mouse input
  41490. */
  41491. touchEnabled?: boolean);
  41492. /**
  41493. * Attach the input controls to a specific dom element to get the input from.
  41494. * @param element Defines the element the controls should be listened from
  41495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41496. */
  41497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41498. /**
  41499. * Detach the current controls from the specified dom element.
  41500. * @param element Defines the element to stop listening the inputs from
  41501. */
  41502. detachControl(element: Nullable<HTMLElement>): void;
  41503. /**
  41504. * Gets the class name of the current intput.
  41505. * @returns the class name
  41506. */
  41507. getClassName(): string;
  41508. /**
  41509. * Get the friendly name associated with the input class.
  41510. * @returns the input friendly name
  41511. */
  41512. getSimpleName(): string;
  41513. }
  41514. }
  41515. declare module BABYLON {
  41516. /**
  41517. * Manage the touch inputs to control the movement of a free camera.
  41518. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41519. */
  41520. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  41521. /**
  41522. * Defines the camera the input is attached to.
  41523. */
  41524. camera: FreeCamera;
  41525. /**
  41526. * Defines the touch sensibility for rotation.
  41527. * The higher the faster.
  41528. */
  41529. touchAngularSensibility: number;
  41530. /**
  41531. * Defines the touch sensibility for move.
  41532. * The higher the faster.
  41533. */
  41534. touchMoveSensibility: number;
  41535. private _offsetX;
  41536. private _offsetY;
  41537. private _pointerPressed;
  41538. private _pointerInput;
  41539. private _observer;
  41540. private _onLostFocus;
  41541. /**
  41542. * Attach the input controls to a specific dom element to get the input from.
  41543. * @param element Defines the element the controls should be listened from
  41544. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41545. */
  41546. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41547. /**
  41548. * Detach the current controls from the specified dom element.
  41549. * @param element Defines the element to stop listening the inputs from
  41550. */
  41551. detachControl(element: Nullable<HTMLElement>): void;
  41552. /**
  41553. * Update the current camera state depending on the inputs that have been used this frame.
  41554. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41555. */
  41556. checkInputs(): void;
  41557. /**
  41558. * Gets the class name of the current intput.
  41559. * @returns the class name
  41560. */
  41561. getClassName(): string;
  41562. /**
  41563. * Get the friendly name associated with the input class.
  41564. * @returns the input friendly name
  41565. */
  41566. getSimpleName(): string;
  41567. }
  41568. }
  41569. declare module BABYLON {
  41570. /**
  41571. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41572. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41573. */
  41574. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41575. /**
  41576. * Defines the camera the input is attached to.
  41577. */
  41578. camera: FreeCamera;
  41579. private _leftjoystick;
  41580. private _rightjoystick;
  41581. /**
  41582. * Gets the left stick of the virtual joystick.
  41583. * @returns The virtual Joystick
  41584. */
  41585. getLeftJoystick(): VirtualJoystick;
  41586. /**
  41587. * Gets the right stick of the virtual joystick.
  41588. * @returns The virtual Joystick
  41589. */
  41590. getRightJoystick(): VirtualJoystick;
  41591. /**
  41592. * Update the current camera state depending on the inputs that have been used this frame.
  41593. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41594. */
  41595. checkInputs(): void;
  41596. /**
  41597. * Attach the input controls to a specific dom element to get the input from.
  41598. * @param element Defines the element the controls should be listened from
  41599. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41600. */
  41601. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41602. /**
  41603. * Detach the current controls from the specified dom element.
  41604. * @param element Defines the element to stop listening the inputs from
  41605. */
  41606. detachControl(element: Nullable<HTMLElement>): void;
  41607. /**
  41608. * Gets the class name of the current intput.
  41609. * @returns the class name
  41610. */
  41611. getClassName(): string;
  41612. /**
  41613. * Get the friendly name associated with the input class.
  41614. * @returns the input friendly name
  41615. */
  41616. getSimpleName(): string;
  41617. }
  41618. }
  41619. declare module BABYLON {
  41620. /**
  41621. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41622. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41623. */
  41624. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41625. /**
  41626. * Creates a new AnaglyphArcRotateCamera
  41627. * @param name defines camera name
  41628. * @param alpha defines alpha angle (in radians)
  41629. * @param beta defines beta angle (in radians)
  41630. * @param radius defines radius
  41631. * @param target defines camera target
  41632. * @param interaxialDistance defines distance between each color axis
  41633. * @param scene defines the hosting scene
  41634. */
  41635. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41636. /**
  41637. * Gets camera class name
  41638. * @returns AnaglyphArcRotateCamera
  41639. */
  41640. getClassName(): string;
  41641. }
  41642. }
  41643. declare module BABYLON {
  41644. /**
  41645. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41646. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41647. */
  41648. class AnaglyphFreeCamera extends FreeCamera {
  41649. /**
  41650. * Creates a new AnaglyphFreeCamera
  41651. * @param name defines camera name
  41652. * @param position defines initial position
  41653. * @param interaxialDistance defines distance between each color axis
  41654. * @param scene defines the hosting scene
  41655. */
  41656. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41657. /**
  41658. * Gets camera class name
  41659. * @returns AnaglyphFreeCamera
  41660. */
  41661. getClassName(): string;
  41662. }
  41663. }
  41664. declare module BABYLON {
  41665. /**
  41666. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41667. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41668. */
  41669. class AnaglyphGamepadCamera extends GamepadCamera {
  41670. /**
  41671. * Creates a new AnaglyphGamepadCamera
  41672. * @param name defines camera name
  41673. * @param position defines initial position
  41674. * @param interaxialDistance defines distance between each color axis
  41675. * @param scene defines the hosting scene
  41676. */
  41677. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41678. /**
  41679. * Gets camera class name
  41680. * @returns AnaglyphGamepadCamera
  41681. */
  41682. getClassName(): string;
  41683. }
  41684. }
  41685. declare module BABYLON {
  41686. /**
  41687. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41688. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41689. */
  41690. class AnaglyphUniversalCamera extends UniversalCamera {
  41691. /**
  41692. * Creates a new AnaglyphUniversalCamera
  41693. * @param name defines camera name
  41694. * @param position defines initial position
  41695. * @param interaxialDistance defines distance between each color axis
  41696. * @param scene defines the hosting scene
  41697. */
  41698. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41699. /**
  41700. * Gets camera class name
  41701. * @returns AnaglyphUniversalCamera
  41702. */
  41703. getClassName(): string;
  41704. }
  41705. }
  41706. declare module BABYLON {
  41707. /**
  41708. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41709. * @see http://doc.babylonjs.com/features/cameras
  41710. */
  41711. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41712. /**
  41713. * Creates a new StereoscopicArcRotateCamera
  41714. * @param name defines camera name
  41715. * @param alpha defines alpha angle (in radians)
  41716. * @param beta defines beta angle (in radians)
  41717. * @param radius defines radius
  41718. * @param target defines camera target
  41719. * @param interaxialDistance defines distance between each color axis
  41720. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41721. * @param scene defines the hosting scene
  41722. */
  41723. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41724. /**
  41725. * Gets camera class name
  41726. * @returns StereoscopicArcRotateCamera
  41727. */
  41728. getClassName(): string;
  41729. }
  41730. }
  41731. declare module BABYLON {
  41732. /**
  41733. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41734. * @see http://doc.babylonjs.com/features/cameras
  41735. */
  41736. class StereoscopicFreeCamera extends FreeCamera {
  41737. /**
  41738. * Creates a new StereoscopicFreeCamera
  41739. * @param name defines camera name
  41740. * @param position defines initial position
  41741. * @param interaxialDistance defines distance between each color axis
  41742. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41743. * @param scene defines the hosting scene
  41744. */
  41745. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41746. /**
  41747. * Gets camera class name
  41748. * @returns StereoscopicFreeCamera
  41749. */
  41750. getClassName(): string;
  41751. }
  41752. }
  41753. declare module BABYLON {
  41754. /**
  41755. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41756. * @see http://doc.babylonjs.com/features/cameras
  41757. */
  41758. class StereoscopicGamepadCamera extends GamepadCamera {
  41759. /**
  41760. * Creates a new StereoscopicGamepadCamera
  41761. * @param name defines camera name
  41762. * @param position defines initial position
  41763. * @param interaxialDistance defines distance between each color axis
  41764. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41765. * @param scene defines the hosting scene
  41766. */
  41767. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41768. /**
  41769. * Gets camera class name
  41770. * @returns StereoscopicGamepadCamera
  41771. */
  41772. getClassName(): string;
  41773. }
  41774. }
  41775. declare module BABYLON {
  41776. /**
  41777. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41778. * @see http://doc.babylonjs.com/features/cameras
  41779. */
  41780. class StereoscopicUniversalCamera extends UniversalCamera {
  41781. /**
  41782. * Creates a new StereoscopicUniversalCamera
  41783. * @param name defines camera name
  41784. * @param position defines initial position
  41785. * @param interaxialDistance defines distance between each color axis
  41786. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41787. * @param scene defines the hosting scene
  41788. */
  41789. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41790. /**
  41791. * Gets camera class name
  41792. * @returns StereoscopicUniversalCamera
  41793. */
  41794. getClassName(): string;
  41795. }
  41796. }
  41797. declare module BABYLON {
  41798. /**
  41799. * This represents all the required metrics to create a VR camera.
  41800. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41801. */
  41802. class VRCameraMetrics {
  41803. /**
  41804. * Define the horizontal resolution off the screen.
  41805. */
  41806. hResolution: number;
  41807. /**
  41808. * Define the vertical resolution off the screen.
  41809. */
  41810. vResolution: number;
  41811. /**
  41812. * Define the horizontal screen size.
  41813. */
  41814. hScreenSize: number;
  41815. /**
  41816. * Define the vertical screen size.
  41817. */
  41818. vScreenSize: number;
  41819. /**
  41820. * Define the vertical screen center position.
  41821. */
  41822. vScreenCenter: number;
  41823. /**
  41824. * Define the distance of the eyes to the screen.
  41825. */
  41826. eyeToScreenDistance: number;
  41827. /**
  41828. * Define the distance between both lenses
  41829. */
  41830. lensSeparationDistance: number;
  41831. /**
  41832. * Define the distance between both viewer's eyes.
  41833. */
  41834. interpupillaryDistance: number;
  41835. /**
  41836. * Define the distortion factor of the VR postprocess.
  41837. * Please, touch with care.
  41838. */
  41839. distortionK: number[];
  41840. /**
  41841. * Define the chromatic aberration correction factors for the VR post process.
  41842. */
  41843. chromaAbCorrection: number[];
  41844. /**
  41845. * Define the scale factor of the post process.
  41846. * The smaller the better but the slower.
  41847. */
  41848. postProcessScaleFactor: number;
  41849. /**
  41850. * Define an offset for the lens center.
  41851. */
  41852. lensCenterOffset: number;
  41853. /**
  41854. * Define if the current vr camera should compensate the distortion of the lense or not.
  41855. */
  41856. compensateDistortion: boolean;
  41857. /**
  41858. * Gets the rendering aspect ratio based on the provided resolutions.
  41859. */
  41860. readonly aspectRatio: number;
  41861. /**
  41862. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41863. */
  41864. readonly aspectRatioFov: number;
  41865. /**
  41866. * @hidden
  41867. */
  41868. readonly leftHMatrix: Matrix;
  41869. /**
  41870. * @hidden
  41871. */
  41872. readonly rightHMatrix: Matrix;
  41873. /**
  41874. * @hidden
  41875. */
  41876. readonly leftPreViewMatrix: Matrix;
  41877. /**
  41878. * @hidden
  41879. */
  41880. readonly rightPreViewMatrix: Matrix;
  41881. /**
  41882. * Get the default VRMetrics based on the most generic setup.
  41883. * @returns the default vr metrics
  41884. */
  41885. static GetDefault(): VRCameraMetrics;
  41886. }
  41887. }
  41888. declare module BABYLON {
  41889. /**
  41890. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41891. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41892. */
  41893. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41894. /**
  41895. * Creates a new VRDeviceOrientationArcRotateCamera
  41896. * @param name defines camera name
  41897. * @param alpha defines the camera rotation along the logitudinal axis
  41898. * @param beta defines the camera rotation along the latitudinal axis
  41899. * @param radius defines the camera distance from its target
  41900. * @param target defines the camera target
  41901. * @param scene defines the scene the camera belongs to
  41902. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41903. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41904. */
  41905. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41906. /**
  41907. * Gets camera class name
  41908. * @returns VRDeviceOrientationArcRotateCamera
  41909. */
  41910. getClassName(): string;
  41911. }
  41912. }
  41913. declare module BABYLON {
  41914. /**
  41915. * Camera used to simulate VR rendering (based on FreeCamera)
  41916. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41917. */
  41918. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41919. /**
  41920. * Creates a new VRDeviceOrientationFreeCamera
  41921. * @param name defines camera name
  41922. * @param position defines the start position of the camera
  41923. * @param scene defines the scene the camera belongs to
  41924. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41925. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41926. */
  41927. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41928. /**
  41929. * Gets camera class name
  41930. * @returns VRDeviceOrientationFreeCamera
  41931. */
  41932. getClassName(): string;
  41933. }
  41934. }
  41935. declare module BABYLON {
  41936. /**
  41937. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41938. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41939. */
  41940. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41941. /**
  41942. * Creates a new VRDeviceOrientationGamepadCamera
  41943. * @param name defines camera name
  41944. * @param position defines the start position of the camera
  41945. * @param scene defines the scene the camera belongs to
  41946. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41947. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41948. */
  41949. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41950. /**
  41951. * Gets camera class name
  41952. * @returns VRDeviceOrientationGamepadCamera
  41953. */
  41954. getClassName(): string;
  41955. }
  41956. }
  41957. declare module BABYLON {
  41958. /**
  41959. * Options to modify the vr teleportation behavior.
  41960. */
  41961. interface VRTeleportationOptions {
  41962. /**
  41963. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41964. */
  41965. floorMeshName?: string;
  41966. /**
  41967. * A list of meshes to be used as the teleportation floor. (default: empty)
  41968. */
  41969. floorMeshes?: Mesh[];
  41970. }
  41971. /**
  41972. * Options to modify the vr experience helper's behavior.
  41973. */
  41974. interface VRExperienceHelperOptions extends WebVROptions {
  41975. /**
  41976. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41977. */
  41978. createDeviceOrientationCamera?: boolean;
  41979. /**
  41980. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41981. */
  41982. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41983. /**
  41984. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41985. */
  41986. laserToggle?: boolean;
  41987. /**
  41988. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41989. */
  41990. floorMeshes?: Mesh[];
  41991. }
  41992. /**
  41993. * Helps to quickly add VR support to an existing scene.
  41994. * See http://doc.babylonjs.com/how_to/webvr_helper
  41995. */
  41996. class VRExperienceHelper {
  41997. /** Options to modify the vr experience helper's behavior. */
  41998. webVROptions: VRExperienceHelperOptions;
  41999. private _scene;
  42000. private _position;
  42001. private _btnVR;
  42002. private _btnVRDisplayed;
  42003. private _webVRsupported;
  42004. private _webVRready;
  42005. private _webVRrequesting;
  42006. private _webVRpresenting;
  42007. private _hasEnteredVR;
  42008. private _fullscreenVRpresenting;
  42009. private _canvas;
  42010. private _webVRCamera;
  42011. private _vrDeviceOrientationCamera;
  42012. private _deviceOrientationCamera;
  42013. private _existingCamera;
  42014. private _onKeyDown;
  42015. private _onVrDisplayPresentChange;
  42016. private _onVRDisplayChanged;
  42017. private _onVRRequestPresentStart;
  42018. private _onVRRequestPresentComplete;
  42019. /**
  42020. * Observable raised when entering VR.
  42021. */
  42022. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42023. /**
  42024. * Observable raised when exiting VR.
  42025. */
  42026. onExitingVRObservable: Observable<VRExperienceHelper>;
  42027. /**
  42028. * Observable raised when controller mesh is loaded.
  42029. */
  42030. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42031. /** Return this.onEnteringVRObservable
  42032. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42033. */
  42034. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42035. /** Return this.onExitingVRObservable
  42036. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42037. */
  42038. readonly onExitingVR: Observable<VRExperienceHelper>;
  42039. /** Return this.onControllerMeshLoadedObservable
  42040. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42041. */
  42042. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42043. private _rayLength;
  42044. private _useCustomVRButton;
  42045. private _teleportationRequested;
  42046. private _teleportActive;
  42047. private _floorMeshName;
  42048. private _floorMeshesCollection;
  42049. private _rotationAllowed;
  42050. private _teleportBackwardsVector;
  42051. private _teleportationTarget;
  42052. private _isDefaultTeleportationTarget;
  42053. private _postProcessMove;
  42054. private _teleportationFillColor;
  42055. private _teleportationBorderColor;
  42056. private _rotationAngle;
  42057. private _haloCenter;
  42058. private _cameraGazer;
  42059. private _padSensibilityUp;
  42060. private _padSensibilityDown;
  42061. private _leftController;
  42062. private _rightController;
  42063. /**
  42064. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42065. */
  42066. onNewMeshSelected: Observable<AbstractMesh>;
  42067. /**
  42068. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42069. */
  42070. onNewMeshPicked: Observable<PickingInfo>;
  42071. private _circleEase;
  42072. /**
  42073. * Observable raised before camera teleportation
  42074. */
  42075. onBeforeCameraTeleport: Observable<Vector3>;
  42076. /**
  42077. * Observable raised after camera teleportation
  42078. */
  42079. onAfterCameraTeleport: Observable<Vector3>;
  42080. /**
  42081. * Observable raised when current selected mesh gets unselected
  42082. */
  42083. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42084. private _raySelectionPredicate;
  42085. /**
  42086. * To be optionaly changed by user to define custom ray selection
  42087. */
  42088. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42089. /**
  42090. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42091. */
  42092. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42093. /**
  42094. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42095. */
  42096. teleportationEnabled: boolean;
  42097. private _defaultHeight;
  42098. private _teleportationInitialized;
  42099. private _interactionsEnabled;
  42100. private _interactionsRequested;
  42101. private _displayGaze;
  42102. private _displayLaserPointer;
  42103. /**
  42104. * The mesh used to display where the user is going to teleport.
  42105. */
  42106. /**
  42107. * Sets the mesh to be used to display where the user is going to teleport.
  42108. */
  42109. teleportationTarget: Mesh;
  42110. /**
  42111. * 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
  42112. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42113. * See http://doc.babylonjs.com/resources/baking_transformations
  42114. */
  42115. gazeTrackerMesh: Mesh;
  42116. /**
  42117. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42118. */
  42119. updateGazeTrackerScale: boolean;
  42120. /**
  42121. * The gaze tracking mesh corresponding to the left controller
  42122. */
  42123. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42124. /**
  42125. * The gaze tracking mesh corresponding to the right controller
  42126. */
  42127. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42128. /**
  42129. * If the ray of the gaze should be displayed.
  42130. */
  42131. /**
  42132. * Sets if the ray of the gaze should be displayed.
  42133. */
  42134. displayGaze: boolean;
  42135. /**
  42136. * If the ray of the LaserPointer should be displayed.
  42137. */
  42138. /**
  42139. * Sets if the ray of the LaserPointer should be displayed.
  42140. */
  42141. displayLaserPointer: boolean;
  42142. /**
  42143. * The deviceOrientationCamera used as the camera when not in VR.
  42144. */
  42145. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42146. /**
  42147. * Based on the current WebVR support, returns the current VR camera used.
  42148. */
  42149. readonly currentVRCamera: Nullable<Camera>;
  42150. /**
  42151. * The webVRCamera which is used when in VR.
  42152. */
  42153. readonly webVRCamera: WebVRFreeCamera;
  42154. /**
  42155. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42156. */
  42157. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42158. private readonly _teleportationRequestInitiated;
  42159. /**
  42160. * Instantiates a VRExperienceHelper.
  42161. * Helps to quickly add VR support to an existing scene.
  42162. * @param scene The scene the VRExperienceHelper belongs to.
  42163. * @param webVROptions Options to modify the vr experience helper's behavior.
  42164. */
  42165. constructor(scene: Scene,
  42166. /** Options to modify the vr experience helper's behavior. */
  42167. webVROptions?: VRExperienceHelperOptions);
  42168. private _onDefaultMeshLoaded;
  42169. private _onResize;
  42170. private _onFullscreenChange;
  42171. /**
  42172. * Gets a value indicating if we are currently in VR mode.
  42173. */
  42174. readonly isInVRMode: boolean;
  42175. private onVrDisplayPresentChange;
  42176. private onVRDisplayChanged;
  42177. private moveButtonToBottomRight;
  42178. private displayVRButton;
  42179. private updateButtonVisibility;
  42180. /**
  42181. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42182. * Otherwise, will use the fullscreen API.
  42183. */
  42184. enterVR(): void;
  42185. /**
  42186. * Attempt to exit VR, or fullscreen.
  42187. */
  42188. exitVR(): void;
  42189. /**
  42190. * The position of the vr experience helper.
  42191. */
  42192. /**
  42193. * Sets the position of the vr experience helper.
  42194. */
  42195. position: Vector3;
  42196. /**
  42197. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42198. */
  42199. enableInteractions(): void;
  42200. private readonly _noControllerIsActive;
  42201. private beforeRender;
  42202. private _isTeleportationFloor;
  42203. /**
  42204. * Adds a floor mesh to be used for teleportation.
  42205. * @param floorMesh the mesh to be used for teleportation.
  42206. */
  42207. addFloorMesh(floorMesh: Mesh): void;
  42208. /**
  42209. * Removes a floor mesh from being used for teleportation.
  42210. * @param floorMesh the mesh to be removed.
  42211. */
  42212. removeFloorMesh(floorMesh: Mesh): void;
  42213. /**
  42214. * Enables interactions and teleportation using the VR controllers and gaze.
  42215. * @param vrTeleportationOptions options to modify teleportation behavior.
  42216. */
  42217. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42218. private _onNewGamepadConnected;
  42219. private _tryEnableInteractionOnController;
  42220. private _onNewGamepadDisconnected;
  42221. private _enableInteractionOnController;
  42222. private _checkTeleportWithRay;
  42223. private _checkRotate;
  42224. private _checkTeleportBackwards;
  42225. private _enableTeleportationOnController;
  42226. private _createTeleportationCircles;
  42227. private _displayTeleportationTarget;
  42228. private _hideTeleportationTarget;
  42229. private _rotateCamera;
  42230. private _moveTeleportationSelectorTo;
  42231. private _workingVector;
  42232. private _workingQuaternion;
  42233. private _workingMatrix;
  42234. /**
  42235. * Teleports the users feet to the desired location
  42236. * @param location The location where the user's feet should be placed
  42237. */
  42238. teleportCamera(location: Vector3): void;
  42239. private _convertNormalToDirectionOfRay;
  42240. private _castRayAndSelectObject;
  42241. private _notifySelectedMeshUnselected;
  42242. /**
  42243. * Sets the color of the laser ray from the vr controllers.
  42244. * @param color new color for the ray.
  42245. */
  42246. changeLaserColor(color: Color3): void;
  42247. /**
  42248. * Sets the color of the ray from the vr headsets gaze.
  42249. * @param color new color for the ray.
  42250. */
  42251. changeGazeColor(color: Color3): void;
  42252. /**
  42253. * Exits VR and disposes of the vr experience helper
  42254. */
  42255. dispose(): void;
  42256. /**
  42257. * Gets the name of the VRExperienceHelper class
  42258. * @returns "VRExperienceHelper"
  42259. */
  42260. getClassName(): string;
  42261. }
  42262. }
  42263. declare module BABYLON {
  42264. /**
  42265. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  42266. * IMPORTANT!! The data is right-hand data.
  42267. * @export
  42268. * @interface DevicePose
  42269. */
  42270. interface DevicePose {
  42271. /**
  42272. * The position of the device, values in array are [x,y,z].
  42273. */
  42274. readonly position: Nullable<Float32Array>;
  42275. /**
  42276. * The linearVelocity of the device, values in array are [x,y,z].
  42277. */
  42278. readonly linearVelocity: Nullable<Float32Array>;
  42279. /**
  42280. * The linearAcceleration of the device, values in array are [x,y,z].
  42281. */
  42282. readonly linearAcceleration: Nullable<Float32Array>;
  42283. /**
  42284. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  42285. */
  42286. readonly orientation: Nullable<Float32Array>;
  42287. /**
  42288. * The angularVelocity of the device, values in array are [x,y,z].
  42289. */
  42290. readonly angularVelocity: Nullable<Float32Array>;
  42291. /**
  42292. * The angularAcceleration of the device, values in array are [x,y,z].
  42293. */
  42294. readonly angularAcceleration: Nullable<Float32Array>;
  42295. }
  42296. /**
  42297. * Interface representing a pose controlled object in Babylon.
  42298. * A pose controlled object has both regular pose values as well as pose values
  42299. * from an external device such as a VR head mounted display
  42300. */
  42301. interface PoseControlled {
  42302. /**
  42303. * The position of the object in babylon space.
  42304. */
  42305. position: Vector3;
  42306. /**
  42307. * The rotation quaternion of the object in babylon space.
  42308. */
  42309. rotationQuaternion: Quaternion;
  42310. /**
  42311. * The position of the device in babylon space.
  42312. */
  42313. devicePosition?: Vector3;
  42314. /**
  42315. * The rotation quaternion of the device in babylon space.
  42316. */
  42317. deviceRotationQuaternion: Quaternion;
  42318. /**
  42319. * The raw pose coming from the device.
  42320. */
  42321. rawPose: Nullable<DevicePose>;
  42322. /**
  42323. * The scale of the device to be used when translating from device space to babylon space.
  42324. */
  42325. deviceScaleFactor: number;
  42326. /**
  42327. * Updates the poseControlled values based on the input device pose.
  42328. * @param poseData the pose data to update the object with
  42329. */
  42330. updateFromDevice(poseData: DevicePose): void;
  42331. }
  42332. /**
  42333. * Set of options to customize the webVRCamera
  42334. */
  42335. interface WebVROptions {
  42336. /**
  42337. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  42338. */
  42339. trackPosition?: boolean;
  42340. /**
  42341. * Sets the scale of the vrDevice in babylon space. (default: 1)
  42342. */
  42343. positionScale?: number;
  42344. /**
  42345. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  42346. */
  42347. displayName?: string;
  42348. /**
  42349. * Should the native controller meshes be initialized. (default: true)
  42350. */
  42351. controllerMeshes?: boolean;
  42352. /**
  42353. * Creating a default HemiLight only on controllers. (default: true)
  42354. */
  42355. defaultLightingOnControllers?: boolean;
  42356. /**
  42357. * If you don't want to use the default VR button of the helper. (default: false)
  42358. */
  42359. useCustomVRButton?: boolean;
  42360. /**
  42361. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  42362. */
  42363. customVRButton?: HTMLButtonElement;
  42364. /**
  42365. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  42366. */
  42367. rayLength?: number;
  42368. /**
  42369. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  42370. */
  42371. defaultHeight?: number;
  42372. }
  42373. /**
  42374. * This represents a WebVR camera.
  42375. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  42376. * @example http://doc.babylonjs.com/how_to/webvr_camera
  42377. */
  42378. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  42379. private webVROptions;
  42380. /**
  42381. * @hidden
  42382. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  42383. */
  42384. _vrDevice: any;
  42385. /**
  42386. * The rawPose of the vrDevice.
  42387. */
  42388. rawPose: Nullable<DevicePose>;
  42389. private _onVREnabled;
  42390. private _specsVersion;
  42391. private _attached;
  42392. private _frameData;
  42393. protected _descendants: Array<Node>;
  42394. private _deviceRoomPosition;
  42395. /** @hidden */
  42396. _deviceRoomRotationQuaternion: Quaternion;
  42397. private _standingMatrix;
  42398. /**
  42399. * Represents device position in babylon space.
  42400. */
  42401. devicePosition: Vector3;
  42402. /**
  42403. * Represents device rotation in babylon space.
  42404. */
  42405. deviceRotationQuaternion: Quaternion;
  42406. /**
  42407. * The scale of the device to be used when translating from device space to babylon space.
  42408. */
  42409. deviceScaleFactor: number;
  42410. private _deviceToWorld;
  42411. private _worldToDevice;
  42412. /**
  42413. * References to the webVR controllers for the vrDevice.
  42414. */
  42415. controllers: Array<WebVRController>;
  42416. /**
  42417. * Emits an event when a controller is attached.
  42418. */
  42419. onControllersAttachedObservable: Observable<WebVRController[]>;
  42420. /**
  42421. * Emits an event when a controller's mesh has been loaded;
  42422. */
  42423. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42424. /**
  42425. * Emits an event when the HMD's pose has been updated.
  42426. */
  42427. onPoseUpdatedFromDeviceObservable: Observable<any>;
  42428. private _poseSet;
  42429. /**
  42430. * If the rig cameras be used as parent instead of this camera.
  42431. */
  42432. rigParenting: boolean;
  42433. private _lightOnControllers;
  42434. private _defaultHeight?;
  42435. /**
  42436. * Instantiates a WebVRFreeCamera.
  42437. * @param name The name of the WebVRFreeCamera
  42438. * @param position The starting anchor position for the camera
  42439. * @param scene The scene the camera belongs to
  42440. * @param webVROptions a set of customizable options for the webVRCamera
  42441. */
  42442. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  42443. /**
  42444. * Gets the device distance from the ground in meters.
  42445. * @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.
  42446. */
  42447. deviceDistanceToRoomGround(): number;
  42448. /**
  42449. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42450. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  42451. */
  42452. useStandingMatrix(callback?: (bool: boolean) => void): void;
  42453. /**
  42454. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42455. * @returns A promise with a boolean set to if the standing matrix is supported.
  42456. */
  42457. useStandingMatrixAsync(): Promise<boolean>;
  42458. /**
  42459. * Disposes the camera
  42460. */
  42461. dispose(): void;
  42462. /**
  42463. * Gets a vrController by name.
  42464. * @param name The name of the controller to retreive
  42465. * @returns the controller matching the name specified or null if not found
  42466. */
  42467. getControllerByName(name: string): Nullable<WebVRController>;
  42468. private _leftController;
  42469. /**
  42470. * The controller corrisponding to the users left hand.
  42471. */
  42472. readonly leftController: Nullable<WebVRController>;
  42473. private _rightController;
  42474. /**
  42475. * The controller corrisponding to the users right hand.
  42476. */
  42477. readonly rightController: Nullable<WebVRController>;
  42478. /**
  42479. * Casts a ray forward from the vrCamera's gaze.
  42480. * @param length Length of the ray (default: 100)
  42481. * @returns the ray corrisponding to the gaze
  42482. */
  42483. getForwardRay(length?: number): Ray;
  42484. /**
  42485. * @hidden
  42486. * Updates the camera based on device's frame data
  42487. */
  42488. _checkInputs(): void;
  42489. /**
  42490. * Updates the poseControlled values based on the input device pose.
  42491. * @param poseData Pose coming from the device
  42492. */
  42493. updateFromDevice(poseData: DevicePose): void;
  42494. private _htmlElementAttached;
  42495. private _detachIfAttached;
  42496. /**
  42497. * WebVR's attach control will start broadcasting frames to the device.
  42498. * Note that in certain browsers (chrome for example) this function must be called
  42499. * within a user-interaction callback. Example:
  42500. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  42501. *
  42502. * @param element html element to attach the vrDevice to
  42503. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  42504. */
  42505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42506. /**
  42507. * Detaches the camera from the html element and disables VR
  42508. *
  42509. * @param element html element to detach from
  42510. */
  42511. detachControl(element: HTMLElement): void;
  42512. /**
  42513. * @returns the name of this class
  42514. */
  42515. getClassName(): string;
  42516. /**
  42517. * Calls resetPose on the vrDisplay
  42518. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  42519. */
  42520. resetToCurrentRotation(): void;
  42521. /**
  42522. * @hidden
  42523. * Updates the rig cameras (left and right eye)
  42524. */
  42525. _updateRigCameras(): void;
  42526. private _workingVector;
  42527. private _oneVector;
  42528. private _workingMatrix;
  42529. private updateCacheCalled;
  42530. private _correctPositionIfNotTrackPosition;
  42531. /**
  42532. * @hidden
  42533. * Updates the cached values of the camera
  42534. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  42535. */
  42536. _updateCache(ignoreParentClass?: boolean): void;
  42537. /**
  42538. * @hidden
  42539. * Get current device position in babylon world
  42540. */
  42541. _computeDevicePosition(): void;
  42542. /**
  42543. * Updates the current device position and rotation in the babylon world
  42544. */
  42545. update(): void;
  42546. /**
  42547. * @hidden
  42548. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  42549. * @returns an identity matrix
  42550. */
  42551. _getViewMatrix(): Matrix;
  42552. private _tmpMatrix;
  42553. /**
  42554. * This function is called by the two RIG cameras.
  42555. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  42556. */
  42557. protected _getWebVRViewMatrix(): Matrix;
  42558. protected _getWebVRProjectionMatrix(): Matrix;
  42559. private _onGamepadConnectedObserver;
  42560. private _onGamepadDisconnectedObserver;
  42561. private _updateCacheWhenTrackingDisabledObserver;
  42562. /**
  42563. * Initializes the controllers and their meshes
  42564. */
  42565. initControllers(): void;
  42566. }
  42567. }
  42568. declare module BABYLON {
  42569. /**
  42570. * WebXR Camera which holds the views for the xrSession
  42571. * @see https://doc.babylonjs.com/how_to/webxr
  42572. */
  42573. class WebXRCamera extends FreeCamera {
  42574. private static _TmpMatrix;
  42575. /**
  42576. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42577. * @param name the name of the camera
  42578. * @param scene the scene to add the camera to
  42579. */
  42580. constructor(name: string, scene: BABYLON.Scene);
  42581. private _updateNumberOfRigCameras;
  42582. /** @hidden */
  42583. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42584. /**
  42585. * Updates the cameras position from the current pose information of the XR session
  42586. * @param xrSessionManager the session containing pose information
  42587. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42588. */
  42589. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42590. }
  42591. }
  42592. declare module BABYLON {
  42593. /**
  42594. * Button which can be used to enter a different mode of XR
  42595. */
  42596. class WebXREnterExitUIButton {
  42597. /** button element */
  42598. element: HTMLElement;
  42599. /** XR initialization options for the button */
  42600. initializationOptions: XRSessionCreationOptions;
  42601. /**
  42602. * Creates a WebXREnterExitUIButton
  42603. * @param element button element
  42604. * @param initializationOptions XR initialization options for the button
  42605. */
  42606. constructor(
  42607. /** button element */
  42608. element: HTMLElement,
  42609. /** XR initialization options for the button */
  42610. initializationOptions: XRSessionCreationOptions);
  42611. /**
  42612. * Overwritable function which can be used to update the button's visuals when the state changes
  42613. * @param activeButton the current active button in the UI
  42614. */
  42615. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42616. }
  42617. /**
  42618. * Options to create the webXR UI
  42619. */
  42620. class WebXREnterExitUIOptions {
  42621. /**
  42622. * Context to enter xr with
  42623. */
  42624. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  42625. /**
  42626. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42627. */
  42628. customButtons?: Array<WebXREnterExitUIButton>;
  42629. }
  42630. /**
  42631. * UI to allow the user to enter/exit XR mode
  42632. */
  42633. class WebXREnterExitUI implements IDisposable {
  42634. private scene;
  42635. private _overlay;
  42636. private _buttons;
  42637. private _activeButton;
  42638. /**
  42639. * Fired every time the active button is changed.
  42640. *
  42641. * When xr is entered via a button that launches xr that button will be the callback parameter
  42642. *
  42643. * When exiting xr the callback parameter will be null)
  42644. */
  42645. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42646. /**
  42647. * Creates UI to allow the user to enter/exit XR mode
  42648. * @param scene the scene to add the ui to
  42649. * @param helper the xr experience helper to enter/exit xr with
  42650. * @param options options to configure the UI
  42651. * @returns the created ui
  42652. */
  42653. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42654. private constructor();
  42655. private _updateButtons;
  42656. /**
  42657. * Disposes of the object
  42658. */
  42659. dispose(): void;
  42660. }
  42661. }
  42662. declare module BABYLON {
  42663. /**
  42664. * States of the webXR experience
  42665. */
  42666. enum WebXRState {
  42667. /**
  42668. * Transitioning to being in XR mode
  42669. */
  42670. ENTERING_XR = 0,
  42671. /**
  42672. * Transitioning to non XR mode
  42673. */
  42674. EXITING_XR = 1,
  42675. /**
  42676. * In XR mode and presenting
  42677. */
  42678. IN_XR = 2,
  42679. /**
  42680. * Not entered XR mode
  42681. */
  42682. NOT_IN_XR = 3
  42683. }
  42684. /**
  42685. * Helper class used to enable XR
  42686. * @see https://doc.babylonjs.com/how_to/webxr
  42687. */
  42688. class WebXRExperienceHelper implements IDisposable {
  42689. private scene;
  42690. /**
  42691. * 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
  42692. */
  42693. container: AbstractMesh;
  42694. /**
  42695. * Camera used to render xr content
  42696. */
  42697. camera: WebXRCamera;
  42698. /**
  42699. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42700. */
  42701. state: WebXRState;
  42702. private _setState;
  42703. private static _TmpVector;
  42704. /**
  42705. * Fires when the state of the experience helper has changed
  42706. */
  42707. onStateChangedObservable: Observable<WebXRState>;
  42708. /** @hidden */
  42709. _sessionManager: WebXRSessionManager;
  42710. private _nonVRCamera;
  42711. private _originalSceneAutoClear;
  42712. private _supported;
  42713. /**
  42714. * Creates the experience helper
  42715. * @param scene the scene to attach the experience helper to
  42716. * @returns a promise for the experience helper
  42717. */
  42718. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  42719. /**
  42720. * Creates a WebXRExperienceHelper
  42721. * @param scene The scene the helper should be created in
  42722. */
  42723. private constructor();
  42724. /**
  42725. * Exits XR mode and returns the scene to its original state
  42726. * @returns promise that resolves after xr mode has exited
  42727. */
  42728. exitXRAsync(): Promise<void>;
  42729. /**
  42730. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42731. * @param sessionCreationOptions options for the XR session
  42732. * @param frameOfReference frame of reference of the XR session
  42733. * @returns promise that resolves after xr mode has entered
  42734. */
  42735. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  42736. /**
  42737. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  42738. * @param ray ray to cast into the environment
  42739. * @returns Promise which resolves with a collision point in the environment if it exists
  42740. */
  42741. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  42742. /**
  42743. * Updates the global position of the camera by moving the camera's container
  42744. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42745. * @param position The desired global position of the camera
  42746. */
  42747. setPositionOfCameraUsingContainer(position: Vector3): void;
  42748. /**
  42749. * Rotates the xr camera by rotating the camera's container around the camera's position
  42750. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42751. * @param rotation the desired quaternion rotation to apply to the camera
  42752. */
  42753. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42754. /**
  42755. * Checks if the creation options are supported by the xr session
  42756. * @param options creation options
  42757. * @returns true if supported
  42758. */
  42759. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  42760. /**
  42761. * Disposes of the experience helper
  42762. */
  42763. dispose(): void;
  42764. }
  42765. }
  42766. declare module BABYLON {
  42767. /**
  42768. * Represents an XR input
  42769. */
  42770. class WebXRController {
  42771. /**
  42772. * 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
  42773. */
  42774. grip?: BABYLON.AbstractMesh;
  42775. /**
  42776. * Pointer which can be used to select objects or attach a visible laser to
  42777. */
  42778. pointer: BABYLON.AbstractMesh;
  42779. /**
  42780. * Creates the controller
  42781. * @see https://doc.babylonjs.com/how_to/webxr
  42782. * @param scene the scene which the controller should be associated to
  42783. */
  42784. constructor(scene: BABYLON.Scene);
  42785. /**
  42786. * Disposes of the object
  42787. */
  42788. dispose(): void;
  42789. }
  42790. /**
  42791. * XR input used to track XR inputs such as controllers/rays
  42792. */
  42793. class WebXRInput implements IDisposable {
  42794. private helper;
  42795. /**
  42796. * XR controllers being tracked
  42797. */
  42798. controllers: Array<WebXRController>;
  42799. private _tmpMatrix;
  42800. private _frameObserver;
  42801. /**
  42802. * Initializes the WebXRInput
  42803. * @param helper experience helper which the input should be created for
  42804. */
  42805. constructor(helper: WebXRExperienceHelper);
  42806. /**
  42807. * Disposes of the object
  42808. */
  42809. dispose(): void;
  42810. }
  42811. }
  42812. declare module BABYLON {
  42813. /**
  42814. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42815. */
  42816. class WebXRManagedOutputCanvas implements IDisposable {
  42817. private _canvas;
  42818. /**
  42819. * xrpresent context of the canvas which can be used to display/mirror xr content
  42820. */
  42821. canvasContext: Nullable<WebGLRenderingContext>;
  42822. /**
  42823. * Initializes the canvas to be added/removed upon entering/exiting xr
  42824. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42825. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42826. */
  42827. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42828. /**
  42829. * Disposes of the object
  42830. */
  42831. dispose(): void;
  42832. private _setManagedOutputCanvas;
  42833. private _addCanvas;
  42834. private _removeCanvas;
  42835. }
  42836. }
  42837. declare module BABYLON {
  42838. /**
  42839. * Manages an XRSession
  42840. * @see https://doc.babylonjs.com/how_to/webxr
  42841. */
  42842. class WebXRSessionManager implements IDisposable {
  42843. private scene;
  42844. /**
  42845. * Fires every time a new xrFrame arrives which can be used to update the camera
  42846. */
  42847. onXRFrameObservable: Observable<any>;
  42848. /**
  42849. * Fires when the xr session is ended either by the device or manually done
  42850. */
  42851. onXRSessionEnded: Observable<any>;
  42852. /** @hidden */
  42853. _xrSession: XRSession;
  42854. /** @hidden */
  42855. _frameOfReference: XRFrameOfReference;
  42856. /** @hidden */
  42857. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42858. /** @hidden */
  42859. _currentXRFrame: Nullable<XRFrame>;
  42860. private _xrNavigator;
  42861. private _xrDevice;
  42862. private _tmpMatrix;
  42863. /**
  42864. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42865. * @param scene The scene which the session should be created for
  42866. */
  42867. constructor(scene: BABYLON.Scene);
  42868. /**
  42869. * Initializes the manager
  42870. * After initialization enterXR can be called to start an XR session
  42871. * @returns Promise which resolves after it is initialized
  42872. */
  42873. initializeAsync(): Promise<void>;
  42874. /**
  42875. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  42876. * @param sessionCreationOptions xr options to create the session with
  42877. * @param frameOfReferenceType option to configure how the xr pose is expressed
  42878. * @returns Promise which resolves after it enters XR
  42879. */
  42880. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  42881. /**
  42882. * Stops the xrSession and restores the renderloop
  42883. * @returns Promise which resolves after it exits XR
  42884. */
  42885. exitXRAsync(): Promise<void>;
  42886. /**
  42887. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  42888. * @param ray ray to cast into the environment
  42889. * @returns Promise which resolves with a collision point in the environment if it exists
  42890. */
  42891. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  42892. /**
  42893. * Checks if a session would be supported for the creation options specified
  42894. * @param options creation options to check if they are supported
  42895. * @returns true if supported
  42896. */
  42897. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  42898. /**
  42899. * @hidden
  42900. * Converts the render layer of xrSession to a render target
  42901. * @param session session to create render target for
  42902. * @param scene scene the new render target should be created for
  42903. */
  42904. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  42905. /**
  42906. * Disposes of the session manager
  42907. */
  42908. dispose(): void;
  42909. }
  42910. }
  42911. declare module BABYLON {
  42912. /**
  42913. * Contains an array of blocks representing the octree
  42914. */
  42915. interface IOctreeContainer<T> {
  42916. /**
  42917. * Blocks within the octree
  42918. */
  42919. blocks: Array<OctreeBlock<T>>;
  42920. }
  42921. /**
  42922. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42923. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42924. */
  42925. class Octree<T> {
  42926. /** 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.) */
  42927. maxDepth: number;
  42928. /**
  42929. * Blocks within the octree containing objects
  42930. */
  42931. blocks: Array<OctreeBlock<T>>;
  42932. /**
  42933. * Content stored in the octree
  42934. */
  42935. dynamicContent: T[];
  42936. private _maxBlockCapacity;
  42937. private _selectionContent;
  42938. private _creationFunc;
  42939. /**
  42940. * Creates a octree
  42941. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42942. * @param creationFunc function to be used to instatiate the octree
  42943. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42944. * @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.)
  42945. */
  42946. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42947. /** 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.) */
  42948. maxDepth?: number);
  42949. /**
  42950. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42951. * @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);
  42952. * @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);
  42953. * @param entries meshes to be added to the octree blocks
  42954. */
  42955. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42956. /**
  42957. * Adds a mesh to the octree
  42958. * @param entry Mesh to add to the octree
  42959. */
  42960. addMesh(entry: T): void;
  42961. /**
  42962. * Selects an array of meshes within the frustum
  42963. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42964. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42965. * @returns array of meshes within the frustum
  42966. */
  42967. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42968. /**
  42969. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42970. * @param sphereCenter defines the bounding sphere center
  42971. * @param sphereRadius defines the bounding sphere radius
  42972. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42973. * @returns an array of objects that intersect the sphere
  42974. */
  42975. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42976. /**
  42977. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42978. * @param ray defines the ray to test with
  42979. * @returns array of intersected objects
  42980. */
  42981. intersectsRay(ray: Ray): SmartArray<T>;
  42982. /**
  42983. * @hidden
  42984. */
  42985. 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;
  42986. /**
  42987. * Adds a mesh into the octree block if it intersects the block
  42988. */
  42989. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42990. /**
  42991. * Adds a submesh into the octree block if it intersects the block
  42992. */
  42993. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42994. }
  42995. }
  42996. declare module BABYLON {
  42997. /**
  42998. * Class used to store a cell in an octree
  42999. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43000. */
  43001. class OctreeBlock<T> {
  43002. /**
  43003. * Gets the content of the current block
  43004. */
  43005. entries: T[];
  43006. /**
  43007. * Gets the list of block children
  43008. */
  43009. blocks: Array<OctreeBlock<T>>;
  43010. private _depth;
  43011. private _maxDepth;
  43012. private _capacity;
  43013. private _minPoint;
  43014. private _maxPoint;
  43015. private _boundingVectors;
  43016. private _creationFunc;
  43017. /**
  43018. * Creates a new block
  43019. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43020. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43021. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43022. * @param depth defines the current depth of this block in the octree
  43023. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43024. * @param creationFunc defines a callback to call when an element is added to the block
  43025. */
  43026. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43027. /**
  43028. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43029. */
  43030. readonly capacity: number;
  43031. /**
  43032. * Gets the minimum vector (in world space) of the block's bounding box
  43033. */
  43034. readonly minPoint: Vector3;
  43035. /**
  43036. * Gets the maximum vector (in world space) of the block's bounding box
  43037. */
  43038. readonly maxPoint: Vector3;
  43039. /**
  43040. * Add a new element to this block
  43041. * @param entry defines the element to add
  43042. */
  43043. addEntry(entry: T): void;
  43044. /**
  43045. * Add an array of elements to this block
  43046. * @param entries defines the array of elements to add
  43047. */
  43048. addEntries(entries: T[]): void;
  43049. /**
  43050. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43051. * @param frustumPlanes defines the frustum planes to test
  43052. * @param selection defines the array to store current content if selection is positive
  43053. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43054. */
  43055. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43056. /**
  43057. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43058. * @param sphereCenter defines the bounding sphere center
  43059. * @param sphereRadius defines the bounding sphere radius
  43060. * @param selection defines the array to store current content if selection is positive
  43061. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43062. */
  43063. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43064. /**
  43065. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43066. * @param ray defines the ray to test with
  43067. * @param selection defines the array to store current content if selection is positive
  43068. */
  43069. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43070. /**
  43071. * Subdivide the content into child blocks (this block will then be empty)
  43072. */
  43073. createInnerBlocks(): void;
  43074. }
  43075. }
  43076. declare module BABYLON {
  43077. interface Scene {
  43078. /**
  43079. * @hidden
  43080. * Backing Filed
  43081. */
  43082. _selectionOctree: Octree<AbstractMesh>;
  43083. /**
  43084. * Gets the octree used to boost mesh selection (picking)
  43085. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43086. */
  43087. selectionOctree: Octree<AbstractMesh>;
  43088. /**
  43089. * Creates or updates the octree used to boost selection (picking)
  43090. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43091. * @param maxCapacity defines the maximum capacity per leaf
  43092. * @param maxDepth defines the maximum depth of the octree
  43093. * @returns an octree of AbstractMesh
  43094. */
  43095. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43096. }
  43097. interface AbstractMesh {
  43098. /**
  43099. * @hidden
  43100. * Backing Field
  43101. */
  43102. _submeshesOctree: Octree<SubMesh>;
  43103. /**
  43104. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43105. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43106. * @param maxCapacity defines the maximum size of each block (64 by default)
  43107. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43108. * @returns the new octree
  43109. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43110. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43111. */
  43112. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43113. }
  43114. /**
  43115. * Defines the octree scene component responsible to manage any octrees
  43116. * in a given scene.
  43117. */
  43118. class OctreeSceneComponent {
  43119. /**
  43120. * The component name helpfull to identify the component in the list of scene components.
  43121. */
  43122. readonly name: string;
  43123. /**
  43124. * The scene the component belongs to.
  43125. */
  43126. scene: Scene;
  43127. /**
  43128. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43129. */
  43130. readonly checksIsEnabled: boolean;
  43131. /**
  43132. * Creates a new instance of the component for the given scene
  43133. * @param scene Defines the scene to register the component in
  43134. */
  43135. constructor(scene: Scene);
  43136. /**
  43137. * Registers the component in a given scene
  43138. */
  43139. register(): void;
  43140. /**
  43141. * Return the list of active meshes
  43142. * @returns the list of active meshes
  43143. */
  43144. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43145. /**
  43146. * Return the list of active sub meshes
  43147. * @param mesh The mesh to get the candidates sub meshes from
  43148. * @returns the list of active sub meshes
  43149. */
  43150. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43151. private _tempRay;
  43152. /**
  43153. * Return the list of sub meshes intersecting with a given local ray
  43154. * @param mesh defines the mesh to find the submesh for
  43155. * @param localRay defines the ray in local space
  43156. * @returns the list of intersecting sub meshes
  43157. */
  43158. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43159. /**
  43160. * Return the list of sub meshes colliding with a collider
  43161. * @param mesh defines the mesh to find the submesh for
  43162. * @param collider defines the collider to evaluate the collision against
  43163. * @returns the list of colliding sub meshes
  43164. */
  43165. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43166. /**
  43167. * Rebuilds the elements related to this component in case of
  43168. * context lost for instance.
  43169. */
  43170. rebuild(): void;
  43171. /**
  43172. * Disposes the component and the associated ressources.
  43173. */
  43174. dispose(): void;
  43175. }
  43176. }
  43177. declare module BABYLON {
  43178. /** @hidden */
  43179. class _OcclusionDataStorage {
  43180. /** @hidden */
  43181. occlusionInternalRetryCounter: number;
  43182. /** @hidden */
  43183. isOcclusionQueryInProgress: boolean;
  43184. /** @hidden */
  43185. isOccluded: boolean;
  43186. /** @hidden */
  43187. occlusionRetryCount: number;
  43188. /** @hidden */
  43189. occlusionType: number;
  43190. /** @hidden */
  43191. occlusionQueryAlgorithmType: number;
  43192. }
  43193. interface Engine {
  43194. /**
  43195. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43196. * @return the new query
  43197. */
  43198. createQuery(): WebGLQuery;
  43199. /**
  43200. * Delete and release a webGL query
  43201. * @param query defines the query to delete
  43202. * @return the current engine
  43203. */
  43204. deleteQuery(query: WebGLQuery): Engine;
  43205. /**
  43206. * Check if a given query has resolved and got its value
  43207. * @param query defines the query to check
  43208. * @returns true if the query got its value
  43209. */
  43210. isQueryResultAvailable(query: WebGLQuery): boolean;
  43211. /**
  43212. * Gets the value of a given query
  43213. * @param query defines the query to check
  43214. * @returns the value of the query
  43215. */
  43216. getQueryResult(query: WebGLQuery): number;
  43217. /**
  43218. * Initiates an occlusion query
  43219. * @param algorithmType defines the algorithm to use
  43220. * @param query defines the query to use
  43221. * @returns the current engine
  43222. * @see http://doc.babylonjs.com/features/occlusionquery
  43223. */
  43224. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43225. /**
  43226. * Ends an occlusion query
  43227. * @see http://doc.babylonjs.com/features/occlusionquery
  43228. * @param algorithmType defines the algorithm to use
  43229. * @returns the current engine
  43230. */
  43231. endOcclusionQuery(algorithmType: number): Engine;
  43232. /**
  43233. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43234. * Please note that only one query can be issued at a time
  43235. * @returns a time token used to track the time span
  43236. */
  43237. startTimeQuery(): Nullable<_TimeToken>;
  43238. /**
  43239. * Ends a time query
  43240. * @param token defines the token used to measure the time span
  43241. * @returns the time spent (in ns)
  43242. */
  43243. endTimeQuery(token: _TimeToken): int;
  43244. /** @hidden */
  43245. _currentNonTimestampToken: Nullable<_TimeToken>;
  43246. /** @hidden */
  43247. _createTimeQuery(): WebGLQuery;
  43248. /** @hidden */
  43249. _deleteTimeQuery(query: WebGLQuery): void;
  43250. /** @hidden */
  43251. _getGlAlgorithmType(algorithmType: number): number;
  43252. /** @hidden */
  43253. _getTimeQueryResult(query: WebGLQuery): any;
  43254. /** @hidden */
  43255. _getTimeQueryAvailability(query: WebGLQuery): any;
  43256. }
  43257. interface AbstractMesh {
  43258. /**
  43259. * Backing filed
  43260. * @hidden
  43261. */
  43262. __occlusionDataStorage: _OcclusionDataStorage;
  43263. /**
  43264. * Access property
  43265. * @hidden
  43266. */
  43267. _occlusionDataStorage: _OcclusionDataStorage;
  43268. /**
  43269. * 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.
  43270. * The default value is -1 which means don't break the query and wait till the result
  43271. * @see http://doc.babylonjs.com/features/occlusionquery
  43272. */
  43273. occlusionRetryCount: number;
  43274. /**
  43275. * 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:
  43276. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43277. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43278. * * 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.
  43279. * @see http://doc.babylonjs.com/features/occlusionquery
  43280. */
  43281. occlusionType: number;
  43282. /**
  43283. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43284. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43285. * * 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.
  43286. * @see http://doc.babylonjs.com/features/occlusionquery
  43287. */
  43288. occlusionQueryAlgorithmType: number;
  43289. /**
  43290. * 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
  43291. * @see http://doc.babylonjs.com/features/occlusionquery
  43292. */
  43293. isOccluded: boolean;
  43294. /**
  43295. * Flag to check the progress status of the query
  43296. * @see http://doc.babylonjs.com/features/occlusionquery
  43297. */
  43298. isOcclusionQueryInProgress: boolean;
  43299. }
  43300. }
  43301. declare module BABYLON {
  43302. interface Engine {
  43303. /**
  43304. * Creates a webGL transform feedback object
  43305. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43306. * @returns the webGL transform feedback object
  43307. */
  43308. createTransformFeedback(): WebGLTransformFeedback;
  43309. /**
  43310. * Delete a webGL transform feedback object
  43311. * @param value defines the webGL transform feedback object to delete
  43312. */
  43313. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43314. /**
  43315. * Bind a webGL transform feedback object to the webgl context
  43316. * @param value defines the webGL transform feedback object to bind
  43317. */
  43318. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43319. /**
  43320. * Begins a transform feedback operation
  43321. * @param usePoints defines if points or triangles must be used
  43322. */
  43323. beginTransformFeedback(usePoints: boolean): void;
  43324. /**
  43325. * Ends a transform feedback operation
  43326. */
  43327. endTransformFeedback(): void;
  43328. /**
  43329. * Specify the varyings to use with transform feedback
  43330. * @param program defines the associated webGL program
  43331. * @param value defines the list of strings representing the varying names
  43332. */
  43333. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43334. /**
  43335. * Bind a webGL buffer for a transform feedback operation
  43336. * @param value defines the webGL buffer to bind
  43337. */
  43338. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43339. }
  43340. }
  43341. declare module BABYLON {
  43342. /**
  43343. * Google Daydream controller
  43344. */
  43345. class DaydreamController extends WebVRController {
  43346. /**
  43347. * Base Url for the controller model.
  43348. */
  43349. static MODEL_BASE_URL: string;
  43350. /**
  43351. * File name for the controller model.
  43352. */
  43353. static MODEL_FILENAME: string;
  43354. /**
  43355. * Gamepad Id prefix used to identify Daydream Controller.
  43356. */
  43357. static readonly GAMEPAD_ID_PREFIX: string;
  43358. /**
  43359. * Creates a new DaydreamController from a gamepad
  43360. * @param vrGamepad the gamepad that the controller should be created from
  43361. */
  43362. constructor(vrGamepad: any);
  43363. /**
  43364. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43365. * @param scene scene in which to add meshes
  43366. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43367. */
  43368. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43369. /**
  43370. * Called once for each button that changed state since the last frame
  43371. * @param buttonIdx Which button index changed
  43372. * @param state New state of the button
  43373. * @param changes Which properties on the state changed since last frame
  43374. */
  43375. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43376. }
  43377. }
  43378. declare module BABYLON {
  43379. /**
  43380. * Gear VR Controller
  43381. */
  43382. class GearVRController extends WebVRController {
  43383. /**
  43384. * Base Url for the controller model.
  43385. */
  43386. static MODEL_BASE_URL: string;
  43387. /**
  43388. * File name for the controller model.
  43389. */
  43390. static MODEL_FILENAME: string;
  43391. /**
  43392. * Gamepad Id prefix used to identify this controller.
  43393. */
  43394. static readonly GAMEPAD_ID_PREFIX: string;
  43395. private readonly _buttonIndexToObservableNameMap;
  43396. /**
  43397. * Creates a new GearVRController from a gamepad
  43398. * @param vrGamepad the gamepad that the controller should be created from
  43399. */
  43400. constructor(vrGamepad: any);
  43401. /**
  43402. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43403. * @param scene scene in which to add meshes
  43404. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43405. */
  43406. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43407. /**
  43408. * Called once for each button that changed state since the last frame
  43409. * @param buttonIdx Which button index changed
  43410. * @param state New state of the button
  43411. * @param changes Which properties on the state changed since last frame
  43412. */
  43413. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43414. }
  43415. }
  43416. declare module BABYLON {
  43417. /**
  43418. * Generic Controller
  43419. */
  43420. class GenericController extends WebVRController {
  43421. /**
  43422. * Base Url for the controller model.
  43423. */
  43424. static readonly MODEL_BASE_URL: string;
  43425. /**
  43426. * File name for the controller model.
  43427. */
  43428. static readonly MODEL_FILENAME: string;
  43429. /**
  43430. * Creates a new GenericController from a gamepad
  43431. * @param vrGamepad the gamepad that the controller should be created from
  43432. */
  43433. constructor(vrGamepad: any);
  43434. /**
  43435. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43436. * @param scene scene in which to add meshes
  43437. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43438. */
  43439. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43440. /**
  43441. * Called once for each button that changed state since the last frame
  43442. * @param buttonIdx Which button index changed
  43443. * @param state New state of the button
  43444. * @param changes Which properties on the state changed since last frame
  43445. */
  43446. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43447. }
  43448. }
  43449. declare module BABYLON {
  43450. /**
  43451. * Oculus Touch Controller
  43452. */
  43453. class OculusTouchController extends WebVRController {
  43454. /**
  43455. * Base Url for the controller model.
  43456. */
  43457. static MODEL_BASE_URL: string;
  43458. /**
  43459. * File name for the left controller model.
  43460. */
  43461. static MODEL_LEFT_FILENAME: string;
  43462. /**
  43463. * File name for the right controller model.
  43464. */
  43465. static MODEL_RIGHT_FILENAME: string;
  43466. /**
  43467. * Fired when the secondary trigger on this controller is modified
  43468. */
  43469. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43470. /**
  43471. * Fired when the thumb rest on this controller is modified
  43472. */
  43473. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43474. /**
  43475. * Creates a new OculusTouchController from a gamepad
  43476. * @param vrGamepad the gamepad that the controller should be created from
  43477. */
  43478. constructor(vrGamepad: any);
  43479. /**
  43480. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43481. * @param scene scene in which to add meshes
  43482. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43483. */
  43484. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43485. /**
  43486. * Fired when the A button on this controller is modified
  43487. */
  43488. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43489. /**
  43490. * Fired when the B button on this controller is modified
  43491. */
  43492. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43493. /**
  43494. * Fired when the X button on this controller is modified
  43495. */
  43496. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43497. /**
  43498. * Fired when the Y button on this controller is modified
  43499. */
  43500. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43501. /**
  43502. * Called once for each button that changed state since the last frame
  43503. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43504. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43505. * 2) secondary trigger (same)
  43506. * 3) A (right) X (left), touch, pressed = value
  43507. * 4) B / Y
  43508. * 5) thumb rest
  43509. * @param buttonIdx Which button index changed
  43510. * @param state New state of the button
  43511. * @param changes Which properties on the state changed since last frame
  43512. */
  43513. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43514. }
  43515. }
  43516. declare module BABYLON {
  43517. /**
  43518. * Defines the types of pose enabled controllers that are supported
  43519. */
  43520. enum PoseEnabledControllerType {
  43521. /**
  43522. * HTC Vive
  43523. */
  43524. VIVE = 0,
  43525. /**
  43526. * Oculus Rift
  43527. */
  43528. OCULUS = 1,
  43529. /**
  43530. * Windows mixed reality
  43531. */
  43532. WINDOWS = 2,
  43533. /**
  43534. * Samsung gear VR
  43535. */
  43536. GEAR_VR = 3,
  43537. /**
  43538. * Google Daydream
  43539. */
  43540. DAYDREAM = 4,
  43541. /**
  43542. * Generic
  43543. */
  43544. GENERIC = 5
  43545. }
  43546. /**
  43547. * Defines the MutableGamepadButton interface for the state of a gamepad button
  43548. */
  43549. interface MutableGamepadButton {
  43550. /**
  43551. * Value of the button/trigger
  43552. */
  43553. value: number;
  43554. /**
  43555. * If the button/trigger is currently touched
  43556. */
  43557. touched: boolean;
  43558. /**
  43559. * If the button/trigger is currently pressed
  43560. */
  43561. pressed: boolean;
  43562. }
  43563. /**
  43564. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  43565. * @hidden
  43566. */
  43567. interface ExtendedGamepadButton extends GamepadButton {
  43568. /**
  43569. * If the button/trigger is currently pressed
  43570. */
  43571. readonly pressed: boolean;
  43572. /**
  43573. * If the button/trigger is currently touched
  43574. */
  43575. readonly touched: boolean;
  43576. /**
  43577. * Value of the button/trigger
  43578. */
  43579. readonly value: number;
  43580. }
  43581. /**
  43582. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43583. */
  43584. class PoseEnabledControllerHelper {
  43585. /**
  43586. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43587. * @param vrGamepad the gamepad to initialized
  43588. * @returns a vr controller of the type the gamepad identified as
  43589. */
  43590. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  43591. }
  43592. /**
  43593. * Defines the PoseEnabledController object that contains state of a vr capable controller
  43594. */
  43595. class PoseEnabledController extends Gamepad implements PoseControlled {
  43596. private _deviceRoomPosition;
  43597. private _deviceRoomRotationQuaternion;
  43598. /**
  43599. * The device position in babylon space
  43600. */
  43601. devicePosition: Vector3;
  43602. /**
  43603. * The device rotation in babylon space
  43604. */
  43605. deviceRotationQuaternion: Quaternion;
  43606. /**
  43607. * The scale factor of the device in babylon space
  43608. */
  43609. deviceScaleFactor: number;
  43610. /**
  43611. * (Likely devicePosition should be used instead) The device position in its room space
  43612. */
  43613. position: Vector3;
  43614. /**
  43615. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  43616. */
  43617. rotationQuaternion: Quaternion;
  43618. /**
  43619. * The type of controller (Eg. Windows mixed reality)
  43620. */
  43621. controllerType: PoseEnabledControllerType;
  43622. protected _calculatedPosition: Vector3;
  43623. private _calculatedRotation;
  43624. /**
  43625. * The raw pose from the device
  43626. */
  43627. rawPose: DevicePose;
  43628. private _trackPosition;
  43629. private _maxRotationDistFromHeadset;
  43630. private _draggedRoomRotation;
  43631. /**
  43632. * @hidden
  43633. */
  43634. _disableTrackPosition(fixedPosition: Vector3): void;
  43635. /**
  43636. * Internal, the mesh attached to the controller
  43637. * @hidden
  43638. */
  43639. _mesh: Nullable<AbstractMesh>;
  43640. private _poseControlledCamera;
  43641. private _leftHandSystemQuaternion;
  43642. /**
  43643. * Internal, matrix used to convert room space to babylon space
  43644. * @hidden
  43645. */
  43646. _deviceToWorld: Matrix;
  43647. /**
  43648. * Node to be used when casting a ray from the controller
  43649. * @hidden
  43650. */
  43651. _pointingPoseNode: Nullable<AbstractMesh>;
  43652. /**
  43653. * Name of the child mesh that can be used to cast a ray from the controller
  43654. */
  43655. static readonly POINTING_POSE: string;
  43656. /**
  43657. * Creates a new PoseEnabledController from a gamepad
  43658. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  43659. */
  43660. constructor(browserGamepad: any);
  43661. private _workingMatrix;
  43662. /**
  43663. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  43664. */
  43665. update(): void;
  43666. /**
  43667. * Updates only the pose device and mesh without doing any button event checking
  43668. */
  43669. protected _updatePoseAndMesh(): void;
  43670. /**
  43671. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  43672. * @param poseData raw pose fromthe device
  43673. */
  43674. updateFromDevice(poseData: DevicePose): void;
  43675. /**
  43676. * @hidden
  43677. */
  43678. _meshAttachedObservable: Observable<AbstractMesh>;
  43679. /**
  43680. * Attaches a mesh to the controller
  43681. * @param mesh the mesh to be attached
  43682. */
  43683. attachToMesh(mesh: AbstractMesh): void;
  43684. /**
  43685. * Attaches the controllers mesh to a camera
  43686. * @param camera the camera the mesh should be attached to
  43687. */
  43688. attachToPoseControlledCamera(camera: TargetCamera): void;
  43689. /**
  43690. * Disposes of the controller
  43691. */
  43692. dispose(): void;
  43693. /**
  43694. * The mesh that is attached to the controller
  43695. */
  43696. readonly mesh: Nullable<AbstractMesh>;
  43697. /**
  43698. * Gets the ray of the controller in the direction the controller is pointing
  43699. * @param length the length the resulting ray should be
  43700. * @returns a ray in the direction the controller is pointing
  43701. */
  43702. getForwardRay(length?: number): Ray;
  43703. }
  43704. }
  43705. declare module BABYLON {
  43706. /**
  43707. * Vive Controller
  43708. */
  43709. class ViveController extends WebVRController {
  43710. /**
  43711. * Base Url for the controller model.
  43712. */
  43713. static MODEL_BASE_URL: string;
  43714. /**
  43715. * File name for the controller model.
  43716. */
  43717. static MODEL_FILENAME: string;
  43718. /**
  43719. * Creates a new ViveController from a gamepad
  43720. * @param vrGamepad the gamepad that the controller should be created from
  43721. */
  43722. constructor(vrGamepad: any);
  43723. /**
  43724. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43725. * @param scene scene in which to add meshes
  43726. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43727. */
  43728. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43729. /**
  43730. * Fired when the left button on this controller is modified
  43731. */
  43732. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43733. /**
  43734. * Fired when the right button on this controller is modified
  43735. */
  43736. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43737. /**
  43738. * Fired when the menu button on this controller is modified
  43739. */
  43740. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43741. /**
  43742. * Called once for each button that changed state since the last frame
  43743. * Vive mapping:
  43744. * 0: touchpad
  43745. * 1: trigger
  43746. * 2: left AND right buttons
  43747. * 3: menu button
  43748. * @param buttonIdx Which button index changed
  43749. * @param state New state of the button
  43750. * @param changes Which properties on the state changed since last frame
  43751. */
  43752. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43753. }
  43754. }
  43755. declare module BABYLON {
  43756. /**
  43757. * Defines the WebVRController object that represents controllers tracked in 3D space
  43758. */
  43759. abstract class WebVRController extends PoseEnabledController {
  43760. /**
  43761. * Internal, the default controller model for the controller
  43762. */
  43763. protected _defaultModel: AbstractMesh;
  43764. /**
  43765. * Fired when the trigger state has changed
  43766. */
  43767. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43768. /**
  43769. * Fired when the main button state has changed
  43770. */
  43771. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43772. /**
  43773. * Fired when the secondary button state has changed
  43774. */
  43775. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43776. /**
  43777. * Fired when the pad state has changed
  43778. */
  43779. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  43780. /**
  43781. * Fired when controllers stick values have changed
  43782. */
  43783. onPadValuesChangedObservable: Observable<StickValues>;
  43784. /**
  43785. * Array of button availible on the controller
  43786. */
  43787. protected _buttons: Array<MutableGamepadButton>;
  43788. private _onButtonStateChange;
  43789. /**
  43790. * Fired when a controller button's state has changed
  43791. * @param callback the callback containing the button that was modified
  43792. */
  43793. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  43794. /**
  43795. * X and Y axis corrisponding to the controllers joystick
  43796. */
  43797. pad: StickValues;
  43798. /**
  43799. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  43800. */
  43801. hand: string;
  43802. /**
  43803. * The default controller model for the controller
  43804. */
  43805. readonly defaultModel: AbstractMesh;
  43806. /**
  43807. * Creates a new WebVRController from a gamepad
  43808. * @param vrGamepad the gamepad that the WebVRController should be created from
  43809. */
  43810. constructor(vrGamepad: any);
  43811. /**
  43812. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  43813. */
  43814. update(): void;
  43815. /**
  43816. * Function to be called when a button is modified
  43817. */
  43818. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43819. /**
  43820. * Loads a mesh and attaches it to the controller
  43821. * @param scene the scene the mesh should be added to
  43822. * @param meshLoaded callback for when the mesh has been loaded
  43823. */
  43824. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43825. private _setButtonValue;
  43826. private _changes;
  43827. private _checkChanges;
  43828. /**
  43829. * Disposes of th webVRCOntroller
  43830. */
  43831. dispose(): void;
  43832. }
  43833. }
  43834. declare module BABYLON {
  43835. /**
  43836. * Defines the WindowsMotionController object that the state of the windows motion controller
  43837. */
  43838. class WindowsMotionController extends WebVRController {
  43839. /**
  43840. * The base url used to load the left and right controller models
  43841. */
  43842. static MODEL_BASE_URL: string;
  43843. /**
  43844. * The name of the left controller model file
  43845. */
  43846. static MODEL_LEFT_FILENAME: string;
  43847. /**
  43848. * The name of the right controller model file
  43849. */
  43850. static MODEL_RIGHT_FILENAME: string;
  43851. /**
  43852. * The controller name prefix for this controller type
  43853. */
  43854. static readonly GAMEPAD_ID_PREFIX: string;
  43855. /**
  43856. * The controller id pattern for this controller type
  43857. */
  43858. private static readonly GAMEPAD_ID_PATTERN;
  43859. private _loadedMeshInfo;
  43860. private readonly _mapping;
  43861. /**
  43862. * Fired when the trackpad on this controller is clicked
  43863. */
  43864. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43865. /**
  43866. * Fired when the trackpad on this controller is modified
  43867. */
  43868. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43869. /**
  43870. * The current x and y values of this controller's trackpad
  43871. */
  43872. trackpad: StickValues;
  43873. /**
  43874. * Creates a new WindowsMotionController from a gamepad
  43875. * @param vrGamepad the gamepad that the controller should be created from
  43876. */
  43877. constructor(vrGamepad: any);
  43878. /**
  43879. * Fired when the trigger on this controller is modified
  43880. */
  43881. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43882. /**
  43883. * Fired when the menu button on this controller is modified
  43884. */
  43885. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43886. /**
  43887. * Fired when the grip button on this controller is modified
  43888. */
  43889. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43890. /**
  43891. * Fired when the thumbstick button on this controller is modified
  43892. */
  43893. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43894. /**
  43895. * Fired when the touchpad button on this controller is modified
  43896. */
  43897. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43898. /**
  43899. * Fired when the touchpad values on this controller are modified
  43900. */
  43901. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43902. private _updateTrackpad;
  43903. /**
  43904. * Called once per frame by the engine.
  43905. */
  43906. update(): void;
  43907. /**
  43908. * Called once for each button that changed state since the last frame
  43909. * @param buttonIdx Which button index changed
  43910. * @param state New state of the button
  43911. * @param changes Which properties on the state changed since last frame
  43912. */
  43913. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43914. /**
  43915. * Moves the buttons on the controller mesh based on their current state
  43916. * @param buttonName the name of the button to move
  43917. * @param buttonValue the value of the button which determines the buttons new position
  43918. */
  43919. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43920. /**
  43921. * Moves the axis on the controller mesh based on its current state
  43922. * @param axis the index of the axis
  43923. * @param axisValue the value of the axis which determines the meshes new position
  43924. * @hidden
  43925. */
  43926. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43927. /**
  43928. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43929. * @param scene scene in which to add meshes
  43930. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43931. */
  43932. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43933. /**
  43934. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43935. * can be transformed by button presses and axes values, based on this._mapping.
  43936. *
  43937. * @param scene scene in which the meshes exist
  43938. * @param meshes list of meshes that make up the controller model to process
  43939. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43940. */
  43941. private processModel;
  43942. private createMeshInfo;
  43943. /**
  43944. * Gets the ray of the controller in the direction the controller is pointing
  43945. * @param length the length the resulting ray should be
  43946. * @returns a ray in the direction the controller is pointing
  43947. */
  43948. getForwardRay(length?: number): Ray;
  43949. /**
  43950. * Disposes of the controller
  43951. */
  43952. dispose(): void;
  43953. }
  43954. }
  43955. declare module BABYLON {
  43956. /**
  43957. * Interface to implement to create a shadow generator compatible with BJS.
  43958. */
  43959. interface IShadowGenerator {
  43960. /**
  43961. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  43962. * @returns The render target texture if present otherwise, null
  43963. */
  43964. getShadowMap(): Nullable<RenderTargetTexture>;
  43965. /**
  43966. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  43967. * @returns The render target texture if the shadow map is present otherwise, null
  43968. */
  43969. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  43970. /**
  43971. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  43972. * @param subMesh The submesh we want to render in the shadow map
  43973. * @param useInstances Defines wether will draw in the map using instances
  43974. * @returns true if ready otherwise, false
  43975. */
  43976. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43977. /**
  43978. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  43979. * @param defines Defines of the material we want to update
  43980. * @param lightIndex Index of the light in the enabled light list of the material
  43981. */
  43982. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  43983. /**
  43984. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  43985. * defined in the generator but impacting the effect).
  43986. * It implies the unifroms available on the materials are the standard BJS ones.
  43987. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  43988. * @param effect The effect we are binfing the information for
  43989. */
  43990. bindShadowLight(lightIndex: string, effect: Effect): void;
  43991. /**
  43992. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  43993. * (eq to shadow prjection matrix * light transform matrix)
  43994. * @returns The transform matrix used to create the shadow map
  43995. */
  43996. getTransformMatrix(): Matrix;
  43997. /**
  43998. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  43999. * Cube and 2D textures for instance.
  44000. */
  44001. recreateShadowMap(): void;
  44002. /**
  44003. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44004. * @param onCompiled Callback triggered at the and of the effects compilation
  44005. * @param options Sets of optional options forcing the compilation with different modes
  44006. */
  44007. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44008. useInstances: boolean;
  44009. }>): void;
  44010. /**
  44011. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44012. * @param options Sets of optional options forcing the compilation with different modes
  44013. * @returns A promise that resolves when the compilation completes
  44014. */
  44015. forceCompilationAsync(options?: Partial<{
  44016. useInstances: boolean;
  44017. }>): Promise<void>;
  44018. /**
  44019. * Serializes the shadow generator setup to a json object.
  44020. * @returns The serialized JSON object
  44021. */
  44022. serialize(): any;
  44023. /**
  44024. * Disposes the Shadow map and related Textures and effects.
  44025. */
  44026. dispose(): void;
  44027. }
  44028. /**
  44029. * Default implementation IShadowGenerator.
  44030. * This is the main object responsible of generating shadows in the framework.
  44031. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44032. */
  44033. class ShadowGenerator implements IShadowGenerator {
  44034. /**
  44035. * Shadow generator mode None: no filtering applied.
  44036. */
  44037. static readonly FILTER_NONE: number;
  44038. /**
  44039. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44040. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44041. */
  44042. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  44043. /**
  44044. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44045. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44046. */
  44047. static readonly FILTER_POISSONSAMPLING: number;
  44048. /**
  44049. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44050. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44051. */
  44052. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  44053. /**
  44054. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44055. * edge artifacts on steep falloff.
  44056. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44057. */
  44058. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  44059. /**
  44060. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44061. * edge artifacts on steep falloff.
  44062. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44063. */
  44064. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  44065. /**
  44066. * Shadow generator mode PCF: Percentage Closer Filtering
  44067. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44068. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44069. */
  44070. static readonly FILTER_PCF: number;
  44071. /**
  44072. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44073. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44074. * Contact Hardening
  44075. */
  44076. static readonly FILTER_PCSS: number;
  44077. /**
  44078. * Reserved for PCF and PCSS
  44079. * Highest Quality.
  44080. *
  44081. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44082. *
  44083. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44084. */
  44085. static readonly QUALITY_HIGH: number;
  44086. /**
  44087. * Reserved for PCF and PCSS
  44088. * Good tradeoff for quality/perf cross devices
  44089. *
  44090. * Execute PCF on a 3*3 kernel.
  44091. *
  44092. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44093. */
  44094. static readonly QUALITY_MEDIUM: number;
  44095. /**
  44096. * Reserved for PCF and PCSS
  44097. * The lowest quality but the fastest.
  44098. *
  44099. * Execute PCF on a 1*1 kernel.
  44100. *
  44101. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44102. */
  44103. static readonly QUALITY_LOW: number;
  44104. private _bias;
  44105. /**
  44106. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44107. */
  44108. /**
  44109. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44110. */
  44111. bias: number;
  44112. private _normalBias;
  44113. /**
  44114. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44115. */
  44116. /**
  44117. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44118. */
  44119. normalBias: number;
  44120. private _blurBoxOffset;
  44121. /**
  44122. * Gets the blur box offset: offset applied during the blur pass.
  44123. * Only usefull if useKernelBlur = false
  44124. */
  44125. /**
  44126. * Sets the blur box offset: offset applied during the blur pass.
  44127. * Only usefull if useKernelBlur = false
  44128. */
  44129. blurBoxOffset: number;
  44130. private _blurScale;
  44131. /**
  44132. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44133. * 2 means half of the size.
  44134. */
  44135. /**
  44136. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44137. * 2 means half of the size.
  44138. */
  44139. blurScale: number;
  44140. private _blurKernel;
  44141. /**
  44142. * Gets the blur kernel: kernel size of the blur pass.
  44143. * Only usefull if useKernelBlur = true
  44144. */
  44145. /**
  44146. * Sets the blur kernel: kernel size of the blur pass.
  44147. * Only usefull if useKernelBlur = true
  44148. */
  44149. blurKernel: number;
  44150. private _useKernelBlur;
  44151. /**
  44152. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44153. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  44154. */
  44155. /**
  44156. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44157. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  44158. */
  44159. useKernelBlur: boolean;
  44160. private _depthScale;
  44161. /**
  44162. * Gets the depth scale used in ESM mode.
  44163. */
  44164. /**
  44165. * Sets the depth scale used in ESM mode.
  44166. * This can override the scale stored on the light.
  44167. */
  44168. depthScale: number;
  44169. private _filter;
  44170. /**
  44171. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44172. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44173. */
  44174. /**
  44175. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44176. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44177. */
  44178. filter: number;
  44179. /**
  44180. * Gets if the current filter is set to Poisson Sampling.
  44181. */
  44182. /**
  44183. * Sets the current filter to Poisson Sampling.
  44184. */
  44185. usePoissonSampling: boolean;
  44186. /**
  44187. * Gets if the current filter is set to ESM.
  44188. */
  44189. /**
  44190. * Sets the current filter is to ESM.
  44191. */
  44192. useExponentialShadowMap: boolean;
  44193. /**
  44194. * Gets if the current filter is set to filtered ESM.
  44195. */
  44196. /**
  44197. * Gets if the current filter is set to filtered ESM.
  44198. */
  44199. useBlurExponentialShadowMap: boolean;
  44200. /**
  44201. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44202. * exponential to prevent steep falloff artifacts).
  44203. */
  44204. /**
  44205. * Sets the current filter to "close ESM" (using the inverse of the
  44206. * exponential to prevent steep falloff artifacts).
  44207. */
  44208. useCloseExponentialShadowMap: boolean;
  44209. /**
  44210. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44211. * exponential to prevent steep falloff artifacts).
  44212. */
  44213. /**
  44214. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44215. * exponential to prevent steep falloff artifacts).
  44216. */
  44217. useBlurCloseExponentialShadowMap: boolean;
  44218. /**
  44219. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44220. */
  44221. /**
  44222. * Sets the current filter to "PCF" (percentage closer filtering).
  44223. */
  44224. usePercentageCloserFiltering: boolean;
  44225. private _filteringQuality;
  44226. /**
  44227. * Gets the PCF or PCSS Quality.
  44228. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44229. */
  44230. /**
  44231. * Sets the PCF or PCSS Quality.
  44232. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44233. */
  44234. filteringQuality: number;
  44235. /**
  44236. * Gets if the current filter is set to "PCSS" (contact hardening).
  44237. */
  44238. /**
  44239. * Sets the current filter to "PCSS" (contact hardening).
  44240. */
  44241. useContactHardeningShadow: boolean;
  44242. private _contactHardeningLightSizeUVRatio;
  44243. /**
  44244. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44245. * Using a ratio helps keeping shape stability independently of the map size.
  44246. *
  44247. * It does not account for the light projection as it was having too much
  44248. * instability during the light setup or during light position changes.
  44249. *
  44250. * Only valid if useContactHardeningShadow is true.
  44251. */
  44252. /**
  44253. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44254. * Using a ratio helps keeping shape stability independently of the map size.
  44255. *
  44256. * It does not account for the light projection as it was having too much
  44257. * instability during the light setup or during light position changes.
  44258. *
  44259. * Only valid if useContactHardeningShadow is true.
  44260. */
  44261. contactHardeningLightSizeUVRatio: number;
  44262. private _darkness;
  44263. /**
  44264. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44265. * 0 means strongest and 1 would means no shadow.
  44266. * @returns the darkness.
  44267. */
  44268. getDarkness(): number;
  44269. /**
  44270. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44271. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44272. * @returns the shadow generator allowing fluent coding.
  44273. */
  44274. setDarkness(darkness: number): ShadowGenerator;
  44275. private _transparencyShadow;
  44276. /**
  44277. * Sets the ability to have transparent shadow (boolean).
  44278. * @param transparent True if transparent else False
  44279. * @returns the shadow generator allowing fluent coding
  44280. */
  44281. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44282. private _shadowMap;
  44283. private _shadowMap2;
  44284. /**
  44285. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44286. * @returns The render target texture if present otherwise, null
  44287. */
  44288. getShadowMap(): Nullable<RenderTargetTexture>;
  44289. /**
  44290. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44291. * @returns The render target texture if the shadow map is present otherwise, null
  44292. */
  44293. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44294. /**
  44295. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44296. * @param mesh Mesh to add
  44297. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44298. * @returns the Shadow Generator itself
  44299. */
  44300. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44301. /**
  44302. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44303. * @param mesh Mesh to remove
  44304. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44305. * @returns the Shadow Generator itself
  44306. */
  44307. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44308. /**
  44309. * Controls the extent to which the shadows fade out at the edge of the frustum
  44310. * Used only by directionals and spots
  44311. */
  44312. frustumEdgeFalloff: number;
  44313. private _light;
  44314. /**
  44315. * Returns the associated light object.
  44316. * @returns the light generating the shadow
  44317. */
  44318. getLight(): IShadowLight;
  44319. /**
  44320. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44321. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44322. * It might on the other hand introduce peter panning.
  44323. */
  44324. forceBackFacesOnly: boolean;
  44325. private _scene;
  44326. private _lightDirection;
  44327. private _effect;
  44328. private _viewMatrix;
  44329. private _projectionMatrix;
  44330. private _transformMatrix;
  44331. private _cachedPosition;
  44332. private _cachedDirection;
  44333. private _cachedDefines;
  44334. private _currentRenderID;
  44335. private _boxBlurPostprocess;
  44336. private _kernelBlurXPostprocess;
  44337. private _kernelBlurYPostprocess;
  44338. private _blurPostProcesses;
  44339. private _mapSize;
  44340. private _currentFaceIndex;
  44341. private _currentFaceIndexCache;
  44342. private _textureType;
  44343. private _defaultTextureMatrix;
  44344. /**
  44345. * Creates a ShadowGenerator object.
  44346. * A ShadowGenerator is the required tool to use the shadows.
  44347. * Each light casting shadows needs to use its own ShadowGenerator.
  44348. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  44349. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44350. * @param light The light object generating the shadows.
  44351. * @param useFullFloatFirst 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.
  44352. */
  44353. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  44354. private _initializeGenerator;
  44355. private _initializeShadowMap;
  44356. private _initializeBlurRTTAndPostProcesses;
  44357. private _renderForShadowMap;
  44358. private _renderSubMeshForShadowMap;
  44359. private _applyFilterValues;
  44360. /**
  44361. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44362. * @param onCompiled Callback triggered at the and of the effects compilation
  44363. * @param options Sets of optional options forcing the compilation with different modes
  44364. */
  44365. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44366. useInstances: boolean;
  44367. }>): void;
  44368. /**
  44369. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44370. * @param options Sets of optional options forcing the compilation with different modes
  44371. * @returns A promise that resolves when the compilation completes
  44372. */
  44373. forceCompilationAsync(options?: Partial<{
  44374. useInstances: boolean;
  44375. }>): Promise<void>;
  44376. /**
  44377. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44378. * @param subMesh The submesh we want to render in the shadow map
  44379. * @param useInstances Defines wether will draw in the map using instances
  44380. * @returns true if ready otherwise, false
  44381. */
  44382. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44383. /**
  44384. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44385. * @param defines Defines of the material we want to update
  44386. * @param lightIndex Index of the light in the enabled light list of the material
  44387. */
  44388. prepareDefines(defines: any, lightIndex: number): void;
  44389. /**
  44390. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44391. * defined in the generator but impacting the effect).
  44392. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44393. * @param effect The effect we are binfing the information for
  44394. */
  44395. bindShadowLight(lightIndex: string, effect: Effect): void;
  44396. /**
  44397. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44398. * (eq to shadow prjection matrix * light transform matrix)
  44399. * @returns The transform matrix used to create the shadow map
  44400. */
  44401. getTransformMatrix(): Matrix;
  44402. /**
  44403. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44404. * Cube and 2D textures for instance.
  44405. */
  44406. recreateShadowMap(): void;
  44407. private _disposeBlurPostProcesses;
  44408. private _disposeRTTandPostProcesses;
  44409. /**
  44410. * Disposes the ShadowGenerator.
  44411. * Returns nothing.
  44412. */
  44413. dispose(): void;
  44414. /**
  44415. * Serializes the shadow generator setup to a json object.
  44416. * @returns The serialized JSON object
  44417. */
  44418. serialize(): any;
  44419. /**
  44420. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44421. * @param parsedShadowGenerator The JSON object to parse
  44422. * @param scene The scene to create the shadow map for
  44423. * @returns The parsed shadow generator
  44424. */
  44425. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44426. }
  44427. }
  44428. declare module BABYLON {
  44429. /**
  44430. * Defines the shadow generator component responsible to manage any shadow generators
  44431. * in a given scene.
  44432. */
  44433. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44434. /**
  44435. * The component name helpfull to identify the component in the list of scene components.
  44436. */
  44437. readonly name: string;
  44438. /**
  44439. * The scene the component belongs to.
  44440. */
  44441. scene: Scene;
  44442. /**
  44443. * Creates a new instance of the component for the given scene
  44444. * @param scene Defines the scene to register the component in
  44445. */
  44446. constructor(scene: Scene);
  44447. /**
  44448. * Registers the component in a given scene
  44449. */
  44450. register(): void;
  44451. /**
  44452. * Rebuilds the elements related to this component in case of
  44453. * context lost for instance.
  44454. */
  44455. rebuild(): void;
  44456. /**
  44457. * Serializes the component data to the specified json object
  44458. * @param serializationObject The object to serialize to
  44459. */
  44460. serialize(serializationObject: any): void;
  44461. /**
  44462. * Adds all the element from the container to the scene
  44463. * @param container the container holding the elements
  44464. */
  44465. addFromContainer(container: AbstractScene): void;
  44466. /**
  44467. * Removes all the elements in the container from the scene
  44468. * @param container contains the elements to remove
  44469. */
  44470. removeFromContainer(container: AbstractScene): void;
  44471. /**
  44472. * Rebuilds the elements related to this component in case of
  44473. * context lost for instance.
  44474. */
  44475. dispose(): void;
  44476. private _gatherRenderTargets;
  44477. }
  44478. }
  44479. declare module BABYLON {
  44480. }
  44481. declare module BABYLON {
  44482. /**
  44483. * Background material used to create an efficient environement around your scene.
  44484. */
  44485. class BackgroundMaterial extends PushMaterial {
  44486. /**
  44487. * Standard reflectance value at parallel view angle.
  44488. */
  44489. static StandardReflectance0: number;
  44490. /**
  44491. * Standard reflectance value at grazing angle.
  44492. */
  44493. static StandardReflectance90: number;
  44494. protected _primaryColor: Color3;
  44495. /**
  44496. * Key light Color (multiply against the environement texture)
  44497. */
  44498. primaryColor: Color3;
  44499. protected __perceptualColor: Nullable<Color3>;
  44500. /**
  44501. * Experimental Internal Use Only.
  44502. *
  44503. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44504. * This acts as a helper to set the primary color to a more "human friendly" value.
  44505. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44506. * output color as close as possible from the chosen value.
  44507. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44508. * part of lighting setup.)
  44509. */
  44510. _perceptualColor: Nullable<Color3>;
  44511. protected _primaryColorShadowLevel: float;
  44512. /**
  44513. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44514. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44515. */
  44516. primaryColorShadowLevel: float;
  44517. protected _primaryColorHighlightLevel: float;
  44518. /**
  44519. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44520. * The primary color is used at the level chosen to define what the white area would look.
  44521. */
  44522. primaryColorHighlightLevel: float;
  44523. protected _reflectionTexture: Nullable<BaseTexture>;
  44524. /**
  44525. * Reflection Texture used in the material.
  44526. * Should be author in a specific way for the best result (refer to the documentation).
  44527. */
  44528. reflectionTexture: Nullable<BaseTexture>;
  44529. protected _reflectionBlur: float;
  44530. /**
  44531. * Reflection Texture level of blur.
  44532. *
  44533. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44534. * texture twice.
  44535. */
  44536. reflectionBlur: float;
  44537. protected _diffuseTexture: Nullable<BaseTexture>;
  44538. /**
  44539. * Diffuse Texture used in the material.
  44540. * Should be author in a specific way for the best result (refer to the documentation).
  44541. */
  44542. diffuseTexture: Nullable<BaseTexture>;
  44543. protected _shadowLights: Nullable<IShadowLight[]>;
  44544. /**
  44545. * Specify the list of lights casting shadow on the material.
  44546. * All scene shadow lights will be included if null.
  44547. */
  44548. shadowLights: Nullable<IShadowLight[]>;
  44549. protected _shadowLevel: float;
  44550. /**
  44551. * Helps adjusting the shadow to a softer level if required.
  44552. * 0 means black shadows and 1 means no shadows.
  44553. */
  44554. shadowLevel: float;
  44555. protected _sceneCenter: Vector3;
  44556. /**
  44557. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44558. * It is usually zero but might be interesting to modify according to your setup.
  44559. */
  44560. sceneCenter: Vector3;
  44561. protected _opacityFresnel: boolean;
  44562. /**
  44563. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44564. * This helps ensuring a nice transition when the camera goes under the ground.
  44565. */
  44566. opacityFresnel: boolean;
  44567. protected _reflectionFresnel: boolean;
  44568. /**
  44569. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44570. * This helps adding a mirror texture on the ground.
  44571. */
  44572. reflectionFresnel: boolean;
  44573. protected _reflectionFalloffDistance: number;
  44574. /**
  44575. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44576. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44577. */
  44578. reflectionFalloffDistance: number;
  44579. protected _reflectionAmount: number;
  44580. /**
  44581. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44582. */
  44583. reflectionAmount: number;
  44584. protected _reflectionReflectance0: number;
  44585. /**
  44586. * This specifies the weight of the reflection at grazing angle.
  44587. */
  44588. reflectionReflectance0: number;
  44589. protected _reflectionReflectance90: number;
  44590. /**
  44591. * This specifies the weight of the reflection at a perpendicular point of view.
  44592. */
  44593. reflectionReflectance90: number;
  44594. /**
  44595. * Sets the reflection reflectance fresnel values according to the default standard
  44596. * empirically know to work well :-)
  44597. */
  44598. reflectionStandardFresnelWeight: number;
  44599. protected _useRGBColor: boolean;
  44600. /**
  44601. * Helps to directly use the maps channels instead of their level.
  44602. */
  44603. useRGBColor: boolean;
  44604. protected _enableNoise: boolean;
  44605. /**
  44606. * This helps reducing the banding effect that could occur on the background.
  44607. */
  44608. enableNoise: boolean;
  44609. /**
  44610. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44611. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44612. * Recommended to be keep at 1.0 except for special cases.
  44613. */
  44614. fovMultiplier: number;
  44615. private _fovMultiplier;
  44616. /**
  44617. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44618. */
  44619. useEquirectangularFOV: boolean;
  44620. private _maxSimultaneousLights;
  44621. /**
  44622. * Number of Simultaneous lights allowed on the material.
  44623. */
  44624. maxSimultaneousLights: int;
  44625. /**
  44626. * Default configuration related to image processing available in the Background Material.
  44627. */
  44628. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44629. /**
  44630. * Keep track of the image processing observer to allow dispose and replace.
  44631. */
  44632. private _imageProcessingObserver;
  44633. /**
  44634. * Attaches a new image processing configuration to the PBR Material.
  44635. * @param configuration (if null the scene configuration will be use)
  44636. */
  44637. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44638. /**
  44639. * Gets the image processing configuration used either in this material.
  44640. */
  44641. /**
  44642. * Sets the Default image processing configuration used either in the this material.
  44643. *
  44644. * If sets to null, the scene one is in use.
  44645. */
  44646. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44647. /**
  44648. * Gets wether the color curves effect is enabled.
  44649. */
  44650. /**
  44651. * Sets wether the color curves effect is enabled.
  44652. */
  44653. cameraColorCurvesEnabled: boolean;
  44654. /**
  44655. * Gets wether the color grading effect is enabled.
  44656. */
  44657. /**
  44658. * Gets wether the color grading effect is enabled.
  44659. */
  44660. cameraColorGradingEnabled: boolean;
  44661. /**
  44662. * Gets wether tonemapping is enabled or not.
  44663. */
  44664. /**
  44665. * Sets wether tonemapping is enabled or not
  44666. */
  44667. cameraToneMappingEnabled: boolean;
  44668. /**
  44669. * The camera exposure used on this material.
  44670. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44671. * This corresponds to a photographic exposure.
  44672. */
  44673. /**
  44674. * The camera exposure used on this material.
  44675. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44676. * This corresponds to a photographic exposure.
  44677. */
  44678. cameraExposure: float;
  44679. /**
  44680. * Gets The camera contrast used on this material.
  44681. */
  44682. /**
  44683. * Sets The camera contrast used on this material.
  44684. */
  44685. cameraContrast: float;
  44686. /**
  44687. * Gets the Color Grading 2D Lookup Texture.
  44688. */
  44689. /**
  44690. * Sets the Color Grading 2D Lookup Texture.
  44691. */
  44692. cameraColorGradingTexture: Nullable<BaseTexture>;
  44693. /**
  44694. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44695. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44696. * 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;
  44697. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44698. */
  44699. /**
  44700. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44701. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44702. * 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;
  44703. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44704. */
  44705. cameraColorCurves: Nullable<ColorCurves>;
  44706. /**
  44707. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44708. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44709. */
  44710. switchToBGR: boolean;
  44711. private _renderTargets;
  44712. private _reflectionControls;
  44713. private _white;
  44714. private _primaryShadowColor;
  44715. private _primaryHighlightColor;
  44716. /**
  44717. * Instantiates a Background Material in the given scene
  44718. * @param name The friendly name of the material
  44719. * @param scene The scene to add the material to
  44720. */
  44721. constructor(name: string, scene: Scene);
  44722. /**
  44723. * Gets a boolean indicating that current material needs to register RTT
  44724. */
  44725. readonly hasRenderTargetTextures: boolean;
  44726. /**
  44727. * The entire material has been created in order to prevent overdraw.
  44728. * @returns false
  44729. */
  44730. needAlphaTesting(): boolean;
  44731. /**
  44732. * The entire material has been created in order to prevent overdraw.
  44733. * @returns true if blending is enable
  44734. */
  44735. needAlphaBlending(): boolean;
  44736. /**
  44737. * Checks wether the material is ready to be rendered for a given mesh.
  44738. * @param mesh The mesh to render
  44739. * @param subMesh The submesh to check against
  44740. * @param useInstances Specify wether or not the material is used with instances
  44741. * @returns true if all the dependencies are ready (Textures, Effects...)
  44742. */
  44743. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44744. /**
  44745. * Compute the primary color according to the chosen perceptual color.
  44746. */
  44747. private _computePrimaryColorFromPerceptualColor;
  44748. /**
  44749. * Compute the highlights and shadow colors according to their chosen levels.
  44750. */
  44751. private _computePrimaryColors;
  44752. /**
  44753. * Build the uniform buffer used in the material.
  44754. */
  44755. buildUniformLayout(): void;
  44756. /**
  44757. * Unbind the material.
  44758. */
  44759. unbind(): void;
  44760. /**
  44761. * Bind only the world matrix to the material.
  44762. * @param world The world matrix to bind.
  44763. */
  44764. bindOnlyWorldMatrix(world: Matrix): void;
  44765. /**
  44766. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44767. * @param world The world matrix to bind.
  44768. * @param subMesh The submesh to bind for.
  44769. */
  44770. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44771. /**
  44772. * Dispose the material.
  44773. * @param forceDisposeEffect Force disposal of the associated effect.
  44774. * @param forceDisposeTextures Force disposal of the associated textures.
  44775. */
  44776. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44777. /**
  44778. * Clones the material.
  44779. * @param name The cloned name.
  44780. * @returns The cloned material.
  44781. */
  44782. clone(name: string): BackgroundMaterial;
  44783. /**
  44784. * Serializes the current material to its JSON representation.
  44785. * @returns The JSON representation.
  44786. */
  44787. serialize(): any;
  44788. /**
  44789. * Gets the class name of the material
  44790. * @returns "BackgroundMaterial"
  44791. */
  44792. getClassName(): string;
  44793. /**
  44794. * Parse a JSON input to create back a background material.
  44795. * @param source The JSON data to parse
  44796. * @param scene The scene to create the parsed material in
  44797. * @param rootUrl The root url of the assets the material depends upon
  44798. * @returns the instantiated BackgroundMaterial.
  44799. */
  44800. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44801. }
  44802. }
  44803. declare module BABYLON {
  44804. /**
  44805. * The Physically based material base class of BJS.
  44806. *
  44807. * This offers the main features of a standard PBR material.
  44808. * For more information, please refer to the documentation :
  44809. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44810. */
  44811. abstract class PBRBaseMaterial extends PushMaterial {
  44812. /**
  44813. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44814. */
  44815. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44816. /**
  44817. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44818. * to enhance interoperability with other engines.
  44819. */
  44820. static readonly LIGHTFALLOFF_GLTF: number;
  44821. /**
  44822. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44823. * to enhance interoperability with other materials.
  44824. */
  44825. static readonly LIGHTFALLOFF_STANDARD: number;
  44826. /**
  44827. * Intensity of the direct lights e.g. the four lights available in your scene.
  44828. * This impacts both the direct diffuse and specular highlights.
  44829. */
  44830. protected _directIntensity: number;
  44831. /**
  44832. * Intensity of the emissive part of the material.
  44833. * This helps controlling the emissive effect without modifying the emissive color.
  44834. */
  44835. protected _emissiveIntensity: number;
  44836. /**
  44837. * Intensity of the environment e.g. how much the environment will light the object
  44838. * either through harmonics for rough material or through the refelction for shiny ones.
  44839. */
  44840. protected _environmentIntensity: number;
  44841. /**
  44842. * This is a special control allowing the reduction of the specular highlights coming from the
  44843. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44844. */
  44845. protected _specularIntensity: number;
  44846. /**
  44847. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44848. */
  44849. private _lightingInfos;
  44850. /**
  44851. * Debug Control allowing disabling the bump map on this material.
  44852. */
  44853. protected _disableBumpMap: boolean;
  44854. /**
  44855. * AKA Diffuse Texture in standard nomenclature.
  44856. */
  44857. protected _albedoTexture: BaseTexture;
  44858. /**
  44859. * AKA Occlusion Texture in other nomenclature.
  44860. */
  44861. protected _ambientTexture: BaseTexture;
  44862. /**
  44863. * AKA Occlusion Texture Intensity in other nomenclature.
  44864. */
  44865. protected _ambientTextureStrength: number;
  44866. /**
  44867. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44868. * 1 means it completely occludes it
  44869. * 0 mean it has no impact
  44870. */
  44871. protected _ambientTextureImpactOnAnalyticalLights: number;
  44872. /**
  44873. * Stores the alpha values in a texture.
  44874. */
  44875. protected _opacityTexture: BaseTexture;
  44876. /**
  44877. * Stores the reflection values in a texture.
  44878. */
  44879. protected _reflectionTexture: BaseTexture;
  44880. /**
  44881. * Stores the refraction values in a texture.
  44882. */
  44883. protected _refractionTexture: BaseTexture;
  44884. /**
  44885. * Stores the emissive values in a texture.
  44886. */
  44887. protected _emissiveTexture: BaseTexture;
  44888. /**
  44889. * AKA Specular texture in other nomenclature.
  44890. */
  44891. protected _reflectivityTexture: BaseTexture;
  44892. /**
  44893. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44894. */
  44895. protected _metallicTexture: BaseTexture;
  44896. /**
  44897. * Specifies the metallic scalar of the metallic/roughness workflow.
  44898. * Can also be used to scale the metalness values of the metallic texture.
  44899. */
  44900. protected _metallic: Nullable<number>;
  44901. /**
  44902. * Specifies the roughness scalar of the metallic/roughness workflow.
  44903. * Can also be used to scale the roughness values of the metallic texture.
  44904. */
  44905. protected _roughness: Nullable<number>;
  44906. /**
  44907. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44908. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44909. */
  44910. protected _microSurfaceTexture: BaseTexture;
  44911. /**
  44912. * Stores surface normal data used to displace a mesh in a texture.
  44913. */
  44914. protected _bumpTexture: BaseTexture;
  44915. /**
  44916. * Stores the pre-calculated light information of a mesh in a texture.
  44917. */
  44918. protected _lightmapTexture: BaseTexture;
  44919. /**
  44920. * The color of a material in ambient lighting.
  44921. */
  44922. protected _ambientColor: Color3;
  44923. /**
  44924. * AKA Diffuse Color in other nomenclature.
  44925. */
  44926. protected _albedoColor: Color3;
  44927. /**
  44928. * AKA Specular Color in other nomenclature.
  44929. */
  44930. protected _reflectivityColor: Color3;
  44931. /**
  44932. * The color applied when light is reflected from a material.
  44933. */
  44934. protected _reflectionColor: Color3;
  44935. /**
  44936. * The color applied when light is emitted from a material.
  44937. */
  44938. protected _emissiveColor: Color3;
  44939. /**
  44940. * AKA Glossiness in other nomenclature.
  44941. */
  44942. protected _microSurface: number;
  44943. /**
  44944. * source material index of refraction (IOR)' / 'destination material IOR.
  44945. */
  44946. protected _indexOfRefraction: number;
  44947. /**
  44948. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  44949. */
  44950. protected _invertRefractionY: boolean;
  44951. /**
  44952. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44953. * Materials half opaque for instance using refraction could benefit from this control.
  44954. */
  44955. protected _linkRefractionWithTransparency: boolean;
  44956. /**
  44957. * Specifies that the material will use the light map as a show map.
  44958. */
  44959. protected _useLightmapAsShadowmap: boolean;
  44960. /**
  44961. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44962. * makes the reflect vector face the model (under horizon).
  44963. */
  44964. protected _useHorizonOcclusion: boolean;
  44965. /**
  44966. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44967. * too much the area relying on ambient texture to define their ambient occlusion.
  44968. */
  44969. protected _useRadianceOcclusion: boolean;
  44970. /**
  44971. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44972. */
  44973. protected _useAlphaFromAlbedoTexture: boolean;
  44974. /**
  44975. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44976. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44977. */
  44978. protected _useSpecularOverAlpha: boolean;
  44979. /**
  44980. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44981. */
  44982. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44983. /**
  44984. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44985. */
  44986. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44987. /**
  44988. * Specifies if the metallic texture contains the roughness information in its green channel.
  44989. */
  44990. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44991. /**
  44992. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44993. */
  44994. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44995. /**
  44996. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44997. */
  44998. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44999. /**
  45000. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45001. */
  45002. protected _useAmbientInGrayScale: boolean;
  45003. /**
  45004. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45005. * The material will try to infer what glossiness each pixel should be.
  45006. */
  45007. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45008. /**
  45009. * Defines the falloff type used in this material.
  45010. * It by default is Physical.
  45011. */
  45012. protected _lightFalloff: number;
  45013. /**
  45014. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45015. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45016. */
  45017. protected _useRadianceOverAlpha: boolean;
  45018. /**
  45019. * Allows using an object space normal map (instead of tangent space).
  45020. */
  45021. protected _useObjectSpaceNormalMap: boolean;
  45022. /**
  45023. * Allows using the bump map in parallax mode.
  45024. */
  45025. protected _useParallax: boolean;
  45026. /**
  45027. * Allows using the bump map in parallax occlusion mode.
  45028. */
  45029. protected _useParallaxOcclusion: boolean;
  45030. /**
  45031. * Controls the scale bias of the parallax mode.
  45032. */
  45033. protected _parallaxScaleBias: number;
  45034. /**
  45035. * If sets to true, disables all the lights affecting the material.
  45036. */
  45037. protected _disableLighting: boolean;
  45038. /**
  45039. * Number of Simultaneous lights allowed on the material.
  45040. */
  45041. protected _maxSimultaneousLights: number;
  45042. /**
  45043. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45044. */
  45045. protected _invertNormalMapX: boolean;
  45046. /**
  45047. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45048. */
  45049. protected _invertNormalMapY: boolean;
  45050. /**
  45051. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45052. */
  45053. protected _twoSidedLighting: boolean;
  45054. /**
  45055. * Defines the alpha limits in alpha test mode.
  45056. */
  45057. protected _alphaCutOff: number;
  45058. /**
  45059. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45060. */
  45061. protected _forceAlphaTest: boolean;
  45062. /**
  45063. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45064. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45065. */
  45066. protected _useAlphaFresnel: boolean;
  45067. /**
  45068. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45069. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45070. */
  45071. protected _useLinearAlphaFresnel: boolean;
  45072. /**
  45073. * The transparency mode of the material.
  45074. */
  45075. protected _transparencyMode: Nullable<number>;
  45076. /**
  45077. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45078. * from cos thetav and roughness:
  45079. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45080. */
  45081. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45082. /**
  45083. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45084. */
  45085. protected _forceIrradianceInFragment: boolean;
  45086. /**
  45087. * Force normal to face away from face.
  45088. */
  45089. protected _forceNormalForward: boolean;
  45090. /**
  45091. * Enables specular anti aliasing in the PBR shader.
  45092. * It will both interacts on the Geometry for analytical and IBL lighting.
  45093. * It also prefilter the roughness map based on the bump values.
  45094. */
  45095. protected _enableSpecularAntiAliasing: boolean;
  45096. /**
  45097. * Default configuration related to image processing available in the PBR Material.
  45098. */
  45099. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45100. /**
  45101. * Keep track of the image processing observer to allow dispose and replace.
  45102. */
  45103. private _imageProcessingObserver;
  45104. /**
  45105. * Attaches a new image processing configuration to the PBR Material.
  45106. * @param configuration
  45107. */
  45108. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45109. /**
  45110. * Stores the available render targets.
  45111. */
  45112. private _renderTargets;
  45113. /**
  45114. * Sets the global ambient color for the material used in lighting calculations.
  45115. */
  45116. private _globalAmbientColor;
  45117. /**
  45118. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45119. */
  45120. private _useLogarithmicDepth;
  45121. /**
  45122. * If set to true, no lighting calculations will be applied.
  45123. */
  45124. private _unlit;
  45125. /**
  45126. * Instantiates a new PBRMaterial instance.
  45127. *
  45128. * @param name The material name
  45129. * @param scene The scene the material will be use in.
  45130. */
  45131. constructor(name: string, scene: Scene);
  45132. /**
  45133. * Gets a boolean indicating that current material needs to register RTT
  45134. */
  45135. readonly hasRenderTargetTextures: boolean;
  45136. /**
  45137. * Gets the name of the material class.
  45138. */
  45139. getClassName(): string;
  45140. /**
  45141. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45142. */
  45143. /**
  45144. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45145. */
  45146. useLogarithmicDepth: boolean;
  45147. /**
  45148. * Gets the current transparency mode.
  45149. */
  45150. /**
  45151. * Sets the transparency mode of the material.
  45152. *
  45153. * | Value | Type | Description |
  45154. * | ----- | ----------------------------------- | ----------- |
  45155. * | 0 | OPAQUE | |
  45156. * | 1 | ALPHATEST | |
  45157. * | 2 | ALPHABLEND | |
  45158. * | 3 | ALPHATESTANDBLEND | |
  45159. *
  45160. */
  45161. transparencyMode: Nullable<number>;
  45162. /**
  45163. * Returns true if alpha blending should be disabled.
  45164. */
  45165. private readonly _disableAlphaBlending;
  45166. /**
  45167. * Specifies whether or not this material should be rendered in alpha blend mode.
  45168. */
  45169. needAlphaBlending(): boolean;
  45170. /**
  45171. * Specifies if the mesh will require alpha blending.
  45172. * @param mesh - BJS mesh.
  45173. */
  45174. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45175. /**
  45176. * Specifies whether or not this material should be rendered in alpha test mode.
  45177. */
  45178. needAlphaTesting(): boolean;
  45179. /**
  45180. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45181. */
  45182. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45183. /**
  45184. * Gets the texture used for the alpha test.
  45185. */
  45186. getAlphaTestTexture(): BaseTexture;
  45187. /**
  45188. * Stores the reflectivity values based on metallic roughness workflow.
  45189. */
  45190. private static _scaledReflectivity;
  45191. /**
  45192. * Specifies that the submesh is ready to be used.
  45193. * @param mesh - BJS mesh.
  45194. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45195. * @param useInstances - Specifies that instances should be used.
  45196. * @returns - boolean indicating that the submesh is ready or not.
  45197. */
  45198. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45199. /**
  45200. * Specifies if the material uses metallic roughness workflow.
  45201. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45202. */
  45203. isMetallicWorkflow(): boolean;
  45204. private _prepareEffect;
  45205. private _prepareDefines;
  45206. /**
  45207. * Force shader compilation
  45208. */
  45209. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45210. clipPlane: boolean;
  45211. }>): void;
  45212. /**
  45213. * Initializes the uniform buffer layout for the shader.
  45214. */
  45215. buildUniformLayout(): void;
  45216. /**
  45217. * Unbinds the textures.
  45218. */
  45219. unbind(): void;
  45220. /**
  45221. * Binds the submesh data.
  45222. * @param world - The world matrix.
  45223. * @param mesh - The BJS mesh.
  45224. * @param subMesh - A submesh of the BJS mesh.
  45225. */
  45226. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45227. /**
  45228. * Returns the animatable textures.
  45229. * @returns - Array of animatable textures.
  45230. */
  45231. getAnimatables(): IAnimatable[];
  45232. /**
  45233. * Returns the texture used for reflections.
  45234. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45235. */
  45236. private _getReflectionTexture;
  45237. /**
  45238. * Returns the texture used for refraction or null if none is used.
  45239. * @returns - Refection texture if present. If no refraction texture and refraction
  45240. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45241. */
  45242. private _getRefractionTexture;
  45243. /**
  45244. * Disposes the resources of the material.
  45245. * @param forceDisposeEffect - Forces the disposal of effects.
  45246. * @param forceDisposeTextures - Forces the disposal of all textures.
  45247. */
  45248. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45249. }
  45250. }
  45251. declare module BABYLON {
  45252. /**
  45253. * The Physically based simple base material of BJS.
  45254. *
  45255. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45256. * It is used as the base class for both the specGloss and metalRough conventions.
  45257. */
  45258. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45259. /**
  45260. * Number of Simultaneous lights allowed on the material.
  45261. */
  45262. maxSimultaneousLights: number;
  45263. /**
  45264. * If sets to true, disables all the lights affecting the material.
  45265. */
  45266. disableLighting: boolean;
  45267. /**
  45268. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45269. */
  45270. environmentTexture: BaseTexture;
  45271. /**
  45272. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45273. */
  45274. invertNormalMapX: boolean;
  45275. /**
  45276. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45277. */
  45278. invertNormalMapY: boolean;
  45279. /**
  45280. * Normal map used in the model.
  45281. */
  45282. normalTexture: BaseTexture;
  45283. /**
  45284. * Emissivie color used to self-illuminate the model.
  45285. */
  45286. emissiveColor: Color3;
  45287. /**
  45288. * Emissivie texture used to self-illuminate the model.
  45289. */
  45290. emissiveTexture: BaseTexture;
  45291. /**
  45292. * Occlusion Channel Strenght.
  45293. */
  45294. occlusionStrength: number;
  45295. /**
  45296. * Occlusion Texture of the material (adding extra occlusion effects).
  45297. */
  45298. occlusionTexture: BaseTexture;
  45299. /**
  45300. * Defines the alpha limits in alpha test mode.
  45301. */
  45302. alphaCutOff: number;
  45303. /**
  45304. * Gets the current double sided mode.
  45305. */
  45306. /**
  45307. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45308. */
  45309. doubleSided: boolean;
  45310. /**
  45311. * Stores the pre-calculated light information of a mesh in a texture.
  45312. */
  45313. lightmapTexture: BaseTexture;
  45314. /**
  45315. * If true, the light map contains occlusion information instead of lighting info.
  45316. */
  45317. useLightmapAsShadowmap: boolean;
  45318. /**
  45319. * Return the active textures of the material.
  45320. */
  45321. getActiveTextures(): BaseTexture[];
  45322. hasTexture(texture: BaseTexture): boolean;
  45323. /**
  45324. * Instantiates a new PBRMaterial instance.
  45325. *
  45326. * @param name The material name
  45327. * @param scene The scene the material will be use in.
  45328. */
  45329. constructor(name: string, scene: Scene);
  45330. getClassName(): string;
  45331. }
  45332. }
  45333. declare module BABYLON {
  45334. /**
  45335. * The Physically based material of BJS.
  45336. *
  45337. * This offers the main features of a standard PBR material.
  45338. * For more information, please refer to the documentation :
  45339. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45340. */
  45341. class PBRMaterial extends PBRBaseMaterial {
  45342. /**
  45343. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45344. */
  45345. static readonly PBRMATERIAL_OPAQUE: number;
  45346. /**
  45347. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45348. */
  45349. static readonly PBRMATERIAL_ALPHATEST: number;
  45350. /**
  45351. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45352. */
  45353. static readonly PBRMATERIAL_ALPHABLEND: number;
  45354. /**
  45355. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45356. * They are also discarded below the alpha cutoff threshold to improve performances.
  45357. */
  45358. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45359. /**
  45360. * Defines the default value of how much AO map is occluding the analytical lights
  45361. * (point spot...).
  45362. */
  45363. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45364. /**
  45365. * Intensity of the direct lights e.g. the four lights available in your scene.
  45366. * This impacts both the direct diffuse and specular highlights.
  45367. */
  45368. directIntensity: number;
  45369. /**
  45370. * Intensity of the emissive part of the material.
  45371. * This helps controlling the emissive effect without modifying the emissive color.
  45372. */
  45373. emissiveIntensity: number;
  45374. /**
  45375. * Intensity of the environment e.g. how much the environment will light the object
  45376. * either through harmonics for rough material or through the refelction for shiny ones.
  45377. */
  45378. environmentIntensity: number;
  45379. /**
  45380. * This is a special control allowing the reduction of the specular highlights coming from the
  45381. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45382. */
  45383. specularIntensity: number;
  45384. /**
  45385. * Debug Control allowing disabling the bump map on this material.
  45386. */
  45387. disableBumpMap: boolean;
  45388. /**
  45389. * AKA Diffuse Texture in standard nomenclature.
  45390. */
  45391. albedoTexture: BaseTexture;
  45392. /**
  45393. * AKA Occlusion Texture in other nomenclature.
  45394. */
  45395. ambientTexture: BaseTexture;
  45396. /**
  45397. * AKA Occlusion Texture Intensity in other nomenclature.
  45398. */
  45399. ambientTextureStrength: number;
  45400. /**
  45401. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45402. * 1 means it completely occludes it
  45403. * 0 mean it has no impact
  45404. */
  45405. ambientTextureImpactOnAnalyticalLights: number;
  45406. /**
  45407. * Stores the alpha values in a texture.
  45408. */
  45409. opacityTexture: BaseTexture;
  45410. /**
  45411. * Stores the reflection values in a texture.
  45412. */
  45413. reflectionTexture: Nullable<BaseTexture>;
  45414. /**
  45415. * Stores the emissive values in a texture.
  45416. */
  45417. emissiveTexture: BaseTexture;
  45418. /**
  45419. * AKA Specular texture in other nomenclature.
  45420. */
  45421. reflectivityTexture: BaseTexture;
  45422. /**
  45423. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45424. */
  45425. metallicTexture: BaseTexture;
  45426. /**
  45427. * Specifies the metallic scalar of the metallic/roughness workflow.
  45428. * Can also be used to scale the metalness values of the metallic texture.
  45429. */
  45430. metallic: Nullable<number>;
  45431. /**
  45432. * Specifies the roughness scalar of the metallic/roughness workflow.
  45433. * Can also be used to scale the roughness values of the metallic texture.
  45434. */
  45435. roughness: Nullable<number>;
  45436. /**
  45437. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45438. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45439. */
  45440. microSurfaceTexture: BaseTexture;
  45441. /**
  45442. * Stores surface normal data used to displace a mesh in a texture.
  45443. */
  45444. bumpTexture: BaseTexture;
  45445. /**
  45446. * Stores the pre-calculated light information of a mesh in a texture.
  45447. */
  45448. lightmapTexture: BaseTexture;
  45449. /**
  45450. * Stores the refracted light information in a texture.
  45451. */
  45452. refractionTexture: BaseTexture;
  45453. /**
  45454. * The color of a material in ambient lighting.
  45455. */
  45456. ambientColor: Color3;
  45457. /**
  45458. * AKA Diffuse Color in other nomenclature.
  45459. */
  45460. albedoColor: Color3;
  45461. /**
  45462. * AKA Specular Color in other nomenclature.
  45463. */
  45464. reflectivityColor: Color3;
  45465. /**
  45466. * The color reflected from the material.
  45467. */
  45468. reflectionColor: Color3;
  45469. /**
  45470. * The color emitted from the material.
  45471. */
  45472. emissiveColor: Color3;
  45473. /**
  45474. * AKA Glossiness in other nomenclature.
  45475. */
  45476. microSurface: number;
  45477. /**
  45478. * source material index of refraction (IOR)' / 'destination material IOR.
  45479. */
  45480. indexOfRefraction: number;
  45481. /**
  45482. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  45483. */
  45484. invertRefractionY: boolean;
  45485. /**
  45486. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45487. * Materials half opaque for instance using refraction could benefit from this control.
  45488. */
  45489. linkRefractionWithTransparency: boolean;
  45490. /**
  45491. * If true, the light map contains occlusion information instead of lighting info.
  45492. */
  45493. useLightmapAsShadowmap: boolean;
  45494. /**
  45495. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45496. */
  45497. useAlphaFromAlbedoTexture: boolean;
  45498. /**
  45499. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45500. */
  45501. forceAlphaTest: boolean;
  45502. /**
  45503. * Defines the alpha limits in alpha test mode.
  45504. */
  45505. alphaCutOff: number;
  45506. /**
  45507. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45508. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45509. */
  45510. useSpecularOverAlpha: boolean;
  45511. /**
  45512. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45513. */
  45514. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45515. /**
  45516. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45517. */
  45518. useRoughnessFromMetallicTextureAlpha: boolean;
  45519. /**
  45520. * Specifies if the metallic texture contains the roughness information in its green channel.
  45521. */
  45522. useRoughnessFromMetallicTextureGreen: boolean;
  45523. /**
  45524. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45525. */
  45526. useMetallnessFromMetallicTextureBlue: boolean;
  45527. /**
  45528. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45529. */
  45530. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45531. /**
  45532. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45533. */
  45534. useAmbientInGrayScale: boolean;
  45535. /**
  45536. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45537. * The material will try to infer what glossiness each pixel should be.
  45538. */
  45539. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45540. /**
  45541. * BJS is using an harcoded light falloff based on a manually sets up range.
  45542. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45543. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45544. */
  45545. /**
  45546. * BJS is using an harcoded light falloff based on a manually sets up range.
  45547. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45548. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45549. */
  45550. usePhysicalLightFalloff: boolean;
  45551. /**
  45552. * In order to support the falloff compatibility with gltf, a special mode has been added
  45553. * to reproduce the gltf light falloff.
  45554. */
  45555. /**
  45556. * In order to support the falloff compatibility with gltf, a special mode has been added
  45557. * to reproduce the gltf light falloff.
  45558. */
  45559. useGLTFLightFalloff: boolean;
  45560. /**
  45561. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45562. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45563. */
  45564. useRadianceOverAlpha: boolean;
  45565. /**
  45566. * Allows using an object space normal map (instead of tangent space).
  45567. */
  45568. useObjectSpaceNormalMap: boolean;
  45569. /**
  45570. * Allows using the bump map in parallax mode.
  45571. */
  45572. useParallax: boolean;
  45573. /**
  45574. * Allows using the bump map in parallax occlusion mode.
  45575. */
  45576. useParallaxOcclusion: boolean;
  45577. /**
  45578. * Controls the scale bias of the parallax mode.
  45579. */
  45580. parallaxScaleBias: number;
  45581. /**
  45582. * If sets to true, disables all the lights affecting the material.
  45583. */
  45584. disableLighting: boolean;
  45585. /**
  45586. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45587. */
  45588. forceIrradianceInFragment: boolean;
  45589. /**
  45590. * Number of Simultaneous lights allowed on the material.
  45591. */
  45592. maxSimultaneousLights: number;
  45593. /**
  45594. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45595. */
  45596. invertNormalMapX: boolean;
  45597. /**
  45598. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45599. */
  45600. invertNormalMapY: boolean;
  45601. /**
  45602. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45603. */
  45604. twoSidedLighting: boolean;
  45605. /**
  45606. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45607. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45608. */
  45609. useAlphaFresnel: boolean;
  45610. /**
  45611. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45612. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45613. */
  45614. useLinearAlphaFresnel: boolean;
  45615. /**
  45616. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45617. * And/Or occlude the blended part.
  45618. */
  45619. environmentBRDFTexture: Nullable<BaseTexture>;
  45620. /**
  45621. * Force normal to face away from face.
  45622. */
  45623. forceNormalForward: boolean;
  45624. /**
  45625. * Enables specular anti aliasing in the PBR shader.
  45626. * It will both interacts on the Geometry for analytical and IBL lighting.
  45627. * It also prefilter the roughness map based on the bump values.
  45628. */
  45629. enableSpecularAntiAliasing: boolean;
  45630. /**
  45631. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45632. * makes the reflect vector face the model (under horizon).
  45633. */
  45634. useHorizonOcclusion: boolean;
  45635. /**
  45636. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45637. * too much the area relying on ambient texture to define their ambient occlusion.
  45638. */
  45639. useRadianceOcclusion: boolean;
  45640. /**
  45641. * If set to true, no lighting calculations will be applied.
  45642. */
  45643. unlit: boolean;
  45644. /**
  45645. * Gets the image processing configuration used either in this material.
  45646. */
  45647. /**
  45648. * Sets the Default image processing configuration used either in the this material.
  45649. *
  45650. * If sets to null, the scene one is in use.
  45651. */
  45652. imageProcessingConfiguration: ImageProcessingConfiguration;
  45653. /**
  45654. * Gets wether the color curves effect is enabled.
  45655. */
  45656. /**
  45657. * Sets wether the color curves effect is enabled.
  45658. */
  45659. cameraColorCurvesEnabled: boolean;
  45660. /**
  45661. * Gets wether the color grading effect is enabled.
  45662. */
  45663. /**
  45664. * Gets wether the color grading effect is enabled.
  45665. */
  45666. cameraColorGradingEnabled: boolean;
  45667. /**
  45668. * Gets wether tonemapping is enabled or not.
  45669. */
  45670. /**
  45671. * Sets wether tonemapping is enabled or not
  45672. */
  45673. cameraToneMappingEnabled: boolean;
  45674. /**
  45675. * The camera exposure used on this material.
  45676. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45677. * This corresponds to a photographic exposure.
  45678. */
  45679. /**
  45680. * The camera exposure used on this material.
  45681. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45682. * This corresponds to a photographic exposure.
  45683. */
  45684. cameraExposure: number;
  45685. /**
  45686. * Gets The camera contrast used on this material.
  45687. */
  45688. /**
  45689. * Sets The camera contrast used on this material.
  45690. */
  45691. cameraContrast: number;
  45692. /**
  45693. * Gets the Color Grading 2D Lookup Texture.
  45694. */
  45695. /**
  45696. * Sets the Color Grading 2D Lookup Texture.
  45697. */
  45698. cameraColorGradingTexture: Nullable<BaseTexture>;
  45699. /**
  45700. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45701. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45702. * 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;
  45703. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45704. */
  45705. /**
  45706. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45707. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45708. * 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;
  45709. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45710. */
  45711. cameraColorCurves: Nullable<ColorCurves>;
  45712. /**
  45713. * Instantiates a new PBRMaterial instance.
  45714. *
  45715. * @param name The material name
  45716. * @param scene The scene the material will be use in.
  45717. */
  45718. constructor(name: string, scene: Scene);
  45719. /**
  45720. * Returns the name of this material class.
  45721. */
  45722. getClassName(): string;
  45723. /**
  45724. * Returns an array of the actively used textures.
  45725. * @returns - Array of BaseTextures
  45726. */
  45727. getActiveTextures(): BaseTexture[];
  45728. /**
  45729. * Checks to see if a texture is used in the material.
  45730. * @param texture - Base texture to use.
  45731. * @returns - Boolean specifying if a texture is used in the material.
  45732. */
  45733. hasTexture(texture: BaseTexture): boolean;
  45734. /**
  45735. * Makes a duplicate of the current material.
  45736. * @param name - name to use for the new material.
  45737. */
  45738. clone(name: string): PBRMaterial;
  45739. /**
  45740. * Serializes this PBR Material.
  45741. * @returns - An object with the serialized material.
  45742. */
  45743. serialize(): any;
  45744. /**
  45745. * Parses a PBR Material from a serialized object.
  45746. * @param source - Serialized object.
  45747. * @param scene - BJS scene instance.
  45748. * @param rootUrl - url for the scene object
  45749. * @returns - PBRMaterial
  45750. */
  45751. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45752. }
  45753. }
  45754. declare module BABYLON {
  45755. /**
  45756. * The PBR material of BJS following the metal roughness convention.
  45757. *
  45758. * This fits to the PBR convention in the GLTF definition:
  45759. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  45760. */
  45761. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  45762. /**
  45763. * The base color has two different interpretations depending on the value of metalness.
  45764. * When the material is a metal, the base color is the specific measured reflectance value
  45765. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  45766. * of the material.
  45767. */
  45768. baseColor: Color3;
  45769. /**
  45770. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  45771. * well as opacity information in the alpha channel.
  45772. */
  45773. baseTexture: BaseTexture;
  45774. /**
  45775. * Specifies the metallic scalar value of the material.
  45776. * Can also be used to scale the metalness values of the metallic texture.
  45777. */
  45778. metallic: number;
  45779. /**
  45780. * Specifies the roughness scalar value of the material.
  45781. * Can also be used to scale the roughness values of the metallic texture.
  45782. */
  45783. roughness: number;
  45784. /**
  45785. * Texture containing both the metallic value in the B channel and the
  45786. * roughness value in the G channel to keep better precision.
  45787. */
  45788. metallicRoughnessTexture: BaseTexture;
  45789. /**
  45790. * Instantiates a new PBRMetalRoughnessMaterial instance.
  45791. *
  45792. * @param name The material name
  45793. * @param scene The scene the material will be use in.
  45794. */
  45795. constructor(name: string, scene: Scene);
  45796. /**
  45797. * Return the currrent class name of the material.
  45798. */
  45799. getClassName(): string;
  45800. /**
  45801. * Return the active textures of the material.
  45802. */
  45803. getActiveTextures(): BaseTexture[];
  45804. /**
  45805. * Checks to see if a texture is used in the material.
  45806. * @param texture - Base texture to use.
  45807. * @returns - Boolean specifying if a texture is used in the material.
  45808. */
  45809. hasTexture(texture: BaseTexture): boolean;
  45810. /**
  45811. * Makes a duplicate of the current material.
  45812. * @param name - name to use for the new material.
  45813. */
  45814. clone(name: string): PBRMetallicRoughnessMaterial;
  45815. /**
  45816. * Serialize the material to a parsable JSON object.
  45817. */
  45818. serialize(): any;
  45819. /**
  45820. * Parses a JSON object correponding to the serialize function.
  45821. */
  45822. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  45823. }
  45824. }
  45825. declare module BABYLON {
  45826. /**
  45827. * The PBR material of BJS following the specular glossiness convention.
  45828. *
  45829. * This fits to the PBR convention in the GLTF definition:
  45830. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  45831. */
  45832. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  45833. /**
  45834. * Specifies the diffuse color of the material.
  45835. */
  45836. diffuseColor: Color3;
  45837. /**
  45838. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  45839. * channel.
  45840. */
  45841. diffuseTexture: BaseTexture;
  45842. /**
  45843. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  45844. */
  45845. specularColor: Color3;
  45846. /**
  45847. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  45848. */
  45849. glossiness: number;
  45850. /**
  45851. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  45852. */
  45853. specularGlossinessTexture: BaseTexture;
  45854. /**
  45855. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  45856. *
  45857. * @param name The material name
  45858. * @param scene The scene the material will be use in.
  45859. */
  45860. constructor(name: string, scene: Scene);
  45861. /**
  45862. * Return the currrent class name of the material.
  45863. */
  45864. getClassName(): string;
  45865. /**
  45866. * Return the active textures of the material.
  45867. */
  45868. getActiveTextures(): BaseTexture[];
  45869. /**
  45870. * Checks to see if a texture is used in the material.
  45871. * @param texture - Base texture to use.
  45872. * @returns - Boolean specifying if a texture is used in the material.
  45873. */
  45874. hasTexture(texture: BaseTexture): boolean;
  45875. /**
  45876. * Makes a duplicate of the current material.
  45877. * @param name - name to use for the new material.
  45878. */
  45879. clone(name: string): PBRSpecularGlossinessMaterial;
  45880. /**
  45881. * Serialize the material to a parsable JSON object.
  45882. */
  45883. serialize(): any;
  45884. /**
  45885. * Parses a JSON object correponding to the serialize function.
  45886. */
  45887. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  45888. }
  45889. }
  45890. declare module BABYLON {
  45891. /**
  45892. * Base class of all the textures in babylon.
  45893. * It groups all the common properties the materials, post process, lights... might need
  45894. * in order to make a correct use of the texture.
  45895. */
  45896. class BaseTexture {
  45897. /**
  45898. * Default anisotropic filtering level for the application.
  45899. * It is set to 4 as a good tradeoff between perf and quality.
  45900. */
  45901. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  45902. /**
  45903. * Define the name of the texture.
  45904. */
  45905. name: string;
  45906. private _hasAlpha;
  45907. /**
  45908. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  45909. */
  45910. hasAlpha: boolean;
  45911. /**
  45912. * Defines if the alpha value should be determined via the rgb values.
  45913. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  45914. */
  45915. getAlphaFromRGB: boolean;
  45916. /**
  45917. * Intensity or strength of the texture.
  45918. * It is commonly used by materials to fine tune the intensity of the texture
  45919. */
  45920. level: number;
  45921. /**
  45922. * Define the UV chanel to use starting from 0 and defaulting to 0.
  45923. * This is part of the texture as textures usually maps to one uv set.
  45924. */
  45925. coordinatesIndex: number;
  45926. private _coordinatesMode;
  45927. /**
  45928. * How a texture is mapped.
  45929. *
  45930. * | Value | Type | Description |
  45931. * | ----- | ----------------------------------- | ----------- |
  45932. * | 0 | EXPLICIT_MODE | |
  45933. * | 1 | SPHERICAL_MODE | |
  45934. * | 2 | PLANAR_MODE | |
  45935. * | 3 | CUBIC_MODE | |
  45936. * | 4 | PROJECTION_MODE | |
  45937. * | 5 | SKYBOX_MODE | |
  45938. * | 6 | INVCUBIC_MODE | |
  45939. * | 7 | EQUIRECTANGULAR_MODE | |
  45940. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  45941. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  45942. */
  45943. coordinatesMode: number;
  45944. /**
  45945. * | Value | Type | Description |
  45946. * | ----- | ------------------ | ----------- |
  45947. * | 0 | CLAMP_ADDRESSMODE | |
  45948. * | 1 | WRAP_ADDRESSMODE | |
  45949. * | 2 | MIRROR_ADDRESSMODE | |
  45950. */
  45951. wrapU: number;
  45952. /**
  45953. * | Value | Type | Description |
  45954. * | ----- | ------------------ | ----------- |
  45955. * | 0 | CLAMP_ADDRESSMODE | |
  45956. * | 1 | WRAP_ADDRESSMODE | |
  45957. * | 2 | MIRROR_ADDRESSMODE | |
  45958. */
  45959. wrapV: number;
  45960. /**
  45961. * | Value | Type | Description |
  45962. * | ----- | ------------------ | ----------- |
  45963. * | 0 | CLAMP_ADDRESSMODE | |
  45964. * | 1 | WRAP_ADDRESSMODE | |
  45965. * | 2 | MIRROR_ADDRESSMODE | |
  45966. */
  45967. wrapR: number;
  45968. /**
  45969. * With compliant hardware and browser (supporting anisotropic filtering)
  45970. * this defines the level of anisotropic filtering in the texture.
  45971. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  45972. */
  45973. anisotropicFilteringLevel: number;
  45974. /**
  45975. * Define if the texture is a cube texture or if false a 2d texture.
  45976. */
  45977. isCube: boolean;
  45978. /**
  45979. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  45980. */
  45981. is3D: boolean;
  45982. /**
  45983. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  45984. * HDR texture are usually stored in linear space.
  45985. * This only impacts the PBR and Background materials
  45986. */
  45987. gammaSpace: boolean;
  45988. /**
  45989. * Gets whether or not the texture contains RGBD data.
  45990. */
  45991. readonly isRGBD: boolean;
  45992. /**
  45993. * Is Z inverted in the texture (useful in a cube texture).
  45994. */
  45995. invertZ: boolean;
  45996. /**
  45997. * @hidden
  45998. */
  45999. lodLevelInAlpha: boolean;
  46000. /**
  46001. * With prefiltered texture, defined the offset used during the prefiltering steps.
  46002. */
  46003. lodGenerationOffset: number;
  46004. /**
  46005. * With prefiltered texture, defined the scale used during the prefiltering steps.
  46006. */
  46007. lodGenerationScale: number;
  46008. /**
  46009. * Define if the texture is a render target.
  46010. */
  46011. isRenderTarget: boolean;
  46012. /**
  46013. * Define the unique id of the texture in the scene.
  46014. */
  46015. readonly uid: string;
  46016. /**
  46017. * Return a string representation of the texture.
  46018. * @returns the texture as a string
  46019. */
  46020. toString(): string;
  46021. /**
  46022. * Get the class name of the texture.
  46023. * @returns "BaseTexture"
  46024. */
  46025. getClassName(): string;
  46026. /**
  46027. * Define the list of animation attached to the texture.
  46028. */
  46029. animations: Animation[];
  46030. /**
  46031. * An event triggered when the texture is disposed.
  46032. */
  46033. onDisposeObservable: Observable<BaseTexture>;
  46034. private _onDisposeObserver;
  46035. /**
  46036. * Callback triggered when the texture has been disposed.
  46037. * Kept for back compatibility, you can use the onDisposeObservable instead.
  46038. */
  46039. onDispose: () => void;
  46040. /**
  46041. * Define the current state of the loading sequence when in delayed load mode.
  46042. */
  46043. delayLoadState: number;
  46044. private _scene;
  46045. /** @hidden */
  46046. _texture: Nullable<InternalTexture>;
  46047. private _uid;
  46048. /**
  46049. * Define if the texture is preventinga material to render or not.
  46050. * If not and the texture is not ready, the engine will use a default black texture instead.
  46051. */
  46052. readonly isBlocking: boolean;
  46053. /**
  46054. * Instantiates a new BaseTexture.
  46055. * Base class of all the textures in babylon.
  46056. * It groups all the common properties the materials, post process, lights... might need
  46057. * in order to make a correct use of the texture.
  46058. * @param scene Define the scene the texture blongs to
  46059. */
  46060. constructor(scene: Nullable<Scene>);
  46061. /**
  46062. * Get the scene the texture belongs to.
  46063. * @returns the scene or null if undefined
  46064. */
  46065. getScene(): Nullable<Scene>;
  46066. /**
  46067. * Get the texture transform matrix used to offset tile the texture for istance.
  46068. * @returns the transformation matrix
  46069. */
  46070. getTextureMatrix(): Matrix;
  46071. /**
  46072. * Get the texture reflection matrix used to rotate/transform the reflection.
  46073. * @returns the reflection matrix
  46074. */
  46075. getReflectionTextureMatrix(): Matrix;
  46076. /**
  46077. * Get the underlying lower level texture from Babylon.
  46078. * @returns the insternal texture
  46079. */
  46080. getInternalTexture(): Nullable<InternalTexture>;
  46081. /**
  46082. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  46083. * @returns true if ready or not blocking
  46084. */
  46085. isReadyOrNotBlocking(): boolean;
  46086. /**
  46087. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  46088. * @returns true if fully ready
  46089. */
  46090. isReady(): boolean;
  46091. private _cachedSize;
  46092. /**
  46093. * Get the size of the texture.
  46094. * @returns the texture size.
  46095. */
  46096. getSize(): ISize;
  46097. /**
  46098. * Get the base size of the texture.
  46099. * It can be different from the size if the texture has been resized for POT for instance
  46100. * @returns the base size
  46101. */
  46102. getBaseSize(): ISize;
  46103. /**
  46104. * Scales the texture if is `canRescale()`
  46105. * @param ratio the resize factor we want to use to rescale
  46106. */
  46107. scale(ratio: number): void;
  46108. /**
  46109. * Get if the texture can rescale.
  46110. */
  46111. readonly canRescale: boolean;
  46112. /** @hidden */
  46113. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  46114. /** @hidden */
  46115. _rebuild(): void;
  46116. /**
  46117. * Triggers the load sequence in delayed load mode.
  46118. */
  46119. delayLoad(): void;
  46120. /**
  46121. * Clones the texture.
  46122. * @returns the cloned texture
  46123. */
  46124. clone(): Nullable<BaseTexture>;
  46125. /**
  46126. * Get the texture underlying type (INT, FLOAT...)
  46127. */
  46128. readonly textureType: number;
  46129. /**
  46130. * Get the texture underlying format (RGB, RGBA...)
  46131. */
  46132. readonly textureFormat: number;
  46133. /**
  46134. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46135. * This will returns an RGBA array buffer containing either in values (0-255) or
  46136. * float values (0-1) depending of the underlying buffer type.
  46137. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46138. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46139. * @param buffer defines a user defined buffer to fill with data (can be null)
  46140. * @returns The Array buffer containing the pixels data.
  46141. */
  46142. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46143. /**
  46144. * Release and destroy the underlying lower level texture aka internalTexture.
  46145. */
  46146. releaseInternalTexture(): void;
  46147. /**
  46148. * Get the polynomial representation of the texture data.
  46149. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46150. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46151. */
  46152. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46153. /** @hidden */
  46154. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46155. /** @hidden */
  46156. readonly _lodTextureMid: Nullable<BaseTexture>;
  46157. /** @hidden */
  46158. readonly _lodTextureLow: Nullable<BaseTexture>;
  46159. /**
  46160. * Dispose the texture and release its associated resources.
  46161. */
  46162. dispose(): void;
  46163. /**
  46164. * Serialize the texture into a JSON representation that can be parsed later on.
  46165. * @returns the JSON representation of the texture
  46166. */
  46167. serialize(): any;
  46168. /**
  46169. * Helper function to be called back once a list of texture contains only ready textures.
  46170. * @param textures Define the list of textures to wait for
  46171. * @param callback Define the callback triggered once the entire list will be ready
  46172. */
  46173. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46174. }
  46175. }
  46176. declare module BABYLON {
  46177. /**
  46178. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46179. * It can help converting any input color in a desired output one. This can then be used to create effects
  46180. * from sepia, black and white to sixties or futuristic rendering...
  46181. *
  46182. * The only supported format is currently 3dl.
  46183. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46184. */
  46185. class ColorGradingTexture extends BaseTexture {
  46186. /**
  46187. * The current texture matrix. (will always be identity in color grading texture)
  46188. */
  46189. private _textureMatrix;
  46190. /**
  46191. * The texture URL.
  46192. */
  46193. url: string;
  46194. /**
  46195. * Empty line regex stored for GC.
  46196. */
  46197. private static _noneEmptyLineRegex;
  46198. private _engine;
  46199. /**
  46200. * Instantiates a ColorGradingTexture from the following parameters.
  46201. *
  46202. * @param url The location of the color gradind data (currently only supporting 3dl)
  46203. * @param scene The scene the texture will be used in
  46204. */
  46205. constructor(url: string, scene: Scene);
  46206. /**
  46207. * Returns the texture matrix used in most of the material.
  46208. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46209. */
  46210. getTextureMatrix(): Matrix;
  46211. /**
  46212. * Occurs when the file being loaded is a .3dl LUT file.
  46213. */
  46214. private load3dlTexture;
  46215. /**
  46216. * Starts the loading process of the texture.
  46217. */
  46218. private loadTexture;
  46219. /**
  46220. * Clones the color gradind texture.
  46221. */
  46222. clone(): ColorGradingTexture;
  46223. /**
  46224. * Called during delayed load for textures.
  46225. */
  46226. delayLoad(): void;
  46227. /**
  46228. * Parses a color grading texture serialized by Babylon.
  46229. * @param parsedTexture The texture information being parsedTexture
  46230. * @param scene The scene to load the texture in
  46231. * @param rootUrl The root url of the data assets to load
  46232. * @return A color gradind texture
  46233. */
  46234. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46235. /**
  46236. * Serializes the LUT texture to json format.
  46237. */
  46238. serialize(): any;
  46239. }
  46240. }
  46241. declare module BABYLON {
  46242. /**
  46243. * Class for creating a cube texture
  46244. */
  46245. class CubeTexture extends BaseTexture {
  46246. /**
  46247. * The url of the texture
  46248. */
  46249. url: string;
  46250. /**
  46251. * Gets or sets the center of the bounding box associated with the cube texture.
  46252. * It must define where the camera used to render the texture was set
  46253. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46254. */
  46255. boundingBoxPosition: Vector3;
  46256. private _boundingBoxSize;
  46257. /**
  46258. * Gets or sets the size of the bounding box associated with the cube texture
  46259. * When defined, the cubemap will switch to local mode
  46260. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46261. * @example https://www.babylonjs-playground.com/#RNASML
  46262. */
  46263. /**
  46264. * Returns the bounding box size
  46265. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46266. */
  46267. boundingBoxSize: Vector3;
  46268. protected _rotationY: number;
  46269. /**
  46270. * Sets texture matrix rotation angle around Y axis in radians.
  46271. */
  46272. /**
  46273. * Gets texture matrix rotation angle around Y axis radians.
  46274. */
  46275. rotationY: number;
  46276. private _noMipmap;
  46277. private _files;
  46278. private _extensions;
  46279. private _textureMatrix;
  46280. private _format;
  46281. private _createPolynomials;
  46282. /** @hidden */
  46283. readonly _prefiltered: boolean;
  46284. /**
  46285. * Creates a cube texture from an array of image urls
  46286. * @param files defines an array of image urls
  46287. * @param scene defines the hosting scene
  46288. * @param noMipmap specifies if mip maps are not used
  46289. * @returns a cube texture
  46290. */
  46291. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46292. /**
  46293. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46294. * @param url defines the url of the prefiltered texture
  46295. * @param scene defines the scene the texture is attached to
  46296. * @param forcedExtension defines the extension of the file if different from the url
  46297. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46298. * @return the prefiltered texture
  46299. */
  46300. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46301. /**
  46302. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46303. * as prefiltered data.
  46304. * @param rootUrl defines the url of the texture or the root name of the six images
  46305. * @param scene defines the scene the texture is attached to
  46306. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46307. * @param noMipmap defines if mipmaps should be created or not
  46308. * @param files defines the six files to load for the different faces
  46309. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46310. * @param onError defines a callback triggered in case of error during load
  46311. * @param format defines the internal format to use for the texture once loaded
  46312. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46313. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46314. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46315. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46316. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46317. * @return the cube texture
  46318. */
  46319. 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);
  46320. /**
  46321. * Delays loading of the cube texture
  46322. */
  46323. delayLoad(): void;
  46324. /**
  46325. * Returns the reflection texture matrix
  46326. * @returns the reflection texture matrix
  46327. */
  46328. getReflectionTextureMatrix(): Matrix;
  46329. /**
  46330. * Sets the reflection texture matrix
  46331. * @param value Reflection texture matrix
  46332. */
  46333. setReflectionTextureMatrix(value: Matrix): void;
  46334. /**
  46335. * Parses text to create a cube texture
  46336. * @param parsedTexture define the serialized text to read from
  46337. * @param scene defines the hosting scene
  46338. * @param rootUrl defines the root url of the cube texture
  46339. * @returns a cube texture
  46340. */
  46341. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46342. /**
  46343. * Makes a clone, or deep copy, of the cube texture
  46344. * @returns a new cube texture
  46345. */
  46346. clone(): CubeTexture;
  46347. }
  46348. }
  46349. declare module BABYLON {
  46350. /**
  46351. * A class extending Texture allowing drawing on a texture
  46352. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46353. */
  46354. class DynamicTexture extends Texture {
  46355. private _generateMipMaps;
  46356. private _canvas;
  46357. private _context;
  46358. private _engine;
  46359. /**
  46360. * Creates a DynamicTexture
  46361. * @param name defines the name of the texture
  46362. * @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
  46363. * @param scene defines the scene where you want the texture
  46364. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46365. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46366. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46367. */
  46368. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46369. /**
  46370. * Gets the current state of canRescale
  46371. */
  46372. readonly canRescale: boolean;
  46373. private _recreate;
  46374. /**
  46375. * Scales the texture
  46376. * @param ratio the scale factor to apply to both width and height
  46377. */
  46378. scale(ratio: number): void;
  46379. /**
  46380. * Resizes the texture
  46381. * @param width the new width
  46382. * @param height the new height
  46383. */
  46384. scaleTo(width: number, height: number): void;
  46385. /**
  46386. * Gets the context of the canvas used by the texture
  46387. * @returns the canvas context of the dynamic texture
  46388. */
  46389. getContext(): CanvasRenderingContext2D;
  46390. /**
  46391. * Clears the texture
  46392. */
  46393. clear(): void;
  46394. /**
  46395. * Updates the texture
  46396. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46397. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46398. */
  46399. update(invertY?: boolean, premulAlpha?: boolean): void;
  46400. /**
  46401. * Draws text onto the texture
  46402. * @param text defines the text to be drawn
  46403. * @param x defines the placement of the text from the left
  46404. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46405. * @param font defines the font to be used with font-style, font-size, font-name
  46406. * @param color defines the color used for the text
  46407. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46408. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46409. * @param update defines whether texture is immediately update (default is true)
  46410. */
  46411. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  46412. /**
  46413. * Clones the texture
  46414. * @returns the clone of the texture.
  46415. */
  46416. clone(): DynamicTexture;
  46417. /**
  46418. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46419. * @returns a serialized dynamic texture object
  46420. */
  46421. serialize(): any;
  46422. /** @hidden */
  46423. _rebuild(): void;
  46424. }
  46425. }
  46426. declare module BABYLON {
  46427. /**
  46428. * This represents a texture coming from an HDR input.
  46429. *
  46430. * The only supported format is currently panorama picture stored in RGBE format.
  46431. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46432. */
  46433. class HDRCubeTexture extends BaseTexture {
  46434. private static _facesMapping;
  46435. private _generateHarmonics;
  46436. private _noMipmap;
  46437. private _textureMatrix;
  46438. private _size;
  46439. private _onLoad;
  46440. private _onError;
  46441. /**
  46442. * The texture URL.
  46443. */
  46444. url: string;
  46445. /**
  46446. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46447. */
  46448. coordinatesMode: number;
  46449. protected _isBlocking: boolean;
  46450. /**
  46451. * Sets wether or not the texture is blocking during loading.
  46452. */
  46453. /**
  46454. * Gets wether or not the texture is blocking during loading.
  46455. */
  46456. isBlocking: boolean;
  46457. protected _rotationY: number;
  46458. /**
  46459. * Sets texture matrix rotation angle around Y axis in radians.
  46460. */
  46461. /**
  46462. * Gets texture matrix rotation angle around Y axis radians.
  46463. */
  46464. rotationY: number;
  46465. /**
  46466. * Gets or sets the center of the bounding box associated with the cube texture
  46467. * It must define where the camera used to render the texture was set
  46468. */
  46469. boundingBoxPosition: Vector3;
  46470. private _boundingBoxSize;
  46471. /**
  46472. * Gets or sets the size of the bounding box associated with the cube texture
  46473. * When defined, the cubemap will switch to local mode
  46474. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46475. * @example https://www.babylonjs-playground.com/#RNASML
  46476. */
  46477. boundingBoxSize: Vector3;
  46478. /**
  46479. * Instantiates an HDRTexture from the following parameters.
  46480. *
  46481. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46482. * @param scene The scene the texture will be used in
  46483. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46484. * @param noMipmap Forces to not generate the mipmap if true
  46485. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46486. * @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)
  46487. * @param reserved Reserved flag for internal use.
  46488. */
  46489. 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>);
  46490. /**
  46491. * Occurs when the file is raw .hdr file.
  46492. */
  46493. private loadTexture;
  46494. clone(): HDRCubeTexture;
  46495. delayLoad(): void;
  46496. /**
  46497. * Get the texture reflection matrix used to rotate/transform the reflection.
  46498. * @returns the reflection matrix
  46499. */
  46500. getReflectionTextureMatrix(): Matrix;
  46501. /**
  46502. * Set the texture reflection matrix used to rotate/transform the reflection.
  46503. * @param value Define the reflection matrix to set
  46504. */
  46505. setReflectionTextureMatrix(value: Matrix): void;
  46506. /**
  46507. * Parses a JSON representation of an HDR Texture in order to create the texture
  46508. * @param parsedTexture Define the JSON representation
  46509. * @param scene Define the scene the texture should be created in
  46510. * @param rootUrl Define the root url in case we need to load relative dependencies
  46511. * @returns the newly created texture after parsing
  46512. */
  46513. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  46514. serialize(): any;
  46515. }
  46516. }
  46517. declare module BABYLON {
  46518. /**
  46519. * Class used to store data associated with WebGL texture data for the engine
  46520. * This class should not be used directly
  46521. */
  46522. class InternalTexture implements IInternalTextureTracker {
  46523. /**
  46524. * The source of the texture data is unknown
  46525. */
  46526. static DATASOURCE_UNKNOWN: number;
  46527. /**
  46528. * Texture data comes from an URL
  46529. */
  46530. static DATASOURCE_URL: number;
  46531. /**
  46532. * Texture data is only used for temporary storage
  46533. */
  46534. static DATASOURCE_TEMP: number;
  46535. /**
  46536. * Texture data comes from raw data (ArrayBuffer)
  46537. */
  46538. static DATASOURCE_RAW: number;
  46539. /**
  46540. * Texture content is dynamic (video or dynamic texture)
  46541. */
  46542. static DATASOURCE_DYNAMIC: number;
  46543. /**
  46544. * Texture content is generated by rendering to it
  46545. */
  46546. static DATASOURCE_RENDERTARGET: number;
  46547. /**
  46548. * Texture content is part of a multi render target process
  46549. */
  46550. static DATASOURCE_MULTIRENDERTARGET: number;
  46551. /**
  46552. * Texture data comes from a cube data file
  46553. */
  46554. static DATASOURCE_CUBE: number;
  46555. /**
  46556. * Texture data comes from a raw cube data
  46557. */
  46558. static DATASOURCE_CUBERAW: number;
  46559. /**
  46560. * Texture data come from a prefiltered cube data file
  46561. */
  46562. static DATASOURCE_CUBEPREFILTERED: number;
  46563. /**
  46564. * Texture content is raw 3D data
  46565. */
  46566. static DATASOURCE_RAW3D: number;
  46567. /**
  46568. * Texture content is a depth texture
  46569. */
  46570. static DATASOURCE_DEPTHTEXTURE: number;
  46571. /**
  46572. * Texture data comes from a raw cube data encoded with RGBD
  46573. */
  46574. static DATASOURCE_CUBERAW_RGBD: number;
  46575. /**
  46576. * Defines if the texture is ready
  46577. */
  46578. isReady: boolean;
  46579. /**
  46580. * Defines if the texture is a cube texture
  46581. */
  46582. isCube: boolean;
  46583. /**
  46584. * Defines if the texture contains 3D data
  46585. */
  46586. is3D: boolean;
  46587. /**
  46588. * Gets the URL used to load this texture
  46589. */
  46590. url: string;
  46591. /**
  46592. * Gets the sampling mode of the texture
  46593. */
  46594. samplingMode: number;
  46595. /**
  46596. * Gets a boolean indicating if the texture needs mipmaps generation
  46597. */
  46598. generateMipMaps: boolean;
  46599. /**
  46600. * Gets the number of samples used by the texture (WebGL2+ only)
  46601. */
  46602. samples: number;
  46603. /**
  46604. * Gets the type of the texture (int, float...)
  46605. */
  46606. type: number;
  46607. /**
  46608. * Gets the format of the texture (RGB, RGBA...)
  46609. */
  46610. format: number;
  46611. /**
  46612. * Observable called when the texture is loaded
  46613. */
  46614. onLoadedObservable: Observable<InternalTexture>;
  46615. /**
  46616. * Gets the width of the texture
  46617. */
  46618. width: number;
  46619. /**
  46620. * Gets the height of the texture
  46621. */
  46622. height: number;
  46623. /**
  46624. * Gets the depth of the texture
  46625. */
  46626. depth: number;
  46627. /**
  46628. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  46629. */
  46630. baseWidth: number;
  46631. /**
  46632. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  46633. */
  46634. baseHeight: number;
  46635. /**
  46636. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  46637. */
  46638. baseDepth: number;
  46639. /**
  46640. * Gets a boolean indicating if the texture is inverted on Y axis
  46641. */
  46642. invertY: boolean;
  46643. /**
  46644. * Gets or set the previous tracker in the list
  46645. */
  46646. previous: Nullable<IInternalTextureTracker>;
  46647. /**
  46648. * Gets or set the next tracker in the list
  46649. */
  46650. next: Nullable<IInternalTextureTracker>;
  46651. /** @hidden */
  46652. _initialSlot: number;
  46653. /** @hidden */
  46654. _designatedSlot: number;
  46655. /** @hidden */
  46656. _dataSource: number;
  46657. /** @hidden */
  46658. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  46659. /** @hidden */
  46660. _bufferView: Nullable<ArrayBufferView>;
  46661. /** @hidden */
  46662. _bufferViewArray: Nullable<ArrayBufferView[]>;
  46663. /** @hidden */
  46664. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  46665. /** @hidden */
  46666. _size: number;
  46667. /** @hidden */
  46668. _extension: string;
  46669. /** @hidden */
  46670. _files: Nullable<string[]>;
  46671. /** @hidden */
  46672. _workingCanvas: HTMLCanvasElement;
  46673. /** @hidden */
  46674. _workingContext: CanvasRenderingContext2D;
  46675. /** @hidden */
  46676. _framebuffer: Nullable<WebGLFramebuffer>;
  46677. /** @hidden */
  46678. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  46679. /** @hidden */
  46680. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  46681. /** @hidden */
  46682. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  46683. /** @hidden */
  46684. _attachments: Nullable<number[]>;
  46685. /** @hidden */
  46686. _cachedCoordinatesMode: Nullable<number>;
  46687. /** @hidden */
  46688. _cachedWrapU: Nullable<number>;
  46689. /** @hidden */
  46690. _cachedWrapV: Nullable<number>;
  46691. /** @hidden */
  46692. _cachedWrapR: Nullable<number>;
  46693. /** @hidden */
  46694. _cachedAnisotropicFilteringLevel: Nullable<number>;
  46695. /** @hidden */
  46696. _isDisabled: boolean;
  46697. /** @hidden */
  46698. _compression: Nullable<string>;
  46699. /** @hidden */
  46700. _generateStencilBuffer: boolean;
  46701. /** @hidden */
  46702. _generateDepthBuffer: boolean;
  46703. /** @hidden */
  46704. _comparisonFunction: number;
  46705. /** @hidden */
  46706. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  46707. /** @hidden */
  46708. _lodGenerationScale: number;
  46709. /** @hidden */
  46710. _lodGenerationOffset: number;
  46711. /** @hidden */
  46712. _lodTextureHigh: BaseTexture;
  46713. /** @hidden */
  46714. _lodTextureMid: BaseTexture;
  46715. /** @hidden */
  46716. _lodTextureLow: BaseTexture;
  46717. /** @hidden */
  46718. _isRGBD: boolean;
  46719. /** @hidden */
  46720. _webGLTexture: Nullable<WebGLTexture>;
  46721. /** @hidden */
  46722. _references: number;
  46723. private _engine;
  46724. /**
  46725. * Gets the Engine the texture belongs to.
  46726. * @returns The babylon engine
  46727. */
  46728. getEngine(): Engine;
  46729. /**
  46730. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  46731. */
  46732. readonly dataSource: number;
  46733. /**
  46734. * Creates a new InternalTexture
  46735. * @param engine defines the engine to use
  46736. * @param dataSource defines the type of data that will be used
  46737. * @param delayAllocation if the texture allocation should be delayed (default: false)
  46738. */
  46739. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  46740. /**
  46741. * Increments the number of references (ie. the number of Texture that point to it)
  46742. */
  46743. incrementReferences(): void;
  46744. /**
  46745. * Change the size of the texture (not the size of the content)
  46746. * @param width defines the new width
  46747. * @param height defines the new height
  46748. * @param depth defines the new depth (1 by default)
  46749. */
  46750. updateSize(width: int, height: int, depth?: int): void;
  46751. /** @hidden */
  46752. _rebuild(): void;
  46753. /** @hidden */
  46754. _swapAndDie(target: InternalTexture): void;
  46755. /**
  46756. * Dispose the current allocated resources
  46757. */
  46758. dispose(): void;
  46759. }
  46760. }
  46761. declare module BABYLON {
  46762. /**
  46763. * This represents the required contract to create a new type of texture loader.
  46764. */
  46765. interface IInternalTextureLoader {
  46766. /**
  46767. * Defines wether the loader supports cascade loading the different faces.
  46768. */
  46769. supportCascades: boolean;
  46770. /**
  46771. * This returns if the loader support the current file information.
  46772. * @param extension defines the file extension of the file being loaded
  46773. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46774. * @param fallback defines the fallback internal texture if any
  46775. * @param isBase64 defines whether the texture is encoded as a base64
  46776. * @param isBuffer defines whether the texture data are stored as a buffer
  46777. * @returns true if the loader can load the specified file
  46778. */
  46779. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46780. /**
  46781. * Transform the url before loading if required.
  46782. * @param rootUrl the url of the texture
  46783. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46784. * @returns the transformed texture
  46785. */
  46786. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46787. /**
  46788. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46789. * @param rootUrl the url of the texture
  46790. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46791. * @returns the fallback texture
  46792. */
  46793. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46794. /**
  46795. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46796. * @param data contains the texture data
  46797. * @param texture defines the BabylonJS internal texture
  46798. * @param createPolynomials will be true if polynomials have been requested
  46799. * @param onLoad defines the callback to trigger once the texture is ready
  46800. * @param onError defines the callback to trigger in case of error
  46801. */
  46802. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46803. /**
  46804. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46805. * @param data contains the texture data
  46806. * @param texture defines the BabylonJS internal texture
  46807. * @param callback defines the method to call once ready to upload
  46808. */
  46809. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46810. }
  46811. }
  46812. declare module BABYLON {
  46813. /**
  46814. * Internal interface used to track InternalTexture already bound to the GL context
  46815. */
  46816. interface IInternalTextureTracker {
  46817. /**
  46818. * Gets or set the previous tracker in the list
  46819. */
  46820. previous: Nullable<IInternalTextureTracker>;
  46821. /**
  46822. * Gets or set the next tracker in the list
  46823. */
  46824. next: Nullable<IInternalTextureTracker>;
  46825. }
  46826. /**
  46827. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  46828. */
  46829. class DummyInternalTextureTracker {
  46830. /**
  46831. * Gets or set the previous tracker in the list
  46832. */
  46833. previous: Nullable<IInternalTextureTracker>;
  46834. /**
  46835. * Gets or set the next tracker in the list
  46836. */
  46837. next: Nullable<IInternalTextureTracker>;
  46838. }
  46839. }
  46840. declare module BABYLON {
  46841. /**
  46842. * Mirror texture can be used to simulate the view from a mirror in a scene.
  46843. * It will dynamically be rendered every frame to adapt to the camera point of view.
  46844. * You can then easily use it as a reflectionTexture on a flat surface.
  46845. * In case the surface is not a plane, please consider relying on reflection probes.
  46846. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46847. */
  46848. class MirrorTexture extends RenderTargetTexture {
  46849. private scene;
  46850. /**
  46851. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  46852. * It is possible to directly set the mirrorPlane by directly using a BABYLON.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.
  46853. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46854. */
  46855. mirrorPlane: Plane;
  46856. /**
  46857. * Define the blur ratio used to blur the reflection if needed.
  46858. */
  46859. blurRatio: number;
  46860. /**
  46861. * Define the adaptive blur kernel used to blur the reflection if needed.
  46862. * This will autocompute the closest best match for the `blurKernel`
  46863. */
  46864. adaptiveBlurKernel: number;
  46865. /**
  46866. * Define the blur kernel used to blur the reflection if needed.
  46867. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46868. */
  46869. blurKernel: number;
  46870. /**
  46871. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  46872. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46873. */
  46874. blurKernelX: number;
  46875. /**
  46876. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  46877. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46878. */
  46879. blurKernelY: number;
  46880. private _autoComputeBlurKernel;
  46881. protected _onRatioRescale(): void;
  46882. private _updateGammaSpace;
  46883. private _imageProcessingConfigChangeObserver;
  46884. private _transformMatrix;
  46885. private _mirrorMatrix;
  46886. private _savedViewMatrix;
  46887. private _blurX;
  46888. private _blurY;
  46889. private _adaptiveBlurKernel;
  46890. private _blurKernelX;
  46891. private _blurKernelY;
  46892. private _blurRatio;
  46893. /**
  46894. * Instantiates a Mirror Texture.
  46895. * Mirror texture can be used to simulate the view from a mirror in a scene.
  46896. * It will dynamically be rendered every frame to adapt to the camera point of view.
  46897. * You can then easily use it as a reflectionTexture on a flat surface.
  46898. * In case the surface is not a plane, please consider relying on reflection probes.
  46899. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46900. * @param name
  46901. * @param size
  46902. * @param scene
  46903. * @param generateMipMaps
  46904. * @param type
  46905. * @param samplingMode
  46906. * @param generateDepthBuffer
  46907. */
  46908. constructor(name: string, size: number | {
  46909. width: number;
  46910. height: number;
  46911. } | {
  46912. ratio: number;
  46913. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  46914. private _preparePostProcesses;
  46915. /**
  46916. * Clone the mirror texture.
  46917. * @returns the cloned texture
  46918. */
  46919. clone(): MirrorTexture;
  46920. /**
  46921. * Serialize the texture to a JSON representation you could use in Parse later on
  46922. * @returns the serialized JSON representation
  46923. */
  46924. serialize(): any;
  46925. /**
  46926. * Dispose the texture and release its associated resources.
  46927. */
  46928. dispose(): void;
  46929. }
  46930. }
  46931. declare module BABYLON {
  46932. /**
  46933. * Creation options of the multi render target texture.
  46934. */
  46935. interface IMultiRenderTargetOptions {
  46936. /**
  46937. * Define if the texture needs to create mip maps after render.
  46938. */
  46939. generateMipMaps?: boolean;
  46940. /**
  46941. * Define the types of all the draw buffers we want to create
  46942. */
  46943. types?: number[];
  46944. /**
  46945. * Define the sampling modes of all the draw buffers we want to create
  46946. */
  46947. samplingModes?: number[];
  46948. /**
  46949. * Define if a depth buffer is required
  46950. */
  46951. generateDepthBuffer?: boolean;
  46952. /**
  46953. * Define if a stencil buffer is required
  46954. */
  46955. generateStencilBuffer?: boolean;
  46956. /**
  46957. * Define if a depth texture is required instead of a depth buffer
  46958. */
  46959. generateDepthTexture?: boolean;
  46960. /**
  46961. * Define the number of desired draw buffers
  46962. */
  46963. textureCount?: number;
  46964. /**
  46965. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46966. */
  46967. doNotChangeAspectRatio?: boolean;
  46968. /**
  46969. * Define the default type of the buffers we are creating
  46970. */
  46971. defaultType?: number;
  46972. }
  46973. /**
  46974. * A multi render target, like a render target provides the ability to render to a texture.
  46975. * Unlike the render target, it can render to several draw buffers in one draw.
  46976. * This is specially interesting in deferred rendering or for any effects requiring more than
  46977. * just one color from a single pass.
  46978. */
  46979. class MultiRenderTarget extends RenderTargetTexture {
  46980. private _internalTextures;
  46981. private _textures;
  46982. private _multiRenderTargetOptions;
  46983. /**
  46984. * Get if draw buffers are currently supported by the used hardware and browser.
  46985. */
  46986. readonly isSupported: boolean;
  46987. /**
  46988. * Get the list of textures generated by the multi render target.
  46989. */
  46990. readonly textures: Texture[];
  46991. /**
  46992. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46993. */
  46994. readonly depthTexture: Texture;
  46995. /**
  46996. * Set the wrapping mode on U of all the textures we are rendering to.
  46997. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46998. */
  46999. wrapU: number;
  47000. /**
  47001. * Set the wrapping mode on V of all the textures we are rendering to.
  47002. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47003. */
  47004. wrapV: number;
  47005. /**
  47006. * Instantiate a new multi render target texture.
  47007. * A multi render target, like a render target provides the ability to render to a texture.
  47008. * Unlike the render target, it can render to several draw buffers in one draw.
  47009. * This is specially interesting in deferred rendering or for any effects requiring more than
  47010. * just one color from a single pass.
  47011. * @param name Define the name of the texture
  47012. * @param size Define the size of the buffers to render to
  47013. * @param count Define the number of target we are rendering into
  47014. * @param scene Define the scene the texture belongs to
  47015. * @param options Define the options used to create the multi render target
  47016. */
  47017. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47018. /** @hidden */
  47019. _rebuild(): void;
  47020. private _createInternalTextures;
  47021. private _createTextures;
  47022. /**
  47023. * Define the number of samples used if MSAA is enabled.
  47024. */
  47025. samples: number;
  47026. /**
  47027. * Resize all the textures in the multi render target.
  47028. * Be carrefull as it will recreate all the data in the new texture.
  47029. * @param size Define the new size
  47030. */
  47031. resize(size: any): void;
  47032. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47033. /**
  47034. * Dispose the render targets and their associated resources
  47035. */
  47036. dispose(): void;
  47037. /**
  47038. * Release all the underlying texture used as draw buffers.
  47039. */
  47040. releaseInternalTextures(): void;
  47041. }
  47042. }
  47043. declare module BABYLON {
  47044. /**
  47045. * Raw cube texture where the raw buffers are passed in
  47046. */
  47047. class RawCubeTexture extends CubeTexture {
  47048. /**
  47049. * Creates a cube texture where the raw buffers are passed in.
  47050. * @param scene defines the scene the texture is attached to
  47051. * @param data defines the array of data to use to create each face
  47052. * @param size defines the size of the textures
  47053. * @param format defines the format of the data
  47054. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  47055. * @param generateMipMaps defines if the engine should generate the mip levels
  47056. * @param invertY defines if data must be stored with Y axis inverted
  47057. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  47058. * @param compression defines the compression used (null by default)
  47059. */
  47060. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47061. /**
  47062. * Updates the raw cube texture.
  47063. * @param data defines the data to store
  47064. * @param format defines the data format
  47065. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47066. * @param invertY defines if data must be stored with Y axis inverted
  47067. * @param compression defines the compression used (null by default)
  47068. * @param level defines which level of the texture to update
  47069. */
  47070. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47071. /**
  47072. * Updates a raw cube texture with RGBD encoded data.
  47073. * @param data defines the array of data [mipmap][face] to use to create each face
  47074. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47075. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47076. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47077. * @returns a promsie that resolves when the operation is complete
  47078. */
  47079. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47080. /**
  47081. * Clones the raw cube texture.
  47082. * @return a new cube texture
  47083. */
  47084. clone(): CubeTexture;
  47085. /** @hidden */
  47086. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47087. }
  47088. }
  47089. declare module BABYLON {
  47090. /**
  47091. * Raw texture can help creating a texture directly from an array of data.
  47092. * This can be super useful if you either get the data from an uncompressed source or
  47093. * if you wish to create your texture pixel by pixel.
  47094. */
  47095. class RawTexture extends Texture {
  47096. /**
  47097. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47098. */
  47099. format: number;
  47100. private _engine;
  47101. /**
  47102. * Instantiates a new RawTexture.
  47103. * Raw texture can help creating a texture directly from an array of data.
  47104. * This can be super useful if you either get the data from an uncompressed source or
  47105. * if you wish to create your texture pixel by pixel.
  47106. * @param data define the array of data to use to create the texture
  47107. * @param width define the width of the texture
  47108. * @param height define the height of the texture
  47109. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47110. * @param scene define the scene the texture belongs to
  47111. * @param generateMipMaps define whether mip maps should be generated or not
  47112. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47113. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47114. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47115. */
  47116. constructor(data: ArrayBufferView, width: number, height: number,
  47117. /**
  47118. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47119. */
  47120. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  47121. /**
  47122. * Updates the texture underlying data.
  47123. * @param data Define the new data of the texture
  47124. */
  47125. update(data: ArrayBufferView): void;
  47126. /**
  47127. * Creates a luminance texture from some data.
  47128. * @param data Define the texture data
  47129. * @param width Define the width of the texture
  47130. * @param height Define the height of the texture
  47131. * @param scene Define the scene the texture belongs to
  47132. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47133. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47134. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47135. * @returns the luminance texture
  47136. */
  47137. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47138. /**
  47139. * Creates a luminance alpha texture from some data.
  47140. * @param data Define the texture data
  47141. * @param width Define the width of the texture
  47142. * @param height Define the height of the texture
  47143. * @param scene Define the scene the texture belongs to
  47144. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47145. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47146. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47147. * @returns the luminance alpha texture
  47148. */
  47149. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47150. /**
  47151. * Creates an alpha texture from some data.
  47152. * @param data Define the texture data
  47153. * @param width Define the width of the texture
  47154. * @param height Define the height of the texture
  47155. * @param scene Define the scene the texture belongs to
  47156. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47157. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47158. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47159. * @returns the alpha texture
  47160. */
  47161. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47162. /**
  47163. * Creates a RGB texture from some data.
  47164. * @param data Define the texture data
  47165. * @param width Define the width of the texture
  47166. * @param height Define the height of the texture
  47167. * @param scene Define the scene the texture belongs to
  47168. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47169. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47170. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47171. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47172. * @returns the RGB alpha texture
  47173. */
  47174. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47175. /**
  47176. * Creates a RGBA texture from some data.
  47177. * @param data Define the texture data
  47178. * @param width Define the width of the texture
  47179. * @param height Define the height of the texture
  47180. * @param scene Define the scene the texture belongs to
  47181. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47182. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47183. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47184. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47185. * @returns the RGBA texture
  47186. */
  47187. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47188. /**
  47189. * Creates a R texture from some data.
  47190. * @param data Define the texture data
  47191. * @param width Define the width of the texture
  47192. * @param height Define the height of the texture
  47193. * @param scene Define the scene the texture belongs to
  47194. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47195. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47196. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47197. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47198. * @returns the R texture
  47199. */
  47200. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47201. }
  47202. }
  47203. declare module BABYLON {
  47204. /**
  47205. * Class used to store 3D textures containing user data
  47206. */
  47207. class RawTexture3D extends Texture {
  47208. /** Gets or sets the texture format to use */
  47209. format: number;
  47210. private _engine;
  47211. /**
  47212. * Create a new RawTexture3D
  47213. * @param data defines the data of the texture
  47214. * @param width defines the width of the texture
  47215. * @param height defines the height of the texture
  47216. * @param depth defines the depth of the texture
  47217. * @param format defines the texture format to use
  47218. * @param scene defines the hosting scene
  47219. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47220. * @param invertY defines if texture must be stored with Y axis inverted
  47221. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47222. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47223. */
  47224. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47225. /** Gets or sets the texture format to use */
  47226. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47227. /**
  47228. * Update the texture with new data
  47229. * @param data defines the data to store in the texture
  47230. */
  47231. update(data: ArrayBufferView): void;
  47232. }
  47233. }
  47234. declare module BABYLON {
  47235. /**
  47236. * Creates a refraction texture used by refraction channel of the standard material.
  47237. * It is like a mirror but to see through a material.
  47238. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47239. */
  47240. class RefractionTexture extends RenderTargetTexture {
  47241. /**
  47242. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47243. * It is possible to directly set the refractionPlane by directly using a BABYLON.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.
  47244. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47245. */
  47246. refractionPlane: Plane;
  47247. /**
  47248. * Define how deep under the surface we should see.
  47249. */
  47250. depth: number;
  47251. /**
  47252. * Creates a refraction texture used by refraction channel of the standard material.
  47253. * It is like a mirror but to see through a material.
  47254. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47255. * @param name Define the texture name
  47256. * @param size Define the size of the underlying texture
  47257. * @param scene Define the scene the refraction belongs to
  47258. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47259. */
  47260. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47261. /**
  47262. * Clone the refraction texture.
  47263. * @returns the cloned texture
  47264. */
  47265. clone(): RefractionTexture;
  47266. /**
  47267. * Serialize the texture to a JSON representation you could use in Parse later on
  47268. * @returns the serialized JSON representation
  47269. */
  47270. serialize(): any;
  47271. }
  47272. }
  47273. declare module BABYLON {
  47274. /**
  47275. * This Helps creating a texture that will be created from a camera in your scene.
  47276. * It is basically a dynamic texture that could be used to create special effects for instance.
  47277. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47278. */
  47279. class RenderTargetTexture extends Texture {
  47280. isCube: boolean;
  47281. /**
  47282. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47283. */
  47284. static readonly REFRESHRATE_RENDER_ONCE: number;
  47285. /**
  47286. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47287. */
  47288. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47289. /**
  47290. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47291. * the central point of your effect and can save a lot of performances.
  47292. */
  47293. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47294. /**
  47295. * Use this predicate to dynamically define the list of mesh you want to render.
  47296. * If set, the renderList property will be overwritten.
  47297. */
  47298. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47299. private _renderList;
  47300. /**
  47301. * Use this list to define the list of mesh you want to render.
  47302. */
  47303. renderList: Nullable<Array<AbstractMesh>>;
  47304. private _hookArray;
  47305. /**
  47306. * Define if particles should be rendered in your texture.
  47307. */
  47308. renderParticles: boolean;
  47309. /**
  47310. * Define if sprites should be rendered in your texture.
  47311. */
  47312. renderSprites: boolean;
  47313. /**
  47314. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47315. */
  47316. coordinatesMode: number;
  47317. /**
  47318. * Define the camera used to render the texture.
  47319. */
  47320. activeCamera: Nullable<Camera>;
  47321. /**
  47322. * Override the render function of the texture with your own one.
  47323. */
  47324. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47325. /**
  47326. * Define if camera post processes should be use while rendering the texture.
  47327. */
  47328. useCameraPostProcesses: boolean;
  47329. /**
  47330. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47331. */
  47332. ignoreCameraViewport: boolean;
  47333. private _postProcessManager;
  47334. private _postProcesses;
  47335. private _resizeObserver;
  47336. /**
  47337. * An event triggered when the texture is unbind.
  47338. */
  47339. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47340. /**
  47341. * An event triggered when the texture is unbind.
  47342. */
  47343. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47344. private _onAfterUnbindObserver;
  47345. /**
  47346. * Set a after unbind callback in the texture.
  47347. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47348. */
  47349. onAfterUnbind: () => void;
  47350. /**
  47351. * An event triggered before rendering the texture
  47352. */
  47353. onBeforeRenderObservable: Observable<number>;
  47354. private _onBeforeRenderObserver;
  47355. /**
  47356. * Set a before render callback in the texture.
  47357. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47358. */
  47359. onBeforeRender: (faceIndex: number) => void;
  47360. /**
  47361. * An event triggered after rendering the texture
  47362. */
  47363. onAfterRenderObservable: Observable<number>;
  47364. private _onAfterRenderObserver;
  47365. /**
  47366. * Set a after render callback in the texture.
  47367. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47368. */
  47369. onAfterRender: (faceIndex: number) => void;
  47370. /**
  47371. * An event triggered after the texture clear
  47372. */
  47373. onClearObservable: Observable<Engine>;
  47374. private _onClearObserver;
  47375. /**
  47376. * Set a clear callback in the texture.
  47377. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47378. */
  47379. onClear: (Engine: Engine) => void;
  47380. /**
  47381. * Define the clear color of the Render Target if it should be different from the scene.
  47382. */
  47383. clearColor: Color4;
  47384. protected _size: number | {
  47385. width: number;
  47386. height: number;
  47387. };
  47388. protected _initialSizeParameter: number | {
  47389. width: number;
  47390. height: number;
  47391. } | {
  47392. ratio: number;
  47393. };
  47394. protected _sizeRatio: Nullable<number>;
  47395. /** @hidden */
  47396. _generateMipMaps: boolean;
  47397. protected _renderingManager: RenderingManager;
  47398. /** @hidden */
  47399. _waitingRenderList: string[];
  47400. protected _doNotChangeAspectRatio: boolean;
  47401. protected _currentRefreshId: number;
  47402. protected _refreshRate: number;
  47403. protected _textureMatrix: Matrix;
  47404. protected _samples: number;
  47405. protected _renderTargetOptions: RenderTargetCreationOptions;
  47406. /**
  47407. * Gets render target creation options that were used.
  47408. */
  47409. readonly renderTargetOptions: RenderTargetCreationOptions;
  47410. protected _engine: Engine;
  47411. protected _onRatioRescale(): void;
  47412. /**
  47413. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  47414. * It must define where the camera used to render the texture is set
  47415. */
  47416. boundingBoxPosition: Vector3;
  47417. private _boundingBoxSize;
  47418. /**
  47419. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  47420. * When defined, the cubemap will switch to local mode
  47421. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47422. * @example https://www.babylonjs-playground.com/#RNASML
  47423. */
  47424. boundingBoxSize: Vector3;
  47425. /**
  47426. * In case the RTT has been created with a depth texture, get the associated
  47427. * depth texture.
  47428. * Otherwise, return null.
  47429. */
  47430. depthStencilTexture: Nullable<InternalTexture>;
  47431. /**
  47432. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  47433. * or used a shadow, depth texture...
  47434. * @param name The friendly name of the texture
  47435. * @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)
  47436. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  47437. * @param generateMipMaps True if mip maps need to be generated after render.
  47438. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  47439. * @param type The type of the buffer in the RTT (int, half float, float...)
  47440. * @param isCube True if a cube texture needs to be created
  47441. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  47442. * @param generateDepthBuffer True to generate a depth buffer
  47443. * @param generateStencilBuffer True to generate a stencil buffer
  47444. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  47445. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  47446. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47447. */
  47448. constructor(name: string, size: number | {
  47449. width: number;
  47450. height: number;
  47451. } | {
  47452. ratio: number;
  47453. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  47454. /**
  47455. * Creates a depth stencil texture.
  47456. * This is only available in WebGL 2 or with the depth texture extension available.
  47457. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  47458. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  47459. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  47460. */
  47461. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  47462. private _processSizeParameter;
  47463. /**
  47464. * Define the number of samples to use in case of MSAA.
  47465. * It defaults to one meaning no MSAA has been enabled.
  47466. */
  47467. samples: number;
  47468. /**
  47469. * Resets the refresh counter of the texture and start bak from scratch.
  47470. * Could be usefull to regenerate the texture if it is setup to render only once.
  47471. */
  47472. resetRefreshCounter(): void;
  47473. /**
  47474. * Define the refresh rate of the texture or the rendering frequency.
  47475. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  47476. */
  47477. refreshRate: number;
  47478. /**
  47479. * Adds a post process to the render target rendering passes.
  47480. * @param postProcess define the post process to add
  47481. */
  47482. addPostProcess(postProcess: PostProcess): void;
  47483. /**
  47484. * Clear all the post processes attached to the render target
  47485. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  47486. */
  47487. clearPostProcesses(dispose?: boolean): void;
  47488. /**
  47489. * Remove one of the post process from the list of attached post processes to the texture
  47490. * @param postProcess define the post process to remove from the list
  47491. */
  47492. removePostProcess(postProcess: PostProcess): void;
  47493. /** @hidden */
  47494. _shouldRender(): boolean;
  47495. /**
  47496. * Gets the actual render size of the texture.
  47497. * @returns the width of the render size
  47498. */
  47499. getRenderSize(): number;
  47500. /**
  47501. * Gets the actual render width of the texture.
  47502. * @returns the width of the render size
  47503. */
  47504. getRenderWidth(): number;
  47505. /**
  47506. * Gets the actual render height of the texture.
  47507. * @returns the height of the render size
  47508. */
  47509. getRenderHeight(): number;
  47510. /**
  47511. * Get if the texture can be rescaled or not.
  47512. */
  47513. readonly canRescale: boolean;
  47514. /**
  47515. * Resize the texture using a ratio.
  47516. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  47517. */
  47518. scale(ratio: number): void;
  47519. /**
  47520. * Get the texture reflection matrix used to rotate/transform the reflection.
  47521. * @returns the reflection matrix
  47522. */
  47523. getReflectionTextureMatrix(): Matrix;
  47524. /**
  47525. * Resize the texture to a new desired size.
  47526. * Be carrefull as it will recreate all the data in the new texture.
  47527. * @param size Define the new size. It can be:
  47528. * - a number for squared texture,
  47529. * - an object containing { width: number, height: number }
  47530. * - or an object containing a ratio { ratio: number }
  47531. */
  47532. resize(size: number | {
  47533. width: number;
  47534. height: number;
  47535. } | {
  47536. ratio: number;
  47537. }): void;
  47538. /**
  47539. * Renders all the objects from the render list into the texture.
  47540. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  47541. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  47542. */
  47543. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  47544. private _bestReflectionRenderTargetDimension;
  47545. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47546. private renderToTarget;
  47547. /**
  47548. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47549. * This allowed control for front to back rendering or reversly depending of the special needs.
  47550. *
  47551. * @param renderingGroupId The rendering group id corresponding to its index
  47552. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47553. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47554. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47555. */
  47556. 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;
  47557. /**
  47558. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47559. *
  47560. * @param renderingGroupId The rendering group id corresponding to its index
  47561. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47562. */
  47563. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47564. /**
  47565. * Clones the texture.
  47566. * @returns the cloned texture
  47567. */
  47568. clone(): RenderTargetTexture;
  47569. /**
  47570. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47571. * @returns The JSON representation of the texture
  47572. */
  47573. serialize(): any;
  47574. /**
  47575. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  47576. */
  47577. disposeFramebufferObjects(): void;
  47578. /**
  47579. * Dispose the texture and release its associated resources.
  47580. */
  47581. dispose(): void;
  47582. /** @hidden */
  47583. _rebuild(): void;
  47584. /**
  47585. * Clear the info related to rendering groups preventing retention point in material dispose.
  47586. */
  47587. freeRenderingGroups(): void;
  47588. }
  47589. }
  47590. declare module BABYLON {
  47591. /**
  47592. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47593. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47594. */
  47595. class Texture extends BaseTexture {
  47596. /** nearest is mag = nearest and min = nearest and mip = linear */
  47597. static readonly NEAREST_SAMPLINGMODE: number;
  47598. /** nearest is mag = nearest and min = nearest and mip = linear */
  47599. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  47600. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47601. static readonly BILINEAR_SAMPLINGMODE: number;
  47602. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47603. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  47604. /** Trilinear is mag = linear and min = linear and mip = linear */
  47605. static readonly TRILINEAR_SAMPLINGMODE: number;
  47606. /** Trilinear is mag = linear and min = linear and mip = linear */
  47607. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  47608. /** mag = nearest and min = nearest and mip = nearest */
  47609. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  47610. /** mag = nearest and min = linear and mip = nearest */
  47611. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  47612. /** mag = nearest and min = linear and mip = linear */
  47613. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  47614. /** mag = nearest and min = linear and mip = none */
  47615. static readonly NEAREST_LINEAR: number;
  47616. /** mag = nearest and min = nearest and mip = none */
  47617. static readonly NEAREST_NEAREST: number;
  47618. /** mag = linear and min = nearest and mip = nearest */
  47619. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  47620. /** mag = linear and min = nearest and mip = linear */
  47621. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  47622. /** mag = linear and min = linear and mip = none */
  47623. static readonly LINEAR_LINEAR: number;
  47624. /** mag = linear and min = nearest and mip = none */
  47625. static readonly LINEAR_NEAREST: number;
  47626. /** Explicit coordinates mode */
  47627. static readonly EXPLICIT_MODE: number;
  47628. /** Spherical coordinates mode */
  47629. static readonly SPHERICAL_MODE: number;
  47630. /** Planar coordinates mode */
  47631. static readonly PLANAR_MODE: number;
  47632. /** Cubic coordinates mode */
  47633. static readonly CUBIC_MODE: number;
  47634. /** Projection coordinates mode */
  47635. static readonly PROJECTION_MODE: number;
  47636. /** Inverse Cubic coordinates mode */
  47637. static readonly SKYBOX_MODE: number;
  47638. /** Inverse Cubic coordinates mode */
  47639. static readonly INVCUBIC_MODE: number;
  47640. /** Equirectangular coordinates mode */
  47641. static readonly EQUIRECTANGULAR_MODE: number;
  47642. /** Equirectangular Fixed coordinates mode */
  47643. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  47644. /** Equirectangular Fixed Mirrored coordinates mode */
  47645. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  47646. /** Texture is not repeating outside of 0..1 UVs */
  47647. static readonly CLAMP_ADDRESSMODE: number;
  47648. /** Texture is repeating outside of 0..1 UVs */
  47649. static readonly WRAP_ADDRESSMODE: number;
  47650. /** Texture is repeating and mirrored */
  47651. static readonly MIRROR_ADDRESSMODE: number;
  47652. /**
  47653. * 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
  47654. */
  47655. static UseSerializedUrlIfAny: boolean;
  47656. /**
  47657. * Define the url of the texture.
  47658. */
  47659. url: Nullable<string>;
  47660. /**
  47661. * Define an offset on the texture to offset the u coordinates of the UVs
  47662. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47663. */
  47664. uOffset: number;
  47665. /**
  47666. * Define an offset on the texture to offset the v coordinates of the UVs
  47667. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47668. */
  47669. vOffset: number;
  47670. /**
  47671. * Define an offset on the texture to scale the u coordinates of the UVs
  47672. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47673. */
  47674. uScale: number;
  47675. /**
  47676. * Define an offset on the texture to scale the v coordinates of the UVs
  47677. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47678. */
  47679. vScale: number;
  47680. /**
  47681. * Define an offset on the texture to rotate around the u coordinates of the UVs
  47682. * @see http://doc.babylonjs.com/how_to/more_materials
  47683. */
  47684. uAng: number;
  47685. /**
  47686. * Define an offset on the texture to rotate around the v coordinates of the UVs
  47687. * @see http://doc.babylonjs.com/how_to/more_materials
  47688. */
  47689. vAng: number;
  47690. /**
  47691. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  47692. * @see http://doc.babylonjs.com/how_to/more_materials
  47693. */
  47694. wAng: number;
  47695. /**
  47696. * Defines the center of rotation (U)
  47697. */
  47698. uRotationCenter: number;
  47699. /**
  47700. * Defines the center of rotation (V)
  47701. */
  47702. vRotationCenter: number;
  47703. /**
  47704. * Defines the center of rotation (W)
  47705. */
  47706. wRotationCenter: number;
  47707. /**
  47708. * Are mip maps generated for this texture or not.
  47709. */
  47710. readonly noMipmap: boolean;
  47711. private _noMipmap;
  47712. /** @hidden */
  47713. _invertY: boolean;
  47714. private _rowGenerationMatrix;
  47715. private _cachedTextureMatrix;
  47716. private _projectionModeMatrix;
  47717. private _t0;
  47718. private _t1;
  47719. private _t2;
  47720. private _cachedUOffset;
  47721. private _cachedVOffset;
  47722. private _cachedUScale;
  47723. private _cachedVScale;
  47724. private _cachedUAng;
  47725. private _cachedVAng;
  47726. private _cachedWAng;
  47727. private _cachedProjectionMatrixId;
  47728. private _cachedCoordinatesMode;
  47729. /** @hidden */
  47730. _samplingMode: number;
  47731. /** @hidden */
  47732. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47733. private _deleteBuffer;
  47734. protected _format: Nullable<number>;
  47735. private _delayedOnLoad;
  47736. private _delayedOnError;
  47737. /**
  47738. * Observable triggered once the texture has been loaded.
  47739. */
  47740. onLoadObservable: Observable<Texture>;
  47741. protected _isBlocking: boolean;
  47742. /**
  47743. * Is the texture preventing material to render while loading.
  47744. * If false, a default texture will be used instead of the loading one during the preparation step.
  47745. */
  47746. isBlocking: boolean;
  47747. /**
  47748. * Get the current sampling mode associated with the texture.
  47749. */
  47750. readonly samplingMode: number;
  47751. /**
  47752. * Instantiates a new texture.
  47753. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47754. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47755. * @param url define the url of the picture to load as a texture
  47756. * @param scene define the scene the texture will belong to
  47757. * @param noMipmap define if the texture will require mip maps or not
  47758. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47759. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47760. * @param onLoad define a callback triggered when the texture has been loaded
  47761. * @param onError define a callback triggered when an error occurred during the loading session
  47762. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  47763. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  47764. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47765. */
  47766. 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);
  47767. /**
  47768. * Update the url (and optional buffer) of this texture if url was null during construction.
  47769. * @param url the url of the texture
  47770. * @param buffer the buffer of the texture (defaults to null)
  47771. */
  47772. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  47773. /**
  47774. * Finish the loading sequence of a texture flagged as delayed load.
  47775. * @hidden
  47776. */
  47777. delayLoad(): void;
  47778. /**
  47779. * Update the sampling mode of the texture.
  47780. * Default is Trilinear mode.
  47781. *
  47782. * | Value | Type | Description |
  47783. * | ----- | ------------------ | ----------- |
  47784. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  47785. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  47786. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  47787. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  47788. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  47789. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  47790. * | 7 | NEAREST_LINEAR | |
  47791. * | 8 | NEAREST_NEAREST | |
  47792. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  47793. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  47794. * | 11 | LINEAR_LINEAR | |
  47795. * | 12 | LINEAR_NEAREST | |
  47796. *
  47797. * > _mag_: magnification filter (close to the viewer)
  47798. * > _min_: minification filter (far from the viewer)
  47799. * > _mip_: filter used between mip map levels
  47800. *@param samplingMode Define the new sampling mode of the texture
  47801. */
  47802. updateSamplingMode(samplingMode: number): void;
  47803. private _prepareRowForTextureGeneration;
  47804. /**
  47805. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  47806. * @returns the transform matrix of the texture.
  47807. */
  47808. getTextureMatrix(): Matrix;
  47809. /**
  47810. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  47811. * @returns The reflection texture transform
  47812. */
  47813. getReflectionTextureMatrix(): Matrix;
  47814. /**
  47815. * Clones the texture.
  47816. * @returns the cloned texture
  47817. */
  47818. clone(): Texture;
  47819. /**
  47820. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47821. * @returns The JSON representation of the texture
  47822. */
  47823. serialize(): any;
  47824. /**
  47825. * Get the current class name of the texture usefull for serialization or dynamic coding.
  47826. * @returns "Texture"
  47827. */
  47828. getClassName(): string;
  47829. /**
  47830. * Dispose the texture and release its associated resources.
  47831. */
  47832. dispose(): void;
  47833. /**
  47834. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  47835. * @param parsedTexture Define the JSON representation of the texture
  47836. * @param scene Define the scene the parsed texture should be instantiated in
  47837. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47838. * @returns The parsed texture if successful
  47839. */
  47840. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  47841. /**
  47842. * Creates a texture from its base 64 representation.
  47843. * @param data Define the base64 payload without the data: prefix
  47844. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  47845. * @param scene Define the scene the texture should belong to
  47846. * @param noMipmap Forces the texture to not create mip map information if true
  47847. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47848. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47849. * @param onLoad define a callback triggered when the texture has been loaded
  47850. * @param onError define a callback triggered when an error occurred during the loading session
  47851. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47852. * @returns the created texture
  47853. */
  47854. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  47855. /**
  47856. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  47857. * @param data Define the base64 payload without the data: prefix
  47858. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  47859. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  47860. * @param scene Define the scene the texture should belong to
  47861. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  47862. * @param noMipmap Forces the texture to not create mip map information if true
  47863. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47864. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47865. * @param onLoad define a callback triggered when the texture has been loaded
  47866. * @param onError define a callback triggered when an error occurred during the loading session
  47867. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47868. * @returns the created texture
  47869. */
  47870. 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;
  47871. }
  47872. }
  47873. declare module BABYLON {
  47874. /**
  47875. * Settings for finer control over video usage
  47876. */
  47877. interface VideoTextureSettings {
  47878. /**
  47879. * Applies `autoplay` to video, if specified
  47880. */
  47881. autoPlay?: boolean;
  47882. /**
  47883. * Applies `loop` to video, if specified
  47884. */
  47885. loop?: boolean;
  47886. /**
  47887. * Automatically updates internal texture from video at every frame in the render loop
  47888. */
  47889. autoUpdateTexture: boolean;
  47890. /**
  47891. * Image src displayed during the video loading or until the user interacts with the video.
  47892. */
  47893. poster?: string;
  47894. }
  47895. /**
  47896. * If you want to display a video in your scene, this is the special texture for that.
  47897. * This special texture works similar to other textures, with the exception of a few parameters.
  47898. * @see https://doc.babylonjs.com/how_to/video_texture
  47899. */
  47900. class VideoTexture extends Texture {
  47901. /**
  47902. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  47903. */
  47904. readonly autoUpdateTexture: boolean;
  47905. /**
  47906. * The video instance used by the texture internally
  47907. */
  47908. readonly video: HTMLVideoElement;
  47909. private _onUserActionRequestedObservable;
  47910. /**
  47911. * Event triggerd when a dom action is required by the user to play the video.
  47912. * This happens due to recent changes in browser policies preventing video to auto start.
  47913. */
  47914. readonly onUserActionRequestedObservable: Observable<Texture>;
  47915. private _generateMipMaps;
  47916. private _engine;
  47917. private _stillImageCaptured;
  47918. private _poster;
  47919. /**
  47920. * Creates a video texture.
  47921. * If you want to display a video in your scene, this is the special texture for that.
  47922. * This special texture works similar to other textures, with the exception of a few parameters.
  47923. * @see https://doc.babylonjs.com/how_to/video_texture
  47924. * @param name optional name, will detect from video source, if not defined
  47925. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  47926. * @param scene is obviously the current scene.
  47927. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  47928. * @param invertY is false by default but can be used to invert video on Y axis
  47929. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  47930. * @param settings allows finer control over video usage
  47931. */
  47932. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  47933. private _getName;
  47934. private _getVideo;
  47935. private _createInternalTexture;
  47936. private reset;
  47937. /**
  47938. * @hidden Internal method to initiate `update`.
  47939. */
  47940. _rebuild(): void;
  47941. /**
  47942. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  47943. */
  47944. update(): void;
  47945. /**
  47946. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  47947. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  47948. */
  47949. updateTexture(isVisible: boolean): void;
  47950. protected _updateInternalTexture: (e?: Event | undefined) => void;
  47951. /**
  47952. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  47953. * @param url New url.
  47954. */
  47955. updateURL(url: string): void;
  47956. /**
  47957. * Dispose the texture and release its associated resources.
  47958. */
  47959. dispose(): void;
  47960. /**
  47961. * Creates a video texture straight from your WebCam video feed.
  47962. * @param scene Define the scene the texture should be created in
  47963. * @param onReady Define a callback to triggered once the texture will be ready
  47964. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  47965. */
  47966. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  47967. minWidth: number;
  47968. maxWidth: number;
  47969. minHeight: number;
  47970. maxHeight: number;
  47971. deviceId: string;
  47972. }): void;
  47973. }
  47974. }
  47975. declare var DracoDecoderModule: any;
  47976. declare var WebAssembly: any;
  47977. declare module BABYLON {
  47978. /**
  47979. * Configuration for Draco compression
  47980. */
  47981. interface IDracoCompressionConfiguration {
  47982. /**
  47983. * Configuration for the decoder.
  47984. */
  47985. decoder?: {
  47986. /**
  47987. * The url to the WebAssembly module.
  47988. */
  47989. wasmUrl?: string;
  47990. /**
  47991. * The url to the WebAssembly binary.
  47992. */
  47993. wasmBinaryUrl?: string;
  47994. /**
  47995. * The url to the fallback JavaScript module.
  47996. */
  47997. fallbackUrl?: string;
  47998. };
  47999. }
  48000. /**
  48001. * Draco compression (https://google.github.io/draco/)
  48002. *
  48003. * This class wraps the Draco module.
  48004. *
  48005. * **Encoder**
  48006. *
  48007. * The encoder is not currently implemented.
  48008. *
  48009. * **Decoder**
  48010. *
  48011. * 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.
  48012. *
  48013. * To update the configuration, use the following code:
  48014. * ```javascript
  48015. * BABYLON.DracoCompression.Configuration = {
  48016. * decoder: {
  48017. * wasmUrl: "<url to the WebAssembly library>",
  48018. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48019. * fallbackUrl: "<url to the fallback JavaScript library>",
  48020. * }
  48021. * };
  48022. * ```
  48023. *
  48024. * 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.
  48025. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48026. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48027. *
  48028. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48029. * ```javascript
  48030. * var dracoCompression = new BABYLON.DracoCompression();
  48031. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48032. * [BABYLON.VertexBuffer.PositionKind]: 0
  48033. * });
  48034. * ```
  48035. *
  48036. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48037. */
  48038. class DracoCompression implements IDisposable {
  48039. private static _DecoderModulePromise;
  48040. /**
  48041. * The configuration. Defaults to the following urls:
  48042. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48043. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48044. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48045. */
  48046. static Configuration: IDracoCompressionConfiguration;
  48047. /**
  48048. * Returns true if the decoder is available.
  48049. */
  48050. static readonly DecoderAvailable: boolean;
  48051. /**
  48052. * Constructor
  48053. */
  48054. constructor();
  48055. /**
  48056. * Stop all async operations and release resources.
  48057. */
  48058. dispose(): void;
  48059. /**
  48060. * Decode Draco compressed mesh data to vertex data.
  48061. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48062. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48063. * @returns A promise that resolves with the decoded vertex data
  48064. */
  48065. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48066. [kind: string]: number;
  48067. }): Promise<VertexData>;
  48068. private static _GetDecoderModule;
  48069. private static _LoadScriptAsync;
  48070. private static _LoadFileAsync;
  48071. }
  48072. }
  48073. declare module BABYLON {
  48074. /**
  48075. * Particle emitter emitting particles from the inside of a box.
  48076. * It emits the particles randomly between 2 given directions.
  48077. */
  48078. class BoxParticleEmitter implements IParticleEmitterType {
  48079. /**
  48080. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48081. */
  48082. direction1: Vector3;
  48083. /**
  48084. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48085. */
  48086. direction2: Vector3;
  48087. /**
  48088. * 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.
  48089. */
  48090. minEmitBox: Vector3;
  48091. /**
  48092. * 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.
  48093. */
  48094. maxEmitBox: Vector3;
  48095. /**
  48096. * Creates a new instance BoxParticleEmitter
  48097. */
  48098. constructor();
  48099. /**
  48100. * Called by the particle System when the direction is computed for the created particle.
  48101. * @param worldMatrix is the world matrix of the particle system
  48102. * @param directionToUpdate is the direction vector to update with the result
  48103. * @param particle is the particle we are computed the direction for
  48104. */
  48105. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48106. /**
  48107. * Called by the particle System when the position is computed for the created particle.
  48108. * @param worldMatrix is the world matrix of the particle system
  48109. * @param positionToUpdate is the position vector to update with the result
  48110. * @param particle is the particle we are computed the position for
  48111. */
  48112. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48113. /**
  48114. * Clones the current emitter and returns a copy of it
  48115. * @returns the new emitter
  48116. */
  48117. clone(): BoxParticleEmitter;
  48118. /**
  48119. * Called by the GPUParticleSystem to setup the update shader
  48120. * @param effect defines the update shader
  48121. */
  48122. applyToShader(effect: Effect): void;
  48123. /**
  48124. * Returns a string to use to update the GPU particles update shader
  48125. * @returns a string containng the defines string
  48126. */
  48127. getEffectDefines(): string;
  48128. /**
  48129. * Returns the string "BoxParticleEmitter"
  48130. * @returns a string containing the class name
  48131. */
  48132. getClassName(): string;
  48133. /**
  48134. * Serializes the particle system to a JSON object.
  48135. * @returns the JSON object
  48136. */
  48137. serialize(): any;
  48138. /**
  48139. * Parse properties from a JSON object
  48140. * @param serializationObject defines the JSON object
  48141. */
  48142. parse(serializationObject: any): void;
  48143. }
  48144. }
  48145. declare module BABYLON {
  48146. /**
  48147. * Particle emitter emitting particles from the inside of a cone.
  48148. * It emits the particles alongside the cone volume from the base to the particle.
  48149. * The emission direction might be randomized.
  48150. */
  48151. class ConeParticleEmitter implements IParticleEmitterType {
  48152. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48153. directionRandomizer: number;
  48154. private _radius;
  48155. private _angle;
  48156. private _height;
  48157. /**
  48158. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  48159. */
  48160. radiusRange: number;
  48161. /**
  48162. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  48163. */
  48164. heightRange: number;
  48165. /**
  48166. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  48167. */
  48168. emitFromSpawnPointOnly: boolean;
  48169. /**
  48170. * Gets or sets the radius of the emission cone
  48171. */
  48172. radius: number;
  48173. /**
  48174. * Gets or sets the angle of the emission cone
  48175. */
  48176. angle: number;
  48177. private _buildHeight;
  48178. /**
  48179. * Creates a new instance ConeParticleEmitter
  48180. * @param radius the radius of the emission cone (1 by default)
  48181. * @param angles the cone base angle (PI by default)
  48182. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  48183. */
  48184. constructor(radius?: number, angle?: number,
  48185. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48186. directionRandomizer?: number);
  48187. /**
  48188. * Called by the particle System when the direction is computed for the created particle.
  48189. * @param worldMatrix is the world matrix of the particle system
  48190. * @param directionToUpdate is the direction vector to update with the result
  48191. * @param particle is the particle we are computed the direction for
  48192. */
  48193. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48194. /**
  48195. * Called by the particle System when the position is computed for the created particle.
  48196. * @param worldMatrix is the world matrix of the particle system
  48197. * @param positionToUpdate is the position vector to update with the result
  48198. * @param particle is the particle we are computed the position for
  48199. */
  48200. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48201. /**
  48202. * Clones the current emitter and returns a copy of it
  48203. * @returns the new emitter
  48204. */
  48205. clone(): ConeParticleEmitter;
  48206. /**
  48207. * Called by the GPUParticleSystem to setup the update shader
  48208. * @param effect defines the update shader
  48209. */
  48210. applyToShader(effect: Effect): void;
  48211. /**
  48212. * Returns a string to use to update the GPU particles update shader
  48213. * @returns a string containng the defines string
  48214. */
  48215. getEffectDefines(): string;
  48216. /**
  48217. * Returns the string "ConeParticleEmitter"
  48218. * @returns a string containing the class name
  48219. */
  48220. getClassName(): string;
  48221. /**
  48222. * Serializes the particle system to a JSON object.
  48223. * @returns the JSON object
  48224. */
  48225. serialize(): any;
  48226. /**
  48227. * Parse properties from a JSON object
  48228. * @param serializationObject defines the JSON object
  48229. */
  48230. parse(serializationObject: any): void;
  48231. }
  48232. }
  48233. declare module BABYLON {
  48234. /**
  48235. * Particle emitter emitting particles from the inside of a cylinder.
  48236. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  48237. */
  48238. class CylinderParticleEmitter implements IParticleEmitterType {
  48239. /**
  48240. * The radius of the emission cylinder.
  48241. */
  48242. radius: number;
  48243. /**
  48244. * The height of the emission cylinder.
  48245. */
  48246. height: number;
  48247. /**
  48248. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48249. */
  48250. radiusRange: number;
  48251. /**
  48252. * How much to randomize the particle direction [0-1].
  48253. */
  48254. directionRandomizer: number;
  48255. /**
  48256. * Creates a new instance CylinderParticleEmitter
  48257. * @param radius the radius of the emission cylinder (1 by default)
  48258. * @param height the height of the emission cylinder (1 by default)
  48259. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48260. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48261. */
  48262. constructor(
  48263. /**
  48264. * The radius of the emission cylinder.
  48265. */
  48266. radius?: number,
  48267. /**
  48268. * The height of the emission cylinder.
  48269. */
  48270. height?: number,
  48271. /**
  48272. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48273. */
  48274. radiusRange?: number,
  48275. /**
  48276. * How much to randomize the particle direction [0-1].
  48277. */
  48278. directionRandomizer?: number);
  48279. /**
  48280. * Called by the particle System when the direction is computed for the created particle.
  48281. * @param worldMatrix is the world matrix of the particle system
  48282. * @param directionToUpdate is the direction vector to update with the result
  48283. * @param particle is the particle we are computed the direction for
  48284. */
  48285. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48286. /**
  48287. * Called by the particle System when the position is computed for the created particle.
  48288. * @param worldMatrix is the world matrix of the particle system
  48289. * @param positionToUpdate is the position vector to update with the result
  48290. * @param particle is the particle we are computed the position for
  48291. */
  48292. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48293. /**
  48294. * Clones the current emitter and returns a copy of it
  48295. * @returns the new emitter
  48296. */
  48297. clone(): CylinderParticleEmitter;
  48298. /**
  48299. * Called by the GPUParticleSystem to setup the update shader
  48300. * @param effect defines the update shader
  48301. */
  48302. applyToShader(effect: Effect): void;
  48303. /**
  48304. * Returns a string to use to update the GPU particles update shader
  48305. * @returns a string containng the defines string
  48306. */
  48307. getEffectDefines(): string;
  48308. /**
  48309. * Returns the string "CylinderParticleEmitter"
  48310. * @returns a string containing the class name
  48311. */
  48312. getClassName(): string;
  48313. /**
  48314. * Serializes the particle system to a JSON object.
  48315. * @returns the JSON object
  48316. */
  48317. serialize(): any;
  48318. /**
  48319. * Parse properties from a JSON object
  48320. * @param serializationObject defines the JSON object
  48321. */
  48322. parse(serializationObject: any): void;
  48323. }
  48324. /**
  48325. * Particle emitter emitting particles from the inside of a cylinder.
  48326. * It emits the particles randomly between two vectors.
  48327. */
  48328. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  48329. /**
  48330. * The min limit of the emission direction.
  48331. */
  48332. direction1: Vector3;
  48333. /**
  48334. * The max limit of the emission direction.
  48335. */
  48336. direction2: Vector3;
  48337. /**
  48338. * Creates a new instance CylinderDirectedParticleEmitter
  48339. * @param radius the radius of the emission cylinder (1 by default)
  48340. * @param height the height of the emission cylinder (1 by default)
  48341. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48342. * @param direction1 the min limit of the emission direction (up vector by default)
  48343. * @param direction2 the max limit of the emission direction (up vector by default)
  48344. */
  48345. constructor(radius?: number, height?: number, radiusRange?: number,
  48346. /**
  48347. * The min limit of the emission direction.
  48348. */
  48349. direction1?: Vector3,
  48350. /**
  48351. * The max limit of the emission direction.
  48352. */
  48353. direction2?: Vector3);
  48354. /**
  48355. * Called by the particle System when the direction is computed for the created particle.
  48356. * @param worldMatrix is the world matrix of the particle system
  48357. * @param directionToUpdate is the direction vector to update with the result
  48358. * @param particle is the particle we are computed the direction for
  48359. */
  48360. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48361. /**
  48362. * Clones the current emitter and returns a copy of it
  48363. * @returns the new emitter
  48364. */
  48365. clone(): CylinderDirectedParticleEmitter;
  48366. /**
  48367. * Called by the GPUParticleSystem to setup the update shader
  48368. * @param effect defines the update shader
  48369. */
  48370. applyToShader(effect: Effect): void;
  48371. /**
  48372. * Returns a string to use to update the GPU particles update shader
  48373. * @returns a string containng the defines string
  48374. */
  48375. getEffectDefines(): string;
  48376. /**
  48377. * Returns the string "CylinderDirectedParticleEmitter"
  48378. * @returns a string containing the class name
  48379. */
  48380. getClassName(): string;
  48381. /**
  48382. * Serializes the particle system to a JSON object.
  48383. * @returns the JSON object
  48384. */
  48385. serialize(): any;
  48386. /**
  48387. * Parse properties from a JSON object
  48388. * @param serializationObject defines the JSON object
  48389. */
  48390. parse(serializationObject: any): void;
  48391. }
  48392. }
  48393. declare module BABYLON {
  48394. /**
  48395. * Particle emitter emitting particles from the inside of a hemisphere.
  48396. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  48397. */
  48398. class HemisphericParticleEmitter implements IParticleEmitterType {
  48399. /**
  48400. * The radius of the emission hemisphere.
  48401. */
  48402. radius: number;
  48403. /**
  48404. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48405. */
  48406. radiusRange: number;
  48407. /**
  48408. * How much to randomize the particle direction [0-1].
  48409. */
  48410. directionRandomizer: number;
  48411. /**
  48412. * Creates a new instance HemisphericParticleEmitter
  48413. * @param radius the radius of the emission hemisphere (1 by default)
  48414. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48415. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48416. */
  48417. constructor(
  48418. /**
  48419. * The radius of the emission hemisphere.
  48420. */
  48421. radius?: number,
  48422. /**
  48423. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48424. */
  48425. radiusRange?: number,
  48426. /**
  48427. * How much to randomize the particle direction [0-1].
  48428. */
  48429. directionRandomizer?: number);
  48430. /**
  48431. * Called by the particle System when the direction is computed for the created particle.
  48432. * @param worldMatrix is the world matrix of the particle system
  48433. * @param directionToUpdate is the direction vector to update with the result
  48434. * @param particle is the particle we are computed the direction for
  48435. */
  48436. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48437. /**
  48438. * Called by the particle System when the position is computed for the created particle.
  48439. * @param worldMatrix is the world matrix of the particle system
  48440. * @param positionToUpdate is the position vector to update with the result
  48441. * @param particle is the particle we are computed the position for
  48442. */
  48443. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48444. /**
  48445. * Clones the current emitter and returns a copy of it
  48446. * @returns the new emitter
  48447. */
  48448. clone(): HemisphericParticleEmitter;
  48449. /**
  48450. * Called by the GPUParticleSystem to setup the update shader
  48451. * @param effect defines the update shader
  48452. */
  48453. applyToShader(effect: Effect): void;
  48454. /**
  48455. * Returns a string to use to update the GPU particles update shader
  48456. * @returns a string containng the defines string
  48457. */
  48458. getEffectDefines(): string;
  48459. /**
  48460. * Returns the string "HemisphericParticleEmitter"
  48461. * @returns a string containing the class name
  48462. */
  48463. getClassName(): string;
  48464. /**
  48465. * Serializes the particle system to a JSON object.
  48466. * @returns the JSON object
  48467. */
  48468. serialize(): any;
  48469. /**
  48470. * Parse properties from a JSON object
  48471. * @param serializationObject defines the JSON object
  48472. */
  48473. parse(serializationObject: any): void;
  48474. }
  48475. }
  48476. declare module BABYLON {
  48477. /**
  48478. * Particle emitter represents a volume emitting particles.
  48479. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  48480. */
  48481. interface IParticleEmitterType {
  48482. /**
  48483. * Called by the particle System when the direction is computed for the created particle.
  48484. * @param worldMatrix is the world matrix of the particle system
  48485. * @param directionToUpdate is the direction vector to update with the result
  48486. * @param particle is the particle we are computed the direction for
  48487. */
  48488. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48489. /**
  48490. * Called by the particle System when the position is computed for the created particle.
  48491. * @param worldMatrix is the world matrix of the particle system
  48492. * @param positionToUpdate is the position vector to update with the result
  48493. * @param particle is the particle we are computed the position for
  48494. */
  48495. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48496. /**
  48497. * Clones the current emitter and returns a copy of it
  48498. * @returns the new emitter
  48499. */
  48500. clone(): IParticleEmitterType;
  48501. /**
  48502. * Called by the GPUParticleSystem to setup the update shader
  48503. * @param effect defines the update shader
  48504. */
  48505. applyToShader(effect: Effect): void;
  48506. /**
  48507. * Returns a string to use to update the GPU particles update shader
  48508. * @returns the effect defines string
  48509. */
  48510. getEffectDefines(): string;
  48511. /**
  48512. * Returns a string representing the class name
  48513. * @returns a string containing the class name
  48514. */
  48515. getClassName(): string;
  48516. /**
  48517. * Serializes the particle system to a JSON object.
  48518. * @returns the JSON object
  48519. */
  48520. serialize(): any;
  48521. /**
  48522. * Parse properties from a JSON object
  48523. * @param serializationObject defines the JSON object
  48524. */
  48525. parse(serializationObject: any): void;
  48526. }
  48527. }
  48528. declare module BABYLON {
  48529. /**
  48530. * Particle emitter emitting particles from a point.
  48531. * It emits the particles randomly between 2 given directions.
  48532. */
  48533. class PointParticleEmitter implements IParticleEmitterType {
  48534. /**
  48535. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48536. */
  48537. direction1: Vector3;
  48538. /**
  48539. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48540. */
  48541. direction2: Vector3;
  48542. /**
  48543. * Creates a new instance PointParticleEmitter
  48544. */
  48545. constructor();
  48546. /**
  48547. * Called by the particle System when the direction is computed for the created particle.
  48548. * @param worldMatrix is the world matrix of the particle system
  48549. * @param directionToUpdate is the direction vector to update with the result
  48550. * @param particle is the particle we are computed the direction for
  48551. */
  48552. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48553. /**
  48554. * Called by the particle System when the position is computed for the created particle.
  48555. * @param worldMatrix is the world matrix of the particle system
  48556. * @param positionToUpdate is the position vector to update with the result
  48557. * @param particle is the particle we are computed the position for
  48558. */
  48559. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48560. /**
  48561. * Clones the current emitter and returns a copy of it
  48562. * @returns the new emitter
  48563. */
  48564. clone(): PointParticleEmitter;
  48565. /**
  48566. * Called by the GPUParticleSystem to setup the update shader
  48567. * @param effect defines the update shader
  48568. */
  48569. applyToShader(effect: Effect): void;
  48570. /**
  48571. * Returns a string to use to update the GPU particles update shader
  48572. * @returns a string containng the defines string
  48573. */
  48574. getEffectDefines(): string;
  48575. /**
  48576. * Returns the string "PointParticleEmitter"
  48577. * @returns a string containing the class name
  48578. */
  48579. getClassName(): string;
  48580. /**
  48581. * Serializes the particle system to a JSON object.
  48582. * @returns the JSON object
  48583. */
  48584. serialize(): any;
  48585. /**
  48586. * Parse properties from a JSON object
  48587. * @param serializationObject defines the JSON object
  48588. */
  48589. parse(serializationObject: any): void;
  48590. }
  48591. }
  48592. declare module BABYLON {
  48593. /**
  48594. * Particle emitter emitting particles from the inside of a sphere.
  48595. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  48596. */
  48597. class SphereParticleEmitter implements IParticleEmitterType {
  48598. /**
  48599. * The radius of the emission sphere.
  48600. */
  48601. radius: number;
  48602. /**
  48603. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48604. */
  48605. radiusRange: number;
  48606. /**
  48607. * How much to randomize the particle direction [0-1].
  48608. */
  48609. directionRandomizer: number;
  48610. /**
  48611. * Creates a new instance SphereParticleEmitter
  48612. * @param radius the radius of the emission sphere (1 by default)
  48613. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48614. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48615. */
  48616. constructor(
  48617. /**
  48618. * The radius of the emission sphere.
  48619. */
  48620. radius?: number,
  48621. /**
  48622. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48623. */
  48624. radiusRange?: number,
  48625. /**
  48626. * How much to randomize the particle direction [0-1].
  48627. */
  48628. directionRandomizer?: number);
  48629. /**
  48630. * Called by the particle System when the direction is computed for the created particle.
  48631. * @param worldMatrix is the world matrix of the particle system
  48632. * @param directionToUpdate is the direction vector to update with the result
  48633. * @param particle is the particle we are computed the direction for
  48634. */
  48635. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48636. /**
  48637. * Called by the particle System when the position is computed for the created particle.
  48638. * @param worldMatrix is the world matrix of the particle system
  48639. * @param positionToUpdate is the position vector to update with the result
  48640. * @param particle is the particle we are computed the position for
  48641. */
  48642. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48643. /**
  48644. * Clones the current emitter and returns a copy of it
  48645. * @returns the new emitter
  48646. */
  48647. clone(): SphereParticleEmitter;
  48648. /**
  48649. * Called by the GPUParticleSystem to setup the update shader
  48650. * @param effect defines the update shader
  48651. */
  48652. applyToShader(effect: Effect): void;
  48653. /**
  48654. * Returns a string to use to update the GPU particles update shader
  48655. * @returns a string containng the defines string
  48656. */
  48657. getEffectDefines(): string;
  48658. /**
  48659. * Returns the string "SphereParticleEmitter"
  48660. * @returns a string containing the class name
  48661. */
  48662. getClassName(): string;
  48663. /**
  48664. * Serializes the particle system to a JSON object.
  48665. * @returns the JSON object
  48666. */
  48667. serialize(): any;
  48668. /**
  48669. * Parse properties from a JSON object
  48670. * @param serializationObject defines the JSON object
  48671. */
  48672. parse(serializationObject: any): void;
  48673. }
  48674. /**
  48675. * Particle emitter emitting particles from the inside of a sphere.
  48676. * It emits the particles randomly between two vectors.
  48677. */
  48678. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  48679. /**
  48680. * The min limit of the emission direction.
  48681. */
  48682. direction1: Vector3;
  48683. /**
  48684. * The max limit of the emission direction.
  48685. */
  48686. direction2: Vector3;
  48687. /**
  48688. * Creates a new instance SphereDirectedParticleEmitter
  48689. * @param radius the radius of the emission sphere (1 by default)
  48690. * @param direction1 the min limit of the emission direction (up vector by default)
  48691. * @param direction2 the max limit of the emission direction (up vector by default)
  48692. */
  48693. constructor(radius?: number,
  48694. /**
  48695. * The min limit of the emission direction.
  48696. */
  48697. direction1?: Vector3,
  48698. /**
  48699. * The max limit of the emission direction.
  48700. */
  48701. direction2?: Vector3);
  48702. /**
  48703. * Called by the particle System when the direction is computed for the created particle.
  48704. * @param worldMatrix is the world matrix of the particle system
  48705. * @param directionToUpdate is the direction vector to update with the result
  48706. * @param particle is the particle we are computed the direction for
  48707. */
  48708. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48709. /**
  48710. * Clones the current emitter and returns a copy of it
  48711. * @returns the new emitter
  48712. */
  48713. clone(): SphereDirectedParticleEmitter;
  48714. /**
  48715. * Called by the GPUParticleSystem to setup the update shader
  48716. * @param effect defines the update shader
  48717. */
  48718. applyToShader(effect: Effect): void;
  48719. /**
  48720. * Returns a string to use to update the GPU particles update shader
  48721. * @returns a string containng the defines string
  48722. */
  48723. getEffectDefines(): string;
  48724. /**
  48725. * Returns the string "SphereDirectedParticleEmitter"
  48726. * @returns a string containing the class name
  48727. */
  48728. getClassName(): string;
  48729. /**
  48730. * Serializes the particle system to a JSON object.
  48731. * @returns the JSON object
  48732. */
  48733. serialize(): any;
  48734. /**
  48735. * Parse properties from a JSON object
  48736. * @param serializationObject defines the JSON object
  48737. */
  48738. parse(serializationObject: any): void;
  48739. }
  48740. }
  48741. declare module BABYLON {
  48742. /** @hidden */
  48743. class CannonJSPlugin implements IPhysicsEnginePlugin {
  48744. private _useDeltaForWorldStep;
  48745. world: any;
  48746. name: string;
  48747. private _physicsMaterials;
  48748. private _fixedTimeStep;
  48749. BJSCANNON: any;
  48750. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  48751. setGravity(gravity: Vector3): void;
  48752. setTimeStep(timeStep: number): void;
  48753. getTimeStep(): number;
  48754. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48755. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48756. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48757. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48758. private _processChildMeshes;
  48759. removePhysicsBody(impostor: PhysicsImpostor): void;
  48760. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48761. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48762. private _addMaterial;
  48763. private _checkWithEpsilon;
  48764. private _createShape;
  48765. private _createHeightmap;
  48766. private _minus90X;
  48767. private _plus90X;
  48768. private _tmpPosition;
  48769. private _tmpDeltaPosition;
  48770. private _tmpUnityRotation;
  48771. private _updatePhysicsBodyTransformation;
  48772. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48773. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48774. isSupported(): boolean;
  48775. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48776. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48777. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48778. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48779. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48780. getBodyMass(impostor: PhysicsImpostor): number;
  48781. getBodyFriction(impostor: PhysicsImpostor): number;
  48782. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48783. getBodyRestitution(impostor: PhysicsImpostor): number;
  48784. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48785. sleepBody(impostor: PhysicsImpostor): void;
  48786. wakeUpBody(impostor: PhysicsImpostor): void;
  48787. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48788. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48789. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48790. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48791. getRadius(impostor: PhysicsImpostor): number;
  48792. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48793. dispose(): void;
  48794. private _extendNamespace;
  48795. }
  48796. }
  48797. declare module BABYLON {
  48798. /** @hidden */
  48799. class OimoJSPlugin implements IPhysicsEnginePlugin {
  48800. world: any;
  48801. name: string;
  48802. BJSOIMO: any;
  48803. constructor(iterations?: number);
  48804. setGravity(gravity: Vector3): void;
  48805. setTimeStep(timeStep: number): void;
  48806. getTimeStep(): number;
  48807. private _tmpImpostorsArray;
  48808. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48809. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48810. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48811. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48812. private _tmpPositionVector;
  48813. removePhysicsBody(impostor: PhysicsImpostor): void;
  48814. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48815. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48816. isSupported(): boolean;
  48817. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48818. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48819. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48820. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48821. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48822. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48823. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48824. getBodyMass(impostor: PhysicsImpostor): number;
  48825. getBodyFriction(impostor: PhysicsImpostor): number;
  48826. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48827. getBodyRestitution(impostor: PhysicsImpostor): number;
  48828. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48829. sleepBody(impostor: PhysicsImpostor): void;
  48830. wakeUpBody(impostor: PhysicsImpostor): void;
  48831. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48832. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  48833. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48834. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48835. getRadius(impostor: PhysicsImpostor): number;
  48836. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48837. dispose(): void;
  48838. }
  48839. }
  48840. declare module BABYLON {
  48841. /**
  48842. * This represents a set of one or more post processes in Babylon.
  48843. * A post process can be used to apply a shader to a texture after it is rendered.
  48844. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48845. */
  48846. class PostProcessRenderEffect {
  48847. private _postProcesses;
  48848. private _getPostProcesses;
  48849. private _singleInstance;
  48850. private _cameras;
  48851. private _indicesForCamera;
  48852. /**
  48853. * Name of the effect
  48854. * @hidden
  48855. */
  48856. _name: string;
  48857. /**
  48858. * Instantiates a post process render effect.
  48859. * A post process can be used to apply a shader to a texture after it is rendered.
  48860. * @param engine The engine the effect is tied to
  48861. * @param name The name of the effect
  48862. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  48863. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  48864. */
  48865. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  48866. /**
  48867. * Checks if all the post processes in the effect are supported.
  48868. */
  48869. readonly isSupported: boolean;
  48870. /**
  48871. * Updates the current state of the effect
  48872. * @hidden
  48873. */
  48874. _update(): void;
  48875. /**
  48876. * Attaches the effect on cameras
  48877. * @param cameras The camera to attach to.
  48878. * @hidden
  48879. */
  48880. _attachCameras(cameras: Camera): void;
  48881. /**
  48882. * Attaches the effect on cameras
  48883. * @param cameras The camera to attach to.
  48884. * @hidden
  48885. */
  48886. _attachCameras(cameras: Camera[]): void;
  48887. /**
  48888. * Detatches the effect on cameras
  48889. * @param cameras The camera to detatch from.
  48890. * @hidden
  48891. */
  48892. _detachCameras(cameras: Camera): void;
  48893. /**
  48894. * Detatches the effect on cameras
  48895. * @param cameras The camera to detatch from.
  48896. * @hidden
  48897. */
  48898. _detachCameras(cameras: Camera[]): void;
  48899. /**
  48900. * Enables the effect on given cameras
  48901. * @param cameras The camera to enable.
  48902. * @hidden
  48903. */
  48904. _enable(cameras: Camera): void;
  48905. /**
  48906. * Enables the effect on given cameras
  48907. * @param cameras The camera to enable.
  48908. * @hidden
  48909. */
  48910. _enable(cameras: Nullable<Camera[]>): void;
  48911. /**
  48912. * Disables the effect on the given cameras
  48913. * @param cameras The camera to disable.
  48914. * @hidden
  48915. */
  48916. _disable(cameras: Camera): void;
  48917. /**
  48918. * Disables the effect on the given cameras
  48919. * @param cameras The camera to disable.
  48920. * @hidden
  48921. */
  48922. _disable(cameras: Nullable<Camera[]>): void;
  48923. /**
  48924. * Gets a list of the post processes contained in the effect.
  48925. * @param camera The camera to get the post processes on.
  48926. * @returns The list of the post processes in the effect.
  48927. */
  48928. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  48929. }
  48930. }
  48931. declare module BABYLON {
  48932. /**
  48933. * PostProcessRenderPipeline
  48934. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48935. */
  48936. class PostProcessRenderPipeline {
  48937. private engine;
  48938. private _renderEffects;
  48939. private _renderEffectsForIsolatedPass;
  48940. /**
  48941. * @hidden
  48942. */
  48943. protected _cameras: Camera[];
  48944. /** @hidden */
  48945. _name: string;
  48946. /**
  48947. * Initializes a PostProcessRenderPipeline
  48948. * @param engine engine to add the pipeline to
  48949. * @param name name of the pipeline
  48950. */
  48951. constructor(engine: Engine, name: string);
  48952. /**
  48953. * "PostProcessRenderPipeline"
  48954. * @returns "PostProcessRenderPipeline"
  48955. */
  48956. getClassName(): string;
  48957. /**
  48958. * If all the render effects in the pipeline are support
  48959. */
  48960. readonly isSupported: boolean;
  48961. /**
  48962. * Adds an effect to the pipeline
  48963. * @param renderEffect the effect to add
  48964. */
  48965. addEffect(renderEffect: PostProcessRenderEffect): void;
  48966. /** @hidden */
  48967. _rebuild(): void;
  48968. /** @hidden */
  48969. _enableEffect(renderEffectName: string, cameras: Camera): void;
  48970. /** @hidden */
  48971. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  48972. /** @hidden */
  48973. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  48974. /** @hidden */
  48975. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  48976. /** @hidden */
  48977. _attachCameras(cameras: Camera, unique: boolean): void;
  48978. /** @hidden */
  48979. _attachCameras(cameras: Camera[], unique: boolean): void;
  48980. /** @hidden */
  48981. _detachCameras(cameras: Camera): void;
  48982. /** @hidden */
  48983. _detachCameras(cameras: Nullable<Camera[]>): void;
  48984. /** @hidden */
  48985. _update(): void;
  48986. /** @hidden */
  48987. _reset(): void;
  48988. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  48989. /**
  48990. * Disposes of the pipeline
  48991. */
  48992. dispose(): void;
  48993. }
  48994. }
  48995. declare module BABYLON {
  48996. /**
  48997. * PostProcessRenderPipelineManager class
  48998. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48999. */
  49000. class PostProcessRenderPipelineManager {
  49001. private _renderPipelines;
  49002. /**
  49003. * Initializes a PostProcessRenderPipelineManager
  49004. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49005. */
  49006. constructor();
  49007. /**
  49008. * Adds a pipeline to the manager
  49009. * @param renderPipeline The pipeline to add
  49010. */
  49011. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  49012. /**
  49013. * Attaches a camera to the pipeline
  49014. * @param renderPipelineName The name of the pipeline to attach to
  49015. * @param cameras the camera to attach
  49016. * @param unique if the camera can be attached multiple times to the pipeline
  49017. */
  49018. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  49019. /**
  49020. * Detaches a camera from the pipeline
  49021. * @param renderPipelineName The name of the pipeline to detach from
  49022. * @param cameras the camera to detach
  49023. */
  49024. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  49025. /**
  49026. * Enables an effect by name on a pipeline
  49027. * @param renderPipelineName the name of the pipeline to enable the effect in
  49028. * @param renderEffectName the name of the effect to enable
  49029. * @param cameras the cameras that the effect should be enabled on
  49030. */
  49031. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49032. /**
  49033. * Disables an effect by name on a pipeline
  49034. * @param renderPipelineName the name of the pipeline to disable the effect in
  49035. * @param renderEffectName the name of the effect to disable
  49036. * @param cameras the cameras that the effect should be disabled on
  49037. */
  49038. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49039. /**
  49040. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  49041. */
  49042. update(): void;
  49043. /** @hidden */
  49044. _rebuild(): void;
  49045. /**
  49046. * Disposes of the manager and pipelines
  49047. */
  49048. dispose(): void;
  49049. }
  49050. }
  49051. declare module BABYLON {
  49052. interface Scene {
  49053. /** @hidden (Backing field) */
  49054. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49055. /**
  49056. * Gets the postprocess render pipeline manager
  49057. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49058. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49059. */
  49060. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49061. }
  49062. /**
  49063. * Defines the Render Pipeline scene component responsible to rendering pipelines
  49064. */
  49065. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  49066. /**
  49067. * The component name helpfull to identify the component in the list of scene components.
  49068. */
  49069. readonly name: string;
  49070. /**
  49071. * The scene the component belongs to.
  49072. */
  49073. scene: Scene;
  49074. /**
  49075. * Creates a new instance of the component for the given scene
  49076. * @param scene Defines the scene to register the component in
  49077. */
  49078. constructor(scene: Scene);
  49079. /**
  49080. * Registers the component in a given scene
  49081. */
  49082. register(): void;
  49083. /**
  49084. * Rebuilds the elements related to this component in case of
  49085. * context lost for instance.
  49086. */
  49087. rebuild(): void;
  49088. /**
  49089. * Disposes the component and the associated ressources
  49090. */
  49091. dispose(): void;
  49092. private _gatherRenderTargets;
  49093. }
  49094. }
  49095. declare module BABYLON {
  49096. /**
  49097. * Helper class dealing with the extraction of spherical polynomial dataArray
  49098. * from a cube map.
  49099. */
  49100. class CubeMapToSphericalPolynomialTools {
  49101. private static FileFaces;
  49102. /**
  49103. * Converts a texture to the according Spherical Polynomial data.
  49104. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49105. *
  49106. * @param texture The texture to extract the information from.
  49107. * @return The Spherical Polynomial data.
  49108. */
  49109. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49110. /**
  49111. * Converts a cubemap to the according Spherical Polynomial data.
  49112. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49113. *
  49114. * @param cubeInfo The Cube map to extract the information from.
  49115. * @return The Spherical Polynomial data.
  49116. */
  49117. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49118. }
  49119. }
  49120. declare module BABYLON {
  49121. /**
  49122. * Header information of HDR texture files.
  49123. */
  49124. interface HDRInfo {
  49125. /**
  49126. * The height of the texture in pixels.
  49127. */
  49128. height: number;
  49129. /**
  49130. * The width of the texture in pixels.
  49131. */
  49132. width: number;
  49133. /**
  49134. * The index of the beginning of the data in the binary file.
  49135. */
  49136. dataPosition: number;
  49137. }
  49138. /**
  49139. * This groups tools to convert HDR texture to native colors array.
  49140. */
  49141. class HDRTools {
  49142. private static Ldexp;
  49143. private static Rgbe2float;
  49144. private static readStringLine;
  49145. /**
  49146. * Reads header information from an RGBE texture stored in a native array.
  49147. * More information on this format are available here:
  49148. * https://en.wikipedia.org/wiki/RGBE_image_format
  49149. *
  49150. * @param uint8array The binary file stored in native array.
  49151. * @return The header information.
  49152. */
  49153. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49154. /**
  49155. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49156. * This RGBE texture needs to store the information as a panorama.
  49157. *
  49158. * More information on this format are available here:
  49159. * https://en.wikipedia.org/wiki/RGBE_image_format
  49160. *
  49161. * @param buffer The binary file stored in an array buffer.
  49162. * @param size The expected size of the extracted cubemap.
  49163. * @return The Cube Map information.
  49164. */
  49165. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49166. /**
  49167. * Returns the pixels data extracted from an RGBE texture.
  49168. * This pixels will be stored left to right up to down in the R G B order in one array.
  49169. *
  49170. * More information on this format are available here:
  49171. * https://en.wikipedia.org/wiki/RGBE_image_format
  49172. *
  49173. * @param uint8array The binary file stored in an array buffer.
  49174. * @param hdrInfo The header information of the file.
  49175. * @return The pixels data in RGB right to left up to down order.
  49176. */
  49177. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49178. private static RGBE_ReadPixels_RLE;
  49179. }
  49180. }
  49181. declare module BABYLON {
  49182. /**
  49183. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49184. */
  49185. interface CubeMapInfo {
  49186. /**
  49187. * The pixel array for the front face.
  49188. * This is stored in format, left to right, up to down format.
  49189. */
  49190. front: Nullable<ArrayBufferView>;
  49191. /**
  49192. * The pixel array for the back face.
  49193. * This is stored in format, left to right, up to down format.
  49194. */
  49195. back: Nullable<ArrayBufferView>;
  49196. /**
  49197. * The pixel array for the left face.
  49198. * This is stored in format, left to right, up to down format.
  49199. */
  49200. left: Nullable<ArrayBufferView>;
  49201. /**
  49202. * The pixel array for the right face.
  49203. * This is stored in format, left to right, up to down format.
  49204. */
  49205. right: Nullable<ArrayBufferView>;
  49206. /**
  49207. * The pixel array for the up face.
  49208. * This is stored in format, left to right, up to down format.
  49209. */
  49210. up: Nullable<ArrayBufferView>;
  49211. /**
  49212. * The pixel array for the down face.
  49213. * This is stored in format, left to right, up to down format.
  49214. */
  49215. down: Nullable<ArrayBufferView>;
  49216. /**
  49217. * The size of the cubemap stored.
  49218. *
  49219. * Each faces will be size * size pixels.
  49220. */
  49221. size: number;
  49222. /**
  49223. * The format of the texture.
  49224. *
  49225. * RGBA, RGB.
  49226. */
  49227. format: number;
  49228. /**
  49229. * The type of the texture data.
  49230. *
  49231. * UNSIGNED_INT, FLOAT.
  49232. */
  49233. type: number;
  49234. /**
  49235. * Specifies whether the texture is in gamma space.
  49236. */
  49237. gammaSpace: boolean;
  49238. }
  49239. /**
  49240. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  49241. */
  49242. class PanoramaToCubeMapTools {
  49243. private static FACE_FRONT;
  49244. private static FACE_BACK;
  49245. private static FACE_RIGHT;
  49246. private static FACE_LEFT;
  49247. private static FACE_DOWN;
  49248. private static FACE_UP;
  49249. /**
  49250. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49251. *
  49252. * @param float32Array The source data.
  49253. * @param inputWidth The width of the input panorama.
  49254. * @param inputHeight The height of the input panorama.
  49255. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49256. * @return The cubemap data
  49257. */
  49258. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49259. private static CreateCubemapTexture;
  49260. private static CalcProjectionSpherical;
  49261. }
  49262. }
  49263. declare module BABYLON {
  49264. }
  49265. declare module BABYLON {
  49266. }
  49267. declare module BABYLON {
  49268. }
  49269. declare module BABYLON {
  49270. }
  49271. declare module BABYLON {
  49272. /**
  49273. * 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.
  49274. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49275. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49276. */
  49277. class CustomProceduralTexture extends ProceduralTexture {
  49278. private _animate;
  49279. private _time;
  49280. private _config;
  49281. private _texturePath;
  49282. /**
  49283. * Instantiates a new Custom Procedural Texture.
  49284. * 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.
  49285. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49286. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49287. * @param name Define the name of the texture
  49288. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49289. * @param size Define the size of the texture to create
  49290. * @param scene Define the scene the texture belongs to
  49291. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49292. * @param generateMipMaps Define if the texture should creates mip maps or not
  49293. */
  49294. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49295. private _loadJson;
  49296. /**
  49297. * Is the texture ready to be used ? (rendered at least once)
  49298. * @returns true if ready, otherwise, false.
  49299. */
  49300. isReady(): boolean;
  49301. /**
  49302. * Render the texture to its associated render target.
  49303. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49304. */
  49305. render(useCameraPostProcess?: boolean): void;
  49306. /**
  49307. * Update the list of dependant textures samplers in the shader.
  49308. */
  49309. updateTextures(): void;
  49310. /**
  49311. * Update the uniform values of the procedural texture in the shader.
  49312. */
  49313. updateShaderUniforms(): void;
  49314. /**
  49315. * Define if the texture animates or not.
  49316. */
  49317. animate: boolean;
  49318. }
  49319. }
  49320. declare module BABYLON {
  49321. /**
  49322. * Class used to generate noise procedural textures
  49323. */
  49324. class NoiseProceduralTexture extends ProceduralTexture {
  49325. private _time;
  49326. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49327. brightness: number;
  49328. /** Defines the number of octaves to process */
  49329. octaves: number;
  49330. /** Defines the level of persistence (0.8 by default) */
  49331. persistence: number;
  49332. /** Gets or sets animation speed factor (default is 1) */
  49333. animationSpeedFactor: number;
  49334. /**
  49335. * Creates a new NoiseProceduralTexture
  49336. * @param name defines the name fo the texture
  49337. * @param size defines the size of the texture (default is 256)
  49338. * @param scene defines the hosting scene
  49339. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49340. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49341. */
  49342. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49343. private _updateShaderUniforms;
  49344. protected _getDefines(): string;
  49345. /** Generate the current state of the procedural texture */
  49346. render(useCameraPostProcess?: boolean): void;
  49347. /**
  49348. * Serializes this noise procedural texture
  49349. * @returns a serialized noise procedural texture object
  49350. */
  49351. serialize(): any;
  49352. /**
  49353. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49354. * @param parsedTexture defines parsed texture data
  49355. * @param scene defines the current scene
  49356. * @param rootUrl defines the root URL containing noise procedural texture information
  49357. * @returns a parsed NoiseProceduralTexture
  49358. */
  49359. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  49360. }
  49361. }
  49362. declare module BABYLON {
  49363. /**
  49364. * 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.
  49365. * This is the base class of any Procedural texture and contains most of the shareable code.
  49366. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49367. */
  49368. class ProceduralTexture extends Texture {
  49369. isCube: boolean;
  49370. /**
  49371. * Define if the texture is enabled or not (disabled texture will not render)
  49372. */
  49373. isEnabled: boolean;
  49374. /**
  49375. * Define if the texture must be cleared before rendering (default is true)
  49376. */
  49377. autoClear: boolean;
  49378. /**
  49379. * Callback called when the texture is generated
  49380. */
  49381. onGenerated: () => void;
  49382. /**
  49383. * Event raised when the texture is generated
  49384. */
  49385. onGeneratedObservable: Observable<ProceduralTexture>;
  49386. /** @hidden */
  49387. _generateMipMaps: boolean;
  49388. /** @hidden **/
  49389. _effect: Effect;
  49390. /** @hidden */
  49391. _textures: {
  49392. [key: string]: Texture;
  49393. };
  49394. private _size;
  49395. private _currentRefreshId;
  49396. private _refreshRate;
  49397. private _vertexBuffers;
  49398. private _indexBuffer;
  49399. private _uniforms;
  49400. private _samplers;
  49401. private _fragment;
  49402. private _floats;
  49403. private _ints;
  49404. private _floatsArrays;
  49405. private _colors3;
  49406. private _colors4;
  49407. private _vectors2;
  49408. private _vectors3;
  49409. private _matrices;
  49410. private _fallbackTexture;
  49411. private _fallbackTextureUsed;
  49412. private _engine;
  49413. private _cachedDefines;
  49414. private _contentUpdateId;
  49415. private _contentData;
  49416. /**
  49417. * Instantiates a new procedural texture.
  49418. * 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.
  49419. * This is the base class of any Procedural texture and contains most of the shareable code.
  49420. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49421. * @param name Define the name of the texture
  49422. * @param size Define the size of the texture to create
  49423. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  49424. * @param scene Define the scene the texture belongs to
  49425. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49426. * @param generateMipMaps Define if the texture should creates mip maps or not
  49427. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  49428. */
  49429. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  49430. /**
  49431. * The effect that is created when initializing the post process.
  49432. * @returns The created effect corrisponding the the postprocess.
  49433. */
  49434. getEffect(): Effect;
  49435. /**
  49436. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  49437. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  49438. */
  49439. getContent(): Nullable<ArrayBufferView>;
  49440. private _createIndexBuffer;
  49441. /** @hidden */
  49442. _rebuild(): void;
  49443. /**
  49444. * Resets the texture in order to recreate its associated resources.
  49445. * This can be called in case of context loss
  49446. */
  49447. reset(): void;
  49448. protected _getDefines(): string;
  49449. /**
  49450. * Is the texture ready to be used ? (rendered at least once)
  49451. * @returns true if ready, otherwise, false.
  49452. */
  49453. isReady(): boolean;
  49454. /**
  49455. * Resets the refresh counter of the texture and start bak from scratch.
  49456. * Could be usefull to regenerate the texture if it is setup to render only once.
  49457. */
  49458. resetRefreshCounter(): void;
  49459. /**
  49460. * Set the fragment shader to use in order to render the texture.
  49461. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  49462. */
  49463. setFragment(fragment: any): void;
  49464. /**
  49465. * Define the refresh rate of the texture or the rendering frequency.
  49466. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  49467. */
  49468. refreshRate: number;
  49469. /** @hidden */
  49470. _shouldRender(): boolean;
  49471. /**
  49472. * Get the size the texture is rendering at.
  49473. * @returns the size (texture is always squared)
  49474. */
  49475. getRenderSize(): number;
  49476. /**
  49477. * Resize the texture to new value.
  49478. * @param size Define the new size the texture should have
  49479. * @param generateMipMaps Define whether the new texture should create mip maps
  49480. */
  49481. resize(size: number, generateMipMaps: boolean): void;
  49482. private _checkUniform;
  49483. /**
  49484. * Set a texture in the shader program used to render.
  49485. * @param name Define the name of the uniform samplers as defined in the shader
  49486. * @param texture Define the texture to bind to this sampler
  49487. * @return the texture itself allowing "fluent" like uniform updates
  49488. */
  49489. setTexture(name: string, texture: Texture): ProceduralTexture;
  49490. /**
  49491. * Set a float in the shader.
  49492. * @param name Define the name of the uniform as defined in the shader
  49493. * @param value Define the value to give to the uniform
  49494. * @return the texture itself allowing "fluent" like uniform updates
  49495. */
  49496. setFloat(name: string, value: number): ProceduralTexture;
  49497. /**
  49498. * Set a int in the shader.
  49499. * @param name Define the name of the uniform as defined in the shader
  49500. * @param value Define the value to give to the uniform
  49501. * @return the texture itself allowing "fluent" like uniform updates
  49502. */
  49503. setInt(name: string, value: number): ProceduralTexture;
  49504. /**
  49505. * Set an array of floats in the shader.
  49506. * @param name Define the name of the uniform as defined in the shader
  49507. * @param value Define the value to give to the uniform
  49508. * @return the texture itself allowing "fluent" like uniform updates
  49509. */
  49510. setFloats(name: string, value: number[]): ProceduralTexture;
  49511. /**
  49512. * Set a vec3 in the shader from a Color3.
  49513. * @param name Define the name of the uniform as defined in the shader
  49514. * @param value Define the value to give to the uniform
  49515. * @return the texture itself allowing "fluent" like uniform updates
  49516. */
  49517. setColor3(name: string, value: Color3): ProceduralTexture;
  49518. /**
  49519. * Set a vec4 in the shader from a Color4.
  49520. * @param name Define the name of the uniform as defined in the shader
  49521. * @param value Define the value to give to the uniform
  49522. * @return the texture itself allowing "fluent" like uniform updates
  49523. */
  49524. setColor4(name: string, value: Color4): ProceduralTexture;
  49525. /**
  49526. * Set a vec2 in the shader from a Vector2.
  49527. * @param name Define the name of the uniform as defined in the shader
  49528. * @param value Define the value to give to the uniform
  49529. * @return the texture itself allowing "fluent" like uniform updates
  49530. */
  49531. setVector2(name: string, value: Vector2): ProceduralTexture;
  49532. /**
  49533. * Set a vec3 in the shader from a Vector3.
  49534. * @param name Define the name of the uniform as defined in the shader
  49535. * @param value Define the value to give to the uniform
  49536. * @return the texture itself allowing "fluent" like uniform updates
  49537. */
  49538. setVector3(name: string, value: Vector3): ProceduralTexture;
  49539. /**
  49540. * Set a mat4 in the shader from a MAtrix.
  49541. * @param name Define the name of the uniform as defined in the shader
  49542. * @param value Define the value to give to the uniform
  49543. * @return the texture itself allowing "fluent" like uniform updates
  49544. */
  49545. setMatrix(name: string, value: Matrix): ProceduralTexture;
  49546. /**
  49547. * Render the texture to its associated render target.
  49548. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49549. */
  49550. render(useCameraPostProcess?: boolean): void;
  49551. /**
  49552. * Clone the texture.
  49553. * @returns the cloned texture
  49554. */
  49555. clone(): ProceduralTexture;
  49556. /**
  49557. * Dispose the texture and release its asoociated resources.
  49558. */
  49559. dispose(): void;
  49560. }
  49561. }
  49562. declare module BABYLON {
  49563. interface AbstractScene {
  49564. /**
  49565. * The list of procedural textures added to the scene
  49566. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49567. */
  49568. proceduralTextures: Array<ProceduralTexture>;
  49569. }
  49570. /**
  49571. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  49572. * in a given scene.
  49573. */
  49574. class ProceduralTextureSceneComponent implements ISceneComponent {
  49575. /**
  49576. * The component name helpfull to identify the component in the list of scene components.
  49577. */
  49578. readonly name: string;
  49579. /**
  49580. * The scene the component belongs to.
  49581. */
  49582. scene: Scene;
  49583. /**
  49584. * Creates a new instance of the component for the given scene
  49585. * @param scene Defines the scene to register the component in
  49586. */
  49587. constructor(scene: Scene);
  49588. /**
  49589. * Registers the component in a given scene
  49590. */
  49591. register(): void;
  49592. /**
  49593. * Rebuilds the elements related to this component in case of
  49594. * context lost for instance.
  49595. */
  49596. rebuild(): void;
  49597. /**
  49598. * Disposes the component and the associated ressources.
  49599. */
  49600. dispose(): void;
  49601. private _beforeClear;
  49602. }
  49603. }
  49604. declare module BABYLON {
  49605. /**
  49606. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  49607. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49608. */
  49609. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49610. private _scene;
  49611. private _camerasToBeAttached;
  49612. /**
  49613. * ID of the sharpen post process,
  49614. */
  49615. private readonly SharpenPostProcessId;
  49616. /**
  49617. * @ignore
  49618. * ID of the image processing post process;
  49619. */
  49620. readonly ImageProcessingPostProcessId: string;
  49621. /**
  49622. * @ignore
  49623. * ID of the Fast Approximate Anti-Aliasing post process;
  49624. */
  49625. readonly FxaaPostProcessId: string;
  49626. /**
  49627. * ID of the chromatic aberration post process,
  49628. */
  49629. private readonly ChromaticAberrationPostProcessId;
  49630. /**
  49631. * ID of the grain post process
  49632. */
  49633. private readonly GrainPostProcessId;
  49634. /**
  49635. * Sharpen post process which will apply a sharpen convolution to enhance edges
  49636. */
  49637. sharpen: SharpenPostProcess;
  49638. private _sharpenEffect;
  49639. private bloom;
  49640. /**
  49641. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  49642. */
  49643. depthOfField: DepthOfFieldEffect;
  49644. /**
  49645. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49646. */
  49647. fxaa: FxaaPostProcess;
  49648. /**
  49649. * Image post processing pass used to perform operations such as tone mapping or color grading.
  49650. */
  49651. imageProcessing: ImageProcessingPostProcess;
  49652. /**
  49653. * Chromatic aberration post process which will shift rgb colors in the image
  49654. */
  49655. chromaticAberration: ChromaticAberrationPostProcess;
  49656. private _chromaticAberrationEffect;
  49657. /**
  49658. * Grain post process which add noise to the image
  49659. */
  49660. grain: GrainPostProcess;
  49661. private _grainEffect;
  49662. /**
  49663. * Glow post process which adds a glow to emmisive areas of the image
  49664. */
  49665. private _glowLayer;
  49666. /**
  49667. * Animations which can be used to tweak settings over a period of time
  49668. */
  49669. animations: Animation[];
  49670. private _imageProcessingConfigurationObserver;
  49671. private _sharpenEnabled;
  49672. private _bloomEnabled;
  49673. private _depthOfFieldEnabled;
  49674. private _depthOfFieldBlurLevel;
  49675. private _fxaaEnabled;
  49676. private _imageProcessingEnabled;
  49677. private _defaultPipelineTextureType;
  49678. private _bloomScale;
  49679. private _chromaticAberrationEnabled;
  49680. private _grainEnabled;
  49681. private _buildAllowed;
  49682. /**
  49683. * Enable or disable the sharpen process from the pipeline
  49684. */
  49685. sharpenEnabled: boolean;
  49686. private _resizeObserver;
  49687. private _hardwareScaleLevel;
  49688. private _bloomKernel;
  49689. /**
  49690. * Specifies the size of the bloom blur kernel, relative to the final output size
  49691. */
  49692. bloomKernel: number;
  49693. /**
  49694. * Specifies the weight of the bloom in the final rendering
  49695. */
  49696. private _bloomWeight;
  49697. /**
  49698. * Specifies the luma threshold for the area that will be blurred by the bloom
  49699. */
  49700. private _bloomThreshold;
  49701. private _hdr;
  49702. /**
  49703. * The strength of the bloom.
  49704. */
  49705. bloomWeight: number;
  49706. /**
  49707. * The strength of the bloom.
  49708. */
  49709. bloomThreshold: number;
  49710. /**
  49711. * The scale of the bloom, lower value will provide better performance.
  49712. */
  49713. bloomScale: number;
  49714. /**
  49715. * Enable or disable the bloom from the pipeline
  49716. */
  49717. bloomEnabled: boolean;
  49718. private _rebuildBloom;
  49719. /**
  49720. * If the depth of field is enabled.
  49721. */
  49722. depthOfFieldEnabled: boolean;
  49723. /**
  49724. * Blur level of the depth of field effect. (Higher blur will effect performance)
  49725. */
  49726. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  49727. /**
  49728. * If the anti aliasing is enabled.
  49729. */
  49730. fxaaEnabled: boolean;
  49731. private _samples;
  49732. /**
  49733. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49734. */
  49735. samples: number;
  49736. /**
  49737. * If image processing is enabled.
  49738. */
  49739. imageProcessingEnabled: boolean;
  49740. /**
  49741. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  49742. */
  49743. glowLayerEnabled: boolean;
  49744. /**
  49745. * Enable or disable the chromaticAberration process from the pipeline
  49746. */
  49747. chromaticAberrationEnabled: boolean;
  49748. /**
  49749. * Enable or disable the grain process from the pipeline
  49750. */
  49751. grainEnabled: boolean;
  49752. /**
  49753. * @constructor
  49754. * @param name - The rendering pipeline name (default: "")
  49755. * @param hdr - If high dynamic range textures should be used (default: true)
  49756. * @param scene - The scene linked to this pipeline (default: the last created scene)
  49757. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  49758. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  49759. */
  49760. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  49761. /**
  49762. * Force the compilation of the entire pipeline.
  49763. */
  49764. prepare(): void;
  49765. private _hasCleared;
  49766. private _prevPostProcess;
  49767. private _prevPrevPostProcess;
  49768. private _setAutoClearAndTextureSharing;
  49769. private _depthOfFieldSceneObserver;
  49770. private _buildPipeline;
  49771. private _disposePostProcesses;
  49772. /**
  49773. * Adds a camera to the pipeline
  49774. * @param camera the camera to be added
  49775. */
  49776. addCamera(camera: Camera): void;
  49777. /**
  49778. * Removes a camera from the pipeline
  49779. * @param camera the camera to remove
  49780. */
  49781. removeCamera(camera: Camera): void;
  49782. /**
  49783. * Dispose of the pipeline and stop all post processes
  49784. */
  49785. dispose(): void;
  49786. /**
  49787. * Serialize the rendering pipeline (Used when exporting)
  49788. * @returns the serialized object
  49789. */
  49790. serialize(): any;
  49791. /**
  49792. * Parse the serialized pipeline
  49793. * @param source Source pipeline.
  49794. * @param scene The scene to load the pipeline to.
  49795. * @param rootUrl The URL of the serialized pipeline.
  49796. * @returns An instantiated pipeline from the serialized object.
  49797. */
  49798. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  49799. }
  49800. }
  49801. declare module BABYLON {
  49802. /**
  49803. * BABYLON.JS Chromatic Aberration GLSL Shader
  49804. * Author: Olivier Guyot
  49805. * Separates very slightly R, G and B colors on the edges of the screen
  49806. * Inspired by Francois Tarlier & Martins Upitis
  49807. */
  49808. class LensRenderingPipeline extends PostProcessRenderPipeline {
  49809. /**
  49810. * @ignore
  49811. * The chromatic aberration PostProcess id in the pipeline
  49812. */
  49813. LensChromaticAberrationEffect: string;
  49814. /**
  49815. * @ignore
  49816. * The highlights enhancing PostProcess id in the pipeline
  49817. */
  49818. HighlightsEnhancingEffect: string;
  49819. /**
  49820. * @ignore
  49821. * The depth-of-field PostProcess id in the pipeline
  49822. */
  49823. LensDepthOfFieldEffect: string;
  49824. private _scene;
  49825. private _depthTexture;
  49826. private _grainTexture;
  49827. private _chromaticAberrationPostProcess;
  49828. private _highlightsPostProcess;
  49829. private _depthOfFieldPostProcess;
  49830. private _edgeBlur;
  49831. private _grainAmount;
  49832. private _chromaticAberration;
  49833. private _distortion;
  49834. private _highlightsGain;
  49835. private _highlightsThreshold;
  49836. private _dofDistance;
  49837. private _dofAperture;
  49838. private _dofDarken;
  49839. private _dofPentagon;
  49840. private _blurNoise;
  49841. /**
  49842. * @constructor
  49843. *
  49844. * Effect parameters are as follow:
  49845. * {
  49846. * chromatic_aberration: number; // from 0 to x (1 for realism)
  49847. * edge_blur: number; // from 0 to x (1 for realism)
  49848. * distortion: number; // from 0 to x (1 for realism)
  49849. * grain_amount: number; // from 0 to 1
  49850. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  49851. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  49852. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  49853. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  49854. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  49855. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  49856. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  49857. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  49858. * }
  49859. * Note: if an effect parameter is unset, effect is disabled
  49860. *
  49861. * @param name The rendering pipeline name
  49862. * @param parameters - An object containing all parameters (see above)
  49863. * @param scene The scene linked to this pipeline
  49864. * @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)
  49865. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49866. */
  49867. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  49868. /**
  49869. * Sets the amount of blur at the edges
  49870. * @param amount blur amount
  49871. */
  49872. setEdgeBlur(amount: number): void;
  49873. /**
  49874. * Sets edge blur to 0
  49875. */
  49876. disableEdgeBlur(): void;
  49877. /**
  49878. * Sets the amout of grain
  49879. * @param amount Amount of grain
  49880. */
  49881. setGrainAmount(amount: number): void;
  49882. /**
  49883. * Set grain amount to 0
  49884. */
  49885. disableGrain(): void;
  49886. /**
  49887. * Sets the chromatic aberration amount
  49888. * @param amount amount of chromatic aberration
  49889. */
  49890. setChromaticAberration(amount: number): void;
  49891. /**
  49892. * Sets chromatic aberration amount to 0
  49893. */
  49894. disableChromaticAberration(): void;
  49895. /**
  49896. * Sets the EdgeDistortion amount
  49897. * @param amount amount of EdgeDistortion
  49898. */
  49899. setEdgeDistortion(amount: number): void;
  49900. /**
  49901. * Sets edge distortion to 0
  49902. */
  49903. disableEdgeDistortion(): void;
  49904. /**
  49905. * Sets the FocusDistance amount
  49906. * @param amount amount of FocusDistance
  49907. */
  49908. setFocusDistance(amount: number): void;
  49909. /**
  49910. * Disables depth of field
  49911. */
  49912. disableDepthOfField(): void;
  49913. /**
  49914. * Sets the Aperture amount
  49915. * @param amount amount of Aperture
  49916. */
  49917. setAperture(amount: number): void;
  49918. /**
  49919. * Sets the DarkenOutOfFocus amount
  49920. * @param amount amount of DarkenOutOfFocus
  49921. */
  49922. setDarkenOutOfFocus(amount: number): void;
  49923. /**
  49924. * Creates a pentagon bokeh effect
  49925. */
  49926. enablePentagonBokeh(): void;
  49927. /**
  49928. * Disables the pentagon bokeh effect
  49929. */
  49930. disablePentagonBokeh(): void;
  49931. /**
  49932. * Enables noise blur
  49933. */
  49934. enableNoiseBlur(): void;
  49935. /**
  49936. * Disables noise blur
  49937. */
  49938. disableNoiseBlur(): void;
  49939. /**
  49940. * Sets the HighlightsGain amount
  49941. * @param amount amount of HighlightsGain
  49942. */
  49943. setHighlightsGain(amount: number): void;
  49944. /**
  49945. * Sets the HighlightsThreshold amount
  49946. * @param amount amount of HighlightsThreshold
  49947. */
  49948. setHighlightsThreshold(amount: number): void;
  49949. /**
  49950. * Disables highlights
  49951. */
  49952. disableHighlights(): void;
  49953. /**
  49954. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  49955. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  49956. */
  49957. dispose(disableDepthRender?: boolean): void;
  49958. private _createChromaticAberrationPostProcess;
  49959. private _createHighlightsPostProcess;
  49960. private _createDepthOfFieldPostProcess;
  49961. private _createGrainTexture;
  49962. }
  49963. }
  49964. declare module BABYLON {
  49965. /**
  49966. * Render pipeline to produce ssao effect
  49967. */
  49968. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  49969. /**
  49970. * @ignore
  49971. * The PassPostProcess id in the pipeline that contains the original scene color
  49972. */
  49973. SSAOOriginalSceneColorEffect: string;
  49974. /**
  49975. * @ignore
  49976. * The SSAO PostProcess id in the pipeline
  49977. */
  49978. SSAORenderEffect: string;
  49979. /**
  49980. * @ignore
  49981. * The horizontal blur PostProcess id in the pipeline
  49982. */
  49983. SSAOBlurHRenderEffect: string;
  49984. /**
  49985. * @ignore
  49986. * The vertical blur PostProcess id in the pipeline
  49987. */
  49988. SSAOBlurVRenderEffect: string;
  49989. /**
  49990. * @ignore
  49991. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  49992. */
  49993. SSAOCombineRenderEffect: string;
  49994. /**
  49995. * The output strength of the SSAO post-process. Default value is 1.0.
  49996. */
  49997. totalStrength: number;
  49998. /**
  49999. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50000. */
  50001. maxZ: number;
  50002. /**
  50003. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50004. */
  50005. minZAspect: number;
  50006. private _samples;
  50007. /**
  50008. * Number of samples used for the SSAO calculations. Default value is 8
  50009. */
  50010. samples: number;
  50011. private _textureSamples;
  50012. /**
  50013. * Number of samples to use for antialiasing
  50014. */
  50015. textureSamples: number;
  50016. /**
  50017. * Ratio object used for SSAO ratio and blur ratio
  50018. */
  50019. private _ratio;
  50020. /**
  50021. * Dynamically generated sphere sampler.
  50022. */
  50023. private _sampleSphere;
  50024. /**
  50025. * Blur filter offsets
  50026. */
  50027. private _samplerOffsets;
  50028. private _expensiveBlur;
  50029. /**
  50030. * If bilateral blur should be used
  50031. */
  50032. expensiveBlur: boolean;
  50033. /**
  50034. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50035. */
  50036. radius: number;
  50037. /**
  50038. * The base color of the SSAO post-process
  50039. * The final result is "base + ssao" between [0, 1]
  50040. */
  50041. base: number;
  50042. /**
  50043. * Support test.
  50044. */
  50045. static readonly IsSupported: boolean;
  50046. private _scene;
  50047. private _depthTexture;
  50048. private _normalTexture;
  50049. private _randomTexture;
  50050. private _originalColorPostProcess;
  50051. private _ssaoPostProcess;
  50052. private _blurHPostProcess;
  50053. private _blurVPostProcess;
  50054. private _ssaoCombinePostProcess;
  50055. private _firstUpdate;
  50056. /**
  50057. * @constructor
  50058. * @param name The rendering pipeline name
  50059. * @param scene The scene linked to this pipeline
  50060. * @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 }
  50061. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50062. */
  50063. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50064. /**
  50065. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50066. */
  50067. dispose(disableGeometryBufferRenderer?: boolean): void;
  50068. private _createBlurPostProcess;
  50069. /** @hidden */
  50070. _rebuild(): void;
  50071. private _bits;
  50072. private _radicalInverse_VdC;
  50073. private _hammersley;
  50074. private _hemisphereSample_uniform;
  50075. private _generateHemisphere;
  50076. private _createSSAOPostProcess;
  50077. private _createSSAOCombinePostProcess;
  50078. private _createRandomTexture;
  50079. /**
  50080. * Serialize the rendering pipeline (Used when exporting)
  50081. * @returns the serialized object
  50082. */
  50083. serialize(): any;
  50084. /**
  50085. * Parse the serialized pipeline
  50086. * @param source Source pipeline.
  50087. * @param scene The scene to load the pipeline to.
  50088. * @param rootUrl The URL of the serialized pipeline.
  50089. * @returns An instantiated pipeline from the serialized object.
  50090. */
  50091. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50092. }
  50093. }
  50094. declare module BABYLON {
  50095. /**
  50096. * Render pipeline to produce ssao effect
  50097. */
  50098. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50099. /**
  50100. * @ignore
  50101. * The PassPostProcess id in the pipeline that contains the original scene color
  50102. */
  50103. SSAOOriginalSceneColorEffect: string;
  50104. /**
  50105. * @ignore
  50106. * The SSAO PostProcess id in the pipeline
  50107. */
  50108. SSAORenderEffect: string;
  50109. /**
  50110. * @ignore
  50111. * The horizontal blur PostProcess id in the pipeline
  50112. */
  50113. SSAOBlurHRenderEffect: string;
  50114. /**
  50115. * @ignore
  50116. * The vertical blur PostProcess id in the pipeline
  50117. */
  50118. SSAOBlurVRenderEffect: string;
  50119. /**
  50120. * @ignore
  50121. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50122. */
  50123. SSAOCombineRenderEffect: string;
  50124. /**
  50125. * The output strength of the SSAO post-process. Default value is 1.0.
  50126. */
  50127. totalStrength: number;
  50128. /**
  50129. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50130. */
  50131. radius: number;
  50132. /**
  50133. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50134. * Must not be equal to fallOff and superior to fallOff.
  50135. * Default value is 0.975
  50136. */
  50137. area: number;
  50138. /**
  50139. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50140. * Must not be equal to area and inferior to area.
  50141. * Default value is 0.0
  50142. */
  50143. fallOff: number;
  50144. /**
  50145. * The base color of the SSAO post-process
  50146. * The final result is "base + ssao" between [0, 1]
  50147. */
  50148. base: number;
  50149. private _scene;
  50150. private _depthTexture;
  50151. private _randomTexture;
  50152. private _originalColorPostProcess;
  50153. private _ssaoPostProcess;
  50154. private _blurHPostProcess;
  50155. private _blurVPostProcess;
  50156. private _ssaoCombinePostProcess;
  50157. private _firstUpdate;
  50158. /**
  50159. * @constructor
  50160. * @param name - The rendering pipeline name
  50161. * @param scene - The scene linked to this pipeline
  50162. * @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 }
  50163. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50164. */
  50165. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50166. /**
  50167. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50168. */
  50169. dispose(disableDepthRender?: boolean): void;
  50170. private _createBlurPostProcess;
  50171. /** @hidden */
  50172. _rebuild(): void;
  50173. private _createSSAOPostProcess;
  50174. private _createSSAOCombinePostProcess;
  50175. private _createRandomTexture;
  50176. }
  50177. }
  50178. declare module BABYLON {
  50179. /**
  50180. * Standard rendering pipeline
  50181. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50182. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50183. */
  50184. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50185. /**
  50186. * Public members
  50187. */
  50188. /**
  50189. * Post-process which contains the original scene color before the pipeline applies all the effects
  50190. */
  50191. originalPostProcess: Nullable<PostProcess>;
  50192. /**
  50193. * Post-process used to down scale an image x4
  50194. */
  50195. downSampleX4PostProcess: Nullable<PostProcess>;
  50196. /**
  50197. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50198. */
  50199. brightPassPostProcess: Nullable<PostProcess>;
  50200. /**
  50201. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50202. */
  50203. blurHPostProcesses: PostProcess[];
  50204. /**
  50205. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50206. */
  50207. blurVPostProcesses: PostProcess[];
  50208. /**
  50209. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50210. */
  50211. textureAdderPostProcess: Nullable<PostProcess>;
  50212. /**
  50213. * Post-process used to create volumetric lighting effect
  50214. */
  50215. volumetricLightPostProcess: Nullable<PostProcess>;
  50216. /**
  50217. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50218. */
  50219. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50220. /**
  50221. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50222. */
  50223. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50224. /**
  50225. * Post-process used to merge the volumetric light effect and the real scene color
  50226. */
  50227. volumetricLightMergePostProces: Nullable<PostProcess>;
  50228. /**
  50229. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50230. */
  50231. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50232. /**
  50233. * Base post-process used to calculate the average luminance of the final image for HDR
  50234. */
  50235. luminancePostProcess: Nullable<PostProcess>;
  50236. /**
  50237. * Post-processes used to create down sample post-processes in order to get
  50238. * the average luminance of the final image for HDR
  50239. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50240. */
  50241. luminanceDownSamplePostProcesses: PostProcess[];
  50242. /**
  50243. * Post-process used to create a HDR effect (light adaptation)
  50244. */
  50245. hdrPostProcess: Nullable<PostProcess>;
  50246. /**
  50247. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  50248. */
  50249. textureAdderFinalPostProcess: Nullable<PostProcess>;
  50250. /**
  50251. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  50252. */
  50253. lensFlareFinalPostProcess: Nullable<PostProcess>;
  50254. /**
  50255. * Post-process used to merge the final HDR post-process and the real scene color
  50256. */
  50257. hdrFinalPostProcess: Nullable<PostProcess>;
  50258. /**
  50259. * Post-process used to create a lens flare effect
  50260. */
  50261. lensFlarePostProcess: Nullable<PostProcess>;
  50262. /**
  50263. * Post-process that merges the result of the lens flare post-process and the real scene color
  50264. */
  50265. lensFlareComposePostProcess: Nullable<PostProcess>;
  50266. /**
  50267. * Post-process used to create a motion blur effect
  50268. */
  50269. motionBlurPostProcess: Nullable<PostProcess>;
  50270. /**
  50271. * Post-process used to create a depth of field effect
  50272. */
  50273. depthOfFieldPostProcess: Nullable<PostProcess>;
  50274. /**
  50275. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50276. */
  50277. fxaaPostProcess: Nullable<FxaaPostProcess>;
  50278. /**
  50279. * Represents the brightness threshold in order to configure the illuminated surfaces
  50280. */
  50281. brightThreshold: number;
  50282. /**
  50283. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  50284. */
  50285. blurWidth: number;
  50286. /**
  50287. * Sets if the blur for highlighted surfaces must be only horizontal
  50288. */
  50289. horizontalBlur: boolean;
  50290. /**
  50291. * Sets the overall exposure used by the pipeline
  50292. */
  50293. exposure: number;
  50294. /**
  50295. * Texture used typically to simulate "dirty" on camera lens
  50296. */
  50297. lensTexture: Nullable<Texture>;
  50298. /**
  50299. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  50300. */
  50301. volumetricLightCoefficient: number;
  50302. /**
  50303. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  50304. */
  50305. volumetricLightPower: number;
  50306. /**
  50307. * Used the set the blur intensity to smooth the volumetric lights
  50308. */
  50309. volumetricLightBlurScale: number;
  50310. /**
  50311. * Light (spot or directional) used to generate the volumetric lights rays
  50312. * The source light must have a shadow generate so the pipeline can get its
  50313. * depth map
  50314. */
  50315. sourceLight: Nullable<SpotLight | DirectionalLight>;
  50316. /**
  50317. * For eye adaptation, represents the minimum luminance the eye can see
  50318. */
  50319. hdrMinimumLuminance: number;
  50320. /**
  50321. * For eye adaptation, represents the decrease luminance speed
  50322. */
  50323. hdrDecreaseRate: number;
  50324. /**
  50325. * For eye adaptation, represents the increase luminance speed
  50326. */
  50327. hdrIncreaseRate: number;
  50328. /**
  50329. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  50330. */
  50331. lensColorTexture: Nullable<Texture>;
  50332. /**
  50333. * The overall strengh for the lens flare effect
  50334. */
  50335. lensFlareStrength: number;
  50336. /**
  50337. * Dispersion coefficient for lens flare ghosts
  50338. */
  50339. lensFlareGhostDispersal: number;
  50340. /**
  50341. * Main lens flare halo width
  50342. */
  50343. lensFlareHaloWidth: number;
  50344. /**
  50345. * Based on the lens distortion effect, defines how much the lens flare result
  50346. * is distorted
  50347. */
  50348. lensFlareDistortionStrength: number;
  50349. /**
  50350. * Lens star texture must be used to simulate rays on the flares and is available
  50351. * in the documentation
  50352. */
  50353. lensStarTexture: Nullable<Texture>;
  50354. /**
  50355. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  50356. * flare effect by taking account of the dirt texture
  50357. */
  50358. lensFlareDirtTexture: Nullable<Texture>;
  50359. /**
  50360. * Represents the focal length for the depth of field effect
  50361. */
  50362. depthOfFieldDistance: number;
  50363. /**
  50364. * Represents the blur intensity for the blurred part of the depth of field effect
  50365. */
  50366. depthOfFieldBlurWidth: number;
  50367. /**
  50368. * For motion blur, defines how much the image is blurred by the movement
  50369. */
  50370. motionStrength: number;
  50371. /**
  50372. * List of animations for the pipeline (IAnimatable implementation)
  50373. */
  50374. animations: Animation[];
  50375. /**
  50376. * Private members
  50377. */
  50378. private _scene;
  50379. private _currentDepthOfFieldSource;
  50380. private _basePostProcess;
  50381. private _hdrCurrentLuminance;
  50382. private _floatTextureType;
  50383. private _ratio;
  50384. private _bloomEnabled;
  50385. private _depthOfFieldEnabled;
  50386. private _vlsEnabled;
  50387. private _lensFlareEnabled;
  50388. private _hdrEnabled;
  50389. private _motionBlurEnabled;
  50390. private _fxaaEnabled;
  50391. private _motionBlurSamples;
  50392. private _volumetricLightStepsCount;
  50393. private _samples;
  50394. /**
  50395. * @ignore
  50396. * Specifies if the bloom pipeline is enabled
  50397. */
  50398. BloomEnabled: boolean;
  50399. /**
  50400. * @ignore
  50401. * Specifies if the depth of field pipeline is enabed
  50402. */
  50403. DepthOfFieldEnabled: boolean;
  50404. /**
  50405. * @ignore
  50406. * Specifies if the lens flare pipeline is enabed
  50407. */
  50408. LensFlareEnabled: boolean;
  50409. /**
  50410. * @ignore
  50411. * Specifies if the HDR pipeline is enabled
  50412. */
  50413. HDREnabled: boolean;
  50414. /**
  50415. * @ignore
  50416. * Specifies if the volumetric lights scattering effect is enabled
  50417. */
  50418. VLSEnabled: boolean;
  50419. /**
  50420. * @ignore
  50421. * Specifies if the motion blur effect is enabled
  50422. */
  50423. MotionBlurEnabled: boolean;
  50424. /**
  50425. * Specifies if anti-aliasing is enabled
  50426. */
  50427. fxaaEnabled: boolean;
  50428. /**
  50429. * Specifies the number of steps used to calculate the volumetric lights
  50430. * Typically in interval [50, 200]
  50431. */
  50432. volumetricLightStepsCount: number;
  50433. /**
  50434. * Specifies the number of samples used for the motion blur effect
  50435. * Typically in interval [16, 64]
  50436. */
  50437. motionBlurSamples: number;
  50438. /**
  50439. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50440. */
  50441. samples: number;
  50442. /**
  50443. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50444. * @constructor
  50445. * @param name The rendering pipeline name
  50446. * @param scene The scene linked to this pipeline
  50447. * @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)
  50448. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  50449. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50450. */
  50451. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  50452. private _buildPipeline;
  50453. private _createDownSampleX4PostProcess;
  50454. private _createBrightPassPostProcess;
  50455. private _createBlurPostProcesses;
  50456. private _createTextureAdderPostProcess;
  50457. private _createVolumetricLightPostProcess;
  50458. private _createLuminancePostProcesses;
  50459. private _createHdrPostProcess;
  50460. private _createLensFlarePostProcess;
  50461. private _createDepthOfFieldPostProcess;
  50462. private _createMotionBlurPostProcess;
  50463. private _getDepthTexture;
  50464. private _disposePostProcesses;
  50465. /**
  50466. * Dispose of the pipeline and stop all post processes
  50467. */
  50468. dispose(): void;
  50469. /**
  50470. * Serialize the rendering pipeline (Used when exporting)
  50471. * @returns the serialized object
  50472. */
  50473. serialize(): any;
  50474. /**
  50475. * Parse the serialized pipeline
  50476. * @param source Source pipeline.
  50477. * @param scene The scene to load the pipeline to.
  50478. * @param rootUrl The URL of the serialized pipeline.
  50479. * @returns An instantiated pipeline from the serialized object.
  50480. */
  50481. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  50482. /**
  50483. * Luminance steps
  50484. */
  50485. static LuminanceSteps: number;
  50486. }
  50487. }