babylon.d.ts 2.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291
  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. /**
  165. * Disposes all the assets in the container
  166. */
  167. dispose(): void;
  168. private _moveAssets;
  169. /**
  170. * Removes all the assets contained in the scene and adds them to the container.
  171. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  172. */
  173. moveAllFromScene(keepAssets?: KeepAssets): void;
  174. /**
  175. * 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.
  176. * @returns the root mesh
  177. */
  178. createRootMesh(): Mesh;
  179. }
  180. }
  181. interface Window {
  182. mozIndexedDB: IDBFactory;
  183. webkitIndexedDB: IDBFactory;
  184. msIndexedDB: IDBFactory;
  185. webkitURL: typeof URL;
  186. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  187. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  188. WebGLRenderingContext: WebGLRenderingContext;
  189. MSGesture: MSGesture;
  190. CANNON: any;
  191. AudioContext: AudioContext;
  192. webkitAudioContext: AudioContext;
  193. PointerEvent: any;
  194. Math: Math;
  195. Uint8Array: Uint8ArrayConstructor;
  196. Float32Array: Float32ArrayConstructor;
  197. mozURL: typeof URL;
  198. msURL: typeof URL;
  199. VRFrameData: any;
  200. DracoDecoderModule: any;
  201. setImmediate(handler: (...args: any[]) => void): number;
  202. }
  203. interface WebGLProgram {
  204. context?: WebGLRenderingContext;
  205. vertexShader?: WebGLShader;
  206. fragmentShader?: WebGLShader;
  207. isParallelCompiled: boolean;
  208. onCompiled?: () => void;
  209. }
  210. interface WebGLRenderingContext {
  211. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  212. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  213. vertexAttribDivisor(index: number, divisor: number): void;
  214. createVertexArray(): any;
  215. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  216. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  217. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  218. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  219. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  220. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  221. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  222. createQuery(): WebGLQuery;
  223. deleteQuery(query: WebGLQuery): void;
  224. beginQuery(target: number, query: WebGLQuery): void;
  225. endQuery(target: number): void;
  226. getQueryParameter(query: WebGLQuery, pname: number): any;
  227. getQuery(target: number, pname: number): any;
  228. MAX_SAMPLES: number;
  229. RGBA8: number;
  230. READ_FRAMEBUFFER: number;
  231. DRAW_FRAMEBUFFER: number;
  232. UNIFORM_BUFFER: number;
  233. HALF_FLOAT_OES: number;
  234. RGBA16F: number;
  235. RGBA32F: number;
  236. R32F: number;
  237. RG32F: number;
  238. RGB32F: number;
  239. R16F: number;
  240. RG16F: number;
  241. RGB16F: number;
  242. RED: number;
  243. RG: number;
  244. R8: number;
  245. RG8: number;
  246. UNSIGNED_INT_24_8: number;
  247. DEPTH24_STENCIL8: number;
  248. drawBuffers(buffers: number[]): void;
  249. readBuffer(src: number): void;
  250. readonly COLOR_ATTACHMENT0: number;
  251. readonly COLOR_ATTACHMENT1: number;
  252. readonly COLOR_ATTACHMENT2: number;
  253. readonly COLOR_ATTACHMENT3: number;
  254. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  255. ANY_SAMPLES_PASSED: number;
  256. QUERY_RESULT_AVAILABLE: number;
  257. QUERY_RESULT: number;
  258. }
  259. interface Document {
  260. mozCancelFullScreen(): void;
  261. msCancelFullScreen(): void;
  262. webkitCancelFullScreen(): void;
  263. requestPointerLock(): void;
  264. exitPointerLock(): void;
  265. mozFullScreen: boolean;
  266. msIsFullScreen: boolean;
  267. readonly webkitIsFullScreen: boolean;
  268. readonly pointerLockElement: Element;
  269. mozPointerLockElement: HTMLElement;
  270. msPointerLockElement: HTMLElement;
  271. webkitPointerLockElement: HTMLElement;
  272. }
  273. interface HTMLCanvasElement {
  274. requestPointerLock(): void;
  275. msRequestPointerLock?(): void;
  276. mozRequestPointerLock?(): void;
  277. webkitRequestPointerLock?(): void;
  278. }
  279. interface CanvasRenderingContext2D {
  280. msImageSmoothingEnabled: boolean;
  281. }
  282. interface WebGLBuffer {
  283. references: number;
  284. capacity: number;
  285. is32Bits: boolean;
  286. }
  287. interface WebGLProgram {
  288. transformFeedback?: WebGLTransformFeedback | null;
  289. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  290. }
  291. interface MouseEvent {
  292. mozMovementX: number;
  293. mozMovementY: number;
  294. webkitMovementX: number;
  295. webkitMovementY: number;
  296. msMovementX: number;
  297. msMovementY: number;
  298. }
  299. interface Navigator {
  300. mozGetVRDevices: (any: any) => any;
  301. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  302. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  303. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  304. webkitGetGamepads(): Gamepad[];
  305. msGetGamepads(): Gamepad[];
  306. webkitGamepads(): Gamepad[];
  307. }
  308. interface HTMLVideoElement {
  309. mozSrcObject: any;
  310. }
  311. interface Math {
  312. fround(x: number): number;
  313. imul(a: number, b: number): number;
  314. }
  315. interface EXT_disjoint_timer_query {
  316. QUERY_COUNTER_BITS_EXT: number;
  317. TIME_ELAPSED_EXT: number;
  318. TIMESTAMP_EXT: number;
  319. GPU_DISJOINT_EXT: number;
  320. QUERY_RESULT_EXT: number;
  321. QUERY_RESULT_AVAILABLE_EXT: number;
  322. queryCounterEXT(query: WebGLQuery, target: number): void;
  323. createQueryEXT(): WebGLQuery;
  324. beginQueryEXT(target: number, query: WebGLQuery): void;
  325. endQueryEXT(target: number): void;
  326. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  327. deleteQueryEXT(query: WebGLQuery): void;
  328. }
  329. interface WebGLUniformLocation {
  330. _currentState: any;
  331. }
  332. interface XRDevice {
  333. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  334. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  335. }
  336. interface XRSession {
  337. getInputSources(): Array<any>;
  338. baseLayer: XRWebGLLayer;
  339. requestFrameOfReference(type: string): Promise<void>;
  340. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  341. end(): Promise<void>;
  342. requestAnimationFrame: Function;
  343. addEventListener: Function;
  344. }
  345. interface XRSessionCreationOptions {
  346. outputContext?: WebGLRenderingContext | null;
  347. immersive?: boolean;
  348. environmentIntegration?: boolean;
  349. }
  350. interface XRLayer {
  351. getViewport: Function;
  352. framebufferWidth: number;
  353. framebufferHeight: number;
  354. }
  355. interface XRView {
  356. projectionMatrix: Float32Array;
  357. }
  358. interface XRFrame {
  359. getDevicePose: Function;
  360. getInputPose: Function;
  361. views: Array<XRView>;
  362. baseLayer: XRLayer;
  363. }
  364. interface XRFrameOfReference {
  365. }
  366. interface XRWebGLLayer extends XRLayer {
  367. framebuffer: WebGLFramebuffer;
  368. }
  369. declare var XRWebGLLayer: {
  370. prototype: XRWebGLLayer;
  371. new (session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  372. };
  373. declare module BABYLON {
  374. /**
  375. * Defines how a node can be built from a string name.
  376. */
  377. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  378. /**
  379. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  380. */
  381. class Node implements IBehaviorAware<Node> {
  382. private static _NodeConstructors;
  383. /**
  384. * Add a new node constructor
  385. * @param type defines the type name of the node to construct
  386. * @param constructorFunc defines the constructor function
  387. */
  388. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  389. /**
  390. * Returns a node constructor based on type name
  391. * @param type defines the type name
  392. * @param name defines the new node name
  393. * @param scene defines the hosting scene
  394. * @param options defines optional options to transmit to constructors
  395. * @returns the new constructor or null
  396. */
  397. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  398. /**
  399. * Gets or sets the name of the node
  400. */
  401. name: string;
  402. /**
  403. * Gets or sets the id of the node
  404. */
  405. id: string;
  406. /**
  407. * Gets or sets the unique id of the node
  408. */
  409. uniqueId: number;
  410. /**
  411. * Gets or sets a string used to store user defined state for the node
  412. */
  413. state: string;
  414. /**
  415. * Gets or sets an object used to store user defined information for the node
  416. */
  417. metadata: any;
  418. /**
  419. * For internal use only. Please do not use.
  420. */
  421. reservedDataStore: any;
  422. /**
  423. * Gets or sets a boolean used to define if the node must be serialized
  424. */
  425. doNotSerialize: boolean;
  426. /** @hidden */
  427. _isDisposed: boolean;
  428. /**
  429. * Gets a list of Animations associated with the node
  430. */
  431. animations: Animation[];
  432. protected _ranges: {
  433. [name: string]: Nullable<AnimationRange>;
  434. };
  435. /**
  436. * Callback raised when the node is ready to be used
  437. */
  438. onReady: (node: Node) => void;
  439. private _isEnabled;
  440. private _isParentEnabled;
  441. private _isReady;
  442. /** @hidden */
  443. _currentRenderId: number;
  444. private _parentRenderId;
  445. protected _childRenderId: number;
  446. /** @hidden */
  447. _waitingParentId: Nullable<string>;
  448. /** @hidden */
  449. _scene: Scene;
  450. /** @hidden */
  451. _cache: any;
  452. private _parentNode;
  453. private _children;
  454. /** @hidden */
  455. _worldMatrix: Matrix;
  456. /** @hidden */
  457. _worldMatrixDeterminant: number;
  458. /** @hidden */
  459. private _sceneRootNodesIndex;
  460. /**
  461. * Gets a boolean indicating if the node has been disposed
  462. * @returns true if the node was disposed
  463. */
  464. isDisposed(): boolean;
  465. /**
  466. * Gets or sets the parent of the node
  467. */
  468. parent: Nullable<Node>;
  469. private addToSceneRootNodes;
  470. private removeFromSceneRootNodes;
  471. private _animationPropertiesOverride;
  472. /**
  473. * Gets or sets the animation properties override
  474. */
  475. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  476. /**
  477. * Gets a string idenfifying the name of the class
  478. * @returns "Node" string
  479. */
  480. getClassName(): string;
  481. /**
  482. * An event triggered when the mesh is disposed
  483. */
  484. onDisposeObservable: Observable<Node>;
  485. private _onDisposeObserver;
  486. /**
  487. * Sets a callback that will be raised when the node will be disposed
  488. */
  489. onDispose: () => void;
  490. /**
  491. * Creates a new Node
  492. * @param name the name and id to be given to this node
  493. * @param scene the scene this node will be added to
  494. * @param addToRootNodes the node will be added to scene.rootNodes
  495. */
  496. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  497. /**
  498. * Gets the scene of the node
  499. * @returns a scene
  500. */
  501. getScene(): Scene;
  502. /**
  503. * Gets the engine of the node
  504. * @returns a Engine
  505. */
  506. getEngine(): Engine;
  507. private _behaviors;
  508. /**
  509. * Attach a behavior to the node
  510. * @see http://doc.babylonjs.com/features/behaviour
  511. * @param behavior defines the behavior to attach
  512. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  513. * @returns the current Node
  514. */
  515. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  516. /**
  517. * Remove an attached behavior
  518. * @see http://doc.babylonjs.com/features/behaviour
  519. * @param behavior defines the behavior to attach
  520. * @returns the current Node
  521. */
  522. removeBehavior(behavior: Behavior<Node>): Node;
  523. /**
  524. * Gets the list of attached behaviors
  525. * @see http://doc.babylonjs.com/features/behaviour
  526. */
  527. readonly behaviors: Behavior<Node>[];
  528. /**
  529. * Gets an attached behavior by name
  530. * @param name defines the name of the behavior to look for
  531. * @see http://doc.babylonjs.com/features/behaviour
  532. * @returns null if behavior was not found else the requested behavior
  533. */
  534. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  535. /**
  536. * Returns the latest update of the World matrix
  537. * @returns a Matrix
  538. */
  539. getWorldMatrix(): Matrix;
  540. /** @hidden */
  541. _getWorldMatrixDeterminant(): number;
  542. /**
  543. * Returns directly the latest state of the mesh World matrix.
  544. * A Matrix is returned.
  545. */
  546. readonly worldMatrixFromCache: Matrix;
  547. /** @hidden */
  548. _initCache(): void;
  549. /** @hidden */
  550. updateCache(force?: boolean): void;
  551. /** @hidden */
  552. _updateCache(ignoreParentClass?: boolean): void;
  553. /** @hidden */
  554. _isSynchronized(): boolean;
  555. /** @hidden */
  556. _markSyncedWithParent(): void;
  557. /** @hidden */
  558. isSynchronizedWithParent(): boolean;
  559. /** @hidden */
  560. isSynchronized(): boolean;
  561. /**
  562. * Is this node ready to be used/rendered
  563. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  564. * @return true if the node is ready
  565. */
  566. isReady(completeCheck?: boolean): boolean;
  567. /**
  568. * Is this node enabled?
  569. * 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
  570. * @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
  571. * @return whether this node (and its parent) is enabled
  572. */
  573. isEnabled(checkAncestors?: boolean): boolean;
  574. /** @hidden */
  575. protected _syncParentEnabledState(): void;
  576. /**
  577. * Set the enabled state of this node
  578. * @param value defines the new enabled state
  579. */
  580. setEnabled(value: boolean): void;
  581. /**
  582. * Is this node a descendant of the given node?
  583. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  584. * @param ancestor defines the parent node to inspect
  585. * @returns a boolean indicating if this node is a descendant of the given node
  586. */
  587. isDescendantOf(ancestor: Node): boolean;
  588. /** @hidden */
  589. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  590. /**
  591. * Will return all nodes that have this node as ascendant
  592. * @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
  593. * @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
  594. * @return all children nodes of all types
  595. */
  596. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  597. /**
  598. * Get all child-meshes of this node
  599. * @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
  600. * @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
  601. * @returns an array of AbstractMesh
  602. */
  603. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  604. /**
  605. * Get all child-transformNodes of this node
  606. * @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
  607. * @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
  608. * @returns an array of TransformNode
  609. */
  610. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  611. /**
  612. * Get all direct children of this node
  613. * @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
  614. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  615. * @returns an array of Node
  616. */
  617. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  618. /** @hidden */
  619. _setReady(state: boolean): void;
  620. /**
  621. * Get an animation by name
  622. * @param name defines the name of the animation to look for
  623. * @returns null if not found else the requested animation
  624. */
  625. getAnimationByName(name: string): Nullable<Animation>;
  626. /**
  627. * Creates an animation range for this node
  628. * @param name defines the name of the range
  629. * @param from defines the starting key
  630. * @param to defines the end key
  631. */
  632. createAnimationRange(name: string, from: number, to: number): void;
  633. /**
  634. * Delete a specific animation range
  635. * @param name defines the name of the range to delete
  636. * @param deleteFrames defines if animation frames from the range must be deleted as well
  637. */
  638. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  639. /**
  640. * Get an animation range by name
  641. * @param name defines the name of the animation range to look for
  642. * @returns null if not found else the requested animation range
  643. */
  644. getAnimationRange(name: string): Nullable<AnimationRange>;
  645. /**
  646. * Will start the animation sequence
  647. * @param name defines the range frames for animation sequence
  648. * @param loop defines if the animation should loop (false by default)
  649. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  650. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  651. * @returns the object created for this animation. If range does not exist, it will return null
  652. */
  653. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  654. /**
  655. * Serialize animation ranges into a JSON compatible object
  656. * @returns serialization object
  657. */
  658. serializeAnimationRanges(): any;
  659. /**
  660. * Computes the world matrix of the node
  661. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  662. * @returns the world matrix
  663. */
  664. computeWorldMatrix(force?: boolean): Matrix;
  665. /**
  666. * Releases resources associated with this node.
  667. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  668. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  669. */
  670. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  671. /**
  672. * Parse animation range data from a serialization object and store them into a given node
  673. * @param node defines where to store the animation ranges
  674. * @param parsedNode defines the serialization object to read data from
  675. * @param scene defines the hosting scene
  676. */
  677. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  678. }
  679. }
  680. declare module BABYLON {
  681. /**
  682. * Define an interface for all classes that will hold resources
  683. */
  684. interface IDisposable {
  685. /**
  686. * Releases all held resources
  687. */
  688. dispose(): void;
  689. }
  690. /**
  691. * This class is used by the onRenderingGroupObservable
  692. */
  693. class RenderingGroupInfo {
  694. /**
  695. * The Scene that being rendered
  696. */
  697. scene: Scene;
  698. /**
  699. * The camera currently used for the rendering pass
  700. */
  701. camera: Nullable<Camera>;
  702. /**
  703. * The ID of the renderingGroup being processed
  704. */
  705. renderingGroupId: number;
  706. }
  707. /** Interface defining initialization parameters for Scene class */
  708. interface SceneOptions {
  709. /**
  710. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  711. * It will improve performance when the number of geometries becomes important.
  712. */
  713. useGeometryIdsMap?: boolean;
  714. /**
  715. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  716. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  717. */
  718. useMaterialMeshMap?: boolean;
  719. /**
  720. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  721. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  722. */
  723. useClonedMeshhMap?: boolean;
  724. }
  725. /**
  726. * Represents a scene to be rendered by the engine.
  727. * @see http://doc.babylonjs.com/features/scene
  728. */
  729. class Scene extends AbstractScene implements IAnimatable {
  730. private static _uniqueIdCounter;
  731. /** The fog is deactivated */
  732. static readonly FOGMODE_NONE: number;
  733. /** The fog density is following an exponential function */
  734. static readonly FOGMODE_EXP: number;
  735. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  736. static readonly FOGMODE_EXP2: number;
  737. /** The fog density is following a linear function. */
  738. static readonly FOGMODE_LINEAR: number;
  739. /**
  740. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  741. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  742. */
  743. static MinDeltaTime: number;
  744. /**
  745. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  746. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  747. */
  748. static MaxDeltaTime: number;
  749. /**
  750. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  751. */
  752. autoClear: boolean;
  753. /**
  754. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  755. */
  756. autoClearDepthAndStencil: boolean;
  757. /**
  758. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  759. */
  760. clearColor: Color4;
  761. /**
  762. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  763. */
  764. ambientColor: Color3;
  765. /** @hidden */
  766. _environmentBRDFTexture: BaseTexture;
  767. /** @hidden */
  768. protected _environmentTexture: Nullable<BaseTexture>;
  769. /**
  770. * Texture used in all pbr material as the reflection texture.
  771. * As in the majority of the scene they are the same (exception for multi room and so on),
  772. * this is easier to reference from here than from all the materials.
  773. */
  774. /**
  775. * Texture used in all pbr material as the reflection texture.
  776. * As in the majority of the scene they are the same (exception for multi room and so on),
  777. * this is easier to set here than in all the materials.
  778. */
  779. environmentTexture: Nullable<BaseTexture>;
  780. /** @hidden */
  781. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  782. /**
  783. * Default image processing configuration used either in the rendering
  784. * Forward main pass or through the imageProcessingPostProcess if present.
  785. * As in the majority of the scene they are the same (exception for multi camera),
  786. * this is easier to reference from here than from all the materials and post process.
  787. *
  788. * No setter as we it is a shared configuration, you can set the values instead.
  789. */
  790. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  791. private _forceWireframe;
  792. /**
  793. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  794. */
  795. forceWireframe: boolean;
  796. private _forcePointsCloud;
  797. /**
  798. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  799. */
  800. forcePointsCloud: boolean;
  801. /**
  802. * Gets or sets the active clipplane 1
  803. */
  804. clipPlane: Nullable<Plane>;
  805. /**
  806. * Gets or sets the active clipplane 2
  807. */
  808. clipPlane2: Nullable<Plane>;
  809. /**
  810. * Gets or sets the active clipplane 3
  811. */
  812. clipPlane3: Nullable<Plane>;
  813. /**
  814. * Gets or sets the active clipplane 4
  815. */
  816. clipPlane4: Nullable<Plane>;
  817. /**
  818. * Gets or sets a boolean indicating if animations are enabled
  819. */
  820. animationsEnabled: boolean;
  821. private _animationPropertiesOverride;
  822. /**
  823. * Gets or sets the animation properties override
  824. */
  825. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  826. /**
  827. * Gets or sets a boolean indicating if a constant deltatime has to be used
  828. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  829. */
  830. useConstantAnimationDeltaTime: boolean;
  831. /**
  832. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  833. * Please note that it requires to run a ray cast through the scene on every frame
  834. */
  835. constantlyUpdateMeshUnderPointer: boolean;
  836. /**
  837. * Defines the HTML cursor to use when hovering over interactive elements
  838. */
  839. hoverCursor: string;
  840. /**
  841. * Defines the HTML default cursor to use (empty by default)
  842. */
  843. defaultCursor: string;
  844. /**
  845. * This is used to call preventDefault() on pointer down
  846. * in order to block unwanted artifacts like system double clicks
  847. */
  848. preventDefaultOnPointerDown: boolean;
  849. /**
  850. * This is used to call preventDefault() on pointer up
  851. * in order to block unwanted artifacts like system double clicks
  852. */
  853. preventDefaultOnPointerUp: boolean;
  854. /**
  855. * Gets or sets user defined metadata
  856. */
  857. metadata: any;
  858. /**
  859. * For internal use only. Please do not use.
  860. */
  861. reservedDataStore: any;
  862. /**
  863. * Gets the name of the plugin used to load this scene (null by default)
  864. */
  865. loadingPluginName: string;
  866. /**
  867. * Use this array to add regular expressions used to disable offline support for specific urls
  868. */
  869. disableOfflineSupportExceptionRules: RegExp[];
  870. /**
  871. * An event triggered when the scene is disposed.
  872. */
  873. onDisposeObservable: Observable<Scene>;
  874. private _onDisposeObserver;
  875. /** Sets a function to be executed when this scene is disposed. */
  876. onDispose: () => void;
  877. /**
  878. * An event triggered before rendering the scene (right after animations and physics)
  879. */
  880. onBeforeRenderObservable: Observable<Scene>;
  881. private _onBeforeRenderObserver;
  882. /** Sets a function to be executed before rendering this scene */
  883. beforeRender: Nullable<() => void>;
  884. /**
  885. * An event triggered after rendering the scene
  886. */
  887. onAfterRenderObservable: Observable<Scene>;
  888. private _onAfterRenderObserver;
  889. /** Sets a function to be executed after rendering this scene */
  890. afterRender: Nullable<() => void>;
  891. /**
  892. * An event triggered before animating the scene
  893. */
  894. onBeforeAnimationsObservable: Observable<Scene>;
  895. /**
  896. * An event triggered after animations processing
  897. */
  898. onAfterAnimationsObservable: Observable<Scene>;
  899. /**
  900. * An event triggered before draw calls are ready to be sent
  901. */
  902. onBeforeDrawPhaseObservable: Observable<Scene>;
  903. /**
  904. * An event triggered after draw calls have been sent
  905. */
  906. onAfterDrawPhaseObservable: Observable<Scene>;
  907. /**
  908. * An event triggered when the scene is ready
  909. */
  910. onReadyObservable: Observable<Scene>;
  911. /**
  912. * An event triggered before rendering a camera
  913. */
  914. onBeforeCameraRenderObservable: Observable<Camera>;
  915. private _onBeforeCameraRenderObserver;
  916. /** Sets a function to be executed before rendering a camera*/
  917. beforeCameraRender: () => void;
  918. /**
  919. * An event triggered after rendering a camera
  920. */
  921. onAfterCameraRenderObservable: Observable<Camera>;
  922. private _onAfterCameraRenderObserver;
  923. /** Sets a function to be executed after rendering a camera*/
  924. afterCameraRender: () => void;
  925. /**
  926. * An event triggered when active meshes evaluation is about to start
  927. */
  928. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  929. /**
  930. * An event triggered when active meshes evaluation is done
  931. */
  932. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  933. /**
  934. * An event triggered when particles rendering is about to start
  935. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  936. */
  937. onBeforeParticlesRenderingObservable: Observable<Scene>;
  938. /**
  939. * An event triggered when particles rendering is done
  940. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  941. */
  942. onAfterParticlesRenderingObservable: Observable<Scene>;
  943. /**
  944. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  945. */
  946. onDataLoadedObservable: Observable<Scene>;
  947. /**
  948. * An event triggered when a camera is created
  949. */
  950. onNewCameraAddedObservable: Observable<Camera>;
  951. /**
  952. * An event triggered when a camera is removed
  953. */
  954. onCameraRemovedObservable: Observable<Camera>;
  955. /**
  956. * An event triggered when a light is created
  957. */
  958. onNewLightAddedObservable: Observable<Light>;
  959. /**
  960. * An event triggered when a light is removed
  961. */
  962. onLightRemovedObservable: Observable<Light>;
  963. /**
  964. * An event triggered when a geometry is created
  965. */
  966. onNewGeometryAddedObservable: Observable<Geometry>;
  967. /**
  968. * An event triggered when a geometry is removed
  969. */
  970. onGeometryRemovedObservable: Observable<Geometry>;
  971. /**
  972. * An event triggered when a transform node is created
  973. */
  974. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  975. /**
  976. * An event triggered when a transform node is removed
  977. */
  978. onTransformNodeRemovedObservable: Observable<TransformNode>;
  979. /**
  980. * An event triggered when a mesh is created
  981. */
  982. onNewMeshAddedObservable: Observable<AbstractMesh>;
  983. /**
  984. * An event triggered when a mesh is removed
  985. */
  986. onMeshRemovedObservable: Observable<AbstractMesh>;
  987. /**
  988. * An event triggered when a material is created
  989. */
  990. onNewMaterialAddedObservable: Observable<Material>;
  991. /**
  992. * An event triggered when a material is removed
  993. */
  994. onMaterialRemovedObservable: Observable<Material>;
  995. /**
  996. * An event triggered when a texture is created
  997. */
  998. onNewTextureAddedObservable: Observable<BaseTexture>;
  999. /**
  1000. * An event triggered when a texture is removed
  1001. */
  1002. onTextureRemovedObservable: Observable<BaseTexture>;
  1003. /**
  1004. * An event triggered when render targets are about to be rendered
  1005. * Can happen multiple times per frame.
  1006. */
  1007. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  1008. /**
  1009. * An event triggered when render targets were rendered.
  1010. * Can happen multiple times per frame.
  1011. */
  1012. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  1013. /**
  1014. * An event triggered before calculating deterministic simulation step
  1015. */
  1016. onBeforeStepObservable: Observable<Scene>;
  1017. /**
  1018. * An event triggered after calculating deterministic simulation step
  1019. */
  1020. onAfterStepObservable: Observable<Scene>;
  1021. /**
  1022. * An event triggered when the activeCamera property is updated
  1023. */
  1024. onActiveCameraChanged: Observable<Scene>;
  1025. /**
  1026. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  1027. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1028. * 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)
  1029. */
  1030. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1031. /**
  1032. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  1033. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1034. * 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)
  1035. */
  1036. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1037. /**
  1038. * This Observable will when a mesh has been imported into the scene.
  1039. */
  1040. onMeshImportedObservable: Observable<AbstractMesh>;
  1041. private _registeredForLateAnimationBindings;
  1042. /**
  1043. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  1044. */
  1045. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  1046. /**
  1047. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  1048. */
  1049. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  1050. /**
  1051. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  1052. */
  1053. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  1054. private _onPointerMove;
  1055. private _onPointerDown;
  1056. private _onPointerUp;
  1057. /** Callback called when a pointer move is detected */
  1058. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1059. /** Callback called when a pointer down is detected */
  1060. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1061. /** Callback called when a pointer up is detected */
  1062. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  1063. /** Callback called when a pointer pick is detected */
  1064. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  1065. /**
  1066. * 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).
  1067. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  1068. */
  1069. onPrePointerObservable: Observable<PointerInfoPre>;
  1070. /**
  1071. * Observable event triggered each time an input event is received from the rendering canvas
  1072. */
  1073. onPointerObservable: Observable<PointerInfo>;
  1074. /**
  1075. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1076. */
  1077. readonly unTranslatedPointer: Vector2;
  1078. /** The distance in pixel that you have to move to prevent some events */
  1079. static DragMovementThreshold: number;
  1080. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1081. static LongPressDelay: number;
  1082. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1083. static DoubleClickDelay: number;
  1084. /** If you need to check double click without raising a single click at first click, enable this flag */
  1085. static ExclusiveDoubleClickMode: boolean;
  1086. private _initClickEvent;
  1087. private _initActionManager;
  1088. private _delayedSimpleClick;
  1089. private _delayedSimpleClickTimeout;
  1090. private _previousDelayedSimpleClickTimeout;
  1091. private _meshPickProceed;
  1092. private _previousButtonPressed;
  1093. private _currentPickResult;
  1094. private _previousPickResult;
  1095. private _totalPointersPressed;
  1096. private _doubleClickOccured;
  1097. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1098. cameraToUseForPointers: Nullable<Camera>;
  1099. private _pointerX;
  1100. private _pointerY;
  1101. private _unTranslatedPointerX;
  1102. private _unTranslatedPointerY;
  1103. private _startingPointerPosition;
  1104. private _previousStartingPointerPosition;
  1105. private _startingPointerTime;
  1106. private _previousStartingPointerTime;
  1107. private _pointerCaptures;
  1108. private _timeAccumulator;
  1109. private _currentStepId;
  1110. private _currentInternalStep;
  1111. /** @hidden */
  1112. _mirroredCameraPosition: Nullable<Vector3>;
  1113. /**
  1114. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1115. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1116. */
  1117. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1118. /**
  1119. * Observable event triggered each time an keyboard event is received from the hosting window
  1120. */
  1121. onKeyboardObservable: Observable<KeyboardInfo>;
  1122. private _onKeyDown;
  1123. private _onKeyUp;
  1124. private _onCanvasFocusObserver;
  1125. private _onCanvasBlurObserver;
  1126. private _useRightHandedSystem;
  1127. /**
  1128. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1129. */
  1130. useRightHandedSystem: boolean;
  1131. /**
  1132. * Sets the step Id used by deterministic lock step
  1133. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1134. * @param newStepId defines the step Id
  1135. */
  1136. setStepId(newStepId: number): void;
  1137. /**
  1138. * Gets the step Id used by deterministic lock step
  1139. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1140. * @returns the step Id
  1141. */
  1142. getStepId(): number;
  1143. /**
  1144. * Gets the internal step used by deterministic lock step
  1145. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1146. * @returns the internal step
  1147. */
  1148. getInternalStep(): number;
  1149. private _fogEnabled;
  1150. /**
  1151. * Gets or sets a boolean indicating if fog is enabled on this scene
  1152. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1153. * (Default is true)
  1154. */
  1155. fogEnabled: boolean;
  1156. private _fogMode;
  1157. /**
  1158. * Gets or sets the fog mode to use
  1159. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1160. * | mode | value |
  1161. * | --- | --- |
  1162. * | FOGMODE_NONE | 0 |
  1163. * | FOGMODE_EXP | 1 |
  1164. * | FOGMODE_EXP2 | 2 |
  1165. * | FOGMODE_LINEAR | 3 |
  1166. */
  1167. fogMode: number;
  1168. /**
  1169. * Gets or sets the fog color to use
  1170. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1171. * (Default is Color3(0.2, 0.2, 0.3))
  1172. */
  1173. fogColor: Color3;
  1174. /**
  1175. * Gets or sets the fog density to use
  1176. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1177. * (Default is 0.1)
  1178. */
  1179. fogDensity: number;
  1180. /**
  1181. * Gets or sets the fog start distance to use
  1182. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1183. * (Default is 0)
  1184. */
  1185. fogStart: number;
  1186. /**
  1187. * Gets or sets the fog end distance to use
  1188. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1189. * (Default is 1000)
  1190. */
  1191. fogEnd: number;
  1192. private _shadowsEnabled;
  1193. /**
  1194. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1195. */
  1196. shadowsEnabled: boolean;
  1197. private _lightsEnabled;
  1198. /**
  1199. * Gets or sets a boolean indicating if lights are enabled on this scene
  1200. */
  1201. lightsEnabled: boolean;
  1202. /** All of the active cameras added to this scene. */
  1203. activeCameras: Camera[];
  1204. private _activeCamera;
  1205. /** Gets or sets the current active camera */
  1206. activeCamera: Nullable<Camera>;
  1207. private _defaultMaterial;
  1208. /** The default material used on meshes when no material is affected */
  1209. /** The default material used on meshes when no material is affected */
  1210. defaultMaterial: Material;
  1211. private _texturesEnabled;
  1212. /**
  1213. * Gets or sets a boolean indicating if textures are enabled on this scene
  1214. */
  1215. texturesEnabled: boolean;
  1216. /**
  1217. * Gets or sets a boolean indicating if particles are enabled on this scene
  1218. */
  1219. particlesEnabled: boolean;
  1220. /**
  1221. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1222. */
  1223. spritesEnabled: boolean;
  1224. private _skeletonsEnabled;
  1225. /**
  1226. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1227. */
  1228. skeletonsEnabled: boolean;
  1229. /**
  1230. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1231. */
  1232. lensFlaresEnabled: boolean;
  1233. /**
  1234. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1236. */
  1237. collisionsEnabled: boolean;
  1238. private _workerCollisions;
  1239. /** @hidden */
  1240. collisionCoordinator: ICollisionCoordinator;
  1241. /**
  1242. * Defines the gravity applied to this scene (used only for collisions)
  1243. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1244. */
  1245. gravity: Vector3;
  1246. /**
  1247. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1248. */
  1249. postProcessesEnabled: boolean;
  1250. /**
  1251. * The list of postprocesses added to the scene
  1252. */
  1253. postProcesses: PostProcess[];
  1254. /**
  1255. * Gets the current postprocess manager
  1256. */
  1257. postProcessManager: PostProcessManager;
  1258. /**
  1259. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1260. */
  1261. renderTargetsEnabled: boolean;
  1262. /**
  1263. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1264. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1265. */
  1266. dumpNextRenderTargets: boolean;
  1267. /**
  1268. * The list of user defined render targets added to the scene
  1269. */
  1270. customRenderTargets: RenderTargetTexture[];
  1271. /**
  1272. * Defines if texture loading must be delayed
  1273. * If true, textures will only be loaded when they need to be rendered
  1274. */
  1275. useDelayedTextureLoading: boolean;
  1276. /**
  1277. * Gets the list of meshes imported to the scene through SceneLoader
  1278. */
  1279. importedMeshesFiles: String[];
  1280. /**
  1281. * Gets or sets a boolean indicating if probes are enabled on this scene
  1282. */
  1283. probesEnabled: boolean;
  1284. /**
  1285. * Gets or sets the current offline provider to use to store scene data
  1286. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1287. */
  1288. offlineProvider: IOfflineProvider;
  1289. /**
  1290. * Gets or sets the action manager associated with the scene
  1291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1292. */
  1293. actionManager: ActionManager;
  1294. private _meshesForIntersections;
  1295. /**
  1296. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1297. */
  1298. proceduralTexturesEnabled: boolean;
  1299. private _engine;
  1300. private _totalVertices;
  1301. /** @hidden */
  1302. _activeIndices: PerfCounter;
  1303. /** @hidden */
  1304. _activeParticles: PerfCounter;
  1305. /** @hidden */
  1306. _activeBones: PerfCounter;
  1307. private _animationRatio;
  1308. private _animationTimeLast;
  1309. private _animationTime;
  1310. /**
  1311. * Gets or sets a general scale for animation speed
  1312. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1313. */
  1314. animationTimeScale: number;
  1315. /** @hidden */
  1316. _cachedMaterial: Nullable<Material>;
  1317. /** @hidden */
  1318. _cachedEffect: Nullable<Effect>;
  1319. /** @hidden */
  1320. _cachedVisibility: Nullable<number>;
  1321. private _renderId;
  1322. private _frameId;
  1323. private _executeWhenReadyTimeoutId;
  1324. private _intermediateRendering;
  1325. private _viewUpdateFlag;
  1326. private _projectionUpdateFlag;
  1327. private _alternateViewUpdateFlag;
  1328. private _alternateProjectionUpdateFlag;
  1329. /** @hidden */
  1330. _toBeDisposed: Nullable<IDisposable>[];
  1331. private _activeRequests;
  1332. private _pendingData;
  1333. private _isDisposed;
  1334. /**
  1335. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1336. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1337. */
  1338. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1339. private _activeMeshes;
  1340. private _processedMaterials;
  1341. private _renderTargets;
  1342. /** @hidden */
  1343. _activeParticleSystems: SmartArray<IParticleSystem>;
  1344. private _activeSkeletons;
  1345. private _softwareSkinnedMeshes;
  1346. private _renderingManager;
  1347. /** @hidden */
  1348. _activeAnimatables: Animatable[];
  1349. private _transformMatrix;
  1350. private _sceneUbo;
  1351. private _alternateSceneUbo;
  1352. private _pickWithRayInverseMatrix;
  1353. private _viewMatrix;
  1354. private _projectionMatrix;
  1355. private _alternateViewMatrix;
  1356. private _alternateProjectionMatrix;
  1357. private _alternateTransformMatrix;
  1358. private _useAlternateCameraConfiguration;
  1359. private _alternateRendering;
  1360. private _wheelEventName;
  1361. /** @hidden */
  1362. _forcedViewPosition: Nullable<Vector3>;
  1363. /** @hidden */
  1364. readonly _isAlternateRenderingEnabled: boolean;
  1365. private _frustumPlanes;
  1366. /**
  1367. * Gets the list of frustum planes (built from the active camera)
  1368. */
  1369. readonly frustumPlanes: Plane[];
  1370. /**
  1371. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1372. * This is useful if there are more lights that the maximum simulteanous authorized
  1373. */
  1374. requireLightSorting: boolean;
  1375. /** @hidden */
  1376. readonly useMaterialMeshMap: boolean;
  1377. /** @hidden */
  1378. readonly useClonedMeshhMap: boolean;
  1379. private _pointerOverMesh;
  1380. private _pickedDownMesh;
  1381. private _pickedUpMesh;
  1382. private _externalData;
  1383. private _uid;
  1384. /**
  1385. * @hidden
  1386. * Backing store of defined scene components.
  1387. */
  1388. _components: ISceneComponent[];
  1389. /**
  1390. * @hidden
  1391. * Backing store of defined scene components.
  1392. */
  1393. _serializableComponents: ISceneSerializableComponent[];
  1394. /**
  1395. * List of components to register on the next registration step.
  1396. */
  1397. private _transientComponents;
  1398. /**
  1399. * Registers the transient components if needed.
  1400. */
  1401. private _registerTransientComponents;
  1402. /**
  1403. * @hidden
  1404. * Add a component to the scene.
  1405. * Note that the ccomponent could be registered on th next frame if this is called after
  1406. * the register component stage.
  1407. * @param component Defines the component to add to the scene
  1408. */
  1409. _addComponent(component: ISceneComponent): void;
  1410. /**
  1411. * @hidden
  1412. * Gets a component from the scene.
  1413. * @param name defines the name of the component to retrieve
  1414. * @returns the component or null if not present
  1415. */
  1416. _getComponent(name: string): Nullable<ISceneComponent>;
  1417. /**
  1418. * @hidden
  1419. * Defines the actions happening before camera updates.
  1420. */
  1421. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1422. /**
  1423. * @hidden
  1424. * Defines the actions happening before clear the canvas.
  1425. */
  1426. _beforeClearStage: Stage<SimpleStageAction>;
  1427. /**
  1428. * @hidden
  1429. * Defines the actions when collecting render targets for the frame.
  1430. */
  1431. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1432. /**
  1433. * @hidden
  1434. * Defines the actions happening for one camera in the frame.
  1435. */
  1436. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1437. /**
  1438. * @hidden
  1439. * Defines the actions happening during the per mesh ready checks.
  1440. */
  1441. _isReadyForMeshStage: Stage<MeshStageAction>;
  1442. /**
  1443. * @hidden
  1444. * Defines the actions happening before evaluate active mesh checks.
  1445. */
  1446. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1447. /**
  1448. * @hidden
  1449. * Defines the actions happening during the evaluate sub mesh checks.
  1450. */
  1451. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1452. /**
  1453. * @hidden
  1454. * Defines the actions happening during the active mesh stage.
  1455. */
  1456. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1457. /**
  1458. * @hidden
  1459. * Defines the actions happening during the per camera render target step.
  1460. */
  1461. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1462. /**
  1463. * @hidden
  1464. * Defines the actions happening just before the active camera is drawing.
  1465. */
  1466. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1467. /**
  1468. * @hidden
  1469. * Defines the actions happening just before a render target is drawing.
  1470. */
  1471. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1472. /**
  1473. * @hidden
  1474. * Defines the actions happening just before a rendering group is drawing.
  1475. */
  1476. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1477. /**
  1478. * @hidden
  1479. * Defines the actions happening just before a mesh is drawing.
  1480. */
  1481. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1482. /**
  1483. * @hidden
  1484. * Defines the actions happening just after a mesh has been drawn.
  1485. */
  1486. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1487. /**
  1488. * @hidden
  1489. * Defines the actions happening just after a rendering group has been drawn.
  1490. */
  1491. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1492. /**
  1493. * @hidden
  1494. * Defines the actions happening just after the active camera has been drawn.
  1495. */
  1496. _afterCameraDrawStage: Stage<CameraStageAction>;
  1497. /**
  1498. * @hidden
  1499. * Defines the actions happening just after a render target has been drawn.
  1500. */
  1501. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1502. /**
  1503. * @hidden
  1504. * Defines the actions happening just after rendering all cameras and computing intersections.
  1505. */
  1506. _afterRenderStage: Stage<SimpleStageAction>;
  1507. /**
  1508. * @hidden
  1509. * Defines the actions happening when a pointer move event happens.
  1510. */
  1511. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1512. /**
  1513. * @hidden
  1514. * Defines the actions happening when a pointer down event happens.
  1515. */
  1516. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1517. /**
  1518. * @hidden
  1519. * Defines the actions happening when a pointer up event happens.
  1520. */
  1521. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1522. /**
  1523. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1524. */
  1525. private geometriesById;
  1526. /**
  1527. * Creates a new Scene
  1528. * @param engine defines the engine to use to render this scene
  1529. */
  1530. constructor(engine: Engine, options?: SceneOptions);
  1531. private _defaultMeshCandidates;
  1532. /**
  1533. * @hidden
  1534. */
  1535. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1536. private _defaultSubMeshCandidates;
  1537. /**
  1538. * @hidden
  1539. */
  1540. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1541. /**
  1542. * Sets the default candidate providers for the scene.
  1543. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1544. * and getCollidingSubMeshCandidates to their default function
  1545. */
  1546. setDefaultCandidateProviders(): void;
  1547. /**
  1548. * Gets a boolean indicating if collisions are processed on a web worker
  1549. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1550. */
  1551. workerCollisions: boolean;
  1552. /**
  1553. * Gets the mesh that is currently under the pointer
  1554. */
  1555. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1556. /**
  1557. * Gets the current on-screen X position of the pointer
  1558. */
  1559. readonly pointerX: number;
  1560. /**
  1561. * Gets the current on-screen Y position of the pointer
  1562. */
  1563. readonly pointerY: number;
  1564. /**
  1565. * Gets the cached material (ie. the latest rendered one)
  1566. * @returns the cached material
  1567. */
  1568. getCachedMaterial(): Nullable<Material>;
  1569. /**
  1570. * Gets the cached effect (ie. the latest rendered one)
  1571. * @returns the cached effect
  1572. */
  1573. getCachedEffect(): Nullable<Effect>;
  1574. /**
  1575. * Gets the cached visibility state (ie. the latest rendered one)
  1576. * @returns the cached visibility state
  1577. */
  1578. getCachedVisibility(): Nullable<number>;
  1579. /**
  1580. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1581. * @param material defines the current material
  1582. * @param effect defines the current effect
  1583. * @param visibility defines the current visibility state
  1584. * @returns true if one parameter is not cached
  1585. */
  1586. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1587. /**
  1588. * Gets the engine associated with the scene
  1589. * @returns an Engine
  1590. */
  1591. getEngine(): Engine;
  1592. /**
  1593. * Gets the total number of vertices rendered per frame
  1594. * @returns the total number of vertices rendered per frame
  1595. */
  1596. getTotalVertices(): number;
  1597. /**
  1598. * Gets the performance counter for total vertices
  1599. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1600. */
  1601. readonly totalVerticesPerfCounter: PerfCounter;
  1602. /**
  1603. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1604. * @returns the total number of active indices rendered per frame
  1605. */
  1606. getActiveIndices(): number;
  1607. /**
  1608. * Gets the performance counter for active indices
  1609. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1610. */
  1611. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1612. /**
  1613. * Gets the total number of active particles rendered per frame
  1614. * @returns the total number of active particles rendered per frame
  1615. */
  1616. getActiveParticles(): number;
  1617. /**
  1618. * Gets the performance counter for active particles
  1619. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1620. */
  1621. readonly activeParticlesPerfCounter: PerfCounter;
  1622. /**
  1623. * Gets the total number of active bones rendered per frame
  1624. * @returns the total number of active bones rendered per frame
  1625. */
  1626. getActiveBones(): number;
  1627. /**
  1628. * Gets the performance counter for active bones
  1629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1630. */
  1631. readonly activeBonesPerfCounter: PerfCounter;
  1632. /**
  1633. * Gets the array of active meshes
  1634. * @returns an array of AbstractMesh
  1635. */
  1636. getActiveMeshes(): SmartArray<AbstractMesh>;
  1637. /**
  1638. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1639. * @returns a number
  1640. */
  1641. getAnimationRatio(): number;
  1642. /**
  1643. * Gets an unique Id for the current render phase
  1644. * @returns a number
  1645. */
  1646. getRenderId(): number;
  1647. /**
  1648. * Gets an unique Id for the current frame
  1649. * @returns a number
  1650. */
  1651. getFrameId(): number;
  1652. /** Call this function if you want to manually increment the render Id*/
  1653. incrementRenderId(): void;
  1654. private _updatePointerPosition;
  1655. private _createUbo;
  1656. private _createAlternateUbo;
  1657. private _setRayOnPointerInfo;
  1658. /**
  1659. * Use this method to simulate a pointer move on a mesh
  1660. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1661. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1662. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1663. * @returns the current scene
  1664. */
  1665. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1666. private _processPointerMove;
  1667. private _checkPrePointerObservable;
  1668. /**
  1669. * Use this method to simulate a pointer down on a mesh
  1670. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1671. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1672. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1673. * @returns the current scene
  1674. */
  1675. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1676. private _processPointerDown;
  1677. /**
  1678. * Use this method to simulate a pointer up on a mesh
  1679. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1680. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1681. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1682. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  1683. * @returns the current scene
  1684. */
  1685. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  1686. private _processPointerUp;
  1687. /**
  1688. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1689. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1690. * @returns true if the pointer was captured
  1691. */
  1692. isPointerCaptured(pointerId?: number): boolean;
  1693. /** @hidden */
  1694. _isPointerSwiping(): boolean;
  1695. /**
  1696. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1697. * @param attachUp defines if you want to attach events to pointerup
  1698. * @param attachDown defines if you want to attach events to pointerdown
  1699. * @param attachMove defines if you want to attach events to pointermove
  1700. */
  1701. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1702. /** Detaches all event handlers*/
  1703. detachControl(): void;
  1704. /**
  1705. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1706. * Delay loaded resources are not taking in account
  1707. * @return true if all required resources are ready
  1708. */
  1709. isReady(): boolean;
  1710. /** Resets all cached information relative to material (including effect and visibility) */
  1711. resetCachedMaterial(): void;
  1712. /**
  1713. * Registers a function to be called before every frame render
  1714. * @param func defines the function to register
  1715. */
  1716. registerBeforeRender(func: () => void): void;
  1717. /**
  1718. * Unregisters a function called before every frame render
  1719. * @param func defines the function to unregister
  1720. */
  1721. unregisterBeforeRender(func: () => void): void;
  1722. /**
  1723. * Registers a function to be called after every frame render
  1724. * @param func defines the function to register
  1725. */
  1726. registerAfterRender(func: () => void): void;
  1727. /**
  1728. * Unregisters a function called after every frame render
  1729. * @param func defines the function to unregister
  1730. */
  1731. unregisterAfterRender(func: () => void): void;
  1732. private _executeOnceBeforeRender;
  1733. /**
  1734. * The provided function will run before render once and will be disposed afterwards.
  1735. * A timeout delay can be provided so that the function will be executed in N ms.
  1736. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1737. * @param func The function to be executed.
  1738. * @param timeout optional delay in ms
  1739. */
  1740. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1741. /** @hidden */
  1742. _addPendingData(data: any): void;
  1743. /** @hidden */
  1744. _removePendingData(data: any): void;
  1745. /**
  1746. * Returns the number of items waiting to be loaded
  1747. * @returns the number of items waiting to be loaded
  1748. */
  1749. getWaitingItemsCount(): number;
  1750. /**
  1751. * Returns a boolean indicating if the scene is still loading data
  1752. */
  1753. readonly isLoading: boolean;
  1754. /**
  1755. * Registers a function to be executed when the scene is ready
  1756. * @param {Function} func - the function to be executed
  1757. */
  1758. executeWhenReady(func: () => void): void;
  1759. /**
  1760. * Returns a promise that resolves when the scene is ready
  1761. * @returns A promise that resolves when the scene is ready
  1762. */
  1763. whenReadyAsync(): Promise<void>;
  1764. /** @hidden */
  1765. _checkIsReady(): void;
  1766. /**
  1767. * Will start the animation sequence of a given target
  1768. * @param target defines the target
  1769. * @param from defines from which frame should animation start
  1770. * @param to defines until which frame should animation run.
  1771. * @param weight defines the weight to apply to the animation (1.0 by default)
  1772. * @param loop defines if the animation loops
  1773. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1774. * @param onAnimationEnd defines the function to be executed when the animation ends
  1775. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1776. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1777. * @returns the animatable object created for this animation
  1778. */
  1779. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1780. /**
  1781. * Will start the animation sequence of a given target
  1782. * @param target defines the target
  1783. * @param from defines from which frame should animation start
  1784. * @param to defines until which frame should animation run.
  1785. * @param loop defines if the animation loops
  1786. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1787. * @param onAnimationEnd defines the function to be executed when the animation ends
  1788. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1789. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1790. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1791. * @returns the animatable object created for this animation
  1792. */
  1793. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1794. /**
  1795. * Will start the animation sequence of a given target and its hierarchy
  1796. * @param target defines the target
  1797. * @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.
  1798. * @param from defines from which frame should animation start
  1799. * @param to defines until which frame should animation run.
  1800. * @param loop defines if the animation loops
  1801. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1802. * @param onAnimationEnd defines the function to be executed when the animation ends
  1803. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1804. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1805. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1806. * @returns the list of created animatables
  1807. */
  1808. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable[];
  1809. /**
  1810. * Begin a new animation on a given node
  1811. * @param target defines the target where the animation will take place
  1812. * @param animations defines the list of animations to start
  1813. * @param from defines the initial value
  1814. * @param to defines the final value
  1815. * @param loop defines if you want animation to loop (off by default)
  1816. * @param speedRatio defines the speed ratio to apply to all animations
  1817. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1818. * @returns the list of created animatables
  1819. */
  1820. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1821. /**
  1822. * Begin a new animation on a given node and its hierarchy
  1823. * @param target defines the root node where the animation will take place
  1824. * @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.
  1825. * @param animations defines the list of animations to start
  1826. * @param from defines the initial value
  1827. * @param to defines the final value
  1828. * @param loop defines if you want animation to loop (off by default)
  1829. * @param speedRatio defines the speed ratio to apply to all animations
  1830. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1831. * @returns the list of animatables created for all nodes
  1832. */
  1833. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1834. /**
  1835. * Gets the animatable associated with a specific target
  1836. * @param target defines the target of the animatable
  1837. * @returns the required animatable if found
  1838. */
  1839. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1840. /**
  1841. * Gets all animatables associated with a given target
  1842. * @param target defines the target to look animatables for
  1843. * @returns an array of Animatables
  1844. */
  1845. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1846. /**
  1847. * Gets all animatable attached to the scene
  1848. */
  1849. readonly animatables: Animatable[];
  1850. /**
  1851. * Will stop the animation of the given target
  1852. * @param target - the target
  1853. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1854. * @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)
  1855. */
  1856. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1857. /**
  1858. * Stops and removes all animations that have been applied to the scene
  1859. */
  1860. stopAllAnimations(): void;
  1861. private _animate;
  1862. /** @hidden */
  1863. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1864. private _processLateAnimationBindingsForMatrices;
  1865. private _processLateAnimationBindingsForQuaternions;
  1866. private _processLateAnimationBindings;
  1867. /** @hidden */
  1868. _switchToAlternateCameraConfiguration(active: boolean): void;
  1869. /**
  1870. * Gets the current view matrix
  1871. * @returns a Matrix
  1872. */
  1873. getViewMatrix(): Matrix;
  1874. /**
  1875. * Gets the current projection matrix
  1876. * @returns a Matrix
  1877. */
  1878. getProjectionMatrix(): Matrix;
  1879. /**
  1880. * Gets the current transform matrix
  1881. * @returns a Matrix made of View * Projection
  1882. */
  1883. getTransformMatrix(): Matrix;
  1884. /**
  1885. * Sets the current transform matrix
  1886. * @param view defines the View matrix to use
  1887. * @param projection defines the Projection matrix to use
  1888. */
  1889. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1890. /** @hidden */
  1891. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1892. /**
  1893. * Gets the uniform buffer used to store scene data
  1894. * @returns a UniformBuffer
  1895. */
  1896. getSceneUniformBuffer(): UniformBuffer;
  1897. /**
  1898. * Gets an unique (relatively to the current scene) Id
  1899. * @returns an unique number for the scene
  1900. */
  1901. getUniqueId(): number;
  1902. /**
  1903. * Add a mesh to the list of scene's meshes
  1904. * @param newMesh defines the mesh to add
  1905. * @param recursive if all child meshes should also be added to the scene
  1906. */
  1907. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1908. /**
  1909. * Remove a mesh for the list of scene's meshes
  1910. * @param toRemove defines the mesh to remove
  1911. * @param recursive if all child meshes should also be removed from the scene
  1912. * @returns the index where the mesh was in the mesh list
  1913. */
  1914. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1915. /**
  1916. * Add a transform node to the list of scene's transform nodes
  1917. * @param newTransformNode defines the transform node to add
  1918. */
  1919. addTransformNode(newTransformNode: TransformNode): void;
  1920. /**
  1921. * Remove a transform node for the list of scene's transform nodes
  1922. * @param toRemove defines the transform node to remove
  1923. * @returns the index where the transform node was in the transform node list
  1924. */
  1925. removeTransformNode(toRemove: TransformNode): number;
  1926. /**
  1927. * Remove a skeleton for the list of scene's skeletons
  1928. * @param toRemove defines the skeleton to remove
  1929. * @returns the index where the skeleton was in the skeleton list
  1930. */
  1931. removeSkeleton(toRemove: Skeleton): number;
  1932. /**
  1933. * Remove a morph target for the list of scene's morph targets
  1934. * @param toRemove defines the morph target to remove
  1935. * @returns the index where the morph target was in the morph target list
  1936. */
  1937. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1938. /**
  1939. * Remove a light for the list of scene's lights
  1940. * @param toRemove defines the light to remove
  1941. * @returns the index where the light was in the light list
  1942. */
  1943. removeLight(toRemove: Light): number;
  1944. /**
  1945. * Remove a camera for the list of scene's cameras
  1946. * @param toRemove defines the camera to remove
  1947. * @returns the index where the camera was in the camera list
  1948. */
  1949. removeCamera(toRemove: Camera): number;
  1950. /**
  1951. * Remove a particle system for the list of scene's particle systems
  1952. * @param toRemove defines the particle system to remove
  1953. * @returns the index where the particle system was in the particle system list
  1954. */
  1955. removeParticleSystem(toRemove: IParticleSystem): number;
  1956. /**
  1957. * Remove a animation for the list of scene's animations
  1958. * @param toRemove defines the animation to remove
  1959. * @returns the index where the animation was in the animation list
  1960. */
  1961. removeAnimation(toRemove: Animation): number;
  1962. /**
  1963. * Removes the given animation group from this scene.
  1964. * @param toRemove The animation group to remove
  1965. * @returns The index of the removed animation group
  1966. */
  1967. removeAnimationGroup(toRemove: AnimationGroup): number;
  1968. /**
  1969. * Removes the given multi-material from this scene.
  1970. * @param toRemove The multi-material to remove
  1971. * @returns The index of the removed multi-material
  1972. */
  1973. removeMultiMaterial(toRemove: MultiMaterial): number;
  1974. /**
  1975. * Removes the given material from this scene.
  1976. * @param toRemove The material to remove
  1977. * @returns The index of the removed material
  1978. */
  1979. removeMaterial(toRemove: Material): number;
  1980. /**
  1981. * Removes the given action manager from this scene.
  1982. * @param toRemove The action manager to remove
  1983. * @returns The index of the removed action manager
  1984. */
  1985. removeActionManager(toRemove: ActionManager): number;
  1986. /**
  1987. * Removes the given texture from this scene.
  1988. * @param toRemove The texture to remove
  1989. * @returns The index of the removed texture
  1990. */
  1991. removeTexture(toRemove: BaseTexture): number;
  1992. /**
  1993. * Adds the given light to this scene
  1994. * @param newLight The light to add
  1995. */
  1996. addLight(newLight: Light): void;
  1997. /**
  1998. * Sorts the list list based on light priorities
  1999. */
  2000. sortLightsByPriority(): void;
  2001. /**
  2002. * Adds the given camera to this scene
  2003. * @param newCamera The camera to add
  2004. */
  2005. addCamera(newCamera: Camera): void;
  2006. /**
  2007. * Adds the given skeleton to this scene
  2008. * @param newSkeleton The skeleton to add
  2009. */
  2010. addSkeleton(newSkeleton: Skeleton): void;
  2011. /**
  2012. * Adds the given particle system to this scene
  2013. * @param newParticleSystem The particle system to add
  2014. */
  2015. addParticleSystem(newParticleSystem: IParticleSystem): void;
  2016. /**
  2017. * Adds the given animation to this scene
  2018. * @param newAnimation The animation to add
  2019. */
  2020. addAnimation(newAnimation: Animation): void;
  2021. /**
  2022. * Adds the given animation group to this scene.
  2023. * @param newAnimationGroup The animation group to add
  2024. */
  2025. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  2026. /**
  2027. * Adds the given multi-material to this scene
  2028. * @param newMultiMaterial The multi-material to add
  2029. */
  2030. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  2031. /**
  2032. * Adds the given material to this scene
  2033. * @param newMaterial The material to add
  2034. */
  2035. addMaterial(newMaterial: Material): void;
  2036. /**
  2037. * Adds the given morph target to this scene
  2038. * @param newMorphTargetManager The morph target to add
  2039. */
  2040. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  2041. /**
  2042. * Adds the given geometry to this scene
  2043. * @param newGeometry The geometry to add
  2044. */
  2045. addGeometry(newGeometry: Geometry): void;
  2046. /**
  2047. * Adds the given action manager to this scene
  2048. * @param newActionManager The action manager to add
  2049. */
  2050. addActionManager(newActionManager: ActionManager): void;
  2051. /**
  2052. * Adds the given texture to this scene.
  2053. * @param newTexture The texture to add
  2054. */
  2055. addTexture(newTexture: BaseTexture): void;
  2056. /**
  2057. * Switch active camera
  2058. * @param newCamera defines the new active camera
  2059. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2060. */
  2061. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2062. /**
  2063. * sets the active camera of the scene using its ID
  2064. * @param id defines the camera's ID
  2065. * @return the new active camera or null if none found.
  2066. */
  2067. setActiveCameraByID(id: string): Nullable<Camera>;
  2068. /**
  2069. * sets the active camera of the scene using its name
  2070. * @param name defines the camera's name
  2071. * @returns the new active camera or null if none found.
  2072. */
  2073. setActiveCameraByName(name: string): Nullable<Camera>;
  2074. /**
  2075. * get an animation group using its name
  2076. * @param name defines the material's name
  2077. * @return the animation group or null if none found.
  2078. */
  2079. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2080. /**
  2081. * get a material using its id
  2082. * @param id defines the material's ID
  2083. * @return the material or null if none found.
  2084. */
  2085. getMaterialByID(id: string): Nullable<Material>;
  2086. /**
  2087. * Gets a material using its name
  2088. * @param name defines the material's name
  2089. * @return the material or null if none found.
  2090. */
  2091. getMaterialByName(name: string): Nullable<Material>;
  2092. /**
  2093. * Gets a camera using its id
  2094. * @param id defines the id to look for
  2095. * @returns the camera or null if not found
  2096. */
  2097. getCameraByID(id: string): Nullable<Camera>;
  2098. /**
  2099. * Gets a camera using its unique id
  2100. * @param uniqueId defines the unique id to look for
  2101. * @returns the camera or null if not found
  2102. */
  2103. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2104. /**
  2105. * Gets a camera using its name
  2106. * @param name defines the camera's name
  2107. * @return the camera or null if none found.
  2108. */
  2109. getCameraByName(name: string): Nullable<Camera>;
  2110. /**
  2111. * Gets a bone using its id
  2112. * @param id defines the bone's id
  2113. * @return the bone or null if not found
  2114. */
  2115. getBoneByID(id: string): Nullable<Bone>;
  2116. /**
  2117. * Gets a bone using its id
  2118. * @param name defines the bone's name
  2119. * @return the bone or null if not found
  2120. */
  2121. getBoneByName(name: string): Nullable<Bone>;
  2122. /**
  2123. * Gets a light node using its name
  2124. * @param name defines the the light's name
  2125. * @return the light or null if none found.
  2126. */
  2127. getLightByName(name: string): Nullable<Light>;
  2128. /**
  2129. * Gets a light node using its id
  2130. * @param id defines the light's id
  2131. * @return the light or null if none found.
  2132. */
  2133. getLightByID(id: string): Nullable<Light>;
  2134. /**
  2135. * Gets a light node using its scene-generated unique ID
  2136. * @param uniqueId defines the light's unique id
  2137. * @return the light or null if none found.
  2138. */
  2139. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2140. /**
  2141. * Gets a particle system by id
  2142. * @param id defines the particle system id
  2143. * @return the corresponding system or null if none found
  2144. */
  2145. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2146. /**
  2147. * Gets a geometry using its ID
  2148. * @param id defines the geometry's id
  2149. * @return the geometry or null if none found.
  2150. */
  2151. getGeometryByID(id: string): Nullable<Geometry>;
  2152. private _getGeometryByUniqueID;
  2153. /**
  2154. * Add a new geometry to this scene
  2155. * @param geometry defines the geometry to be added to the scene.
  2156. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2157. * @return a boolean defining if the geometry was added or not
  2158. */
  2159. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2160. /**
  2161. * Removes an existing geometry
  2162. * @param geometry defines the geometry to be removed from the scene
  2163. * @return a boolean defining if the geometry was removed or not
  2164. */
  2165. removeGeometry(geometry: Geometry): boolean;
  2166. /**
  2167. * Gets the list of geometries attached to the scene
  2168. * @returns an array of Geometry
  2169. */
  2170. getGeometries(): Geometry[];
  2171. /**
  2172. * Gets the first added mesh found of a given ID
  2173. * @param id defines the id to search for
  2174. * @return the mesh found or null if not found at all
  2175. */
  2176. getMeshByID(id: string): Nullable<AbstractMesh>;
  2177. /**
  2178. * Gets a list of meshes using their id
  2179. * @param id defines the id to search for
  2180. * @returns a list of meshes
  2181. */
  2182. getMeshesByID(id: string): Array<AbstractMesh>;
  2183. /**
  2184. * Gets the first added transform node found of a given ID
  2185. * @param id defines the id to search for
  2186. * @return the found transform node or null if not found at all.
  2187. */
  2188. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2189. /**
  2190. * Gets a list of transform nodes using their id
  2191. * @param id defines the id to search for
  2192. * @returns a list of transform nodes
  2193. */
  2194. getTransformNodesByID(id: string): Array<TransformNode>;
  2195. /**
  2196. * Gets a mesh with its auto-generated unique id
  2197. * @param uniqueId defines the unique id to search for
  2198. * @return the found mesh or null if not found at all.
  2199. */
  2200. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2201. /**
  2202. * Gets a the last added mesh using a given id
  2203. * @param id defines the id to search for
  2204. * @return the found mesh or null if not found at all.
  2205. */
  2206. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2207. /**
  2208. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2209. * @param id defines the id to search for
  2210. * @return the found node or null if not found at all
  2211. */
  2212. getLastEntryByID(id: string): Nullable<Node>;
  2213. /**
  2214. * Gets a node (Mesh, Camera, Light) using a given id
  2215. * @param id defines the id to search for
  2216. * @return the found node or null if not found at all
  2217. */
  2218. getNodeByID(id: string): Nullable<Node>;
  2219. /**
  2220. * Gets a node (Mesh, Camera, Light) using a given name
  2221. * @param name defines the name to search for
  2222. * @return the found node or null if not found at all.
  2223. */
  2224. getNodeByName(name: string): Nullable<Node>;
  2225. /**
  2226. * Gets a mesh using a given name
  2227. * @param name defines the name to search for
  2228. * @return the found mesh or null if not found at all.
  2229. */
  2230. getMeshByName(name: string): Nullable<AbstractMesh>;
  2231. /**
  2232. * Gets a transform node using a given name
  2233. * @param name defines the name to search for
  2234. * @return the found transform node or null if not found at all.
  2235. */
  2236. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2237. /**
  2238. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2239. * @param id defines the id to search for
  2240. * @return the found skeleton or null if not found at all.
  2241. */
  2242. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2243. /**
  2244. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2245. * @param id defines the id to search for
  2246. * @return the found skeleton or null if not found at all.
  2247. */
  2248. getSkeletonById(id: string): Nullable<Skeleton>;
  2249. /**
  2250. * Gets a skeleton using a given name
  2251. * @param name defines the name to search for
  2252. * @return the found skeleton or null if not found at all.
  2253. */
  2254. getSkeletonByName(name: string): Nullable<Skeleton>;
  2255. /**
  2256. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2257. * @param id defines the id to search for
  2258. * @return the found morph target manager or null if not found at all.
  2259. */
  2260. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2261. /**
  2262. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  2263. * @param id defines the id to search for
  2264. * @return the found morph target or null if not found at all.
  2265. */
  2266. getMorphTargetById(id: string): Nullable<MorphTarget>;
  2267. /**
  2268. * Gets a boolean indicating if the given mesh is active
  2269. * @param mesh defines the mesh to look for
  2270. * @returns true if the mesh is in the active list
  2271. */
  2272. isActiveMesh(mesh: AbstractMesh): boolean;
  2273. /**
  2274. * Return a unique id as a string which can serve as an identifier for the scene
  2275. */
  2276. readonly uid: string;
  2277. /**
  2278. * Add an externaly attached data from its key.
  2279. * This method call will fail and return false, if such key already exists.
  2280. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2281. * @param key the unique key that identifies the data
  2282. * @param data the data object to associate to the key for this Engine instance
  2283. * @return true if no such key were already present and the data was added successfully, false otherwise
  2284. */
  2285. addExternalData<T>(key: string, data: T): boolean;
  2286. /**
  2287. * Get an externaly attached data from its key
  2288. * @param key the unique key that identifies the data
  2289. * @return the associated data, if present (can be null), or undefined if not present
  2290. */
  2291. getExternalData<T>(key: string): Nullable<T>;
  2292. /**
  2293. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2294. * @param key the unique key that identifies the data
  2295. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2296. * @return the associated data, can be null if the factory returned null.
  2297. */
  2298. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2299. /**
  2300. * Remove an externaly attached data from the Engine instance
  2301. * @param key the unique key that identifies the data
  2302. * @return true if the data was successfully removed, false if it doesn't exist
  2303. */
  2304. removeExternalData(key: string): boolean;
  2305. private _evaluateSubMesh;
  2306. /**
  2307. * Clear the processed materials smart array preventing retention point in material dispose.
  2308. */
  2309. freeProcessedMaterials(): void;
  2310. private _preventFreeActiveMeshesAndRenderingGroups;
  2311. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2312. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2313. * when disposing several meshes in a row or a hierarchy of meshes.
  2314. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2315. */
  2316. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2317. /**
  2318. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2319. */
  2320. freeActiveMeshes(): void;
  2321. /**
  2322. * Clear the info related to rendering groups preventing retention points during dispose.
  2323. */
  2324. freeRenderingGroups(): void;
  2325. /** @hidden */
  2326. _isInIntermediateRendering(): boolean;
  2327. /**
  2328. * Lambda returning the list of potentially active meshes.
  2329. */
  2330. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2331. /**
  2332. * Lambda returning the list of potentially active sub meshes.
  2333. */
  2334. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2335. /**
  2336. * Lambda returning the list of potentially intersecting sub meshes.
  2337. */
  2338. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2339. /**
  2340. * Lambda returning the list of potentially colliding sub meshes.
  2341. */
  2342. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2343. private _activeMeshesFrozen;
  2344. /**
  2345. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2346. * @returns the current scene
  2347. */
  2348. freezeActiveMeshes(): Scene;
  2349. /**
  2350. * Use this function to restart evaluating active meshes on every frame
  2351. * @returns the current scene
  2352. */
  2353. unfreezeActiveMeshes(): Scene;
  2354. private _evaluateActiveMeshes;
  2355. private _activeMesh;
  2356. /**
  2357. * Update the transform matrix to update from the current active camera
  2358. * @param force defines a boolean used to force the update even if cache is up to date
  2359. */
  2360. updateTransformMatrix(force?: boolean): void;
  2361. /**
  2362. * 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)
  2363. * @param alternateCamera defines the camera to use
  2364. */
  2365. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2366. /** @hidden */
  2367. _allowPostProcessClearColor: boolean;
  2368. private _renderForCamera;
  2369. private _processSubCameras;
  2370. private _checkIntersections;
  2371. /** @hidden */
  2372. _advancePhysicsEngineStep(step: number): void;
  2373. /**
  2374. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2375. */
  2376. getDeterministicFrameTime: () => number;
  2377. /**
  2378. * Render the scene
  2379. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2380. */
  2381. render(updateCameras?: boolean): void;
  2382. /**
  2383. * Freeze all materials
  2384. * A frozen material will not be updatable but should be faster to render
  2385. */
  2386. freezeMaterials(): void;
  2387. /**
  2388. * Unfreeze all materials
  2389. * A frozen material will not be updatable but should be faster to render
  2390. */
  2391. unfreezeMaterials(): void;
  2392. /**
  2393. * Releases all held ressources
  2394. */
  2395. dispose(): void;
  2396. /**
  2397. * Gets if the scene is already disposed
  2398. */
  2399. readonly isDisposed: boolean;
  2400. /**
  2401. * Call this function to reduce memory footprint of the scene.
  2402. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2403. */
  2404. clearCachedVertexData(): void;
  2405. /**
  2406. * This function will remove the local cached buffer data from texture.
  2407. * It will save memory but will prevent the texture from being rebuilt
  2408. */
  2409. cleanCachedTextureBuffer(): void;
  2410. /**
  2411. * Get the world extend vectors with an optional filter
  2412. *
  2413. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2414. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2415. */
  2416. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2417. min: Vector3;
  2418. max: Vector3;
  2419. };
  2420. /**
  2421. * Creates a ray that can be used to pick in the scene
  2422. * @param x defines the x coordinate of the origin (on-screen)
  2423. * @param y defines the y coordinate of the origin (on-screen)
  2424. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2425. * @param camera defines the camera to use for the picking
  2426. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2427. * @returns a Ray
  2428. */
  2429. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2430. /**
  2431. * Creates a ray that can be used to pick in the scene
  2432. * @param x defines the x coordinate of the origin (on-screen)
  2433. * @param y defines the y coordinate of the origin (on-screen)
  2434. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2435. * @param result defines the ray where to store the picking ray
  2436. * @param camera defines the camera to use for the picking
  2437. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2438. * @returns the current scene
  2439. */
  2440. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2441. /**
  2442. * Creates a ray that can be used to pick in the scene
  2443. * @param x defines the x coordinate of the origin (on-screen)
  2444. * @param y defines the y coordinate of the origin (on-screen)
  2445. * @param camera defines the camera to use for the picking
  2446. * @returns a Ray
  2447. */
  2448. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2449. /**
  2450. * Creates a ray that can be used to pick in the scene
  2451. * @param x defines the x coordinate of the origin (on-screen)
  2452. * @param y defines the y coordinate of the origin (on-screen)
  2453. * @param result defines the ray where to store the picking ray
  2454. * @param camera defines the camera to use for the picking
  2455. * @returns the current scene
  2456. */
  2457. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2458. private _internalPick;
  2459. private _internalMultiPick;
  2460. private _tempPickingRay;
  2461. /** Launch a ray to try to pick a mesh in the scene
  2462. * @param x position on screen
  2463. * @param y position on screen
  2464. * @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
  2465. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2466. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2467. * @returns a PickingInfo
  2468. */
  2469. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2470. private _cachedRayForTransform;
  2471. /** Use the given ray to pick a mesh in the scene
  2472. * @param ray The ray to use to pick meshes
  2473. * @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
  2474. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2475. * @returns a PickingInfo
  2476. */
  2477. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2478. /**
  2479. * Launch a ray to try to pick a mesh in the scene
  2480. * @param x X position on screen
  2481. * @param y Y position on screen
  2482. * @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
  2483. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2484. * @returns an array of PickingInfo
  2485. */
  2486. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2487. /**
  2488. * Launch a ray to try to pick a mesh in the scene
  2489. * @param ray Ray to use
  2490. * @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
  2491. * @returns an array of PickingInfo
  2492. */
  2493. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2494. /**
  2495. * Force the value of meshUnderPointer
  2496. * @param mesh defines the mesh to use
  2497. */
  2498. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2499. /**
  2500. * Gets the mesh under the pointer
  2501. * @returns a Mesh or null if no mesh is under the pointer
  2502. */
  2503. getPointerOverMesh(): Nullable<AbstractMesh>;
  2504. /** @hidden */
  2505. _rebuildGeometries(): void;
  2506. /** @hidden */
  2507. _rebuildTextures(): void;
  2508. private _getByTags;
  2509. /**
  2510. * Get a list of meshes by tags
  2511. * @param tagsQuery defines the tags query to use
  2512. * @param forEach defines a predicate used to filter results
  2513. * @returns an array of Mesh
  2514. */
  2515. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2516. /**
  2517. * Get a list of cameras by tags
  2518. * @param tagsQuery defines the tags query to use
  2519. * @param forEach defines a predicate used to filter results
  2520. * @returns an array of Camera
  2521. */
  2522. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2523. /**
  2524. * Get a list of lights by tags
  2525. * @param tagsQuery defines the tags query to use
  2526. * @param forEach defines a predicate used to filter results
  2527. * @returns an array of Light
  2528. */
  2529. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2530. /**
  2531. * Get a list of materials by tags
  2532. * @param tagsQuery defines the tags query to use
  2533. * @param forEach defines a predicate used to filter results
  2534. * @returns an array of Material
  2535. */
  2536. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2537. /**
  2538. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2539. * This allowed control for front to back rendering or reversly depending of the special needs.
  2540. *
  2541. * @param renderingGroupId The rendering group id corresponding to its index
  2542. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2543. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2544. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2545. */
  2546. 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;
  2547. /**
  2548. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2549. *
  2550. * @param renderingGroupId The rendering group id corresponding to its index
  2551. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2552. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2553. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2554. */
  2555. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2556. /**
  2557. * Gets the current auto clear configuration for one rendering group of the rendering
  2558. * manager.
  2559. * @param index the rendering group index to get the information for
  2560. * @returns The auto clear setup for the requested rendering group
  2561. */
  2562. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2563. private _blockMaterialDirtyMechanism;
  2564. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2565. blockMaterialDirtyMechanism: boolean;
  2566. /**
  2567. * Will flag all materials as dirty to trigger new shader compilation
  2568. * @param flag defines the flag used to specify which material part must be marked as dirty
  2569. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2570. */
  2571. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2572. /** @hidden */
  2573. _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;
  2574. /** @hidden */
  2575. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2576. }
  2577. }
  2578. declare module BABYLON {
  2579. /**
  2580. * Groups all the scene component constants in one place to ease maintenance.
  2581. * @hidden
  2582. */
  2583. class SceneComponentConstants {
  2584. static readonly NAME_EFFECTLAYER: string;
  2585. static readonly NAME_LAYER: string;
  2586. static readonly NAME_LENSFLARESYSTEM: string;
  2587. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2588. static readonly NAME_PARTICLESYSTEM: string;
  2589. static readonly NAME_GAMEPAD: string;
  2590. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2591. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2592. static readonly NAME_DEPTHRENDERER: string;
  2593. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2594. static readonly NAME_SPRITE: string;
  2595. static readonly NAME_OUTLINERENDERER: string;
  2596. static readonly NAME_PROCEDURALTEXTURE: string;
  2597. static readonly NAME_SHADOWGENERATOR: string;
  2598. static readonly NAME_OCTREE: string;
  2599. static readonly NAME_PHYSICSENGINE: string;
  2600. static readonly NAME_AUDIO: string;
  2601. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2602. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2603. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2604. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2605. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2606. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2607. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2608. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  2609. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2610. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2611. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2612. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2613. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2614. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2615. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2616. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  2617. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2618. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2619. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2620. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2621. static readonly STEP_AFTERRENDER_AUDIO: number;
  2622. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2623. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2624. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2625. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2626. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2627. static readonly STEP_POINTERMOVE_SPRITE: number;
  2628. static readonly STEP_POINTERDOWN_SPRITE: number;
  2629. static readonly STEP_POINTERUP_SPRITE: number;
  2630. }
  2631. /**
  2632. * This represents a scene component.
  2633. *
  2634. * This is used to decouple the dependency the scene is having on the different workloads like
  2635. * layers, post processes...
  2636. */
  2637. interface ISceneComponent {
  2638. /**
  2639. * The name of the component. Each component must have a unique name.
  2640. */
  2641. name: string;
  2642. /**
  2643. * The scene the component belongs to.
  2644. */
  2645. scene: Scene;
  2646. /**
  2647. * Register the component to one instance of a scene.
  2648. */
  2649. register(): void;
  2650. /**
  2651. * Rebuilds the elements related to this component in case of
  2652. * context lost for instance.
  2653. */
  2654. rebuild(): void;
  2655. /**
  2656. * Disposes the component and the associated ressources.
  2657. */
  2658. dispose(): void;
  2659. }
  2660. /**
  2661. * This represents a SERIALIZABLE scene component.
  2662. *
  2663. * This extends Scene Component to add Serialization methods on top.
  2664. */
  2665. interface ISceneSerializableComponent extends ISceneComponent {
  2666. /**
  2667. * Adds all the element from the container to the scene
  2668. * @param container the container holding the elements
  2669. */
  2670. addFromContainer(container: AbstractScene): void;
  2671. /**
  2672. * Removes all the elements in the container from the scene
  2673. * @param container contains the elements to remove
  2674. */
  2675. removeFromContainer(container: AbstractScene): void;
  2676. /**
  2677. * Serializes the component data to the specified json object
  2678. * @param serializationObject The object to serialize to
  2679. */
  2680. serialize(serializationObject: any): void;
  2681. }
  2682. /**
  2683. * Strong typing of a Mesh related stage step action
  2684. */
  2685. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2686. /**
  2687. * Strong typing of a Evaluate Sub Mesh related stage step action
  2688. */
  2689. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2690. /**
  2691. * Strong typing of a Active Mesh related stage step action
  2692. */
  2693. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2694. /**
  2695. * Strong typing of a Camera related stage step action
  2696. */
  2697. type CameraStageAction = (camera: Camera) => void;
  2698. /**
  2699. * Strong typing of a Render Target related stage step action
  2700. */
  2701. type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  2702. /**
  2703. * Strong typing of a RenderingGroup related stage step action
  2704. */
  2705. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2706. /**
  2707. * Strong typing of a Mesh Render related stage step action
  2708. */
  2709. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2710. /**
  2711. * Strong typing of a simple stage step action
  2712. */
  2713. type SimpleStageAction = () => void;
  2714. /**
  2715. * Strong typing of a render target action.
  2716. */
  2717. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2718. /**
  2719. * Strong typing of a pointer move action.
  2720. */
  2721. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2722. /**
  2723. * Strong typing of a pointer up/down action.
  2724. */
  2725. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2726. /**
  2727. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2728. * @hidden
  2729. */
  2730. class Stage<T extends Function> extends Array<{
  2731. index: number;
  2732. component: ISceneComponent;
  2733. action: T;
  2734. }> {
  2735. /**
  2736. * Hide ctor from the rest of the world.
  2737. * @param items The items to add.
  2738. */
  2739. private constructor();
  2740. /**
  2741. * Creates a new Stage.
  2742. * @returns A new instance of a Stage
  2743. */
  2744. static Create<T extends Function>(): Stage<T>;
  2745. /**
  2746. * Registers a step in an ordered way in the targeted stage.
  2747. * @param index Defines the position to register the step in
  2748. * @param component Defines the component attached to the step
  2749. * @param action Defines the action to launch during the step
  2750. */
  2751. registerStep(index: number, component: ISceneComponent, action: T): void;
  2752. /**
  2753. * Clears all the steps from the stage.
  2754. */
  2755. clear(): void;
  2756. }
  2757. }
  2758. declare module BABYLON {
  2759. /** Alias type for value that can be null */
  2760. type Nullable<T> = T | null;
  2761. /**
  2762. * Alias type for number that are floats
  2763. * @ignorenaming
  2764. */
  2765. type float = number;
  2766. /**
  2767. * Alias type for number that are doubles.
  2768. * @ignorenaming
  2769. */
  2770. type double = number;
  2771. /**
  2772. * Alias type for number that are integer
  2773. * @ignorenaming
  2774. */
  2775. type int = number;
  2776. /** Alias type for number array or Float32Array */
  2777. type FloatArray = number[] | Float32Array;
  2778. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2779. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2780. /**
  2781. * Alias for types that can be used by a Buffer or VertexBuffer.
  2782. */
  2783. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2784. /**
  2785. * Alias type for primitive types
  2786. * @ignorenaming
  2787. */
  2788. type Primitive = undefined | null | boolean | string | number | Function;
  2789. /**
  2790. * Type modifier to make all the properties of an object Readonly
  2791. */
  2792. type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  2793. /**
  2794. * Type modifier to make all the properties of an object Readonly recursively
  2795. */
  2796. type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  2797. /** @hidden */
  2798. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  2799. }
  2800. /** @hidden */
  2801. /** @hidden */
  2802. type DeepImmutableObject<T> = {
  2803. readonly [K in keyof T]: DeepImmutable<T[K]>;
  2804. };
  2805. }
  2806. declare module BABYLON {
  2807. /**
  2808. * The action to be carried out following a trigger
  2809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2810. */
  2811. class Action {
  2812. /** the trigger, with or without parameters, for the action */
  2813. triggerOptions: any;
  2814. /**
  2815. * Trigger for the action
  2816. */
  2817. trigger: number;
  2818. /**
  2819. * Internal only - manager for action
  2820. * @hidden
  2821. */
  2822. _actionManager: ActionManager;
  2823. private _nextActiveAction;
  2824. private _child;
  2825. private _condition?;
  2826. private _triggerParameter;
  2827. /**
  2828. * An event triggered prior to action being executed.
  2829. */
  2830. onBeforeExecuteObservable: Observable<Action>;
  2831. /**
  2832. * Creates a new Action
  2833. * @param triggerOptions the trigger, with or without parameters, for the action
  2834. * @param condition an optional determinant of action
  2835. */
  2836. constructor(
  2837. /** the trigger, with or without parameters, for the action */
  2838. triggerOptions: any, condition?: Condition);
  2839. /**
  2840. * Internal only
  2841. * @hidden
  2842. */
  2843. _prepare(): void;
  2844. /**
  2845. * Gets the trigger parameters
  2846. * @returns the trigger parameters
  2847. */
  2848. getTriggerParameter(): any;
  2849. /**
  2850. * Internal only - executes current action event
  2851. * @hidden
  2852. */
  2853. _executeCurrent(evt?: ActionEvent): void;
  2854. /**
  2855. * Execute placeholder for child classes
  2856. * @param evt optional action event
  2857. */
  2858. execute(evt?: ActionEvent): void;
  2859. /**
  2860. * Skips to next active action
  2861. */
  2862. skipToNextActiveAction(): void;
  2863. /**
  2864. * Adds action to chain of actions, may be a DoNothingAction
  2865. * @param action defines the next action to execute
  2866. * @returns The action passed in
  2867. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2868. */
  2869. then(action: Action): Action;
  2870. /**
  2871. * Internal only
  2872. * @hidden
  2873. */
  2874. _getProperty(propertyPath: string): string;
  2875. /**
  2876. * Internal only
  2877. * @hidden
  2878. */
  2879. _getEffectiveTarget(target: any, propertyPath: string): any;
  2880. /**
  2881. * Serialize placeholder for child classes
  2882. * @param parent of child
  2883. * @returns the serialized object
  2884. */
  2885. serialize(parent: any): any;
  2886. /**
  2887. * Internal only called by serialize
  2888. * @hidden
  2889. */
  2890. protected _serialize(serializedAction: any, parent?: any): any;
  2891. /**
  2892. * Internal only
  2893. * @hidden
  2894. */
  2895. static _SerializeValueAsString: (value: any) => string;
  2896. /**
  2897. * Internal only
  2898. * @hidden
  2899. */
  2900. static _GetTargetProperty: (target: Scene | Node) => {
  2901. name: string;
  2902. targetType: string;
  2903. value: string;
  2904. };
  2905. }
  2906. }
  2907. declare module BABYLON {
  2908. /**
  2909. * ActionEvent is the event being sent when an action is triggered.
  2910. */
  2911. class ActionEvent {
  2912. /** The mesh or sprite that triggered the action */
  2913. source: any;
  2914. /** The X mouse cursor position at the time of the event */
  2915. pointerX: number;
  2916. /** The Y mouse cursor position at the time of the event */
  2917. pointerY: number;
  2918. /** The mesh that is currently pointed at (can be null) */
  2919. meshUnderPointer: Nullable<AbstractMesh>;
  2920. /** the original (browser) event that triggered the ActionEvent */
  2921. sourceEvent?: any;
  2922. /** additional data for the event */
  2923. additionalData?: any;
  2924. /**
  2925. * Creates a new ActionEvent
  2926. * @param source The mesh or sprite that triggered the action
  2927. * @param pointerX The X mouse cursor position at the time of the event
  2928. * @param pointerY The Y mouse cursor position at the time of the event
  2929. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2930. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2931. * @param additionalData additional data for the event
  2932. */
  2933. constructor(
  2934. /** The mesh or sprite that triggered the action */
  2935. source: any,
  2936. /** The X mouse cursor position at the time of the event */
  2937. pointerX: number,
  2938. /** The Y mouse cursor position at the time of the event */
  2939. pointerY: number,
  2940. /** The mesh that is currently pointed at (can be null) */
  2941. meshUnderPointer: Nullable<AbstractMesh>,
  2942. /** the original (browser) event that triggered the ActionEvent */
  2943. sourceEvent?: any,
  2944. /** additional data for the event */
  2945. additionalData?: any);
  2946. /**
  2947. * Helper function to auto-create an ActionEvent from a source mesh.
  2948. * @param source The source mesh that triggered the event
  2949. * @param evt The original (browser) event
  2950. * @param additionalData additional data for the event
  2951. * @returns the new ActionEvent
  2952. */
  2953. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2954. /**
  2955. * Helper function to auto-create an ActionEvent from a source sprite
  2956. * @param source The source sprite that triggered the event
  2957. * @param scene Scene associated with the sprite
  2958. * @param evt The original (browser) event
  2959. * @param additionalData additional data for the event
  2960. * @returns the new ActionEvent
  2961. */
  2962. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2963. /**
  2964. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2965. * @param scene the scene where the event occurred
  2966. * @param evt The original (browser) event
  2967. * @returns the new ActionEvent
  2968. */
  2969. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2970. /**
  2971. * Helper function to auto-create an ActionEvent from a primitive
  2972. * @param prim defines the target primitive
  2973. * @param pointerPos defines the pointer position
  2974. * @param evt The original (browser) event
  2975. * @param additionalData additional data for the event
  2976. * @returns the new ActionEvent
  2977. */
  2978. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2979. }
  2980. /**
  2981. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2982. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2984. */
  2985. class ActionManager {
  2986. /**
  2987. * Nothing
  2988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2989. */
  2990. static readonly NothingTrigger: number;
  2991. /**
  2992. * On pick
  2993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2994. */
  2995. static readonly OnPickTrigger: number;
  2996. /**
  2997. * On left pick
  2998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2999. */
  3000. static readonly OnLeftPickTrigger: number;
  3001. /**
  3002. * On right pick
  3003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3004. */
  3005. static readonly OnRightPickTrigger: number;
  3006. /**
  3007. * On center pick
  3008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3009. */
  3010. static readonly OnCenterPickTrigger: number;
  3011. /**
  3012. * On pick down
  3013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3014. */
  3015. static readonly OnPickDownTrigger: number;
  3016. /**
  3017. * On double pick
  3018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3019. */
  3020. static readonly OnDoublePickTrigger: number;
  3021. /**
  3022. * On pick up
  3023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3024. */
  3025. static readonly OnPickUpTrigger: number;
  3026. /**
  3027. * On pick out.
  3028. * This trigger will only be raised if you also declared a OnPickDown
  3029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3030. */
  3031. static readonly OnPickOutTrigger: number;
  3032. /**
  3033. * On long press
  3034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3035. */
  3036. static readonly OnLongPressTrigger: number;
  3037. /**
  3038. * On pointer over
  3039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3040. */
  3041. static readonly OnPointerOverTrigger: number;
  3042. /**
  3043. * On pointer out
  3044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3045. */
  3046. static readonly OnPointerOutTrigger: number;
  3047. /**
  3048. * On every frame
  3049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3050. */
  3051. static readonly OnEveryFrameTrigger: number;
  3052. /**
  3053. * On intersection enter
  3054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3055. */
  3056. static readonly OnIntersectionEnterTrigger: number;
  3057. /**
  3058. * On intersection exit
  3059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3060. */
  3061. static readonly OnIntersectionExitTrigger: number;
  3062. /**
  3063. * On key down
  3064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3065. */
  3066. static readonly OnKeyDownTrigger: number;
  3067. /**
  3068. * On key up
  3069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3070. */
  3071. static readonly OnKeyUpTrigger: number;
  3072. /** Gets the list of active triggers */
  3073. static Triggers: {
  3074. [key: string]: number;
  3075. };
  3076. /** Gets the list of actions */
  3077. actions: Action[];
  3078. /** Gets the cursor to use when hovering items */
  3079. hoverCursor: string;
  3080. private _scene;
  3081. /**
  3082. * Creates a new action manager
  3083. * @param scene defines the hosting scene
  3084. */
  3085. constructor(scene: Scene);
  3086. /**
  3087. * Releases all associated resources
  3088. */
  3089. dispose(): void;
  3090. /**
  3091. * Gets hosting scene
  3092. * @returns the hosting scene
  3093. */
  3094. getScene(): Scene;
  3095. /**
  3096. * Does this action manager handles actions of any of the given triggers
  3097. * @param triggers defines the triggers to be tested
  3098. * @return a boolean indicating whether one (or more) of the triggers is handled
  3099. */
  3100. hasSpecificTriggers(triggers: number[]): boolean;
  3101. /**
  3102. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3103. * speed.
  3104. * @param triggerA defines the trigger to be tested
  3105. * @param triggerB defines the trigger to be tested
  3106. * @return a boolean indicating whether one (or more) of the triggers is handled
  3107. */
  3108. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3109. /**
  3110. * Does this action manager handles actions of a given trigger
  3111. * @param trigger defines the trigger to be tested
  3112. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3113. * @return whether the trigger is handled
  3114. */
  3115. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3116. /**
  3117. * Does this action manager has pointer triggers
  3118. */
  3119. readonly hasPointerTriggers: boolean;
  3120. /**
  3121. * Does this action manager has pick triggers
  3122. */
  3123. readonly hasPickTriggers: boolean;
  3124. /**
  3125. * Does exist one action manager with at least one trigger
  3126. **/
  3127. static readonly HasTriggers: boolean;
  3128. /**
  3129. * Does exist one action manager with at least one pick trigger
  3130. **/
  3131. static readonly HasPickTriggers: boolean;
  3132. /**
  3133. * Does exist one action manager that handles actions of a given trigger
  3134. * @param trigger defines the trigger to be tested
  3135. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3136. **/
  3137. static HasSpecificTrigger(trigger: number): boolean;
  3138. /**
  3139. * Registers an action to this action manager
  3140. * @param action defines the action to be registered
  3141. * @return the action amended (prepared) after registration
  3142. */
  3143. registerAction(action: Action): Nullable<Action>;
  3144. /**
  3145. * Unregisters an action to this action manager
  3146. * @param action defines the action to be unregistered
  3147. * @return a boolean indicating whether the action has been unregistered
  3148. */
  3149. unregisterAction(action: Action): Boolean;
  3150. /**
  3151. * Process a specific trigger
  3152. * @param trigger defines the trigger to process
  3153. * @param evt defines the event details to be processed
  3154. */
  3155. processTrigger(trigger: number, evt?: ActionEvent): void;
  3156. /** @hidden */
  3157. _getEffectiveTarget(target: any, propertyPath: string): any;
  3158. /** @hidden */
  3159. _getProperty(propertyPath: string): string;
  3160. /**
  3161. * Serialize this manager to a JSON object
  3162. * @param name defines the property name to store this manager
  3163. * @returns a JSON representation of this manager
  3164. */
  3165. serialize(name: string): any;
  3166. /**
  3167. * Creates a new ActionManager from a JSON data
  3168. * @param parsedActions defines the JSON data to read from
  3169. * @param object defines the hosting mesh
  3170. * @param scene defines the hosting scene
  3171. */
  3172. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3173. /**
  3174. * Get a trigger name by index
  3175. * @param trigger defines the trigger index
  3176. * @returns a trigger name
  3177. */
  3178. static GetTriggerName(trigger: number): string;
  3179. }
  3180. }
  3181. declare module BABYLON {
  3182. /**
  3183. * A Condition applied to an Action
  3184. */
  3185. class Condition {
  3186. /**
  3187. * Internal only - manager for action
  3188. * @hidden
  3189. */
  3190. _actionManager: ActionManager;
  3191. /**
  3192. * Internal only
  3193. * @hidden
  3194. */
  3195. _evaluationId: number;
  3196. /**
  3197. * Internal only
  3198. * @hidden
  3199. */
  3200. _currentResult: boolean;
  3201. /**
  3202. * Creates a new Condition
  3203. * @param actionManager the manager of the action the condition is applied to
  3204. */
  3205. constructor(actionManager: ActionManager);
  3206. /**
  3207. * Check if the current condition is valid
  3208. * @returns a boolean
  3209. */
  3210. isValid(): boolean;
  3211. /**
  3212. * Internal only
  3213. * @hidden
  3214. */
  3215. _getProperty(propertyPath: string): string;
  3216. /**
  3217. * Internal only
  3218. * @hidden
  3219. */
  3220. _getEffectiveTarget(target: any, propertyPath: string): any;
  3221. /**
  3222. * Serialize placeholder for child classes
  3223. * @returns the serialized object
  3224. */
  3225. serialize(): any;
  3226. /**
  3227. * Internal only
  3228. * @hidden
  3229. */
  3230. protected _serialize(serializedCondition: any): any;
  3231. }
  3232. /**
  3233. * Defines specific conditional operators as extensions of Condition
  3234. */
  3235. class ValueCondition extends Condition {
  3236. /** path to specify the property of the target the conditional operator uses */
  3237. propertyPath: string;
  3238. /** the value compared by the conditional operator against the current value of the property */
  3239. value: any;
  3240. /** the conditional operator, default ValueCondition.IsEqual */
  3241. operator: number;
  3242. /**
  3243. * Internal only
  3244. * @hidden
  3245. */
  3246. private static _IsEqual;
  3247. /**
  3248. * Internal only
  3249. * @hidden
  3250. */
  3251. private static _IsDifferent;
  3252. /**
  3253. * Internal only
  3254. * @hidden
  3255. */
  3256. private static _IsGreater;
  3257. /**
  3258. * Internal only
  3259. * @hidden
  3260. */
  3261. private static _IsLesser;
  3262. /**
  3263. * returns the number for IsEqual
  3264. */
  3265. static readonly IsEqual: number;
  3266. /**
  3267. * Returns the number for IsDifferent
  3268. */
  3269. static readonly IsDifferent: number;
  3270. /**
  3271. * Returns the number for IsGreater
  3272. */
  3273. static readonly IsGreater: number;
  3274. /**
  3275. * Returns the number for IsLesser
  3276. */
  3277. static readonly IsLesser: number;
  3278. /**
  3279. * Internal only The action manager for the condition
  3280. * @hidden
  3281. */
  3282. _actionManager: ActionManager;
  3283. /**
  3284. * Internal only
  3285. * @hidden
  3286. */
  3287. private _target;
  3288. /**
  3289. * Internal only
  3290. * @hidden
  3291. */
  3292. private _effectiveTarget;
  3293. /**
  3294. * Internal only
  3295. * @hidden
  3296. */
  3297. private _property;
  3298. /**
  3299. * Creates a new ValueCondition
  3300. * @param actionManager manager for the action the condition applies to
  3301. * @param target for the action
  3302. * @param propertyPath path to specify the property of the target the conditional operator uses
  3303. * @param value the value compared by the conditional operator against the current value of the property
  3304. * @param operator the conditional operator, default ValueCondition.IsEqual
  3305. */
  3306. constructor(actionManager: ActionManager, target: any,
  3307. /** path to specify the property of the target the conditional operator uses */
  3308. propertyPath: string,
  3309. /** the value compared by the conditional operator against the current value of the property */
  3310. value: any,
  3311. /** the conditional operator, default ValueCondition.IsEqual */
  3312. operator?: number);
  3313. /**
  3314. * Compares the given value with the property value for the specified conditional operator
  3315. * @returns the result of the comparison
  3316. */
  3317. isValid(): boolean;
  3318. /**
  3319. * Serialize the ValueCondition into a JSON compatible object
  3320. * @returns serialization object
  3321. */
  3322. serialize(): any;
  3323. /**
  3324. * Gets the name of the conditional operator for the ValueCondition
  3325. * @param operator the conditional operator
  3326. * @returns the name
  3327. */
  3328. static GetOperatorName(operator: number): string;
  3329. }
  3330. /**
  3331. * Defines a predicate condition as an extension of Condition
  3332. */
  3333. class PredicateCondition extends Condition {
  3334. /** defines the predicate function used to validate the condition */
  3335. predicate: () => boolean;
  3336. /**
  3337. * Internal only - manager for action
  3338. * @hidden
  3339. */
  3340. _actionManager: ActionManager;
  3341. /**
  3342. * Creates a new PredicateCondition
  3343. * @param actionManager manager for the action the condition applies to
  3344. * @param predicate defines the predicate function used to validate the condition
  3345. */
  3346. constructor(actionManager: ActionManager,
  3347. /** defines the predicate function used to validate the condition */
  3348. predicate: () => boolean);
  3349. /**
  3350. * @returns the validity of the predicate condition
  3351. */
  3352. isValid(): boolean;
  3353. }
  3354. /**
  3355. * Defines a state condition as an extension of Condition
  3356. */
  3357. class StateCondition extends Condition {
  3358. /** Value to compare with target state */
  3359. value: string;
  3360. /**
  3361. * Internal only - manager for action
  3362. * @hidden
  3363. */
  3364. _actionManager: ActionManager;
  3365. /**
  3366. * Internal only
  3367. * @hidden
  3368. */
  3369. private _target;
  3370. /**
  3371. * Creates a new StateCondition
  3372. * @param actionManager manager for the action the condition applies to
  3373. * @param target of the condition
  3374. * @param value to compare with target state
  3375. */
  3376. constructor(actionManager: ActionManager, target: any,
  3377. /** Value to compare with target state */
  3378. value: string);
  3379. /**
  3380. * Gets a boolean indicating if the current condition is met
  3381. * @returns the validity of the state
  3382. */
  3383. isValid(): boolean;
  3384. /**
  3385. * Serialize the StateCondition into a JSON compatible object
  3386. * @returns serialization object
  3387. */
  3388. serialize(): any;
  3389. }
  3390. }
  3391. declare module BABYLON {
  3392. /**
  3393. * This defines an action responsible to toggle a boolean once triggered.
  3394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3395. */
  3396. class SwitchBooleanAction extends Action {
  3397. /**
  3398. * The path to the boolean property in the target object
  3399. */
  3400. propertyPath: string;
  3401. private _target;
  3402. private _effectiveTarget;
  3403. private _property;
  3404. /**
  3405. * Instantiate the action
  3406. * @param triggerOptions defines the trigger options
  3407. * @param target defines the object containing the boolean
  3408. * @param propertyPath defines the path to the boolean property in the target object
  3409. * @param condition defines the trigger related conditions
  3410. */
  3411. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3412. /** @hidden */
  3413. _prepare(): void;
  3414. /**
  3415. * Execute the action toggle the boolean value.
  3416. */
  3417. execute(): void;
  3418. /**
  3419. * Serializes the actions and its related information.
  3420. * @param parent defines the object to serialize in
  3421. * @returns the serialized object
  3422. */
  3423. serialize(parent: any): any;
  3424. }
  3425. /**
  3426. * This defines an action responsible to set a the state field of the target
  3427. * to a desired value once triggered.
  3428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3429. */
  3430. class SetStateAction extends Action {
  3431. /**
  3432. * The value to store in the state field.
  3433. */
  3434. value: string;
  3435. private _target;
  3436. /**
  3437. * Instantiate the action
  3438. * @param triggerOptions defines the trigger options
  3439. * @param target defines the object containing the state property
  3440. * @param value defines the value to store in the state field
  3441. * @param condition defines the trigger related conditions
  3442. */
  3443. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3444. /**
  3445. * Execute the action and store the value on the target state property.
  3446. */
  3447. execute(): void;
  3448. /**
  3449. * Serializes the actions and its related information.
  3450. * @param parent defines the object to serialize in
  3451. * @returns the serialized object
  3452. */
  3453. serialize(parent: any): any;
  3454. }
  3455. /**
  3456. * This defines an action responsible to set a property of the target
  3457. * to a desired value once triggered.
  3458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3459. */
  3460. class SetValueAction extends Action {
  3461. /**
  3462. * The path of the property to set in the target.
  3463. */
  3464. propertyPath: string;
  3465. /**
  3466. * The value to set in the property
  3467. */
  3468. value: any;
  3469. private _target;
  3470. private _effectiveTarget;
  3471. private _property;
  3472. /**
  3473. * Instantiate the action
  3474. * @param triggerOptions defines the trigger options
  3475. * @param target defines the object containing the property
  3476. * @param propertyPath defines the path of the property to set in the target
  3477. * @param value defines the value to set in the property
  3478. * @param condition defines the trigger related conditions
  3479. */
  3480. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3481. /** @hidden */
  3482. _prepare(): void;
  3483. /**
  3484. * Execute the action and set the targetted property to the desired value.
  3485. */
  3486. execute(): void;
  3487. /**
  3488. * Serializes the actions and its related information.
  3489. * @param parent defines the object to serialize in
  3490. * @returns the serialized object
  3491. */
  3492. serialize(parent: any): any;
  3493. }
  3494. /**
  3495. * This defines an action responsible to increment the target value
  3496. * to a desired value once triggered.
  3497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3498. */
  3499. class IncrementValueAction extends Action {
  3500. /**
  3501. * The path of the property to increment in the target.
  3502. */
  3503. propertyPath: string;
  3504. /**
  3505. * The value we should increment the property by.
  3506. */
  3507. value: any;
  3508. private _target;
  3509. private _effectiveTarget;
  3510. private _property;
  3511. /**
  3512. * Instantiate the action
  3513. * @param triggerOptions defines the trigger options
  3514. * @param target defines the object containing the property
  3515. * @param propertyPath defines the path of the property to increment in the target
  3516. * @param value defines the value value we should increment the property by
  3517. * @param condition defines the trigger related conditions
  3518. */
  3519. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3520. /** @hidden */
  3521. _prepare(): void;
  3522. /**
  3523. * Execute the action and increment the target of the value amount.
  3524. */
  3525. execute(): void;
  3526. /**
  3527. * Serializes the actions and its related information.
  3528. * @param parent defines the object to serialize in
  3529. * @returns the serialized object
  3530. */
  3531. serialize(parent: any): any;
  3532. }
  3533. /**
  3534. * This defines an action responsible to start an animation once triggered.
  3535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3536. */
  3537. class PlayAnimationAction extends Action {
  3538. /**
  3539. * Where the animation should start (animation frame)
  3540. */
  3541. from: number;
  3542. /**
  3543. * Where the animation should stop (animation frame)
  3544. */
  3545. to: number;
  3546. /**
  3547. * Define if the animation should loop or stop after the first play.
  3548. */
  3549. loop?: boolean;
  3550. private _target;
  3551. /**
  3552. * Instantiate the action
  3553. * @param triggerOptions defines the trigger options
  3554. * @param target defines the target animation or animation name
  3555. * @param from defines from where the animation should start (animation frame)
  3556. * @param end defines where the animation should stop (animation frame)
  3557. * @param loop defines if the animation should loop or stop after the first play
  3558. * @param condition defines the trigger related conditions
  3559. */
  3560. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3561. /** @hidden */
  3562. _prepare(): void;
  3563. /**
  3564. * Execute the action and play the animation.
  3565. */
  3566. execute(): void;
  3567. /**
  3568. * Serializes the actions and its related information.
  3569. * @param parent defines the object to serialize in
  3570. * @returns the serialized object
  3571. */
  3572. serialize(parent: any): any;
  3573. }
  3574. /**
  3575. * This defines an action responsible to stop an animation once triggered.
  3576. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3577. */
  3578. class StopAnimationAction extends Action {
  3579. private _target;
  3580. /**
  3581. * Instantiate the action
  3582. * @param triggerOptions defines the trigger options
  3583. * @param target defines the target animation or animation name
  3584. * @param condition defines the trigger related conditions
  3585. */
  3586. constructor(triggerOptions: any, target: any, condition?: Condition);
  3587. /** @hidden */
  3588. _prepare(): void;
  3589. /**
  3590. * Execute the action and stop the animation.
  3591. */
  3592. execute(): void;
  3593. /**
  3594. * Serializes the actions and its related information.
  3595. * @param parent defines the object to serialize in
  3596. * @returns the serialized object
  3597. */
  3598. serialize(parent: any): any;
  3599. }
  3600. /**
  3601. * This defines an action responsible that does nothing once triggered.
  3602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3603. */
  3604. class DoNothingAction extends Action {
  3605. /**
  3606. * Instantiate the action
  3607. * @param triggerOptions defines the trigger options
  3608. * @param condition defines the trigger related conditions
  3609. */
  3610. constructor(triggerOptions?: any, condition?: Condition);
  3611. /**
  3612. * Execute the action and do nothing.
  3613. */
  3614. execute(): void;
  3615. /**
  3616. * Serializes the actions and its related information.
  3617. * @param parent defines the object to serialize in
  3618. * @returns the serialized object
  3619. */
  3620. serialize(parent: any): any;
  3621. }
  3622. /**
  3623. * This defines an action responsible to trigger several actions once triggered.
  3624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3625. */
  3626. class CombineAction extends Action {
  3627. /**
  3628. * The list of aggregated animations to run.
  3629. */
  3630. children: Action[];
  3631. /**
  3632. * Instantiate the action
  3633. * @param triggerOptions defines the trigger options
  3634. * @param children defines the list of aggregated animations to run
  3635. * @param condition defines the trigger related conditions
  3636. */
  3637. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3638. /** @hidden */
  3639. _prepare(): void;
  3640. /**
  3641. * Execute the action and executes all the aggregated actions.
  3642. */
  3643. execute(evt: ActionEvent): void;
  3644. /**
  3645. * Serializes the actions and its related information.
  3646. * @param parent defines the object to serialize in
  3647. * @returns the serialized object
  3648. */
  3649. serialize(parent: any): any;
  3650. }
  3651. /**
  3652. * This defines an action responsible to run code (external event) once triggered.
  3653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3654. */
  3655. class ExecuteCodeAction extends Action {
  3656. /**
  3657. * The callback function to run.
  3658. */
  3659. func: (evt: ActionEvent) => void;
  3660. /**
  3661. * Instantiate the action
  3662. * @param triggerOptions defines the trigger options
  3663. * @param func defines the callback function to run
  3664. * @param condition defines the trigger related conditions
  3665. */
  3666. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3667. /**
  3668. * Execute the action and run the attached code.
  3669. */
  3670. execute(evt: ActionEvent): void;
  3671. }
  3672. /**
  3673. * This defines an action responsible to set the parent property of the target once triggered.
  3674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3675. */
  3676. class SetParentAction extends Action {
  3677. private _parent;
  3678. private _target;
  3679. /**
  3680. * Instantiate the action
  3681. * @param triggerOptions defines the trigger options
  3682. * @param target defines the target containing the parent property
  3683. * @param parent defines from where the animation should start (animation frame)
  3684. * @param condition defines the trigger related conditions
  3685. */
  3686. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3687. /** @hidden */
  3688. _prepare(): void;
  3689. /**
  3690. * Execute the action and set the parent property.
  3691. */
  3692. execute(): void;
  3693. /**
  3694. * Serializes the actions and its related information.
  3695. * @param parent defines the object to serialize in
  3696. * @returns the serialized object
  3697. */
  3698. serialize(parent: any): any;
  3699. }
  3700. }
  3701. declare module BABYLON {
  3702. /**
  3703. * This defines an action helpful to play a defined sound on a triggered action.
  3704. */
  3705. class PlaySoundAction extends Action {
  3706. private _sound;
  3707. /**
  3708. * Instantiate the action
  3709. * @param triggerOptions defines the trigger options
  3710. * @param sound defines the sound to play
  3711. * @param condition defines the trigger related conditions
  3712. */
  3713. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3714. /** @hidden */
  3715. _prepare(): void;
  3716. /**
  3717. * Execute the action and play the sound.
  3718. */
  3719. execute(): void;
  3720. /**
  3721. * Serializes the actions and its related information.
  3722. * @param parent defines the object to serialize in
  3723. * @returns the serialized object
  3724. */
  3725. serialize(parent: any): any;
  3726. }
  3727. /**
  3728. * This defines an action helpful to stop a defined sound on a triggered action.
  3729. */
  3730. class StopSoundAction extends Action {
  3731. private _sound;
  3732. /**
  3733. * Instantiate the action
  3734. * @param triggerOptions defines the trigger options
  3735. * @param sound defines the sound to stop
  3736. * @param condition defines the trigger related conditions
  3737. */
  3738. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3739. /** @hidden */
  3740. _prepare(): void;
  3741. /**
  3742. * Execute the action and stop the sound.
  3743. */
  3744. execute(): void;
  3745. /**
  3746. * Serializes the actions and its related information.
  3747. * @param parent defines the object to serialize in
  3748. * @returns the serialized object
  3749. */
  3750. serialize(parent: any): any;
  3751. }
  3752. }
  3753. declare module BABYLON {
  3754. /**
  3755. * This defines an action responsible to change the value of a property
  3756. * by interpolating between its current value and the newly set one once triggered.
  3757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3758. */
  3759. class InterpolateValueAction extends Action {
  3760. /**
  3761. * Defines the path of the property where the value should be interpolated
  3762. */
  3763. propertyPath: string;
  3764. /**
  3765. * Defines the target value at the end of the interpolation.
  3766. */
  3767. value: any;
  3768. /**
  3769. * Defines the time it will take for the property to interpolate to the value.
  3770. */
  3771. duration: number;
  3772. /**
  3773. * Defines if the other scene animations should be stopped when the action has been triggered
  3774. */
  3775. stopOtherAnimations?: boolean;
  3776. /**
  3777. * Defines a callback raised once the interpolation animation has been done.
  3778. */
  3779. onInterpolationDone?: () => void;
  3780. /**
  3781. * Observable triggered once the interpolation animation has been done.
  3782. */
  3783. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3784. private _target;
  3785. private _effectiveTarget;
  3786. private _property;
  3787. /**
  3788. * Instantiate the action
  3789. * @param triggerOptions defines the trigger options
  3790. * @param target defines the object containing the value to interpolate
  3791. * @param propertyPath defines the path to the property in the target object
  3792. * @param value defines the target value at the end of the interpolation
  3793. * @param duration deines the time it will take for the property to interpolate to the value.
  3794. * @param condition defines the trigger related conditions
  3795. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3796. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3797. */
  3798. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3799. /** @hidden */
  3800. _prepare(): void;
  3801. /**
  3802. * Execute the action starts the value interpolation.
  3803. */
  3804. execute(): void;
  3805. /**
  3806. * Serializes the actions and its related information.
  3807. * @param parent defines the object to serialize in
  3808. * @returns the serialized object
  3809. */
  3810. serialize(parent: any): any;
  3811. }
  3812. }
  3813. declare module BABYLON {
  3814. /**
  3815. * Class used to store an actual running animation
  3816. */
  3817. class Animatable {
  3818. /** defines the target object */
  3819. target: any;
  3820. /** defines the starting frame number (default is 0) */
  3821. fromFrame: number;
  3822. /** defines the ending frame number (default is 100) */
  3823. toFrame: number;
  3824. /** defines if the animation must loop (default is false) */
  3825. loopAnimation: boolean;
  3826. /** defines a callback to call when animation ends if it is not looping */
  3827. onAnimationEnd?: (() => void) | null | undefined;
  3828. private _localDelayOffset;
  3829. private _pausedDelay;
  3830. private _runtimeAnimations;
  3831. private _paused;
  3832. private _scene;
  3833. private _speedRatio;
  3834. private _weight;
  3835. private _syncRoot;
  3836. /**
  3837. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3838. * This will only apply for non looping animation (default is true)
  3839. */
  3840. disposeOnEnd: boolean;
  3841. /**
  3842. * Gets a boolean indicating if the animation has started
  3843. */
  3844. animationStarted: boolean;
  3845. /**
  3846. * Observer raised when the animation ends
  3847. */
  3848. onAnimationEndObservable: Observable<Animatable>;
  3849. /**
  3850. * Gets the root Animatable used to synchronize and normalize animations
  3851. */
  3852. readonly syncRoot: Animatable;
  3853. /**
  3854. * Gets the current frame of the first RuntimeAnimation
  3855. * Used to synchronize Animatables
  3856. */
  3857. readonly masterFrame: number;
  3858. /**
  3859. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3860. */
  3861. weight: number;
  3862. /**
  3863. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3864. */
  3865. speedRatio: number;
  3866. /**
  3867. * Creates a new Animatable
  3868. * @param scene defines the hosting scene
  3869. * @param target defines the target object
  3870. * @param fromFrame defines the starting frame number (default is 0)
  3871. * @param toFrame defines the ending frame number (default is 100)
  3872. * @param loopAnimation defines if the animation must loop (default is false)
  3873. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3874. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3875. * @param animations defines a group of animation to add to the new Animatable
  3876. */
  3877. constructor(scene: Scene,
  3878. /** defines the target object */
  3879. target: any,
  3880. /** defines the starting frame number (default is 0) */
  3881. fromFrame?: number,
  3882. /** defines the ending frame number (default is 100) */
  3883. toFrame?: number,
  3884. /** defines if the animation must loop (default is false) */
  3885. loopAnimation?: boolean, speedRatio?: number,
  3886. /** defines a callback to call when animation ends if it is not looping */
  3887. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3888. /**
  3889. * Synchronize and normalize current Animatable with a source Animatable
  3890. * This is useful when using animation weights and when animations are not of the same length
  3891. * @param root defines the root Animatable to synchronize with
  3892. * @returns the current Animatable
  3893. */
  3894. syncWith(root: Animatable): Animatable;
  3895. /**
  3896. * Gets the list of runtime animations
  3897. * @returns an array of RuntimeAnimation
  3898. */
  3899. getAnimations(): RuntimeAnimation[];
  3900. /**
  3901. * Adds more animations to the current animatable
  3902. * @param target defines the target of the animations
  3903. * @param animations defines the new animations to add
  3904. */
  3905. appendAnimations(target: any, animations: Animation[]): void;
  3906. /**
  3907. * Gets the source animation for a specific property
  3908. * @param property defines the propertyu to look for
  3909. * @returns null or the source animation for the given property
  3910. */
  3911. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3912. /**
  3913. * Gets the runtime animation for a specific property
  3914. * @param property defines the propertyu to look for
  3915. * @returns null or the runtime animation for the given property
  3916. */
  3917. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3918. /**
  3919. * Resets the animatable to its original state
  3920. */
  3921. reset(): void;
  3922. /**
  3923. * Allows the animatable to blend with current running animations
  3924. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3925. * @param blendingSpeed defines the blending speed to use
  3926. */
  3927. enableBlending(blendingSpeed: number): void;
  3928. /**
  3929. * Disable animation blending
  3930. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3931. */
  3932. disableBlending(): void;
  3933. /**
  3934. * Jump directly to a given frame
  3935. * @param frame defines the frame to jump to
  3936. */
  3937. goToFrame(frame: number): void;
  3938. /**
  3939. * Pause the animation
  3940. */
  3941. pause(): void;
  3942. /**
  3943. * Restart the animation
  3944. */
  3945. restart(): void;
  3946. private _raiseOnAnimationEnd;
  3947. /**
  3948. * Stop and delete the current animation
  3949. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3950. * @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)
  3951. */
  3952. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3953. /**
  3954. * Wait asynchronously for the animation to end
  3955. * @returns a promise which will be fullfilled when the animation ends
  3956. */
  3957. waitAsync(): Promise<Animatable>;
  3958. /** @hidden */
  3959. _animate(delay: number): boolean;
  3960. }
  3961. }
  3962. declare module BABYLON {
  3963. /**
  3964. * Represents the range of an animation
  3965. */
  3966. class AnimationRange {
  3967. /**The name of the animation range**/
  3968. name: string;
  3969. /**The starting frame of the animation */
  3970. from: number;
  3971. /**The ending frame of the animation*/
  3972. to: number;
  3973. /**
  3974. * Initializes the range of an animation
  3975. * @param name The name of the animation range
  3976. * @param from The starting frame of the animation
  3977. * @param to The ending frame of the animation
  3978. */
  3979. constructor(
  3980. /**The name of the animation range**/
  3981. name: string,
  3982. /**The starting frame of the animation */
  3983. from: number,
  3984. /**The ending frame of the animation*/
  3985. to: number);
  3986. /**
  3987. * Makes a copy of the animation range
  3988. * @returns A copy of the animation range
  3989. */
  3990. clone(): AnimationRange;
  3991. }
  3992. /**
  3993. * Composed of a frame, and an action function
  3994. */
  3995. class AnimationEvent {
  3996. /** The frame for which the event is triggered **/
  3997. frame: number;
  3998. /** The event to perform when triggered **/
  3999. action: (currentFrame: number) => void;
  4000. /** Specifies if the event should be triggered only once**/
  4001. onlyOnce?: boolean | undefined;
  4002. /**
  4003. * Specifies if the animation event is done
  4004. */
  4005. isDone: boolean;
  4006. /**
  4007. * Initializes the animation event
  4008. * @param frame The frame for which the event is triggered
  4009. * @param action The event to perform when triggered
  4010. * @param onlyOnce Specifies if the event should be triggered only once
  4011. */
  4012. constructor(
  4013. /** The frame for which the event is triggered **/
  4014. frame: number,
  4015. /** The event to perform when triggered **/
  4016. action: (currentFrame: number) => void,
  4017. /** Specifies if the event should be triggered only once**/
  4018. onlyOnce?: boolean | undefined);
  4019. /** @hidden */
  4020. _clone(): AnimationEvent;
  4021. }
  4022. /**
  4023. * A cursor which tracks a point on a path
  4024. */
  4025. class PathCursor {
  4026. private path;
  4027. /**
  4028. * Stores path cursor callbacks for when an onchange event is triggered
  4029. */
  4030. private _onchange;
  4031. /**
  4032. * The value of the path cursor
  4033. */
  4034. value: number;
  4035. /**
  4036. * The animation array of the path cursor
  4037. */
  4038. animations: Animation[];
  4039. /**
  4040. * Initializes the path cursor
  4041. * @param path The path to track
  4042. */
  4043. constructor(path: Path2);
  4044. /**
  4045. * Gets the cursor point on the path
  4046. * @returns A point on the path cursor at the cursor location
  4047. */
  4048. getPoint(): Vector3;
  4049. /**
  4050. * Moves the cursor ahead by the step amount
  4051. * @param step The amount to move the cursor forward
  4052. * @returns This path cursor
  4053. */
  4054. moveAhead(step?: number): PathCursor;
  4055. /**
  4056. * Moves the cursor behind by the step amount
  4057. * @param step The amount to move the cursor back
  4058. * @returns This path cursor
  4059. */
  4060. moveBack(step?: number): PathCursor;
  4061. /**
  4062. * Moves the cursor by the step amount
  4063. * If the step amount is greater than one, an exception is thrown
  4064. * @param step The amount to move the cursor
  4065. * @returns This path cursor
  4066. */
  4067. move(step: number): PathCursor;
  4068. /**
  4069. * Ensures that the value is limited between zero and one
  4070. * @returns This path cursor
  4071. */
  4072. private ensureLimits;
  4073. /**
  4074. * Runs onchange callbacks on change (used by the animation engine)
  4075. * @returns This path cursor
  4076. */
  4077. private raiseOnChange;
  4078. /**
  4079. * Executes a function on change
  4080. * @param f A path cursor onchange callback
  4081. * @returns This path cursor
  4082. */
  4083. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4084. }
  4085. /**
  4086. * Defines an interface which represents an animation key frame
  4087. */
  4088. interface IAnimationKey {
  4089. /**
  4090. * Frame of the key frame
  4091. */
  4092. frame: number;
  4093. /**
  4094. * Value at the specifies key frame
  4095. */
  4096. value: any;
  4097. /**
  4098. * The input tangent for the cubic hermite spline
  4099. */
  4100. inTangent?: any;
  4101. /**
  4102. * The output tangent for the cubic hermite spline
  4103. */
  4104. outTangent?: any;
  4105. /**
  4106. * The animation interpolation type
  4107. */
  4108. interpolation?: AnimationKeyInterpolation;
  4109. }
  4110. /**
  4111. * Enum for the animation key frame interpolation type
  4112. */
  4113. enum AnimationKeyInterpolation {
  4114. /**
  4115. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4116. */
  4117. STEP = 1
  4118. }
  4119. /**
  4120. * Class used to store any kind of animation
  4121. */
  4122. class Animation {
  4123. /**Name of the animation */
  4124. name: string;
  4125. /**Property to animate */
  4126. targetProperty: string;
  4127. /**The frames per second of the animation */
  4128. framePerSecond: number;
  4129. /**The data type of the animation */
  4130. dataType: number;
  4131. /**The loop mode of the animation */
  4132. loopMode?: number | undefined;
  4133. /**Specifies if blending should be enabled */
  4134. enableBlending?: boolean | undefined;
  4135. /**
  4136. * Use matrix interpolation instead of using direct key value when animating matrices
  4137. */
  4138. static AllowMatricesInterpolation: boolean;
  4139. /**
  4140. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4141. */
  4142. static AllowMatrixDecomposeForInterpolation: boolean;
  4143. /**
  4144. * Stores the key frames of the animation
  4145. */
  4146. private _keys;
  4147. /**
  4148. * Stores the easing function of the animation
  4149. */
  4150. private _easingFunction;
  4151. /**
  4152. * @hidden Internal use only
  4153. */
  4154. _runtimeAnimations: RuntimeAnimation[];
  4155. /**
  4156. * The set of event that will be linked to this animation
  4157. */
  4158. private _events;
  4159. /**
  4160. * Stores an array of target property paths
  4161. */
  4162. targetPropertyPath: string[];
  4163. /**
  4164. * Stores the blending speed of the animation
  4165. */
  4166. blendingSpeed: number;
  4167. /**
  4168. * Stores the animation ranges for the animation
  4169. */
  4170. private _ranges;
  4171. /**
  4172. * @hidden Internal use
  4173. */
  4174. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4175. /**
  4176. * Sets up an animation
  4177. * @param property The property to animate
  4178. * @param animationType The animation type to apply
  4179. * @param framePerSecond The frames per second of the animation
  4180. * @param easingFunction The easing function used in the animation
  4181. * @returns The created animation
  4182. */
  4183. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4184. /**
  4185. * Create and start an animation on a node
  4186. * @param name defines the name of the global animation that will be run on all nodes
  4187. * @param node defines the root node where the animation will take place
  4188. * @param targetProperty defines property to animate
  4189. * @param framePerSecond defines the number of frame per second yo use
  4190. * @param totalFrame defines the number of frames in total
  4191. * @param from defines the initial value
  4192. * @param to defines the final value
  4193. * @param loopMode defines which loop mode you want to use (off by default)
  4194. * @param easingFunction defines the easing function to use (linear by default)
  4195. * @param onAnimationEnd defines the callback to call when animation end
  4196. * @returns the animatable created for this animation
  4197. */
  4198. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4199. /**
  4200. * Create and start an animation on a node and its descendants
  4201. * @param name defines the name of the global animation that will be run on all nodes
  4202. * @param node defines the root node where the animation will take place
  4203. * @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
  4204. * @param targetProperty defines property to animate
  4205. * @param framePerSecond defines the number of frame per second to use
  4206. * @param totalFrame defines the number of frames in total
  4207. * @param from defines the initial value
  4208. * @param to defines the final value
  4209. * @param loopMode defines which loop mode you want to use (off by default)
  4210. * @param easingFunction defines the easing function to use (linear by default)
  4211. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4212. * @returns the list of animatables created for all nodes
  4213. * @example https://www.babylonjs-playground.com/#MH0VLI
  4214. */
  4215. 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[]>;
  4216. /**
  4217. * Creates a new animation, merges it with the existing animations and starts it
  4218. * @param name Name of the animation
  4219. * @param node Node which contains the scene that begins the animations
  4220. * @param targetProperty Specifies which property to animate
  4221. * @param framePerSecond The frames per second of the animation
  4222. * @param totalFrame The total number of frames
  4223. * @param from The frame at the beginning of the animation
  4224. * @param to The frame at the end of the animation
  4225. * @param loopMode Specifies the loop mode of the animation
  4226. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4227. * @param onAnimationEnd Callback to run once the animation is complete
  4228. * @returns Nullable animation
  4229. */
  4230. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4231. /**
  4232. * Transition property of an host to the target Value
  4233. * @param property The property to transition
  4234. * @param targetValue The target Value of the property
  4235. * @param host The object where the property to animate belongs
  4236. * @param scene Scene used to run the animation
  4237. * @param frameRate Framerate (in frame/s) to use
  4238. * @param transition The transition type we want to use
  4239. * @param duration The duration of the animation, in milliseconds
  4240. * @param onAnimationEnd Callback trigger at the end of the animation
  4241. * @returns Nullable animation
  4242. */
  4243. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4244. /**
  4245. * Return the array of runtime animations currently using this animation
  4246. */
  4247. readonly runtimeAnimations: RuntimeAnimation[];
  4248. /**
  4249. * Specifies if any of the runtime animations are currently running
  4250. */
  4251. readonly hasRunningRuntimeAnimations: boolean;
  4252. /**
  4253. * Initializes the animation
  4254. * @param name Name of the animation
  4255. * @param targetProperty Property to animate
  4256. * @param framePerSecond The frames per second of the animation
  4257. * @param dataType The data type of the animation
  4258. * @param loopMode The loop mode of the animation
  4259. * @param enableBlendings Specifies if blending should be enabled
  4260. */
  4261. constructor(
  4262. /**Name of the animation */
  4263. name: string,
  4264. /**Property to animate */
  4265. targetProperty: string,
  4266. /**The frames per second of the animation */
  4267. framePerSecond: number,
  4268. /**The data type of the animation */
  4269. dataType: number,
  4270. /**The loop mode of the animation */
  4271. loopMode?: number | undefined,
  4272. /**Specifies if blending should be enabled */
  4273. enableBlending?: boolean | undefined);
  4274. /**
  4275. * Converts the animation to a string
  4276. * @param fullDetails support for multiple levels of logging within scene loading
  4277. * @returns String form of the animation
  4278. */
  4279. toString(fullDetails?: boolean): string;
  4280. /**
  4281. * Add an event to this animation
  4282. * @param event Event to add
  4283. */
  4284. addEvent(event: AnimationEvent): void;
  4285. /**
  4286. * Remove all events found at the given frame
  4287. * @param frame The frame to remove events from
  4288. */
  4289. removeEvents(frame: number): void;
  4290. /**
  4291. * Retrieves all the events from the animation
  4292. * @returns Events from the animation
  4293. */
  4294. getEvents(): AnimationEvent[];
  4295. /**
  4296. * Creates an animation range
  4297. * @param name Name of the animation range
  4298. * @param from Starting frame of the animation range
  4299. * @param to Ending frame of the animation
  4300. */
  4301. createRange(name: string, from: number, to: number): void;
  4302. /**
  4303. * Deletes an animation range by name
  4304. * @param name Name of the animation range to delete
  4305. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4306. */
  4307. deleteRange(name: string, deleteFrames?: boolean): void;
  4308. /**
  4309. * Gets the animation range by name, or null if not defined
  4310. * @param name Name of the animation range
  4311. * @returns Nullable animation range
  4312. */
  4313. getRange(name: string): Nullable<AnimationRange>;
  4314. /**
  4315. * Gets the key frames from the animation
  4316. * @returns The key frames of the animation
  4317. */
  4318. getKeys(): Array<IAnimationKey>;
  4319. /**
  4320. * Gets the highest frame rate of the animation
  4321. * @returns Highest frame rate of the animation
  4322. */
  4323. getHighestFrame(): number;
  4324. /**
  4325. * Gets the easing function of the animation
  4326. * @returns Easing function of the animation
  4327. */
  4328. getEasingFunction(): IEasingFunction;
  4329. /**
  4330. * Sets the easing function of the animation
  4331. * @param easingFunction A custom mathematical formula for animation
  4332. */
  4333. setEasingFunction(easingFunction: EasingFunction): void;
  4334. /**
  4335. * Interpolates a scalar linearly
  4336. * @param startValue Start value of the animation curve
  4337. * @param endValue End value of the animation curve
  4338. * @param gradient Scalar amount to interpolate
  4339. * @returns Interpolated scalar value
  4340. */
  4341. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4342. /**
  4343. * Interpolates a scalar cubically
  4344. * @param startValue Start value of the animation curve
  4345. * @param outTangent End tangent of the animation
  4346. * @param endValue End value of the animation curve
  4347. * @param inTangent Start tangent of the animation curve
  4348. * @param gradient Scalar amount to interpolate
  4349. * @returns Interpolated scalar value
  4350. */
  4351. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4352. /**
  4353. * Interpolates a quaternion using a spherical linear interpolation
  4354. * @param startValue Start value of the animation curve
  4355. * @param endValue End value of the animation curve
  4356. * @param gradient Scalar amount to interpolate
  4357. * @returns Interpolated quaternion value
  4358. */
  4359. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4360. /**
  4361. * Interpolates a quaternion cubically
  4362. * @param startValue Start value of the animation curve
  4363. * @param outTangent End tangent of the animation curve
  4364. * @param endValue End value of the animation curve
  4365. * @param inTangent Start tangent of the animation curve
  4366. * @param gradient Scalar amount to interpolate
  4367. * @returns Interpolated quaternion value
  4368. */
  4369. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4370. /**
  4371. * Interpolates a Vector3 linearl
  4372. * @param startValue Start value of the animation curve
  4373. * @param endValue End value of the animation curve
  4374. * @param gradient Scalar amount to interpolate
  4375. * @returns Interpolated scalar value
  4376. */
  4377. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4378. /**
  4379. * Interpolates a Vector3 cubically
  4380. * @param startValue Start value of the animation curve
  4381. * @param outTangent End tangent of the animation
  4382. * @param endValue End value of the animation curve
  4383. * @param inTangent Start tangent of the animation curve
  4384. * @param gradient Scalar amount to interpolate
  4385. * @returns InterpolatedVector3 value
  4386. */
  4387. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4388. /**
  4389. * Interpolates a Vector2 linearly
  4390. * @param startValue Start value of the animation curve
  4391. * @param endValue End value of the animation curve
  4392. * @param gradient Scalar amount to interpolate
  4393. * @returns Interpolated Vector2 value
  4394. */
  4395. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4396. /**
  4397. * Interpolates a Vector2 cubically
  4398. * @param startValue Start value of the animation curve
  4399. * @param outTangent End tangent of the animation
  4400. * @param endValue End value of the animation curve
  4401. * @param inTangent Start tangent of the animation curve
  4402. * @param gradient Scalar amount to interpolate
  4403. * @returns Interpolated Vector2 value
  4404. */
  4405. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4406. /**
  4407. * Interpolates a size linearly
  4408. * @param startValue Start value of the animation curve
  4409. * @param endValue End value of the animation curve
  4410. * @param gradient Scalar amount to interpolate
  4411. * @returns Interpolated Size value
  4412. */
  4413. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4414. /**
  4415. * Interpolates a Color3 linearly
  4416. * @param startValue Start value of the animation curve
  4417. * @param endValue End value of the animation curve
  4418. * @param gradient Scalar amount to interpolate
  4419. * @returns Interpolated Color3 value
  4420. */
  4421. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4422. /**
  4423. * @hidden Internal use only
  4424. */
  4425. _getKeyValue(value: any): any;
  4426. /**
  4427. * @hidden Internal use only
  4428. */
  4429. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4430. /**
  4431. * Defines the function to use to interpolate matrices
  4432. * @param startValue defines the start matrix
  4433. * @param endValue defines the end matrix
  4434. * @param gradient defines the gradient between both matrices
  4435. * @param result defines an optional target matrix where to store the interpolation
  4436. * @returns the interpolated matrix
  4437. */
  4438. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4439. /**
  4440. * Makes a copy of the animation
  4441. * @returns Cloned animation
  4442. */
  4443. clone(): Animation;
  4444. /**
  4445. * Sets the key frames of the animation
  4446. * @param values The animation key frames to set
  4447. */
  4448. setKeys(values: Array<IAnimationKey>): void;
  4449. /**
  4450. * Serializes the animation to an object
  4451. * @returns Serialized object
  4452. */
  4453. serialize(): any;
  4454. /**
  4455. * Float animation type
  4456. */
  4457. private static _ANIMATIONTYPE_FLOAT;
  4458. /**
  4459. * Vector3 animation type
  4460. */
  4461. private static _ANIMATIONTYPE_VECTOR3;
  4462. /**
  4463. * Quaternion animation type
  4464. */
  4465. private static _ANIMATIONTYPE_QUATERNION;
  4466. /**
  4467. * Matrix animation type
  4468. */
  4469. private static _ANIMATIONTYPE_MATRIX;
  4470. /**
  4471. * Color3 animation type
  4472. */
  4473. private static _ANIMATIONTYPE_COLOR3;
  4474. /**
  4475. * Vector2 animation type
  4476. */
  4477. private static _ANIMATIONTYPE_VECTOR2;
  4478. /**
  4479. * Size animation type
  4480. */
  4481. private static _ANIMATIONTYPE_SIZE;
  4482. /**
  4483. * Relative Loop Mode
  4484. */
  4485. private static _ANIMATIONLOOPMODE_RELATIVE;
  4486. /**
  4487. * Cycle Loop Mode
  4488. */
  4489. private static _ANIMATIONLOOPMODE_CYCLE;
  4490. /**
  4491. * Constant Loop Mode
  4492. */
  4493. private static _ANIMATIONLOOPMODE_CONSTANT;
  4494. /**
  4495. * Get the float animation type
  4496. */
  4497. static readonly ANIMATIONTYPE_FLOAT: number;
  4498. /**
  4499. * Get the Vector3 animation type
  4500. */
  4501. static readonly ANIMATIONTYPE_VECTOR3: number;
  4502. /**
  4503. * Get the Vector2 animation type
  4504. */
  4505. static readonly ANIMATIONTYPE_VECTOR2: number;
  4506. /**
  4507. * Get the Size animation type
  4508. */
  4509. static readonly ANIMATIONTYPE_SIZE: number;
  4510. /**
  4511. * Get the Quaternion animation type
  4512. */
  4513. static readonly ANIMATIONTYPE_QUATERNION: number;
  4514. /**
  4515. * Get the Matrix animation type
  4516. */
  4517. static readonly ANIMATIONTYPE_MATRIX: number;
  4518. /**
  4519. * Get the Color3 animation type
  4520. */
  4521. static readonly ANIMATIONTYPE_COLOR3: number;
  4522. /**
  4523. * Get the Relative Loop Mode
  4524. */
  4525. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4526. /**
  4527. * Get the Cycle Loop Mode
  4528. */
  4529. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4530. /**
  4531. * Get the Constant Loop Mode
  4532. */
  4533. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4534. /** @hidden */
  4535. static _UniversalLerp(left: any, right: any, amount: number): any;
  4536. /**
  4537. * Parses an animation object and creates an animation
  4538. * @param parsedAnimation Parsed animation object
  4539. * @returns Animation object
  4540. */
  4541. static Parse(parsedAnimation: any): Animation;
  4542. /**
  4543. * Appends the serialized animations from the source animations
  4544. * @param source Source containing the animations
  4545. * @param destination Target to store the animations
  4546. */
  4547. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4548. }
  4549. }
  4550. declare module BABYLON {
  4551. /**
  4552. * This class defines the direct association between an animation and a target
  4553. */
  4554. class TargetedAnimation {
  4555. /**
  4556. * Animation to perform
  4557. */
  4558. animation: Animation;
  4559. /**
  4560. * Target to animate
  4561. */
  4562. target: any;
  4563. }
  4564. /**
  4565. * Use this class to create coordinated animations on multiple targets
  4566. */
  4567. class AnimationGroup implements IDisposable {
  4568. /** The name of the animation group */
  4569. name: string;
  4570. private _scene;
  4571. private _targetedAnimations;
  4572. private _animatables;
  4573. private _from;
  4574. private _to;
  4575. private _isStarted;
  4576. private _isPaused;
  4577. private _speedRatio;
  4578. /**
  4579. * Gets or sets the unique id of the node
  4580. */
  4581. uniqueId: number;
  4582. /**
  4583. * This observable will notify when one animation have ended.
  4584. */
  4585. onAnimationEndObservable: Observable<TargetedAnimation>;
  4586. /**
  4587. * This observable will notify when all animations have ended.
  4588. */
  4589. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4590. /**
  4591. * This observable will notify when all animations have paused.
  4592. */
  4593. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4594. /**
  4595. * This observable will notify when all animations are playing.
  4596. */
  4597. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  4598. /**
  4599. * Gets the first frame
  4600. */
  4601. readonly from: number;
  4602. /**
  4603. * Gets the last frame
  4604. */
  4605. readonly to: number;
  4606. /**
  4607. * Define if the animations are started
  4608. */
  4609. readonly isStarted: boolean;
  4610. /**
  4611. * Gets a value indicating that the current group is playing
  4612. */
  4613. readonly isPlaying: boolean;
  4614. /**
  4615. * Gets or sets the speed ratio to use for all animations
  4616. */
  4617. /**
  4618. * Gets or sets the speed ratio to use for all animations
  4619. */
  4620. speedRatio: number;
  4621. /**
  4622. * Gets the targeted animations for this animation group
  4623. */
  4624. readonly targetedAnimations: Array<TargetedAnimation>;
  4625. /**
  4626. * returning the list of animatables controlled by this animation group.
  4627. */
  4628. readonly animatables: Array<Animatable>;
  4629. /**
  4630. * Instantiates a new Animation Group.
  4631. * This helps managing several animations at once.
  4632. * @see http://doc.babylonjs.com/how_to/group
  4633. * @param name Defines the name of the group
  4634. * @param scene Defines the scene the group belongs to
  4635. */
  4636. constructor(
  4637. /** The name of the animation group */
  4638. name: string, scene?: Nullable<Scene>);
  4639. /**
  4640. * Add an animation (with its target) in the group
  4641. * @param animation defines the animation we want to add
  4642. * @param target defines the target of the animation
  4643. * @returns the TargetedAnimation object
  4644. */
  4645. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4646. /**
  4647. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4648. * It can add constant keys at begin or end
  4649. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4650. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4651. * @returns the animation group
  4652. */
  4653. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4654. /**
  4655. * Start all animations on given targets
  4656. * @param loop defines if animations must loop
  4657. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4658. * @param from defines the from key (optional)
  4659. * @param to defines the to key (optional)
  4660. * @returns the current animation group
  4661. */
  4662. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4663. /**
  4664. * Pause all animations
  4665. * @returns the animation group
  4666. */
  4667. pause(): AnimationGroup;
  4668. /**
  4669. * Play all animations to initial state
  4670. * This function will start() the animations if they were not started or will restart() them if they were paused
  4671. * @param loop defines if animations must loop
  4672. * @returns the animation group
  4673. */
  4674. play(loop?: boolean): AnimationGroup;
  4675. /**
  4676. * Reset all animations to initial state
  4677. * @returns the animation group
  4678. */
  4679. reset(): AnimationGroup;
  4680. /**
  4681. * Restart animations from key 0
  4682. * @returns the animation group
  4683. */
  4684. restart(): AnimationGroup;
  4685. /**
  4686. * Stop all animations
  4687. * @returns the animation group
  4688. */
  4689. stop(): AnimationGroup;
  4690. /**
  4691. * Set animation weight for all animatables
  4692. * @param weight defines the weight to use
  4693. * @return the animationGroup
  4694. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4695. */
  4696. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4697. /**
  4698. * Synchronize and normalize all animatables with a source animatable
  4699. * @param root defines the root animatable to synchronize with
  4700. * @return the animationGroup
  4701. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4702. */
  4703. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4704. /**
  4705. * Goes to a specific frame in this animation group
  4706. * @param frame the frame number to go to
  4707. * @return the animationGroup
  4708. */
  4709. goToFrame(frame: number): AnimationGroup;
  4710. /**
  4711. * Dispose all associated resources
  4712. */
  4713. dispose(): void;
  4714. private _checkAnimationGroupEnded;
  4715. /**
  4716. * Returns a new AnimationGroup object parsed from the source provided.
  4717. * @param parsedAnimationGroup defines the source
  4718. * @param scene defines the scene that will receive the animationGroup
  4719. * @returns a new AnimationGroup
  4720. */
  4721. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4722. /**
  4723. * Returns the string "AnimationGroup"
  4724. * @returns "AnimationGroup"
  4725. */
  4726. getClassName(): string;
  4727. /**
  4728. * Creates a detailled string about the object
  4729. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4730. * @returns a string representing the object
  4731. */
  4732. toString(fullDetails?: boolean): string;
  4733. }
  4734. }
  4735. declare module BABYLON {
  4736. /**
  4737. * Class used to override all child animations of a given target
  4738. */
  4739. class AnimationPropertiesOverride {
  4740. /**
  4741. * Gets or sets a value indicating if animation blending must be used
  4742. */
  4743. enableBlending: boolean;
  4744. /**
  4745. * Gets or sets the blending speed to use when enableBlending is true
  4746. */
  4747. blendingSpeed: number;
  4748. /**
  4749. * Gets or sets the default loop mode to use
  4750. */
  4751. loopMode: number;
  4752. }
  4753. }
  4754. declare module BABYLON {
  4755. /**
  4756. * This represents the main contract an easing function should follow.
  4757. * Easing functions are used throughout the animation system.
  4758. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4759. */
  4760. interface IEasingFunction {
  4761. /**
  4762. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4763. * of the easing function.
  4764. * The link below provides some of the most common examples of easing functions.
  4765. * @see https://easings.net/
  4766. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4767. * @returns the corresponding value on the curve defined by the easing function
  4768. */
  4769. ease(gradient: number): number;
  4770. }
  4771. /**
  4772. * Base class used for every default easing function.
  4773. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4774. */
  4775. class EasingFunction implements IEasingFunction {
  4776. /**
  4777. * Interpolation follows the mathematical formula associated with the easing function.
  4778. */
  4779. static readonly EASINGMODE_EASEIN: number;
  4780. /**
  4781. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4782. */
  4783. static readonly EASINGMODE_EASEOUT: number;
  4784. /**
  4785. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4786. */
  4787. static readonly EASINGMODE_EASEINOUT: number;
  4788. private _easingMode;
  4789. /**
  4790. * Sets the easing mode of the current function.
  4791. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4792. */
  4793. setEasingMode(easingMode: number): void;
  4794. /**
  4795. * Gets the current easing mode.
  4796. * @returns the easing mode
  4797. */
  4798. getEasingMode(): number;
  4799. /**
  4800. * @hidden
  4801. */
  4802. easeInCore(gradient: number): number;
  4803. /**
  4804. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4805. * of the easing function.
  4806. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4807. * @returns the corresponding value on the curve defined by the easing function
  4808. */
  4809. ease(gradient: number): number;
  4810. }
  4811. /**
  4812. * Easing function with a circle shape (see link below).
  4813. * @see https://easings.net/#easeInCirc
  4814. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4815. */
  4816. class CircleEase extends EasingFunction implements IEasingFunction {
  4817. /** @hidden */
  4818. easeInCore(gradient: number): number;
  4819. }
  4820. /**
  4821. * Easing function with a ease back shape (see link below).
  4822. * @see https://easings.net/#easeInBack
  4823. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4824. */
  4825. class BackEase extends EasingFunction implements IEasingFunction {
  4826. /** Defines the amplitude of the function */
  4827. amplitude: number;
  4828. /**
  4829. * Instantiates a back ease easing
  4830. * @see https://easings.net/#easeInBack
  4831. * @param amplitude Defines the amplitude of the function
  4832. */
  4833. constructor(
  4834. /** Defines the amplitude of the function */
  4835. amplitude?: number);
  4836. /** @hidden */
  4837. easeInCore(gradient: number): number;
  4838. }
  4839. /**
  4840. * Easing function with a bouncing shape (see link below).
  4841. * @see https://easings.net/#easeInBounce
  4842. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4843. */
  4844. class BounceEase extends EasingFunction implements IEasingFunction {
  4845. /** Defines the number of bounces */
  4846. bounces: number;
  4847. /** Defines the amplitude of the bounce */
  4848. bounciness: number;
  4849. /**
  4850. * Instantiates a bounce easing
  4851. * @see https://easings.net/#easeInBounce
  4852. * @param bounces Defines the number of bounces
  4853. * @param bounciness Defines the amplitude of the bounce
  4854. */
  4855. constructor(
  4856. /** Defines the number of bounces */
  4857. bounces?: number,
  4858. /** Defines the amplitude of the bounce */
  4859. bounciness?: number);
  4860. /** @hidden */
  4861. easeInCore(gradient: number): number;
  4862. }
  4863. /**
  4864. * Easing function with a power of 3 shape (see link below).
  4865. * @see https://easings.net/#easeInCubic
  4866. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4867. */
  4868. class CubicEase extends EasingFunction implements IEasingFunction {
  4869. /** @hidden */
  4870. easeInCore(gradient: number): number;
  4871. }
  4872. /**
  4873. * Easing function with an elastic shape (see link below).
  4874. * @see https://easings.net/#easeInElastic
  4875. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4876. */
  4877. class ElasticEase extends EasingFunction implements IEasingFunction {
  4878. /** Defines the number of oscillations*/
  4879. oscillations: number;
  4880. /** Defines the amplitude of the oscillations*/
  4881. springiness: number;
  4882. /**
  4883. * Instantiates an elastic easing function
  4884. * @see https://easings.net/#easeInElastic
  4885. * @param oscillations Defines the number of oscillations
  4886. * @param springiness Defines the amplitude of the oscillations
  4887. */
  4888. constructor(
  4889. /** Defines the number of oscillations*/
  4890. oscillations?: number,
  4891. /** Defines the amplitude of the oscillations*/
  4892. springiness?: number);
  4893. /** @hidden */
  4894. easeInCore(gradient: number): number;
  4895. }
  4896. /**
  4897. * Easing function with an exponential shape (see link below).
  4898. * @see https://easings.net/#easeInExpo
  4899. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4900. */
  4901. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4902. /** Defines the exponent of the function */
  4903. exponent: number;
  4904. /**
  4905. * Instantiates an exponential easing function
  4906. * @see https://easings.net/#easeInExpo
  4907. * @param exponent Defines the exponent of the function
  4908. */
  4909. constructor(
  4910. /** Defines the exponent of the function */
  4911. exponent?: number);
  4912. /** @hidden */
  4913. easeInCore(gradient: number): number;
  4914. }
  4915. /**
  4916. * Easing function with a power shape (see link below).
  4917. * @see https://easings.net/#easeInQuad
  4918. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4919. */
  4920. class PowerEase extends EasingFunction implements IEasingFunction {
  4921. /** Defines the power of the function */
  4922. power: number;
  4923. /**
  4924. * Instantiates an power base easing function
  4925. * @see https://easings.net/#easeInQuad
  4926. * @param power Defines the power of the function
  4927. */
  4928. constructor(
  4929. /** Defines the power of the function */
  4930. power?: number);
  4931. /** @hidden */
  4932. easeInCore(gradient: number): number;
  4933. }
  4934. /**
  4935. * Easing function with a power of 2 shape (see link below).
  4936. * @see https://easings.net/#easeInQuad
  4937. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4938. */
  4939. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4940. /** @hidden */
  4941. easeInCore(gradient: number): number;
  4942. }
  4943. /**
  4944. * Easing function with a power of 4 shape (see link below).
  4945. * @see https://easings.net/#easeInQuart
  4946. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4947. */
  4948. class QuarticEase extends EasingFunction implements IEasingFunction {
  4949. /** @hidden */
  4950. easeInCore(gradient: number): number;
  4951. }
  4952. /**
  4953. * Easing function with a power of 5 shape (see link below).
  4954. * @see https://easings.net/#easeInQuint
  4955. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4956. */
  4957. class QuinticEase extends EasingFunction implements IEasingFunction {
  4958. /** @hidden */
  4959. easeInCore(gradient: number): number;
  4960. }
  4961. /**
  4962. * Easing function with a sin shape (see link below).
  4963. * @see https://easings.net/#easeInSine
  4964. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4965. */
  4966. class SineEase extends EasingFunction implements IEasingFunction {
  4967. /** @hidden */
  4968. easeInCore(gradient: number): number;
  4969. }
  4970. /**
  4971. * Easing function with a bezier shape (see link below).
  4972. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4973. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4974. */
  4975. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4976. /** Defines the x component of the start tangent in the bezier curve */
  4977. x1: number;
  4978. /** Defines the y component of the start tangent in the bezier curve */
  4979. y1: number;
  4980. /** Defines the x component of the end tangent in the bezier curve */
  4981. x2: number;
  4982. /** Defines the y component of the end tangent in the bezier curve */
  4983. y2: number;
  4984. /**
  4985. * Instantiates a bezier function
  4986. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4987. * @param x1 Defines the x component of the start tangent in the bezier curve
  4988. * @param y1 Defines the y component of the start tangent in the bezier curve
  4989. * @param x2 Defines the x component of the end tangent in the bezier curve
  4990. * @param y2 Defines the y component of the end tangent in the bezier curve
  4991. */
  4992. constructor(
  4993. /** Defines the x component of the start tangent in the bezier curve */
  4994. x1?: number,
  4995. /** Defines the y component of the start tangent in the bezier curve */
  4996. y1?: number,
  4997. /** Defines the x component of the end tangent in the bezier curve */
  4998. x2?: number,
  4999. /** Defines the y component of the end tangent in the bezier curve */
  5000. y2?: number);
  5001. /** @hidden */
  5002. easeInCore(gradient: number): number;
  5003. }
  5004. }
  5005. declare module BABYLON {
  5006. /**
  5007. * Defines a runtime animation
  5008. */
  5009. class RuntimeAnimation {
  5010. private _events;
  5011. /**
  5012. * The current frame of the runtime animation
  5013. */
  5014. private _currentFrame;
  5015. /**
  5016. * The animation used by the runtime animation
  5017. */
  5018. private _animation;
  5019. /**
  5020. * The target of the runtime animation
  5021. */
  5022. private _target;
  5023. /**
  5024. * The initiating animatable
  5025. */
  5026. private _host;
  5027. /**
  5028. * The original value of the runtime animation
  5029. */
  5030. private _originalValue;
  5031. /**
  5032. * The original blend value of the runtime animation
  5033. */
  5034. private _originalBlendValue;
  5035. /**
  5036. * The offsets cache of the runtime animation
  5037. */
  5038. private _offsetsCache;
  5039. /**
  5040. * The high limits cache of the runtime animation
  5041. */
  5042. private _highLimitsCache;
  5043. /**
  5044. * Specifies if the runtime animation has been stopped
  5045. */
  5046. private _stopped;
  5047. /**
  5048. * The blending factor of the runtime animation
  5049. */
  5050. private _blendingFactor;
  5051. /**
  5052. * The BabylonJS scene
  5053. */
  5054. private _scene;
  5055. /**
  5056. * The current value of the runtime animation
  5057. */
  5058. private _currentValue;
  5059. /** @hidden */
  5060. _workValue: any;
  5061. /**
  5062. * The active target of the runtime animation
  5063. */
  5064. private _activeTarget;
  5065. /**
  5066. * The target path of the runtime animation
  5067. */
  5068. private _targetPath;
  5069. /**
  5070. * The weight of the runtime animation
  5071. */
  5072. private _weight;
  5073. /**
  5074. * The ratio offset of the runtime animation
  5075. */
  5076. private _ratioOffset;
  5077. /**
  5078. * The previous delay of the runtime animation
  5079. */
  5080. private _previousDelay;
  5081. /**
  5082. * The previous ratio of the runtime animation
  5083. */
  5084. private _previousRatio;
  5085. /**
  5086. * Gets the current frame of the runtime animation
  5087. */
  5088. readonly currentFrame: number;
  5089. /**
  5090. * Gets the weight of the runtime animation
  5091. */
  5092. readonly weight: number;
  5093. /**
  5094. * Gets the current value of the runtime animation
  5095. */
  5096. readonly currentValue: any;
  5097. /**
  5098. * Gets the target path of the runtime animation
  5099. */
  5100. readonly targetPath: string;
  5101. /**
  5102. * Gets the actual target of the runtime animation
  5103. */
  5104. readonly target: any;
  5105. /**
  5106. * Create a new RuntimeAnimation object
  5107. * @param target defines the target of the animation
  5108. * @param animation defines the source animation object
  5109. * @param scene defines the hosting scene
  5110. * @param host defines the initiating Animatable
  5111. */
  5112. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5113. /**
  5114. * Gets the animation from the runtime animation
  5115. */
  5116. readonly animation: Animation;
  5117. /**
  5118. * Resets the runtime animation to the beginning
  5119. * @param restoreOriginal defines whether to restore the target property to the original value
  5120. */
  5121. reset(restoreOriginal?: boolean): void;
  5122. /**
  5123. * Specifies if the runtime animation is stopped
  5124. * @returns Boolean specifying if the runtime animation is stopped
  5125. */
  5126. isStopped(): boolean;
  5127. /**
  5128. * Disposes of the runtime animation
  5129. */
  5130. dispose(): void;
  5131. /**
  5132. * Interpolates the animation from the current frame
  5133. * @param currentFrame The frame to interpolate the animation to
  5134. * @param repeatCount The number of times that the animation should loop
  5135. * @param loopMode The type of looping mode to use
  5136. * @param offsetValue Animation offset value
  5137. * @param highLimitValue The high limit value
  5138. * @returns The interpolated value
  5139. */
  5140. private _interpolate;
  5141. /**
  5142. * Apply the interpolated value to the target
  5143. * @param currentValue defines the value computed by the animation
  5144. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5145. */
  5146. setValue(currentValue: any, weight?: number): void;
  5147. private _setValue;
  5148. /**
  5149. * Gets the loop pmode of the runtime animation
  5150. * @returns Loop Mode
  5151. */
  5152. private _getCorrectLoopMode;
  5153. /**
  5154. * Move the current animation to a given frame
  5155. * @param frame defines the frame to move to
  5156. */
  5157. goToFrame(frame: number): void;
  5158. /**
  5159. * @hidden Internal use only
  5160. */
  5161. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5162. /**
  5163. * Execute the current animation
  5164. * @param delay defines the delay to add to the current frame
  5165. * @param from defines the lower bound of the animation range
  5166. * @param to defines the upper bound of the animation range
  5167. * @param loop defines if the current animation must loop
  5168. * @param speedRatio defines the current speed ratio
  5169. * @param weight defines the weight of the animation (default is -1 so no weight)
  5170. * @returns a boolean indicating if the animation is running
  5171. */
  5172. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5173. }
  5174. }
  5175. declare module BABYLON {
  5176. /**
  5177. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5179. */
  5180. class Analyser {
  5181. /**
  5182. * Gets or sets the smoothing
  5183. * @ignorenaming
  5184. */
  5185. SMOOTHING: number;
  5186. /**
  5187. * Gets or sets the FFT table size
  5188. * @ignorenaming
  5189. */
  5190. FFT_SIZE: number;
  5191. /**
  5192. * Gets or sets the bar graph amplitude
  5193. * @ignorenaming
  5194. */
  5195. BARGRAPHAMPLITUDE: number;
  5196. /**
  5197. * Gets or sets the position of the debug canvas
  5198. * @ignorenaming
  5199. */
  5200. DEBUGCANVASPOS: {
  5201. x: number;
  5202. y: number;
  5203. };
  5204. /**
  5205. * Gets or sets the debug canvas size
  5206. * @ignorenaming
  5207. */
  5208. DEBUGCANVASSIZE: {
  5209. width: number;
  5210. height: number;
  5211. };
  5212. private _byteFreqs;
  5213. private _byteTime;
  5214. private _floatFreqs;
  5215. private _webAudioAnalyser;
  5216. private _debugCanvas;
  5217. private _debugCanvasContext;
  5218. private _scene;
  5219. private _registerFunc;
  5220. private _audioEngine;
  5221. /**
  5222. * Creates a new analyser
  5223. * @param scene defines hosting scene
  5224. */
  5225. constructor(scene: Scene);
  5226. /**
  5227. * Get the number of data values you will have to play with for the visualization
  5228. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5229. * @returns a number
  5230. */
  5231. getFrequencyBinCount(): number;
  5232. /**
  5233. * Gets the current frequency data as a byte array
  5234. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5235. * @returns a Uint8Array
  5236. */
  5237. getByteFrequencyData(): Uint8Array;
  5238. /**
  5239. * Gets the current waveform as a byte array
  5240. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5241. * @returns a Uint8Array
  5242. */
  5243. getByteTimeDomainData(): Uint8Array;
  5244. /**
  5245. * Gets the current frequency data as a float array
  5246. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5247. * @returns a Float32Array
  5248. */
  5249. getFloatFrequencyData(): Float32Array;
  5250. /**
  5251. * Renders the debug canvas
  5252. */
  5253. drawDebugCanvas(): void;
  5254. /**
  5255. * Stops rendering the debug canvas and removes it
  5256. */
  5257. stopDebugCanvas(): void;
  5258. /**
  5259. * Connects two audio nodes
  5260. * @param inputAudioNode defines first node to connect
  5261. * @param outputAudioNode defines second node to connect
  5262. */
  5263. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5264. /**
  5265. * Releases all associated resources
  5266. */
  5267. dispose(): void;
  5268. }
  5269. }
  5270. declare module BABYLON {
  5271. /**
  5272. * This represents an audio engine and it is responsible
  5273. * to play, synchronize and analyse sounds throughout the application.
  5274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5275. */
  5276. interface IAudioEngine extends IDisposable {
  5277. /**
  5278. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5279. */
  5280. readonly canUseWebAudio: boolean;
  5281. /**
  5282. * Gets the current AudioContext if available.
  5283. */
  5284. readonly audioContext: Nullable<AudioContext>;
  5285. /**
  5286. * The master gain node defines the global audio volume of your audio engine.
  5287. */
  5288. readonly masterGain: GainNode;
  5289. /**
  5290. * Gets whether or not mp3 are supported by your browser.
  5291. */
  5292. readonly isMP3supported: boolean;
  5293. /**
  5294. * Gets whether or not ogg are supported by your browser.
  5295. */
  5296. readonly isOGGsupported: boolean;
  5297. /**
  5298. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5299. * @ignoreNaming
  5300. */
  5301. WarnedWebAudioUnsupported: boolean;
  5302. /**
  5303. * Defines if the audio engine relies on a custom unlocked button.
  5304. * In this case, the embedded button will not be displayed.
  5305. */
  5306. useCustomUnlockedButton: boolean;
  5307. /**
  5308. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5309. */
  5310. readonly unlocked: boolean;
  5311. /**
  5312. * Event raised when audio has been unlocked on the browser.
  5313. */
  5314. onAudioUnlockedObservable: Observable<AudioEngine>;
  5315. /**
  5316. * Event raised when audio has been locked on the browser.
  5317. */
  5318. onAudioLockedObservable: Observable<AudioEngine>;
  5319. /**
  5320. * Flags the audio engine in Locked state.
  5321. * This happens due to new browser policies preventing audio to autoplay.
  5322. */
  5323. lock(): void;
  5324. /**
  5325. * Unlocks the audio engine once a user action has been done on the dom.
  5326. * This is helpful to resume play once browser policies have been satisfied.
  5327. */
  5328. unlock(): void;
  5329. }
  5330. /**
  5331. * This represents the default audio engine used in babylon.
  5332. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5334. */
  5335. class AudioEngine implements IAudioEngine {
  5336. private _audioContext;
  5337. private _audioContextInitialized;
  5338. private _muteButton;
  5339. private _hostElement;
  5340. /**
  5341. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5342. */
  5343. canUseWebAudio: boolean;
  5344. /**
  5345. * The master gain node defines the global audio volume of your audio engine.
  5346. */
  5347. masterGain: GainNode;
  5348. /**
  5349. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5350. * @ignoreNaming
  5351. */
  5352. WarnedWebAudioUnsupported: boolean;
  5353. /**
  5354. * Gets whether or not mp3 are supported by your browser.
  5355. */
  5356. isMP3supported: boolean;
  5357. /**
  5358. * Gets whether or not ogg are supported by your browser.
  5359. */
  5360. isOGGsupported: boolean;
  5361. /**
  5362. * Gets whether audio has been unlocked on the device.
  5363. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5364. * a user interaction has happened.
  5365. */
  5366. unlocked: boolean;
  5367. /**
  5368. * Defines if the audio engine relies on a custom unlocked button.
  5369. * In this case, the embedded button will not be displayed.
  5370. */
  5371. useCustomUnlockedButton: boolean;
  5372. /**
  5373. * Event raised when audio has been unlocked on the browser.
  5374. */
  5375. onAudioUnlockedObservable: Observable<AudioEngine>;
  5376. /**
  5377. * Event raised when audio has been locked on the browser.
  5378. */
  5379. onAudioLockedObservable: Observable<AudioEngine>;
  5380. /**
  5381. * Gets the current AudioContext if available.
  5382. */
  5383. readonly audioContext: Nullable<AudioContext>;
  5384. private _connectedAnalyser;
  5385. /**
  5386. * Instantiates a new audio engine.
  5387. *
  5388. * There should be only one per page as some browsers restrict the number
  5389. * of audio contexts you can create.
  5390. * @param hostElement defines the host element where to display the mute icon if necessary
  5391. */
  5392. constructor(hostElement?: Nullable<HTMLElement>);
  5393. /**
  5394. * Flags the audio engine in Locked state.
  5395. * This happens due to new browser policies preventing audio to autoplay.
  5396. */
  5397. lock(): void;
  5398. /**
  5399. * Unlocks the audio engine once a user action has been done on the dom.
  5400. * This is helpful to resume play once browser policies have been satisfied.
  5401. */
  5402. unlock(): void;
  5403. private _resumeAudioContext;
  5404. private _initializeAudioContext;
  5405. private _tryToRun;
  5406. private _triggerRunningState;
  5407. private _triggerSuspendedState;
  5408. private _displayMuteButton;
  5409. private _moveButtonToTopLeft;
  5410. private _onResize;
  5411. private _hideMuteButton;
  5412. /**
  5413. * Destroy and release the resources associated with the audio ccontext.
  5414. */
  5415. dispose(): void;
  5416. /**
  5417. * Gets the global volume sets on the master gain.
  5418. * @returns the global volume if set or -1 otherwise
  5419. */
  5420. getGlobalVolume(): number;
  5421. /**
  5422. * Sets the global volume of your experience (sets on the master gain).
  5423. * @param newVolume Defines the new global volume of the application
  5424. */
  5425. setGlobalVolume(newVolume: number): void;
  5426. /**
  5427. * Connect the audio engine to an audio analyser allowing some amazing
  5428. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5430. * @param analyser The analyser to connect to the engine
  5431. */
  5432. connectToAnalyser(analyser: Analyser): void;
  5433. }
  5434. }
  5435. declare module BABYLON {
  5436. interface AbstractScene {
  5437. /**
  5438. * The list of sounds used in the scene.
  5439. */
  5440. sounds: Nullable<Array<Sound>>;
  5441. }
  5442. interface Scene {
  5443. /**
  5444. * @hidden
  5445. * Backing field
  5446. */
  5447. _mainSoundTrack: SoundTrack;
  5448. /**
  5449. * The main sound track played by the scene.
  5450. * It cotains your primary collection of sounds.
  5451. */
  5452. mainSoundTrack: SoundTrack;
  5453. /**
  5454. * The list of sound tracks added to the scene
  5455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5456. */
  5457. soundTracks: Nullable<Array<SoundTrack>>;
  5458. /**
  5459. * Gets a sound using a given name
  5460. * @param name defines the name to search for
  5461. * @return the found sound or null if not found at all.
  5462. */
  5463. getSoundByName(name: string): Nullable<Sound>;
  5464. /**
  5465. * Gets or sets if audio support is enabled
  5466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5467. */
  5468. audioEnabled: boolean;
  5469. /**
  5470. * Gets or sets if audio will be output to headphones
  5471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5472. */
  5473. headphone: boolean;
  5474. }
  5475. /**
  5476. * Defines the sound scene component responsible to manage any sounds
  5477. * in a given scene.
  5478. */
  5479. class AudioSceneComponent implements ISceneSerializableComponent {
  5480. /**
  5481. * The component name helpfull to identify the component in the list of scene components.
  5482. */
  5483. readonly name: string;
  5484. /**
  5485. * The scene the component belongs to.
  5486. */
  5487. scene: Scene;
  5488. private _audioEnabled;
  5489. /**
  5490. * Gets whether audio is enabled or not.
  5491. * Please use related enable/disable method to switch state.
  5492. */
  5493. readonly audioEnabled: boolean;
  5494. private _headphone;
  5495. /**
  5496. * Gets whether audio is outputing to headphone or not.
  5497. * Please use the according Switch methods to change output.
  5498. */
  5499. readonly headphone: boolean;
  5500. /**
  5501. * Creates a new instance of the component for the given scene
  5502. * @param scene Defines the scene to register the component in
  5503. */
  5504. constructor(scene: Scene);
  5505. /**
  5506. * Registers the component in a given scene
  5507. */
  5508. register(): void;
  5509. /**
  5510. * Rebuilds the elements related to this component in case of
  5511. * context lost for instance.
  5512. */
  5513. rebuild(): void;
  5514. /**
  5515. * Serializes the component data to the specified json object
  5516. * @param serializationObject The object to serialize to
  5517. */
  5518. serialize(serializationObject: any): void;
  5519. /**
  5520. * Adds all the element from the container to the scene
  5521. * @param container the container holding the elements
  5522. */
  5523. addFromContainer(container: AbstractScene): void;
  5524. /**
  5525. * Removes all the elements in the container from the scene
  5526. * @param container contains the elements to remove
  5527. */
  5528. removeFromContainer(container: AbstractScene): void;
  5529. /**
  5530. * Disposes the component and the associated ressources.
  5531. */
  5532. dispose(): void;
  5533. /**
  5534. * Disables audio in the associated scene.
  5535. */
  5536. disableAudio(): void;
  5537. /**
  5538. * Enables audio in the associated scene.
  5539. */
  5540. enableAudio(): void;
  5541. /**
  5542. * Switch audio to headphone output.
  5543. */
  5544. switchAudioModeForHeadphones(): void;
  5545. /**
  5546. * Switch audio to normal speakers.
  5547. */
  5548. switchAudioModeForNormalSpeakers(): void;
  5549. private _afterRender;
  5550. }
  5551. }
  5552. declare module BABYLON {
  5553. /**
  5554. * Defines a sound that can be played in the application.
  5555. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5557. */
  5558. class Sound {
  5559. /**
  5560. * The name of the sound in the scene.
  5561. */
  5562. name: string;
  5563. /**
  5564. * Does the sound autoplay once loaded.
  5565. */
  5566. autoplay: boolean;
  5567. /**
  5568. * Does the sound loop after it finishes playing once.
  5569. */
  5570. loop: boolean;
  5571. /**
  5572. * Does the sound use a custom attenuation curve to simulate the falloff
  5573. * happening when the source gets further away from the camera.
  5574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5575. */
  5576. useCustomAttenuation: boolean;
  5577. /**
  5578. * The sound track id this sound belongs to.
  5579. */
  5580. soundTrackId: number;
  5581. /**
  5582. * Is this sound currently played.
  5583. */
  5584. isPlaying: boolean;
  5585. /**
  5586. * Is this sound currently paused.
  5587. */
  5588. isPaused: boolean;
  5589. /**
  5590. * Does this sound enables spatial sound.
  5591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5592. */
  5593. spatialSound: boolean;
  5594. /**
  5595. * Define the reference distance the sound should be heard perfectly.
  5596. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5597. */
  5598. refDistance: number;
  5599. /**
  5600. * Define the roll off factor of spatial sounds.
  5601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5602. */
  5603. rolloffFactor: number;
  5604. /**
  5605. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5607. */
  5608. maxDistance: number;
  5609. /**
  5610. * Define the distance attenuation model the sound will follow.
  5611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5612. */
  5613. distanceModel: string;
  5614. /**
  5615. * @hidden
  5616. * Back Compat
  5617. **/
  5618. onended: () => any;
  5619. /**
  5620. * Observable event when the current playing sound finishes.
  5621. */
  5622. onEndedObservable: Observable<Sound>;
  5623. private _panningModel;
  5624. private _playbackRate;
  5625. private _streaming;
  5626. private _startTime;
  5627. private _startOffset;
  5628. private _position;
  5629. /** @hidden */
  5630. _positionInEmitterSpace: boolean;
  5631. private _localDirection;
  5632. private _volume;
  5633. private _isReadyToPlay;
  5634. private _isDirectional;
  5635. private _readyToPlayCallback;
  5636. private _audioBuffer;
  5637. private _soundSource;
  5638. private _streamingSource;
  5639. private _soundPanner;
  5640. private _soundGain;
  5641. private _inputAudioNode;
  5642. private _outputAudioNode;
  5643. private _coneInnerAngle;
  5644. private _coneOuterAngle;
  5645. private _coneOuterGain;
  5646. private _scene;
  5647. private _connectedTransformNode;
  5648. private _customAttenuationFunction;
  5649. private _registerFunc;
  5650. private _isOutputConnected;
  5651. private _htmlAudioElement;
  5652. private _urlType;
  5653. /**
  5654. * Create a sound and attach it to a scene
  5655. * @param name Name of your sound
  5656. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5657. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5658. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5659. */
  5660. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5661. /**
  5662. * Release the sound and its associated resources
  5663. */
  5664. dispose(): void;
  5665. /**
  5666. * Gets if the sounds is ready to be played or not.
  5667. * @returns true if ready, otherwise false
  5668. */
  5669. isReady(): boolean;
  5670. private _soundLoaded;
  5671. /**
  5672. * Sets the data of the sound from an audiobuffer
  5673. * @param audioBuffer The audioBuffer containing the data
  5674. */
  5675. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5676. /**
  5677. * Updates the current sounds options such as maxdistance, loop...
  5678. * @param options A JSON object containing values named as the object properties
  5679. */
  5680. updateOptions(options: any): void;
  5681. private _createSpatialParameters;
  5682. private _updateSpatialParameters;
  5683. /**
  5684. * Switch the panning model to HRTF:
  5685. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5687. */
  5688. switchPanningModelToHRTF(): void;
  5689. /**
  5690. * Switch the panning model to Equal Power:
  5691. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5692. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5693. */
  5694. switchPanningModelToEqualPower(): void;
  5695. private _switchPanningModel;
  5696. /**
  5697. * Connect this sound to a sound track audio node like gain...
  5698. * @param soundTrackAudioNode the sound track audio node to connect to
  5699. */
  5700. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5701. /**
  5702. * Transform this sound into a directional source
  5703. * @param coneInnerAngle Size of the inner cone in degree
  5704. * @param coneOuterAngle Size of the outer cone in degree
  5705. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5706. */
  5707. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5708. /**
  5709. * Gets or sets the inner angle for the directional cone.
  5710. */
  5711. /**
  5712. * Gets or sets the inner angle for the directional cone.
  5713. */
  5714. directionalConeInnerAngle: number;
  5715. /**
  5716. * Gets or sets the outer angle for the directional cone.
  5717. */
  5718. /**
  5719. * Gets or sets the outer angle for the directional cone.
  5720. */
  5721. directionalConeOuterAngle: number;
  5722. /**
  5723. * Sets the position of the emitter if spatial sound is enabled
  5724. * @param newPosition Defines the new posisiton
  5725. */
  5726. setPosition(newPosition: Vector3): void;
  5727. /**
  5728. * Sets the local direction of the emitter if spatial sound is enabled
  5729. * @param newLocalDirection Defines the new local direction
  5730. */
  5731. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5732. private _updateDirection;
  5733. /** @hidden */
  5734. updateDistanceFromListener(): void;
  5735. /**
  5736. * Sets a new custom attenuation function for the sound.
  5737. * @param callback Defines the function used for the attenuation
  5738. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5739. */
  5740. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5741. /**
  5742. * Play the sound
  5743. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5744. * @param offset (optional) Start the sound setting it at a specific time
  5745. */
  5746. play(time?: number, offset?: number): void;
  5747. private _onended;
  5748. /**
  5749. * Stop the sound
  5750. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5751. */
  5752. stop(time?: number): void;
  5753. /**
  5754. * Put the sound in pause
  5755. */
  5756. pause(): void;
  5757. /**
  5758. * Sets a dedicated volume for this sounds
  5759. * @param newVolume Define the new volume of the sound
  5760. * @param time Define in how long the sound should be at this value
  5761. */
  5762. setVolume(newVolume: number, time?: number): void;
  5763. /**
  5764. * Set the sound play back rate
  5765. * @param newPlaybackRate Define the playback rate the sound should be played at
  5766. */
  5767. setPlaybackRate(newPlaybackRate: number): void;
  5768. /**
  5769. * Gets the volume of the sound.
  5770. * @returns the volume of the sound
  5771. */
  5772. getVolume(): number;
  5773. /**
  5774. * Attach the sound to a dedicated mesh
  5775. * @param transformNode The transform node to connect the sound with
  5776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5777. */
  5778. attachToMesh(transformNode: TransformNode): void;
  5779. /**
  5780. * Detach the sound from the previously attached mesh
  5781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5782. */
  5783. detachFromMesh(): void;
  5784. private _onRegisterAfterWorldMatrixUpdate;
  5785. /**
  5786. * Clone the current sound in the scene.
  5787. * @returns the new sound clone
  5788. */
  5789. clone(): Nullable<Sound>;
  5790. /**
  5791. * Gets the current underlying audio buffer containing the data
  5792. * @returns the audio buffer
  5793. */
  5794. getAudioBuffer(): Nullable<AudioBuffer>;
  5795. /**
  5796. * Serializes the Sound in a JSON representation
  5797. * @returns the JSON representation of the sound
  5798. */
  5799. serialize(): any;
  5800. /**
  5801. * Parse a JSON representation of a sound to innstantiate in a given scene
  5802. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5803. * @param scene Define the scene the new parsed sound should be created in
  5804. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5805. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5806. * @returns the newly parsed sound
  5807. */
  5808. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5809. }
  5810. }
  5811. declare module BABYLON {
  5812. /**
  5813. * Options allowed during the creation of a sound track.
  5814. */
  5815. interface ISoundTrackOptions {
  5816. /**
  5817. * The volume the sound track should take during creation
  5818. */
  5819. volume?: number;
  5820. /**
  5821. * Define if the sound track is the main sound track of the scene
  5822. */
  5823. mainTrack?: boolean;
  5824. }
  5825. /**
  5826. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5827. * It will be also used in a future release to apply effects on a specific track.
  5828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5829. */
  5830. class SoundTrack {
  5831. /**
  5832. * The unique identifier of the sound track in the scene.
  5833. */
  5834. id: number;
  5835. /**
  5836. * The list of sounds included in the sound track.
  5837. */
  5838. soundCollection: Array<Sound>;
  5839. private _outputAudioNode;
  5840. private _scene;
  5841. private _isMainTrack;
  5842. private _connectedAnalyser;
  5843. private _options;
  5844. private _isInitialized;
  5845. /**
  5846. * Creates a new sound track.
  5847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5848. * @param scene Define the scene the sound track belongs to
  5849. * @param options
  5850. */
  5851. constructor(scene: Scene, options?: ISoundTrackOptions);
  5852. private _initializeSoundTrackAudioGraph;
  5853. /**
  5854. * Release the sound track and its associated resources
  5855. */
  5856. dispose(): void;
  5857. /**
  5858. * Adds a sound to this sound track
  5859. * @param sound define the cound to add
  5860. * @ignoreNaming
  5861. */
  5862. AddSound(sound: Sound): void;
  5863. /**
  5864. * Removes a sound to this sound track
  5865. * @param sound define the cound to remove
  5866. * @ignoreNaming
  5867. */
  5868. RemoveSound(sound: Sound): void;
  5869. /**
  5870. * Set a global volume for the full sound track.
  5871. * @param newVolume Define the new volume of the sound track
  5872. */
  5873. setVolume(newVolume: number): void;
  5874. /**
  5875. * Switch the panning model to HRTF:
  5876. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5878. */
  5879. switchPanningModelToHRTF(): void;
  5880. /**
  5881. * Switch the panning model to Equal Power:
  5882. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5884. */
  5885. switchPanningModelToEqualPower(): void;
  5886. /**
  5887. * Connect the sound track to an audio analyser allowing some amazing
  5888. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5889. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5890. * @param analyser The analyser to connect to the engine
  5891. */
  5892. connectToAnalyser(analyser: Analyser): void;
  5893. }
  5894. }
  5895. declare module BABYLON {
  5896. /**
  5897. * Wraps one or more Sound objects and selects one with random weight for playback.
  5898. */
  5899. class WeightedSound {
  5900. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5901. loop: boolean;
  5902. private _coneInnerAngle;
  5903. private _coneOuterAngle;
  5904. private _volume;
  5905. /** A Sound is currently playing. */
  5906. isPlaying: boolean;
  5907. /** A Sound is currently paused. */
  5908. isPaused: boolean;
  5909. private _sounds;
  5910. private _weights;
  5911. private _currentIndex?;
  5912. /**
  5913. * Creates a new WeightedSound from the list of sounds given.
  5914. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5915. * @param sounds Array of Sounds that will be selected from.
  5916. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5917. */
  5918. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5919. /**
  5920. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5921. */
  5922. /**
  5923. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5924. */
  5925. directionalConeInnerAngle: number;
  5926. /**
  5927. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5928. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5929. */
  5930. /**
  5931. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5932. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5933. */
  5934. directionalConeOuterAngle: number;
  5935. /**
  5936. * Playback volume.
  5937. */
  5938. /**
  5939. * Playback volume.
  5940. */
  5941. volume: number;
  5942. private _onended;
  5943. /**
  5944. * Suspend playback
  5945. */
  5946. pause(): void;
  5947. /**
  5948. * Stop playback
  5949. */
  5950. stop(): void;
  5951. /**
  5952. * Start playback.
  5953. * @param startOffset Position the clip head at a specific time in seconds.
  5954. */
  5955. play(startOffset?: number): void;
  5956. }
  5957. }
  5958. declare module BABYLON {
  5959. /**
  5960. * Interface used to define a behavior
  5961. */
  5962. interface Behavior<T> {
  5963. /** gets or sets behavior's name */
  5964. name: string;
  5965. /**
  5966. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5967. */
  5968. init(): void;
  5969. /**
  5970. * Called when the behavior is attached to a target
  5971. * @param target defines the target where the behavior is attached to
  5972. */
  5973. attach(target: T): void;
  5974. /**
  5975. * Called when the behavior is detached from its target
  5976. */
  5977. detach(): void;
  5978. }
  5979. /**
  5980. * Interface implemented by classes supporting behaviors
  5981. */
  5982. interface IBehaviorAware<T> {
  5983. /**
  5984. * Attach a behavior
  5985. * @param behavior defines the behavior to attach
  5986. * @returns the current host
  5987. */
  5988. addBehavior(behavior: Behavior<T>): T;
  5989. /**
  5990. * Remove a behavior from the current object
  5991. * @param behavior defines the behavior to detach
  5992. * @returns the current host
  5993. */
  5994. removeBehavior(behavior: Behavior<T>): T;
  5995. /**
  5996. * Gets a behavior using its name to search
  5997. * @param name defines the name to search
  5998. * @returns the behavior or null if not found
  5999. */
  6000. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6001. }
  6002. }
  6003. declare module BABYLON {
  6004. /**
  6005. * Class used to store bone information
  6006. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6007. */
  6008. class Bone extends Node {
  6009. /**
  6010. * defines the bone name
  6011. */
  6012. name: string;
  6013. private static _tmpVecs;
  6014. private static _tmpQuat;
  6015. private static _tmpMats;
  6016. /**
  6017. * Gets the list of child bones
  6018. */
  6019. children: Bone[];
  6020. /** Gets the animations associated with this bone */
  6021. animations: Animation[];
  6022. /**
  6023. * Gets or sets bone length
  6024. */
  6025. length: number;
  6026. /**
  6027. * @hidden Internal only
  6028. * Set this value to map this bone to a different index in the transform matrices
  6029. * Set this value to -1 to exclude the bone from the transform matrices
  6030. */
  6031. _index: Nullable<number>;
  6032. private _skeleton;
  6033. private _localMatrix;
  6034. private _restPose;
  6035. private _baseMatrix;
  6036. private _absoluteTransform;
  6037. private _invertedAbsoluteTransform;
  6038. private _parent;
  6039. private _scalingDeterminant;
  6040. private _worldTransform;
  6041. private _localScaling;
  6042. private _localRotation;
  6043. private _localPosition;
  6044. private _needToDecompose;
  6045. private _needToCompose;
  6046. /** @hidden */
  6047. _linkedTransformNode: Nullable<TransformNode>;
  6048. /** @hidden */
  6049. /** @hidden */
  6050. _matrix: Matrix;
  6051. /**
  6052. * Create a new bone
  6053. * @param name defines the bone name
  6054. * @param skeleton defines the parent skeleton
  6055. * @param parentBone defines the parent (can be null if the bone is the root)
  6056. * @param localMatrix defines the local matrix
  6057. * @param restPose defines the rest pose matrix
  6058. * @param baseMatrix defines the base matrix
  6059. * @param index defines index of the bone in the hiearchy
  6060. */
  6061. constructor(
  6062. /**
  6063. * defines the bone name
  6064. */
  6065. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  6066. /**
  6067. * Gets the parent skeleton
  6068. * @returns a skeleton
  6069. */
  6070. getSkeleton(): Skeleton;
  6071. /**
  6072. * Gets parent bone
  6073. * @returns a bone or null if the bone is the root of the bone hierarchy
  6074. */
  6075. getParent(): Nullable<Bone>;
  6076. /**
  6077. * Sets the parent bone
  6078. * @param parent defines the parent (can be null if the bone is the root)
  6079. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6080. */
  6081. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  6082. /**
  6083. * Gets the local matrix
  6084. * @returns a matrix
  6085. */
  6086. getLocalMatrix(): Matrix;
  6087. /**
  6088. * Gets the base matrix (initial matrix which remains unchanged)
  6089. * @returns a matrix
  6090. */
  6091. getBaseMatrix(): Matrix;
  6092. /**
  6093. * Gets the rest pose matrix
  6094. * @returns a matrix
  6095. */
  6096. getRestPose(): Matrix;
  6097. /**
  6098. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  6099. */
  6100. getWorldMatrix(): Matrix;
  6101. /**
  6102. * Sets the local matrix to rest pose matrix
  6103. */
  6104. returnToRest(): void;
  6105. /**
  6106. * Gets the inverse of the absolute transform matrix.
  6107. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6108. * @returns a matrix
  6109. */
  6110. getInvertedAbsoluteTransform(): Matrix;
  6111. /**
  6112. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6113. * @returns a matrix
  6114. */
  6115. getAbsoluteTransform(): Matrix;
  6116. /**
  6117. * Links with the given transform node.
  6118. * The local matrix of this bone is copied from the transform node every frame.
  6119. * @param transformNode defines the transform node to link to
  6120. */
  6121. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  6122. /** Gets or sets current position (in local space) */
  6123. position: Vector3;
  6124. /** Gets or sets current rotation (in local space) */
  6125. rotation: Vector3;
  6126. /** Gets or sets current rotation quaternion (in local space) */
  6127. rotationQuaternion: Quaternion;
  6128. /** Gets or sets current scaling (in local space) */
  6129. scaling: Vector3;
  6130. /**
  6131. * Gets the animation properties override
  6132. */
  6133. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6134. private _decompose;
  6135. private _compose;
  6136. /**
  6137. * Update the base and local matrices
  6138. * @param matrix defines the new base or local matrix
  6139. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6140. * @param updateLocalMatrix defines if the local matrix should be updated
  6141. */
  6142. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6143. /** @hidden */
  6144. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6145. /**
  6146. * Flag the bone as dirty (Forcing it to update everything)
  6147. */
  6148. markAsDirty(): void;
  6149. private _markAsDirtyAndCompose;
  6150. private _markAsDirtyAndDecompose;
  6151. /**
  6152. * Copy an animation range from another bone
  6153. * @param source defines the source bone
  6154. * @param rangeName defines the range name to copy
  6155. * @param frameOffset defines the frame offset
  6156. * @param rescaleAsRequired defines if rescaling must be applied if required
  6157. * @param skelDimensionsRatio defines the scaling ratio
  6158. * @returns true if operation was successful
  6159. */
  6160. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6161. /**
  6162. * Translate the bone in local or world space
  6163. * @param vec The amount to translate the bone
  6164. * @param space The space that the translation is in
  6165. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6166. */
  6167. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6168. /**
  6169. * Set the postion of the bone in local or world space
  6170. * @param position The position to set the bone
  6171. * @param space The space that the position is in
  6172. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6173. */
  6174. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6175. /**
  6176. * Set the absolute position of the bone (world space)
  6177. * @param position The position to set the bone
  6178. * @param mesh The mesh that this bone is attached to
  6179. */
  6180. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6181. /**
  6182. * Scale the bone on the x, y and z axes (in local space)
  6183. * @param x The amount to scale the bone on the x axis
  6184. * @param y The amount to scale the bone on the y axis
  6185. * @param z The amount to scale the bone on the z axis
  6186. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6187. */
  6188. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6189. /**
  6190. * Set the bone scaling in local space
  6191. * @param scale defines the scaling vector
  6192. */
  6193. setScale(scale: Vector3): void;
  6194. /**
  6195. * Gets the current scaling in local space
  6196. * @returns the current scaling vector
  6197. */
  6198. getScale(): Vector3;
  6199. /**
  6200. * Gets the current scaling in local space and stores it in a target vector
  6201. * @param result defines the target vector
  6202. */
  6203. getScaleToRef(result: Vector3): void;
  6204. /**
  6205. * Set the yaw, pitch, and roll of the bone in local or world space
  6206. * @param yaw The rotation of the bone on the y axis
  6207. * @param pitch The rotation of the bone on the x axis
  6208. * @param roll The rotation of the bone on the z axis
  6209. * @param space The space that the axes of rotation are in
  6210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6211. */
  6212. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6213. /**
  6214. * Add a rotation to the bone on an axis in local or world space
  6215. * @param axis The axis to rotate the bone on
  6216. * @param amount The amount to rotate the bone
  6217. * @param space The space that the axis is in
  6218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6219. */
  6220. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6221. /**
  6222. * Set the rotation of the bone to a particular axis angle in local or world space
  6223. * @param axis The axis to rotate the bone on
  6224. * @param angle The angle that the bone should be rotated to
  6225. * @param space The space that the axis is in
  6226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6227. */
  6228. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6229. /**
  6230. * Set the euler rotation of the bone in local of world space
  6231. * @param rotation The euler rotation that the bone should be set to
  6232. * @param space The space that the rotation is in
  6233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6234. */
  6235. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6236. /**
  6237. * Set the quaternion rotation of the bone in local of world space
  6238. * @param quat The quaternion rotation that the bone should be set to
  6239. * @param space The space that the rotation is in
  6240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6241. */
  6242. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6243. /**
  6244. * Set the rotation matrix of the bone in local of world space
  6245. * @param rotMat The rotation matrix that the bone should be set to
  6246. * @param space The space that the rotation is in
  6247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6248. */
  6249. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6250. private _rotateWithMatrix;
  6251. private _getNegativeRotationToRef;
  6252. /**
  6253. * Get the position of the bone in local or world space
  6254. * @param space The space that the returned position is in
  6255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6256. * @returns The position of the bone
  6257. */
  6258. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6259. /**
  6260. * Copy the position of the bone to a vector3 in local or world space
  6261. * @param space The space that the returned position is in
  6262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6263. * @param result The vector3 to copy the position to
  6264. */
  6265. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6266. /**
  6267. * Get the absolute position of the bone (world space)
  6268. * @param mesh The mesh that this bone is attached to
  6269. * @returns The absolute position of the bone
  6270. */
  6271. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6272. /**
  6273. * Copy the absolute position of the bone (world space) to the result param
  6274. * @param mesh The mesh that this bone is attached to
  6275. * @param result The vector3 to copy the absolute position to
  6276. */
  6277. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6278. /**
  6279. * Compute the absolute transforms of this bone and its children
  6280. */
  6281. computeAbsoluteTransforms(): void;
  6282. /**
  6283. * Get the world direction from an axis that is in the local space of the bone
  6284. * @param localAxis The local direction that is used to compute the world direction
  6285. * @param mesh The mesh that this bone is attached to
  6286. * @returns The world direction
  6287. */
  6288. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6289. /**
  6290. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6291. * @param localAxis The local direction that is used to compute the world direction
  6292. * @param mesh The mesh that this bone is attached to
  6293. * @param result The vector3 that the world direction will be copied to
  6294. */
  6295. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6296. /**
  6297. * Get the euler rotation of the bone in local or world space
  6298. * @param space The space that the rotation should be in
  6299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6300. * @returns The euler rotation
  6301. */
  6302. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6303. /**
  6304. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6305. * @param space The space that the rotation should be in
  6306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6307. * @param result The vector3 that the rotation should be copied to
  6308. */
  6309. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6310. /**
  6311. * Get the quaternion rotation of the bone in either local or world space
  6312. * @param space The space that the rotation should be in
  6313. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6314. * @returns The quaternion rotation
  6315. */
  6316. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6317. /**
  6318. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6319. * @param space The space that the rotation should be in
  6320. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6321. * @param result The quaternion that the rotation should be copied to
  6322. */
  6323. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6324. /**
  6325. * Get the rotation matrix of the bone in local or world space
  6326. * @param space The space that the rotation should be in
  6327. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6328. * @returns The rotation matrix
  6329. */
  6330. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6331. /**
  6332. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6333. * @param space The space that the rotation should be in
  6334. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6335. * @param result The quaternion that the rotation should be copied to
  6336. */
  6337. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6338. /**
  6339. * Get the world position of a point that is in the local space of the bone
  6340. * @param position The local position
  6341. * @param mesh The mesh that this bone is attached to
  6342. * @returns The world position
  6343. */
  6344. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6345. /**
  6346. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6347. * @param position The local position
  6348. * @param mesh The mesh that this bone is attached to
  6349. * @param result The vector3 that the world position should be copied to
  6350. */
  6351. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6352. /**
  6353. * Get the local position of a point that is in world space
  6354. * @param position The world position
  6355. * @param mesh The mesh that this bone is attached to
  6356. * @returns The local position
  6357. */
  6358. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6359. /**
  6360. * Get the local position of a point that is in world space and copy it to the result param
  6361. * @param position The world position
  6362. * @param mesh The mesh that this bone is attached to
  6363. * @param result The vector3 that the local position should be copied to
  6364. */
  6365. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6366. }
  6367. }
  6368. declare module BABYLON {
  6369. /**
  6370. * Class used to apply inverse kinematics to bones
  6371. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6372. */
  6373. class BoneIKController {
  6374. private static _tmpVecs;
  6375. private static _tmpQuat;
  6376. private static _tmpMats;
  6377. /**
  6378. * Gets or sets the target mesh
  6379. */
  6380. targetMesh: AbstractMesh;
  6381. /** Gets or sets the mesh used as pole */
  6382. poleTargetMesh: AbstractMesh;
  6383. /**
  6384. * Gets or sets the bone used as pole
  6385. */
  6386. poleTargetBone: Nullable<Bone>;
  6387. /**
  6388. * Gets or sets the target position
  6389. */
  6390. targetPosition: Vector3;
  6391. /**
  6392. * Gets or sets the pole target position
  6393. */
  6394. poleTargetPosition: Vector3;
  6395. /**
  6396. * Gets or sets the pole target local offset
  6397. */
  6398. poleTargetLocalOffset: Vector3;
  6399. /**
  6400. * Gets or sets the pole angle
  6401. */
  6402. poleAngle: number;
  6403. /**
  6404. * Gets or sets the mesh associated with the controller
  6405. */
  6406. mesh: AbstractMesh;
  6407. /**
  6408. * 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)
  6409. */
  6410. slerpAmount: number;
  6411. private _bone1Quat;
  6412. private _bone1Mat;
  6413. private _bone2Ang;
  6414. private _bone1;
  6415. private _bone2;
  6416. private _bone1Length;
  6417. private _bone2Length;
  6418. private _maxAngle;
  6419. private _maxReach;
  6420. private _rightHandedSystem;
  6421. private _bendAxis;
  6422. private _slerping;
  6423. private _adjustRoll;
  6424. /**
  6425. * Gets or sets maximum allowed angle
  6426. */
  6427. maxAngle: number;
  6428. /**
  6429. * Creates a new BoneIKController
  6430. * @param mesh defines the mesh to control
  6431. * @param bone defines the bone to control
  6432. * @param options defines options to set up the controller
  6433. */
  6434. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6435. targetMesh?: AbstractMesh;
  6436. poleTargetMesh?: AbstractMesh;
  6437. poleTargetBone?: Bone;
  6438. poleTargetLocalOffset?: Vector3;
  6439. poleAngle?: number;
  6440. bendAxis?: Vector3;
  6441. maxAngle?: number;
  6442. slerpAmount?: number;
  6443. });
  6444. private _setMaxAngle;
  6445. /**
  6446. * Force the controller to update the bones
  6447. */
  6448. update(): void;
  6449. }
  6450. }
  6451. declare module BABYLON {
  6452. /**
  6453. * Class used to make a bone look toward a point in space
  6454. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6455. */
  6456. class BoneLookController {
  6457. private static _tmpVecs;
  6458. private static _tmpQuat;
  6459. private static _tmpMats;
  6460. /**
  6461. * The target Vector3 that the bone will look at
  6462. */
  6463. target: Vector3;
  6464. /**
  6465. * The mesh that the bone is attached to
  6466. */
  6467. mesh: AbstractMesh;
  6468. /**
  6469. * The bone that will be looking to the target
  6470. */
  6471. bone: Bone;
  6472. /**
  6473. * The up axis of the coordinate system that is used when the bone is rotated
  6474. */
  6475. upAxis: Vector3;
  6476. /**
  6477. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6478. */
  6479. upAxisSpace: Space;
  6480. /**
  6481. * Used to make an adjustment to the yaw of the bone
  6482. */
  6483. adjustYaw: number;
  6484. /**
  6485. * Used to make an adjustment to the pitch of the bone
  6486. */
  6487. adjustPitch: number;
  6488. /**
  6489. * Used to make an adjustment to the roll of the bone
  6490. */
  6491. adjustRoll: number;
  6492. /**
  6493. * 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)
  6494. */
  6495. slerpAmount: number;
  6496. private _minYaw;
  6497. private _maxYaw;
  6498. private _minPitch;
  6499. private _maxPitch;
  6500. private _minYawSin;
  6501. private _minYawCos;
  6502. private _maxYawSin;
  6503. private _maxYawCos;
  6504. private _midYawConstraint;
  6505. private _minPitchTan;
  6506. private _maxPitchTan;
  6507. private _boneQuat;
  6508. private _slerping;
  6509. private _transformYawPitch;
  6510. private _transformYawPitchInv;
  6511. private _firstFrameSkipped;
  6512. private _yawRange;
  6513. private _fowardAxis;
  6514. /**
  6515. * Gets or sets the minimum yaw angle that the bone can look to
  6516. */
  6517. minYaw: number;
  6518. /**
  6519. * Gets or sets the maximum yaw angle that the bone can look to
  6520. */
  6521. maxYaw: number;
  6522. /**
  6523. * Gets or sets the minimum pitch angle that the bone can look to
  6524. */
  6525. minPitch: number;
  6526. /**
  6527. * Gets or sets the maximum pitch angle that the bone can look to
  6528. */
  6529. maxPitch: number;
  6530. /**
  6531. * Create a BoneLookController
  6532. * @param mesh the mesh that the bone belongs to
  6533. * @param bone the bone that will be looking to the target
  6534. * @param target the target Vector3 to look at
  6535. * @param settings optional settings:
  6536. * * maxYaw: the maximum angle the bone will yaw to
  6537. * * minYaw: the minimum angle the bone will yaw to
  6538. * * maxPitch: the maximum angle the bone will pitch to
  6539. * * minPitch: the minimum angle the bone will yaw to
  6540. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6541. * * upAxis: the up axis of the coordinate system
  6542. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6543. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6544. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6545. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6546. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6547. * * adjustRoll: used to make an adjustment to the roll of the bone
  6548. **/
  6549. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6550. maxYaw?: number;
  6551. minYaw?: number;
  6552. maxPitch?: number;
  6553. minPitch?: number;
  6554. slerpAmount?: number;
  6555. upAxis?: Vector3;
  6556. upAxisSpace?: Space;
  6557. yawAxis?: Vector3;
  6558. pitchAxis?: Vector3;
  6559. adjustYaw?: number;
  6560. adjustPitch?: number;
  6561. adjustRoll?: number;
  6562. });
  6563. /**
  6564. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6565. */
  6566. update(): void;
  6567. private _getAngleDiff;
  6568. private _getAngleBetween;
  6569. private _isAngleBetween;
  6570. }
  6571. }
  6572. declare module BABYLON {
  6573. /**
  6574. * Class used to handle skinning animations
  6575. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6576. */
  6577. class Skeleton implements IAnimatable {
  6578. /** defines the skeleton name */
  6579. name: string;
  6580. /** defines the skeleton Id */
  6581. id: string;
  6582. /**
  6583. * Defines the list of child bones
  6584. */
  6585. bones: Bone[];
  6586. /**
  6587. * Defines an estimate of the dimension of the skeleton at rest
  6588. */
  6589. dimensionsAtRest: Vector3;
  6590. /**
  6591. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6592. */
  6593. needInitialSkinMatrix: boolean;
  6594. /**
  6595. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  6596. */
  6597. overrideMesh: Nullable<AbstractMesh>;
  6598. /**
  6599. * Gets the list of animations attached to this skeleton
  6600. */
  6601. animations: Array<Animation>;
  6602. private _scene;
  6603. private _isDirty;
  6604. private _transformMatrices;
  6605. private _transformMatrixTexture;
  6606. private _meshesWithPoseMatrix;
  6607. private _animatables;
  6608. private _identity;
  6609. private _synchronizedWithMesh;
  6610. private _ranges;
  6611. private _lastAbsoluteTransformsUpdateId;
  6612. private _canUseTextureForBones;
  6613. /** @hidden */
  6614. _numBonesWithLinkedTransformNode: number;
  6615. /**
  6616. * Specifies if the skeleton should be serialized
  6617. */
  6618. doNotSerialize: boolean;
  6619. /**
  6620. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  6621. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  6622. */
  6623. useTextureToStoreBoneMatrices: boolean;
  6624. private _animationPropertiesOverride;
  6625. /**
  6626. * Gets or sets the animation properties override
  6627. */
  6628. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6629. /**
  6630. * An observable triggered before computing the skeleton's matrices
  6631. */
  6632. onBeforeComputeObservable: Observable<Skeleton>;
  6633. /**
  6634. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  6635. */
  6636. readonly isUsingTextureForMatrices: boolean;
  6637. /**
  6638. * Creates a new skeleton
  6639. * @param name defines the skeleton name
  6640. * @param id defines the skeleton Id
  6641. * @param scene defines the hosting scene
  6642. */
  6643. constructor(
  6644. /** defines the skeleton name */
  6645. name: string,
  6646. /** defines the skeleton Id */
  6647. id: string, scene: Scene);
  6648. /**
  6649. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6650. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6651. * @returns a Float32Array containing matrices data
  6652. */
  6653. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6654. /**
  6655. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  6656. * @returns a raw texture containing the data
  6657. */
  6658. getTransformMatrixTexture(): Nullable<RawTexture>;
  6659. /**
  6660. * Gets the current hosting scene
  6661. * @returns a scene object
  6662. */
  6663. getScene(): Scene;
  6664. /**
  6665. * Gets a string representing the current skeleton data
  6666. * @param fullDetails defines a boolean indicating if we want a verbose version
  6667. * @returns a string representing the current skeleton data
  6668. */
  6669. toString(fullDetails?: boolean): string;
  6670. /**
  6671. * Get bone's index searching by name
  6672. * @param name defines bone's name to search for
  6673. * @return the indice of the bone. Returns -1 if not found
  6674. */
  6675. getBoneIndexByName(name: string): number;
  6676. /**
  6677. * Creater a new animation range
  6678. * @param name defines the name of the range
  6679. * @param from defines the start key
  6680. * @param to defines the end key
  6681. */
  6682. createAnimationRange(name: string, from: number, to: number): void;
  6683. /**
  6684. * Delete a specific animation range
  6685. * @param name defines the name of the range
  6686. * @param deleteFrames defines if frames must be removed as well
  6687. */
  6688. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6689. /**
  6690. * Gets a specific animation range
  6691. * @param name defines the name of the range to look for
  6692. * @returns the requested animation range or null if not found
  6693. */
  6694. getAnimationRange(name: string): Nullable<AnimationRange>;
  6695. /**
  6696. * Gets the list of all animation ranges defined on this skeleton
  6697. * @returns an array
  6698. */
  6699. getAnimationRanges(): Nullable<AnimationRange>[];
  6700. /**
  6701. * Copy animation range from a source skeleton.
  6702. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6703. * @param source defines the source skeleton
  6704. * @param name defines the name of the range to copy
  6705. * @param rescaleAsRequired defines if rescaling must be applied if required
  6706. * @returns true if operation was successful
  6707. */
  6708. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6709. /**
  6710. * Forces the skeleton to go to rest pose
  6711. */
  6712. returnToRest(): void;
  6713. private _getHighestAnimationFrame;
  6714. /**
  6715. * Begin a specific animation range
  6716. * @param name defines the name of the range to start
  6717. * @param loop defines if looping must be turned on (false by default)
  6718. * @param speedRatio defines the speed ratio to apply (1 by default)
  6719. * @param onAnimationEnd defines a callback which will be called when animation will end
  6720. * @returns a new animatable
  6721. */
  6722. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6723. /** @hidden */
  6724. _markAsDirty(): void;
  6725. /** @hidden */
  6726. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6727. /** @hidden */
  6728. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6729. private _computeTransformMatrices;
  6730. /**
  6731. * Build all resources required to render a skeleton
  6732. */
  6733. prepare(): void;
  6734. /**
  6735. * Gets the list of animatables currently running for this skeleton
  6736. * @returns an array of animatables
  6737. */
  6738. getAnimatables(): IAnimatable[];
  6739. /**
  6740. * Clone the current skeleton
  6741. * @param name defines the name of the new skeleton
  6742. * @param id defines the id of the enw skeleton
  6743. * @returns the new skeleton
  6744. */
  6745. clone(name: string, id: string): Skeleton;
  6746. /**
  6747. * Enable animation blending for this skeleton
  6748. * @param blendingSpeed defines the blending speed to apply
  6749. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6750. */
  6751. enableBlending(blendingSpeed?: number): void;
  6752. /**
  6753. * Releases all resources associated with the current skeleton
  6754. */
  6755. dispose(): void;
  6756. /**
  6757. * Serialize the skeleton in a JSON object
  6758. * @returns a JSON object
  6759. */
  6760. serialize(): any;
  6761. /**
  6762. * Creates a new skeleton from serialized data
  6763. * @param parsedSkeleton defines the serialized data
  6764. * @param scene defines the hosting scene
  6765. * @returns a new skeleton
  6766. */
  6767. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6768. /**
  6769. * Compute all node absolute transforms
  6770. * @param forceUpdate defines if computation must be done even if cache is up to date
  6771. */
  6772. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6773. /**
  6774. * Gets the root pose matrix
  6775. * @returns a matrix
  6776. */
  6777. getPoseMatrix(): Nullable<Matrix>;
  6778. /**
  6779. * Sorts bones per internal index
  6780. */
  6781. sortBones(): void;
  6782. private _sortBones;
  6783. }
  6784. }
  6785. declare module BABYLON {
  6786. /** @hidden */
  6787. class Collider {
  6788. /** Define if a collision was found */
  6789. collisionFound: boolean;
  6790. /**
  6791. * Define last intersection point in local space
  6792. */
  6793. intersectionPoint: Vector3;
  6794. /**
  6795. * Define last collided mesh
  6796. */
  6797. collidedMesh: Nullable<AbstractMesh>;
  6798. private _collisionPoint;
  6799. private _planeIntersectionPoint;
  6800. private _tempVector;
  6801. private _tempVector2;
  6802. private _tempVector3;
  6803. private _tempVector4;
  6804. private _edge;
  6805. private _baseToVertex;
  6806. private _destinationPoint;
  6807. private _slidePlaneNormal;
  6808. private _displacementVector;
  6809. /** @hidden */
  6810. _radius: Vector3;
  6811. /** @hidden */
  6812. _retry: number;
  6813. private _velocity;
  6814. private _basePoint;
  6815. private _epsilon;
  6816. /** @hidden */
  6817. _velocityWorldLength: number;
  6818. /** @hidden */
  6819. _basePointWorld: Vector3;
  6820. private _velocityWorld;
  6821. private _normalizedVelocity;
  6822. /** @hidden */
  6823. _initialVelocity: Vector3;
  6824. /** @hidden */
  6825. _initialPosition: Vector3;
  6826. private _nearestDistance;
  6827. private _collisionMask;
  6828. collisionMask: number;
  6829. /**
  6830. * Gets the plane normal used to compute the sliding response (in local space)
  6831. */
  6832. readonly slidePlaneNormal: Vector3;
  6833. /** @hidden */
  6834. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6835. /** @hidden */
  6836. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6837. /** @hidden */
  6838. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6839. /** @hidden */
  6840. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6841. /** @hidden */
  6842. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6843. /** @hidden */
  6844. _getResponse(pos: Vector3, vel: Vector3): void;
  6845. }
  6846. }
  6847. declare module BABYLON {
  6848. /** @hidden */
  6849. var CollisionWorker: string;
  6850. /** @hidden */
  6851. interface ICollisionCoordinator {
  6852. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6853. init(scene: Scene): void;
  6854. destroy(): void;
  6855. onMeshAdded(mesh: AbstractMesh): void;
  6856. onMeshUpdated(mesh: AbstractMesh): void;
  6857. onMeshRemoved(mesh: AbstractMesh): void;
  6858. onGeometryAdded(geometry: Geometry): void;
  6859. onGeometryUpdated(geometry: Geometry): void;
  6860. onGeometryDeleted(geometry: Geometry): void;
  6861. }
  6862. /** @hidden */
  6863. interface SerializedMesh {
  6864. id: string;
  6865. name: string;
  6866. uniqueId: number;
  6867. geometryId: Nullable<string>;
  6868. sphereCenter: Array<number>;
  6869. sphereRadius: number;
  6870. boxMinimum: Array<number>;
  6871. boxMaximum: Array<number>;
  6872. worldMatrixFromCache: any;
  6873. subMeshes: Array<SerializedSubMesh>;
  6874. checkCollisions: boolean;
  6875. }
  6876. /** @hidden */
  6877. interface SerializedSubMesh {
  6878. position: number;
  6879. verticesStart: number;
  6880. verticesCount: number;
  6881. indexStart: number;
  6882. indexCount: number;
  6883. hasMaterial: boolean;
  6884. sphereCenter: Array<number>;
  6885. sphereRadius: number;
  6886. boxMinimum: Array<number>;
  6887. boxMaximum: Array<number>;
  6888. }
  6889. /**
  6890. * Interface describing the value associated with a geometry.
  6891. * @hidden
  6892. */
  6893. interface SerializedGeometry {
  6894. /**
  6895. * Defines the unique ID of the geometry
  6896. */
  6897. id: string;
  6898. /**
  6899. * Defines the array containing the positions
  6900. */
  6901. positions: Float32Array;
  6902. /**
  6903. * Defines the array containing the indices
  6904. */
  6905. indices: Uint32Array;
  6906. /**
  6907. * Defines the array containing the normals
  6908. */
  6909. normals: Float32Array;
  6910. }
  6911. /** @hidden */
  6912. interface BabylonMessage {
  6913. taskType: WorkerTaskType;
  6914. payload: InitPayload | CollidePayload | UpdatePayload;
  6915. }
  6916. /** @hidden */
  6917. interface SerializedColliderToWorker {
  6918. position: Array<number>;
  6919. velocity: Array<number>;
  6920. radius: Array<number>;
  6921. }
  6922. /** Defines supported task for worker process */
  6923. enum WorkerTaskType {
  6924. /** Initialization */
  6925. INIT = 0,
  6926. /** Update of geometry */
  6927. UPDATE = 1,
  6928. /** Evaluate collision */
  6929. COLLIDE = 2
  6930. }
  6931. /** @hidden */
  6932. interface WorkerReply {
  6933. error: WorkerReplyType;
  6934. taskType: WorkerTaskType;
  6935. payload?: any;
  6936. }
  6937. /** @hidden */
  6938. interface CollisionReplyPayload {
  6939. newPosition: Array<number>;
  6940. collisionId: number;
  6941. collidedMeshUniqueId: number;
  6942. }
  6943. /** @hidden */
  6944. interface InitPayload {
  6945. }
  6946. /** @hidden */
  6947. interface CollidePayload {
  6948. collisionId: number;
  6949. collider: SerializedColliderToWorker;
  6950. maximumRetry: number;
  6951. excludedMeshUniqueId: Nullable<number>;
  6952. }
  6953. /** @hidden */
  6954. interface UpdatePayload {
  6955. updatedMeshes: {
  6956. [n: number]: SerializedMesh;
  6957. };
  6958. updatedGeometries: {
  6959. [s: string]: SerializedGeometry;
  6960. };
  6961. removedMeshes: Array<number>;
  6962. removedGeometries: Array<string>;
  6963. }
  6964. /** Defines kind of replies returned by worker */
  6965. enum WorkerReplyType {
  6966. /** Success */
  6967. SUCCESS = 0,
  6968. /** Unkown error */
  6969. UNKNOWN_ERROR = 1
  6970. }
  6971. /** @hidden */
  6972. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6973. private _scene;
  6974. private _scaledPosition;
  6975. private _scaledVelocity;
  6976. private _collisionsCallbackArray;
  6977. private _init;
  6978. private _runningUpdated;
  6979. private _worker;
  6980. private _addUpdateMeshesList;
  6981. private _addUpdateGeometriesList;
  6982. private _toRemoveMeshesArray;
  6983. private _toRemoveGeometryArray;
  6984. constructor();
  6985. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6986. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6987. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6988. init(scene: Scene): void;
  6989. destroy(): void;
  6990. onMeshAdded(mesh: AbstractMesh): void;
  6991. onMeshUpdated: (transformNode: TransformNode) => void;
  6992. onMeshRemoved(mesh: AbstractMesh): void;
  6993. onGeometryAdded(geometry: Geometry): void;
  6994. onGeometryUpdated: (geometry: Geometry) => void;
  6995. onGeometryDeleted(geometry: Geometry): void;
  6996. private _afterRender;
  6997. private _onMessageFromWorker;
  6998. }
  6999. /** @hidden */
  7000. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  7001. private _scene;
  7002. private _scaledPosition;
  7003. private _scaledVelocity;
  7004. private _finalPosition;
  7005. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  7006. init(scene: Scene): void;
  7007. destroy(): void;
  7008. onMeshAdded(mesh: AbstractMesh): void;
  7009. onMeshUpdated(mesh: AbstractMesh): void;
  7010. onMeshRemoved(mesh: AbstractMesh): void;
  7011. onGeometryAdded(geometry: Geometry): void;
  7012. onGeometryUpdated(geometry: Geometry): void;
  7013. onGeometryDeleted(geometry: Geometry): void;
  7014. private _collideWithWorld;
  7015. }
  7016. }
  7017. declare function importScripts(...urls: string[]): void;
  7018. declare const safePostMessage: any;
  7019. declare module BABYLON {
  7020. /** @hidden */
  7021. var WorkerIncluded: boolean;
  7022. /** @hidden */
  7023. class CollisionCache {
  7024. private _meshes;
  7025. private _geometries;
  7026. getMeshes(): {
  7027. [n: number]: SerializedMesh;
  7028. };
  7029. getGeometries(): {
  7030. [s: number]: SerializedGeometry;
  7031. };
  7032. getMesh(id: any): SerializedMesh;
  7033. addMesh(mesh: SerializedMesh): void;
  7034. removeMesh(uniqueId: number): void;
  7035. getGeometry(id: string): SerializedGeometry;
  7036. addGeometry(geometry: SerializedGeometry): void;
  7037. removeGeometry(id: string): void;
  7038. }
  7039. /** @hidden */
  7040. class CollideWorker {
  7041. collider: Collider;
  7042. private _collisionCache;
  7043. private finalPosition;
  7044. private collisionsScalingMatrix;
  7045. private collisionTranformationMatrix;
  7046. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  7047. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  7048. private checkCollision;
  7049. private processCollisionsForSubMeshes;
  7050. private collideForSubMesh;
  7051. private checkSubmeshCollision;
  7052. }
  7053. /** @hidden */
  7054. interface ICollisionDetector {
  7055. onInit(payload: InitPayload): void;
  7056. onUpdate(payload: UpdatePayload): void;
  7057. onCollision(payload: CollidePayload): void;
  7058. }
  7059. /** @hidden */
  7060. class CollisionDetectorTransferable implements ICollisionDetector {
  7061. private _collisionCache;
  7062. onInit(payload: InitPayload): void;
  7063. onUpdate(payload: UpdatePayload): void;
  7064. onCollision(payload: CollidePayload): void;
  7065. }
  7066. }
  7067. declare module BABYLON {
  7068. /**
  7069. * @hidden
  7070. */
  7071. class IntersectionInfo {
  7072. bu: Nullable<number>;
  7073. bv: Nullable<number>;
  7074. distance: number;
  7075. faceId: number;
  7076. subMeshId: number;
  7077. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7078. }
  7079. /**
  7080. * Information about the result of picking within a scene
  7081. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  7082. */
  7083. class PickingInfo {
  7084. /**
  7085. * If the pick collided with an object
  7086. */
  7087. hit: boolean;
  7088. /**
  7089. * Distance away where the pick collided
  7090. */
  7091. distance: number;
  7092. /**
  7093. * The location of pick collision
  7094. */
  7095. pickedPoint: Nullable<Vector3>;
  7096. /**
  7097. * The mesh corresponding the the pick collision
  7098. */
  7099. pickedMesh: Nullable<AbstractMesh>;
  7100. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  7101. bu: number;
  7102. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  7103. bv: number;
  7104. /** The id of the face on the mesh that was picked */
  7105. faceId: number;
  7106. /** Id of the the submesh that was picked */
  7107. subMeshId: number;
  7108. /** If a sprite was picked, this will be the sprite the pick collided with */
  7109. pickedSprite: Nullable<Sprite>;
  7110. /**
  7111. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  7112. */
  7113. originMesh: Nullable<AbstractMesh>;
  7114. /**
  7115. * The ray that was used to perform the picking.
  7116. */
  7117. ray: Nullable<Ray>;
  7118. /**
  7119. * Gets the normal correspodning to the face the pick collided with
  7120. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  7121. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  7122. * @returns The normal correspodning to the face the pick collided with
  7123. */
  7124. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  7125. /**
  7126. * Gets the texture coordinates of where the pick occured
  7127. * @returns the vector containing the coordnates of the texture
  7128. */
  7129. getTextureCoordinates(): Nullable<Vector2>;
  7130. }
  7131. }
  7132. declare module BABYLON {
  7133. /**
  7134. * Class used to store bounding box information
  7135. */
  7136. class BoundingBox implements ICullable {
  7137. /**
  7138. * Gets the 8 vectors representing the bounding box in local space
  7139. */
  7140. readonly vectors: Vector3[];
  7141. /**
  7142. * Gets the center of the bounding box in local space
  7143. */
  7144. readonly center: Vector3;
  7145. /**
  7146. * Gets the center of the bounding box in world space
  7147. */
  7148. readonly centerWorld: Vector3;
  7149. /**
  7150. * Gets the extend size in local space
  7151. */
  7152. readonly extendSize: Vector3;
  7153. /**
  7154. * Gets the extend size in world space
  7155. */
  7156. readonly extendSizeWorld: Vector3;
  7157. /**
  7158. * Gets the OBB (object bounding box) directions
  7159. */
  7160. readonly directions: Vector3[];
  7161. /**
  7162. * Gets the 8 vectors representing the bounding box in world space
  7163. */
  7164. readonly vectorsWorld: Vector3[];
  7165. /**
  7166. * Gets the minimum vector in world space
  7167. */
  7168. readonly minimumWorld: Vector3;
  7169. /**
  7170. * Gets the maximum vector in world space
  7171. */
  7172. readonly maximumWorld: Vector3;
  7173. /**
  7174. * Gets the minimum vector in local space
  7175. */
  7176. readonly minimum: Vector3;
  7177. /**
  7178. * Gets the maximum vector in local space
  7179. */
  7180. readonly maximum: Vector3;
  7181. private _worldMatrix;
  7182. private static readonly TmpVector3;
  7183. /**
  7184. * @hidden
  7185. */
  7186. _tag: number;
  7187. /**
  7188. * Creates a new bounding box
  7189. * @param min defines the minimum vector (in local space)
  7190. * @param max defines the maximum vector (in local space)
  7191. * @param worldMatrix defines the new world matrix
  7192. */
  7193. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7194. /**
  7195. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7196. * @param min defines the new minimum vector (in local space)
  7197. * @param max defines the new maximum vector (in local space)
  7198. * @param worldMatrix defines the new world matrix
  7199. */
  7200. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7201. /**
  7202. * Scale the current bounding box by applying a scale factor
  7203. * @param factor defines the scale factor to apply
  7204. * @returns the current bounding box
  7205. */
  7206. scale(factor: number): BoundingBox;
  7207. /**
  7208. * Gets the world matrix of the bounding box
  7209. * @returns a matrix
  7210. */
  7211. getWorldMatrix(): DeepImmutable<Matrix>;
  7212. /** @hidden */
  7213. _update(world: DeepImmutable<Matrix>): void;
  7214. /**
  7215. * Tests if the bounding box is intersecting the frustum planes
  7216. * @param frustumPlanes defines the frustum planes to test
  7217. * @returns true if there is an intersection
  7218. */
  7219. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7220. /**
  7221. * Tests if the bounding box is entirely inside the frustum planes
  7222. * @param frustumPlanes defines the frustum planes to test
  7223. * @returns true if there is an inclusion
  7224. */
  7225. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7226. /**
  7227. * Tests if a point is inside the bounding box
  7228. * @param point defines the point to test
  7229. * @returns true if the point is inside the bounding box
  7230. */
  7231. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7232. /**
  7233. * Tests if the bounding box intersects with a bounding sphere
  7234. * @param sphere defines the sphere to test
  7235. * @returns true if there is an intersection
  7236. */
  7237. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7238. /**
  7239. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7240. * @param min defines the min vector to use
  7241. * @param max defines the max vector to use
  7242. * @returns true if there is an intersection
  7243. */
  7244. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7245. /**
  7246. * Tests if two bounding boxes are intersections
  7247. * @param box0 defines the first box to test
  7248. * @param box1 defines the second box to test
  7249. * @returns true if there is an intersection
  7250. */
  7251. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7252. /**
  7253. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7254. * @param minPoint defines the minimum vector of the bounding box
  7255. * @param maxPoint defines the maximum vector of the bounding box
  7256. * @param sphereCenter defines the sphere center
  7257. * @param sphereRadius defines the sphere radius
  7258. * @returns true if there is an intersection
  7259. */
  7260. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7261. /**
  7262. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7263. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7264. * @param frustumPlanes defines the frustum planes to test
  7265. * @return true if there is an inclusion
  7266. */
  7267. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7268. /**
  7269. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7270. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7271. * @param frustumPlanes defines the frustum planes to test
  7272. * @return true if there is an intersection
  7273. */
  7274. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7275. }
  7276. }
  7277. declare module BABYLON {
  7278. /**
  7279. * Interface for cullable objects
  7280. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7281. */
  7282. interface ICullable {
  7283. /**
  7284. * Checks if the object or part of the object is in the frustum
  7285. * @param frustumPlanes Camera near/planes
  7286. * @returns true if the object is in frustum otherwise false
  7287. */
  7288. isInFrustum(frustumPlanes: Plane[]): boolean;
  7289. /**
  7290. * Checks if a cullable object (mesh...) is in the camera frustum
  7291. * Unlike isInFrustum this cheks the full bounding box
  7292. * @param frustumPlanes Camera near/planes
  7293. * @returns true if the object is in frustum otherwise false
  7294. */
  7295. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7296. }
  7297. /**
  7298. * Info for a bounding data of a mesh
  7299. */
  7300. class BoundingInfo implements ICullable {
  7301. /**
  7302. * Bounding box for the mesh
  7303. */
  7304. readonly boundingBox: BoundingBox;
  7305. /**
  7306. * Bounding sphere for the mesh
  7307. */
  7308. readonly boundingSphere: BoundingSphere;
  7309. private _isLocked;
  7310. private static readonly TmpVector3;
  7311. /**
  7312. * Constructs bounding info
  7313. * @param minimum min vector of the bounding box/sphere
  7314. * @param maximum max vector of the bounding box/sphere
  7315. * @param worldMatrix defines the new world matrix
  7316. */
  7317. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7318. /**
  7319. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7320. * @param min defines the new minimum vector (in local space)
  7321. * @param max defines the new maximum vector (in local space)
  7322. * @param worldMatrix defines the new world matrix
  7323. */
  7324. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7325. /**
  7326. * min vector of the bounding box/sphere
  7327. */
  7328. readonly minimum: Vector3;
  7329. /**
  7330. * max vector of the bounding box/sphere
  7331. */
  7332. readonly maximum: Vector3;
  7333. /**
  7334. * If the info is locked and won't be updated to avoid perf overhead
  7335. */
  7336. isLocked: boolean;
  7337. /**
  7338. * Updates the bounding sphere and box
  7339. * @param world world matrix to be used to update
  7340. */
  7341. update(world: DeepImmutable<Matrix>): void;
  7342. /**
  7343. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7344. * @param center New center of the bounding info
  7345. * @param extend New extend of the bounding info
  7346. * @returns the current bounding info
  7347. */
  7348. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7349. /**
  7350. * Scale the current bounding info by applying a scale factor
  7351. * @param factor defines the scale factor to apply
  7352. * @returns the current bounding info
  7353. */
  7354. scale(factor: number): BoundingInfo;
  7355. /**
  7356. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7357. * @param frustumPlanes defines the frustum to test
  7358. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  7359. * @returns true if the bounding info is in the frustum planes
  7360. */
  7361. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7362. /**
  7363. * Gets the world distance between the min and max points of the bounding box
  7364. */
  7365. readonly diagonalLength: number;
  7366. /**
  7367. * Checks if a cullable object (mesh...) is in the camera frustum
  7368. * Unlike isInFrustum this cheks the full bounding box
  7369. * @param frustumPlanes Camera near/planes
  7370. * @returns true if the object is in frustum otherwise false
  7371. */
  7372. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7373. /** @hidden */
  7374. _checkCollision(collider: Collider): boolean;
  7375. /**
  7376. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7377. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7378. * @param point the point to check intersection with
  7379. * @returns if the point intersects
  7380. */
  7381. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7382. /**
  7383. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7384. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7385. * @param boundingInfo the bounding info to check intersection with
  7386. * @param precise if the intersection should be done using OBB
  7387. * @returns if the bounding info intersects
  7388. */
  7389. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7390. }
  7391. }
  7392. declare module BABYLON {
  7393. /**
  7394. * Class used to store bounding sphere information
  7395. */
  7396. class BoundingSphere {
  7397. /**
  7398. * Gets the center of the bounding sphere in local space
  7399. */
  7400. readonly center: Vector3;
  7401. /**
  7402. * Radius of the bounding sphere in local space
  7403. */
  7404. radius: number;
  7405. /**
  7406. * Gets the center of the bounding sphere in world space
  7407. */
  7408. readonly centerWorld: Vector3;
  7409. /**
  7410. * Radius of the bounding sphere in world space
  7411. */
  7412. radiusWorld: number;
  7413. /**
  7414. * Gets the minimum vector in local space
  7415. */
  7416. readonly minimum: Vector3;
  7417. /**
  7418. * Gets the maximum vector in local space
  7419. */
  7420. readonly maximum: Vector3;
  7421. private _worldMatrix;
  7422. private static readonly TmpVector3;
  7423. /**
  7424. * Creates a new bounding sphere
  7425. * @param min defines the minimum vector (in local space)
  7426. * @param max defines the maximum vector (in local space)
  7427. * @param worldMatrix defines the new world matrix
  7428. */
  7429. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7430. /**
  7431. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7432. * @param min defines the new minimum vector (in local space)
  7433. * @param max defines the new maximum vector (in local space)
  7434. * @param worldMatrix defines the new world matrix
  7435. */
  7436. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7437. /**
  7438. * Scale the current bounding sphere by applying a scale factor
  7439. * @param factor defines the scale factor to apply
  7440. * @returns the current bounding box
  7441. */
  7442. scale(factor: number): BoundingSphere;
  7443. /**
  7444. * Gets the world matrix of the bounding box
  7445. * @returns a matrix
  7446. */
  7447. getWorldMatrix(): DeepImmutable<Matrix>;
  7448. /** @hidden */
  7449. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7450. /**
  7451. * Tests if the bounding sphere is intersecting the frustum planes
  7452. * @param frustumPlanes defines the frustum planes to test
  7453. * @returns true if there is an intersection
  7454. */
  7455. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7456. /**
  7457. * Tests if a point is inside the bounding sphere
  7458. * @param point defines the point to test
  7459. * @returns true if the point is inside the bounding sphere
  7460. */
  7461. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7462. /**
  7463. * Checks if two sphere intersct
  7464. * @param sphere0 sphere 0
  7465. * @param sphere1 sphere 1
  7466. * @returns true if the speres intersect
  7467. */
  7468. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7469. }
  7470. }
  7471. declare module BABYLON {
  7472. /**
  7473. * Class representing a ray with position and direction
  7474. */
  7475. class Ray {
  7476. /** origin point */
  7477. origin: Vector3;
  7478. /** direction */
  7479. direction: Vector3;
  7480. /** length of the ray */
  7481. length: number;
  7482. private static readonly TmpVector3;
  7483. private _tmpRay;
  7484. /**
  7485. * Creates a new ray
  7486. * @param origin origin point
  7487. * @param direction direction
  7488. * @param length length of the ray
  7489. */
  7490. constructor(
  7491. /** origin point */
  7492. origin: Vector3,
  7493. /** direction */
  7494. direction: Vector3,
  7495. /** length of the ray */
  7496. length?: number);
  7497. /**
  7498. * Checks if the ray intersects a box
  7499. * @param minimum bound of the box
  7500. * @param maximum bound of the box
  7501. * @param intersectionTreshold extra extend to be added to the box in all direction
  7502. * @returns if the box was hit
  7503. */
  7504. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  7505. /**
  7506. * Checks if the ray intersects a box
  7507. * @param box the bounding box to check
  7508. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  7509. * @returns if the box was hit
  7510. */
  7511. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  7512. /**
  7513. * If the ray hits a sphere
  7514. * @param sphere the bounding sphere to check
  7515. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  7516. * @returns true if it hits the sphere
  7517. */
  7518. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  7519. /**
  7520. * If the ray hits a triange
  7521. * @param vertex0 triangle vertex
  7522. * @param vertex1 triangle vertex
  7523. * @param vertex2 triangle vertex
  7524. * @returns intersection information if hit
  7525. */
  7526. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  7527. /**
  7528. * Checks if ray intersects a plane
  7529. * @param plane the plane to check
  7530. * @returns the distance away it was hit
  7531. */
  7532. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  7533. /**
  7534. * Checks if ray intersects a mesh
  7535. * @param mesh the mesh to check
  7536. * @param fastCheck if only the bounding box should checked
  7537. * @returns picking info of the intersecton
  7538. */
  7539. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  7540. /**
  7541. * Checks if ray intersects a mesh
  7542. * @param meshes the meshes to check
  7543. * @param fastCheck if only the bounding box should checked
  7544. * @param results array to store result in
  7545. * @returns Array of picking infos
  7546. */
  7547. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  7548. private _comparePickingInfo;
  7549. private static smallnum;
  7550. private static rayl;
  7551. /**
  7552. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  7553. * @param sega the first point of the segment to test the intersection against
  7554. * @param segb the second point of the segment to test the intersection against
  7555. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  7556. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  7557. */
  7558. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  7559. /**
  7560. * Update the ray from viewport position
  7561. * @param x position
  7562. * @param y y position
  7563. * @param viewportWidth viewport width
  7564. * @param viewportHeight viewport height
  7565. * @param world world matrix
  7566. * @param view view matrix
  7567. * @param projection projection matrix
  7568. * @returns this ray updated
  7569. */
  7570. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7571. /**
  7572. * Creates a ray with origin and direction of 0,0,0
  7573. * @returns the new ray
  7574. */
  7575. static Zero(): Ray;
  7576. /**
  7577. * Creates a new ray from screen space and viewport
  7578. * @param x position
  7579. * @param y y position
  7580. * @param viewportWidth viewport width
  7581. * @param viewportHeight viewport height
  7582. * @param world world matrix
  7583. * @param view view matrix
  7584. * @param projection projection matrix
  7585. * @returns new ray
  7586. */
  7587. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7588. /**
  7589. * 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
  7590. * transformed to the given world matrix.
  7591. * @param origin The origin point
  7592. * @param end The end point
  7593. * @param world a matrix to transform the ray to. Default is the identity matrix.
  7594. * @returns the new ray
  7595. */
  7596. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  7597. /**
  7598. * Transforms a ray by a matrix
  7599. * @param ray ray to transform
  7600. * @param matrix matrix to apply
  7601. * @returns the resulting new ray
  7602. */
  7603. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  7604. /**
  7605. * Transforms a ray by a matrix
  7606. * @param ray ray to transform
  7607. * @param matrix matrix to apply
  7608. * @param result ray to store result in
  7609. */
  7610. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  7611. }
  7612. }
  7613. declare module BABYLON {
  7614. /**
  7615. * This represents an orbital type of camera.
  7616. *
  7617. * 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.
  7618. * 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.
  7619. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  7620. */
  7621. class ArcRotateCamera extends TargetCamera {
  7622. /**
  7623. * Defines the rotation angle of the camera along the longitudinal axis.
  7624. */
  7625. alpha: number;
  7626. /**
  7627. * Defines the rotation angle of the camera along the latitudinal axis.
  7628. */
  7629. beta: number;
  7630. /**
  7631. * Defines the radius of the camera from it s target point.
  7632. */
  7633. radius: number;
  7634. protected _target: Vector3;
  7635. protected _targetHost: Nullable<AbstractMesh>;
  7636. /**
  7637. * Defines the target point of the camera.
  7638. * The camera looks towards it form the radius distance.
  7639. */
  7640. target: Vector3;
  7641. /**
  7642. * Current inertia value on the longitudinal axis.
  7643. * The bigger this number the longer it will take for the camera to stop.
  7644. */
  7645. inertialAlphaOffset: number;
  7646. /**
  7647. * Current inertia value on the latitudinal axis.
  7648. * The bigger this number the longer it will take for the camera to stop.
  7649. */
  7650. inertialBetaOffset: number;
  7651. /**
  7652. * Current inertia value on the radius axis.
  7653. * The bigger this number the longer it will take for the camera to stop.
  7654. */
  7655. inertialRadiusOffset: number;
  7656. /**
  7657. * Minimum allowed angle on the longitudinal axis.
  7658. * This can help limiting how the Camera is able to move in the scene.
  7659. */
  7660. lowerAlphaLimit: Nullable<number>;
  7661. /**
  7662. * Maximum allowed angle on the longitudinal axis.
  7663. * This can help limiting how the Camera is able to move in the scene.
  7664. */
  7665. upperAlphaLimit: Nullable<number>;
  7666. /**
  7667. * Minimum allowed angle on the latitudinal axis.
  7668. * This can help limiting how the Camera is able to move in the scene.
  7669. */
  7670. lowerBetaLimit: number;
  7671. /**
  7672. * Maximum allowed angle on the latitudinal axis.
  7673. * This can help limiting how the Camera is able to move in the scene.
  7674. */
  7675. upperBetaLimit: number;
  7676. /**
  7677. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  7678. * This can help limiting how the Camera is able to move in the scene.
  7679. */
  7680. lowerRadiusLimit: Nullable<number>;
  7681. /**
  7682. * Maximum allowed distance of the camera to the target (The camera can not get further).
  7683. * This can help limiting how the Camera is able to move in the scene.
  7684. */
  7685. upperRadiusLimit: Nullable<number>;
  7686. /**
  7687. * Defines the current inertia value used during panning of the camera along the X axis.
  7688. */
  7689. inertialPanningX: number;
  7690. /**
  7691. * Defines the current inertia value used during panning of the camera along the Y axis.
  7692. */
  7693. inertialPanningY: number;
  7694. /**
  7695. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  7696. * Basically if your fingers moves away from more than this distance you will be considered
  7697. * in pinch mode.
  7698. */
  7699. pinchToPanMaxDistance: number;
  7700. /**
  7701. * Defines the maximum distance the camera can pan.
  7702. * This could help keeping the cammera always in your scene.
  7703. */
  7704. panningDistanceLimit: Nullable<number>;
  7705. /**
  7706. * Defines the target of the camera before paning.
  7707. */
  7708. panningOriginTarget: Vector3;
  7709. /**
  7710. * Defines the value of the inertia used during panning.
  7711. * 0 would mean stop inertia and one would mean no decelleration at all.
  7712. */
  7713. panningInertia: number;
  7714. /**
  7715. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  7716. */
  7717. angularSensibilityX: number;
  7718. /**
  7719. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  7720. */
  7721. angularSensibilityY: number;
  7722. /**
  7723. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  7724. */
  7725. pinchPrecision: number;
  7726. /**
  7727. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  7728. * It will be used instead of pinchDeltaPrecision if different from 0.
  7729. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7730. */
  7731. pinchDeltaPercentage: number;
  7732. /**
  7733. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  7734. */
  7735. panningSensibility: number;
  7736. /**
  7737. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  7738. */
  7739. keysUp: number[];
  7740. /**
  7741. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  7742. */
  7743. keysDown: number[];
  7744. /**
  7745. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  7746. */
  7747. keysLeft: number[];
  7748. /**
  7749. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  7750. */
  7751. keysRight: number[];
  7752. /**
  7753. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  7754. */
  7755. wheelPrecision: number;
  7756. /**
  7757. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  7758. * It will be used instead of pinchDeltaPrecision if different from 0.
  7759. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7760. */
  7761. wheelDeltaPercentage: number;
  7762. /**
  7763. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  7764. */
  7765. zoomOnFactor: number;
  7766. /**
  7767. * Defines a screen offset for the camera position.
  7768. */
  7769. targetScreenOffset: Vector2;
  7770. /**
  7771. * Allows the camera to be completely reversed.
  7772. * If false the camera can not arrive upside down.
  7773. */
  7774. allowUpsideDown: boolean;
  7775. /**
  7776. * Define if double tap/click is used to restore the previously saved state of the camera.
  7777. */
  7778. useInputToRestoreState: boolean;
  7779. /** @hidden */
  7780. _viewMatrix: Matrix;
  7781. /** @hidden */
  7782. _useCtrlForPanning: boolean;
  7783. /** @hidden */
  7784. _panningMouseButton: number;
  7785. /**
  7786. * Defines the inpute associated to the camera.
  7787. */
  7788. inputs: ArcRotateCameraInputsManager;
  7789. /** @hidden */
  7790. _reset: () => void;
  7791. /**
  7792. * Defines the allowed panning axis.
  7793. */
  7794. panningAxis: Vector3;
  7795. protected _localDirection: Vector3;
  7796. protected _transformedDirection: Vector3;
  7797. private _bouncingBehavior;
  7798. /**
  7799. * Gets the bouncing behavior of the camera if it has been enabled.
  7800. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7801. */
  7802. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  7803. /**
  7804. * Defines if the bouncing behavior of the camera is enabled on the camera.
  7805. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7806. */
  7807. useBouncingBehavior: boolean;
  7808. private _framingBehavior;
  7809. /**
  7810. * Gets the framing behavior of the camera if it has been enabled.
  7811. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7812. */
  7813. readonly framingBehavior: Nullable<FramingBehavior>;
  7814. /**
  7815. * Defines if the framing behavior of the camera is enabled on the camera.
  7816. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7817. */
  7818. useFramingBehavior: boolean;
  7819. private _autoRotationBehavior;
  7820. /**
  7821. * Gets the auto rotation behavior of the camera if it has been enabled.
  7822. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7823. */
  7824. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  7825. /**
  7826. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  7827. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7828. */
  7829. useAutoRotationBehavior: boolean;
  7830. /**
  7831. * Observable triggered when the mesh target has been changed on the camera.
  7832. */
  7833. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7834. /**
  7835. * Event raised when the camera is colliding with a mesh.
  7836. */
  7837. onCollide: (collidedMesh: AbstractMesh) => void;
  7838. /**
  7839. * Defines whether the camera should check collision with the objects oh the scene.
  7840. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7841. */
  7842. checkCollisions: boolean;
  7843. /**
  7844. * Defines the collision radius of the camera.
  7845. * This simulates a sphere around the camera.
  7846. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7847. */
  7848. collisionRadius: Vector3;
  7849. protected _collider: Collider;
  7850. protected _previousPosition: Vector3;
  7851. protected _collisionVelocity: Vector3;
  7852. protected _newPosition: Vector3;
  7853. protected _previousAlpha: number;
  7854. protected _previousBeta: number;
  7855. protected _previousRadius: number;
  7856. protected _collisionTriggered: boolean;
  7857. protected _targetBoundingCenter: Nullable<Vector3>;
  7858. private _computationVector;
  7859. /**
  7860. * Instantiates a new ArcRotateCamera in a given scene
  7861. * @param name Defines the name of the camera
  7862. * @param alpha Defines the camera rotation along the logitudinal axis
  7863. * @param beta Defines the camera rotation along the latitudinal axis
  7864. * @param radius Defines the camera distance from its target
  7865. * @param target Defines the camera target
  7866. * @param scene Defines the scene the camera belongs to
  7867. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7868. */
  7869. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7870. /** @hidden */
  7871. _initCache(): void;
  7872. /** @hidden */
  7873. _updateCache(ignoreParentClass?: boolean): void;
  7874. protected _getTargetPosition(): Vector3;
  7875. private _storedAlpha;
  7876. private _storedBeta;
  7877. private _storedRadius;
  7878. private _storedTarget;
  7879. /**
  7880. * Stores the current state of the camera (alpha, beta, radius and target)
  7881. * @returns the camera itself
  7882. */
  7883. storeState(): Camera;
  7884. /**
  7885. * @hidden
  7886. * Restored camera state. You must call storeState() first
  7887. */
  7888. _restoreStateValues(): boolean;
  7889. /** @hidden */
  7890. _isSynchronizedViewMatrix(): boolean;
  7891. /**
  7892. * Attached controls to the current camera.
  7893. * @param element Defines the element the controls should be listened from
  7894. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7895. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7896. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7897. */
  7898. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7899. /**
  7900. * Detach the current controls from the camera.
  7901. * The camera will stop reacting to inputs.
  7902. * @param element Defines the element to stop listening the inputs from
  7903. */
  7904. detachControl(element: HTMLElement): void;
  7905. /** @hidden */
  7906. _checkInputs(): void;
  7907. protected _checkLimits(): void;
  7908. /**
  7909. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7910. */
  7911. rebuildAnglesAndRadius(): void;
  7912. /**
  7913. * Use a position to define the current camera related information like aplha, beta and radius
  7914. * @param position Defines the position to set the camera at
  7915. */
  7916. setPosition(position: Vector3): void;
  7917. /**
  7918. * Defines the target the camera should look at.
  7919. * This will automatically adapt alpha beta and radius to fit within the new target.
  7920. * @param target Defines the new target as a Vector or a mesh
  7921. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7922. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7923. */
  7924. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7925. /** @hidden */
  7926. _getViewMatrix(): Matrix;
  7927. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7928. /**
  7929. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7930. * @param meshes Defines the mesh to zoom on
  7931. * @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)
  7932. */
  7933. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7934. /**
  7935. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7936. * The target will be changed but the radius
  7937. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7938. * @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)
  7939. */
  7940. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7941. min: Vector3;
  7942. max: Vector3;
  7943. distance: number;
  7944. }, doNotUpdateMaxZ?: boolean): void;
  7945. /**
  7946. * @override
  7947. * Override Camera.createRigCamera
  7948. */
  7949. createRigCamera(name: string, cameraIndex: number): Camera;
  7950. /**
  7951. * @hidden
  7952. * @override
  7953. * Override Camera._updateRigCameras
  7954. */
  7955. _updateRigCameras(): void;
  7956. /**
  7957. * Destroy the camera and release the current resources hold by it.
  7958. */
  7959. dispose(): void;
  7960. /**
  7961. * Gets the current object class name.
  7962. * @return the class name
  7963. */
  7964. getClassName(): string;
  7965. }
  7966. }
  7967. declare module BABYLON {
  7968. /**
  7969. * Default Inputs manager for the ArcRotateCamera.
  7970. * It groups all the default supported inputs for ease of use.
  7971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7972. */
  7973. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7974. /**
  7975. * Instantiates a new ArcRotateCameraInputsManager.
  7976. * @param camera Defines the camera the inputs belong to
  7977. */
  7978. constructor(camera: ArcRotateCamera);
  7979. /**
  7980. * Add mouse wheel input support to the input manager.
  7981. * @returns the current input manager
  7982. */
  7983. addMouseWheel(): ArcRotateCameraInputsManager;
  7984. /**
  7985. * Add pointers input support to the input manager.
  7986. * @returns the current input manager
  7987. */
  7988. addPointers(): ArcRotateCameraInputsManager;
  7989. /**
  7990. * Add keyboard input support to the input manager.
  7991. * @returns the current input manager
  7992. */
  7993. addKeyboard(): ArcRotateCameraInputsManager;
  7994. /**
  7995. * Add orientation input support to the input manager.
  7996. * @returns the current input manager
  7997. */
  7998. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7999. }
  8000. }
  8001. declare module BABYLON {
  8002. /**
  8003. * This is the base class of all the camera used in the application.
  8004. * @see http://doc.babylonjs.com/features/cameras
  8005. */
  8006. class Camera extends Node {
  8007. /**
  8008. * This is the default projection mode used by the cameras.
  8009. * It helps recreating a feeling of perspective and better appreciate depth.
  8010. * This is the best way to simulate real life cameras.
  8011. */
  8012. static readonly PERSPECTIVE_CAMERA: number;
  8013. /**
  8014. * This helps creating camera with an orthographic mode.
  8015. * 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.
  8016. */
  8017. static readonly ORTHOGRAPHIC_CAMERA: number;
  8018. /**
  8019. * This is the default FOV mode for perspective cameras.
  8020. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  8021. */
  8022. static readonly FOVMODE_VERTICAL_FIXED: number;
  8023. /**
  8024. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  8025. */
  8026. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  8027. /**
  8028. * This specifies ther is no need for a camera rig.
  8029. * Basically only one eye is rendered corresponding to the camera.
  8030. */
  8031. static readonly RIG_MODE_NONE: number;
  8032. /**
  8033. * Simulates a camera Rig with one blue eye and one red eye.
  8034. * This can be use with 3d blue and red glasses.
  8035. */
  8036. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  8037. /**
  8038. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  8039. */
  8040. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  8041. /**
  8042. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  8043. */
  8044. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  8045. /**
  8046. * Defines that both eyes of the camera will be rendered over under each other.
  8047. */
  8048. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  8049. /**
  8050. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  8051. */
  8052. static readonly RIG_MODE_VR: number;
  8053. /**
  8054. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  8055. */
  8056. static readonly RIG_MODE_WEBVR: number;
  8057. /**
  8058. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  8059. */
  8060. static readonly RIG_MODE_CUSTOM: number;
  8061. /**
  8062. * Defines if by default attaching controls should prevent the default javascript event to continue.
  8063. */
  8064. static ForceAttachControlToAlwaysPreventDefault: boolean;
  8065. /**
  8066. * @hidden
  8067. * Might be removed once multiview will be a thing
  8068. */
  8069. static UseAlternateWebVRRendering: boolean;
  8070. /**
  8071. * Define the input manager associated with the camera.
  8072. */
  8073. inputs: CameraInputsManager<Camera>;
  8074. /**
  8075. * Define the current local position of the camera in the scene
  8076. */
  8077. position: Vector3;
  8078. /**
  8079. * The vector the camera should consider as up.
  8080. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  8081. */
  8082. upVector: Vector3;
  8083. /**
  8084. * Define the current limit on the left side for an orthographic camera
  8085. * In scene unit
  8086. */
  8087. orthoLeft: Nullable<number>;
  8088. /**
  8089. * Define the current limit on the right side for an orthographic camera
  8090. * In scene unit
  8091. */
  8092. orthoRight: Nullable<number>;
  8093. /**
  8094. * Define the current limit on the bottom side for an orthographic camera
  8095. * In scene unit
  8096. */
  8097. orthoBottom: Nullable<number>;
  8098. /**
  8099. * Define the current limit on the top side for an orthographic camera
  8100. * In scene unit
  8101. */
  8102. orthoTop: Nullable<number>;
  8103. /**
  8104. * Field Of View is set in Radians. (default is 0.8)
  8105. */
  8106. fov: number;
  8107. /**
  8108. * Define the minimum distance the camera can see from.
  8109. * This is important to note that the depth buffer are not infinite and the closer it starts
  8110. * the more your scene might encounter depth fighting issue.
  8111. */
  8112. minZ: number;
  8113. /**
  8114. * Define the maximum distance the camera can see to.
  8115. * This is important to note that the depth buffer are not infinite and the further it end
  8116. * the more your scene might encounter depth fighting issue.
  8117. */
  8118. maxZ: number;
  8119. /**
  8120. * Define the default inertia of the camera.
  8121. * This helps giving a smooth feeling to the camera movement.
  8122. */
  8123. inertia: number;
  8124. /**
  8125. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  8126. */
  8127. mode: number;
  8128. /**
  8129. * Define wether the camera is intermediate.
  8130. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  8131. */
  8132. isIntermediate: boolean;
  8133. /**
  8134. * Define the viewport of the camera.
  8135. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  8136. */
  8137. viewport: Viewport;
  8138. /**
  8139. * Restricts the camera to viewing objects with the same layerMask.
  8140. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  8141. */
  8142. layerMask: number;
  8143. /**
  8144. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  8145. */
  8146. fovMode: number;
  8147. /**
  8148. * Rig mode of the camera.
  8149. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  8150. * This is normally controlled byt the camera themselves as internal use.
  8151. */
  8152. cameraRigMode: number;
  8153. /**
  8154. * Defines the distance between both "eyes" in case of a RIG
  8155. */
  8156. interaxialDistance: number;
  8157. /**
  8158. * Defines if stereoscopic rendering is done side by side or over under.
  8159. */
  8160. isStereoscopicSideBySide: boolean;
  8161. /**
  8162. * 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
  8163. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  8164. * else in the scene.
  8165. */
  8166. customRenderTargets: RenderTargetTexture[];
  8167. /**
  8168. * When set, the camera will render to this render target instead of the default canvas
  8169. */
  8170. outputRenderTarget: Nullable<RenderTargetTexture>;
  8171. /**
  8172. * Observable triggered when the camera view matrix has changed.
  8173. */
  8174. onViewMatrixChangedObservable: Observable<Camera>;
  8175. /**
  8176. * Observable triggered when the camera Projection matrix has changed.
  8177. */
  8178. onProjectionMatrixChangedObservable: Observable<Camera>;
  8179. /**
  8180. * Observable triggered when the inputs have been processed.
  8181. */
  8182. onAfterCheckInputsObservable: Observable<Camera>;
  8183. /**
  8184. * Observable triggered when reset has been called and applied to the camera.
  8185. */
  8186. onRestoreStateObservable: Observable<Camera>;
  8187. /** @hidden */
  8188. _cameraRigParams: any;
  8189. /** @hidden */
  8190. _rigCameras: Camera[];
  8191. /** @hidden */
  8192. _rigPostProcess: Nullable<PostProcess>;
  8193. protected _webvrViewMatrix: Matrix;
  8194. /** @hidden */
  8195. _skipRendering: boolean;
  8196. /** @hidden */
  8197. _alternateCamera: Camera;
  8198. /** @hidden */
  8199. _projectionMatrix: Matrix;
  8200. /** @hidden */
  8201. _postProcesses: Nullable<PostProcess>[];
  8202. /** @hidden */
  8203. _activeMeshes: SmartArray<AbstractMesh>;
  8204. protected _globalPosition: Vector3;
  8205. /** hidden */
  8206. _computedViewMatrix: Matrix;
  8207. private _doNotComputeProjectionMatrix;
  8208. private _transformMatrix;
  8209. private _frustumPlanes;
  8210. private _refreshFrustumPlanes;
  8211. private _storedFov;
  8212. private _stateStored;
  8213. /**
  8214. * Instantiates a new camera object.
  8215. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  8216. * @see http://doc.babylonjs.com/features/cameras
  8217. * @param name Defines the name of the camera in the scene
  8218. * @param position Defines the position of the camera
  8219. * @param scene Defines the scene the camera belongs too
  8220. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  8221. */
  8222. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8223. /**
  8224. * Store current camera state (fov, position, etc..)
  8225. * @returns the camera
  8226. */
  8227. storeState(): Camera;
  8228. /**
  8229. * Restores the camera state values if it has been stored. You must call storeState() first
  8230. */
  8231. protected _restoreStateValues(): boolean;
  8232. /**
  8233. * Restored camera state. You must call storeState() first.
  8234. * @returns true if restored and false otherwise
  8235. */
  8236. restoreState(): boolean;
  8237. /**
  8238. * Gets the class name of the camera.
  8239. * @returns the class name
  8240. */
  8241. getClassName(): string;
  8242. /**
  8243. * Gets a string representation of the camera useful for debug purpose.
  8244. * @param fullDetails Defines that a more verboe level of logging is required
  8245. * @returns the string representation
  8246. */
  8247. toString(fullDetails?: boolean): string;
  8248. /**
  8249. * Gets the current world space position of the camera.
  8250. */
  8251. readonly globalPosition: Vector3;
  8252. /**
  8253. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  8254. * @returns the active meshe list
  8255. */
  8256. getActiveMeshes(): SmartArray<AbstractMesh>;
  8257. /**
  8258. * Check wether a mesh is part of the current active mesh list of the camera
  8259. * @param mesh Defines the mesh to check
  8260. * @returns true if active, false otherwise
  8261. */
  8262. isActiveMesh(mesh: Mesh): boolean;
  8263. /**
  8264. * Is this camera ready to be used/rendered
  8265. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  8266. * @return true if the camera is ready
  8267. */
  8268. isReady(completeCheck?: boolean): boolean;
  8269. /** @hidden */
  8270. _initCache(): void;
  8271. /** @hidden */
  8272. _updateCache(ignoreParentClass?: boolean): void;
  8273. /** @hidden */
  8274. _isSynchronized(): boolean;
  8275. /** @hidden */
  8276. _isSynchronizedViewMatrix(): boolean;
  8277. /** @hidden */
  8278. _isSynchronizedProjectionMatrix(): boolean;
  8279. /**
  8280. * Attach the input controls to a specific dom element to get the input from.
  8281. * @param element Defines the element the controls should be listened from
  8282. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8283. */
  8284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8285. /**
  8286. * Detach the current controls from the specified dom element.
  8287. * @param element Defines the element to stop listening the inputs from
  8288. */
  8289. detachControl(element: HTMLElement): void;
  8290. /**
  8291. * Update the camera state according to the different inputs gathered during the frame.
  8292. */
  8293. update(): void;
  8294. /** @hidden */
  8295. _checkInputs(): void;
  8296. /** @hidden */
  8297. readonly rigCameras: Camera[];
  8298. /**
  8299. * Gets the post process used by the rig cameras
  8300. */
  8301. readonly rigPostProcess: Nullable<PostProcess>;
  8302. /**
  8303. * Internal, gets the first post proces.
  8304. * @returns the first post process to be run on this camera.
  8305. */
  8306. _getFirstPostProcess(): Nullable<PostProcess>;
  8307. private _cascadePostProcessesToRigCams;
  8308. /**
  8309. * Attach a post process to the camera.
  8310. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8311. * @param postProcess The post process to attach to the camera
  8312. * @param insertAt The position of the post process in case several of them are in use in the scene
  8313. * @returns the position the post process has been inserted at
  8314. */
  8315. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  8316. /**
  8317. * Detach a post process to the camera.
  8318. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8319. * @param postProcess The post process to detach from the camera
  8320. */
  8321. detachPostProcess(postProcess: PostProcess): void;
  8322. /**
  8323. * Gets the current world matrix of the camera
  8324. */
  8325. getWorldMatrix(): Matrix;
  8326. /** @hidden */
  8327. protected _getViewMatrix(): Matrix;
  8328. /**
  8329. * Gets the current view matrix of the camera.
  8330. * @param force forces the camera to recompute the matrix without looking at the cached state
  8331. * @returns the view matrix
  8332. */
  8333. getViewMatrix(force?: boolean): Matrix;
  8334. /**
  8335. * Freeze the projection matrix.
  8336. * It will prevent the cache check of the camera projection compute and can speed up perf
  8337. * if no parameter of the camera are meant to change
  8338. * @param projection Defines manually a projection if necessary
  8339. */
  8340. freezeProjectionMatrix(projection?: Matrix): void;
  8341. /**
  8342. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  8343. */
  8344. unfreezeProjectionMatrix(): void;
  8345. /**
  8346. * Gets the current projection matrix of the camera.
  8347. * @param force forces the camera to recompute the matrix without looking at the cached state
  8348. * @returns the projection matrix
  8349. */
  8350. getProjectionMatrix(force?: boolean): Matrix;
  8351. /**
  8352. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  8353. * @returns a Matrix
  8354. */
  8355. getTransformationMatrix(): Matrix;
  8356. private _updateFrustumPlanes;
  8357. /**
  8358. * Checks if a cullable object (mesh...) is in the camera frustum
  8359. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  8360. * @param target The object to check
  8361. * @returns true if the object is in frustum otherwise false
  8362. */
  8363. isInFrustum(target: ICullable): boolean;
  8364. /**
  8365. * Checks if a cullable object (mesh...) is in the camera frustum
  8366. * Unlike isInFrustum this cheks the full bounding box
  8367. * @param target The object to check
  8368. * @returns true if the object is in frustum otherwise false
  8369. */
  8370. isCompletelyInFrustum(target: ICullable): boolean;
  8371. /**
  8372. * Gets a ray in the forward direction from the camera.
  8373. * @param length Defines the length of the ray to create
  8374. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  8375. * @param origin Defines the start point of the ray which defaults to the camera position
  8376. * @returns the forward ray
  8377. */
  8378. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  8379. /**
  8380. * Releases resources associated with this node.
  8381. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8382. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8383. */
  8384. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8385. /**
  8386. * Gets the left camera of a rig setup in case of Rigged Camera
  8387. */
  8388. readonly leftCamera: Nullable<FreeCamera>;
  8389. /**
  8390. * Gets the right camera of a rig setup in case of Rigged Camera
  8391. */
  8392. readonly rightCamera: Nullable<FreeCamera>;
  8393. /**
  8394. * Gets the left camera target of a rig setup in case of Rigged Camera
  8395. * @returns the target position
  8396. */
  8397. getLeftTarget(): Nullable<Vector3>;
  8398. /**
  8399. * Gets the right camera target of a rig setup in case of Rigged Camera
  8400. * @returns the target position
  8401. */
  8402. getRightTarget(): Nullable<Vector3>;
  8403. /**
  8404. * @hidden
  8405. */
  8406. setCameraRigMode(mode: number, rigParams: any): void;
  8407. private _getVRProjectionMatrix;
  8408. protected _updateCameraRotationMatrix(): void;
  8409. protected _updateWebVRCameraRotationMatrix(): void;
  8410. /**
  8411. * This function MUST be overwritten by the different WebVR cameras available.
  8412. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8413. */
  8414. protected _getWebVRProjectionMatrix(): Matrix;
  8415. /**
  8416. * This function MUST be overwritten by the different WebVR cameras available.
  8417. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8418. */
  8419. protected _getWebVRViewMatrix(): Matrix;
  8420. /** @hidden */
  8421. setCameraRigParameter(name: string, value: any): void;
  8422. /**
  8423. * needs to be overridden by children so sub has required properties to be copied
  8424. * @hidden
  8425. */
  8426. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8427. /**
  8428. * May need to be overridden by children
  8429. * @hidden
  8430. */
  8431. _updateRigCameras(): void;
  8432. /** @hidden */
  8433. _setupInputs(): void;
  8434. /**
  8435. * Serialiaze the camera setup to a json represention
  8436. * @returns the JSON representation
  8437. */
  8438. serialize(): any;
  8439. /**
  8440. * Clones the current camera.
  8441. * @param name The cloned camera name
  8442. * @returns the cloned camera
  8443. */
  8444. clone(name: string): Camera;
  8445. /**
  8446. * Gets the direction of the camera relative to a given local axis.
  8447. * @param localAxis Defines the reference axis to provide a relative direction.
  8448. * @return the direction
  8449. */
  8450. getDirection(localAxis: Vector3): Vector3;
  8451. /**
  8452. * Gets the direction of the camera relative to a given local axis into a passed vector.
  8453. * @param localAxis Defines the reference axis to provide a relative direction.
  8454. * @param result Defines the vector to store the result in
  8455. */
  8456. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  8457. /**
  8458. * Gets a camera constructor for a given camera type
  8459. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  8460. * @param name The name of the camera the result will be able to instantiate
  8461. * @param scene The scene the result will construct the camera in
  8462. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  8463. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  8464. * @returns a factory method to construc the camera
  8465. */
  8466. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8467. /**
  8468. * Compute the world matrix of the camera.
  8469. * @returns the camera workd matrix
  8470. */
  8471. computeWorldMatrix(): Matrix;
  8472. /**
  8473. * Parse a JSON and creates the camera from the parsed information
  8474. * @param parsedCamera The JSON to parse
  8475. * @param scene The scene to instantiate the camera in
  8476. * @returns the newly constructed camera
  8477. */
  8478. static Parse(parsedCamera: any, scene: Scene): Camera;
  8479. }
  8480. }
  8481. declare module BABYLON {
  8482. /**
  8483. * @ignore
  8484. * This is a list of all the different input types that are available in the application.
  8485. * Fo instance: ArcRotateCameraGamepadInput...
  8486. */
  8487. var CameraInputTypes: {};
  8488. /**
  8489. * This is the contract to implement in order to create a new input class.
  8490. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8491. */
  8492. interface ICameraInput<TCamera extends Camera> {
  8493. /**
  8494. * Defines the camera the input is attached to.
  8495. */
  8496. camera: Nullable<TCamera>;
  8497. /**
  8498. * Gets the class name of the current intput.
  8499. * @returns the class name
  8500. */
  8501. getClassName(): string;
  8502. /**
  8503. * Get the friendly name associated with the input class.
  8504. * @returns the input friendly name
  8505. */
  8506. getSimpleName(): string;
  8507. /**
  8508. * Attach the input controls to a specific dom element to get the input from.
  8509. * @param element Defines the element the controls should be listened from
  8510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8511. */
  8512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8513. /**
  8514. * Detach the current controls from the specified dom element.
  8515. * @param element Defines the element to stop listening the inputs from
  8516. */
  8517. detachControl(element: Nullable<HTMLElement>): void;
  8518. /**
  8519. * Update the current camera state depending on the inputs that have been used this frame.
  8520. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8521. */
  8522. checkInputs?: () => void;
  8523. }
  8524. /**
  8525. * Represents a map of input types to input instance or input index to input instance.
  8526. */
  8527. interface CameraInputsMap<TCamera extends Camera> {
  8528. /**
  8529. * Accessor to the input by input type.
  8530. */
  8531. [name: string]: ICameraInput<TCamera>;
  8532. /**
  8533. * Accessor to the input by input index.
  8534. */
  8535. [idx: number]: ICameraInput<TCamera>;
  8536. }
  8537. /**
  8538. * This represents the input manager used within a camera.
  8539. * It helps dealing with all the different kind of input attached to a camera.
  8540. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8541. */
  8542. class CameraInputsManager<TCamera extends Camera> {
  8543. /**
  8544. * Defines the list of inputs attahed to the camera.
  8545. */
  8546. attached: CameraInputsMap<TCamera>;
  8547. /**
  8548. * Defines the dom element the camera is collecting inputs from.
  8549. * This is null if the controls have not been attached.
  8550. */
  8551. attachedElement: Nullable<HTMLElement>;
  8552. /**
  8553. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8554. */
  8555. noPreventDefault: boolean;
  8556. /**
  8557. * Defined the camera the input manager belongs to.
  8558. */
  8559. camera: TCamera;
  8560. /**
  8561. * Update the current camera state depending on the inputs that have been used this frame.
  8562. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8563. */
  8564. checkInputs: () => void;
  8565. /**
  8566. * Instantiate a new Camera Input Manager.
  8567. * @param camera Defines the camera the input manager blongs to
  8568. */
  8569. constructor(camera: TCamera);
  8570. /**
  8571. * Add an input method to a camera
  8572. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8573. * @param input camera input method
  8574. */
  8575. add(input: ICameraInput<TCamera>): void;
  8576. /**
  8577. * Remove a specific input method from a camera
  8578. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8579. * @param inputToRemove camera input method
  8580. */
  8581. remove(inputToRemove: ICameraInput<TCamera>): void;
  8582. /**
  8583. * Remove a specific input type from a camera
  8584. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8585. * @param inputType the type of the input to remove
  8586. */
  8587. removeByType(inputType: string): void;
  8588. private _addCheckInputs;
  8589. /**
  8590. * Attach the input controls to the currently attached dom element to listen the events from.
  8591. * @param input Defines the input to attach
  8592. */
  8593. attachInput(input: ICameraInput<TCamera>): void;
  8594. /**
  8595. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8596. * @param element Defines the dom element to collect the events from
  8597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8598. */
  8599. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8600. /**
  8601. * Detach the current manager inputs controls from a specific dom element.
  8602. * @param element Defines the dom element to collect the events from
  8603. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8604. */
  8605. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8606. /**
  8607. * Rebuild the dynamic inputCheck function from the current list of
  8608. * defined inputs in the manager.
  8609. */
  8610. rebuildInputCheck(): void;
  8611. /**
  8612. * Remove all attached input methods from a camera
  8613. */
  8614. clear(): void;
  8615. /**
  8616. * Serialize the current input manager attached to a camera.
  8617. * This ensures than once parsed,
  8618. * the input associated to the camera will be identical to the current ones
  8619. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8620. */
  8621. serialize(serializedCamera: any): void;
  8622. /**
  8623. * Parses an input manager serialized JSON to restore the previous list of inputs
  8624. * and states associated to a camera.
  8625. * @param parsedCamera Defines the JSON to parse
  8626. */
  8627. parse(parsedCamera: any): void;
  8628. }
  8629. }
  8630. declare module BABYLON {
  8631. /**
  8632. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  8633. * being tilted forward or back and left or right.
  8634. */
  8635. class DeviceOrientationCamera extends FreeCamera {
  8636. private _initialQuaternion;
  8637. private _quaternionCache;
  8638. /**
  8639. * Creates a new device orientation camera
  8640. * @param name The name of the camera
  8641. * @param position The start position camera
  8642. * @param scene The scene the camera belongs to
  8643. */
  8644. constructor(name: string, position: Vector3, scene: Scene);
  8645. /**
  8646. * Gets the current instance class name ("DeviceOrientationCamera").
  8647. * This helps avoiding instanceof at run time.
  8648. * @returns the class name
  8649. */
  8650. getClassName(): string;
  8651. /**
  8652. * @hidden
  8653. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  8654. */
  8655. _checkInputs(): void;
  8656. /**
  8657. * Reset the camera to its default orientation on the specified axis only.
  8658. * @param axis The axis to reset
  8659. */
  8660. resetToCurrentRotation(axis?: Axis): void;
  8661. }
  8662. }
  8663. declare module BABYLON {
  8664. /**
  8665. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8666. * such as in a 3D Space Shooter or a Flight Simulator.
  8667. */
  8668. class FlyCamera extends TargetCamera {
  8669. /**
  8670. * Define the collision ellipsoid of the camera.
  8671. * This is helpful for simulating a camera body, like a player's body.
  8672. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8673. */
  8674. ellipsoid: Vector3;
  8675. /**
  8676. * Define an offset for the position of the ellipsoid around the camera.
  8677. * This can be helpful if the camera is attached away from the player's body center,
  8678. * such as at its head.
  8679. */
  8680. ellipsoidOffset: Vector3;
  8681. /**
  8682. * Enable or disable collisions of the camera with the rest of the scene objects.
  8683. */
  8684. checkCollisions: boolean;
  8685. /**
  8686. * Enable or disable gravity on the camera.
  8687. */
  8688. applyGravity: boolean;
  8689. /**
  8690. * Define the current direction the camera is moving to.
  8691. */
  8692. cameraDirection: Vector3;
  8693. /**
  8694. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  8695. * This overrides and empties cameraRotation.
  8696. */
  8697. rotationQuaternion: BABYLON.Quaternion;
  8698. /**
  8699. * Track Roll to maintain the wanted Rolling when looking around.
  8700. */
  8701. _trackRoll: number;
  8702. /**
  8703. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  8704. */
  8705. rollCorrect: number;
  8706. /**
  8707. * Mimic a banked turn, Rolling the camera when Yawing.
  8708. * It's recommended to use rollCorrect = 10 for faster banking correction.
  8709. */
  8710. bankedTurn: boolean;
  8711. /**
  8712. * Limit in radians for how much Roll banking will add. (Default: 90°)
  8713. */
  8714. bankedTurnLimit: number;
  8715. /**
  8716. * Value of 0 disables the banked Roll.
  8717. * Value of 1 is equal to the Yaw angle in radians.
  8718. */
  8719. bankedTurnMultiplier: number;
  8720. /**
  8721. * The inputs manager loads all the input sources, such as keyboard and mouse.
  8722. */
  8723. inputs: FlyCameraInputsManager;
  8724. /**
  8725. * Gets the input sensibility for mouse input.
  8726. * Higher values reduce sensitivity.
  8727. */
  8728. /**
  8729. * Sets the input sensibility for a mouse input.
  8730. * Higher values reduce sensitivity.
  8731. */
  8732. angularSensibility: number;
  8733. /**
  8734. * Get the keys for camera movement forward.
  8735. */
  8736. /**
  8737. * Set the keys for camera movement forward.
  8738. */
  8739. keysForward: number[];
  8740. /**
  8741. * Get the keys for camera movement backward.
  8742. */
  8743. keysBackward: number[];
  8744. /**
  8745. * Get the keys for camera movement up.
  8746. */
  8747. /**
  8748. * Set the keys for camera movement up.
  8749. */
  8750. keysUp: number[];
  8751. /**
  8752. * Get the keys for camera movement down.
  8753. */
  8754. /**
  8755. * Set the keys for camera movement down.
  8756. */
  8757. keysDown: number[];
  8758. /**
  8759. * Get the keys for camera movement left.
  8760. */
  8761. /**
  8762. * Set the keys for camera movement left.
  8763. */
  8764. keysLeft: number[];
  8765. /**
  8766. * Set the keys for camera movement right.
  8767. */
  8768. /**
  8769. * Set the keys for camera movement right.
  8770. */
  8771. keysRight: number[];
  8772. /**
  8773. * Event raised when the camera collides with a mesh in the scene.
  8774. */
  8775. onCollide: (collidedMesh: AbstractMesh) => void;
  8776. private _collider;
  8777. private _needMoveForGravity;
  8778. private _oldPosition;
  8779. private _diffPosition;
  8780. private _newPosition;
  8781. /** @hidden */
  8782. _localDirection: Vector3;
  8783. /** @hidden */
  8784. _transformedDirection: Vector3;
  8785. /**
  8786. * Instantiates a FlyCamera.
  8787. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8788. * such as in a 3D Space Shooter or a Flight Simulator.
  8789. * @param name Define the name of the camera in the scene.
  8790. * @param position Define the starting position of the camera in the scene.
  8791. * @param scene Define the scene the camera belongs to.
  8792. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  8793. */
  8794. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8795. /**
  8796. * Attach a control to the HTML DOM element.
  8797. * @param element Defines the element that listens to the input events.
  8798. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  8799. */
  8800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8801. /**
  8802. * Detach a control from the HTML DOM element.
  8803. * The camera will stop reacting to that input.
  8804. * @param element Defines the element that listens to the input events.
  8805. */
  8806. detachControl(element: HTMLElement): void;
  8807. private _collisionMask;
  8808. /**
  8809. * Get the mask that the camera ignores in collision events.
  8810. */
  8811. /**
  8812. * Set the mask that the camera ignores in collision events.
  8813. */
  8814. collisionMask: number;
  8815. /** @hidden */
  8816. _collideWithWorld(displacement: Vector3): void;
  8817. /** @hidden */
  8818. private _onCollisionPositionChange;
  8819. /** @hidden */
  8820. _checkInputs(): void;
  8821. /** @hidden */
  8822. _decideIfNeedsToMove(): boolean;
  8823. /** @hidden */
  8824. _updatePosition(): void;
  8825. /**
  8826. * Restore the Roll to its target value at the rate specified.
  8827. * @param rate - Higher means slower restoring.
  8828. * @hidden
  8829. */
  8830. restoreRoll(rate: number): void;
  8831. /**
  8832. * Destroy the camera and release the current resources held by it.
  8833. */
  8834. dispose(): void;
  8835. /**
  8836. * Get the current object class name.
  8837. * @returns the class name.
  8838. */
  8839. getClassName(): string;
  8840. }
  8841. }
  8842. declare module BABYLON {
  8843. /**
  8844. * Default Inputs manager for the FlyCamera.
  8845. * It groups all the default supported inputs for ease of use.
  8846. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8847. */
  8848. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  8849. /**
  8850. * Instantiates a new FlyCameraInputsManager.
  8851. * @param camera Defines the camera the inputs belong to.
  8852. */
  8853. constructor(camera: FlyCamera);
  8854. /**
  8855. * Add keyboard input support to the input manager.
  8856. * @returns the new FlyCameraKeyboardMoveInput().
  8857. */
  8858. addKeyboard(): FlyCameraInputsManager;
  8859. /**
  8860. * Add mouse input support to the input manager.
  8861. * @param touchEnabled Enable touch screen support.
  8862. * @returns the new FlyCameraMouseInput().
  8863. */
  8864. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  8865. }
  8866. }
  8867. declare module BABYLON {
  8868. /**
  8869. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  8870. * an arc rotate version arcFollowCamera are available.
  8871. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8872. */
  8873. class FollowCamera extends TargetCamera {
  8874. /**
  8875. * Distance the follow camera should follow an object at
  8876. */
  8877. radius: number;
  8878. /**
  8879. * Define a rotation offset between the camera and the object it follows
  8880. */
  8881. rotationOffset: number;
  8882. /**
  8883. * Define a height offset between the camera and the object it follows.
  8884. * It can help following an object from the top (like a car chaing a plane)
  8885. */
  8886. heightOffset: number;
  8887. /**
  8888. * Define how fast the camera can accelerate to follow it s target.
  8889. */
  8890. cameraAcceleration: number;
  8891. /**
  8892. * Define the speed limit of the camera following an object.
  8893. */
  8894. maxCameraSpeed: number;
  8895. /**
  8896. * Define the target of the camera.
  8897. */
  8898. lockedTarget: Nullable<AbstractMesh>;
  8899. /**
  8900. * Instantiates the follow camera.
  8901. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8902. * @param name Define the name of the camera in the scene
  8903. * @param position Define the position of the camera
  8904. * @param scene Define the scene the camera belong to
  8905. * @param lockedTarget Define the target of the camera
  8906. */
  8907. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8908. private _follow;
  8909. /** @hidden */
  8910. _checkInputs(): void;
  8911. /**
  8912. * Gets the camera class name.
  8913. * @returns the class name
  8914. */
  8915. getClassName(): string;
  8916. }
  8917. /**
  8918. * Arc Rotate version of the follow camera.
  8919. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8920. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8921. */
  8922. class ArcFollowCamera extends TargetCamera {
  8923. /** The longitudinal angle of the camera */
  8924. alpha: number;
  8925. /** The latitudinal angle of the camera */
  8926. beta: number;
  8927. /** The radius of the camera from its target */
  8928. radius: number;
  8929. /** Define the camera target (the messh it should follow) */
  8930. target: Nullable<AbstractMesh>;
  8931. private _cartesianCoordinates;
  8932. /**
  8933. * Instantiates a new ArcFollowCamera
  8934. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8935. * @param name Define the name of the camera
  8936. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8937. * @param beta Define the rotation angle of the camera around the elevation axis
  8938. * @param radius Define the radius of the camera from its target point
  8939. * @param target Define the target of the camera
  8940. * @param scene Define the scene the camera belongs to
  8941. */
  8942. constructor(name: string,
  8943. /** The longitudinal angle of the camera */
  8944. alpha: number,
  8945. /** The latitudinal angle of the camera */
  8946. beta: number,
  8947. /** The radius of the camera from its target */
  8948. radius: number,
  8949. /** Define the camera target (the messh it should follow) */
  8950. target: Nullable<AbstractMesh>, scene: Scene);
  8951. private _follow;
  8952. /** @hidden */
  8953. _checkInputs(): void;
  8954. /**
  8955. * Returns the class name of the object.
  8956. * It is mostly used internally for serialization purposes.
  8957. */
  8958. getClassName(): string;
  8959. }
  8960. }
  8961. declare module BABYLON {
  8962. /**
  8963. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8964. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8965. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8966. */
  8967. class FreeCamera extends TargetCamera {
  8968. /**
  8969. * Define the collision ellipsoid of the camera.
  8970. * This is helpful to simulate a camera body like the player body around the camera
  8971. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8972. */
  8973. ellipsoid: Vector3;
  8974. /**
  8975. * Define an offset for the position of the ellipsoid around the camera.
  8976. * This can be helpful to determine the center of the body near the gravity center of the body
  8977. * instead of its head.
  8978. */
  8979. ellipsoidOffset: Vector3;
  8980. /**
  8981. * Enable or disable collisions of the camera with the rest of the scene objects.
  8982. */
  8983. checkCollisions: boolean;
  8984. /**
  8985. * Enable or disable gravity on the camera.
  8986. */
  8987. applyGravity: boolean;
  8988. /**
  8989. * Define the input manager associated to the camera.
  8990. */
  8991. inputs: FreeCameraInputsManager;
  8992. /**
  8993. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8994. * Higher values reduce sensitivity.
  8995. */
  8996. /**
  8997. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8998. * Higher values reduce sensitivity.
  8999. */
  9000. angularSensibility: number;
  9001. /**
  9002. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9003. */
  9004. keysUp: number[];
  9005. /**
  9006. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9007. */
  9008. keysDown: number[];
  9009. /**
  9010. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9011. */
  9012. keysLeft: number[];
  9013. /**
  9014. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9015. */
  9016. keysRight: number[];
  9017. /**
  9018. * Event raised when the camera collide with a mesh in the scene.
  9019. */
  9020. onCollide: (collidedMesh: AbstractMesh) => void;
  9021. private _collider;
  9022. private _needMoveForGravity;
  9023. private _oldPosition;
  9024. private _diffPosition;
  9025. private _newPosition;
  9026. /** @hidden */
  9027. _localDirection: Vector3;
  9028. /** @hidden */
  9029. _transformedDirection: Vector3;
  9030. /**
  9031. * Instantiates a Free Camera.
  9032. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  9033. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  9034. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9035. * @param name Define the name of the camera in the scene
  9036. * @param position Define the start position of the camera in the scene
  9037. * @param scene Define the scene the camera belongs to
  9038. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9039. */
  9040. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9041. /**
  9042. * Attached controls to the current camera.
  9043. * @param element Defines the element the controls should be listened from
  9044. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9045. */
  9046. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9047. /**
  9048. * Detach the current controls from the camera.
  9049. * The camera will stop reacting to inputs.
  9050. * @param element Defines the element to stop listening the inputs from
  9051. */
  9052. detachControl(element: HTMLElement): void;
  9053. private _collisionMask;
  9054. /**
  9055. * Define a collision mask to limit the list of object the camera can collide with
  9056. */
  9057. collisionMask: number;
  9058. /** @hidden */
  9059. _collideWithWorld(displacement: Vector3): void;
  9060. private _onCollisionPositionChange;
  9061. /** @hidden */
  9062. _checkInputs(): void;
  9063. /** @hidden */
  9064. _decideIfNeedsToMove(): boolean;
  9065. /** @hidden */
  9066. _updatePosition(): void;
  9067. /**
  9068. * Destroy the camera and release the current resources hold by it.
  9069. */
  9070. dispose(): void;
  9071. /**
  9072. * Gets the current object class name.
  9073. * @return the class name
  9074. */
  9075. getClassName(): string;
  9076. }
  9077. }
  9078. declare module BABYLON {
  9079. /**
  9080. * Default Inputs manager for the FreeCamera.
  9081. * It groups all the default supported inputs for ease of use.
  9082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9083. */
  9084. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  9085. /**
  9086. * Instantiates a new FreeCameraInputsManager.
  9087. * @param camera Defines the camera the inputs belong to
  9088. */
  9089. constructor(camera: FreeCamera);
  9090. /**
  9091. * Add keyboard input support to the input manager.
  9092. * @returns the current input manager
  9093. */
  9094. addKeyboard(): FreeCameraInputsManager;
  9095. /**
  9096. * Add mouse input support to the input manager.
  9097. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  9098. * @returns the current input manager
  9099. */
  9100. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  9101. /**
  9102. * Add orientation input support to the input manager.
  9103. * @returns the current input manager
  9104. */
  9105. addDeviceOrientation(): FreeCameraInputsManager;
  9106. /**
  9107. * Add touch input support to the input manager.
  9108. * @returns the current input manager
  9109. */
  9110. addTouch(): FreeCameraInputsManager;
  9111. /**
  9112. * Add virtual joystick input support to the input manager.
  9113. * @returns the current input manager
  9114. */
  9115. addVirtualJoystick(): FreeCameraInputsManager;
  9116. }
  9117. }
  9118. declare module BABYLON {
  9119. /**
  9120. * This represents a FPS type of camera. This is only here for back compat purpose.
  9121. * Please use the UniversalCamera instead as both are identical.
  9122. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9123. */
  9124. class GamepadCamera extends UniversalCamera {
  9125. /**
  9126. * Instantiates a new Gamepad Camera
  9127. * This represents a FPS type of camera. This is only here for back compat purpose.
  9128. * Please use the UniversalCamera instead as both are identical.
  9129. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9130. * @param name Define the name of the camera in the scene
  9131. * @param position Define the start position of the camera in the scene
  9132. * @param scene Define the scene the camera belongs to
  9133. */
  9134. constructor(name: string, position: Vector3, scene: Scene);
  9135. /**
  9136. * Gets the current object class name.
  9137. * @return the class name
  9138. */
  9139. getClassName(): string;
  9140. }
  9141. }
  9142. declare module BABYLON {
  9143. /**
  9144. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9145. * This is the base of the follow, arc rotate cameras and Free camera
  9146. * @see http://doc.babylonjs.com/features/cameras
  9147. */
  9148. class TargetCamera extends Camera {
  9149. private static _RigCamTransformMatrix;
  9150. private static _TargetTransformMatrix;
  9151. private static _TargetFocalPoint;
  9152. /**
  9153. * Define the current direction the camera is moving to
  9154. */
  9155. cameraDirection: Vector3;
  9156. /**
  9157. * Define the current rotation the camera is rotating to
  9158. */
  9159. cameraRotation: Vector2;
  9160. /**
  9161. * When set, the up vector of the camera will be updated by the rotation of the camera
  9162. */
  9163. updateUpVectorFromRotation: boolean;
  9164. private _tmpQuaternion;
  9165. /**
  9166. * Define the current rotation of the camera
  9167. */
  9168. rotation: Vector3;
  9169. /**
  9170. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9171. */
  9172. rotationQuaternion: Quaternion;
  9173. /**
  9174. * Define the current speed of the camera
  9175. */
  9176. speed: number;
  9177. /**
  9178. * Add cconstraint to the camera to prevent it to move freely in all directions and
  9179. * around all axis.
  9180. */
  9181. noRotationConstraint: boolean;
  9182. /**
  9183. * Define the current target of the camera as an object or a position.
  9184. */
  9185. lockedTarget: any;
  9186. /** @hidden */
  9187. _currentTarget: Vector3;
  9188. /** @hidden */
  9189. _initialFocalDistance: number;
  9190. /** @hidden */
  9191. _viewMatrix: Matrix;
  9192. /** @hidden */
  9193. _camMatrix: Matrix;
  9194. /** @hidden */
  9195. _cameraTransformMatrix: Matrix;
  9196. /** @hidden */
  9197. _cameraRotationMatrix: Matrix;
  9198. /** @hidden */
  9199. _referencePoint: Vector3;
  9200. /** @hidden */
  9201. _transformedReferencePoint: Vector3;
  9202. protected _globalCurrentTarget: Vector3;
  9203. protected _globalCurrentUpVector: Vector3;
  9204. /** @hidden */
  9205. _reset: () => void;
  9206. private _defaultUp;
  9207. /**
  9208. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  9209. * This is the base of the follow, arc rotate cameras and Free camera
  9210. * @see http://doc.babylonjs.com/features/cameras
  9211. * @param name Defines the name of the camera in the scene
  9212. * @param position Defines the start position of the camera in the scene
  9213. * @param scene Defines the scene the camera belongs to
  9214. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9215. */
  9216. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9217. /**
  9218. * Gets the position in front of the camera at a given distance.
  9219. * @param distance The distance from the camera we want the position to be
  9220. * @returns the position
  9221. */
  9222. getFrontPosition(distance: number): Vector3;
  9223. /** @hidden */
  9224. _getLockedTargetPosition(): Nullable<Vector3>;
  9225. private _storedPosition;
  9226. private _storedRotation;
  9227. private _storedRotationQuaternion;
  9228. /**
  9229. * Store current camera state of the camera (fov, position, rotation, etc..)
  9230. * @returns the camera
  9231. */
  9232. storeState(): Camera;
  9233. /**
  9234. * Restored camera state. You must call storeState() first
  9235. * @returns whether it was successful or not
  9236. * @hidden
  9237. */
  9238. _restoreStateValues(): boolean;
  9239. /** @hidden */
  9240. _initCache(): void;
  9241. /** @hidden */
  9242. _updateCache(ignoreParentClass?: boolean): void;
  9243. /** @hidden */
  9244. _isSynchronizedViewMatrix(): boolean;
  9245. /** @hidden */
  9246. _computeLocalCameraSpeed(): number;
  9247. /** @hidden */
  9248. setTarget(target: Vector3): void;
  9249. /**
  9250. * Return the current target position of the camera. This value is expressed in local space.
  9251. * @returns the target position
  9252. */
  9253. getTarget(): Vector3;
  9254. /** @hidden */
  9255. _decideIfNeedsToMove(): boolean;
  9256. /** @hidden */
  9257. _updatePosition(): void;
  9258. /** @hidden */
  9259. _checkInputs(): void;
  9260. protected _updateCameraRotationMatrix(): void;
  9261. /**
  9262. * 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)
  9263. * @returns the current camera
  9264. */
  9265. private _rotateUpVectorWithCameraRotationMatrix;
  9266. private _cachedRotationZ;
  9267. private _cachedQuaternionRotationZ;
  9268. /** @hidden */
  9269. _getViewMatrix(): Matrix;
  9270. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9271. /**
  9272. * @hidden
  9273. */
  9274. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9275. /**
  9276. * @hidden
  9277. */
  9278. _updateRigCameras(): void;
  9279. private _getRigCamPositionAndTarget;
  9280. /**
  9281. * Gets the current object class name.
  9282. * @return the class name
  9283. */
  9284. getClassName(): string;
  9285. }
  9286. }
  9287. declare module BABYLON {
  9288. /**
  9289. * This represents a FPS type of camera controlled by touch.
  9290. * This is like a universal camera minus the Gamepad controls.
  9291. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9292. */
  9293. class TouchCamera extends FreeCamera {
  9294. /**
  9295. * Defines the touch sensibility for rotation.
  9296. * The higher the faster.
  9297. */
  9298. touchAngularSensibility: number;
  9299. /**
  9300. * Defines the touch sensibility for move.
  9301. * The higher the faster.
  9302. */
  9303. touchMoveSensibility: number;
  9304. /**
  9305. * Instantiates a new touch camera.
  9306. * This represents a FPS type of camera controlled by touch.
  9307. * This is like a universal camera minus the Gamepad controls.
  9308. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9309. * @param name Define the name of the camera in the scene
  9310. * @param position Define the start position of the camera in the scene
  9311. * @param scene Define the scene the camera belongs to
  9312. */
  9313. constructor(name: string, position: Vector3, scene: Scene);
  9314. /**
  9315. * Gets the current object class name.
  9316. * @return the class name
  9317. */
  9318. getClassName(): string;
  9319. /** @hidden */
  9320. _setupInputs(): void;
  9321. }
  9322. }
  9323. declare module BABYLON {
  9324. /**
  9325. * 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,
  9326. * which still works and will still be found in many Playgrounds.
  9327. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9328. */
  9329. class UniversalCamera extends TouchCamera {
  9330. /**
  9331. * Defines the gamepad rotation sensiblity.
  9332. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  9333. */
  9334. gamepadAngularSensibility: number;
  9335. /**
  9336. * Defines the gamepad move sensiblity.
  9337. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  9338. */
  9339. gamepadMoveSensibility: number;
  9340. /**
  9341. * 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,
  9342. * which still works and will still be found in many Playgrounds.
  9343. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9344. * @param name Define the name of the camera in the scene
  9345. * @param position Define the start position of the camera in the scene
  9346. * @param scene Define the scene the camera belongs to
  9347. */
  9348. constructor(name: string, position: Vector3, scene: Scene);
  9349. /**
  9350. * Gets the current object class name.
  9351. * @return the class name
  9352. */
  9353. getClassName(): string;
  9354. }
  9355. }
  9356. declare module BABYLON {
  9357. /**
  9358. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  9359. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9360. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9361. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9362. */
  9363. class VirtualJoysticksCamera extends FreeCamera {
  9364. /**
  9365. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  9366. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9367. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9368. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9369. * @param name Define the name of the camera in the scene
  9370. * @param position Define the start position of the camera in the scene
  9371. * @param scene Define the scene the camera belongs to
  9372. */
  9373. constructor(name: string, position: Vector3, scene: Scene);
  9374. /**
  9375. * Gets the current object class name.
  9376. * @return the class name
  9377. */
  9378. getClassName(): string;
  9379. }
  9380. }
  9381. interface VRDisplay extends EventTarget {
  9382. /**
  9383. * Dictionary of capabilities describing the VRDisplay.
  9384. */
  9385. readonly capabilities: VRDisplayCapabilities;
  9386. /**
  9387. * z-depth defining the far plane of the eye view frustum
  9388. * enables mapping of values in the render target depth
  9389. * attachment to scene coordinates. Initially set to 10000.0.
  9390. */
  9391. depthFar: number;
  9392. /**
  9393. * z-depth defining the near plane of the eye view frustum
  9394. * enables mapping of values in the render target depth
  9395. * attachment to scene coordinates. Initially set to 0.01.
  9396. */
  9397. depthNear: number;
  9398. /**
  9399. * An identifier for this distinct VRDisplay. Used as an
  9400. * association point in the Gamepad API.
  9401. */
  9402. readonly displayId: number;
  9403. /**
  9404. * A display name, a user-readable name identifying it.
  9405. */
  9406. readonly displayName: string;
  9407. readonly isConnected: boolean;
  9408. readonly isPresenting: boolean;
  9409. /**
  9410. * If this VRDisplay supports room-scale experiences, the optional
  9411. * stage attribute contains details on the room-scale parameters.
  9412. */
  9413. readonly stageParameters: VRStageParameters | null;
  9414. /**
  9415. * Passing the value returned by `requestAnimationFrame` to
  9416. * `cancelAnimationFrame` will unregister the callback.
  9417. * @param handle Define the hanle of the request to cancel
  9418. */
  9419. cancelAnimationFrame(handle: number): void;
  9420. /**
  9421. * Stops presenting to the VRDisplay.
  9422. * @returns a promise to know when it stopped
  9423. */
  9424. exitPresent(): Promise<void>;
  9425. /**
  9426. * Return the current VREyeParameters for the given eye.
  9427. * @param whichEye Define the eye we want the parameter for
  9428. * @returns the eye parameters
  9429. */
  9430. getEyeParameters(whichEye: string): VREyeParameters;
  9431. /**
  9432. * Populates the passed VRFrameData with the information required to render
  9433. * the current frame.
  9434. * @param frameData Define the data structure to populate
  9435. * @returns true if ok otherwise false
  9436. */
  9437. getFrameData(frameData: VRFrameData): boolean;
  9438. /**
  9439. * Get the layers currently being presented.
  9440. * @returns the list of VR layers
  9441. */
  9442. getLayers(): VRLayer[];
  9443. /**
  9444. * Return a VRPose containing the future predicted pose of the VRDisplay
  9445. * when the current frame will be presented. The value returned will not
  9446. * change until JavaScript has returned control to the browser.
  9447. *
  9448. * The VRPose will contain the position, orientation, velocity,
  9449. * and acceleration of each of these properties.
  9450. * @returns the pose object
  9451. */
  9452. getPose(): VRPose;
  9453. /**
  9454. * Return the current instantaneous pose of the VRDisplay, with no
  9455. * prediction applied.
  9456. * @returns the current instantaneous pose
  9457. */
  9458. getImmediatePose(): VRPose;
  9459. /**
  9460. * The callback passed to `requestAnimationFrame` will be called
  9461. * any time a new frame should be rendered. When the VRDisplay is
  9462. * presenting the callback will be called at the native refresh
  9463. * rate of the HMD. When not presenting this function acts
  9464. * identically to how window.requestAnimationFrame acts. Content should
  9465. * make no assumptions of frame rate or vsync behavior as the HMD runs
  9466. * asynchronously from other displays and at differing refresh rates.
  9467. * @param callback Define the eaction to run next frame
  9468. * @returns the request handle it
  9469. */
  9470. requestAnimationFrame(callback: FrameRequestCallback): number;
  9471. /**
  9472. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  9473. * Repeat calls while already presenting will update the VRLayers being displayed.
  9474. * @param layers Define the list of layer to present
  9475. * @returns a promise to know when the request has been fulfilled
  9476. */
  9477. requestPresent(layers: VRLayer[]): Promise<void>;
  9478. /**
  9479. * Reset the pose for this display, treating its current position and
  9480. * orientation as the "origin/zero" values. VRPose.position,
  9481. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9482. * updated when calling resetPose(). This should be called in only
  9483. * sitting-space experiences.
  9484. */
  9485. resetPose(): void;
  9486. /**
  9487. * The VRLayer provided to the VRDisplay will be captured and presented
  9488. * in the HMD. Calling this function has the same effect on the source
  9489. * canvas as any other operation that uses its source image, and canvases
  9490. * created without preserveDrawingBuffer set to true will be cleared.
  9491. * @param pose Define the pose to submit
  9492. */
  9493. submitFrame(pose?: VRPose): void;
  9494. }
  9495. declare var VRDisplay: {
  9496. prototype: VRDisplay;
  9497. new (): VRDisplay;
  9498. };
  9499. interface VRLayer {
  9500. leftBounds?: number[] | Float32Array | null;
  9501. rightBounds?: number[] | Float32Array | null;
  9502. source?: HTMLCanvasElement | null;
  9503. }
  9504. interface VRDisplayCapabilities {
  9505. readonly canPresent: boolean;
  9506. readonly hasExternalDisplay: boolean;
  9507. readonly hasOrientation: boolean;
  9508. readonly hasPosition: boolean;
  9509. readonly maxLayers: number;
  9510. }
  9511. interface VREyeParameters {
  9512. /** @deprecated */
  9513. readonly fieldOfView: VRFieldOfView;
  9514. readonly offset: Float32Array;
  9515. readonly renderHeight: number;
  9516. readonly renderWidth: number;
  9517. }
  9518. interface VRFieldOfView {
  9519. readonly downDegrees: number;
  9520. readonly leftDegrees: number;
  9521. readonly rightDegrees: number;
  9522. readonly upDegrees: number;
  9523. }
  9524. interface VRFrameData {
  9525. readonly leftProjectionMatrix: Float32Array;
  9526. readonly leftViewMatrix: Float32Array;
  9527. readonly pose: VRPose;
  9528. readonly rightProjectionMatrix: Float32Array;
  9529. readonly rightViewMatrix: Float32Array;
  9530. readonly timestamp: number;
  9531. }
  9532. interface VRPose {
  9533. readonly angularAcceleration: Float32Array | null;
  9534. readonly angularVelocity: Float32Array | null;
  9535. readonly linearAcceleration: Float32Array | null;
  9536. readonly linearVelocity: Float32Array | null;
  9537. readonly orientation: Float32Array | null;
  9538. readonly position: Float32Array | null;
  9539. readonly timestamp: number;
  9540. }
  9541. interface VRStageParameters {
  9542. sittingToStandingTransform?: Float32Array;
  9543. sizeX?: number;
  9544. sizeY?: number;
  9545. }
  9546. interface Navigator {
  9547. getVRDisplays(): Promise<VRDisplay[]>;
  9548. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9549. }
  9550. interface Window {
  9551. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9552. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9553. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9554. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9555. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9556. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9557. }
  9558. interface Gamepad {
  9559. readonly displayId: number;
  9560. }
  9561. /**
  9562. * Module Debug contains the (visual) components to debug a scene correctly
  9563. */
  9564. declare module BABYLON.Debug {
  9565. /**
  9566. * The Axes viewer will show 3 axes in a specific point in space
  9567. */
  9568. class AxesViewer {
  9569. private _xAxis;
  9570. private _yAxis;
  9571. private _zAxis;
  9572. private _tmpVector;
  9573. private _scaleLinesFactor;
  9574. private _instanced;
  9575. /**
  9576. * Gets the hosting scene
  9577. */
  9578. scene: Scene;
  9579. /**
  9580. * Gets or sets a number used to scale line length
  9581. */
  9582. scaleLines: number;
  9583. /** Gets the node hierarchy used to render x-axis */
  9584. readonly xAxis: TransformNode;
  9585. /** Gets the node hierarchy used to render y-axis */
  9586. readonly yAxis: TransformNode;
  9587. /** Gets the node hierarchy used to render z-axis */
  9588. readonly zAxis: TransformNode;
  9589. /**
  9590. * Creates a new AxesViewer
  9591. * @param scene defines the hosting scene
  9592. * @param scaleLines defines a number used to scale line length (1 by default)
  9593. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  9594. * @param xAxis defines the node hierarchy used to render the x-axis
  9595. * @param yAxis defines the node hierarchy used to render the y-axis
  9596. * @param zAxis defines the node hierarchy used to render the z-axis
  9597. */
  9598. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  9599. /**
  9600. * Force the viewer to update
  9601. * @param position defines the position of the viewer
  9602. * @param xaxis defines the x axis of the viewer
  9603. * @param yaxis defines the y axis of the viewer
  9604. * @param zaxis defines the z axis of the viewer
  9605. */
  9606. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9607. /**
  9608. * Creates an instance of this axes viewer.
  9609. * @returns a new axes viewer with instanced meshes
  9610. */
  9611. createInstance(): AxesViewer;
  9612. /** Releases resources */
  9613. dispose(): void;
  9614. private static _SetRenderingGroupId;
  9615. }
  9616. }
  9617. declare module BABYLON.Debug {
  9618. /**
  9619. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9620. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9621. */
  9622. class BoneAxesViewer extends AxesViewer {
  9623. /**
  9624. * Gets or sets the target mesh where to display the axes viewer
  9625. */
  9626. mesh: Nullable<Mesh>;
  9627. /**
  9628. * Gets or sets the target bone where to display the axes viewer
  9629. */
  9630. bone: Nullable<Bone>;
  9631. /** Gets current position */
  9632. pos: Vector3;
  9633. /** Gets direction of X axis */
  9634. xaxis: Vector3;
  9635. /** Gets direction of Y axis */
  9636. yaxis: Vector3;
  9637. /** Gets direction of Z axis */
  9638. zaxis: Vector3;
  9639. /**
  9640. * Creates a new BoneAxesViewer
  9641. * @param scene defines the hosting scene
  9642. * @param bone defines the target bone
  9643. * @param mesh defines the target mesh
  9644. * @param scaleLines defines a scaling factor for line length (1 by default)
  9645. */
  9646. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9647. /**
  9648. * Force the viewer to update
  9649. */
  9650. update(): void;
  9651. /** Releases resources */
  9652. dispose(): void;
  9653. }
  9654. }
  9655. declare module BABYLON {
  9656. /**
  9657. * Interface used to define scene explorer extensibility option
  9658. */
  9659. interface IExplorerExtensibilityOption {
  9660. /**
  9661. * Define the option label
  9662. */
  9663. label: string;
  9664. /**
  9665. * Defines the action to execute on click
  9666. */
  9667. action: (entity: any) => void;
  9668. }
  9669. /**
  9670. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  9671. */
  9672. interface IExplorerExtensibilityGroup {
  9673. /**
  9674. * Defines a predicate to test if a given type mut be extended
  9675. */
  9676. predicate: (entity: any) => boolean;
  9677. /**
  9678. * Gets the list of options added to a type
  9679. */
  9680. entries: IExplorerExtensibilityOption[];
  9681. }
  9682. /**
  9683. * Interface used to define the options to use to create the Inspector
  9684. */
  9685. interface IInspectorOptions {
  9686. /**
  9687. * Display in overlay mode (default: false)
  9688. */
  9689. overlay?: boolean;
  9690. /**
  9691. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  9692. */
  9693. globalRoot?: HTMLElement;
  9694. /**
  9695. * Display the Scene explorer
  9696. */
  9697. showExplorer?: boolean;
  9698. /**
  9699. * Display the property inspector
  9700. */
  9701. showInspector?: boolean;
  9702. /**
  9703. * Display in embed mode (both panes on the right)
  9704. */
  9705. embedMode?: boolean;
  9706. /**
  9707. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  9708. */
  9709. handleResize?: boolean;
  9710. /**
  9711. * Allow the panes to popup (default: true)
  9712. */
  9713. enablePopup?: boolean;
  9714. /**
  9715. * Allow the panes to be closed by users (default: true)
  9716. */
  9717. enableClose?: boolean;
  9718. /**
  9719. * Optional list of extensibility entries
  9720. */
  9721. explorerExtensibility?: IExplorerExtensibilityGroup[];
  9722. }
  9723. interface Scene {
  9724. /**
  9725. * @hidden
  9726. * Backing field
  9727. */
  9728. _debugLayer: DebugLayer;
  9729. /**
  9730. * Gets the debug layer (aka Inspector) associated with the scene
  9731. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9732. */
  9733. debugLayer: DebugLayer;
  9734. }
  9735. /**
  9736. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9737. * what is happening in your scene
  9738. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9739. */
  9740. class DebugLayer {
  9741. /**
  9742. * Define the url to get the inspector script from.
  9743. * By default it uses the babylonjs CDN.
  9744. * @ignoreNaming
  9745. */
  9746. static InspectorURL: string;
  9747. private _scene;
  9748. private BJSINSPECTOR;
  9749. /**
  9750. * Observable triggered when a property is changed through the inspector.
  9751. */
  9752. onPropertyChangedObservable: Observable<{
  9753. object: any;
  9754. property: string;
  9755. value: any;
  9756. initialValue: any;
  9757. }>;
  9758. /**
  9759. * Instantiates a new debug layer.
  9760. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9761. * what is happening in your scene
  9762. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9763. * @param scene Defines the scene to inspect
  9764. */
  9765. constructor(scene: Scene);
  9766. /** Creates the inspector window. */
  9767. private _createInspector;
  9768. /**
  9769. * Get if the inspector is visible or not.
  9770. * @returns true if visible otherwise, false
  9771. */
  9772. isVisible(): boolean;
  9773. /**
  9774. * Hide the inspector and close its window.
  9775. */
  9776. hide(): void;
  9777. /**
  9778. * Launch the debugLayer.
  9779. * @param config Define the configuration of the inspector
  9780. */
  9781. show(config?: IInspectorOptions): void;
  9782. }
  9783. }
  9784. declare module BABYLON.Debug {
  9785. /**
  9786. * Used to show the physics impostor around the specific mesh
  9787. */
  9788. class PhysicsViewer {
  9789. /** @hidden */
  9790. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9791. /** @hidden */
  9792. protected _meshes: Array<Nullable<AbstractMesh>>;
  9793. /** @hidden */
  9794. protected _scene: Nullable<Scene>;
  9795. /** @hidden */
  9796. protected _numMeshes: number;
  9797. /** @hidden */
  9798. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9799. private _renderFunction;
  9800. private _utilityLayer;
  9801. private _debugBoxMesh;
  9802. private _debugSphereMesh;
  9803. private _debugMaterial;
  9804. /**
  9805. * Creates a new PhysicsViewer
  9806. * @param scene defines the hosting scene
  9807. */
  9808. constructor(scene: Scene);
  9809. /** @hidden */
  9810. protected _updateDebugMeshes(): void;
  9811. /**
  9812. * Renders a specified physic impostor
  9813. * @param impostor defines the impostor to render
  9814. * @returns the new debug mesh used to render the impostor
  9815. */
  9816. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  9817. /**
  9818. * Hides a specified physic impostor
  9819. * @param impostor defines the impostor to hide
  9820. */
  9821. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9822. private _getDebugMaterial;
  9823. private _getDebugBoxMesh;
  9824. private _getDebugSphereMesh;
  9825. private _getDebugMesh;
  9826. /** Releases all resources */
  9827. dispose(): void;
  9828. }
  9829. }
  9830. declare module BABYLON {
  9831. /**
  9832. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9833. * in order to better appreciate the issue one might have.
  9834. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9835. */
  9836. class RayHelper {
  9837. /**
  9838. * Defines the ray we are currently tryin to visualize.
  9839. */
  9840. ray: Nullable<Ray>;
  9841. private _renderPoints;
  9842. private _renderLine;
  9843. private _renderFunction;
  9844. private _scene;
  9845. private _updateToMeshFunction;
  9846. private _attachedToMesh;
  9847. private _meshSpaceDirection;
  9848. private _meshSpaceOrigin;
  9849. /**
  9850. * Helper function to create a colored helper in a scene in one line.
  9851. * @param ray Defines the ray we are currently tryin to visualize
  9852. * @param scene Defines the scene the ray is used in
  9853. * @param color Defines the color we want to see the ray in
  9854. * @returns The newly created ray helper.
  9855. */
  9856. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9857. /**
  9858. * Instantiate a new ray helper.
  9859. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9860. * in order to better appreciate the issue one might have.
  9861. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9862. * @param ray Defines the ray we are currently tryin to visualize
  9863. */
  9864. constructor(ray: Ray);
  9865. /**
  9866. * Shows the ray we are willing to debug.
  9867. * @param scene Defines the scene the ray needs to be rendered in
  9868. * @param color Defines the color the ray needs to be rendered in
  9869. */
  9870. show(scene: Scene, color?: Color3): void;
  9871. /**
  9872. * Hides the ray we are debugging.
  9873. */
  9874. hide(): void;
  9875. private _render;
  9876. /**
  9877. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9878. * @param mesh Defines the mesh we want the helper attached to
  9879. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9880. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9881. * @param length Defines the length of the ray
  9882. */
  9883. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9884. /**
  9885. * Detach the ray helper from the mesh it has previously been attached to.
  9886. */
  9887. detachFromMesh(): void;
  9888. private _updateToMesh;
  9889. /**
  9890. * Dispose the helper and release its associated resources.
  9891. */
  9892. dispose(): void;
  9893. }
  9894. }
  9895. declare module BABYLON.Debug {
  9896. /**
  9897. * Class used to render a debug view of a given skeleton
  9898. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9899. */
  9900. class SkeletonViewer {
  9901. /** defines the skeleton to render */
  9902. skeleton: Skeleton;
  9903. /** defines the mesh attached to the skeleton */
  9904. mesh: AbstractMesh;
  9905. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9906. autoUpdateBonesMatrices: boolean;
  9907. /** defines the rendering group id to use with the viewer */
  9908. renderingGroupId: number;
  9909. /** Gets or sets the color used to render the skeleton */
  9910. color: Color3;
  9911. private _scene;
  9912. private _debugLines;
  9913. private _debugMesh;
  9914. private _isEnabled;
  9915. private _renderFunction;
  9916. private _utilityLayer;
  9917. /**
  9918. * Returns the mesh used to render the bones
  9919. */
  9920. readonly debugMesh: Nullable<LinesMesh>;
  9921. /**
  9922. * Creates a new SkeletonViewer
  9923. * @param skeleton defines the skeleton to render
  9924. * @param mesh defines the mesh attached to the skeleton
  9925. * @param scene defines the hosting scene
  9926. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9927. * @param renderingGroupId defines the rendering group id to use with the viewer
  9928. */
  9929. constructor(
  9930. /** defines the skeleton to render */
  9931. skeleton: Skeleton,
  9932. /** defines the mesh attached to the skeleton */
  9933. mesh: AbstractMesh, scene: Scene,
  9934. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9935. autoUpdateBonesMatrices?: boolean,
  9936. /** defines the rendering group id to use with the viewer */
  9937. renderingGroupId?: number);
  9938. /** Gets or sets a boolean indicating if the viewer is enabled */
  9939. isEnabled: boolean;
  9940. private _getBonePosition;
  9941. private _getLinesForBonesWithLength;
  9942. private _getLinesForBonesNoLength;
  9943. /** Update the viewer to sync with current skeleton state */
  9944. update(): void;
  9945. /** Release associated resources */
  9946. dispose(): void;
  9947. }
  9948. }
  9949. declare module BABYLON {
  9950. /**
  9951. * Interface for attribute information associated with buffer instanciation
  9952. */
  9953. class InstancingAttributeInfo {
  9954. /**
  9955. * Index/offset of the attribute in the vertex shader
  9956. */
  9957. index: number;
  9958. /**
  9959. * size of the attribute, 1, 2, 3 or 4
  9960. */
  9961. attributeSize: number;
  9962. /**
  9963. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9964. * default is FLOAT
  9965. */
  9966. attribyteType: number;
  9967. /**
  9968. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9969. */
  9970. normalized: boolean;
  9971. /**
  9972. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9973. */
  9974. offset: number;
  9975. /**
  9976. * Name of the GLSL attribute, for debugging purpose only
  9977. */
  9978. attributeName: string;
  9979. }
  9980. /**
  9981. * Define options used to create a render target texture
  9982. */
  9983. class RenderTargetCreationOptions {
  9984. /**
  9985. * Specifies is mipmaps must be generated
  9986. */
  9987. generateMipMaps?: boolean;
  9988. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9989. generateDepthBuffer?: boolean;
  9990. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9991. generateStencilBuffer?: boolean;
  9992. /** Defines texture type (int by default) */
  9993. type?: number;
  9994. /** Defines sampling mode (trilinear by default) */
  9995. samplingMode?: number;
  9996. /** Defines format (RGBA by default) */
  9997. format?: number;
  9998. }
  9999. /**
  10000. * Define options used to create a depth texture
  10001. */
  10002. class DepthTextureCreationOptions {
  10003. /** Specifies whether or not a stencil should be allocated in the texture */
  10004. generateStencil?: boolean;
  10005. /** Specifies whether or not bilinear filtering is enable on the texture */
  10006. bilinearFiltering?: boolean;
  10007. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10008. comparisonFunction?: number;
  10009. /** Specifies if the created texture is a cube texture */
  10010. isCube?: boolean;
  10011. }
  10012. /**
  10013. * Class used to describe the capabilities of the engine relatively to the current browser
  10014. */
  10015. class EngineCapabilities {
  10016. /** Maximum textures units per fragment shader */
  10017. maxTexturesImageUnits: number;
  10018. /** Maximum texture units per vertex shader */
  10019. maxVertexTextureImageUnits: number;
  10020. /** Maximum textures units in the entire pipeline */
  10021. maxCombinedTexturesImageUnits: number;
  10022. /** Maximum texture size */
  10023. maxTextureSize: number;
  10024. /** Maximum cube texture size */
  10025. maxCubemapTextureSize: number;
  10026. /** Maximum render texture size */
  10027. maxRenderTextureSize: number;
  10028. /** Maximum number of vertex attributes */
  10029. maxVertexAttribs: number;
  10030. /** Maximum number of varyings */
  10031. maxVaryingVectors: number;
  10032. /** Maximum number of uniforms per vertex shader */
  10033. maxVertexUniformVectors: number;
  10034. /** Maximum number of uniforms per fragment shader */
  10035. maxFragmentUniformVectors: number;
  10036. /** Defines if standard derivates (dx/dy) are supported */
  10037. standardDerivatives: boolean;
  10038. /** Defines if s3tc texture compression is supported */
  10039. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  10040. /** Defines if pvrtc texture compression is supported */
  10041. pvrtc: any;
  10042. /** Defines if etc1 texture compression is supported */
  10043. etc1: any;
  10044. /** Defines if etc2 texture compression is supported */
  10045. etc2: any;
  10046. /** Defines if astc texture compression is supported */
  10047. astc: any;
  10048. /** Defines if float textures are supported */
  10049. textureFloat: boolean;
  10050. /** Defines if vertex array objects are supported */
  10051. vertexArrayObject: boolean;
  10052. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  10053. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  10054. /** Gets the maximum level of anisotropy supported */
  10055. maxAnisotropy: number;
  10056. /** Defines if instancing is supported */
  10057. instancedArrays: boolean;
  10058. /** Defines if 32 bits indices are supported */
  10059. uintIndices: boolean;
  10060. /** Defines if high precision shaders are supported */
  10061. highPrecisionShaderSupported: boolean;
  10062. /** Defines if depth reading in the fragment shader is supported */
  10063. fragmentDepthSupported: boolean;
  10064. /** Defines if float texture linear filtering is supported*/
  10065. textureFloatLinearFiltering: boolean;
  10066. /** Defines if rendering to float textures is supported */
  10067. textureFloatRender: boolean;
  10068. /** Defines if half float textures are supported*/
  10069. textureHalfFloat: boolean;
  10070. /** Defines if half float texture linear filtering is supported*/
  10071. textureHalfFloatLinearFiltering: boolean;
  10072. /** Defines if rendering to half float textures is supported */
  10073. textureHalfFloatRender: boolean;
  10074. /** Defines if textureLOD shader command is supported */
  10075. textureLOD: boolean;
  10076. /** Defines if draw buffers extension is supported */
  10077. drawBuffersExtension: boolean;
  10078. /** Defines if depth textures are supported */
  10079. depthTextureExtension: boolean;
  10080. /** Defines if float color buffer are supported */
  10081. colorBufferFloat: boolean;
  10082. /** Gets disjoint timer query extension (null if not supported) */
  10083. timerQuery: EXT_disjoint_timer_query;
  10084. /** Defines if timestamp can be used with timer query */
  10085. canUseTimestampForTimerQuery: boolean;
  10086. /** Function used to let the system compiles shaders in background */
  10087. parallelShaderCompile: {
  10088. MAX_SHADER_COMPILER_THREADS_KHR: number;
  10089. maxShaderCompilerThreadsKHR: (thread: number) => void;
  10090. COMPLETION_STATUS_KHR: number;
  10091. };
  10092. }
  10093. /** Interface defining initialization parameters for Engine class */
  10094. interface EngineOptions extends WebGLContextAttributes {
  10095. /**
  10096. * Defines if the engine should no exceed a specified device ratio
  10097. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  10098. */
  10099. limitDeviceRatio?: number;
  10100. /**
  10101. * Defines if webvr should be enabled automatically
  10102. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10103. */
  10104. autoEnableWebVR?: boolean;
  10105. /**
  10106. * Defines if webgl2 should be turned off even if supported
  10107. * @see http://doc.babylonjs.com/features/webgl2
  10108. */
  10109. disableWebGL2Support?: boolean;
  10110. /**
  10111. * Defines if webaudio should be initialized as well
  10112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10113. */
  10114. audioEngine?: boolean;
  10115. /**
  10116. * Defines if animations should run using a deterministic lock step
  10117. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10118. */
  10119. deterministicLockstep?: boolean;
  10120. /** Defines the maximum steps to use with deterministic lock step mode */
  10121. lockstepMaxSteps?: number;
  10122. /**
  10123. * Defines that engine should ignore context lost events
  10124. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  10125. */
  10126. doNotHandleContextLost?: boolean;
  10127. }
  10128. /**
  10129. * Defines the interface used by display changed events
  10130. */
  10131. interface IDisplayChangedEventArgs {
  10132. /** Gets the vrDisplay object (if any) */
  10133. vrDisplay: Nullable<any>;
  10134. /** Gets a boolean indicating if webVR is supported */
  10135. vrSupported: boolean;
  10136. }
  10137. /**
  10138. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  10139. */
  10140. class Engine {
  10141. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  10142. static ExceptionList: ({
  10143. key: string;
  10144. capture: string;
  10145. captureConstraint: number;
  10146. targets: string[];
  10147. } | {
  10148. key: string;
  10149. capture: null;
  10150. captureConstraint: null;
  10151. targets: string[];
  10152. })[];
  10153. /** Gets the list of created engines */
  10154. static Instances: Engine[];
  10155. /**
  10156. * Gets the latest created engine
  10157. */
  10158. static readonly LastCreatedEngine: Nullable<Engine>;
  10159. /**
  10160. * Gets the latest created scene
  10161. */
  10162. static readonly LastCreatedScene: Nullable<Scene>;
  10163. /**
  10164. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10165. * @param flag defines which part of the materials must be marked as dirty
  10166. * @param predicate defines a predicate used to filter which materials should be affected
  10167. */
  10168. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10169. /**
  10170. * Hidden
  10171. */
  10172. static _TextureLoaders: IInternalTextureLoader[];
  10173. /** Defines that alpha blending is disabled */
  10174. static readonly ALPHA_DISABLE: number;
  10175. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10176. static readonly ALPHA_ADD: number;
  10177. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10178. static readonly ALPHA_COMBINE: number;
  10179. /** Defines that alpha blending to DEST - SRC * DEST */
  10180. static readonly ALPHA_SUBTRACT: number;
  10181. /** Defines that alpha blending to SRC * DEST */
  10182. static readonly ALPHA_MULTIPLY: number;
  10183. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10184. static readonly ALPHA_MAXIMIZED: number;
  10185. /** Defines that alpha blending to SRC + DEST */
  10186. static readonly ALPHA_ONEONE: number;
  10187. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10188. static readonly ALPHA_PREMULTIPLIED: number;
  10189. /**
  10190. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10191. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10192. */
  10193. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10194. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10195. static readonly ALPHA_INTERPOLATE: number;
  10196. /**
  10197. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10198. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10199. */
  10200. static readonly ALPHA_SCREENMODE: number;
  10201. /** Defines that the ressource is not delayed*/
  10202. static readonly DELAYLOADSTATE_NONE: number;
  10203. /** Defines that the ressource was successfully delay loaded */
  10204. static readonly DELAYLOADSTATE_LOADED: number;
  10205. /** Defines that the ressource is currently delay loading */
  10206. static readonly DELAYLOADSTATE_LOADING: number;
  10207. /** Defines that the ressource is delayed and has not started loading */
  10208. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10209. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10210. static readonly NEVER: number;
  10211. /** 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 */
  10212. static readonly ALWAYS: number;
  10213. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10214. static readonly LESS: number;
  10215. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10216. static readonly EQUAL: number;
  10217. /** 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 */
  10218. static readonly LEQUAL: number;
  10219. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10220. static readonly GREATER: number;
  10221. /** 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 */
  10222. static readonly GEQUAL: number;
  10223. /** 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 */
  10224. static readonly NOTEQUAL: number;
  10225. /** Passed to stencilOperation to specify that stencil value must be kept */
  10226. static readonly KEEP: number;
  10227. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10228. static readonly REPLACE: number;
  10229. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10230. static readonly INCR: number;
  10231. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10232. static readonly DECR: number;
  10233. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10234. static readonly INVERT: number;
  10235. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10236. static readonly INCR_WRAP: number;
  10237. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10238. static readonly DECR_WRAP: number;
  10239. /** Texture is not repeating outside of 0..1 UVs */
  10240. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10241. /** Texture is repeating outside of 0..1 UVs */
  10242. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10243. /** Texture is repeating and mirrored */
  10244. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10245. /** ALPHA */
  10246. static readonly TEXTUREFORMAT_ALPHA: number;
  10247. /** LUMINANCE */
  10248. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10249. /** LUMINANCE_ALPHA */
  10250. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10251. /** RGB */
  10252. static readonly TEXTUREFORMAT_RGB: number;
  10253. /** RGBA */
  10254. static readonly TEXTUREFORMAT_RGBA: number;
  10255. /** RED */
  10256. static readonly TEXTUREFORMAT_RED: number;
  10257. /** RED (2nd reference) */
  10258. static readonly TEXTUREFORMAT_R: number;
  10259. /** RG */
  10260. static readonly TEXTUREFORMAT_RG: number;
  10261. /** RED_INTEGER */
  10262. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10263. /** RED_INTEGER (2nd reference) */
  10264. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10265. /** RG_INTEGER */
  10266. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10267. /** RGB_INTEGER */
  10268. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10269. /** RGBA_INTEGER */
  10270. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10271. /** UNSIGNED_BYTE */
  10272. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10273. /** UNSIGNED_BYTE (2nd reference) */
  10274. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10275. /** FLOAT */
  10276. static readonly TEXTURETYPE_FLOAT: number;
  10277. /** HALF_FLOAT */
  10278. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10279. /** BYTE */
  10280. static readonly TEXTURETYPE_BYTE: number;
  10281. /** SHORT */
  10282. static readonly TEXTURETYPE_SHORT: number;
  10283. /** UNSIGNED_SHORT */
  10284. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10285. /** INT */
  10286. static readonly TEXTURETYPE_INT: number;
  10287. /** UNSIGNED_INT */
  10288. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10289. /** UNSIGNED_SHORT_4_4_4_4 */
  10290. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10291. /** UNSIGNED_SHORT_5_5_5_1 */
  10292. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10293. /** UNSIGNED_SHORT_5_6_5 */
  10294. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10295. /** UNSIGNED_INT_2_10_10_10_REV */
  10296. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10297. /** UNSIGNED_INT_24_8 */
  10298. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10299. /** UNSIGNED_INT_10F_11F_11F_REV */
  10300. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10301. /** UNSIGNED_INT_5_9_9_9_REV */
  10302. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10303. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10304. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10305. /** nearest is mag = nearest and min = nearest and mip = linear */
  10306. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10307. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10308. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10309. /** Trilinear is mag = linear and min = linear and mip = linear */
  10310. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10311. /** nearest is mag = nearest and min = nearest and mip = linear */
  10312. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10313. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10314. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10315. /** Trilinear is mag = linear and min = linear and mip = linear */
  10316. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10317. /** mag = nearest and min = nearest and mip = nearest */
  10318. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10319. /** mag = nearest and min = linear and mip = nearest */
  10320. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10321. /** mag = nearest and min = linear and mip = linear */
  10322. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10323. /** mag = nearest and min = linear and mip = none */
  10324. static readonly TEXTURE_NEAREST_LINEAR: number;
  10325. /** mag = nearest and min = nearest and mip = none */
  10326. static readonly TEXTURE_NEAREST_NEAREST: number;
  10327. /** mag = linear and min = nearest and mip = nearest */
  10328. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10329. /** mag = linear and min = nearest and mip = linear */
  10330. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10331. /** mag = linear and min = linear and mip = none */
  10332. static readonly TEXTURE_LINEAR_LINEAR: number;
  10333. /** mag = linear and min = nearest and mip = none */
  10334. static readonly TEXTURE_LINEAR_NEAREST: number;
  10335. /** Explicit coordinates mode */
  10336. static readonly TEXTURE_EXPLICIT_MODE: number;
  10337. /** Spherical coordinates mode */
  10338. static readonly TEXTURE_SPHERICAL_MODE: number;
  10339. /** Planar coordinates mode */
  10340. static readonly TEXTURE_PLANAR_MODE: number;
  10341. /** Cubic coordinates mode */
  10342. static readonly TEXTURE_CUBIC_MODE: number;
  10343. /** Projection coordinates mode */
  10344. static readonly TEXTURE_PROJECTION_MODE: number;
  10345. /** Skybox coordinates mode */
  10346. static readonly TEXTURE_SKYBOX_MODE: number;
  10347. /** Inverse Cubic coordinates mode */
  10348. static readonly TEXTURE_INVCUBIC_MODE: number;
  10349. /** Equirectangular coordinates mode */
  10350. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10351. /** Equirectangular Fixed coordinates mode */
  10352. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10353. /** Equirectangular Fixed Mirrored coordinates mode */
  10354. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10355. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10356. static readonly SCALEMODE_FLOOR: number;
  10357. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10358. static readonly SCALEMODE_NEAREST: number;
  10359. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10360. static readonly SCALEMODE_CEILING: number;
  10361. /**
  10362. * Returns the current version of the framework
  10363. */
  10364. static readonly Version: string;
  10365. /**
  10366. * Returns a string describing the current engine
  10367. */
  10368. readonly description: string;
  10369. /**
  10370. * Gets or sets the epsilon value used by collision engine
  10371. */
  10372. static CollisionsEpsilon: number;
  10373. /**
  10374. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10375. */
  10376. static CodeRepository: string;
  10377. /**
  10378. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10379. */
  10380. static ShadersRepository: string;
  10381. /**
  10382. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10383. */
  10384. forcePOTTextures: boolean;
  10385. /**
  10386. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10387. */
  10388. isFullscreen: boolean;
  10389. /**
  10390. * Gets a boolean indicating if the pointer is currently locked
  10391. */
  10392. isPointerLock: boolean;
  10393. /**
  10394. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10395. */
  10396. cullBackFaces: boolean;
  10397. /**
  10398. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10399. */
  10400. renderEvenInBackground: boolean;
  10401. /**
  10402. * Gets or sets a boolean indicating that cache can be kept between frames
  10403. */
  10404. preventCacheWipeBetweenFrames: boolean;
  10405. /**
  10406. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10407. **/
  10408. enableOfflineSupport: boolean;
  10409. /**
  10410. * 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)
  10411. **/
  10412. disableManifestCheck: boolean;
  10413. /**
  10414. * Gets the list of created scenes
  10415. */
  10416. scenes: Scene[];
  10417. /**
  10418. * Event raised when a new scene is created
  10419. */
  10420. onNewSceneAddedObservable: Observable<Scene>;
  10421. /**
  10422. * Gets the list of created postprocesses
  10423. */
  10424. postProcesses: PostProcess[];
  10425. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10426. validateShaderPrograms: boolean;
  10427. /**
  10428. * Observable event triggered each time the rendering canvas is resized
  10429. */
  10430. onResizeObservable: Observable<Engine>;
  10431. /**
  10432. * Observable event triggered each time the canvas loses focus
  10433. */
  10434. onCanvasBlurObservable: Observable<Engine>;
  10435. /**
  10436. * Observable event triggered each time the canvas gains focus
  10437. */
  10438. onCanvasFocusObservable: Observable<Engine>;
  10439. /**
  10440. * Observable event triggered each time the canvas receives pointerout event
  10441. */
  10442. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10443. /**
  10444. * Observable event triggered before each texture is initialized
  10445. */
  10446. onBeforeTextureInitObservable: Observable<Texture>;
  10447. private _vrDisplay;
  10448. private _vrSupported;
  10449. private _oldSize;
  10450. private _oldHardwareScaleFactor;
  10451. private _vrExclusivePointerMode;
  10452. private _webVRInitPromise;
  10453. /**
  10454. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10455. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10456. */
  10457. readonly isInVRExclusivePointerMode: boolean;
  10458. /**
  10459. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10460. */
  10461. disableUniformBuffers: boolean;
  10462. /** @hidden */
  10463. _uniformBuffers: UniformBuffer[];
  10464. /**
  10465. * Gets a boolean indicating that the engine supports uniform buffers
  10466. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10467. */
  10468. readonly supportsUniformBuffers: boolean;
  10469. /**
  10470. * Observable raised when the engine begins a new frame
  10471. */
  10472. onBeginFrameObservable: Observable<Engine>;
  10473. /**
  10474. * If set, will be used to request the next animation frame for the render loop
  10475. */
  10476. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10477. /**
  10478. * Observable raised when the engine ends the current frame
  10479. */
  10480. onEndFrameObservable: Observable<Engine>;
  10481. /**
  10482. * Observable raised when the engine is about to compile a shader
  10483. */
  10484. onBeforeShaderCompilationObservable: Observable<Engine>;
  10485. /**
  10486. * Observable raised when the engine has jsut compiled a shader
  10487. */
  10488. onAfterShaderCompilationObservable: Observable<Engine>;
  10489. /** @hidden */
  10490. _gl: WebGLRenderingContext;
  10491. private _renderingCanvas;
  10492. private _windowIsBackground;
  10493. private _webGLVersion;
  10494. /**
  10495. * Gets a boolean indicating that only power of 2 textures are supported
  10496. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10497. */
  10498. readonly needPOTTextures: boolean;
  10499. /** @hidden */
  10500. _badOS: boolean;
  10501. /** @hidden */
  10502. _badDesktopOS: boolean;
  10503. /**
  10504. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10505. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10506. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10507. */
  10508. disableTextureBindingOptimization: boolean;
  10509. /**
  10510. * Gets the audio engine
  10511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10512. * @ignorenaming
  10513. */
  10514. static audioEngine: IAudioEngine;
  10515. /**
  10516. * Default AudioEngine factory responsible of creating the Audio Engine.
  10517. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10518. */
  10519. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10520. /**
  10521. * Default offline support factory responsible of creating a tool used to store data locally.
  10522. * By default, this will create a Database object if the workload has been embedded.
  10523. */
  10524. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10525. private _onFocus;
  10526. private _onBlur;
  10527. private _onCanvasPointerOut;
  10528. private _onCanvasBlur;
  10529. private _onCanvasFocus;
  10530. private _onFullscreenChange;
  10531. private _onPointerLockChange;
  10532. private _onVRDisplayPointerRestricted;
  10533. private _onVRDisplayPointerUnrestricted;
  10534. private _onVrDisplayConnect;
  10535. private _onVrDisplayDisconnect;
  10536. private _onVrDisplayPresentChange;
  10537. /**
  10538. * Observable signaled when VR display mode changes
  10539. */
  10540. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10541. /**
  10542. * Observable signaled when VR request present is complete
  10543. */
  10544. onVRRequestPresentComplete: Observable<boolean>;
  10545. /**
  10546. * Observable signaled when VR request present starts
  10547. */
  10548. onVRRequestPresentStart: Observable<Engine>;
  10549. private _hardwareScalingLevel;
  10550. /** @hidden */
  10551. protected _caps: EngineCapabilities;
  10552. private _pointerLockRequested;
  10553. private _isStencilEnable;
  10554. private _colorWrite;
  10555. private _loadingScreen;
  10556. /** @hidden */
  10557. _drawCalls: PerfCounter;
  10558. /** @hidden */
  10559. _textureCollisions: PerfCounter;
  10560. private _glVersion;
  10561. private _glRenderer;
  10562. private _glVendor;
  10563. private _videoTextureSupported;
  10564. private _renderingQueueLaunched;
  10565. private _activeRenderLoops;
  10566. private _deterministicLockstep;
  10567. private _lockstepMaxSteps;
  10568. /**
  10569. * Observable signaled when a context lost event is raised
  10570. */
  10571. onContextLostObservable: Observable<Engine>;
  10572. /**
  10573. * Observable signaled when a context restored event is raised
  10574. */
  10575. onContextRestoredObservable: Observable<Engine>;
  10576. private _onContextLost;
  10577. private _onContextRestored;
  10578. private _contextWasLost;
  10579. private _doNotHandleContextLost;
  10580. /**
  10581. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10582. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10583. */
  10584. doNotHandleContextLost: boolean;
  10585. private _performanceMonitor;
  10586. private _fps;
  10587. private _deltaTime;
  10588. /**
  10589. * Turn this value on if you want to pause FPS computation when in background
  10590. */
  10591. disablePerformanceMonitorInBackground: boolean;
  10592. /**
  10593. * Gets the performance monitor attached to this engine
  10594. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10595. */
  10596. readonly performanceMonitor: PerformanceMonitor;
  10597. /** @hidden */
  10598. protected _depthCullingState: _DepthCullingState;
  10599. /** @hidden */
  10600. protected _stencilState: _StencilState;
  10601. /** @hidden */
  10602. protected _alphaState: _AlphaState;
  10603. /** @hidden */
  10604. protected _alphaMode: number;
  10605. protected _internalTexturesCache: InternalTexture[];
  10606. /** @hidden */
  10607. protected _activeChannel: number;
  10608. private _currentTextureChannel;
  10609. /** @hidden */
  10610. protected _boundTexturesCache: {
  10611. [key: string]: Nullable<InternalTexture>;
  10612. };
  10613. /** @hidden */
  10614. protected _currentEffect: Nullable<Effect>;
  10615. /** @hidden */
  10616. protected _currentProgram: Nullable<WebGLProgram>;
  10617. private _compiledEffects;
  10618. private _vertexAttribArraysEnabled;
  10619. /** @hidden */
  10620. protected _cachedViewport: Nullable<Viewport>;
  10621. private _cachedVertexArrayObject;
  10622. /** @hidden */
  10623. protected _cachedVertexBuffers: any;
  10624. /** @hidden */
  10625. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10626. /** @hidden */
  10627. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10628. /** @hidden */
  10629. protected _currentRenderTarget: Nullable<InternalTexture>;
  10630. private _uintIndicesCurrentlySet;
  10631. private _currentBoundBuffer;
  10632. /** @hidden */
  10633. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10634. private _currentBufferPointers;
  10635. private _currentInstanceLocations;
  10636. private _currentInstanceBuffers;
  10637. private _textureUnits;
  10638. private _firstBoundInternalTextureTracker;
  10639. private _lastBoundInternalTextureTracker;
  10640. private _workingCanvas;
  10641. private _workingContext;
  10642. private _rescalePostProcess;
  10643. private _dummyFramebuffer;
  10644. private _externalData;
  10645. private _bindedRenderFunction;
  10646. private _vaoRecordInProgress;
  10647. private _mustWipeVertexAttributes;
  10648. private _emptyTexture;
  10649. private _emptyCubeTexture;
  10650. private _emptyTexture3D;
  10651. /** @hidden */
  10652. _frameHandler: number;
  10653. private _nextFreeTextureSlots;
  10654. private _maxSimultaneousTextures;
  10655. private _activeRequests;
  10656. private _texturesSupported;
  10657. private _textureFormatInUse;
  10658. /**
  10659. * Gets the list of texture formats supported
  10660. */
  10661. readonly texturesSupported: Array<string>;
  10662. /**
  10663. * Gets the list of texture formats in use
  10664. */
  10665. readonly textureFormatInUse: Nullable<string>;
  10666. /**
  10667. * Gets the current viewport
  10668. */
  10669. readonly currentViewport: Nullable<Viewport>;
  10670. /**
  10671. * Gets the default empty texture
  10672. */
  10673. readonly emptyTexture: InternalTexture;
  10674. /**
  10675. * Gets the default empty 3D texture
  10676. */
  10677. readonly emptyTexture3D: InternalTexture;
  10678. /**
  10679. * Gets the default empty cube texture
  10680. */
  10681. readonly emptyCubeTexture: InternalTexture;
  10682. /**
  10683. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10684. */
  10685. readonly premultipliedAlpha: boolean;
  10686. /**
  10687. * Creates a new engine
  10688. * @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
  10689. * @param antialias defines enable antialiasing (default: false)
  10690. * @param options defines further options to be sent to the getContext() function
  10691. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10692. */
  10693. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10694. private _rebuildInternalTextures;
  10695. private _rebuildEffects;
  10696. /**
  10697. * Gets a boolean indicating if all created effects are ready
  10698. * @returns true if all effects are ready
  10699. */
  10700. areAllEffectsReady(): boolean;
  10701. private _rebuildBuffers;
  10702. private _initGLContext;
  10703. /**
  10704. * Gets version of the current webGL context
  10705. */
  10706. readonly webGLVersion: number;
  10707. /**
  10708. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10709. */
  10710. readonly isStencilEnable: boolean;
  10711. private _prepareWorkingCanvas;
  10712. /**
  10713. * Reset the texture cache to empty state
  10714. */
  10715. resetTextureCache(): void;
  10716. /**
  10717. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10718. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10719. * @returns true if engine is in deterministic lock step mode
  10720. */
  10721. isDeterministicLockStep(): boolean;
  10722. /**
  10723. * Gets the max steps when engine is running in deterministic lock step
  10724. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10725. * @returns the max steps
  10726. */
  10727. getLockstepMaxSteps(): number;
  10728. /**
  10729. * Gets an object containing information about the current webGL context
  10730. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10731. */
  10732. getGlInfo(): {
  10733. vendor: string;
  10734. renderer: string;
  10735. version: string;
  10736. };
  10737. /**
  10738. * Gets current aspect ratio
  10739. * @param camera defines the camera to use to get the aspect ratio
  10740. * @param useScreen defines if screen size must be used (or the current render target if any)
  10741. * @returns a number defining the aspect ratio
  10742. */
  10743. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10744. /**
  10745. * Gets current screen aspect ratio
  10746. * @returns a number defining the aspect ratio
  10747. */
  10748. getScreenAspectRatio(): number;
  10749. /**
  10750. * Gets the current render width
  10751. * @param useScreen defines if screen size must be used (or the current render target if any)
  10752. * @returns a number defining the current render width
  10753. */
  10754. getRenderWidth(useScreen?: boolean): number;
  10755. /**
  10756. * Gets the current render height
  10757. * @param useScreen defines if screen size must be used (or the current render target if any)
  10758. * @returns a number defining the current render height
  10759. */
  10760. getRenderHeight(useScreen?: boolean): number;
  10761. /**
  10762. * Gets the HTML canvas attached with the current webGL context
  10763. * @returns a HTML canvas
  10764. */
  10765. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10766. /**
  10767. * Gets the client rect of the HTML canvas attached with the current webGL context
  10768. * @returns a client rectanglee
  10769. */
  10770. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10771. /**
  10772. * Defines the hardware scaling level.
  10773. * By default the hardware scaling level is computed from the window device ratio.
  10774. * 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.
  10775. * @param level defines the level to use
  10776. */
  10777. setHardwareScalingLevel(level: number): void;
  10778. /**
  10779. * Gets the current hardware scaling level.
  10780. * By default the hardware scaling level is computed from the window device ratio.
  10781. * 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.
  10782. * @returns a number indicating the current hardware scaling level
  10783. */
  10784. getHardwareScalingLevel(): number;
  10785. /**
  10786. * Gets the list of loaded textures
  10787. * @returns an array containing all loaded textures
  10788. */
  10789. getLoadedTexturesCache(): InternalTexture[];
  10790. /**
  10791. * Gets the object containing all engine capabilities
  10792. * @returns the EngineCapabilities object
  10793. */
  10794. getCaps(): EngineCapabilities;
  10795. /**
  10796. * Gets the current depth function
  10797. * @returns a number defining the depth function
  10798. */
  10799. getDepthFunction(): Nullable<number>;
  10800. /**
  10801. * Sets the current depth function
  10802. * @param depthFunc defines the function to use
  10803. */
  10804. setDepthFunction(depthFunc: number): void;
  10805. /**
  10806. * Sets the current depth function to GREATER
  10807. */
  10808. setDepthFunctionToGreater(): void;
  10809. /**
  10810. * Sets the current depth function to GEQUAL
  10811. */
  10812. setDepthFunctionToGreaterOrEqual(): void;
  10813. /**
  10814. * Sets the current depth function to LESS
  10815. */
  10816. setDepthFunctionToLess(): void;
  10817. /**
  10818. * Sets the current depth function to LEQUAL
  10819. */
  10820. setDepthFunctionToLessOrEqual(): void;
  10821. /**
  10822. * Gets a boolean indicating if stencil buffer is enabled
  10823. * @returns the current stencil buffer state
  10824. */
  10825. getStencilBuffer(): boolean;
  10826. /**
  10827. * Enable or disable the stencil buffer
  10828. * @param enable defines if the stencil buffer must be enabled or disabled
  10829. */
  10830. setStencilBuffer(enable: boolean): void;
  10831. /**
  10832. * Gets the current stencil mask
  10833. * @returns a number defining the new stencil mask to use
  10834. */
  10835. getStencilMask(): number;
  10836. /**
  10837. * Sets the current stencil mask
  10838. * @param mask defines the new stencil mask to use
  10839. */
  10840. setStencilMask(mask: number): void;
  10841. /**
  10842. * Gets the current stencil function
  10843. * @returns a number defining the stencil function to use
  10844. */
  10845. getStencilFunction(): number;
  10846. /**
  10847. * Gets the current stencil reference value
  10848. * @returns a number defining the stencil reference value to use
  10849. */
  10850. getStencilFunctionReference(): number;
  10851. /**
  10852. * Gets the current stencil mask
  10853. * @returns a number defining the stencil mask to use
  10854. */
  10855. getStencilFunctionMask(): number;
  10856. /**
  10857. * Sets the current stencil function
  10858. * @param stencilFunc defines the new stencil function to use
  10859. */
  10860. setStencilFunction(stencilFunc: number): void;
  10861. /**
  10862. * Sets the current stencil reference
  10863. * @param reference defines the new stencil reference to use
  10864. */
  10865. setStencilFunctionReference(reference: number): void;
  10866. /**
  10867. * Sets the current stencil mask
  10868. * @param mask defines the new stencil mask to use
  10869. */
  10870. setStencilFunctionMask(mask: number): void;
  10871. /**
  10872. * Gets the current stencil operation when stencil fails
  10873. * @returns a number defining stencil operation to use when stencil fails
  10874. */
  10875. getStencilOperationFail(): number;
  10876. /**
  10877. * Gets the current stencil operation when depth fails
  10878. * @returns a number defining stencil operation to use when depth fails
  10879. */
  10880. getStencilOperationDepthFail(): number;
  10881. /**
  10882. * Gets the current stencil operation when stencil passes
  10883. * @returns a number defining stencil operation to use when stencil passes
  10884. */
  10885. getStencilOperationPass(): number;
  10886. /**
  10887. * Sets the stencil operation to use when stencil fails
  10888. * @param operation defines the stencil operation to use when stencil fails
  10889. */
  10890. setStencilOperationFail(operation: number): void;
  10891. /**
  10892. * Sets the stencil operation to use when depth fails
  10893. * @param operation defines the stencil operation to use when depth fails
  10894. */
  10895. setStencilOperationDepthFail(operation: number): void;
  10896. /**
  10897. * Sets the stencil operation to use when stencil passes
  10898. * @param operation defines the stencil operation to use when stencil passes
  10899. */
  10900. setStencilOperationPass(operation: number): void;
  10901. /**
  10902. * Sets a boolean indicating if the dithering state is enabled or disabled
  10903. * @param value defines the dithering state
  10904. */
  10905. setDitheringState(value: boolean): void;
  10906. /**
  10907. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10908. * @param value defines the rasterizer state
  10909. */
  10910. setRasterizerState(value: boolean): void;
  10911. /**
  10912. * stop executing a render loop function and remove it from the execution array
  10913. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10914. */
  10915. stopRenderLoop(renderFunction?: () => void): void;
  10916. /** @hidden */
  10917. _renderLoop(): void;
  10918. /**
  10919. * Register and execute a render loop. The engine can have more than one render function
  10920. * @param renderFunction defines the function to continuously execute
  10921. */
  10922. runRenderLoop(renderFunction: () => void): void;
  10923. /**
  10924. * Toggle full screen mode
  10925. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10926. */
  10927. switchFullscreen(requestPointerLock: boolean): void;
  10928. /**
  10929. * Clear the current render buffer or the current render target (if any is set up)
  10930. * @param color defines the color to use
  10931. * @param backBuffer defines if the back buffer must be cleared
  10932. * @param depth defines if the depth buffer must be cleared
  10933. * @param stencil defines if the stencil buffer must be cleared
  10934. */
  10935. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10936. /**
  10937. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10938. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10939. * @param y defines the y-coordinate of the corner of the clear rectangle
  10940. * @param width defines the width of the clear rectangle
  10941. * @param height defines the height of the clear rectangle
  10942. * @param clearColor defines the clear color
  10943. */
  10944. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10945. private _viewportCached;
  10946. /** @hidden */
  10947. _viewport(x: number, y: number, width: number, height: number): void;
  10948. /**
  10949. * Set the WebGL's viewport
  10950. * @param viewport defines the viewport element to be used
  10951. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10952. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10953. */
  10954. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10955. /**
  10956. * Directly set the WebGL Viewport
  10957. * @param x defines the x coordinate of the viewport (in screen space)
  10958. * @param y defines the y coordinate of the viewport (in screen space)
  10959. * @param width defines the width of the viewport (in screen space)
  10960. * @param height defines the height of the viewport (in screen space)
  10961. * @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
  10962. */
  10963. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10964. /**
  10965. * Begin a new frame
  10966. */
  10967. beginFrame(): void;
  10968. /**
  10969. * Enf the current frame
  10970. */
  10971. endFrame(): void;
  10972. /**
  10973. * Resize the view according to the canvas' size
  10974. */
  10975. resize(): void;
  10976. /**
  10977. * Force a specific size of the canvas
  10978. * @param width defines the new canvas' width
  10979. * @param height defines the new canvas' height
  10980. */
  10981. setSize(width: number, height: number): void;
  10982. /**
  10983. * Gets a boolean indicating if a webVR device was detected
  10984. * @returns true if a webVR device was detected
  10985. */
  10986. isVRDevicePresent(): boolean;
  10987. /**
  10988. * Gets the current webVR device
  10989. * @returns the current webVR device (or null)
  10990. */
  10991. getVRDevice(): any;
  10992. /**
  10993. * Initializes a webVR display and starts listening to display change events
  10994. * The onVRDisplayChangedObservable will be notified upon these changes
  10995. * @returns The onVRDisplayChangedObservable
  10996. */
  10997. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10998. /**
  10999. * Initializes a webVR display and starts listening to display change events
  11000. * The onVRDisplayChangedObservable will be notified upon these changes
  11001. * @returns A promise containing a VRDisplay and if vr is supported
  11002. */
  11003. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  11004. /**
  11005. * Call this function to switch to webVR mode
  11006. * Will do nothing if webVR is not supported or if there is no webVR device
  11007. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11008. */
  11009. enableVR(): void;
  11010. /**
  11011. * Call this function to leave webVR mode
  11012. * Will do nothing if webVR is not supported or if there is no webVR device
  11013. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11014. */
  11015. disableVR(): void;
  11016. private _onVRFullScreenTriggered;
  11017. private _getVRDisplaysAsync;
  11018. /**
  11019. * Binds the frame buffer to the specified texture.
  11020. * @param texture The texture to render to or null for the default canvas
  11021. * @param faceIndex The face of the texture to render to in case of cube texture
  11022. * @param requiredWidth The width of the target to render to
  11023. * @param requiredHeight The height of the target to render to
  11024. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  11025. * @param depthStencilTexture The depth stencil texture to use to render
  11026. * @param lodLevel defines le lod level to bind to the frame buffer
  11027. */
  11028. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  11029. private bindUnboundFramebuffer;
  11030. /**
  11031. * Unbind the current render target texture from the webGL context
  11032. * @param texture defines the render target texture to unbind
  11033. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11034. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11035. */
  11036. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11037. /**
  11038. * Unbind a list of render target textures from the webGL context
  11039. * This is used only when drawBuffer extension or webGL2 are active
  11040. * @param textures defines the render target textures to unbind
  11041. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11042. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11043. */
  11044. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11045. /**
  11046. * Force the mipmap generation for the given render target texture
  11047. * @param texture defines the render target texture to use
  11048. */
  11049. generateMipMapsForCubemap(texture: InternalTexture): void;
  11050. /**
  11051. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  11052. */
  11053. flushFramebuffer(): void;
  11054. /**
  11055. * Unbind the current render target and bind the default framebuffer
  11056. */
  11057. restoreDefaultFramebuffer(): void;
  11058. /**
  11059. * Create an uniform buffer
  11060. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11061. * @param elements defines the content of the uniform buffer
  11062. * @returns the webGL uniform buffer
  11063. */
  11064. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  11065. /**
  11066. * Create a dynamic uniform buffer
  11067. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11068. * @param elements defines the content of the uniform buffer
  11069. * @returns the webGL uniform buffer
  11070. */
  11071. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  11072. /**
  11073. * Update an existing uniform buffer
  11074. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11075. * @param uniformBuffer defines the target uniform buffer
  11076. * @param elements defines the content to update
  11077. * @param offset defines the offset in the uniform buffer where update should start
  11078. * @param count defines the size of the data to update
  11079. */
  11080. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  11081. private _resetVertexBufferBinding;
  11082. /**
  11083. * Creates a vertex buffer
  11084. * @param data the data for the vertex buffer
  11085. * @returns the new WebGL static buffer
  11086. */
  11087. createVertexBuffer(data: DataArray): WebGLBuffer;
  11088. /**
  11089. * Creates a dynamic vertex buffer
  11090. * @param data the data for the dynamic vertex buffer
  11091. * @returns the new WebGL dynamic buffer
  11092. */
  11093. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  11094. /**
  11095. * Update a dynamic index buffer
  11096. * @param indexBuffer defines the target index buffer
  11097. * @param indices defines the data to update
  11098. * @param offset defines the offset in the target index buffer where update should start
  11099. */
  11100. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11101. /**
  11102. * Updates a dynamic vertex buffer.
  11103. * @param vertexBuffer the vertex buffer to update
  11104. * @param data the data used to update the vertex buffer
  11105. * @param byteOffset the byte offset of the data
  11106. * @param byteLength the byte length of the data
  11107. */
  11108. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11109. private _resetIndexBufferBinding;
  11110. /**
  11111. * Creates a new index buffer
  11112. * @param indices defines the content of the index buffer
  11113. * @param updatable defines if the index buffer must be updatable
  11114. * @returns a new webGL buffer
  11115. */
  11116. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  11117. /**
  11118. * Bind a webGL buffer to the webGL context
  11119. * @param buffer defines the buffer to bind
  11120. */
  11121. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  11122. /**
  11123. * Bind an uniform buffer to the current webGL context
  11124. * @param buffer defines the buffer to bind
  11125. */
  11126. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  11127. /**
  11128. * Bind a buffer to the current webGL context at a given location
  11129. * @param buffer defines the buffer to bind
  11130. * @param location defines the index where to bind the buffer
  11131. */
  11132. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  11133. /**
  11134. * Bind a specific block at a given index in a specific shader program
  11135. * @param shaderProgram defines the shader program
  11136. * @param blockName defines the block name
  11137. * @param index defines the index where to bind the block
  11138. */
  11139. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  11140. private bindIndexBuffer;
  11141. private bindBuffer;
  11142. /**
  11143. * update the bound buffer with the given data
  11144. * @param data defines the data to update
  11145. */
  11146. updateArrayBuffer(data: Float32Array): void;
  11147. private _vertexAttribPointer;
  11148. private _bindIndexBufferWithCache;
  11149. private _bindVertexBuffersAttributes;
  11150. /**
  11151. * Records a vertex array object
  11152. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11153. * @param vertexBuffers defines the list of vertex buffers to store
  11154. * @param indexBuffer defines the index buffer to store
  11155. * @param effect defines the effect to store
  11156. * @returns the new vertex array object
  11157. */
  11158. recordVertexArrayObject(vertexBuffers: {
  11159. [key: string]: VertexBuffer;
  11160. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  11161. /**
  11162. * Bind a specific vertex array object
  11163. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11164. * @param vertexArrayObject defines the vertex array object to bind
  11165. * @param indexBuffer defines the index buffer to bind
  11166. */
  11167. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11168. /**
  11169. * Bind webGl buffers directly to the webGL context
  11170. * @param vertexBuffer defines the vertex buffer to bind
  11171. * @param indexBuffer defines the index buffer to bind
  11172. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11173. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11174. * @param effect defines the effect associated with the vertex buffer
  11175. */
  11176. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11177. private _unbindVertexArrayObject;
  11178. /**
  11179. * Bind a list of vertex buffers to the webGL context
  11180. * @param vertexBuffers defines the list of vertex buffers to bind
  11181. * @param indexBuffer defines the index buffer to bind
  11182. * @param effect defines the effect associated with the vertex buffers
  11183. */
  11184. bindBuffers(vertexBuffers: {
  11185. [key: string]: Nullable<VertexBuffer>;
  11186. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11187. /**
  11188. * Unbind all instance attributes
  11189. */
  11190. unbindInstanceAttributes(): void;
  11191. /**
  11192. * Release and free the memory of a vertex array object
  11193. * @param vao defines the vertex array object to delete
  11194. */
  11195. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11196. /** @hidden */
  11197. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11198. /**
  11199. * Creates a webGL buffer to use with instanciation
  11200. * @param capacity defines the size of the buffer
  11201. * @returns the webGL buffer
  11202. */
  11203. createInstancesBuffer(capacity: number): WebGLBuffer;
  11204. /**
  11205. * Delete a webGL buffer used with instanciation
  11206. * @param buffer defines the webGL buffer to delete
  11207. */
  11208. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11209. /**
  11210. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11211. * @param instancesBuffer defines the webGL buffer to update and bind
  11212. * @param data defines the data to store in the buffer
  11213. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11214. */
  11215. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11216. /**
  11217. * Apply all cached states (depth, culling, stencil and alpha)
  11218. */
  11219. applyStates(): void;
  11220. /**
  11221. * Send a draw order
  11222. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11223. * @param indexStart defines the starting index
  11224. * @param indexCount defines the number of index to draw
  11225. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11226. */
  11227. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11228. /**
  11229. * Draw a list of points
  11230. * @param verticesStart defines the index of first vertex to draw
  11231. * @param verticesCount defines the count of vertices to draw
  11232. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11233. */
  11234. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11235. /**
  11236. * Draw a list of unindexed primitives
  11237. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11238. * @param verticesStart defines the index of first vertex to draw
  11239. * @param verticesCount defines the count of vertices to draw
  11240. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11241. */
  11242. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11243. /**
  11244. * Draw a list of indexed primitives
  11245. * @param fillMode defines the primitive to use
  11246. * @param indexStart defines the starting index
  11247. * @param indexCount defines the number of index to draw
  11248. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11249. */
  11250. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11251. /**
  11252. * Draw a list of unindexed primitives
  11253. * @param fillMode defines the primitive to use
  11254. * @param verticesStart defines the index of first vertex to draw
  11255. * @param verticesCount defines the count of vertices to draw
  11256. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11257. */
  11258. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11259. private _drawMode;
  11260. /** @hidden */
  11261. _releaseEffect(effect: Effect): void;
  11262. /** @hidden */
  11263. _deleteProgram(program: WebGLProgram): void;
  11264. /**
  11265. * Create a new effect (used to store vertex/fragment shaders)
  11266. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11267. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11268. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11269. * @param samplers defines an array of string used to represent textures
  11270. * @param defines defines the string containing the defines to use to compile the shaders
  11271. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11272. * @param onCompiled defines a function to call when the effect creation is successful
  11273. * @param onError defines a function to call when the effect creation has failed
  11274. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11275. * @returns the new Effect
  11276. */
  11277. 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;
  11278. private _compileShader;
  11279. private _compileRawShader;
  11280. /**
  11281. * Directly creates a webGL program
  11282. * @param vertexCode defines the vertex shader code to use
  11283. * @param fragmentCode defines the fragment shader code to use
  11284. * @param context defines the webGL context to use (if not set, the current one will be used)
  11285. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11286. * @returns the new webGL program
  11287. */
  11288. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11289. /**
  11290. * Creates a webGL program
  11291. * @param vertexCode defines the vertex shader code to use
  11292. * @param fragmentCode defines the fragment shader code to use
  11293. * @param defines defines the string containing the defines to use to compile the shaders
  11294. * @param context defines the webGL context to use (if not set, the current one will be used)
  11295. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11296. * @returns the new webGL program
  11297. */
  11298. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11299. private _createShaderProgram;
  11300. private _finalizeProgram;
  11301. /** @hidden */
  11302. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11303. /** @hidden */
  11304. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11305. /**
  11306. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11307. * @param shaderProgram defines the webGL program to use
  11308. * @param uniformsNames defines the list of uniform names
  11309. * @returns an array of webGL uniform locations
  11310. */
  11311. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11312. /**
  11313. * Gets the lsit of active attributes for a given webGL program
  11314. * @param shaderProgram defines the webGL program to use
  11315. * @param attributesNames defines the list of attribute names to get
  11316. * @returns an array of indices indicating the offset of each attribute
  11317. */
  11318. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11319. /**
  11320. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11321. * @param effect defines the effect to activate
  11322. */
  11323. enableEffect(effect: Nullable<Effect>): void;
  11324. /**
  11325. * Set the value of an uniform to an array of int32
  11326. * @param uniform defines the webGL uniform location where to store the value
  11327. * @param array defines the array of int32 to store
  11328. */
  11329. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11330. /**
  11331. * Set the value of an uniform to an array of int32 (stored as vec2)
  11332. * @param uniform defines the webGL uniform location where to store the value
  11333. * @param array defines the array of int32 to store
  11334. */
  11335. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11336. /**
  11337. * Set the value of an uniform to an array of int32 (stored as vec3)
  11338. * @param uniform defines the webGL uniform location where to store the value
  11339. * @param array defines the array of int32 to store
  11340. */
  11341. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11342. /**
  11343. * Set the value of an uniform to an array of int32 (stored as vec4)
  11344. * @param uniform defines the webGL uniform location where to store the value
  11345. * @param array defines the array of int32 to store
  11346. */
  11347. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11348. /**
  11349. * Set the value of an uniform to an array of float32
  11350. * @param uniform defines the webGL uniform location where to store the value
  11351. * @param array defines the array of float32 to store
  11352. */
  11353. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11354. /**
  11355. * Set the value of an uniform to an array of float32 (stored as vec2)
  11356. * @param uniform defines the webGL uniform location where to store the value
  11357. * @param array defines the array of float32 to store
  11358. */
  11359. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11360. /**
  11361. * Set the value of an uniform to an array of float32 (stored as vec3)
  11362. * @param uniform defines the webGL uniform location where to store the value
  11363. * @param array defines the array of float32 to store
  11364. */
  11365. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11366. /**
  11367. * Set the value of an uniform to an array of float32 (stored as vec4)
  11368. * @param uniform defines the webGL uniform location where to store the value
  11369. * @param array defines the array of float32 to store
  11370. */
  11371. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11372. /**
  11373. * Set the value of an uniform to an array of number
  11374. * @param uniform defines the webGL uniform location where to store the value
  11375. * @param array defines the array of number to store
  11376. */
  11377. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11378. /**
  11379. * Set the value of an uniform to an array of number (stored as vec2)
  11380. * @param uniform defines the webGL uniform location where to store the value
  11381. * @param array defines the array of number to store
  11382. */
  11383. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11384. /**
  11385. * Set the value of an uniform to an array of number (stored as vec3)
  11386. * @param uniform defines the webGL uniform location where to store the value
  11387. * @param array defines the array of number to store
  11388. */
  11389. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11390. /**
  11391. * Set the value of an uniform to an array of number (stored as vec4)
  11392. * @param uniform defines the webGL uniform location where to store the value
  11393. * @param array defines the array of number to store
  11394. */
  11395. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11396. /**
  11397. * Set the value of an uniform to an array of float32 (stored as matrices)
  11398. * @param uniform defines the webGL uniform location where to store the value
  11399. * @param matrices defines the array of float32 to store
  11400. */
  11401. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11402. /**
  11403. * Set the value of an uniform to a matrix
  11404. * @param uniform defines the webGL uniform location where to store the value
  11405. * @param matrix defines the matrix to store
  11406. */
  11407. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11408. /**
  11409. * Set the value of an uniform to a matrix (3x3)
  11410. * @param uniform defines the webGL uniform location where to store the value
  11411. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11412. */
  11413. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11414. /**
  11415. * Set the value of an uniform to a matrix (2x2)
  11416. * @param uniform defines the webGL uniform location where to store the value
  11417. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11418. */
  11419. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11420. /**
  11421. * Set the value of an uniform to a number (int)
  11422. * @param uniform defines the webGL uniform location where to store the value
  11423. * @param value defines the int number to store
  11424. */
  11425. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11426. /**
  11427. * Set the value of an uniform to a number (float)
  11428. * @param uniform defines the webGL uniform location where to store the value
  11429. * @param value defines the float number to store
  11430. */
  11431. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11432. /**
  11433. * Set the value of an uniform to a vec2
  11434. * @param uniform defines the webGL uniform location where to store the value
  11435. * @param x defines the 1st component of the value
  11436. * @param y defines the 2nd component of the value
  11437. */
  11438. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11439. /**
  11440. * Set the value of an uniform to a vec3
  11441. * @param uniform defines the webGL uniform location where to store the value
  11442. * @param x defines the 1st component of the value
  11443. * @param y defines the 2nd component of the value
  11444. * @param z defines the 3rd component of the value
  11445. */
  11446. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11447. /**
  11448. * Set the value of an uniform to a boolean
  11449. * @param uniform defines the webGL uniform location where to store the value
  11450. * @param bool defines the boolean to store
  11451. */
  11452. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11453. /**
  11454. * Set the value of an uniform to a vec4
  11455. * @param uniform defines the webGL uniform location where to store the value
  11456. * @param x defines the 1st component of the value
  11457. * @param y defines the 2nd component of the value
  11458. * @param z defines the 3rd component of the value
  11459. * @param w defines the 4th component of the value
  11460. */
  11461. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11462. /**
  11463. * Set the value of an uniform to a Color3
  11464. * @param uniform defines the webGL uniform location where to store the value
  11465. * @param color3 defines the color to store
  11466. */
  11467. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11468. /**
  11469. * Set the value of an uniform to a Color3 and an alpha value
  11470. * @param uniform defines the webGL uniform location where to store the value
  11471. * @param color3 defines the color to store
  11472. * @param alpha defines the alpha component to store
  11473. */
  11474. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11475. /**
  11476. * Sets a Color4 on a uniform variable
  11477. * @param uniform defines the uniform location
  11478. * @param color4 defines the value to be set
  11479. */
  11480. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11481. /**
  11482. * Set various states to the webGL context
  11483. * @param culling defines backface culling state
  11484. * @param zOffset defines the value to apply to zOffset (0 by default)
  11485. * @param force defines if states must be applied even if cache is up to date
  11486. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11487. */
  11488. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11489. /**
  11490. * Set the z offset to apply to current rendering
  11491. * @param value defines the offset to apply
  11492. */
  11493. setZOffset(value: number): void;
  11494. /**
  11495. * Gets the current value of the zOffset
  11496. * @returns the current zOffset state
  11497. */
  11498. getZOffset(): number;
  11499. /**
  11500. * Enable or disable depth buffering
  11501. * @param enable defines the state to set
  11502. */
  11503. setDepthBuffer(enable: boolean): void;
  11504. /**
  11505. * Gets a boolean indicating if depth writing is enabled
  11506. * @returns the current depth writing state
  11507. */
  11508. getDepthWrite(): boolean;
  11509. /**
  11510. * Enable or disable depth writing
  11511. * @param enable defines the state to set
  11512. */
  11513. setDepthWrite(enable: boolean): void;
  11514. /**
  11515. * Enable or disable color writing
  11516. * @param enable defines the state to set
  11517. */
  11518. setColorWrite(enable: boolean): void;
  11519. /**
  11520. * Gets a boolean indicating if color writing is enabled
  11521. * @returns the current color writing state
  11522. */
  11523. getColorWrite(): boolean;
  11524. /**
  11525. * Sets alpha constants used by some alpha blending modes
  11526. * @param r defines the red component
  11527. * @param g defines the green component
  11528. * @param b defines the blue component
  11529. * @param a defines the alpha component
  11530. */
  11531. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11532. /**
  11533. * Sets the current alpha mode
  11534. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11535. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11536. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11537. */
  11538. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11539. /**
  11540. * Gets the current alpha mode
  11541. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11542. * @returns the current alpha mode
  11543. */
  11544. getAlphaMode(): number;
  11545. /**
  11546. * Clears the list of texture accessible through engine.
  11547. * This can help preventing texture load conflict due to name collision.
  11548. */
  11549. clearInternalTexturesCache(): void;
  11550. /**
  11551. * Force the entire cache to be cleared
  11552. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11553. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11554. */
  11555. wipeCaches(bruteForce?: boolean): void;
  11556. /**
  11557. * Set the compressed texture format to use, based on the formats you have, and the formats
  11558. * supported by the hardware / browser.
  11559. *
  11560. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11561. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11562. * to API arguments needed to compressed textures. This puts the burden on the container
  11563. * generator to house the arcane code for determining these for current & future formats.
  11564. *
  11565. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11566. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11567. *
  11568. * Note: The result of this call is not taken into account when a texture is base64.
  11569. *
  11570. * @param formatsAvailable defines the list of those format families you have created
  11571. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11572. *
  11573. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11574. * @returns The extension selected.
  11575. */
  11576. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11577. private _getSamplingParameters;
  11578. private _partialLoadImg;
  11579. private _cascadeLoadImgs;
  11580. /** @hidden */
  11581. _createTexture(): WebGLTexture;
  11582. /**
  11583. * Usually called from BABYLON.Texture.ts.
  11584. * Passed information to create a WebGLTexture
  11585. * @param urlArg defines a value which contains one of the following:
  11586. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11587. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11588. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11589. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11590. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  11591. * @param scene needed for loading to the correct scene
  11592. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11593. * @param onLoad optional callback to be called upon successful completion
  11594. * @param onError optional callback to be called upon failure
  11595. * @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
  11596. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11597. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11598. * @param forcedExtension defines the extension to use to pick the right loader
  11599. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  11600. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11601. */
  11602. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  11603. private _rescaleTexture;
  11604. /**
  11605. * Update a raw texture
  11606. * @param texture defines the texture to update
  11607. * @param data defines the data to store in the texture
  11608. * @param format defines the format of the data
  11609. * @param invertY defines if data must be stored with Y axis inverted
  11610. * @param compression defines the compression used (null by default)
  11611. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11612. */
  11613. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11614. /**
  11615. * Creates a raw texture
  11616. * @param data defines the data to store in the texture
  11617. * @param width defines the width of the texture
  11618. * @param height defines the height of the texture
  11619. * @param format defines the format of the data
  11620. * @param generateMipMaps defines if the engine should generate the mip levels
  11621. * @param invertY defines if data must be stored with Y axis inverted
  11622. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11623. * @param compression defines the compression used (null by default)
  11624. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11625. * @returns the raw texture inside an InternalTexture
  11626. */
  11627. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11628. private _unpackFlipYCached;
  11629. /**
  11630. * In case you are sharing the context with other applications, it might
  11631. * be interested to not cache the unpack flip y state to ensure a consistent
  11632. * value would be set.
  11633. */
  11634. enableUnpackFlipYCached: boolean;
  11635. /** @hidden */
  11636. _unpackFlipY(value: boolean): void;
  11637. /** @hidden */
  11638. _getUnpackAlignement(): number;
  11639. /**
  11640. * Creates a dynamic texture
  11641. * @param width defines the width of the texture
  11642. * @param height defines the height of the texture
  11643. * @param generateMipMaps defines if the engine should generate the mip levels
  11644. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11645. * @returns the dynamic texture inside an InternalTexture
  11646. */
  11647. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11648. /**
  11649. * Update the sampling mode of a given texture
  11650. * @param samplingMode defines the required sampling mode
  11651. * @param texture defines the texture to update
  11652. */
  11653. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11654. /**
  11655. * Update the content of a dynamic texture
  11656. * @param texture defines the texture to update
  11657. * @param canvas defines the canvas containing the source
  11658. * @param invertY defines if data must be stored with Y axis inverted
  11659. * @param premulAlpha defines if alpha is stored as premultiplied
  11660. * @param format defines the format of the data
  11661. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11662. */
  11663. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11664. /**
  11665. * Update a video texture
  11666. * @param texture defines the texture to update
  11667. * @param video defines the video element to use
  11668. * @param invertY defines if data must be stored with Y axis inverted
  11669. */
  11670. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11671. /**
  11672. * Updates a depth texture Comparison Mode and Function.
  11673. * If the comparison Function is equal to 0, the mode will be set to none.
  11674. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11675. * @param texture The texture to set the comparison function for
  11676. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11677. */
  11678. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11679. private _setupDepthStencilTexture;
  11680. /**
  11681. * Creates a depth stencil texture.
  11682. * This is only available in WebGL 2 or with the depth texture extension available.
  11683. * @param size The size of face edge in the texture.
  11684. * @param options The options defining the texture.
  11685. * @returns The texture
  11686. */
  11687. createDepthStencilTexture(size: number | {
  11688. width: number;
  11689. height: number;
  11690. }, options: DepthTextureCreationOptions): InternalTexture;
  11691. /**
  11692. * Creates a depth stencil texture.
  11693. * This is only available in WebGL 2 or with the depth texture extension available.
  11694. * @param size The size of face edge in the texture.
  11695. * @param options The options defining the texture.
  11696. * @returns The texture
  11697. */
  11698. private _createDepthStencilTexture;
  11699. /**
  11700. * Creates a depth stencil cube texture.
  11701. * This is only available in WebGL 2.
  11702. * @param size The size of face edge in the cube texture.
  11703. * @param options The options defining the cube texture.
  11704. * @returns The cube texture
  11705. */
  11706. private _createDepthStencilCubeTexture;
  11707. /**
  11708. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11709. * @param renderTarget The render target to set the frame buffer for
  11710. */
  11711. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11712. /**
  11713. * Creates a new render target texture
  11714. * @param size defines the size of the texture
  11715. * @param options defines the options used to create the texture
  11716. * @returns a new render target texture stored in an InternalTexture
  11717. */
  11718. createRenderTargetTexture(size: number | {
  11719. width: number;
  11720. height: number;
  11721. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11722. /**
  11723. * Create a multi render target texture
  11724. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11725. * @param size defines the size of the texture
  11726. * @param options defines the creation options
  11727. * @returns the cube texture as an InternalTexture
  11728. */
  11729. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11730. private _setupFramebufferDepthAttachments;
  11731. /**
  11732. * Updates the sample count of a render target texture
  11733. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11734. * @param texture defines the texture to update
  11735. * @param samples defines the sample count to set
  11736. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11737. */
  11738. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11739. /**
  11740. * Update the sample count for a given multiple render target texture
  11741. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11742. * @param textures defines the textures to update
  11743. * @param samples defines the sample count to set
  11744. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11745. */
  11746. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11747. /** @hidden */
  11748. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11749. /** @hidden */
  11750. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11751. /** @hidden */
  11752. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11753. /** @hidden */
  11754. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11755. /**
  11756. * Creates a new render target cube texture
  11757. * @param size defines the size of the texture
  11758. * @param options defines the options used to create the texture
  11759. * @returns a new render target cube texture stored in an InternalTexture
  11760. */
  11761. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11762. /**
  11763. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11764. * @param rootUrl defines the url where the file to load is located
  11765. * @param scene defines the current scene
  11766. * @param lodScale defines scale to apply to the mip map selection
  11767. * @param lodOffset defines offset to apply to the mip map selection
  11768. * @param onLoad defines an optional callback raised when the texture is loaded
  11769. * @param onError defines an optional callback raised if there is an issue to load the texture
  11770. * @param format defines the format of the data
  11771. * @param forcedExtension defines the extension to use to pick the right loader
  11772. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11773. * @returns the cube texture as an InternalTexture
  11774. */
  11775. 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;
  11776. /**
  11777. * Creates a cube texture
  11778. * @param rootUrl defines the url where the files to load is located
  11779. * @param scene defines the current scene
  11780. * @param files defines the list of files to load (1 per face)
  11781. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11782. * @param onLoad defines an optional callback raised when the texture is loaded
  11783. * @param onError defines an optional callback raised if there is an issue to load the texture
  11784. * @param format defines the format of the data
  11785. * @param forcedExtension defines the extension to use to pick the right loader
  11786. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11787. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11788. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11789. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11790. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  11791. * @returns the cube texture as an InternalTexture
  11792. */
  11793. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  11794. /**
  11795. * @hidden
  11796. */
  11797. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11798. /**
  11799. * Update a raw cube texture
  11800. * @param texture defines the texture to udpdate
  11801. * @param data defines the data to store
  11802. * @param format defines the data format
  11803. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11804. * @param invertY defines if data must be stored with Y axis inverted
  11805. * @param compression defines the compression used (null by default)
  11806. * @param level defines which level of the texture to update
  11807. */
  11808. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11809. /**
  11810. * Creates a new raw cube texture
  11811. * @param data defines the array of data to use to create each face
  11812. * @param size defines the size of the textures
  11813. * @param format defines the format of the data
  11814. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11815. * @param generateMipMaps defines if the engine should generate the mip levels
  11816. * @param invertY defines if data must be stored with Y axis inverted
  11817. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11818. * @param compression defines the compression used (null by default)
  11819. * @returns the cube texture as an InternalTexture
  11820. */
  11821. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11822. /**
  11823. * Creates a new raw cube texture from a specified url
  11824. * @param url defines the url where the data is located
  11825. * @param scene defines the current scene
  11826. * @param size defines the size of the textures
  11827. * @param format defines the format of the data
  11828. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11829. * @param noMipmap defines if the engine should avoid generating the mip levels
  11830. * @param callback defines a callback used to extract texture data from loaded data
  11831. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11832. * @param onLoad defines a callback called when texture is loaded
  11833. * @param onError defines a callback called if there is an error
  11834. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11835. * @param invertY defines if data must be stored with Y axis inverted
  11836. * @returns the cube texture as an InternalTexture
  11837. */
  11838. 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;
  11839. /**
  11840. * Update a raw 3D texture
  11841. * @param texture defines the texture to update
  11842. * @param data defines the data to store
  11843. * @param format defines the data format
  11844. * @param invertY defines if data must be stored with Y axis inverted
  11845. * @param compression defines the used compression (can be null)
  11846. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11847. */
  11848. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11849. /**
  11850. * Creates a new raw 3D texture
  11851. * @param data defines the data used to create the texture
  11852. * @param width defines the width of the texture
  11853. * @param height defines the height of the texture
  11854. * @param depth defines the depth of the texture
  11855. * @param format defines the format of the texture
  11856. * @param generateMipMaps defines if the engine must generate mip levels
  11857. * @param invertY defines if data must be stored with Y axis inverted
  11858. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11859. * @param compression defines the compressed used (can be null)
  11860. * @param textureType defines the compressed used (can be null)
  11861. * @returns a new raw 3D texture (stored in an InternalTexture)
  11862. */
  11863. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11864. private _prepareWebGLTextureContinuation;
  11865. private _prepareWebGLTexture;
  11866. private _convertRGBtoRGBATextureData;
  11867. /** @hidden */
  11868. _releaseFramebufferObjects(texture: InternalTexture): void;
  11869. /** @hidden */
  11870. _releaseTexture(texture: InternalTexture): void;
  11871. private setProgram;
  11872. private _boundUniforms;
  11873. /**
  11874. * Binds an effect to the webGL context
  11875. * @param effect defines the effect to bind
  11876. */
  11877. bindSamplers(effect: Effect): void;
  11878. private _moveBoundTextureOnTop;
  11879. private _getCorrectTextureChannel;
  11880. private _linkTrackers;
  11881. private _removeDesignatedSlot;
  11882. private _activateCurrentTexture;
  11883. /** @hidden */
  11884. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11885. /** @hidden */
  11886. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11887. /**
  11888. * Sets a texture to the webGL context from a postprocess
  11889. * @param channel defines the channel to use
  11890. * @param postProcess defines the source postprocess
  11891. */
  11892. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11893. /**
  11894. * Binds the output of the passed in post process to the texture channel specified
  11895. * @param channel The channel the texture should be bound to
  11896. * @param postProcess The post process which's output should be bound
  11897. */
  11898. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11899. /**
  11900. * Unbind all textures from the webGL context
  11901. */
  11902. unbindAllTextures(): void;
  11903. /**
  11904. * Sets a texture to the according uniform.
  11905. * @param channel The texture channel
  11906. * @param uniform The uniform to set
  11907. * @param texture The texture to apply
  11908. */
  11909. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11910. /**
  11911. * Sets a depth stencil texture from a render target to the according uniform.
  11912. * @param channel The texture channel
  11913. * @param uniform The uniform to set
  11914. * @param texture The render target texture containing the depth stencil texture to apply
  11915. */
  11916. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11917. private _bindSamplerUniformToChannel;
  11918. private _getTextureWrapMode;
  11919. private _setTexture;
  11920. /**
  11921. * Sets an array of texture to the webGL context
  11922. * @param channel defines the channel where the texture array must be set
  11923. * @param uniform defines the associated uniform location
  11924. * @param textures defines the array of textures to bind
  11925. */
  11926. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11927. /** @hidden */
  11928. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11929. private _setTextureParameterFloat;
  11930. private _setTextureParameterInteger;
  11931. /**
  11932. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11933. * @param x defines the x coordinate of the rectangle where pixels must be read
  11934. * @param y defines the y coordinate of the rectangle where pixels must be read
  11935. * @param width defines the width of the rectangle where pixels must be read
  11936. * @param height defines the height of the rectangle where pixels must be read
  11937. * @returns a Uint8Array containing RGBA colors
  11938. */
  11939. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11940. /**
  11941. * Add an externaly attached data from its key.
  11942. * This method call will fail and return false, if such key already exists.
  11943. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11944. * @param key the unique key that identifies the data
  11945. * @param data the data object to associate to the key for this Engine instance
  11946. * @return true if no such key were already present and the data was added successfully, false otherwise
  11947. */
  11948. addExternalData<T>(key: string, data: T): boolean;
  11949. /**
  11950. * Get an externaly attached data from its key
  11951. * @param key the unique key that identifies the data
  11952. * @return the associated data, if present (can be null), or undefined if not present
  11953. */
  11954. getExternalData<T>(key: string): T;
  11955. /**
  11956. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11957. * @param key the unique key that identifies the data
  11958. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11959. * @return the associated data, can be null if the factory returned null.
  11960. */
  11961. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11962. /**
  11963. * Remove an externaly attached data from the Engine instance
  11964. * @param key the unique key that identifies the data
  11965. * @return true if the data was successfully removed, false if it doesn't exist
  11966. */
  11967. removeExternalData(key: string): boolean;
  11968. /**
  11969. * Unbind all vertex attributes from the webGL context
  11970. */
  11971. unbindAllAttributes(): void;
  11972. /**
  11973. * 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
  11974. */
  11975. releaseEffects(): void;
  11976. /**
  11977. * Dispose and release all associated resources
  11978. */
  11979. dispose(): void;
  11980. /**
  11981. * Display the loading screen
  11982. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11983. */
  11984. displayLoadingUI(): void;
  11985. /**
  11986. * Hide the loading screen
  11987. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11988. */
  11989. hideLoadingUI(): void;
  11990. /**
  11991. * Gets the current loading screen object
  11992. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11993. */
  11994. /**
  11995. * Sets the current loading screen object
  11996. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11997. */
  11998. loadingScreen: ILoadingScreen;
  11999. /**
  12000. * Sets the current loading screen text
  12001. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12002. */
  12003. loadingUIText: string;
  12004. /**
  12005. * Sets the current loading screen background color
  12006. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12007. */
  12008. loadingUIBackgroundColor: string;
  12009. /**
  12010. * Attach a new callback raised when context lost event is fired
  12011. * @param callback defines the callback to call
  12012. */
  12013. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12014. /**
  12015. * Attach a new callback raised when context restored event is fired
  12016. * @param callback defines the callback to call
  12017. */
  12018. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12019. /**
  12020. * Gets the source code of the vertex shader associated with a specific webGL program
  12021. * @param program defines the program to use
  12022. * @returns a string containing the source code of the vertex shader associated with the program
  12023. */
  12024. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  12025. /**
  12026. * Gets the source code of the fragment shader associated with a specific webGL program
  12027. * @param program defines the program to use
  12028. * @returns a string containing the source code of the fragment shader associated with the program
  12029. */
  12030. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  12031. /**
  12032. * Get the current error code of the webGL context
  12033. * @returns the error code
  12034. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12035. */
  12036. getError(): number;
  12037. /**
  12038. * Gets the current framerate
  12039. * @returns a number representing the framerate
  12040. */
  12041. getFps(): number;
  12042. /**
  12043. * Gets the time spent between current and previous frame
  12044. * @returns a number representing the delta time in ms
  12045. */
  12046. getDeltaTime(): number;
  12047. private _measureFps;
  12048. /** @hidden */
  12049. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  12050. private _canRenderToFloatFramebuffer;
  12051. private _canRenderToHalfFloatFramebuffer;
  12052. private _canRenderToFramebuffer;
  12053. /** @hidden */
  12054. _getWebGLTextureType(type: number): number;
  12055. private _getInternalFormat;
  12056. /** @hidden */
  12057. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  12058. /** @hidden */
  12059. _getRGBAMultiSampleBufferFormat(type: number): number;
  12060. /** @hidden */
  12061. _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;
  12062. /** @hidden */
  12063. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  12064. private _partialLoadFile;
  12065. private _cascadeLoadFiles;
  12066. /**
  12067. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  12068. * @returns true if the engine can be created
  12069. * @ignorenaming
  12070. */
  12071. static isSupported(): boolean;
  12072. }
  12073. }
  12074. declare module BABYLON {
  12075. /**
  12076. * Options to create the null engine
  12077. */
  12078. class NullEngineOptions {
  12079. /**
  12080. * Render width (Default: 512)
  12081. */
  12082. renderWidth: number;
  12083. /**
  12084. * Render height (Default: 256)
  12085. */
  12086. renderHeight: number;
  12087. /**
  12088. * Texture size (Default: 512)
  12089. */
  12090. textureSize: number;
  12091. /**
  12092. * If delta time between frames should be constant
  12093. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12094. */
  12095. deterministicLockstep: boolean;
  12096. /**
  12097. * Maximum about of steps between frames (Default: 4)
  12098. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12099. */
  12100. lockstepMaxSteps: number;
  12101. }
  12102. /**
  12103. * The null engine class provides support for headless version of babylon.js.
  12104. * This can be used in server side scenario or for testing purposes
  12105. */
  12106. class NullEngine extends Engine {
  12107. private _options;
  12108. /**
  12109. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12110. */
  12111. isDeterministicLockStep(): boolean;
  12112. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  12113. getLockstepMaxSteps(): number;
  12114. /**
  12115. * Sets hardware scaling, used to save performance if needed
  12116. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  12117. */
  12118. getHardwareScalingLevel(): number;
  12119. constructor(options?: NullEngineOptions);
  12120. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12121. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  12122. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  12123. getRenderWidth(useScreen?: boolean): number;
  12124. getRenderHeight(useScreen?: boolean): number;
  12125. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  12126. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  12127. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  12128. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  12129. bindSamplers(effect: Effect): void;
  12130. enableEffect(effect: Effect): void;
  12131. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  12132. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  12133. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  12134. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  12135. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  12136. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  12137. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  12138. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  12139. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  12140. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  12141. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  12142. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  12143. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  12144. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  12145. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  12146. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12147. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12148. setFloat(uniform: WebGLUniformLocation, value: number): void;
  12149. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  12150. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  12151. setBool(uniform: WebGLUniformLocation, bool: number): void;
  12152. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  12153. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  12154. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  12155. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12156. bindBuffers(vertexBuffers: {
  12157. [key: string]: VertexBuffer;
  12158. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  12159. wipeCaches(bruteForce?: boolean): void;
  12160. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  12161. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  12162. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  12163. /** @hidden */
  12164. _createTexture(): WebGLTexture;
  12165. /** @hidden */
  12166. _releaseTexture(texture: InternalTexture): void;
  12167. 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;
  12168. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12169. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12170. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12171. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12172. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12173. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12174. areAllEffectsReady(): boolean;
  12175. /**
  12176. * @hidden
  12177. * Get the current error code of the webGL context
  12178. * @returns the error code
  12179. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12180. */
  12181. getError(): number;
  12182. /** @hidden */
  12183. _getUnpackAlignement(): number;
  12184. /** @hidden */
  12185. _unpackFlipY(value: boolean): void;
  12186. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12187. /**
  12188. * Updates a dynamic vertex buffer.
  12189. * @param vertexBuffer the vertex buffer to update
  12190. * @param data the data used to update the vertex buffer
  12191. * @param byteOffset the byte offset of the data (optional)
  12192. * @param byteLength the byte length of the data (optional)
  12193. */
  12194. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12195. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12196. /** @hidden */
  12197. _bindTexture(channel: number, texture: InternalTexture): void;
  12198. /** @hidden */
  12199. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12200. releaseEffects(): void;
  12201. displayLoadingUI(): void;
  12202. hideLoadingUI(): void;
  12203. /** @hidden */
  12204. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12205. /** @hidden */
  12206. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12207. /** @hidden */
  12208. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12209. /** @hidden */
  12210. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12211. }
  12212. }
  12213. interface WebGLRenderingContext {
  12214. readonly RASTERIZER_DISCARD: number;
  12215. readonly DEPTH_COMPONENT24: number;
  12216. readonly TEXTURE_3D: number;
  12217. readonly TEXTURE_2D_ARRAY: number;
  12218. readonly TEXTURE_COMPARE_FUNC: number;
  12219. readonly TEXTURE_COMPARE_MODE: number;
  12220. readonly COMPARE_REF_TO_TEXTURE: number;
  12221. readonly TEXTURE_WRAP_R: number;
  12222. readonly HALF_FLOAT: number;
  12223. readonly RGB8: number;
  12224. readonly RED_INTEGER: number;
  12225. readonly RG_INTEGER: number;
  12226. readonly RGB_INTEGER: number;
  12227. readonly RGBA_INTEGER: number;
  12228. readonly R8_SNORM: number;
  12229. readonly RG8_SNORM: number;
  12230. readonly RGB8_SNORM: number;
  12231. readonly RGBA8_SNORM: number;
  12232. readonly R8I: number;
  12233. readonly RG8I: number;
  12234. readonly RGB8I: number;
  12235. readonly RGBA8I: number;
  12236. readonly R8UI: number;
  12237. readonly RG8UI: number;
  12238. readonly RGB8UI: number;
  12239. readonly RGBA8UI: number;
  12240. readonly R16I: number;
  12241. readonly RG16I: number;
  12242. readonly RGB16I: number;
  12243. readonly RGBA16I: number;
  12244. readonly R16UI: number;
  12245. readonly RG16UI: number;
  12246. readonly RGB16UI: number;
  12247. readonly RGBA16UI: number;
  12248. readonly R32I: number;
  12249. readonly RG32I: number;
  12250. readonly RGB32I: number;
  12251. readonly RGBA32I: number;
  12252. readonly R32UI: number;
  12253. readonly RG32UI: number;
  12254. readonly RGB32UI: number;
  12255. readonly RGBA32UI: number;
  12256. readonly RGB10_A2UI: number;
  12257. readonly R11F_G11F_B10F: number;
  12258. readonly RGB9_E5: number;
  12259. readonly RGB10_A2: number;
  12260. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12261. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12262. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12263. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12264. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12265. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12266. 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;
  12267. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12268. readonly TRANSFORM_FEEDBACK: number;
  12269. readonly INTERLEAVED_ATTRIBS: number;
  12270. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12271. createTransformFeedback(): WebGLTransformFeedback;
  12272. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12273. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12274. beginTransformFeedback(primitiveMode: number): void;
  12275. endTransformFeedback(): void;
  12276. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12277. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12278. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12279. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12280. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12281. }
  12282. interface ImageBitmap {
  12283. readonly width: number;
  12284. readonly height: number;
  12285. close(): void;
  12286. }
  12287. interface WebGLQuery extends WebGLObject {
  12288. }
  12289. declare var WebGLQuery: {
  12290. prototype: WebGLQuery;
  12291. new (): WebGLQuery;
  12292. };
  12293. interface WebGLSampler extends WebGLObject {
  12294. }
  12295. declare var WebGLSampler: {
  12296. prototype: WebGLSampler;
  12297. new (): WebGLSampler;
  12298. };
  12299. interface WebGLSync extends WebGLObject {
  12300. }
  12301. declare var WebGLSync: {
  12302. prototype: WebGLSync;
  12303. new (): WebGLSync;
  12304. };
  12305. interface WebGLTransformFeedback extends WebGLObject {
  12306. }
  12307. declare var WebGLTransformFeedback: {
  12308. prototype: WebGLTransformFeedback;
  12309. new (): WebGLTransformFeedback;
  12310. };
  12311. interface WebGLVertexArrayObject extends WebGLObject {
  12312. }
  12313. declare var WebGLVertexArrayObject: {
  12314. prototype: WebGLVertexArrayObject;
  12315. new (): WebGLVertexArrayObject;
  12316. };
  12317. declare module BABYLON {
  12318. /**
  12319. * Gather the list of clipboard event types as constants.
  12320. */
  12321. class ClipboardEventTypes {
  12322. /**
  12323. * The clipboard event is fired when a copy command is active (pressed).
  12324. */
  12325. static readonly COPY: number;
  12326. /**
  12327. * The clipboard event is fired when a cut command is active (pressed).
  12328. */
  12329. static readonly CUT: number;
  12330. /**
  12331. * The clipboard event is fired when a paste command is active (pressed).
  12332. */
  12333. static readonly PASTE: number;
  12334. }
  12335. /**
  12336. * This class is used to store clipboard related info for the onClipboardObservable event.
  12337. */
  12338. class ClipboardInfo {
  12339. /**
  12340. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12341. */
  12342. type: number;
  12343. /**
  12344. * Defines the related dom event
  12345. */
  12346. event: ClipboardEvent;
  12347. /**
  12348. *Creates an instance of ClipboardInfo.
  12349. * @param {number} type
  12350. * @param {ClipboardEvent} event
  12351. */
  12352. constructor(
  12353. /**
  12354. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12355. */
  12356. type: number,
  12357. /**
  12358. * Defines the related dom event
  12359. */
  12360. event: ClipboardEvent);
  12361. /**
  12362. * Get the clipboard event's type from the keycode.
  12363. * @param keyCode Defines the keyCode for the current keyboard event.
  12364. * @return {number}
  12365. */
  12366. static GetTypeFromCharacter(keyCode: number): number;
  12367. }
  12368. }
  12369. declare module BABYLON {
  12370. /**
  12371. * Gather the list of keyboard event types as constants.
  12372. */
  12373. class KeyboardEventTypes {
  12374. /**
  12375. * The keydown event is fired when a key becomes active (pressed).
  12376. */
  12377. static readonly KEYDOWN: number;
  12378. /**
  12379. * The keyup event is fired when a key has been released.
  12380. */
  12381. static readonly KEYUP: number;
  12382. }
  12383. /**
  12384. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12385. */
  12386. class KeyboardInfo {
  12387. /**
  12388. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12389. */
  12390. type: number;
  12391. /**
  12392. * Defines the related dom event
  12393. */
  12394. event: KeyboardEvent;
  12395. /**
  12396. * Instantiates a new keyboard info.
  12397. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12398. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12399. * @param event Defines the related dom event
  12400. */
  12401. constructor(
  12402. /**
  12403. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12404. */
  12405. type: number,
  12406. /**
  12407. * Defines the related dom event
  12408. */
  12409. event: KeyboardEvent);
  12410. }
  12411. /**
  12412. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12413. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12414. */
  12415. class KeyboardInfoPre extends KeyboardInfo {
  12416. /**
  12417. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12418. */
  12419. type: number;
  12420. /**
  12421. * Defines the related dom event
  12422. */
  12423. event: KeyboardEvent;
  12424. /**
  12425. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12426. */
  12427. skipOnPointerObservable: boolean;
  12428. /**
  12429. * Instantiates a new keyboard pre info.
  12430. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12431. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12432. * @param event Defines the related dom event
  12433. */
  12434. constructor(
  12435. /**
  12436. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12437. */
  12438. type: number,
  12439. /**
  12440. * Defines the related dom event
  12441. */
  12442. event: KeyboardEvent);
  12443. }
  12444. }
  12445. declare module BABYLON {
  12446. /**
  12447. * Gather the list of pointer event types as constants.
  12448. */
  12449. class PointerEventTypes {
  12450. /**
  12451. * 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.
  12452. */
  12453. static readonly POINTERDOWN: number;
  12454. /**
  12455. * The pointerup event is fired when a pointer is no longer active.
  12456. */
  12457. static readonly POINTERUP: number;
  12458. /**
  12459. * The pointermove event is fired when a pointer changes coordinates.
  12460. */
  12461. static readonly POINTERMOVE: number;
  12462. /**
  12463. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12464. */
  12465. static readonly POINTERWHEEL: number;
  12466. /**
  12467. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12468. */
  12469. static readonly POINTERPICK: number;
  12470. /**
  12471. * The pointertap event is fired when a the object has been touched and released without drag.
  12472. */
  12473. static readonly POINTERTAP: number;
  12474. /**
  12475. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12476. */
  12477. static readonly POINTERDOUBLETAP: number;
  12478. }
  12479. /**
  12480. * Base class of pointer info types.
  12481. */
  12482. class PointerInfoBase {
  12483. /**
  12484. * Defines the type of event (BABYLON.PointerEventTypes)
  12485. */
  12486. type: number;
  12487. /**
  12488. * Defines the related dom event
  12489. */
  12490. event: PointerEvent | MouseWheelEvent;
  12491. /**
  12492. * Instantiates the base class of pointers info.
  12493. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12494. * @param event Defines the related dom event
  12495. */
  12496. constructor(
  12497. /**
  12498. * Defines the type of event (BABYLON.PointerEventTypes)
  12499. */
  12500. type: number,
  12501. /**
  12502. * Defines the related dom event
  12503. */
  12504. event: PointerEvent | MouseWheelEvent);
  12505. }
  12506. /**
  12507. * This class is used to store pointer related info for the onPrePointerObservable event.
  12508. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12509. */
  12510. class PointerInfoPre extends PointerInfoBase {
  12511. /**
  12512. * Ray from a pointer if availible (eg. 6dof controller)
  12513. */
  12514. ray: Nullable<Ray>;
  12515. /**
  12516. * Defines the local position of the pointer on the canvas.
  12517. */
  12518. localPosition: Vector2;
  12519. /**
  12520. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12521. */
  12522. skipOnPointerObservable: boolean;
  12523. /**
  12524. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12525. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12526. * @param event Defines the related dom event
  12527. * @param localX Defines the local x coordinates of the pointer when the event occured
  12528. * @param localY Defines the local y coordinates of the pointer when the event occured
  12529. */
  12530. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12531. }
  12532. /**
  12533. * This type contains all the data related to a pointer event in Babylon.js.
  12534. * 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.
  12535. */
  12536. class PointerInfo extends PointerInfoBase {
  12537. /**
  12538. * Defines the picking info associated to the info (if any)\
  12539. */
  12540. pickInfo: Nullable<PickingInfo>;
  12541. /**
  12542. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12543. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12544. * @param event Defines the related dom event
  12545. * @param pickInfo Defines the picking info associated to the info (if any)\
  12546. */
  12547. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12548. /**
  12549. * Defines the picking info associated to the info (if any)\
  12550. */
  12551. pickInfo: Nullable<PickingInfo>);
  12552. }
  12553. }
  12554. declare module BABYLON {
  12555. /**
  12556. * Represents a gamepad control stick position
  12557. */
  12558. class StickValues {
  12559. /**
  12560. * The x component of the control stick
  12561. */
  12562. x: number;
  12563. /**
  12564. * The y component of the control stick
  12565. */
  12566. y: number;
  12567. /**
  12568. * Initializes the gamepad x and y control stick values
  12569. * @param x The x component of the gamepad control stick value
  12570. * @param y The y component of the gamepad control stick value
  12571. */
  12572. constructor(
  12573. /**
  12574. * The x component of the control stick
  12575. */
  12576. x: number,
  12577. /**
  12578. * The y component of the control stick
  12579. */
  12580. y: number);
  12581. }
  12582. /**
  12583. * An interface which manages callbacks for gamepad button changes
  12584. */
  12585. interface GamepadButtonChanges {
  12586. /**
  12587. * Called when a gamepad has been changed
  12588. */
  12589. changed: boolean;
  12590. /**
  12591. * Called when a gamepad press event has been triggered
  12592. */
  12593. pressChanged: boolean;
  12594. /**
  12595. * Called when a touch event has been triggered
  12596. */
  12597. touchChanged: boolean;
  12598. /**
  12599. * Called when a value has changed
  12600. */
  12601. valueChanged: boolean;
  12602. }
  12603. /**
  12604. * Represents a gamepad
  12605. */
  12606. class Gamepad {
  12607. /**
  12608. * The id of the gamepad
  12609. */
  12610. id: string;
  12611. /**
  12612. * The index of the gamepad
  12613. */
  12614. index: number;
  12615. /**
  12616. * The browser gamepad
  12617. */
  12618. browserGamepad: any;
  12619. /**
  12620. * Specifies what type of gamepad this represents
  12621. */
  12622. type: number;
  12623. private _leftStick;
  12624. private _rightStick;
  12625. /** @hidden */
  12626. _isConnected: boolean;
  12627. private _leftStickAxisX;
  12628. private _leftStickAxisY;
  12629. private _rightStickAxisX;
  12630. private _rightStickAxisY;
  12631. /**
  12632. * Triggered when the left control stick has been changed
  12633. */
  12634. private _onleftstickchanged;
  12635. /**
  12636. * Triggered when the right control stick has been changed
  12637. */
  12638. private _onrightstickchanged;
  12639. /**
  12640. * Represents a gamepad controller
  12641. */
  12642. static GAMEPAD: number;
  12643. /**
  12644. * Represents a generic controller
  12645. */
  12646. static GENERIC: number;
  12647. /**
  12648. * Represents an XBox controller
  12649. */
  12650. static XBOX: number;
  12651. /**
  12652. * Represents a pose-enabled controller
  12653. */
  12654. static POSE_ENABLED: number;
  12655. /**
  12656. * Specifies whether the left control stick should be Y-inverted
  12657. */
  12658. protected _invertLeftStickY: boolean;
  12659. /**
  12660. * Specifies if the gamepad has been connected
  12661. */
  12662. readonly isConnected: boolean;
  12663. /**
  12664. * Initializes the gamepad
  12665. * @param id The id of the gamepad
  12666. * @param index The index of the gamepad
  12667. * @param browserGamepad The browser gamepad
  12668. * @param leftStickX The x component of the left joystick
  12669. * @param leftStickY The y component of the left joystick
  12670. * @param rightStickX The x component of the right joystick
  12671. * @param rightStickY The y component of the right joystick
  12672. */
  12673. constructor(
  12674. /**
  12675. * The id of the gamepad
  12676. */
  12677. id: string,
  12678. /**
  12679. * The index of the gamepad
  12680. */
  12681. index: number,
  12682. /**
  12683. * The browser gamepad
  12684. */
  12685. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12686. /**
  12687. * Callback triggered when the left joystick has changed
  12688. * @param callback
  12689. */
  12690. onleftstickchanged(callback: (values: StickValues) => void): void;
  12691. /**
  12692. * Callback triggered when the right joystick has changed
  12693. * @param callback
  12694. */
  12695. onrightstickchanged(callback: (values: StickValues) => void): void;
  12696. /**
  12697. * Gets the left joystick
  12698. */
  12699. /**
  12700. * Sets the left joystick values
  12701. */
  12702. leftStick: StickValues;
  12703. /**
  12704. * Gets the right joystick
  12705. */
  12706. /**
  12707. * Sets the right joystick value
  12708. */
  12709. rightStick: StickValues;
  12710. /**
  12711. * Updates the gamepad joystick positions
  12712. */
  12713. update(): void;
  12714. /**
  12715. * Disposes the gamepad
  12716. */
  12717. dispose(): void;
  12718. }
  12719. /**
  12720. * Represents a generic gamepad
  12721. */
  12722. class GenericPad extends Gamepad {
  12723. private _buttons;
  12724. private _onbuttondown;
  12725. private _onbuttonup;
  12726. /**
  12727. * Observable triggered when a button has been pressed
  12728. */
  12729. onButtonDownObservable: Observable<number>;
  12730. /**
  12731. * Observable triggered when a button has been released
  12732. */
  12733. onButtonUpObservable: Observable<number>;
  12734. /**
  12735. * Callback triggered when a button has been pressed
  12736. * @param callback Called when a button has been pressed
  12737. */
  12738. onbuttondown(callback: (buttonPressed: number) => void): void;
  12739. /**
  12740. * Callback triggered when a button has been released
  12741. * @param callback Called when a button has been released
  12742. */
  12743. onbuttonup(callback: (buttonReleased: number) => void): void;
  12744. /**
  12745. * Initializes the generic gamepad
  12746. * @param id The id of the generic gamepad
  12747. * @param index The index of the generic gamepad
  12748. * @param browserGamepad The browser gamepad
  12749. */
  12750. constructor(id: string, index: number, browserGamepad: any);
  12751. private _setButtonValue;
  12752. /**
  12753. * Updates the generic gamepad
  12754. */
  12755. update(): void;
  12756. /**
  12757. * Disposes the generic gamepad
  12758. */
  12759. dispose(): void;
  12760. }
  12761. }
  12762. declare module BABYLON {
  12763. /**
  12764. * Manager for handling gamepads
  12765. */
  12766. class GamepadManager {
  12767. private _scene?;
  12768. private _babylonGamepads;
  12769. private _oneGamepadConnected;
  12770. /** @hidden */
  12771. _isMonitoring: boolean;
  12772. private _gamepadEventSupported;
  12773. private _gamepadSupport;
  12774. /**
  12775. * observable to be triggered when the gamepad controller has been connected
  12776. */
  12777. onGamepadConnectedObservable: Observable<Gamepad>;
  12778. /**
  12779. * observable to be triggered when the gamepad controller has been disconnected
  12780. */
  12781. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12782. private _onGamepadConnectedEvent;
  12783. private _onGamepadDisconnectedEvent;
  12784. /**
  12785. * Initializes the gamepad manager
  12786. * @param _scene BabylonJS scene
  12787. */
  12788. constructor(_scene?: Scene | undefined);
  12789. /**
  12790. * The gamepads in the game pad manager
  12791. */
  12792. readonly gamepads: Gamepad[];
  12793. /**
  12794. * Get the gamepad controllers based on type
  12795. * @param type The type of gamepad controller
  12796. * @returns Nullable gamepad
  12797. */
  12798. getGamepadByType(type?: number): Nullable<Gamepad>;
  12799. /**
  12800. * Disposes the gamepad manager
  12801. */
  12802. dispose(): void;
  12803. private _addNewGamepad;
  12804. private _startMonitoringGamepads;
  12805. private _stopMonitoringGamepads;
  12806. /** @hidden */
  12807. _checkGamepadsStatus(): void;
  12808. private _updateGamepadObjects;
  12809. }
  12810. }
  12811. declare module BABYLON {
  12812. interface Scene {
  12813. /** @hidden */
  12814. _gamepadManager: Nullable<GamepadManager>;
  12815. /**
  12816. * Gets the gamepad manager associated with the scene
  12817. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12818. */
  12819. gamepadManager: GamepadManager;
  12820. }
  12821. /**
  12822. * Interface representing a free camera inputs manager
  12823. */
  12824. interface FreeCameraInputsManager {
  12825. /**
  12826. * Adds gamepad input support to the FreeCameraInputsManager.
  12827. * @returns the FreeCameraInputsManager
  12828. */
  12829. addGamepad(): FreeCameraInputsManager;
  12830. }
  12831. /**
  12832. * Interface representing an arc rotate camera inputs manager
  12833. */
  12834. interface ArcRotateCameraInputsManager {
  12835. /**
  12836. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12837. * @returns the camera inputs manager
  12838. */
  12839. addGamepad(): ArcRotateCameraInputsManager;
  12840. }
  12841. /**
  12842. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12843. */
  12844. class GamepadSystemSceneComponent implements ISceneComponent {
  12845. /**
  12846. * The component name helpfull to identify the component in the list of scene components.
  12847. */
  12848. readonly name: string;
  12849. /**
  12850. * The scene the component belongs to.
  12851. */
  12852. scene: Scene;
  12853. /**
  12854. * Creates a new instance of the component for the given scene
  12855. * @param scene Defines the scene to register the component in
  12856. */
  12857. constructor(scene: Scene);
  12858. /**
  12859. * Registers the component in a given scene
  12860. */
  12861. register(): void;
  12862. /**
  12863. * Rebuilds the elements related to this component in case of
  12864. * context lost for instance.
  12865. */
  12866. rebuild(): void;
  12867. /**
  12868. * Disposes the component and the associated ressources
  12869. */
  12870. dispose(): void;
  12871. private _beforeCameraUpdate;
  12872. }
  12873. }
  12874. declare module BABYLON {
  12875. /**
  12876. * Defines supported buttons for XBox360 compatible gamepads
  12877. */
  12878. enum Xbox360Button {
  12879. /** A */
  12880. A = 0,
  12881. /** B */
  12882. B = 1,
  12883. /** X */
  12884. X = 2,
  12885. /** Y */
  12886. Y = 3,
  12887. /** Start */
  12888. Start = 4,
  12889. /** Back */
  12890. Back = 5,
  12891. /** Left button */
  12892. LB = 6,
  12893. /** Right button */
  12894. RB = 7,
  12895. /** Left stick */
  12896. LeftStick = 8,
  12897. /** Right stick */
  12898. RightStick = 9
  12899. }
  12900. /** Defines values for XBox360 DPad */
  12901. enum Xbox360Dpad {
  12902. /** Up */
  12903. Up = 0,
  12904. /** Down */
  12905. Down = 1,
  12906. /** Left */
  12907. Left = 2,
  12908. /** Right */
  12909. Right = 3
  12910. }
  12911. /**
  12912. * Defines a XBox360 gamepad
  12913. */
  12914. class Xbox360Pad extends Gamepad {
  12915. private _leftTrigger;
  12916. private _rightTrigger;
  12917. private _onlefttriggerchanged;
  12918. private _onrighttriggerchanged;
  12919. private _onbuttondown;
  12920. private _onbuttonup;
  12921. private _ondpaddown;
  12922. private _ondpadup;
  12923. /** Observable raised when a button is pressed */
  12924. onButtonDownObservable: Observable<Xbox360Button>;
  12925. /** Observable raised when a button is released */
  12926. onButtonUpObservable: Observable<Xbox360Button>;
  12927. /** Observable raised when a pad is pressed */
  12928. onPadDownObservable: Observable<Xbox360Dpad>;
  12929. /** Observable raised when a pad is released */
  12930. onPadUpObservable: Observable<Xbox360Dpad>;
  12931. private _buttonA;
  12932. private _buttonB;
  12933. private _buttonX;
  12934. private _buttonY;
  12935. private _buttonBack;
  12936. private _buttonStart;
  12937. private _buttonLB;
  12938. private _buttonRB;
  12939. private _buttonLeftStick;
  12940. private _buttonRightStick;
  12941. private _dPadUp;
  12942. private _dPadDown;
  12943. private _dPadLeft;
  12944. private _dPadRight;
  12945. private _isXboxOnePad;
  12946. /**
  12947. * Creates a new XBox360 gamepad object
  12948. * @param id defines the id of this gamepad
  12949. * @param index defines its index
  12950. * @param gamepad defines the internal HTML gamepad object
  12951. * @param xboxOne defines if it is a XBox One gamepad
  12952. */
  12953. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12954. /**
  12955. * Defines the callback to call when left trigger is pressed
  12956. * @param callback defines the callback to use
  12957. */
  12958. onlefttriggerchanged(callback: (value: number) => void): void;
  12959. /**
  12960. * Defines the callback to call when right trigger is pressed
  12961. * @param callback defines the callback to use
  12962. */
  12963. onrighttriggerchanged(callback: (value: number) => void): void;
  12964. /**
  12965. * Gets the left trigger value
  12966. */
  12967. /**
  12968. * Sets the left trigger value
  12969. */
  12970. leftTrigger: number;
  12971. /**
  12972. * Gets the right trigger value
  12973. */
  12974. /**
  12975. * Sets the right trigger value
  12976. */
  12977. rightTrigger: number;
  12978. /**
  12979. * Defines the callback to call when a button is pressed
  12980. * @param callback defines the callback to use
  12981. */
  12982. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12983. /**
  12984. * Defines the callback to call when a button is released
  12985. * @param callback defines the callback to use
  12986. */
  12987. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12988. /**
  12989. * Defines the callback to call when a pad is pressed
  12990. * @param callback defines the callback to use
  12991. */
  12992. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12993. /**
  12994. * Defines the callback to call when a pad is released
  12995. * @param callback defines the callback to use
  12996. */
  12997. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12998. private _setButtonValue;
  12999. private _setDPadValue;
  13000. /**
  13001. * Gets the value of the `A` button
  13002. */
  13003. /**
  13004. * Sets the value of the `A` button
  13005. */
  13006. buttonA: number;
  13007. /**
  13008. * Gets the value of the `B` button
  13009. */
  13010. /**
  13011. * Sets the value of the `B` button
  13012. */
  13013. buttonB: number;
  13014. /**
  13015. * Gets the value of the `X` button
  13016. */
  13017. /**
  13018. * Sets the value of the `X` button
  13019. */
  13020. buttonX: number;
  13021. /**
  13022. * Gets the value of the `Y` button
  13023. */
  13024. /**
  13025. * Sets the value of the `Y` button
  13026. */
  13027. buttonY: number;
  13028. /**
  13029. * Gets the value of the `Start` button
  13030. */
  13031. /**
  13032. * Sets the value of the `Start` button
  13033. */
  13034. buttonStart: number;
  13035. /**
  13036. * Gets the value of the `Back` button
  13037. */
  13038. /**
  13039. * Sets the value of the `Back` button
  13040. */
  13041. buttonBack: number;
  13042. /**
  13043. * Gets the value of the `Left` button
  13044. */
  13045. /**
  13046. * Sets the value of the `Left` button
  13047. */
  13048. buttonLB: number;
  13049. /**
  13050. * Gets the value of the `Right` button
  13051. */
  13052. /**
  13053. * Sets the value of the `Right` button
  13054. */
  13055. buttonRB: number;
  13056. /**
  13057. * Gets the value of the Left joystick
  13058. */
  13059. /**
  13060. * Sets the value of the Left joystick
  13061. */
  13062. buttonLeftStick: number;
  13063. /**
  13064. * Gets the value of the Right joystick
  13065. */
  13066. /**
  13067. * Sets the value of the Right joystick
  13068. */
  13069. buttonRightStick: number;
  13070. /**
  13071. * Gets the value of D-pad up
  13072. */
  13073. /**
  13074. * Sets the value of D-pad up
  13075. */
  13076. dPadUp: number;
  13077. /**
  13078. * Gets the value of D-pad down
  13079. */
  13080. /**
  13081. * Sets the value of D-pad down
  13082. */
  13083. dPadDown: number;
  13084. /**
  13085. * Gets the value of D-pad left
  13086. */
  13087. /**
  13088. * Sets the value of D-pad left
  13089. */
  13090. dPadLeft: number;
  13091. /**
  13092. * Gets the value of D-pad right
  13093. */
  13094. /**
  13095. * Sets the value of D-pad right
  13096. */
  13097. dPadRight: number;
  13098. /**
  13099. * Force the gamepad to synchronize with device values
  13100. */
  13101. update(): void;
  13102. /**
  13103. * Disposes the gamepad
  13104. */
  13105. dispose(): void;
  13106. }
  13107. }
  13108. declare module BABYLON {
  13109. /**
  13110. * Single axis drag gizmo
  13111. */
  13112. class AxisDragGizmo extends Gizmo {
  13113. /**
  13114. * Drag behavior responsible for the gizmos dragging interactions
  13115. */
  13116. dragBehavior: PointerDragBehavior;
  13117. private _pointerObserver;
  13118. /**
  13119. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13120. */
  13121. snapDistance: number;
  13122. /**
  13123. * Event that fires each time the gizmo snaps to a new location.
  13124. * * snapDistance is the the change in distance
  13125. */
  13126. onSnapObservable: Observable<{
  13127. snapDistance: number;
  13128. }>;
  13129. /** @hidden */
  13130. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  13131. /** @hidden */
  13132. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  13133. /**
  13134. * Creates an AxisDragGizmo
  13135. * @param gizmoLayer The utility layer the gizmo will be added to
  13136. * @param dragAxis The axis which the gizmo will be able to drag on
  13137. * @param color The color of the gizmo
  13138. */
  13139. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13140. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13141. /**
  13142. * Disposes of the gizmo
  13143. */
  13144. dispose(): void;
  13145. }
  13146. }
  13147. declare module BABYLON {
  13148. /**
  13149. * Single axis scale gizmo
  13150. */
  13151. class AxisScaleGizmo extends Gizmo {
  13152. private _coloredMaterial;
  13153. /**
  13154. * Drag behavior responsible for the gizmos dragging interactions
  13155. */
  13156. dragBehavior: PointerDragBehavior;
  13157. private _pointerObserver;
  13158. /**
  13159. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13160. */
  13161. snapDistance: number;
  13162. /**
  13163. * Event that fires each time the gizmo snaps to a new location.
  13164. * * snapDistance is the the change in distance
  13165. */
  13166. onSnapObservable: Observable<{
  13167. snapDistance: number;
  13168. }>;
  13169. /**
  13170. * If the scaling operation should be done on all axis (default: false)
  13171. */
  13172. uniformScaling: boolean;
  13173. /**
  13174. * Creates an AxisScaleGizmo
  13175. * @param gizmoLayer The utility layer the gizmo will be added to
  13176. * @param dragAxis The axis which the gizmo will be able to scale on
  13177. * @param color The color of the gizmo
  13178. */
  13179. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13180. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13181. /**
  13182. * Disposes of the gizmo
  13183. */
  13184. dispose(): void;
  13185. /**
  13186. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13187. * @param mesh The mesh to replace the default mesh of the gizmo
  13188. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  13189. */
  13190. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  13191. }
  13192. }
  13193. declare module BABYLON {
  13194. /**
  13195. * Bounding box gizmo
  13196. */
  13197. class BoundingBoxGizmo extends Gizmo {
  13198. private _lineBoundingBox;
  13199. private _rotateSpheresParent;
  13200. private _scaleBoxesParent;
  13201. private _boundingDimensions;
  13202. private _renderObserver;
  13203. private _pointerObserver;
  13204. private _scaleDragSpeed;
  13205. private _tmpQuaternion;
  13206. private _tmpVector;
  13207. private _tmpRotationMatrix;
  13208. /**
  13209. * 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)
  13210. */
  13211. ignoreChildren: boolean;
  13212. /**
  13213. * 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)
  13214. */
  13215. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  13216. /**
  13217. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  13218. */
  13219. rotationSphereSize: number;
  13220. /**
  13221. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  13222. */
  13223. scaleBoxSize: number;
  13224. /**
  13225. * 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)
  13226. */
  13227. fixedDragMeshScreenSize: boolean;
  13228. /**
  13229. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13230. */
  13231. fixedDragMeshScreenSizeDistanceFactor: number;
  13232. /**
  13233. * Fired when a rotation sphere or scale box is dragged
  13234. */
  13235. onDragStartObservable: Observable<{}>;
  13236. /**
  13237. * Fired when a scale box is dragged
  13238. */
  13239. onScaleBoxDragObservable: Observable<{}>;
  13240. /**
  13241. * Fired when a scale box drag is ended
  13242. */
  13243. onScaleBoxDragEndObservable: Observable<{}>;
  13244. /**
  13245. * Fired when a rotation sphere is dragged
  13246. */
  13247. onRotationSphereDragObservable: Observable<{}>;
  13248. /**
  13249. * Fired when a rotation sphere drag is ended
  13250. */
  13251. onRotationSphereDragEndObservable: Observable<{}>;
  13252. /**
  13253. * 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)
  13254. */
  13255. scalePivot: Nullable<Vector3>;
  13256. private _anchorMesh;
  13257. private _existingMeshScale;
  13258. private static _PivotCached;
  13259. private static _OldPivotPoint;
  13260. private static _PivotTranslation;
  13261. private static _PivotTmpVector;
  13262. /** @hidden */
  13263. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13264. /** @hidden */
  13265. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13266. /**
  13267. * Creates an BoundingBoxGizmo
  13268. * @param gizmoLayer The utility layer the gizmo will be added to
  13269. * @param color The color of the gizmo
  13270. */
  13271. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13272. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13273. private _selectNode;
  13274. /**
  13275. * Updates the bounding box information for the Gizmo
  13276. */
  13277. updateBoundingBox(): void;
  13278. private _updateRotationSpheres;
  13279. private _updateScaleBoxes;
  13280. /**
  13281. * Enables rotation on the specified axis and disables rotation on the others
  13282. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13283. */
  13284. setEnabledRotationAxis(axis: string): void;
  13285. /**
  13286. * Disposes of the gizmo
  13287. */
  13288. dispose(): void;
  13289. /**
  13290. * 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)
  13291. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13292. * @returns the bounding box mesh with the passed in mesh as a child
  13293. */
  13294. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13295. /**
  13296. * CustomMeshes are not supported by this gizmo
  13297. * @param mesh The mesh to replace the default mesh of the gizmo
  13298. */
  13299. setCustomMesh(mesh: Mesh): void;
  13300. }
  13301. }
  13302. declare module BABYLON {
  13303. /**
  13304. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13305. */
  13306. class Gizmo implements IDisposable {
  13307. /** The utility layer the gizmo will be added to */
  13308. gizmoLayer: UtilityLayerRenderer;
  13309. /**
  13310. * The root mesh of the gizmo
  13311. */
  13312. protected _rootMesh: Mesh;
  13313. private _attachedMesh;
  13314. /**
  13315. * Ratio for the scale of the gizmo (Default: 1)
  13316. */
  13317. scaleRatio: number;
  13318. private _tmpMatrix;
  13319. /**
  13320. * If a custom mesh has been set (Default: false)
  13321. */
  13322. protected _customMeshSet: boolean;
  13323. /**
  13324. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13325. * * When set, interactions will be enabled
  13326. */
  13327. attachedMesh: Nullable<AbstractMesh>;
  13328. /**
  13329. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13330. * @param mesh The mesh to replace the default mesh of the gizmo
  13331. */
  13332. setCustomMesh(mesh: Mesh): void;
  13333. /**
  13334. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13335. */
  13336. updateGizmoRotationToMatchAttachedMesh: boolean;
  13337. /**
  13338. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13339. */
  13340. updateGizmoPositionToMatchAttachedMesh: boolean;
  13341. /**
  13342. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13343. */
  13344. protected _updateScale: boolean;
  13345. protected _interactionsEnabled: boolean;
  13346. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13347. private _beforeRenderObserver;
  13348. /**
  13349. * Creates a gizmo
  13350. * @param gizmoLayer The utility layer the gizmo will be added to
  13351. */
  13352. constructor(
  13353. /** The utility layer the gizmo will be added to */
  13354. gizmoLayer?: UtilityLayerRenderer);
  13355. private _tempVector;
  13356. /**
  13357. * @hidden
  13358. * Updates the gizmo to match the attached mesh's position/rotation
  13359. */
  13360. protected _update(): void;
  13361. /**
  13362. * Disposes of the gizmo
  13363. */
  13364. dispose(): void;
  13365. }
  13366. }
  13367. declare module BABYLON {
  13368. /**
  13369. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13370. */
  13371. class GizmoManager implements IDisposable {
  13372. private scene;
  13373. /**
  13374. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13375. */
  13376. gizmos: {
  13377. positionGizmo: Nullable<PositionGizmo>;
  13378. rotationGizmo: Nullable<RotationGizmo>;
  13379. scaleGizmo: Nullable<ScaleGizmo>;
  13380. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13381. };
  13382. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  13383. clearGizmoOnEmptyPointerEvent: boolean;
  13384. /** Fires an event when the manager is attached to a mesh */
  13385. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  13386. private _gizmosEnabled;
  13387. private _pointerObserver;
  13388. private _attachedMesh;
  13389. private _boundingBoxColor;
  13390. private _defaultUtilityLayer;
  13391. private _defaultKeepDepthUtilityLayer;
  13392. /**
  13393. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13394. */
  13395. boundingBoxDragBehavior: SixDofDragBehavior;
  13396. /**
  13397. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13398. */
  13399. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13400. /**
  13401. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13402. */
  13403. usePointerToAttachGizmos: boolean;
  13404. /**
  13405. * Instatiates a gizmo manager
  13406. * @param scene the scene to overlay the gizmos on top of
  13407. */
  13408. constructor(scene: Scene);
  13409. /**
  13410. * Attaches a set of gizmos to the specified mesh
  13411. * @param mesh The mesh the gizmo's should be attached to
  13412. */
  13413. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13414. /**
  13415. * If the position gizmo is enabled
  13416. */
  13417. positionGizmoEnabled: boolean;
  13418. /**
  13419. * If the rotation gizmo is enabled
  13420. */
  13421. rotationGizmoEnabled: boolean;
  13422. /**
  13423. * If the scale gizmo is enabled
  13424. */
  13425. scaleGizmoEnabled: boolean;
  13426. /**
  13427. * If the boundingBox gizmo is enabled
  13428. */
  13429. boundingBoxGizmoEnabled: boolean;
  13430. /**
  13431. * Disposes of the gizmo manager
  13432. */
  13433. dispose(): void;
  13434. }
  13435. }
  13436. declare module BABYLON {
  13437. /**
  13438. * Single plane rotation gizmo
  13439. */
  13440. class PlaneRotationGizmo extends Gizmo {
  13441. /**
  13442. * Drag behavior responsible for the gizmos dragging interactions
  13443. */
  13444. dragBehavior: PointerDragBehavior;
  13445. private _pointerObserver;
  13446. /**
  13447. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13448. */
  13449. snapDistance: number;
  13450. /**
  13451. * Event that fires each time the gizmo snaps to a new location.
  13452. * * snapDistance is the the change in distance
  13453. */
  13454. onSnapObservable: Observable<{
  13455. snapDistance: number;
  13456. }>;
  13457. /**
  13458. * Creates a PlaneRotationGizmo
  13459. * @param gizmoLayer The utility layer the gizmo will be added to
  13460. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13461. * @param color The color of the gizmo
  13462. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13463. */
  13464. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13465. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13466. /**
  13467. * Disposes of the gizmo
  13468. */
  13469. dispose(): void;
  13470. }
  13471. }
  13472. declare module BABYLON {
  13473. /**
  13474. * Gizmo that enables dragging a mesh along 3 axis
  13475. */
  13476. class PositionGizmo extends Gizmo {
  13477. /**
  13478. * Internal gizmo used for interactions on the x axis
  13479. */
  13480. xGizmo: AxisDragGizmo;
  13481. /**
  13482. * Internal gizmo used for interactions on the y axis
  13483. */
  13484. yGizmo: AxisDragGizmo;
  13485. /**
  13486. * Internal gizmo used for interactions on the z axis
  13487. */
  13488. zGizmo: AxisDragGizmo;
  13489. /** Fires an event when any of it's sub gizmos are dragged */
  13490. onDragStartObservable: Observable<{}>;
  13491. /** Fires an event when any of it's sub gizmos are released from dragging */
  13492. onDragEndObservable: Observable<{}>;
  13493. attachedMesh: Nullable<AbstractMesh>;
  13494. /**
  13495. * Creates a PositionGizmo
  13496. * @param gizmoLayer The utility layer the gizmo will be added to
  13497. */
  13498. constructor(gizmoLayer?: UtilityLayerRenderer);
  13499. updateGizmoRotationToMatchAttachedMesh: boolean;
  13500. /**
  13501. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13502. */
  13503. snapDistance: number;
  13504. /**
  13505. * Ratio for the scale of the gizmo (Default: 1)
  13506. */
  13507. scaleRatio: number;
  13508. /**
  13509. * Disposes of the gizmo
  13510. */
  13511. dispose(): void;
  13512. /**
  13513. * CustomMeshes are not supported by this gizmo
  13514. * @param mesh The mesh to replace the default mesh of the gizmo
  13515. */
  13516. setCustomMesh(mesh: Mesh): void;
  13517. }
  13518. }
  13519. declare module BABYLON {
  13520. /**
  13521. * Gizmo that enables rotating a mesh along 3 axis
  13522. */
  13523. class RotationGizmo extends Gizmo {
  13524. /**
  13525. * Internal gizmo used for interactions on the x axis
  13526. */
  13527. xGizmo: PlaneRotationGizmo;
  13528. /**
  13529. * Internal gizmo used for interactions on the y axis
  13530. */
  13531. yGizmo: PlaneRotationGizmo;
  13532. /**
  13533. * Internal gizmo used for interactions on the z axis
  13534. */
  13535. zGizmo: PlaneRotationGizmo;
  13536. /** Fires an event when any of it's sub gizmos are dragged */
  13537. onDragStartObservable: Observable<{}>;
  13538. /** Fires an event when any of it's sub gizmos are released from dragging */
  13539. onDragEndObservable: Observable<{}>;
  13540. attachedMesh: Nullable<AbstractMesh>;
  13541. /**
  13542. * Creates a RotationGizmo
  13543. * @param gizmoLayer The utility layer the gizmo will be added to
  13544. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13545. */
  13546. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13547. updateGizmoRotationToMatchAttachedMesh: boolean;
  13548. /**
  13549. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13550. */
  13551. snapDistance: number;
  13552. /**
  13553. * Ratio for the scale of the gizmo (Default: 1)
  13554. */
  13555. scaleRatio: number;
  13556. /**
  13557. * Disposes of the gizmo
  13558. */
  13559. dispose(): void;
  13560. /**
  13561. * CustomMeshes are not supported by this gizmo
  13562. * @param mesh The mesh to replace the default mesh of the gizmo
  13563. */
  13564. setCustomMesh(mesh: Mesh): void;
  13565. }
  13566. }
  13567. declare module BABYLON {
  13568. /**
  13569. * Gizmo that enables scaling a mesh along 3 axis
  13570. */
  13571. class ScaleGizmo extends Gizmo {
  13572. /**
  13573. * Internal gizmo used for interactions on the x axis
  13574. */
  13575. xGizmo: AxisScaleGizmo;
  13576. /**
  13577. * Internal gizmo used for interactions on the y axis
  13578. */
  13579. yGizmo: AxisScaleGizmo;
  13580. /**
  13581. * Internal gizmo used for interactions on the z axis
  13582. */
  13583. zGizmo: AxisScaleGizmo;
  13584. /**
  13585. * Internal gizmo used to scale all axis equally
  13586. */
  13587. uniformScaleGizmo: AxisScaleGizmo;
  13588. /** Fires an event when any of it's sub gizmos are dragged */
  13589. onDragStartObservable: Observable<{}>;
  13590. /** Fires an event when any of it's sub gizmos are released from dragging */
  13591. onDragEndObservable: Observable<{}>;
  13592. attachedMesh: Nullable<AbstractMesh>;
  13593. /**
  13594. * Creates a ScaleGizmo
  13595. * @param gizmoLayer The utility layer the gizmo will be added to
  13596. */
  13597. constructor(gizmoLayer?: UtilityLayerRenderer);
  13598. updateGizmoRotationToMatchAttachedMesh: boolean;
  13599. /**
  13600. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13601. */
  13602. snapDistance: number;
  13603. /**
  13604. * Ratio for the scale of the gizmo (Default: 1)
  13605. */
  13606. scaleRatio: number;
  13607. /**
  13608. * Disposes of the gizmo
  13609. */
  13610. dispose(): void;
  13611. }
  13612. }
  13613. declare module BABYLON {
  13614. /**
  13615. * Represents the different options available during the creation of
  13616. * a Environment helper.
  13617. *
  13618. * This can control the default ground, skybox and image processing setup of your scene.
  13619. */
  13620. interface IEnvironmentHelperOptions {
  13621. /**
  13622. * Specifies wether or not to create a ground.
  13623. * True by default.
  13624. */
  13625. createGround: boolean;
  13626. /**
  13627. * Specifies the ground size.
  13628. * 15 by default.
  13629. */
  13630. groundSize: number;
  13631. /**
  13632. * The texture used on the ground for the main color.
  13633. * Comes from the BabylonJS CDN by default.
  13634. *
  13635. * Remarks: Can be either a texture or a url.
  13636. */
  13637. groundTexture: string | BaseTexture;
  13638. /**
  13639. * The color mixed in the ground texture by default.
  13640. * BabylonJS clearColor by default.
  13641. */
  13642. groundColor: Color3;
  13643. /**
  13644. * Specifies the ground opacity.
  13645. * 1 by default.
  13646. */
  13647. groundOpacity: number;
  13648. /**
  13649. * Enables the ground to receive shadows.
  13650. * True by default.
  13651. */
  13652. enableGroundShadow: boolean;
  13653. /**
  13654. * Helps preventing the shadow to be fully black on the ground.
  13655. * 0.5 by default.
  13656. */
  13657. groundShadowLevel: number;
  13658. /**
  13659. * Creates a mirror texture attach to the ground.
  13660. * false by default.
  13661. */
  13662. enableGroundMirror: boolean;
  13663. /**
  13664. * Specifies the ground mirror size ratio.
  13665. * 0.3 by default as the default kernel is 64.
  13666. */
  13667. groundMirrorSizeRatio: number;
  13668. /**
  13669. * Specifies the ground mirror blur kernel size.
  13670. * 64 by default.
  13671. */
  13672. groundMirrorBlurKernel: number;
  13673. /**
  13674. * Specifies the ground mirror visibility amount.
  13675. * 1 by default
  13676. */
  13677. groundMirrorAmount: number;
  13678. /**
  13679. * Specifies the ground mirror reflectance weight.
  13680. * This uses the standard weight of the background material to setup the fresnel effect
  13681. * of the mirror.
  13682. * 1 by default.
  13683. */
  13684. groundMirrorFresnelWeight: number;
  13685. /**
  13686. * Specifies the ground mirror Falloff distance.
  13687. * This can helps reducing the size of the reflection.
  13688. * 0 by Default.
  13689. */
  13690. groundMirrorFallOffDistance: number;
  13691. /**
  13692. * Specifies the ground mirror texture type.
  13693. * Unsigned Int by Default.
  13694. */
  13695. groundMirrorTextureType: number;
  13696. /**
  13697. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13698. * the shown objects.
  13699. */
  13700. groundYBias: number;
  13701. /**
  13702. * Specifies wether or not to create a skybox.
  13703. * True by default.
  13704. */
  13705. createSkybox: boolean;
  13706. /**
  13707. * Specifies the skybox size.
  13708. * 20 by default.
  13709. */
  13710. skyboxSize: number;
  13711. /**
  13712. * The texture used on the skybox for the main color.
  13713. * Comes from the BabylonJS CDN by default.
  13714. *
  13715. * Remarks: Can be either a texture or a url.
  13716. */
  13717. skyboxTexture: string | BaseTexture;
  13718. /**
  13719. * The color mixed in the skybox texture by default.
  13720. * BabylonJS clearColor by default.
  13721. */
  13722. skyboxColor: Color3;
  13723. /**
  13724. * The background rotation around the Y axis of the scene.
  13725. * This helps aligning the key lights of your scene with the background.
  13726. * 0 by default.
  13727. */
  13728. backgroundYRotation: number;
  13729. /**
  13730. * Compute automatically the size of the elements to best fit with the scene.
  13731. */
  13732. sizeAuto: boolean;
  13733. /**
  13734. * Default position of the rootMesh if autoSize is not true.
  13735. */
  13736. rootPosition: Vector3;
  13737. /**
  13738. * Sets up the image processing in the scene.
  13739. * true by default.
  13740. */
  13741. setupImageProcessing: boolean;
  13742. /**
  13743. * The texture used as your environment texture in the scene.
  13744. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13745. *
  13746. * Remarks: Can be either a texture or a url.
  13747. */
  13748. environmentTexture: string | BaseTexture;
  13749. /**
  13750. * The value of the exposure to apply to the scene.
  13751. * 0.6 by default if setupImageProcessing is true.
  13752. */
  13753. cameraExposure: number;
  13754. /**
  13755. * The value of the contrast to apply to the scene.
  13756. * 1.6 by default if setupImageProcessing is true.
  13757. */
  13758. cameraContrast: number;
  13759. /**
  13760. * Specifies wether or not tonemapping should be enabled in the scene.
  13761. * true by default if setupImageProcessing is true.
  13762. */
  13763. toneMappingEnabled: boolean;
  13764. }
  13765. /**
  13766. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13767. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13768. * It also helps with the default setup of your imageProcessing configuration.
  13769. */
  13770. class EnvironmentHelper {
  13771. /**
  13772. * Default ground texture URL.
  13773. */
  13774. private static _groundTextureCDNUrl;
  13775. /**
  13776. * Default skybox texture URL.
  13777. */
  13778. private static _skyboxTextureCDNUrl;
  13779. /**
  13780. * Default environment texture URL.
  13781. */
  13782. private static _environmentTextureCDNUrl;
  13783. /**
  13784. * Creates the default options for the helper.
  13785. */
  13786. private static _getDefaultOptions;
  13787. private _rootMesh;
  13788. /**
  13789. * Gets the root mesh created by the helper.
  13790. */
  13791. readonly rootMesh: Mesh;
  13792. private _skybox;
  13793. /**
  13794. * Gets the skybox created by the helper.
  13795. */
  13796. readonly skybox: Nullable<Mesh>;
  13797. private _skyboxTexture;
  13798. /**
  13799. * Gets the skybox texture created by the helper.
  13800. */
  13801. readonly skyboxTexture: Nullable<BaseTexture>;
  13802. private _skyboxMaterial;
  13803. /**
  13804. * Gets the skybox material created by the helper.
  13805. */
  13806. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13807. private _ground;
  13808. /**
  13809. * Gets the ground mesh created by the helper.
  13810. */
  13811. readonly ground: Nullable<Mesh>;
  13812. private _groundTexture;
  13813. /**
  13814. * Gets the ground texture created by the helper.
  13815. */
  13816. readonly groundTexture: Nullable<BaseTexture>;
  13817. private _groundMirror;
  13818. /**
  13819. * Gets the ground mirror created by the helper.
  13820. */
  13821. readonly groundMirror: Nullable<MirrorTexture>;
  13822. /**
  13823. * Gets the ground mirror render list to helps pushing the meshes
  13824. * you wish in the ground reflection.
  13825. */
  13826. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13827. private _groundMaterial;
  13828. /**
  13829. * Gets the ground material created by the helper.
  13830. */
  13831. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13832. /**
  13833. * Stores the creation options.
  13834. */
  13835. private readonly _scene;
  13836. private _options;
  13837. /**
  13838. * This observable will be notified with any error during the creation of the environment,
  13839. * mainly texture creation errors.
  13840. */
  13841. onErrorObservable: Observable<{
  13842. message?: string;
  13843. exception?: any;
  13844. }>;
  13845. /**
  13846. * constructor
  13847. * @param options
  13848. * @param scene The scene to add the material to
  13849. */
  13850. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13851. /**
  13852. * Updates the background according to the new options
  13853. * @param options
  13854. */
  13855. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13856. /**
  13857. * Sets the primary color of all the available elements.
  13858. * @param color the main color to affect to the ground and the background
  13859. */
  13860. setMainColor(color: Color3): void;
  13861. /**
  13862. * Setup the image processing according to the specified options.
  13863. */
  13864. private _setupImageProcessing;
  13865. /**
  13866. * Setup the environment texture according to the specified options.
  13867. */
  13868. private _setupEnvironmentTexture;
  13869. /**
  13870. * Setup the background according to the specified options.
  13871. */
  13872. private _setupBackground;
  13873. /**
  13874. * Get the scene sizes according to the setup.
  13875. */
  13876. private _getSceneSize;
  13877. /**
  13878. * Setup the ground according to the specified options.
  13879. */
  13880. private _setupGround;
  13881. /**
  13882. * Setup the ground material according to the specified options.
  13883. */
  13884. private _setupGroundMaterial;
  13885. /**
  13886. * Setup the ground diffuse texture according to the specified options.
  13887. */
  13888. private _setupGroundDiffuseTexture;
  13889. /**
  13890. * Setup the ground mirror texture according to the specified options.
  13891. */
  13892. private _setupGroundMirrorTexture;
  13893. /**
  13894. * Setup the ground to receive the mirror texture.
  13895. */
  13896. private _setupMirrorInGroundMaterial;
  13897. /**
  13898. * Setup the skybox according to the specified options.
  13899. */
  13900. private _setupSkybox;
  13901. /**
  13902. * Setup the skybox material according to the specified options.
  13903. */
  13904. private _setupSkyboxMaterial;
  13905. /**
  13906. * Setup the skybox reflection texture according to the specified options.
  13907. */
  13908. private _setupSkyboxReflectionTexture;
  13909. private _errorHandler;
  13910. /**
  13911. * Dispose all the elements created by the Helper.
  13912. */
  13913. dispose(): void;
  13914. }
  13915. }
  13916. declare module BABYLON {
  13917. /**
  13918. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13919. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13920. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13921. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13922. */
  13923. class PhotoDome extends TransformNode {
  13924. private _useDirectMapping;
  13925. /**
  13926. * The texture being displayed on the sphere
  13927. */
  13928. protected _photoTexture: Texture;
  13929. /**
  13930. * Gets or sets the texture being displayed on the sphere
  13931. */
  13932. photoTexture: Texture;
  13933. /**
  13934. * Observable raised when an error occured while loading the 360 image
  13935. */
  13936. onLoadErrorObservable: Observable<string>;
  13937. /**
  13938. * The skybox material
  13939. */
  13940. protected _material: BackgroundMaterial;
  13941. /**
  13942. * The surface used for the skybox
  13943. */
  13944. protected _mesh: Mesh;
  13945. /**
  13946. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13947. * Also see the options.resolution property.
  13948. */
  13949. fovMultiplier: number;
  13950. /**
  13951. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13952. * @param name Element's name, child elements will append suffixes for their own names.
  13953. * @param urlsOfPhoto defines the url of the photo to display
  13954. * @param options defines an object containing optional or exposed sub element properties
  13955. * @param onError defines a callback called when an error occured while loading the texture
  13956. */
  13957. constructor(name: string, urlOfPhoto: string, options: {
  13958. resolution?: number;
  13959. size?: number;
  13960. useDirectMapping?: boolean;
  13961. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13962. /**
  13963. * Releases resources associated with this node.
  13964. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13965. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13966. */
  13967. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13968. }
  13969. }
  13970. declare module BABYLON {
  13971. interface Scene {
  13972. /**
  13973. * Creates a default light for the scene.
  13974. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13975. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13976. */
  13977. createDefaultLight(replace?: boolean): void;
  13978. /**
  13979. * Creates a default camera for the scene.
  13980. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13981. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13982. * @param replace has default false, when true replaces the active camera in the scene
  13983. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13984. */
  13985. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13986. /**
  13987. * Creates a default camera and a default light.
  13988. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13989. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13990. * @param replace has the default false, when true replaces the active camera/light in the scene
  13991. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13992. */
  13993. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13994. /**
  13995. * Creates a new sky box
  13996. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13997. * @param environmentTexture defines the texture to use as environment texture
  13998. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13999. * @param scale defines the overall scale of the skybox
  14000. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  14001. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  14002. * @returns a new mesh holding the sky box
  14003. */
  14004. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  14005. /**
  14006. * Creates a new environment
  14007. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  14008. * @param options defines the options you can use to configure the environment
  14009. * @returns the new EnvironmentHelper
  14010. */
  14011. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  14012. /**
  14013. * Creates a new VREXperienceHelper
  14014. * @see http://doc.babylonjs.com/how_to/webvr_helper
  14015. * @param webVROptions defines the options used to create the new VREXperienceHelper
  14016. * @returns a new VREXperienceHelper
  14017. */
  14018. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  14019. /**
  14020. * Creates a new XREXperienceHelper
  14021. * @see http://doc.babylonjs.com/how_to/webxr
  14022. * @returns a promise for a new XREXperienceHelper
  14023. */
  14024. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  14025. }
  14026. }
  14027. declare module BABYLON {
  14028. /**
  14029. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  14030. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  14031. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  14032. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  14033. */
  14034. class VideoDome extends TransformNode {
  14035. private _useDirectMapping;
  14036. /**
  14037. * The video texture being displayed on the sphere
  14038. */
  14039. protected _videoTexture: VideoTexture;
  14040. /**
  14041. * Gets the video texture being displayed on the sphere
  14042. */
  14043. readonly videoTexture: VideoTexture;
  14044. /**
  14045. * The skybox material
  14046. */
  14047. protected _material: BackgroundMaterial;
  14048. /**
  14049. * The surface used for the skybox
  14050. */
  14051. protected _mesh: Mesh;
  14052. /**
  14053. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  14054. * Also see the options.resolution property.
  14055. */
  14056. fovMultiplier: number;
  14057. /**
  14058. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  14059. * @param name Element's name, child elements will append suffixes for their own names.
  14060. * @param urlsOrVideo defines the url(s) or the video element to use
  14061. * @param options An object containing optional or exposed sub element properties
  14062. */
  14063. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  14064. resolution?: number;
  14065. clickToPlay?: boolean;
  14066. autoPlay?: boolean;
  14067. loop?: boolean;
  14068. size?: number;
  14069. poster?: string;
  14070. useDirectMapping?: boolean;
  14071. }, scene: Scene);
  14072. /**
  14073. * Releases resources associated with this node.
  14074. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14075. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14076. */
  14077. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14078. }
  14079. }
  14080. declare module BABYLON {
  14081. /**
  14082. * This class can be used to get instrumentation data from a Babylon engine
  14083. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14084. */
  14085. class EngineInstrumentation implements IDisposable {
  14086. /**
  14087. * Define the instrumented engine.
  14088. */
  14089. engine: Engine;
  14090. private _captureGPUFrameTime;
  14091. private _gpuFrameTimeToken;
  14092. private _gpuFrameTime;
  14093. private _captureShaderCompilationTime;
  14094. private _shaderCompilationTime;
  14095. private _onBeginFrameObserver;
  14096. private _onEndFrameObserver;
  14097. private _onBeforeShaderCompilationObserver;
  14098. private _onAfterShaderCompilationObserver;
  14099. /**
  14100. * Gets the perf counter used for GPU frame time
  14101. */
  14102. readonly gpuFrameTimeCounter: PerfCounter;
  14103. /**
  14104. * Gets the GPU frame time capture status
  14105. */
  14106. /**
  14107. * Enable or disable the GPU frame time capture
  14108. */
  14109. captureGPUFrameTime: boolean;
  14110. /**
  14111. * Gets the perf counter used for shader compilation time
  14112. */
  14113. readonly shaderCompilationTimeCounter: PerfCounter;
  14114. /**
  14115. * Gets the shader compilation time capture status
  14116. */
  14117. /**
  14118. * Enable or disable the shader compilation time capture
  14119. */
  14120. captureShaderCompilationTime: boolean;
  14121. /**
  14122. * Instantiates a new engine instrumentation.
  14123. * This class can be used to get instrumentation data from a Babylon engine
  14124. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14125. * @param engine Defines the engine to instrument
  14126. */
  14127. constructor(
  14128. /**
  14129. * Define the instrumented engine.
  14130. */
  14131. engine: Engine);
  14132. /**
  14133. * Dispose and release associated resources.
  14134. */
  14135. dispose(): void;
  14136. }
  14137. }
  14138. declare module BABYLON {
  14139. /**
  14140. * This class can be used to get instrumentation data from a Babylon engine
  14141. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14142. */
  14143. class SceneInstrumentation implements IDisposable {
  14144. /**
  14145. * Defines the scene to instrument
  14146. */
  14147. scene: Scene;
  14148. private _captureActiveMeshesEvaluationTime;
  14149. private _activeMeshesEvaluationTime;
  14150. private _captureRenderTargetsRenderTime;
  14151. private _renderTargetsRenderTime;
  14152. private _captureFrameTime;
  14153. private _frameTime;
  14154. private _captureRenderTime;
  14155. private _renderTime;
  14156. private _captureInterFrameTime;
  14157. private _interFrameTime;
  14158. private _captureParticlesRenderTime;
  14159. private _particlesRenderTime;
  14160. private _captureSpritesRenderTime;
  14161. private _spritesRenderTime;
  14162. private _capturePhysicsTime;
  14163. private _physicsTime;
  14164. private _captureAnimationsTime;
  14165. private _animationsTime;
  14166. private _captureCameraRenderTime;
  14167. private _cameraRenderTime;
  14168. private _onBeforeActiveMeshesEvaluationObserver;
  14169. private _onAfterActiveMeshesEvaluationObserver;
  14170. private _onBeforeRenderTargetsRenderObserver;
  14171. private _onAfterRenderTargetsRenderObserver;
  14172. private _onAfterRenderObserver;
  14173. private _onBeforeDrawPhaseObserver;
  14174. private _onAfterDrawPhaseObserver;
  14175. private _onBeforeAnimationsObserver;
  14176. private _onBeforeParticlesRenderingObserver;
  14177. private _onAfterParticlesRenderingObserver;
  14178. private _onBeforeSpritesRenderingObserver;
  14179. private _onAfterSpritesRenderingObserver;
  14180. private _onBeforePhysicsObserver;
  14181. private _onAfterPhysicsObserver;
  14182. private _onAfterAnimationsObserver;
  14183. private _onBeforeCameraRenderObserver;
  14184. private _onAfterCameraRenderObserver;
  14185. /**
  14186. * Gets the perf counter used for active meshes evaluation time
  14187. */
  14188. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  14189. /**
  14190. * Gets the active meshes evaluation time capture status
  14191. */
  14192. /**
  14193. * Enable or disable the active meshes evaluation time capture
  14194. */
  14195. captureActiveMeshesEvaluationTime: boolean;
  14196. /**
  14197. * Gets the perf counter used for render targets render time
  14198. */
  14199. readonly renderTargetsRenderTimeCounter: PerfCounter;
  14200. /**
  14201. * Gets the render targets render time capture status
  14202. */
  14203. /**
  14204. * Enable or disable the render targets render time capture
  14205. */
  14206. captureRenderTargetsRenderTime: boolean;
  14207. /**
  14208. * Gets the perf counter used for particles render time
  14209. */
  14210. readonly particlesRenderTimeCounter: PerfCounter;
  14211. /**
  14212. * Gets the particles render time capture status
  14213. */
  14214. /**
  14215. * Enable or disable the particles render time capture
  14216. */
  14217. captureParticlesRenderTime: boolean;
  14218. /**
  14219. * Gets the perf counter used for sprites render time
  14220. */
  14221. readonly spritesRenderTimeCounter: PerfCounter;
  14222. /**
  14223. * Gets the sprites render time capture status
  14224. */
  14225. /**
  14226. * Enable or disable the sprites render time capture
  14227. */
  14228. captureSpritesRenderTime: boolean;
  14229. /**
  14230. * Gets the perf counter used for physics time
  14231. */
  14232. readonly physicsTimeCounter: PerfCounter;
  14233. /**
  14234. * Gets the physics time capture status
  14235. */
  14236. /**
  14237. * Enable or disable the physics time capture
  14238. */
  14239. capturePhysicsTime: boolean;
  14240. /**
  14241. * Gets the perf counter used for animations time
  14242. */
  14243. readonly animationsTimeCounter: PerfCounter;
  14244. /**
  14245. * Gets the animations time capture status
  14246. */
  14247. /**
  14248. * Enable or disable the animations time capture
  14249. */
  14250. captureAnimationsTime: boolean;
  14251. /**
  14252. * Gets the perf counter used for frame time capture
  14253. */
  14254. readonly frameTimeCounter: PerfCounter;
  14255. /**
  14256. * Gets the frame time capture status
  14257. */
  14258. /**
  14259. * Enable or disable the frame time capture
  14260. */
  14261. captureFrameTime: boolean;
  14262. /**
  14263. * Gets the perf counter used for inter-frames time capture
  14264. */
  14265. readonly interFrameTimeCounter: PerfCounter;
  14266. /**
  14267. * Gets the inter-frames time capture status
  14268. */
  14269. /**
  14270. * Enable or disable the inter-frames time capture
  14271. */
  14272. captureInterFrameTime: boolean;
  14273. /**
  14274. * Gets the perf counter used for render time capture
  14275. */
  14276. readonly renderTimeCounter: PerfCounter;
  14277. /**
  14278. * Gets the render time capture status
  14279. */
  14280. /**
  14281. * Enable or disable the render time capture
  14282. */
  14283. captureRenderTime: boolean;
  14284. /**
  14285. * Gets the perf counter used for camera render time capture
  14286. */
  14287. readonly cameraRenderTimeCounter: PerfCounter;
  14288. /**
  14289. * Gets the camera render time capture status
  14290. */
  14291. /**
  14292. * Enable or disable the camera render time capture
  14293. */
  14294. captureCameraRenderTime: boolean;
  14295. /**
  14296. * Gets the perf counter used for draw calls
  14297. */
  14298. readonly drawCallsCounter: PerfCounter;
  14299. /**
  14300. * Gets the perf counter used for texture collisions
  14301. */
  14302. readonly textureCollisionsCounter: PerfCounter;
  14303. /**
  14304. * Instantiates a new scene instrumentation.
  14305. * This class can be used to get instrumentation data from a Babylon engine
  14306. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14307. * @param scene Defines the scene to instrument
  14308. */
  14309. constructor(
  14310. /**
  14311. * Defines the scene to instrument
  14312. */
  14313. scene: Scene);
  14314. /**
  14315. * Dispose and release associated resources.
  14316. */
  14317. dispose(): void;
  14318. }
  14319. }
  14320. declare module BABYLON {
  14321. /**
  14322. * @hidden
  14323. **/
  14324. class _TimeToken {
  14325. _startTimeQuery: Nullable<WebGLQuery>;
  14326. _endTimeQuery: Nullable<WebGLQuery>;
  14327. _timeElapsedQuery: Nullable<WebGLQuery>;
  14328. _timeElapsedQueryEnded: boolean;
  14329. }
  14330. }
  14331. declare module BABYLON {
  14332. /**
  14333. * Effect layer options. This helps customizing the behaviour
  14334. * of the effect layer.
  14335. */
  14336. interface IEffectLayerOptions {
  14337. /**
  14338. * Multiplication factor apply to the canvas size to compute the render target size
  14339. * used to generated the objects (the smaller the faster).
  14340. */
  14341. mainTextureRatio: number;
  14342. /**
  14343. * Enforces a fixed size texture to ensure effect stability across devices.
  14344. */
  14345. mainTextureFixedSize?: number;
  14346. /**
  14347. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14348. */
  14349. alphaBlendingMode: number;
  14350. /**
  14351. * The camera attached to the layer.
  14352. */
  14353. camera: Nullable<Camera>;
  14354. /**
  14355. * The rendering group to draw the layer in.
  14356. */
  14357. renderingGroupId: number;
  14358. }
  14359. /**
  14360. * The effect layer Helps adding post process effect blended with the main pass.
  14361. *
  14362. * This can be for instance use to generate glow or higlight effects on the scene.
  14363. *
  14364. * The effect layer class can not be used directly and is intented to inherited from to be
  14365. * customized per effects.
  14366. */
  14367. abstract class EffectLayer {
  14368. private _vertexBuffers;
  14369. private _indexBuffer;
  14370. private _cachedDefines;
  14371. private _effectLayerMapGenerationEffect;
  14372. private _effectLayerOptions;
  14373. private _mergeEffect;
  14374. protected _scene: Scene;
  14375. protected _engine: Engine;
  14376. protected _maxSize: number;
  14377. protected _mainTextureDesiredSize: ISize;
  14378. protected _mainTexture: RenderTargetTexture;
  14379. protected _shouldRender: boolean;
  14380. protected _postProcesses: PostProcess[];
  14381. protected _textures: BaseTexture[];
  14382. protected _emissiveTextureAndColor: {
  14383. texture: Nullable<BaseTexture>;
  14384. color: Color4;
  14385. };
  14386. /**
  14387. * The name of the layer
  14388. */
  14389. name: string;
  14390. /**
  14391. * The clear color of the texture used to generate the glow map.
  14392. */
  14393. neutralColor: Color4;
  14394. /**
  14395. * Specifies wether the highlight layer is enabled or not.
  14396. */
  14397. isEnabled: boolean;
  14398. /**
  14399. * Gets the camera attached to the layer.
  14400. */
  14401. readonly camera: Nullable<Camera>;
  14402. /**
  14403. * Gets the rendering group id the layer should render in.
  14404. */
  14405. readonly renderingGroupId: number;
  14406. /**
  14407. * An event triggered when the effect layer has been disposed.
  14408. */
  14409. onDisposeObservable: Observable<EffectLayer>;
  14410. /**
  14411. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14412. */
  14413. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14414. /**
  14415. * An event triggered when the generated texture is being merged in the scene.
  14416. */
  14417. onBeforeComposeObservable: Observable<EffectLayer>;
  14418. /**
  14419. * An event triggered when the generated texture has been merged in the scene.
  14420. */
  14421. onAfterComposeObservable: Observable<EffectLayer>;
  14422. /**
  14423. * An event triggered when the efffect layer changes its size.
  14424. */
  14425. onSizeChangedObservable: Observable<EffectLayer>;
  14426. /**
  14427. * Instantiates a new effect Layer and references it in the scene.
  14428. * @param name The name of the layer
  14429. * @param scene The scene to use the layer in
  14430. */
  14431. constructor(
  14432. /** The Friendly of the effect in the scene */
  14433. name: string, scene: Scene);
  14434. /**
  14435. * Get the effect name of the layer.
  14436. * @return The effect name
  14437. */
  14438. abstract getEffectName(): string;
  14439. /**
  14440. * Checks for the readiness of the element composing the layer.
  14441. * @param subMesh the mesh to check for
  14442. * @param useInstances specify wether or not to use instances to render the mesh
  14443. * @return true if ready otherwise, false
  14444. */
  14445. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14446. /**
  14447. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14448. * @returns true if the effect requires stencil during the main canvas render pass.
  14449. */
  14450. abstract needStencil(): boolean;
  14451. /**
  14452. * Create the merge effect. This is the shader use to blit the information back
  14453. * to the main canvas at the end of the scene rendering.
  14454. * @returns The effect containing the shader used to merge the effect on the main canvas
  14455. */
  14456. protected abstract _createMergeEffect(): Effect;
  14457. /**
  14458. * Creates the render target textures and post processes used in the effect layer.
  14459. */
  14460. protected abstract _createTextureAndPostProcesses(): void;
  14461. /**
  14462. * Implementation specific of rendering the generating effect on the main canvas.
  14463. * @param effect The effect used to render through
  14464. */
  14465. protected abstract _internalRender(effect: Effect): void;
  14466. /**
  14467. * Sets the required values for both the emissive texture and and the main color.
  14468. */
  14469. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14470. /**
  14471. * Free any resources and references associated to a mesh.
  14472. * Internal use
  14473. * @param mesh The mesh to free.
  14474. */
  14475. abstract _disposeMesh(mesh: Mesh): void;
  14476. /**
  14477. * Serializes this layer (Glow or Highlight for example)
  14478. * @returns a serialized layer object
  14479. */
  14480. abstract serialize?(): any;
  14481. /**
  14482. * Initializes the effect layer with the required options.
  14483. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14484. */
  14485. protected _init(options: Partial<IEffectLayerOptions>): void;
  14486. /**
  14487. * Generates the index buffer of the full screen quad blending to the main canvas.
  14488. */
  14489. private _generateIndexBuffer;
  14490. /**
  14491. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14492. */
  14493. private _genrateVertexBuffer;
  14494. /**
  14495. * Sets the main texture desired size which is the closest power of two
  14496. * of the engine canvas size.
  14497. */
  14498. private _setMainTextureSize;
  14499. /**
  14500. * Creates the main texture for the effect layer.
  14501. */
  14502. protected _createMainTexture(): void;
  14503. /**
  14504. * Checks for the readiness of the element composing the layer.
  14505. * @param subMesh the mesh to check for
  14506. * @param useInstances specify wether or not to use instances to render the mesh
  14507. * @param emissiveTexture the associated emissive texture used to generate the glow
  14508. * @return true if ready otherwise, false
  14509. */
  14510. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14511. /**
  14512. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14513. */
  14514. render(): void;
  14515. /**
  14516. * Determine if a given mesh will be used in the current effect.
  14517. * @param mesh mesh to test
  14518. * @returns true if the mesh will be used
  14519. */
  14520. hasMesh(mesh: AbstractMesh): boolean;
  14521. /**
  14522. * Returns true if the layer contains information to display, otherwise false.
  14523. * @returns true if the glow layer should be rendered
  14524. */
  14525. shouldRender(): boolean;
  14526. /**
  14527. * Returns true if the mesh should render, otherwise false.
  14528. * @param mesh The mesh to render
  14529. * @returns true if it should render otherwise false
  14530. */
  14531. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14532. /**
  14533. * Returns true if the mesh should render, otherwise false.
  14534. * @param mesh The mesh to render
  14535. * @returns true if it should render otherwise false
  14536. */
  14537. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14538. /**
  14539. * Renders the submesh passed in parameter to the generation map.
  14540. */
  14541. protected _renderSubMesh(subMesh: SubMesh): void;
  14542. /**
  14543. * Rebuild the required buffers.
  14544. * @hidden Internal use only.
  14545. */
  14546. _rebuild(): void;
  14547. /**
  14548. * Dispose only the render target textures and post process.
  14549. */
  14550. private _disposeTextureAndPostProcesses;
  14551. /**
  14552. * Dispose the highlight layer and free resources.
  14553. */
  14554. dispose(): void;
  14555. /**
  14556. * Gets the class name of the effect layer
  14557. * @returns the string with the class name of the effect layer
  14558. */
  14559. getClassName(): string;
  14560. /**
  14561. * Creates an effect layer from parsed effect layer data
  14562. * @param parsedEffectLayer defines effect layer data
  14563. * @param scene defines the current scene
  14564. * @param rootUrl defines the root URL containing the effect layer information
  14565. * @returns a parsed effect Layer
  14566. */
  14567. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14568. }
  14569. }
  14570. declare module BABYLON {
  14571. interface AbstractScene {
  14572. /**
  14573. * The list of effect layers (highlights/glow) added to the scene
  14574. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14575. * @see http://doc.babylonjs.com/how_to/glow_layer
  14576. */
  14577. effectLayers: Array<EffectLayer>;
  14578. /**
  14579. * Removes the given effect layer from this scene.
  14580. * @param toRemove defines the effect layer to remove
  14581. * @returns the index of the removed effect layer
  14582. */
  14583. removeEffectLayer(toRemove: EffectLayer): number;
  14584. /**
  14585. * Adds the given effect layer to this scene
  14586. * @param newEffectLayer defines the effect layer to add
  14587. */
  14588. addEffectLayer(newEffectLayer: EffectLayer): void;
  14589. }
  14590. /**
  14591. * Defines the layer scene component responsible to manage any effect layers
  14592. * in a given scene.
  14593. */
  14594. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14595. /**
  14596. * The component name helpfull to identify the component in the list of scene components.
  14597. */
  14598. readonly name: string;
  14599. /**
  14600. * The scene the component belongs to.
  14601. */
  14602. scene: Scene;
  14603. private _engine;
  14604. private _renderEffects;
  14605. private _needStencil;
  14606. private _previousStencilState;
  14607. /**
  14608. * Creates a new instance of the component for the given scene
  14609. * @param scene Defines the scene to register the component in
  14610. */
  14611. constructor(scene: Scene);
  14612. /**
  14613. * Registers the component in a given scene
  14614. */
  14615. register(): void;
  14616. /**
  14617. * Rebuilds the elements related to this component in case of
  14618. * context lost for instance.
  14619. */
  14620. rebuild(): void;
  14621. /**
  14622. * Serializes the component data to the specified json object
  14623. * @param serializationObject The object to serialize to
  14624. */
  14625. serialize(serializationObject: any): void;
  14626. /**
  14627. * Adds all the element from the container to the scene
  14628. * @param container the container holding the elements
  14629. */
  14630. addFromContainer(container: AbstractScene): void;
  14631. /**
  14632. * Removes all the elements in the container from the scene
  14633. * @param container contains the elements to remove
  14634. */
  14635. removeFromContainer(container: AbstractScene): void;
  14636. /**
  14637. * Disposes the component and the associated ressources.
  14638. */
  14639. dispose(): void;
  14640. private _isReadyForMesh;
  14641. private _renderMainTexture;
  14642. private _setStencil;
  14643. private _setStencilBack;
  14644. private _draw;
  14645. private _drawCamera;
  14646. private _drawRenderingGroup;
  14647. }
  14648. }
  14649. declare module BABYLON {
  14650. interface AbstractScene {
  14651. /**
  14652. * Return a the first highlight layer of the scene with a given name.
  14653. * @param name The name of the highlight layer to look for.
  14654. * @return The highlight layer if found otherwise null.
  14655. */
  14656. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14657. }
  14658. /**
  14659. * Glow layer options. This helps customizing the behaviour
  14660. * of the glow layer.
  14661. */
  14662. interface IGlowLayerOptions {
  14663. /**
  14664. * Multiplication factor apply to the canvas size to compute the render target size
  14665. * used to generated the glowing objects (the smaller the faster).
  14666. */
  14667. mainTextureRatio: number;
  14668. /**
  14669. * Enforces a fixed size texture to ensure resize independant blur.
  14670. */
  14671. mainTextureFixedSize?: number;
  14672. /**
  14673. * How big is the kernel of the blur texture.
  14674. */
  14675. blurKernelSize: number;
  14676. /**
  14677. * The camera attached to the layer.
  14678. */
  14679. camera: Nullable<Camera>;
  14680. /**
  14681. * Enable MSAA by chosing the number of samples.
  14682. */
  14683. mainTextureSamples?: number;
  14684. /**
  14685. * The rendering group to draw the layer in.
  14686. */
  14687. renderingGroupId: number;
  14688. }
  14689. /**
  14690. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14691. *
  14692. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14693. * glowy meshes to your scene.
  14694. *
  14695. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14696. */
  14697. class GlowLayer extends EffectLayer {
  14698. /**
  14699. * Effect Name of the layer.
  14700. */
  14701. static readonly EffectName: string;
  14702. /**
  14703. * The default blur kernel size used for the glow.
  14704. */
  14705. static DefaultBlurKernelSize: number;
  14706. /**
  14707. * The default texture size ratio used for the glow.
  14708. */
  14709. static DefaultTextureRatio: number;
  14710. /**
  14711. * Sets the kernel size of the blur.
  14712. */
  14713. /**
  14714. * Gets the kernel size of the blur.
  14715. */
  14716. blurKernelSize: number;
  14717. /**
  14718. * Sets the glow intensity.
  14719. */
  14720. /**
  14721. * Gets the glow intensity.
  14722. */
  14723. intensity: number;
  14724. private _options;
  14725. private _intensity;
  14726. private _horizontalBlurPostprocess1;
  14727. private _verticalBlurPostprocess1;
  14728. private _horizontalBlurPostprocess2;
  14729. private _verticalBlurPostprocess2;
  14730. private _blurTexture1;
  14731. private _blurTexture2;
  14732. private _postProcesses1;
  14733. private _postProcesses2;
  14734. private _includedOnlyMeshes;
  14735. private _excludedMeshes;
  14736. /**
  14737. * Callback used to let the user override the color selection on a per mesh basis
  14738. */
  14739. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14740. /**
  14741. * Callback used to let the user override the texture selection on a per mesh basis
  14742. */
  14743. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14744. /**
  14745. * Instantiates a new glow Layer and references it to the scene.
  14746. * @param name The name of the layer
  14747. * @param scene The scene to use the layer in
  14748. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14749. */
  14750. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14751. /**
  14752. * Get the effect name of the layer.
  14753. * @return The effect name
  14754. */
  14755. getEffectName(): string;
  14756. /**
  14757. * Create the merge effect. This is the shader use to blit the information back
  14758. * to the main canvas at the end of the scene rendering.
  14759. */
  14760. protected _createMergeEffect(): Effect;
  14761. /**
  14762. * Creates the render target textures and post processes used in the glow layer.
  14763. */
  14764. protected _createTextureAndPostProcesses(): void;
  14765. /**
  14766. * Checks for the readiness of the element composing the layer.
  14767. * @param subMesh the mesh to check for
  14768. * @param useInstances specify wether or not to use instances to render the mesh
  14769. * @param emissiveTexture the associated emissive texture used to generate the glow
  14770. * @return true if ready otherwise, false
  14771. */
  14772. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14773. /**
  14774. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14775. */
  14776. needStencil(): boolean;
  14777. /**
  14778. * Implementation specific of rendering the generating effect on the main canvas.
  14779. * @param effect The effect used to render through
  14780. */
  14781. protected _internalRender(effect: Effect): void;
  14782. /**
  14783. * Sets the required values for both the emissive texture and and the main color.
  14784. */
  14785. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14786. /**
  14787. * Returns true if the mesh should render, otherwise false.
  14788. * @param mesh The mesh to render
  14789. * @returns true if it should render otherwise false
  14790. */
  14791. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14792. /**
  14793. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14794. * @param mesh The mesh to exclude from the glow layer
  14795. */
  14796. addExcludedMesh(mesh: Mesh): void;
  14797. /**
  14798. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14799. * @param mesh The mesh to remove
  14800. */
  14801. removeExcludedMesh(mesh: Mesh): void;
  14802. /**
  14803. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14804. * @param mesh The mesh to include in the glow layer
  14805. */
  14806. addIncludedOnlyMesh(mesh: Mesh): void;
  14807. /**
  14808. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14809. * @param mesh The mesh to remove
  14810. */
  14811. removeIncludedOnlyMesh(mesh: Mesh): void;
  14812. /**
  14813. * Determine if a given mesh will be used in the glow layer
  14814. * @param mesh The mesh to test
  14815. * @returns true if the mesh will be highlighted by the current glow layer
  14816. */
  14817. hasMesh(mesh: AbstractMesh): boolean;
  14818. /**
  14819. * Free any resources and references associated to a mesh.
  14820. * Internal use
  14821. * @param mesh The mesh to free.
  14822. * @hidden
  14823. */
  14824. _disposeMesh(mesh: Mesh): void;
  14825. /**
  14826. * Gets the class name of the effect layer
  14827. * @returns the string with the class name of the effect layer
  14828. */
  14829. getClassName(): string;
  14830. /**
  14831. * Serializes this glow layer
  14832. * @returns a serialized glow layer object
  14833. */
  14834. serialize(): any;
  14835. /**
  14836. * Creates a Glow Layer from parsed glow layer data
  14837. * @param parsedGlowLayer defines glow layer data
  14838. * @param scene defines the current scene
  14839. * @param rootUrl defines the root URL containing the glow layer information
  14840. * @returns a parsed Glow Layer
  14841. */
  14842. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14843. }
  14844. }
  14845. declare module BABYLON {
  14846. interface AbstractScene {
  14847. /**
  14848. * Return a the first highlight layer of the scene with a given name.
  14849. * @param name The name of the highlight layer to look for.
  14850. * @return The highlight layer if found otherwise null.
  14851. */
  14852. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14853. }
  14854. /**
  14855. * Highlight layer options. This helps customizing the behaviour
  14856. * of the highlight layer.
  14857. */
  14858. interface IHighlightLayerOptions {
  14859. /**
  14860. * Multiplication factor apply to the canvas size to compute the render target size
  14861. * used to generated the glowing objects (the smaller the faster).
  14862. */
  14863. mainTextureRatio: number;
  14864. /**
  14865. * Enforces a fixed size texture to ensure resize independant blur.
  14866. */
  14867. mainTextureFixedSize?: number;
  14868. /**
  14869. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14870. * of the picture to blur (the smaller the faster).
  14871. */
  14872. blurTextureSizeRatio: number;
  14873. /**
  14874. * How big in texel of the blur texture is the vertical blur.
  14875. */
  14876. blurVerticalSize: number;
  14877. /**
  14878. * How big in texel of the blur texture is the horizontal blur.
  14879. */
  14880. blurHorizontalSize: number;
  14881. /**
  14882. * Alpha blending mode used to apply the blur. Default is combine.
  14883. */
  14884. alphaBlendingMode: number;
  14885. /**
  14886. * The camera attached to the layer.
  14887. */
  14888. camera: Nullable<Camera>;
  14889. /**
  14890. * Should we display highlight as a solid stroke?
  14891. */
  14892. isStroke?: boolean;
  14893. /**
  14894. * The rendering group to draw the layer in.
  14895. */
  14896. renderingGroupId: number;
  14897. }
  14898. /**
  14899. * The highlight layer Helps adding a glow effect around a mesh.
  14900. *
  14901. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14902. * glowy meshes to your scene.
  14903. *
  14904. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14905. */
  14906. class HighlightLayer extends EffectLayer {
  14907. name: string;
  14908. /**
  14909. * Effect Name of the highlight layer.
  14910. */
  14911. static readonly EffectName: string;
  14912. /**
  14913. * The neutral color used during the preparation of the glow effect.
  14914. * This is black by default as the blend operation is a blend operation.
  14915. */
  14916. static NeutralColor: Color4;
  14917. /**
  14918. * Stencil value used for glowing meshes.
  14919. */
  14920. static GlowingMeshStencilReference: number;
  14921. /**
  14922. * Stencil value used for the other meshes in the scene.
  14923. */
  14924. static NormalMeshStencilReference: number;
  14925. /**
  14926. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14927. */
  14928. innerGlow: boolean;
  14929. /**
  14930. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14931. */
  14932. outerGlow: boolean;
  14933. /**
  14934. * Specifies the horizontal size of the blur.
  14935. */
  14936. /**
  14937. * Gets the horizontal size of the blur.
  14938. */
  14939. blurHorizontalSize: number;
  14940. /**
  14941. * Specifies the vertical size of the blur.
  14942. */
  14943. /**
  14944. * Gets the vertical size of the blur.
  14945. */
  14946. blurVerticalSize: number;
  14947. /**
  14948. * An event triggered when the highlight layer is being blurred.
  14949. */
  14950. onBeforeBlurObservable: Observable<HighlightLayer>;
  14951. /**
  14952. * An event triggered when the highlight layer has been blurred.
  14953. */
  14954. onAfterBlurObservable: Observable<HighlightLayer>;
  14955. private _instanceGlowingMeshStencilReference;
  14956. private _options;
  14957. private _downSamplePostprocess;
  14958. private _horizontalBlurPostprocess;
  14959. private _verticalBlurPostprocess;
  14960. private _blurTexture;
  14961. private _meshes;
  14962. private _excludedMeshes;
  14963. /**
  14964. * Instantiates a new highlight Layer and references it to the scene..
  14965. * @param name The name of the layer
  14966. * @param scene The scene to use the layer in
  14967. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14968. */
  14969. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14970. /**
  14971. * Get the effect name of the layer.
  14972. * @return The effect name
  14973. */
  14974. getEffectName(): string;
  14975. /**
  14976. * Create the merge effect. This is the shader use to blit the information back
  14977. * to the main canvas at the end of the scene rendering.
  14978. */
  14979. protected _createMergeEffect(): Effect;
  14980. /**
  14981. * Creates the render target textures and post processes used in the highlight layer.
  14982. */
  14983. protected _createTextureAndPostProcesses(): void;
  14984. /**
  14985. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14986. */
  14987. needStencil(): boolean;
  14988. /**
  14989. * Checks for the readiness of the element composing the layer.
  14990. * @param subMesh the mesh to check for
  14991. * @param useInstances specify wether or not to use instances to render the mesh
  14992. * @param emissiveTexture the associated emissive texture used to generate the glow
  14993. * @return true if ready otherwise, false
  14994. */
  14995. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14996. /**
  14997. * Implementation specific of rendering the generating effect on the main canvas.
  14998. * @param effect The effect used to render through
  14999. */
  15000. protected _internalRender(effect: Effect): void;
  15001. /**
  15002. * Returns true if the layer contains information to display, otherwise false.
  15003. */
  15004. shouldRender(): boolean;
  15005. /**
  15006. * Returns true if the mesh should render, otherwise false.
  15007. * @param mesh The mesh to render
  15008. * @returns true if it should render otherwise false
  15009. */
  15010. protected _shouldRenderMesh(mesh: Mesh): boolean;
  15011. /**
  15012. * Sets the required values for both the emissive texture and and the main color.
  15013. */
  15014. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  15015. /**
  15016. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  15017. * @param mesh The mesh to exclude from the highlight layer
  15018. */
  15019. addExcludedMesh(mesh: Mesh): void;
  15020. /**
  15021. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  15022. * @param mesh The mesh to highlight
  15023. */
  15024. removeExcludedMesh(mesh: Mesh): void;
  15025. /**
  15026. * Determine if a given mesh will be highlighted by the current HighlightLayer
  15027. * @param mesh mesh to test
  15028. * @returns true if the mesh will be highlighted by the current HighlightLayer
  15029. */
  15030. hasMesh(mesh: AbstractMesh): boolean;
  15031. /**
  15032. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  15033. * @param mesh The mesh to highlight
  15034. * @param color The color of the highlight
  15035. * @param glowEmissiveOnly Extract the glow from the emissive texture
  15036. */
  15037. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  15038. /**
  15039. * Remove a mesh from the highlight layer in order to make it stop glowing.
  15040. * @param mesh The mesh to highlight
  15041. */
  15042. removeMesh(mesh: Mesh): void;
  15043. /**
  15044. * Force the stencil to the normal expected value for none glowing parts
  15045. */
  15046. private _defaultStencilReference;
  15047. /**
  15048. * Free any resources and references associated to a mesh.
  15049. * Internal use
  15050. * @param mesh The mesh to free.
  15051. * @hidden
  15052. */
  15053. _disposeMesh(mesh: Mesh): void;
  15054. /**
  15055. * Dispose the highlight layer and free resources.
  15056. */
  15057. dispose(): void;
  15058. /**
  15059. * Gets the class name of the effect layer
  15060. * @returns the string with the class name of the effect layer
  15061. */
  15062. getClassName(): string;
  15063. /**
  15064. * Serializes this Highlight layer
  15065. * @returns a serialized Highlight layer object
  15066. */
  15067. serialize(): any;
  15068. /**
  15069. * Creates a Highlight layer from parsed Highlight layer data
  15070. * @param parsedHightlightLayer defines the Highlight layer data
  15071. * @param scene defines the current scene
  15072. * @param rootUrl defines the root URL containing the Highlight layer information
  15073. * @returns a parsed Highlight layer
  15074. */
  15075. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  15076. }
  15077. }
  15078. declare module BABYLON {
  15079. /**
  15080. * This represents a full screen 2d layer.
  15081. * This can be useful to display a picture in the background of your scene for instance.
  15082. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15083. */
  15084. class Layer {
  15085. /**
  15086. * Define the name of the layer.
  15087. */
  15088. name: string;
  15089. /**
  15090. * Define the texture the layer should display.
  15091. */
  15092. texture: Nullable<Texture>;
  15093. /**
  15094. * Is the layer in background or foreground.
  15095. */
  15096. isBackground: boolean;
  15097. /**
  15098. * Define the color of the layer (instead of texture).
  15099. */
  15100. color: Color4;
  15101. /**
  15102. * Define the scale of the layer in order to zoom in out of the texture.
  15103. */
  15104. scale: Vector2;
  15105. /**
  15106. * Define an offset for the layer in order to shift the texture.
  15107. */
  15108. offset: Vector2;
  15109. /**
  15110. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  15111. */
  15112. alphaBlendingMode: number;
  15113. /**
  15114. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  15115. * Alpha test will not mix with the background color in case of transparency.
  15116. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  15117. */
  15118. alphaTest: boolean;
  15119. /**
  15120. * Define a mask to restrict the layer to only some of the scene cameras.
  15121. */
  15122. layerMask: number;
  15123. /**
  15124. * Define the list of render target the layer is visible into.
  15125. */
  15126. renderTargetTextures: RenderTargetTexture[];
  15127. /**
  15128. * Define if the layer is only used in renderTarget or if it also
  15129. * renders in the main frame buffer of the canvas.
  15130. */
  15131. renderOnlyInRenderTargetTextures: boolean;
  15132. private _scene;
  15133. private _vertexBuffers;
  15134. private _indexBuffer;
  15135. private _effect;
  15136. private _alphaTestEffect;
  15137. /**
  15138. * An event triggered when the layer is disposed.
  15139. */
  15140. onDisposeObservable: Observable<Layer>;
  15141. private _onDisposeObserver;
  15142. /**
  15143. * Back compatibility with callback before the onDisposeObservable existed.
  15144. * The set callback will be triggered when the layer has been disposed.
  15145. */
  15146. onDispose: () => void;
  15147. /**
  15148. * An event triggered before rendering the scene
  15149. */
  15150. onBeforeRenderObservable: Observable<Layer>;
  15151. private _onBeforeRenderObserver;
  15152. /**
  15153. * Back compatibility with callback before the onBeforeRenderObservable existed.
  15154. * The set callback will be triggered just before rendering the layer.
  15155. */
  15156. onBeforeRender: () => void;
  15157. /**
  15158. * An event triggered after rendering the scene
  15159. */
  15160. onAfterRenderObservable: Observable<Layer>;
  15161. private _onAfterRenderObserver;
  15162. /**
  15163. * Back compatibility with callback before the onAfterRenderObservable existed.
  15164. * The set callback will be triggered just after rendering the layer.
  15165. */
  15166. onAfterRender: () => void;
  15167. /**
  15168. * Instantiates a new layer.
  15169. * This represents a full screen 2d layer.
  15170. * This can be useful to display a picture in the background of your scene for instance.
  15171. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15172. * @param name Define the name of the layer in the scene
  15173. * @param imgUrl Define the url of the texture to display in the layer
  15174. * @param scene Define the scene the layer belongs to
  15175. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  15176. * @param color Defines a color for the layer
  15177. */
  15178. constructor(
  15179. /**
  15180. * Define the name of the layer.
  15181. */
  15182. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  15183. private _createIndexBuffer;
  15184. /** @hidden */
  15185. _rebuild(): void;
  15186. /**
  15187. * Renders the layer in the scene.
  15188. */
  15189. render(): void;
  15190. /**
  15191. * Disposes and releases the associated ressources.
  15192. */
  15193. dispose(): void;
  15194. }
  15195. }
  15196. declare module BABYLON {
  15197. interface AbstractScene {
  15198. /**
  15199. * The list of layers (background and foreground) of the scene
  15200. */
  15201. layers: Array<Layer>;
  15202. }
  15203. /**
  15204. * Defines the layer scene component responsible to manage any layers
  15205. * in a given scene.
  15206. */
  15207. class LayerSceneComponent implements ISceneComponent {
  15208. /**
  15209. * The component name helpfull to identify the component in the list of scene components.
  15210. */
  15211. readonly name: string;
  15212. /**
  15213. * The scene the component belongs to.
  15214. */
  15215. scene: Scene;
  15216. private _engine;
  15217. /**
  15218. * Creates a new instance of the component for the given scene
  15219. * @param scene Defines the scene to register the component in
  15220. */
  15221. constructor(scene: Scene);
  15222. /**
  15223. * Registers the component in a given scene
  15224. */
  15225. register(): void;
  15226. /**
  15227. * Rebuilds the elements related to this component in case of
  15228. * context lost for instance.
  15229. */
  15230. rebuild(): void;
  15231. /**
  15232. * Disposes the component and the associated ressources.
  15233. */
  15234. dispose(): void;
  15235. private _draw;
  15236. private _drawCameraPredicate;
  15237. private _drawCameraBackground;
  15238. private _drawCameraForeground;
  15239. private _drawRenderTargetPredicate;
  15240. private _drawRenderTargetBackground;
  15241. private _drawRenderTargetForeground;
  15242. }
  15243. }
  15244. declare module BABYLON {
  15245. /**
  15246. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15247. * It controls one of the indiviual texture used in the effect.
  15248. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15249. */
  15250. class LensFlare {
  15251. /**
  15252. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15253. */
  15254. size: number;
  15255. /**
  15256. * 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.
  15257. */
  15258. position: number;
  15259. /**
  15260. * Define the lens color.
  15261. */
  15262. color: Color3;
  15263. /**
  15264. * Define the lens texture.
  15265. */
  15266. texture: Nullable<Texture>;
  15267. /**
  15268. * Define the alpha mode to render this particular lens.
  15269. */
  15270. alphaMode: number;
  15271. private _system;
  15272. /**
  15273. * Creates a new Lens Flare.
  15274. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15275. * It controls one of the indiviual texture used in the effect.
  15276. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15277. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  15278. * @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.
  15279. * @param color Define the lens color
  15280. * @param imgUrl Define the lens texture url
  15281. * @param system Define the `lensFlareSystem` this flare is part of
  15282. * @returns The newly created Lens Flare
  15283. */
  15284. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  15285. /**
  15286. * Instantiates a new Lens Flare.
  15287. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15288. * It controls one of the indiviual texture used in the effect.
  15289. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15290. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  15291. * @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.
  15292. * @param color Define the lens color
  15293. * @param imgUrl Define the lens texture url
  15294. * @param system Define the `lensFlareSystem` this flare is part of
  15295. */
  15296. constructor(
  15297. /**
  15298. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15299. */
  15300. size: number,
  15301. /**
  15302. * 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.
  15303. */
  15304. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  15305. /**
  15306. * Dispose and release the lens flare with its associated resources.
  15307. */
  15308. dispose(): void;
  15309. }
  15310. }
  15311. declare module BABYLON {
  15312. /**
  15313. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15314. * It is usually composed of several `BABYLON.lensFlare`.
  15315. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15316. */
  15317. class LensFlareSystem {
  15318. /**
  15319. * Define the name of the lens flare system
  15320. */
  15321. name: string;
  15322. /**
  15323. * List of lens flares used in this system.
  15324. */
  15325. lensFlares: LensFlare[];
  15326. /**
  15327. * Define a limit from the border the lens flare can be visible.
  15328. */
  15329. borderLimit: number;
  15330. /**
  15331. * Define a viewport border we do not want to see the lens flare in.
  15332. */
  15333. viewportBorder: number;
  15334. /**
  15335. * Define a predicate which could limit the list of meshes able to occlude the effect.
  15336. */
  15337. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15338. /**
  15339. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  15340. */
  15341. layerMask: number;
  15342. /**
  15343. * Define the id of the lens flare system in the scene.
  15344. * (equal to name by default)
  15345. */
  15346. id: string;
  15347. private _scene;
  15348. private _emitter;
  15349. private _vertexBuffers;
  15350. private _indexBuffer;
  15351. private _effect;
  15352. private _positionX;
  15353. private _positionY;
  15354. private _isEnabled;
  15355. /**
  15356. * Instantiates a lens flare system.
  15357. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15358. * It is usually composed of several `BABYLON.lensFlare`.
  15359. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15360. * @param name Define the name of the lens flare system in the scene
  15361. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  15362. * @param scene Define the scene the lens flare system belongs to
  15363. */
  15364. constructor(
  15365. /**
  15366. * Define the name of the lens flare system
  15367. */
  15368. name: string, emitter: any, scene: Scene);
  15369. /**
  15370. * Define if the lens flare system is enabled.
  15371. */
  15372. isEnabled: boolean;
  15373. /**
  15374. * Get the scene the effects belongs to.
  15375. * @returns the scene holding the lens flare system
  15376. */
  15377. getScene(): Scene;
  15378. /**
  15379. * Get the emitter of the lens flare system.
  15380. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15381. * @returns the emitter of the lens flare system
  15382. */
  15383. getEmitter(): any;
  15384. /**
  15385. * Set the emitter of the lens flare system.
  15386. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15387. * @param newEmitter Define the new emitter of the system
  15388. */
  15389. setEmitter(newEmitter: any): void;
  15390. /**
  15391. * Get the lens flare system emitter position.
  15392. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  15393. * @returns the position
  15394. */
  15395. getEmitterPosition(): Vector3;
  15396. /**
  15397. * @hidden
  15398. */
  15399. computeEffectivePosition(globalViewport: Viewport): boolean;
  15400. /** @hidden */
  15401. _isVisible(): boolean;
  15402. /**
  15403. * @hidden
  15404. */
  15405. render(): boolean;
  15406. /**
  15407. * Dispose and release the lens flare with its associated resources.
  15408. */
  15409. dispose(): void;
  15410. /**
  15411. * Parse a lens flare system from a JSON repressentation
  15412. * @param parsedLensFlareSystem Define the JSON to parse
  15413. * @param scene Define the scene the parsed system should be instantiated in
  15414. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  15415. * @returns the parsed system
  15416. */
  15417. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15418. /**
  15419. * Serialize the current Lens Flare System into a JSON representation.
  15420. * @returns the serialized JSON
  15421. */
  15422. serialize(): any;
  15423. }
  15424. }
  15425. declare module BABYLON {
  15426. interface AbstractScene {
  15427. /**
  15428. * The list of lens flare system added to the scene
  15429. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15430. */
  15431. lensFlareSystems: Array<LensFlareSystem>;
  15432. /**
  15433. * Removes the given lens flare system from this scene.
  15434. * @param toRemove The lens flare system to remove
  15435. * @returns The index of the removed lens flare system
  15436. */
  15437. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  15438. /**
  15439. * Adds the given lens flare system to this scene
  15440. * @param newLensFlareSystem The lens flare system to add
  15441. */
  15442. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  15443. /**
  15444. * Gets a lens flare system using its name
  15445. * @param name defines the name to look for
  15446. * @returns the lens flare system or null if not found
  15447. */
  15448. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  15449. /**
  15450. * Gets a lens flare system using its id
  15451. * @param id defines the id to look for
  15452. * @returns the lens flare system or null if not found
  15453. */
  15454. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  15455. }
  15456. /**
  15457. * Defines the lens flare scene component responsible to manage any lens flares
  15458. * in a given scene.
  15459. */
  15460. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  15461. /**
  15462. * The component name helpfull to identify the component in the list of scene components.
  15463. */
  15464. readonly name: string;
  15465. /**
  15466. * The scene the component belongs to.
  15467. */
  15468. scene: Scene;
  15469. /**
  15470. * Creates a new instance of the component for the given scene
  15471. * @param scene Defines the scene to register the component in
  15472. */
  15473. constructor(scene: Scene);
  15474. /**
  15475. * Registers the component in a given scene
  15476. */
  15477. register(): void;
  15478. /**
  15479. * Rebuilds the elements related to this component in case of
  15480. * context lost for instance.
  15481. */
  15482. rebuild(): void;
  15483. /**
  15484. * Adds all the element from the container to the scene
  15485. * @param container the container holding the elements
  15486. */
  15487. addFromContainer(container: AbstractScene): void;
  15488. /**
  15489. * Removes all the elements in the container from the scene
  15490. * @param container contains the elements to remove
  15491. */
  15492. removeFromContainer(container: AbstractScene): void;
  15493. /**
  15494. * Serializes the component data to the specified json object
  15495. * @param serializationObject The object to serialize to
  15496. */
  15497. serialize(serializationObject: any): void;
  15498. /**
  15499. * Disposes the component and the associated ressources.
  15500. */
  15501. dispose(): void;
  15502. private _draw;
  15503. }
  15504. }
  15505. declare module BABYLON {
  15506. /**
  15507. * A directional light is defined by a direction (what a surprise!).
  15508. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15509. * 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.
  15510. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15511. */
  15512. class DirectionalLight extends ShadowLight {
  15513. private _shadowFrustumSize;
  15514. /**
  15515. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15516. */
  15517. /**
  15518. * Specifies a fix frustum size for the shadow generation.
  15519. */
  15520. shadowFrustumSize: number;
  15521. private _shadowOrthoScale;
  15522. /**
  15523. * Gets the shadow projection scale against the optimal computed one.
  15524. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15525. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15526. */
  15527. /**
  15528. * Sets the shadow projection scale against the optimal computed one.
  15529. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15530. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15531. */
  15532. shadowOrthoScale: number;
  15533. /**
  15534. * Automatically compute the projection matrix to best fit (including all the casters)
  15535. * on each frame.
  15536. */
  15537. autoUpdateExtends: boolean;
  15538. private _orthoLeft;
  15539. private _orthoRight;
  15540. private _orthoTop;
  15541. private _orthoBottom;
  15542. /**
  15543. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15544. * The directional light is emitted from everywhere in the given direction.
  15545. * It can cast shadows.
  15546. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15547. * @param name The friendly name of the light
  15548. * @param direction The direction of the light
  15549. * @param scene The scene the light belongs to
  15550. */
  15551. constructor(name: string, direction: Vector3, scene: Scene);
  15552. /**
  15553. * Returns the string "DirectionalLight".
  15554. * @return The class name
  15555. */
  15556. getClassName(): string;
  15557. /**
  15558. * Returns the integer 1.
  15559. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15560. */
  15561. getTypeID(): number;
  15562. /**
  15563. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15564. * Returns the DirectionalLight Shadow projection matrix.
  15565. */
  15566. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15567. /**
  15568. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15569. * Returns the DirectionalLight Shadow projection matrix.
  15570. */
  15571. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15572. /**
  15573. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15574. * Returns the DirectionalLight Shadow projection matrix.
  15575. */
  15576. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15577. protected _buildUniformLayout(): void;
  15578. /**
  15579. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15580. * @param effect The effect to update
  15581. * @param lightIndex The index of the light in the effect to update
  15582. * @returns The directional light
  15583. */
  15584. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15585. /**
  15586. * Gets the minZ used for shadow according to both the scene and the light.
  15587. *
  15588. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15589. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15590. * @param activeCamera The camera we are returning the min for
  15591. * @returns the depth min z
  15592. */
  15593. getDepthMinZ(activeCamera: Camera): number;
  15594. /**
  15595. * Gets the maxZ used for shadow according to both the scene and the light.
  15596. *
  15597. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15598. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15599. * @param activeCamera The camera we are returning the max for
  15600. * @returns the depth max z
  15601. */
  15602. getDepthMaxZ(activeCamera: Camera): number;
  15603. /**
  15604. * Prepares the list of defines specific to the light type.
  15605. * @param defines the list of defines
  15606. * @param lightIndex defines the index of the light for the effect
  15607. */
  15608. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15609. }
  15610. }
  15611. declare module BABYLON {
  15612. /**
  15613. * The HemisphericLight simulates the ambient environment light,
  15614. * so the passed direction is the light reflection direction, not the incoming direction.
  15615. */
  15616. class HemisphericLight extends Light {
  15617. /**
  15618. * The groundColor is the light in the opposite direction to the one specified during creation.
  15619. * 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.
  15620. */
  15621. groundColor: Color3;
  15622. /**
  15623. * The light reflection direction, not the incoming direction.
  15624. */
  15625. direction: Vector3;
  15626. /**
  15627. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15628. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15629. * The HemisphericLight can't cast shadows.
  15630. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15631. * @param name The friendly name of the light
  15632. * @param direction The direction of the light reflection
  15633. * @param scene The scene the light belongs to
  15634. */
  15635. constructor(name: string, direction: Vector3, scene: Scene);
  15636. protected _buildUniformLayout(): void;
  15637. /**
  15638. * Returns the string "HemisphericLight".
  15639. * @return The class name
  15640. */
  15641. getClassName(): string;
  15642. /**
  15643. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15644. * Returns the updated direction.
  15645. * @param target The target the direction should point to
  15646. * @return The computed direction
  15647. */
  15648. setDirectionToTarget(target: Vector3): Vector3;
  15649. /**
  15650. * Returns the shadow generator associated to the light.
  15651. * @returns Always null for hemispheric lights because it does not support shadows.
  15652. */
  15653. getShadowGenerator(): Nullable<IShadowGenerator>;
  15654. /**
  15655. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15656. * @param effect The effect to update
  15657. * @param lightIndex The index of the light in the effect to update
  15658. * @returns The hemispheric light
  15659. */
  15660. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15661. /**
  15662. * Computes the world matrix of the node
  15663. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15664. * @param useWasUpdatedFlag defines a reserved property
  15665. * @returns the world matrix
  15666. */
  15667. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15668. /**
  15669. * Returns the integer 3.
  15670. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15671. */
  15672. getTypeID(): number;
  15673. /**
  15674. * Prepares the list of defines specific to the light type.
  15675. * @param defines the list of defines
  15676. * @param lightIndex defines the index of the light for the effect
  15677. */
  15678. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15679. }
  15680. }
  15681. declare module BABYLON {
  15682. /**
  15683. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15684. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15685. * 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.
  15686. */
  15687. abstract class Light extends Node {
  15688. /**
  15689. * Falloff Default: light is falling off following the material specification:
  15690. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15691. */
  15692. static readonly FALLOFF_DEFAULT: number;
  15693. /**
  15694. * Falloff Physical: light is falling off following the inverse squared distance law.
  15695. */
  15696. static readonly FALLOFF_PHYSICAL: number;
  15697. /**
  15698. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15699. * to enhance interoperability with other engines.
  15700. */
  15701. static readonly FALLOFF_GLTF: number;
  15702. /**
  15703. * Falloff Standard: light is falling off like in the standard material
  15704. * to enhance interoperability with other materials.
  15705. */
  15706. static readonly FALLOFF_STANDARD: number;
  15707. /**
  15708. * If every light affecting the material is in this lightmapMode,
  15709. * material.lightmapTexture adds or multiplies
  15710. * (depends on material.useLightmapAsShadowmap)
  15711. * after every other light calculations.
  15712. */
  15713. static readonly LIGHTMAP_DEFAULT: number;
  15714. /**
  15715. * material.lightmapTexture as only diffuse lighting from this light
  15716. * adds only specular lighting from this light
  15717. * adds dynamic shadows
  15718. */
  15719. static readonly LIGHTMAP_SPECULAR: number;
  15720. /**
  15721. * material.lightmapTexture as only lighting
  15722. * no light calculation from this light
  15723. * only adds dynamic shadows from this light
  15724. */
  15725. static readonly LIGHTMAP_SHADOWSONLY: number;
  15726. /**
  15727. * Each light type uses the default quantity according to its type:
  15728. * point/spot lights use luminous intensity
  15729. * directional lights use illuminance
  15730. */
  15731. static readonly INTENSITYMODE_AUTOMATIC: number;
  15732. /**
  15733. * lumen (lm)
  15734. */
  15735. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15736. /**
  15737. * candela (lm/sr)
  15738. */
  15739. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15740. /**
  15741. * lux (lm/m^2)
  15742. */
  15743. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15744. /**
  15745. * nit (cd/m^2)
  15746. */
  15747. static readonly INTENSITYMODE_LUMINANCE: number;
  15748. /**
  15749. * Light type const id of the point light.
  15750. */
  15751. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15752. /**
  15753. * Light type const id of the directional light.
  15754. */
  15755. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15756. /**
  15757. * Light type const id of the spot light.
  15758. */
  15759. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15760. /**
  15761. * Light type const id of the hemispheric light.
  15762. */
  15763. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15764. /**
  15765. * Diffuse gives the basic color to an object.
  15766. */
  15767. diffuse: Color3;
  15768. /**
  15769. * Specular produces a highlight color on an object.
  15770. * Note: This is note affecting PBR materials.
  15771. */
  15772. specular: Color3;
  15773. /**
  15774. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15775. * falling off base on range or angle.
  15776. * This can be set to any values in Light.FALLOFF_x.
  15777. *
  15778. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  15779. * other types of materials.
  15780. */
  15781. falloffType: number;
  15782. /**
  15783. * Strength of the light.
  15784. * Note: By default it is define in the framework own unit.
  15785. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15786. */
  15787. intensity: number;
  15788. private _range;
  15789. protected _inverseSquaredRange: number;
  15790. /**
  15791. * Defines how far from the source the light is impacting in scene units.
  15792. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15793. */
  15794. /**
  15795. * Defines how far from the source the light is impacting in scene units.
  15796. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15797. */
  15798. range: number;
  15799. /**
  15800. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15801. * of light.
  15802. */
  15803. private _photometricScale;
  15804. private _intensityMode;
  15805. /**
  15806. * Gets the photometric scale used to interpret the intensity.
  15807. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15808. */
  15809. /**
  15810. * Sets the photometric scale used to interpret the intensity.
  15811. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15812. */
  15813. intensityMode: number;
  15814. private _radius;
  15815. /**
  15816. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15817. */
  15818. /**
  15819. * sets the light radius used by PBR Materials to simulate soft area lights.
  15820. */
  15821. radius: number;
  15822. private _renderPriority;
  15823. /**
  15824. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15825. * exceeding the number allowed of the materials.
  15826. */
  15827. renderPriority: number;
  15828. private _shadowEnabled;
  15829. /**
  15830. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15831. * the current shadow generator.
  15832. */
  15833. /**
  15834. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15835. * the current shadow generator.
  15836. */
  15837. shadowEnabled: boolean;
  15838. private _includedOnlyMeshes;
  15839. /**
  15840. * Gets the only meshes impacted by this light.
  15841. */
  15842. /**
  15843. * Sets the only meshes impacted by this light.
  15844. */
  15845. includedOnlyMeshes: AbstractMesh[];
  15846. private _excludedMeshes;
  15847. /**
  15848. * Gets the meshes not impacted by this light.
  15849. */
  15850. /**
  15851. * Sets the meshes not impacted by this light.
  15852. */
  15853. excludedMeshes: AbstractMesh[];
  15854. private _excludeWithLayerMask;
  15855. /**
  15856. * Gets the layer id use to find what meshes are not impacted by the light.
  15857. * Inactive if 0
  15858. */
  15859. /**
  15860. * Sets the layer id use to find what meshes are not impacted by the light.
  15861. * Inactive if 0
  15862. */
  15863. excludeWithLayerMask: number;
  15864. private _includeOnlyWithLayerMask;
  15865. /**
  15866. * Gets the layer id use to find what meshes are impacted by the light.
  15867. * Inactive if 0
  15868. */
  15869. /**
  15870. * Sets the layer id use to find what meshes are impacted by the light.
  15871. * Inactive if 0
  15872. */
  15873. includeOnlyWithLayerMask: number;
  15874. private _lightmapMode;
  15875. /**
  15876. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15877. */
  15878. /**
  15879. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15880. */
  15881. lightmapMode: number;
  15882. /**
  15883. * Shadow generator associted to the light.
  15884. * @hidden Internal use only.
  15885. */
  15886. _shadowGenerator: Nullable<IShadowGenerator>;
  15887. /**
  15888. * @hidden Internal use only.
  15889. */
  15890. _excludedMeshesIds: string[];
  15891. /**
  15892. * @hidden Internal use only.
  15893. */
  15894. _includedOnlyMeshesIds: string[];
  15895. /**
  15896. * The current light unifom buffer.
  15897. * @hidden Internal use only.
  15898. */
  15899. _uniformBuffer: UniformBuffer;
  15900. /**
  15901. * Creates a Light object in the scene.
  15902. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15903. * @param name The firendly name of the light
  15904. * @param scene The scene the light belongs too
  15905. */
  15906. constructor(name: string, scene: Scene);
  15907. protected abstract _buildUniformLayout(): void;
  15908. /**
  15909. * Sets the passed Effect "effect" with the Light information.
  15910. * @param effect The effect to update
  15911. * @param lightIndex The index of the light in the effect to update
  15912. * @returns The light
  15913. */
  15914. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15915. /**
  15916. * Returns the string "Light".
  15917. * @returns the class name
  15918. */
  15919. getClassName(): string;
  15920. /**
  15921. * Converts the light information to a readable string for debug purpose.
  15922. * @param fullDetails Supports for multiple levels of logging within scene loading
  15923. * @returns the human readable light info
  15924. */
  15925. toString(fullDetails?: boolean): string;
  15926. /** @hidden */
  15927. protected _syncParentEnabledState(): void;
  15928. /**
  15929. * Set the enabled state of this node.
  15930. * @param value - the new enabled state
  15931. */
  15932. setEnabled(value: boolean): void;
  15933. /**
  15934. * Returns the Light associated shadow generator if any.
  15935. * @return the associated shadow generator.
  15936. */
  15937. getShadowGenerator(): Nullable<IShadowGenerator>;
  15938. /**
  15939. * Returns a Vector3, the absolute light position in the World.
  15940. * @returns the world space position of the light
  15941. */
  15942. getAbsolutePosition(): Vector3;
  15943. /**
  15944. * Specifies if the light will affect the passed mesh.
  15945. * @param mesh The mesh to test against the light
  15946. * @return true the mesh is affected otherwise, false.
  15947. */
  15948. canAffectMesh(mesh: AbstractMesh): boolean;
  15949. /**
  15950. * Sort function to order lights for rendering.
  15951. * @param a First Light object to compare to second.
  15952. * @param b Second Light object to compare first.
  15953. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15954. */
  15955. static CompareLightsPriority(a: Light, b: Light): number;
  15956. /**
  15957. * Releases resources associated with this node.
  15958. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15959. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15960. */
  15961. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15962. /**
  15963. * Returns the light type ID (integer).
  15964. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15965. */
  15966. getTypeID(): number;
  15967. /**
  15968. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15969. * @returns the scaled intensity in intensity mode unit
  15970. */
  15971. getScaledIntensity(): number;
  15972. /**
  15973. * Returns a new Light object, named "name", from the current one.
  15974. * @param name The name of the cloned light
  15975. * @returns the new created light
  15976. */
  15977. clone(name: string): Nullable<Light>;
  15978. /**
  15979. * Serializes the current light into a Serialization object.
  15980. * @returns the serialized object.
  15981. */
  15982. serialize(): any;
  15983. /**
  15984. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15985. * This new light is named "name" and added to the passed scene.
  15986. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15987. * @param name The friendly name of the light
  15988. * @param scene The scene the new light will belong to
  15989. * @returns the constructor function
  15990. */
  15991. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15992. /**
  15993. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15994. * @param parsedLight The JSON representation of the light
  15995. * @param scene The scene to create the parsed light in
  15996. * @returns the created light after parsing
  15997. */
  15998. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15999. private _hookArrayForExcluded;
  16000. private _hookArrayForIncludedOnly;
  16001. private _resyncMeshes;
  16002. /**
  16003. * Forces the meshes to update their light related information in their rendering used effects
  16004. * @hidden Internal Use Only
  16005. */
  16006. _markMeshesAsLightDirty(): void;
  16007. /**
  16008. * Recomputes the cached photometric scale if needed.
  16009. */
  16010. private _computePhotometricScale;
  16011. /**
  16012. * Returns the Photometric Scale according to the light type and intensity mode.
  16013. */
  16014. private _getPhotometricScale;
  16015. /**
  16016. * Reorder the light in the scene according to their defined priority.
  16017. * @hidden Internal Use Only
  16018. */
  16019. _reorderLightsInScene(): void;
  16020. /**
  16021. * Prepares the list of defines specific to the light type.
  16022. * @param defines the list of defines
  16023. * @param lightIndex defines the index of the light for the effect
  16024. */
  16025. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16026. }
  16027. }
  16028. declare module BABYLON {
  16029. /**
  16030. * A point light is a light defined by an unique point in world space.
  16031. * The light is emitted in every direction from this point.
  16032. * A good example of a point light is a standard light bulb.
  16033. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16034. */
  16035. class PointLight extends ShadowLight {
  16036. private _shadowAngle;
  16037. /**
  16038. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16039. * This specifies what angle the shadow will use to be created.
  16040. *
  16041. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  16042. */
  16043. /**
  16044. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16045. * This specifies what angle the shadow will use to be created.
  16046. *
  16047. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  16048. */
  16049. shadowAngle: number;
  16050. /**
  16051. * Gets the direction if it has been set.
  16052. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16053. */
  16054. /**
  16055. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16056. */
  16057. direction: Vector3;
  16058. /**
  16059. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  16060. * A PointLight emits the light in every direction.
  16061. * It can cast shadows.
  16062. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  16063. * ```javascript
  16064. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  16065. * ```
  16066. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16067. * @param name The light friendly name
  16068. * @param position The position of the point light in the scene
  16069. * @param scene The scene the lights belongs to
  16070. */
  16071. constructor(name: string, position: Vector3, scene: Scene);
  16072. /**
  16073. * Returns the string "PointLight"
  16074. * @returns the class name
  16075. */
  16076. getClassName(): string;
  16077. /**
  16078. * Returns the integer 0.
  16079. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16080. */
  16081. getTypeID(): number;
  16082. /**
  16083. * Specifies wether or not the shadowmap should be a cube texture.
  16084. * @returns true if the shadowmap needs to be a cube texture.
  16085. */
  16086. needCube(): boolean;
  16087. /**
  16088. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  16089. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16090. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16091. */
  16092. getShadowDirection(faceIndex?: number): Vector3;
  16093. /**
  16094. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  16095. * - fov = PI / 2
  16096. * - aspect ratio : 1.0
  16097. * - z-near and far equal to the active camera minZ and maxZ.
  16098. * Returns the PointLight.
  16099. */
  16100. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16101. protected _buildUniformLayout(): void;
  16102. /**
  16103. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  16104. * @param effect The effect to update
  16105. * @param lightIndex The index of the light in the effect to update
  16106. * @returns The point light
  16107. */
  16108. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  16109. /**
  16110. * Prepares the list of defines specific to the light type.
  16111. * @param defines the list of defines
  16112. * @param lightIndex defines the index of the light for the effect
  16113. */
  16114. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16115. }
  16116. }
  16117. declare module BABYLON {
  16118. /**
  16119. * Interface describing all the common properties and methods a shadow light needs to implement.
  16120. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  16121. * as well as binding the different shadow properties to the effects.
  16122. */
  16123. interface IShadowLight extends Light {
  16124. /**
  16125. * The light id in the scene (used in scene.findLighById for instance)
  16126. */
  16127. id: string;
  16128. /**
  16129. * The position the shdow will be casted from.
  16130. */
  16131. position: Vector3;
  16132. /**
  16133. * In 2d mode (needCube being false), the direction used to cast the shadow.
  16134. */
  16135. direction: Vector3;
  16136. /**
  16137. * The transformed position. Position of the light in world space taking parenting in account.
  16138. */
  16139. transformedPosition: Vector3;
  16140. /**
  16141. * The transformed direction. Direction of the light in world space taking parenting in account.
  16142. */
  16143. transformedDirection: Vector3;
  16144. /**
  16145. * The friendly name of the light in the scene.
  16146. */
  16147. name: string;
  16148. /**
  16149. * Defines the shadow projection clipping minimum z value.
  16150. */
  16151. shadowMinZ: number;
  16152. /**
  16153. * Defines the shadow projection clipping maximum z value.
  16154. */
  16155. shadowMaxZ: number;
  16156. /**
  16157. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16158. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16159. */
  16160. computeTransformedInformation(): boolean;
  16161. /**
  16162. * Gets the scene the light belongs to.
  16163. * @returns The scene
  16164. */
  16165. getScene(): Scene;
  16166. /**
  16167. * Callback defining a custom Projection Matrix Builder.
  16168. * This can be used to override the default projection matrix computation.
  16169. */
  16170. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16171. /**
  16172. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16173. * @param matrix The materix to updated with the projection information
  16174. * @param viewMatrix The transform matrix of the light
  16175. * @param renderList The list of mesh to render in the map
  16176. * @returns The current light
  16177. */
  16178. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16179. /**
  16180. * Gets the current depth scale used in ESM.
  16181. * @returns The scale
  16182. */
  16183. getDepthScale(): number;
  16184. /**
  16185. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16186. * @returns true if a cube texture needs to be use
  16187. */
  16188. needCube(): boolean;
  16189. /**
  16190. * Detects if the projection matrix requires to be recomputed this frame.
  16191. * @returns true if it requires to be recomputed otherwise, false.
  16192. */
  16193. needProjectionMatrixCompute(): boolean;
  16194. /**
  16195. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16196. */
  16197. forceProjectionMatrixCompute(): void;
  16198. /**
  16199. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16200. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16201. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16202. */
  16203. getShadowDirection(faceIndex?: number): Vector3;
  16204. /**
  16205. * Gets the minZ used for shadow according to both the scene and the light.
  16206. * @param activeCamera The camera we are returning the min for
  16207. * @returns the depth min z
  16208. */
  16209. getDepthMinZ(activeCamera: Camera): number;
  16210. /**
  16211. * Gets the maxZ used for shadow according to both the scene and the light.
  16212. * @param activeCamera The camera we are returning the max for
  16213. * @returns the depth max z
  16214. */
  16215. getDepthMaxZ(activeCamera: Camera): number;
  16216. }
  16217. /**
  16218. * Base implementation IShadowLight
  16219. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  16220. */
  16221. abstract class ShadowLight extends Light implements IShadowLight {
  16222. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16223. protected _position: Vector3;
  16224. protected _setPosition(value: Vector3): void;
  16225. /**
  16226. * Sets the position the shadow will be casted from. Also use as the light position for both
  16227. * point and spot lights.
  16228. */
  16229. /**
  16230. * Sets the position the shadow will be casted from. Also use as the light position for both
  16231. * point and spot lights.
  16232. */
  16233. position: Vector3;
  16234. protected _direction: Vector3;
  16235. protected _setDirection(value: Vector3): void;
  16236. /**
  16237. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  16238. * Also use as the light direction on spot and directional lights.
  16239. */
  16240. /**
  16241. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  16242. * Also use as the light direction on spot and directional lights.
  16243. */
  16244. direction: Vector3;
  16245. private _shadowMinZ;
  16246. /**
  16247. * Gets the shadow projection clipping minimum z value.
  16248. */
  16249. /**
  16250. * Sets the shadow projection clipping minimum z value.
  16251. */
  16252. shadowMinZ: number;
  16253. private _shadowMaxZ;
  16254. /**
  16255. * Sets the shadow projection clipping maximum z value.
  16256. */
  16257. /**
  16258. * Gets the shadow projection clipping maximum z value.
  16259. */
  16260. shadowMaxZ: number;
  16261. /**
  16262. * Callback defining a custom Projection Matrix Builder.
  16263. * This can be used to override the default projection matrix computation.
  16264. */
  16265. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16266. /**
  16267. * The transformed position. Position of the light in world space taking parenting in account.
  16268. */
  16269. transformedPosition: Vector3;
  16270. /**
  16271. * The transformed direction. Direction of the light in world space taking parenting in account.
  16272. */
  16273. transformedDirection: Vector3;
  16274. private _needProjectionMatrixCompute;
  16275. /**
  16276. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16277. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16278. */
  16279. computeTransformedInformation(): boolean;
  16280. /**
  16281. * Return the depth scale used for the shadow map.
  16282. * @returns the depth scale.
  16283. */
  16284. getDepthScale(): number;
  16285. /**
  16286. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16287. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16288. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16289. */
  16290. getShadowDirection(faceIndex?: number): Vector3;
  16291. /**
  16292. * Returns the ShadowLight absolute position in the World.
  16293. * @returns the position vector in world space
  16294. */
  16295. getAbsolutePosition(): Vector3;
  16296. /**
  16297. * Sets the ShadowLight direction toward the passed target.
  16298. * @param target The point tot target in local space
  16299. * @returns the updated ShadowLight direction
  16300. */
  16301. setDirectionToTarget(target: Vector3): Vector3;
  16302. /**
  16303. * Returns the light rotation in euler definition.
  16304. * @returns the x y z rotation in local space.
  16305. */
  16306. getRotation(): Vector3;
  16307. /**
  16308. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16309. * @returns true if a cube texture needs to be use
  16310. */
  16311. needCube(): boolean;
  16312. /**
  16313. * Detects if the projection matrix requires to be recomputed this frame.
  16314. * @returns true if it requires to be recomputed otherwise, false.
  16315. */
  16316. needProjectionMatrixCompute(): boolean;
  16317. /**
  16318. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16319. */
  16320. forceProjectionMatrixCompute(): void;
  16321. /** @hidden */
  16322. _initCache(): void;
  16323. /** @hidden */
  16324. _isSynchronized(): boolean;
  16325. /**
  16326. * Computes the world matrix of the node
  16327. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16328. * @returns the world matrix
  16329. */
  16330. computeWorldMatrix(force?: boolean): Matrix;
  16331. /**
  16332. * Gets the minZ used for shadow according to both the scene and the light.
  16333. * @param activeCamera The camera we are returning the min for
  16334. * @returns the depth min z
  16335. */
  16336. getDepthMinZ(activeCamera: Camera): number;
  16337. /**
  16338. * Gets the maxZ used for shadow according to both the scene and the light.
  16339. * @param activeCamera The camera we are returning the max for
  16340. * @returns the depth max z
  16341. */
  16342. getDepthMaxZ(activeCamera: Camera): number;
  16343. /**
  16344. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16345. * @param matrix The materix to updated with the projection information
  16346. * @param viewMatrix The transform matrix of the light
  16347. * @param renderList The list of mesh to render in the map
  16348. * @returns The current light
  16349. */
  16350. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16351. }
  16352. }
  16353. declare module BABYLON {
  16354. /**
  16355. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16356. * These values define a cone of light starting from the position, emitting toward the direction.
  16357. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16358. * and the exponent defines the speed of the decay of the light with distance (reach).
  16359. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16360. */
  16361. class SpotLight extends ShadowLight {
  16362. private _angle;
  16363. private _innerAngle;
  16364. private _cosHalfAngle;
  16365. private _lightAngleScale;
  16366. private _lightAngleOffset;
  16367. /**
  16368. * Gets the cone angle of the spot light in Radians.
  16369. */
  16370. /**
  16371. * Sets the cone angle of the spot light in Radians.
  16372. */
  16373. angle: number;
  16374. /**
  16375. * Only used in gltf falloff mode, this defines the angle where
  16376. * the directional falloff will start before cutting at angle which could be seen
  16377. * as outer angle.
  16378. */
  16379. /**
  16380. * Only used in gltf falloff mode, this defines the angle where
  16381. * the directional falloff will start before cutting at angle which could be seen
  16382. * as outer angle.
  16383. */
  16384. innerAngle: number;
  16385. private _shadowAngleScale;
  16386. /**
  16387. * Allows scaling the angle of the light for shadow generation only.
  16388. */
  16389. /**
  16390. * Allows scaling the angle of the light for shadow generation only.
  16391. */
  16392. shadowAngleScale: number;
  16393. /**
  16394. * The light decay speed with the distance from the emission spot.
  16395. */
  16396. exponent: number;
  16397. private _projectionTextureMatrix;
  16398. /**
  16399. * Allows reading the projecton texture
  16400. */
  16401. readonly projectionTextureMatrix: Matrix;
  16402. protected _projectionTextureLightNear: number;
  16403. /**
  16404. * Gets the near clip of the Spotlight for texture projection.
  16405. */
  16406. /**
  16407. * Sets the near clip of the Spotlight for texture projection.
  16408. */
  16409. projectionTextureLightNear: number;
  16410. protected _projectionTextureLightFar: number;
  16411. /**
  16412. * Gets the far clip of the Spotlight for texture projection.
  16413. */
  16414. /**
  16415. * Sets the far clip of the Spotlight for texture projection.
  16416. */
  16417. projectionTextureLightFar: number;
  16418. protected _projectionTextureUpDirection: Vector3;
  16419. /**
  16420. * Gets the Up vector of the Spotlight for texture projection.
  16421. */
  16422. /**
  16423. * Sets the Up vector of the Spotlight for texture projection.
  16424. */
  16425. projectionTextureUpDirection: Vector3;
  16426. private _projectionTexture;
  16427. /**
  16428. * Gets the projection texture of the light.
  16429. */
  16430. /**
  16431. * Sets the projection texture of the light.
  16432. */
  16433. projectionTexture: Nullable<BaseTexture>;
  16434. private _projectionTextureViewLightDirty;
  16435. private _projectionTextureProjectionLightDirty;
  16436. private _projectionTextureDirty;
  16437. private _projectionTextureViewTargetVector;
  16438. private _projectionTextureViewLightMatrix;
  16439. private _projectionTextureProjectionLightMatrix;
  16440. private _projectionTextureScalingMatrix;
  16441. /**
  16442. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16443. * It can cast shadows.
  16444. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16445. * @param name The light friendly name
  16446. * @param position The position of the spot light in the scene
  16447. * @param direction The direction of the light in the scene
  16448. * @param angle The cone angle of the light in Radians
  16449. * @param exponent The light decay speed with the distance from the emission spot
  16450. * @param scene The scene the lights belongs to
  16451. */
  16452. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16453. /**
  16454. * Returns the string "SpotLight".
  16455. * @returns the class name
  16456. */
  16457. getClassName(): string;
  16458. /**
  16459. * Returns the integer 2.
  16460. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16461. */
  16462. getTypeID(): number;
  16463. /**
  16464. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16465. */
  16466. protected _setDirection(value: Vector3): void;
  16467. /**
  16468. * Overrides the position setter to recompute the projection texture view light Matrix.
  16469. */
  16470. protected _setPosition(value: Vector3): void;
  16471. /**
  16472. * 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.
  16473. * Returns the SpotLight.
  16474. */
  16475. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16476. protected _computeProjectionTextureViewLightMatrix(): void;
  16477. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16478. /**
  16479. * Main function for light texture projection matrix computing.
  16480. */
  16481. protected _computeProjectionTextureMatrix(): void;
  16482. protected _buildUniformLayout(): void;
  16483. private _computeAngleValues;
  16484. /**
  16485. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16486. * @param effect The effect to update
  16487. * @param lightIndex The index of the light in the effect to update
  16488. * @returns The spot light
  16489. */
  16490. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16491. /**
  16492. * Disposes the light and the associated resources.
  16493. */
  16494. dispose(): void;
  16495. /**
  16496. * Prepares the list of defines specific to the light type.
  16497. * @param defines the list of defines
  16498. * @param lightIndex defines the index of the light for the effect
  16499. */
  16500. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16501. }
  16502. }
  16503. declare module BABYLON {
  16504. /**
  16505. * Interface used to present a loading screen while loading a scene
  16506. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16507. */
  16508. interface ILoadingScreen {
  16509. /**
  16510. * Function called to display the loading screen
  16511. */
  16512. displayLoadingUI: () => void;
  16513. /**
  16514. * Function called to hide the loading screen
  16515. */
  16516. hideLoadingUI: () => void;
  16517. /**
  16518. * Gets or sets the color to use for the background
  16519. */
  16520. loadingUIBackgroundColor: string;
  16521. /**
  16522. * Gets or sets the text to display while loading
  16523. */
  16524. loadingUIText: string;
  16525. }
  16526. /**
  16527. * Class used for the default loading screen
  16528. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16529. */
  16530. class DefaultLoadingScreen implements ILoadingScreen {
  16531. private _renderingCanvas;
  16532. private _loadingText;
  16533. private _loadingDivBackgroundColor;
  16534. private _loadingDiv;
  16535. private _loadingTextDiv;
  16536. /**
  16537. * Creates a new default loading screen
  16538. * @param _renderingCanvas defines the canvas used to render the scene
  16539. * @param _loadingText defines the default text to display
  16540. * @param _loadingDivBackgroundColor defines the default background color
  16541. */
  16542. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16543. /**
  16544. * Function called to display the loading screen
  16545. */
  16546. displayLoadingUI(): void;
  16547. /**
  16548. * Function called to hide the loading screen
  16549. */
  16550. hideLoadingUI(): void;
  16551. /**
  16552. * Gets or sets the text to display while loading
  16553. */
  16554. loadingUIText: string;
  16555. /**
  16556. * Gets or sets the color to use for the background
  16557. */
  16558. loadingUIBackgroundColor: string;
  16559. private _resizeLoadingUI;
  16560. }
  16561. }
  16562. declare module BABYLON {
  16563. /**
  16564. * Class used to represent data loading progression
  16565. */
  16566. class SceneLoaderProgressEvent {
  16567. /** defines if data length to load can be evaluated */
  16568. readonly lengthComputable: boolean;
  16569. /** defines the loaded data length */
  16570. readonly loaded: number;
  16571. /** defines the data length to load */
  16572. readonly total: number;
  16573. /**
  16574. * Create a new progress event
  16575. * @param lengthComputable defines if data length to load can be evaluated
  16576. * @param loaded defines the loaded data length
  16577. * @param total defines the data length to load
  16578. */
  16579. constructor(
  16580. /** defines if data length to load can be evaluated */
  16581. lengthComputable: boolean,
  16582. /** defines the loaded data length */
  16583. loaded: number,
  16584. /** defines the data length to load */
  16585. total: number);
  16586. /**
  16587. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16588. * @param event defines the source event
  16589. * @returns a new SceneLoaderProgressEvent
  16590. */
  16591. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16592. }
  16593. /**
  16594. * Interface used by SceneLoader plugins to define supported file extensions
  16595. */
  16596. interface ISceneLoaderPluginExtensions {
  16597. /**
  16598. * Defines the list of supported extensions
  16599. */
  16600. [extension: string]: {
  16601. isBinary: boolean;
  16602. };
  16603. }
  16604. /**
  16605. * Interface used by SceneLoader plugin factory
  16606. */
  16607. interface ISceneLoaderPluginFactory {
  16608. /**
  16609. * Defines the name of the factory
  16610. */
  16611. name: string;
  16612. /**
  16613. * Function called to create a new plugin
  16614. * @return the new plugin
  16615. */
  16616. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16617. /**
  16618. * Boolean indicating if the plugin can direct load specific data
  16619. */
  16620. canDirectLoad?: (data: string) => boolean;
  16621. }
  16622. /**
  16623. * Interface used to define a SceneLoader plugin
  16624. */
  16625. interface ISceneLoaderPlugin {
  16626. /**
  16627. * The friendly name of this plugin.
  16628. */
  16629. name: string;
  16630. /**
  16631. * The file extensions supported by this plugin.
  16632. */
  16633. extensions: string | ISceneLoaderPluginExtensions;
  16634. /**
  16635. * Import meshes into a scene.
  16636. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16637. * @param scene The scene to import into
  16638. * @param data The data to import
  16639. * @param rootUrl The root url for scene and resources
  16640. * @param meshes The meshes array to import into
  16641. * @param particleSystems The particle systems array to import into
  16642. * @param skeletons The skeletons array to import into
  16643. * @param onError The callback when import fails
  16644. * @returns True if successful or false otherwise
  16645. */
  16646. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16647. /**
  16648. * Load into a scene.
  16649. * @param scene The scene to load into
  16650. * @param data The data to import
  16651. * @param rootUrl The root url for scene and resources
  16652. * @param onError The callback when import fails
  16653. * @returns true if successful or false otherwise
  16654. */
  16655. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16656. /**
  16657. * The callback that returns true if the data can be directly loaded.
  16658. */
  16659. canDirectLoad?: (data: string) => boolean;
  16660. /**
  16661. * The callback that allows custom handling of the root url based on the response url.
  16662. */
  16663. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16664. /**
  16665. * Load into an asset container.
  16666. * @param scene The scene to load into
  16667. * @param data The data to import
  16668. * @param rootUrl The root url for scene and resources
  16669. * @param onError The callback when import fails
  16670. * @returns The loaded asset container
  16671. */
  16672. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16673. }
  16674. /**
  16675. * Interface used to define an async SceneLoader plugin
  16676. */
  16677. interface ISceneLoaderPluginAsync {
  16678. /**
  16679. * The friendly name of this plugin.
  16680. */
  16681. name: string;
  16682. /**
  16683. * The file extensions supported by this plugin.
  16684. */
  16685. extensions: string | ISceneLoaderPluginExtensions;
  16686. /**
  16687. * Import meshes into a scene.
  16688. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16689. * @param scene The scene to import into
  16690. * @param data The data to import
  16691. * @param rootUrl The root url for scene and resources
  16692. * @param onProgress The callback when the load progresses
  16693. * @param fileName Defines the name of the file to load
  16694. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16695. */
  16696. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16697. meshes: AbstractMesh[];
  16698. particleSystems: IParticleSystem[];
  16699. skeletons: Skeleton[];
  16700. animationGroups: AnimationGroup[];
  16701. }>;
  16702. /**
  16703. * Load into a scene.
  16704. * @param scene The scene to load into
  16705. * @param data The data to import
  16706. * @param rootUrl The root url for scene and resources
  16707. * @param onProgress The callback when the load progresses
  16708. * @param fileName Defines the name of the file to load
  16709. * @returns Nothing
  16710. */
  16711. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16712. /**
  16713. * The callback that returns true if the data can be directly loaded.
  16714. */
  16715. canDirectLoad?: (data: string) => boolean;
  16716. /**
  16717. * The callback that allows custom handling of the root url based on the response url.
  16718. */
  16719. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16720. /**
  16721. * Load into an asset container.
  16722. * @param scene The scene to load into
  16723. * @param data The data to import
  16724. * @param rootUrl The root url for scene and resources
  16725. * @param onProgress The callback when the load progresses
  16726. * @param fileName Defines the name of the file to load
  16727. * @returns The loaded asset container
  16728. */
  16729. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16730. }
  16731. /**
  16732. * Class used to load scene from various file formats using registered plugins
  16733. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16734. */
  16735. class SceneLoader {
  16736. private static _ForceFullSceneLoadingForIncremental;
  16737. private static _ShowLoadingScreen;
  16738. private static _CleanBoneMatrixWeights;
  16739. /**
  16740. * No logging while loading
  16741. */
  16742. static readonly NO_LOGGING: number;
  16743. /**
  16744. * Minimal logging while loading
  16745. */
  16746. static readonly MINIMAL_LOGGING: number;
  16747. /**
  16748. * Summary logging while loading
  16749. */
  16750. static readonly SUMMARY_LOGGING: number;
  16751. /**
  16752. * Detailled logging while loading
  16753. */
  16754. static readonly DETAILED_LOGGING: number;
  16755. private static _loggingLevel;
  16756. /**
  16757. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16758. */
  16759. static ForceFullSceneLoadingForIncremental: boolean;
  16760. /**
  16761. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16762. */
  16763. static ShowLoadingScreen: boolean;
  16764. /**
  16765. * Defines the current logging level (while loading the scene)
  16766. * @ignorenaming
  16767. */
  16768. static loggingLevel: number;
  16769. /**
  16770. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16771. */
  16772. static CleanBoneMatrixWeights: boolean;
  16773. /**
  16774. * Event raised when a plugin is used to load a scene
  16775. */
  16776. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16777. private static _registeredPlugins;
  16778. private static _getDefaultPlugin;
  16779. private static _getPluginForExtension;
  16780. private static _getPluginForDirectLoad;
  16781. private static _getPluginForFilename;
  16782. private static _getDirectLoad;
  16783. private static _loadData;
  16784. private static _getFileInfo;
  16785. /**
  16786. * Gets a plugin that can load the given extension
  16787. * @param extension defines the extension to load
  16788. * @returns a plugin or null if none works
  16789. */
  16790. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16791. /**
  16792. * Gets a boolean indicating that the given extension can be loaded
  16793. * @param extension defines the extension to load
  16794. * @returns true if the extension is supported
  16795. */
  16796. static IsPluginForExtensionAvailable(extension: string): boolean;
  16797. /**
  16798. * Adds a new plugin to the list of registered plugins
  16799. * @param plugin defines the plugin to add
  16800. */
  16801. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16802. /**
  16803. * Import meshes into a scene
  16804. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16805. * @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)
  16806. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16807. * @param scene the instance of BABYLON.Scene to append to
  16808. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16809. * @param onProgress a callback with a progress event for each file being loaded
  16810. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16811. * @param pluginExtension the extension used to determine the plugin
  16812. * @returns The loaded plugin
  16813. */
  16814. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16815. /**
  16816. * Import meshes into a scene
  16817. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16818. * @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)
  16819. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16820. * @param scene the instance of BABYLON.Scene to append to
  16821. * @param onProgress a callback with a progress event for each file being loaded
  16822. * @param pluginExtension the extension used to determine the plugin
  16823. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16824. */
  16825. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16826. meshes: AbstractMesh[];
  16827. particleSystems: IParticleSystem[];
  16828. skeletons: Skeleton[];
  16829. animationGroups: AnimationGroup[];
  16830. }>;
  16831. /**
  16832. * Load a scene
  16833. * @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)
  16834. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16835. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16836. * @param onSuccess a callback with the scene when import succeeds
  16837. * @param onProgress a callback with a progress event for each file being loaded
  16838. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16839. * @param pluginExtension the extension used to determine the plugin
  16840. * @returns The loaded plugin
  16841. */
  16842. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16843. /**
  16844. * Load a scene
  16845. * @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)
  16846. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16847. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16848. * @param onProgress a callback with a progress event for each file being loaded
  16849. * @param pluginExtension the extension used to determine the plugin
  16850. * @returns The loaded scene
  16851. */
  16852. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16853. /**
  16854. * Append a scene
  16855. * @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)
  16856. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16857. * @param scene is the instance of BABYLON.Scene to append to
  16858. * @param onSuccess a callback with the scene when import succeeds
  16859. * @param onProgress a callback with a progress event for each file being loaded
  16860. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16861. * @param pluginExtension the extension used to determine the plugin
  16862. * @returns The loaded plugin
  16863. */
  16864. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16865. /**
  16866. * Append a scene
  16867. * @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)
  16868. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16869. * @param scene is the instance of BABYLON.Scene to append to
  16870. * @param onProgress a callback with a progress event for each file being loaded
  16871. * @param pluginExtension the extension used to determine the plugin
  16872. * @returns The given scene
  16873. */
  16874. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16875. /**
  16876. * Load a scene into an asset container
  16877. * @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)
  16878. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16879. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16880. * @param onSuccess a callback with the scene when import succeeds
  16881. * @param onProgress a callback with a progress event for each file being loaded
  16882. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16883. * @param pluginExtension the extension used to determine the plugin
  16884. * @returns The loaded plugin
  16885. */
  16886. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16887. /**
  16888. * Load a scene into an asset container
  16889. * @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)
  16890. * @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)
  16891. * @param scene is the instance of BABYLON.Scene to append to
  16892. * @param onProgress a callback with a progress event for each file being loaded
  16893. * @param pluginExtension the extension used to determine the plugin
  16894. * @returns The loaded asset container
  16895. */
  16896. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16897. }
  16898. }
  16899. declare module BABYLON {
  16900. /**
  16901. * Scalar computation library
  16902. */
  16903. class Scalar {
  16904. /**
  16905. * Two pi constants convenient for computation.
  16906. */
  16907. static TwoPi: number;
  16908. /**
  16909. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  16910. * @param a number
  16911. * @param b number
  16912. * @param epsilon (default = 1.401298E-45)
  16913. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  16914. */
  16915. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  16916. /**
  16917. * Returns a string : the upper case translation of the number i to hexadecimal.
  16918. * @param i number
  16919. * @returns the upper case translation of the number i to hexadecimal.
  16920. */
  16921. static ToHex(i: number): string;
  16922. /**
  16923. * Returns -1 if value is negative and +1 is value is positive.
  16924. * @param value the value
  16925. * @returns the value itself if it's equal to zero.
  16926. */
  16927. static Sign(value: number): number;
  16928. /**
  16929. * Returns the value itself if it's between min and max.
  16930. * Returns min if the value is lower than min.
  16931. * Returns max if the value is greater than max.
  16932. * @param value the value to clmap
  16933. * @param min the min value to clamp to (default: 0)
  16934. * @param max the max value to clamp to (default: 1)
  16935. * @returns the clamped value
  16936. */
  16937. static Clamp(value: number, min?: number, max?: number): number;
  16938. /**
  16939. * the log2 of value.
  16940. * @param value the value to compute log2 of
  16941. * @returns the log2 of value.
  16942. */
  16943. static Log2(value: number): number;
  16944. /**
  16945. * Loops the value, so that it is never larger than length and never smaller than 0.
  16946. *
  16947. * This is similar to the modulo operator but it works with floating point numbers.
  16948. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  16949. * With t = 5 and length = 2.5, the result would be 0.0.
  16950. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  16951. * @param value the value
  16952. * @param length the length
  16953. * @returns the looped value
  16954. */
  16955. static Repeat(value: number, length: number): number;
  16956. /**
  16957. * Normalize the value between 0.0 and 1.0 using min and max values
  16958. * @param value value to normalize
  16959. * @param min max to normalize between
  16960. * @param max min to normalize between
  16961. * @returns the normalized value
  16962. */
  16963. static Normalize(value: number, min: number, max: number): number;
  16964. /**
  16965. * Denormalize the value from 0.0 and 1.0 using min and max values
  16966. * @param normalized value to denormalize
  16967. * @param min max to denormalize between
  16968. * @param max min to denormalize between
  16969. * @returns the denormalized value
  16970. */
  16971. static Denormalize(normalized: number, min: number, max: number): number;
  16972. /**
  16973. * Calculates the shortest difference between two given angles given in degrees.
  16974. * @param current current angle in degrees
  16975. * @param target target angle in degrees
  16976. * @returns the delta
  16977. */
  16978. static DeltaAngle(current: number, target: number): number;
  16979. /**
  16980. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  16981. * @param tx value
  16982. * @param length length
  16983. * @returns The returned value will move back and forth between 0 and length
  16984. */
  16985. static PingPong(tx: number, length: number): number;
  16986. /**
  16987. * Interpolates between min and max with smoothing at the limits.
  16988. *
  16989. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  16990. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  16991. * @param from from
  16992. * @param to to
  16993. * @param tx value
  16994. * @returns the smooth stepped value
  16995. */
  16996. static SmoothStep(from: number, to: number, tx: number): number;
  16997. /**
  16998. * Moves a value current towards target.
  16999. *
  17000. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  17001. * Negative values of maxDelta pushes the value away from target.
  17002. * @param current current value
  17003. * @param target target value
  17004. * @param maxDelta max distance to move
  17005. * @returns resulting value
  17006. */
  17007. static MoveTowards(current: number, target: number, maxDelta: number): number;
  17008. /**
  17009. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  17010. *
  17011. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  17012. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  17013. * @param current current value
  17014. * @param target target value
  17015. * @param maxDelta max distance to move
  17016. * @returns resulting angle
  17017. */
  17018. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  17019. /**
  17020. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  17021. * @param start start value
  17022. * @param end target value
  17023. * @param amount amount to lerp between
  17024. * @returns the lerped value
  17025. */
  17026. static Lerp(start: number, end: number, amount: number): number;
  17027. /**
  17028. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  17029. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  17030. * @param start start value
  17031. * @param end target value
  17032. * @param amount amount to lerp between
  17033. * @returns the lerped value
  17034. */
  17035. static LerpAngle(start: number, end: number, amount: number): number;
  17036. /**
  17037. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  17038. * @param a start value
  17039. * @param b target value
  17040. * @param value value between a and b
  17041. * @returns the inverseLerp value
  17042. */
  17043. static InverseLerp(a: number, b: number, value: number): number;
  17044. /**
  17045. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  17046. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  17047. * @param value1 spline value
  17048. * @param tangent1 spline value
  17049. * @param value2 spline value
  17050. * @param tangent2 spline value
  17051. * @param amount input value
  17052. * @returns hermite result
  17053. */
  17054. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  17055. /**
  17056. * Returns a random float number between and min and max values
  17057. * @param min min value of random
  17058. * @param max max value of random
  17059. * @returns random value
  17060. */
  17061. static RandomRange(min: number, max: number): number;
  17062. /**
  17063. * This function returns percentage of a number in a given range.
  17064. *
  17065. * RangeToPercent(40,20,60) will return 0.5 (50%)
  17066. * RangeToPercent(34,0,100) will return 0.34 (34%)
  17067. * @param number to convert to percentage
  17068. * @param min min range
  17069. * @param max max range
  17070. * @returns the percentage
  17071. */
  17072. static RangeToPercent(number: number, min: number, max: number): number;
  17073. /**
  17074. * This function returns number that corresponds to the percentage in a given range.
  17075. *
  17076. * PercentToRange(0.34,0,100) will return 34.
  17077. * @param percent to convert to number
  17078. * @param min min range
  17079. * @param max max range
  17080. * @returns the number
  17081. */
  17082. static PercentToRange(percent: number, min: number, max: number): number;
  17083. /**
  17084. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  17085. * @param angle The angle to normalize in radian.
  17086. * @return The converted angle.
  17087. */
  17088. static NormalizeRadians(angle: number): number;
  17089. }
  17090. }
  17091. declare module BABYLON {
  17092. /**
  17093. * Constant used to convert a value to gamma space
  17094. * @ignorenaming
  17095. */
  17096. const ToGammaSpace: number;
  17097. /**
  17098. * Constant used to convert a value to linear space
  17099. * @ignorenaming
  17100. */
  17101. const ToLinearSpace = 2.2;
  17102. /**
  17103. * Constant used to define the minimal number value in Babylon.js
  17104. * @ignorenaming
  17105. */
  17106. const Epsilon = 0.001;
  17107. /**
  17108. * Class used to hold a RBG color
  17109. */
  17110. class Color3 {
  17111. /**
  17112. * Defines the red component (between 0 and 1, default is 0)
  17113. */
  17114. r: number;
  17115. /**
  17116. * Defines the green component (between 0 and 1, default is 0)
  17117. */
  17118. g: number;
  17119. /**
  17120. * Defines the blue component (between 0 and 1, default is 0)
  17121. */
  17122. b: number;
  17123. /**
  17124. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  17125. * @param r defines the red component (between 0 and 1, default is 0)
  17126. * @param g defines the green component (between 0 and 1, default is 0)
  17127. * @param b defines the blue component (between 0 and 1, default is 0)
  17128. */
  17129. constructor(
  17130. /**
  17131. * Defines the red component (between 0 and 1, default is 0)
  17132. */
  17133. r?: number,
  17134. /**
  17135. * Defines the green component (between 0 and 1, default is 0)
  17136. */
  17137. g?: number,
  17138. /**
  17139. * Defines the blue component (between 0 and 1, default is 0)
  17140. */
  17141. b?: number);
  17142. /**
  17143. * Creates a string with the Color3 current values
  17144. * @returns the string representation of the Color3 object
  17145. */
  17146. toString(): string;
  17147. /**
  17148. * Returns the string "Color3"
  17149. * @returns "Color3"
  17150. */
  17151. getClassName(): string;
  17152. /**
  17153. * Compute the Color3 hash code
  17154. * @returns an unique number that can be used to hash Color3 objects
  17155. */
  17156. getHashCode(): number;
  17157. /**
  17158. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  17159. * @param array defines the array where to store the r,g,b components
  17160. * @param index defines an optional index in the target array to define where to start storing values
  17161. * @returns the current Color3 object
  17162. */
  17163. toArray(array: FloatArray, index?: number): Color3;
  17164. /**
  17165. * Returns a new Color4 object from the current Color3 and the given alpha
  17166. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  17167. * @returns a new Color4 object
  17168. */
  17169. toColor4(alpha?: number): Color4;
  17170. /**
  17171. * Returns a new array populated with 3 numeric elements : red, green and blue values
  17172. * @returns the new array
  17173. */
  17174. asArray(): number[];
  17175. /**
  17176. * Returns the luminance value
  17177. * @returns a float value
  17178. */
  17179. toLuminance(): number;
  17180. /**
  17181. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  17182. * @param otherColor defines the second operand
  17183. * @returns the new Color3 object
  17184. */
  17185. multiply(otherColor: DeepImmutable<Color3>): Color3;
  17186. /**
  17187. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  17188. * @param otherColor defines the second operand
  17189. * @param result defines the Color3 object where to store the result
  17190. * @returns the current Color3
  17191. */
  17192. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  17193. /**
  17194. * Determines equality between Color3 objects
  17195. * @param otherColor defines the second operand
  17196. * @returns true if the rgb values are equal to the given ones
  17197. */
  17198. equals(otherColor: DeepImmutable<Color3>): boolean;
  17199. /**
  17200. * Determines equality between the current Color3 object and a set of r,b,g values
  17201. * @param r defines the red component to check
  17202. * @param g defines the green component to check
  17203. * @param b defines the blue component to check
  17204. * @returns true if the rgb values are equal to the given ones
  17205. */
  17206. equalsFloats(r: number, g: number, b: number): boolean;
  17207. /**
  17208. * Multiplies in place each rgb value by scale
  17209. * @param scale defines the scaling factor
  17210. * @returns the updated Color3
  17211. */
  17212. scale(scale: number): Color3;
  17213. /**
  17214. * Multiplies the rgb values by scale and stores the result into "result"
  17215. * @param scale defines the scaling factor
  17216. * @param result defines the Color3 object where to store the result
  17217. * @returns the unmodified current Color3
  17218. */
  17219. scaleToRef(scale: number, result: Color3): Color3;
  17220. /**
  17221. * Scale the current Color3 values by a factor and add the result to a given Color3
  17222. * @param scale defines the scale factor
  17223. * @param result defines color to store the result into
  17224. * @returns the unmodified current Color3
  17225. */
  17226. scaleAndAddToRef(scale: number, result: Color3): Color3;
  17227. /**
  17228. * Clamps the rgb values by the min and max values and stores the result into "result"
  17229. * @param min defines minimum clamping value (default is 0)
  17230. * @param max defines maximum clamping value (default is 1)
  17231. * @param result defines color to store the result into
  17232. * @returns the original Color3
  17233. */
  17234. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  17235. /**
  17236. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  17237. * @param otherColor defines the second operand
  17238. * @returns the new Color3
  17239. */
  17240. add(otherColor: DeepImmutable<Color3>): Color3;
  17241. /**
  17242. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  17243. * @param otherColor defines the second operand
  17244. * @param result defines Color3 object to store the result into
  17245. * @returns the unmodified current Color3
  17246. */
  17247. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  17248. /**
  17249. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  17250. * @param otherColor defines the second operand
  17251. * @returns the new Color3
  17252. */
  17253. subtract(otherColor: DeepImmutable<Color3>): Color3;
  17254. /**
  17255. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  17256. * @param otherColor defines the second operand
  17257. * @param result defines Color3 object to store the result into
  17258. * @returns the unmodified current Color3
  17259. */
  17260. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  17261. /**
  17262. * Copy the current object
  17263. * @returns a new Color3 copied the current one
  17264. */
  17265. clone(): Color3;
  17266. /**
  17267. * Copies the rgb values from the source in the current Color3
  17268. * @param source defines the source Color3 object
  17269. * @returns the updated Color3 object
  17270. */
  17271. copyFrom(source: DeepImmutable<Color3>): Color3;
  17272. /**
  17273. * Updates the Color3 rgb values from the given floats
  17274. * @param r defines the red component to read from
  17275. * @param g defines the green component to read from
  17276. * @param b defines the blue component to read from
  17277. * @returns the current Color3 object
  17278. */
  17279. copyFromFloats(r: number, g: number, b: number): Color3;
  17280. /**
  17281. * Updates the Color3 rgb values from the given floats
  17282. * @param r defines the red component to read from
  17283. * @param g defines the green component to read from
  17284. * @param b defines the blue component to read from
  17285. * @returns the current Color3 object
  17286. */
  17287. set(r: number, g: number, b: number): Color3;
  17288. /**
  17289. * Compute the Color3 hexadecimal code as a string
  17290. * @returns a string containing the hexadecimal representation of the Color3 object
  17291. */
  17292. toHexString(): string;
  17293. /**
  17294. * Computes a new Color3 converted from the current one to linear space
  17295. * @returns a new Color3 object
  17296. */
  17297. toLinearSpace(): Color3;
  17298. /**
  17299. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  17300. * @param convertedColor defines the Color3 object where to store the linear space version
  17301. * @returns the unmodified Color3
  17302. */
  17303. toLinearSpaceToRef(convertedColor: Color3): Color3;
  17304. /**
  17305. * Computes a new Color3 converted from the current one to gamma space
  17306. * @returns a new Color3 object
  17307. */
  17308. toGammaSpace(): Color3;
  17309. /**
  17310. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  17311. * @param convertedColor defines the Color3 object where to store the gamma space version
  17312. * @returns the unmodified Color3
  17313. */
  17314. toGammaSpaceToRef(convertedColor: Color3): Color3;
  17315. /**
  17316. * Creates a new Color3 from the string containing valid hexadecimal values
  17317. * @param hex defines a string containing valid hexadecimal values
  17318. * @returns a new Color3 object
  17319. */
  17320. static FromHexString(hex: string): Color3;
  17321. /**
  17322. * Creates a new Vector3 from the starting index of the given array
  17323. * @param array defines the source array
  17324. * @param offset defines an offset in the source array
  17325. * @returns a new Color3 object
  17326. */
  17327. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  17328. /**
  17329. * Creates a new Color3 from integer values (< 256)
  17330. * @param r defines the red component to read from (value between 0 and 255)
  17331. * @param g defines the green component to read from (value between 0 and 255)
  17332. * @param b defines the blue component to read from (value between 0 and 255)
  17333. * @returns a new Color3 object
  17334. */
  17335. static FromInts(r: number, g: number, b: number): Color3;
  17336. /**
  17337. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  17338. * @param start defines the start Color3 value
  17339. * @param end defines the end Color3 value
  17340. * @param amount defines the gradient value between start and end
  17341. * @returns a new Color3 object
  17342. */
  17343. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  17344. /**
  17345. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  17346. * @param left defines the start value
  17347. * @param right defines the end value
  17348. * @param amount defines the gradient factor
  17349. * @param result defines the Color3 object where to store the result
  17350. */
  17351. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  17352. /**
  17353. * Returns a Color3 value containing a red color
  17354. * @returns a new Color3 object
  17355. */
  17356. static Red(): Color3;
  17357. /**
  17358. * Returns a Color3 value containing a green color
  17359. * @returns a new Color3 object
  17360. */
  17361. static Green(): Color3;
  17362. /**
  17363. * Returns a Color3 value containing a blue color
  17364. * @returns a new Color3 object
  17365. */
  17366. static Blue(): Color3;
  17367. /**
  17368. * Returns a Color3 value containing a black color
  17369. * @returns a new Color3 object
  17370. */
  17371. static Black(): Color3;
  17372. /**
  17373. * Returns a Color3 value containing a white color
  17374. * @returns a new Color3 object
  17375. */
  17376. static White(): Color3;
  17377. /**
  17378. * Returns a Color3 value containing a purple color
  17379. * @returns a new Color3 object
  17380. */
  17381. static Purple(): Color3;
  17382. /**
  17383. * Returns a Color3 value containing a magenta color
  17384. * @returns a new Color3 object
  17385. */
  17386. static Magenta(): Color3;
  17387. /**
  17388. * Returns a Color3 value containing a yellow color
  17389. * @returns a new Color3 object
  17390. */
  17391. static Yellow(): Color3;
  17392. /**
  17393. * Returns a Color3 value containing a gray color
  17394. * @returns a new Color3 object
  17395. */
  17396. static Gray(): Color3;
  17397. /**
  17398. * Returns a Color3 value containing a teal color
  17399. * @returns a new Color3 object
  17400. */
  17401. static Teal(): Color3;
  17402. /**
  17403. * Returns a Color3 value containing a random color
  17404. * @returns a new Color3 object
  17405. */
  17406. static Random(): Color3;
  17407. }
  17408. /**
  17409. * Class used to hold a RBGA color
  17410. */
  17411. class Color4 {
  17412. /**
  17413. * Defines the red component (between 0 and 1, default is 0)
  17414. */
  17415. r: number;
  17416. /**
  17417. * Defines the green component (between 0 and 1, default is 0)
  17418. */
  17419. g: number;
  17420. /**
  17421. * Defines the blue component (between 0 and 1, default is 0)
  17422. */
  17423. b: number;
  17424. /**
  17425. * Defines the alpha component (between 0 and 1, default is 1)
  17426. */
  17427. a: number;
  17428. /**
  17429. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  17430. * @param r defines the red component (between 0 and 1, default is 0)
  17431. * @param g defines the green component (between 0 and 1, default is 0)
  17432. * @param b defines the blue component (between 0 and 1, default is 0)
  17433. * @param a defines the alpha component (between 0 and 1, default is 1)
  17434. */
  17435. constructor(
  17436. /**
  17437. * Defines the red component (between 0 and 1, default is 0)
  17438. */
  17439. r?: number,
  17440. /**
  17441. * Defines the green component (between 0 and 1, default is 0)
  17442. */
  17443. g?: number,
  17444. /**
  17445. * Defines the blue component (between 0 and 1, default is 0)
  17446. */
  17447. b?: number,
  17448. /**
  17449. * Defines the alpha component (between 0 and 1, default is 1)
  17450. */
  17451. a?: number);
  17452. /**
  17453. * Adds in place the given Color4 values to the current Color4 object
  17454. * @param right defines the second operand
  17455. * @returns the current updated Color4 object
  17456. */
  17457. addInPlace(right: DeepImmutable<Color4>): Color4;
  17458. /**
  17459. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  17460. * @returns the new array
  17461. */
  17462. asArray(): number[];
  17463. /**
  17464. * Stores from the starting index in the given array the Color4 successive values
  17465. * @param array defines the array where to store the r,g,b components
  17466. * @param index defines an optional index in the target array to define where to start storing values
  17467. * @returns the current Color4 object
  17468. */
  17469. toArray(array: number[], index?: number): Color4;
  17470. /**
  17471. * Determines equality between Color4 objects
  17472. * @param otherColor defines the second operand
  17473. * @returns true if the rgba values are equal to the given ones
  17474. */
  17475. equals(otherColor: DeepImmutable<Color4>): boolean;
  17476. /**
  17477. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  17478. * @param right defines the second operand
  17479. * @returns a new Color4 object
  17480. */
  17481. add(right: DeepImmutable<Color4>): Color4;
  17482. /**
  17483. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  17484. * @param right defines the second operand
  17485. * @returns a new Color4 object
  17486. */
  17487. subtract(right: DeepImmutable<Color4>): Color4;
  17488. /**
  17489. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  17490. * @param right defines the second operand
  17491. * @param result defines the Color4 object where to store the result
  17492. * @returns the current Color4 object
  17493. */
  17494. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  17495. /**
  17496. * Creates a new Color4 with the current Color4 values multiplied by scale
  17497. * @param scale defines the scaling factor to apply
  17498. * @returns a new Color4 object
  17499. */
  17500. scale(scale: number): Color4;
  17501. /**
  17502. * Multiplies the current Color4 values by scale and stores the result in "result"
  17503. * @param scale defines the scaling factor to apply
  17504. * @param result defines the Color4 object where to store the result
  17505. * @returns the current unmodified Color4
  17506. */
  17507. scaleToRef(scale: number, result: Color4): Color4;
  17508. /**
  17509. * Scale the current Color4 values by a factor and add the result to a given Color4
  17510. * @param scale defines the scale factor
  17511. * @param result defines the Color4 object where to store the result
  17512. * @returns the unmodified current Color4
  17513. */
  17514. scaleAndAddToRef(scale: number, result: Color4): Color4;
  17515. /**
  17516. * Clamps the rgb values by the min and max values and stores the result into "result"
  17517. * @param min defines minimum clamping value (default is 0)
  17518. * @param max defines maximum clamping value (default is 1)
  17519. * @param result defines color to store the result into.
  17520. * @returns the cuurent Color4
  17521. */
  17522. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  17523. /**
  17524. * Multipy an Color4 value by another and return a new Color4 object
  17525. * @param color defines the Color4 value to multiply by
  17526. * @returns a new Color4 object
  17527. */
  17528. multiply(color: Color4): Color4;
  17529. /**
  17530. * Multipy a Color4 value by another and push the result in a reference value
  17531. * @param color defines the Color4 value to multiply by
  17532. * @param result defines the Color4 to fill the result in
  17533. * @returns the result Color4
  17534. */
  17535. multiplyToRef(color: Color4, result: Color4): Color4;
  17536. /**
  17537. * Creates a string with the Color4 current values
  17538. * @returns the string representation of the Color4 object
  17539. */
  17540. toString(): string;
  17541. /**
  17542. * Returns the string "Color4"
  17543. * @returns "Color4"
  17544. */
  17545. getClassName(): string;
  17546. /**
  17547. * Compute the Color4 hash code
  17548. * @returns an unique number that can be used to hash Color4 objects
  17549. */
  17550. getHashCode(): number;
  17551. /**
  17552. * Creates a new Color4 copied from the current one
  17553. * @returns a new Color4 object
  17554. */
  17555. clone(): Color4;
  17556. /**
  17557. * Copies the given Color4 values into the current one
  17558. * @param source defines the source Color4 object
  17559. * @returns the current updated Color4 object
  17560. */
  17561. copyFrom(source: Color4): Color4;
  17562. /**
  17563. * Copies the given float values into the current one
  17564. * @param r defines the red component to read from
  17565. * @param g defines the green component to read from
  17566. * @param b defines the blue component to read from
  17567. * @param a defines the alpha component to read from
  17568. * @returns the current updated Color4 object
  17569. */
  17570. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  17571. /**
  17572. * Copies the given float values into the current one
  17573. * @param r defines the red component to read from
  17574. * @param g defines the green component to read from
  17575. * @param b defines the blue component to read from
  17576. * @param a defines the alpha component to read from
  17577. * @returns the current updated Color4 object
  17578. */
  17579. set(r: number, g: number, b: number, a: number): Color4;
  17580. /**
  17581. * Compute the Color4 hexadecimal code as a string
  17582. * @returns a string containing the hexadecimal representation of the Color4 object
  17583. */
  17584. toHexString(): string;
  17585. /**
  17586. * Computes a new Color4 converted from the current one to linear space
  17587. * @returns a new Color4 object
  17588. */
  17589. toLinearSpace(): Color4;
  17590. /**
  17591. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  17592. * @param convertedColor defines the Color4 object where to store the linear space version
  17593. * @returns the unmodified Color4
  17594. */
  17595. toLinearSpaceToRef(convertedColor: Color4): Color4;
  17596. /**
  17597. * Computes a new Color4 converted from the current one to gamma space
  17598. * @returns a new Color4 object
  17599. */
  17600. toGammaSpace(): Color4;
  17601. /**
  17602. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  17603. * @param convertedColor defines the Color4 object where to store the gamma space version
  17604. * @returns the unmodified Color4
  17605. */
  17606. toGammaSpaceToRef(convertedColor: Color4): Color4;
  17607. /**
  17608. * Creates a new Color4 from the string containing valid hexadecimal values
  17609. * @param hex defines a string containing valid hexadecimal values
  17610. * @returns a new Color4 object
  17611. */
  17612. static FromHexString(hex: string): Color4;
  17613. /**
  17614. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  17615. * @param left defines the start value
  17616. * @param right defines the end value
  17617. * @param amount defines the gradient factor
  17618. * @returns a new Color4 object
  17619. */
  17620. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  17621. /**
  17622. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  17623. * @param left defines the start value
  17624. * @param right defines the end value
  17625. * @param amount defines the gradient factor
  17626. * @param result defines the Color4 object where to store data
  17627. */
  17628. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  17629. /**
  17630. * Creates a new Color4 from a Color3 and an alpha value
  17631. * @param color3 defines the source Color3 to read from
  17632. * @param alpha defines the alpha component (1.0 by default)
  17633. * @returns a new Color4 object
  17634. */
  17635. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  17636. /**
  17637. * Creates a new Color4 from the starting index element of the given array
  17638. * @param array defines the source array to read from
  17639. * @param offset defines the offset in the source array
  17640. * @returns a new Color4 object
  17641. */
  17642. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  17643. /**
  17644. * Creates a new Color3 from integer values (< 256)
  17645. * @param r defines the red component to read from (value between 0 and 255)
  17646. * @param g defines the green component to read from (value between 0 and 255)
  17647. * @param b defines the blue component to read from (value between 0 and 255)
  17648. * @param a defines the alpha component to read from (value between 0 and 255)
  17649. * @returns a new Color3 object
  17650. */
  17651. static FromInts(r: number, g: number, b: number, a: number): Color4;
  17652. /**
  17653. * Check the content of a given array and convert it to an array containing RGBA data
  17654. * If the original array was already containing count * 4 values then it is returned directly
  17655. * @param colors defines the array to check
  17656. * @param count defines the number of RGBA data to expect
  17657. * @returns an array containing count * 4 values (RGBA)
  17658. */
  17659. static CheckColors4(colors: number[], count: number): number[];
  17660. }
  17661. /**
  17662. * Class representing a vector containing 2 coordinates
  17663. */
  17664. class Vector2 {
  17665. /** defines the first coordinate */
  17666. x: number;
  17667. /** defines the second coordinate */
  17668. y: number;
  17669. /**
  17670. * Creates a new Vector2 from the given x and y coordinates
  17671. * @param x defines the first coordinate
  17672. * @param y defines the second coordinate
  17673. */
  17674. constructor(
  17675. /** defines the first coordinate */
  17676. x?: number,
  17677. /** defines the second coordinate */
  17678. y?: number);
  17679. /**
  17680. * Gets a string with the Vector2 coordinates
  17681. * @returns a string with the Vector2 coordinates
  17682. */
  17683. toString(): string;
  17684. /**
  17685. * Gets class name
  17686. * @returns the string "Vector2"
  17687. */
  17688. getClassName(): string;
  17689. /**
  17690. * Gets current vector hash code
  17691. * @returns the Vector2 hash code as a number
  17692. */
  17693. getHashCode(): number;
  17694. /**
  17695. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  17696. * @param array defines the source array
  17697. * @param index defines the offset in source array
  17698. * @returns the current Vector2
  17699. */
  17700. toArray(array: FloatArray, index?: number): Vector2;
  17701. /**
  17702. * Copy the current vector to an array
  17703. * @returns a new array with 2 elements: the Vector2 coordinates.
  17704. */
  17705. asArray(): number[];
  17706. /**
  17707. * Sets the Vector2 coordinates with the given Vector2 coordinates
  17708. * @param source defines the source Vector2
  17709. * @returns the current updated Vector2
  17710. */
  17711. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  17712. /**
  17713. * Sets the Vector2 coordinates with the given floats
  17714. * @param x defines the first coordinate
  17715. * @param y defines the second coordinate
  17716. * @returns the current updated Vector2
  17717. */
  17718. copyFromFloats(x: number, y: number): Vector2;
  17719. /**
  17720. * Sets the Vector2 coordinates with the given floats
  17721. * @param x defines the first coordinate
  17722. * @param y defines the second coordinate
  17723. * @returns the current updated Vector2
  17724. */
  17725. set(x: number, y: number): Vector2;
  17726. /**
  17727. * Add another vector with the current one
  17728. * @param otherVector defines the other vector
  17729. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  17730. */
  17731. add(otherVector: DeepImmutable<Vector2>): Vector2;
  17732. /**
  17733. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  17734. * @param otherVector defines the other vector
  17735. * @param result defines the target vector
  17736. * @returns the unmodified current Vector2
  17737. */
  17738. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  17739. /**
  17740. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  17741. * @param otherVector defines the other vector
  17742. * @returns the current updated Vector2
  17743. */
  17744. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  17745. /**
  17746. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  17747. * @param otherVector defines the other vector
  17748. * @returns a new Vector2
  17749. */
  17750. addVector3(otherVector: Vector3): Vector2;
  17751. /**
  17752. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  17753. * @param otherVector defines the other vector
  17754. * @returns a new Vector2
  17755. */
  17756. subtract(otherVector: Vector2): Vector2;
  17757. /**
  17758. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  17759. * @param otherVector defines the other vector
  17760. * @param result defines the target vector
  17761. * @returns the unmodified current Vector2
  17762. */
  17763. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  17764. /**
  17765. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  17766. * @param otherVector defines the other vector
  17767. * @returns the current updated Vector2
  17768. */
  17769. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  17770. /**
  17771. * Multiplies in place the current Vector2 coordinates by the given ones
  17772. * @param otherVector defines the other vector
  17773. * @returns the current updated Vector2
  17774. */
  17775. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  17776. /**
  17777. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  17778. * @param otherVector defines the other vector
  17779. * @returns a new Vector2
  17780. */
  17781. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  17782. /**
  17783. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  17784. * @param otherVector defines the other vector
  17785. * @param result defines the target vector
  17786. * @returns the unmodified current Vector2
  17787. */
  17788. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  17789. /**
  17790. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  17791. * @param x defines the first coordinate
  17792. * @param y defines the second coordinate
  17793. * @returns a new Vector2
  17794. */
  17795. multiplyByFloats(x: number, y: number): Vector2;
  17796. /**
  17797. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  17798. * @param otherVector defines the other vector
  17799. * @returns a new Vector2
  17800. */
  17801. divide(otherVector: Vector2): Vector2;
  17802. /**
  17803. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  17804. * @param otherVector defines the other vector
  17805. * @param result defines the target vector
  17806. * @returns the unmodified current Vector2
  17807. */
  17808. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  17809. /**
  17810. * Divides the current Vector2 coordinates by the given ones
  17811. * @param otherVector defines the other vector
  17812. * @returns the current updated Vector2
  17813. */
  17814. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  17815. /**
  17816. * Gets a new Vector2 with current Vector2 negated coordinates
  17817. * @returns a new Vector2
  17818. */
  17819. negate(): Vector2;
  17820. /**
  17821. * Multiply the Vector2 coordinates by scale
  17822. * @param scale defines the scaling factor
  17823. * @returns the current updated Vector2
  17824. */
  17825. scaleInPlace(scale: number): Vector2;
  17826. /**
  17827. * Returns a new Vector2 scaled by "scale" from the current Vector2
  17828. * @param scale defines the scaling factor
  17829. * @returns a new Vector2
  17830. */
  17831. scale(scale: number): Vector2;
  17832. /**
  17833. * Scale the current Vector2 values by a factor to a given Vector2
  17834. * @param scale defines the scale factor
  17835. * @param result defines the Vector2 object where to store the result
  17836. * @returns the unmodified current Vector2
  17837. */
  17838. scaleToRef(scale: number, result: Vector2): Vector2;
  17839. /**
  17840. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  17841. * @param scale defines the scale factor
  17842. * @param result defines the Vector2 object where to store the result
  17843. * @returns the unmodified current Vector2
  17844. */
  17845. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  17846. /**
  17847. * Gets a boolean if two vectors are equals
  17848. * @param otherVector defines the other vector
  17849. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  17850. */
  17851. equals(otherVector: DeepImmutable<Vector2>): boolean;
  17852. /**
  17853. * Gets a boolean if two vectors are equals (using an epsilon value)
  17854. * @param otherVector defines the other vector
  17855. * @param epsilon defines the minimal distance to consider equality
  17856. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  17857. */
  17858. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  17859. /**
  17860. * Gets a new Vector2 from current Vector2 floored values
  17861. * @returns a new Vector2
  17862. */
  17863. floor(): Vector2;
  17864. /**
  17865. * Gets a new Vector2 from current Vector2 floored values
  17866. * @returns a new Vector2
  17867. */
  17868. fract(): Vector2;
  17869. /**
  17870. * Gets the length of the vector
  17871. * @returns the vector length (float)
  17872. */
  17873. length(): number;
  17874. /**
  17875. * Gets the vector squared length
  17876. * @returns the vector squared length (float)
  17877. */
  17878. lengthSquared(): number;
  17879. /**
  17880. * Normalize the vector
  17881. * @returns the current updated Vector2
  17882. */
  17883. normalize(): Vector2;
  17884. /**
  17885. * Gets a new Vector2 copied from the Vector2
  17886. * @returns a new Vector2
  17887. */
  17888. clone(): Vector2;
  17889. /**
  17890. * Gets a new Vector2(0, 0)
  17891. * @returns a new Vector2
  17892. */
  17893. static Zero(): Vector2;
  17894. /**
  17895. * Gets a new Vector2(1, 1)
  17896. * @returns a new Vector2
  17897. */
  17898. static One(): Vector2;
  17899. /**
  17900. * Gets a new Vector2 set from the given index element of the given array
  17901. * @param array defines the data source
  17902. * @param offset defines the offset in the data source
  17903. * @returns a new Vector2
  17904. */
  17905. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  17906. /**
  17907. * Sets "result" from the given index element of the given array
  17908. * @param array defines the data source
  17909. * @param offset defines the offset in the data source
  17910. * @param result defines the target vector
  17911. */
  17912. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  17913. /**
  17914. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  17915. * @param value1 defines 1st point of control
  17916. * @param value2 defines 2nd point of control
  17917. * @param value3 defines 3rd point of control
  17918. * @param value4 defines 4th point of control
  17919. * @param amount defines the interpolation factor
  17920. * @returns a new Vector2
  17921. */
  17922. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  17923. /**
  17924. * 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".
  17925. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  17926. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  17927. * @param value defines the value to clamp
  17928. * @param min defines the lower limit
  17929. * @param max defines the upper limit
  17930. * @returns a new Vector2
  17931. */
  17932. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  17933. /**
  17934. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  17935. * @param value1 defines the 1st control point
  17936. * @param tangent1 defines the outgoing tangent
  17937. * @param value2 defines the 2nd control point
  17938. * @param tangent2 defines the incoming tangent
  17939. * @param amount defines the interpolation factor
  17940. * @returns a new Vector2
  17941. */
  17942. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  17943. /**
  17944. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  17945. * @param start defines the start vector
  17946. * @param end defines the end vector
  17947. * @param amount defines the interpolation factor
  17948. * @returns a new Vector2
  17949. */
  17950. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  17951. /**
  17952. * Gets the dot product of the vector "left" and the vector "right"
  17953. * @param left defines first vector
  17954. * @param right defines second vector
  17955. * @returns the dot product (float)
  17956. */
  17957. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  17958. /**
  17959. * Returns a new Vector2 equal to the normalized given vector
  17960. * @param vector defines the vector to normalize
  17961. * @returns a new Vector2
  17962. */
  17963. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  17964. /**
  17965. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  17966. * @param left defines 1st vector
  17967. * @param right defines 2nd vector
  17968. * @returns a new Vector2
  17969. */
  17970. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  17971. /**
  17972. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  17973. * @param left defines 1st vector
  17974. * @param right defines 2nd vector
  17975. * @returns a new Vector2
  17976. */
  17977. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  17978. /**
  17979. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  17980. * @param vector defines the vector to transform
  17981. * @param transformation defines the matrix to apply
  17982. * @returns a new Vector2
  17983. */
  17984. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  17985. /**
  17986. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  17987. * @param vector defines the vector to transform
  17988. * @param transformation defines the matrix to apply
  17989. * @param result defines the target vector
  17990. */
  17991. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  17992. /**
  17993. * Determines if a given vector is included in a triangle
  17994. * @param p defines the vector to test
  17995. * @param p0 defines 1st triangle point
  17996. * @param p1 defines 2nd triangle point
  17997. * @param p2 defines 3rd triangle point
  17998. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  17999. */
  18000. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  18001. /**
  18002. * Gets the distance between the vectors "value1" and "value2"
  18003. * @param value1 defines first vector
  18004. * @param value2 defines second vector
  18005. * @returns the distance between vectors
  18006. */
  18007. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  18008. /**
  18009. * Returns the squared distance between the vectors "value1" and "value2"
  18010. * @param value1 defines first vector
  18011. * @param value2 defines second vector
  18012. * @returns the squared distance between vectors
  18013. */
  18014. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  18015. /**
  18016. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  18017. * @param value1 defines first vector
  18018. * @param value2 defines second vector
  18019. * @returns a new Vector2
  18020. */
  18021. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  18022. /**
  18023. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  18024. * @param p defines the middle point
  18025. * @param segA defines one point of the segment
  18026. * @param segB defines the other point of the segment
  18027. * @returns the shortest distance
  18028. */
  18029. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  18030. }
  18031. /**
  18032. * Classed used to store (x,y,z) vector representation
  18033. * A Vector3 is the main object used in 3D geometry
  18034. * It can represent etiher the coordinates of a point the space, either a direction
  18035. * Reminder: Babylon.js uses a left handed forward facing system
  18036. */
  18037. class Vector3 {
  18038. /**
  18039. * Defines the first coordinates (on X axis)
  18040. */
  18041. x: number;
  18042. /**
  18043. * Defines the second coordinates (on Y axis)
  18044. */
  18045. y: number;
  18046. /**
  18047. * Defines the third coordinates (on Z axis)
  18048. */
  18049. z: number;
  18050. /**
  18051. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  18052. * @param x defines the first coordinates (on X axis)
  18053. * @param y defines the second coordinates (on Y axis)
  18054. * @param z defines the third coordinates (on Z axis)
  18055. */
  18056. constructor(
  18057. /**
  18058. * Defines the first coordinates (on X axis)
  18059. */
  18060. x?: number,
  18061. /**
  18062. * Defines the second coordinates (on Y axis)
  18063. */
  18064. y?: number,
  18065. /**
  18066. * Defines the third coordinates (on Z axis)
  18067. */
  18068. z?: number);
  18069. /**
  18070. * Creates a string representation of the Vector3
  18071. * @returns a string with the Vector3 coordinates.
  18072. */
  18073. toString(): string;
  18074. /**
  18075. * Gets the class name
  18076. * @returns the string "Vector3"
  18077. */
  18078. getClassName(): string;
  18079. /**
  18080. * Creates the Vector3 hash code
  18081. * @returns a number which tends to be unique between Vector3 instances
  18082. */
  18083. getHashCode(): number;
  18084. /**
  18085. * Creates an array containing three elements : the coordinates of the Vector3
  18086. * @returns a new array of numbers
  18087. */
  18088. asArray(): number[];
  18089. /**
  18090. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  18091. * @param array defines the destination array
  18092. * @param index defines the offset in the destination array
  18093. * @returns the current Vector3
  18094. */
  18095. toArray(array: FloatArray, index?: number): Vector3;
  18096. /**
  18097. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  18098. * @returns a new Quaternion object, computed from the Vector3 coordinates
  18099. */
  18100. toQuaternion(): Quaternion;
  18101. /**
  18102. * Adds the given vector to the current Vector3
  18103. * @param otherVector defines the second operand
  18104. * @returns the current updated Vector3
  18105. */
  18106. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  18107. /**
  18108. * Adds the given coordinates to the current Vector3
  18109. * @param x defines the x coordinate of the operand
  18110. * @param y defines the y coordinate of the operand
  18111. * @param z defines the z coordinate of the operand
  18112. * @returns the current updated Vector3
  18113. */
  18114. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  18115. /**
  18116. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  18117. * @param otherVector defines the second operand
  18118. * @returns the resulting Vector3
  18119. */
  18120. add(otherVector: DeepImmutable<Vector3>): Vector3;
  18121. /**
  18122. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  18123. * @param otherVector defines the second operand
  18124. * @param result defines the Vector3 object where to store the result
  18125. * @returns the current Vector3
  18126. */
  18127. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  18128. /**
  18129. * Subtract the given vector from the current Vector3
  18130. * @param otherVector defines the second operand
  18131. * @returns the current updated Vector3
  18132. */
  18133. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  18134. /**
  18135. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  18136. * @param otherVector defines the second operand
  18137. * @returns the resulting Vector3
  18138. */
  18139. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  18140. /**
  18141. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  18142. * @param otherVector defines the second operand
  18143. * @param result defines the Vector3 object where to store the result
  18144. * @returns the current Vector3
  18145. */
  18146. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  18147. /**
  18148. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  18149. * @param x defines the x coordinate of the operand
  18150. * @param y defines the y coordinate of the operand
  18151. * @param z defines the z coordinate of the operand
  18152. * @returns the resulting Vector3
  18153. */
  18154. subtractFromFloats(x: number, y: number, z: number): Vector3;
  18155. /**
  18156. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  18157. * @param x defines the x coordinate of the operand
  18158. * @param y defines the y coordinate of the operand
  18159. * @param z defines the z coordinate of the operand
  18160. * @param result defines the Vector3 object where to store the result
  18161. * @returns the current Vector3
  18162. */
  18163. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  18164. /**
  18165. * Gets a new Vector3 set with the current Vector3 negated coordinates
  18166. * @returns a new Vector3
  18167. */
  18168. negate(): Vector3;
  18169. /**
  18170. * Multiplies the Vector3 coordinates by the float "scale"
  18171. * @param scale defines the multiplier factor
  18172. * @returns the current updated Vector3
  18173. */
  18174. scaleInPlace(scale: number): Vector3;
  18175. /**
  18176. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  18177. * @param scale defines the multiplier factor
  18178. * @returns a new Vector3
  18179. */
  18180. scale(scale: number): Vector3;
  18181. /**
  18182. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  18183. * @param scale defines the multiplier factor
  18184. * @param result defines the Vector3 object where to store the result
  18185. * @returns the current Vector3
  18186. */
  18187. scaleToRef(scale: number, result: Vector3): Vector3;
  18188. /**
  18189. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  18190. * @param scale defines the scale factor
  18191. * @param result defines the Vector3 object where to store the result
  18192. * @returns the unmodified current Vector3
  18193. */
  18194. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  18195. /**
  18196. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  18197. * @param otherVector defines the second operand
  18198. * @returns true if both vectors are equals
  18199. */
  18200. equals(otherVector: DeepImmutable<Vector3>): boolean;
  18201. /**
  18202. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  18203. * @param otherVector defines the second operand
  18204. * @param epsilon defines the minimal distance to define values as equals
  18205. * @returns true if both vectors are distant less than epsilon
  18206. */
  18207. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  18208. /**
  18209. * Returns true if the current Vector3 coordinates equals the given floats
  18210. * @param x defines the x coordinate of the operand
  18211. * @param y defines the y coordinate of the operand
  18212. * @param z defines the z coordinate of the operand
  18213. * @returns true if both vectors are equals
  18214. */
  18215. equalsToFloats(x: number, y: number, z: number): boolean;
  18216. /**
  18217. * Multiplies the current Vector3 coordinates by the given ones
  18218. * @param otherVector defines the second operand
  18219. * @returns the current updated Vector3
  18220. */
  18221. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  18222. /**
  18223. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  18224. * @param otherVector defines the second operand
  18225. * @returns the new Vector3
  18226. */
  18227. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  18228. /**
  18229. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  18230. * @param otherVector defines the second operand
  18231. * @param result defines the Vector3 object where to store the result
  18232. * @returns the current Vector3
  18233. */
  18234. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  18235. /**
  18236. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  18237. * @param x defines the x coordinate of the operand
  18238. * @param y defines the y coordinate of the operand
  18239. * @param z defines the z coordinate of the operand
  18240. * @returns the new Vector3
  18241. */
  18242. multiplyByFloats(x: number, y: number, z: number): Vector3;
  18243. /**
  18244. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  18245. * @param otherVector defines the second operand
  18246. * @returns the new Vector3
  18247. */
  18248. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  18249. /**
  18250. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  18251. * @param otherVector defines the second operand
  18252. * @param result defines the Vector3 object where to store the result
  18253. * @returns the current Vector3
  18254. */
  18255. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  18256. /**
  18257. * Divides the current Vector3 coordinates by the given ones.
  18258. * @param otherVector defines the second operand
  18259. * @returns the current updated Vector3
  18260. */
  18261. divideInPlace(otherVector: Vector3): Vector3;
  18262. /**
  18263. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  18264. * @param other defines the second operand
  18265. * @returns the current updated Vector3
  18266. */
  18267. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  18268. /**
  18269. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  18270. * @param other defines the second operand
  18271. * @returns the current updated Vector3
  18272. */
  18273. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  18274. /**
  18275. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  18276. * @param x defines the x coordinate of the operand
  18277. * @param y defines the y coordinate of the operand
  18278. * @param z defines the z coordinate of the operand
  18279. * @returns the current updated Vector3
  18280. */
  18281. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  18282. /**
  18283. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  18284. * @param x defines the x coordinate of the operand
  18285. * @param y defines the y coordinate of the operand
  18286. * @param z defines the z coordinate of the operand
  18287. * @returns the current updated Vector3
  18288. */
  18289. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  18290. /**
  18291. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  18292. */
  18293. readonly isNonUniform: boolean;
  18294. /**
  18295. * Gets a new Vector3 from current Vector3 floored values
  18296. * @returns a new Vector3
  18297. */
  18298. floor(): Vector3;
  18299. /**
  18300. * Gets a new Vector3 from current Vector3 floored values
  18301. * @returns a new Vector3
  18302. */
  18303. fract(): Vector3;
  18304. /**
  18305. * Gets the length of the Vector3
  18306. * @returns the length of the Vecto3
  18307. */
  18308. length(): number;
  18309. /**
  18310. * Gets the squared length of the Vector3
  18311. * @returns squared length of the Vector3
  18312. */
  18313. lengthSquared(): number;
  18314. /**
  18315. * Normalize the current Vector3.
  18316. * Please note that this is an in place operation.
  18317. * @returns the current updated Vector3
  18318. */
  18319. normalize(): Vector3;
  18320. /**
  18321. * Reorders the x y z properties of the vector in place
  18322. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  18323. * @returns the current updated vector
  18324. */
  18325. reorderInPlace(order: string): this;
  18326. /**
  18327. * Rotates the vector around 0,0,0 by a quaternion
  18328. * @param quaternion the rotation quaternion
  18329. * @param result vector to store the result
  18330. * @returns the resulting vector
  18331. */
  18332. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  18333. /**
  18334. * Rotates a vector around a given point
  18335. * @param quaternion the rotation quaternion
  18336. * @param point the point to rotate around
  18337. * @param result vector to store the result
  18338. * @returns the resulting vector
  18339. */
  18340. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  18341. /**
  18342. * Normalize the current Vector3 with the given input length.
  18343. * Please note that this is an in place operation.
  18344. * @param len the length of the vector
  18345. * @returns the current updated Vector3
  18346. */
  18347. normalizeFromLength(len: number): Vector3;
  18348. /**
  18349. * Normalize the current Vector3 to a new vector
  18350. * @returns the new Vector3
  18351. */
  18352. normalizeToNew(): Vector3;
  18353. /**
  18354. * Normalize the current Vector3 to the reference
  18355. * @param reference define the Vector3 to update
  18356. * @returns the updated Vector3
  18357. */
  18358. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  18359. /**
  18360. * Creates a new Vector3 copied from the current Vector3
  18361. * @returns the new Vector3
  18362. */
  18363. clone(): Vector3;
  18364. /**
  18365. * Copies the given vector coordinates to the current Vector3 ones
  18366. * @param source defines the source Vector3
  18367. * @returns the current updated Vector3
  18368. */
  18369. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  18370. /**
  18371. * Copies the given floats to the current Vector3 coordinates
  18372. * @param x defines the x coordinate of the operand
  18373. * @param y defines the y coordinate of the operand
  18374. * @param z defines the z coordinate of the operand
  18375. * @returns the current updated Vector3
  18376. */
  18377. copyFromFloats(x: number, y: number, z: number): Vector3;
  18378. /**
  18379. * Copies the given floats to the current Vector3 coordinates
  18380. * @param x defines the x coordinate of the operand
  18381. * @param y defines the y coordinate of the operand
  18382. * @param z defines the z coordinate of the operand
  18383. * @returns the current updated Vector3
  18384. */
  18385. set(x: number, y: number, z: number): Vector3;
  18386. /**
  18387. * Copies the given float to the current Vector3 coordinates
  18388. * @param v defines the x, y and z coordinates of the operand
  18389. * @returns the current updated Vector3
  18390. */
  18391. setAll(v: number): Vector3;
  18392. /**
  18393. * Get the clip factor between two vectors
  18394. * @param vector0 defines the first operand
  18395. * @param vector1 defines the second operand
  18396. * @param axis defines the axis to use
  18397. * @param size defines the size along the axis
  18398. * @returns the clip factor
  18399. */
  18400. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  18401. /**
  18402. * Get angle between two vectors
  18403. * @param vector0 angle between vector0 and vector1
  18404. * @param vector1 angle between vector0 and vector1
  18405. * @param normal direction of the normal
  18406. * @return the angle between vector0 and vector1
  18407. */
  18408. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  18409. /**
  18410. * Returns a new Vector3 set from the index "offset" of the given array
  18411. * @param array defines the source array
  18412. * @param offset defines the offset in the source array
  18413. * @returns the new Vector3
  18414. */
  18415. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  18416. /**
  18417. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  18418. * This function is deprecated. Use FromArray instead
  18419. * @param array defines the source array
  18420. * @param offset defines the offset in the source array
  18421. * @returns the new Vector3
  18422. */
  18423. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  18424. /**
  18425. * Sets the given vector "result" with the element values from the index "offset" of the given array
  18426. * @param array defines the source array
  18427. * @param offset defines the offset in the source array
  18428. * @param result defines the Vector3 where to store the result
  18429. */
  18430. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  18431. /**
  18432. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  18433. * This function is deprecated. Use FromArrayToRef instead.
  18434. * @param array defines the source array
  18435. * @param offset defines the offset in the source array
  18436. * @param result defines the Vector3 where to store the result
  18437. */
  18438. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  18439. /**
  18440. * Sets the given vector "result" with the given floats.
  18441. * @param x defines the x coordinate of the source
  18442. * @param y defines the y coordinate of the source
  18443. * @param z defines the z coordinate of the source
  18444. * @param result defines the Vector3 where to store the result
  18445. */
  18446. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  18447. /**
  18448. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  18449. * @returns a new empty Vector3
  18450. */
  18451. static Zero(): Vector3;
  18452. /**
  18453. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  18454. * @returns a new unit Vector3
  18455. */
  18456. static One(): Vector3;
  18457. /**
  18458. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  18459. * @returns a new up Vector3
  18460. */
  18461. static Up(): Vector3;
  18462. /**
  18463. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  18464. * @returns a new down Vector3
  18465. */
  18466. static Down(): Vector3;
  18467. /**
  18468. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  18469. * @returns a new forward Vector3
  18470. */
  18471. static Forward(): Vector3;
  18472. /**
  18473. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  18474. * @returns a new forward Vector3
  18475. */
  18476. static Backward(): Vector3;
  18477. /**
  18478. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  18479. * @returns a new right Vector3
  18480. */
  18481. static Right(): Vector3;
  18482. /**
  18483. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  18484. * @returns a new left Vector3
  18485. */
  18486. static Left(): Vector3;
  18487. /**
  18488. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  18489. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  18490. * @param vector defines the Vector3 to transform
  18491. * @param transformation defines the transformation matrix
  18492. * @returns the transformed Vector3
  18493. */
  18494. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  18495. /**
  18496. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  18497. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  18498. * @param vector defines the Vector3 to transform
  18499. * @param transformation defines the transformation matrix
  18500. * @param result defines the Vector3 where to store the result
  18501. */
  18502. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  18503. /**
  18504. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  18505. * This method computes tranformed coordinates only, not transformed direction vectors
  18506. * @param x define the x coordinate of the source vector
  18507. * @param y define the y coordinate of the source vector
  18508. * @param z define the z coordinate of the source vector
  18509. * @param transformation defines the transformation matrix
  18510. * @param result defines the Vector3 where to store the result
  18511. */
  18512. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  18513. /**
  18514. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  18515. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  18516. * @param vector defines the Vector3 to transform
  18517. * @param transformation defines the transformation matrix
  18518. * @returns the new Vector3
  18519. */
  18520. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  18521. /**
  18522. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  18523. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  18524. * @param vector defines the Vector3 to transform
  18525. * @param transformation defines the transformation matrix
  18526. * @param result defines the Vector3 where to store the result
  18527. */
  18528. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  18529. /**
  18530. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  18531. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  18532. * @param x define the x coordinate of the source vector
  18533. * @param y define the y coordinate of the source vector
  18534. * @param z define the z coordinate of the source vector
  18535. * @param transformation defines the transformation matrix
  18536. * @param result defines the Vector3 where to store the result
  18537. */
  18538. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  18539. /**
  18540. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  18541. * @param value1 defines the first control point
  18542. * @param value2 defines the second control point
  18543. * @param value3 defines the third control point
  18544. * @param value4 defines the fourth control point
  18545. * @param amount defines the amount on the spline to use
  18546. * @returns the new Vector3
  18547. */
  18548. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  18549. /**
  18550. * 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"
  18551. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  18552. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  18553. * @param value defines the current value
  18554. * @param min defines the lower range value
  18555. * @param max defines the upper range value
  18556. * @returns the new Vector3
  18557. */
  18558. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  18559. /**
  18560. * 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"
  18561. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  18562. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  18563. * @param value defines the current value
  18564. * @param min defines the lower range value
  18565. * @param max defines the upper range value
  18566. * @param result defines the Vector3 where to store the result
  18567. */
  18568. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  18569. /**
  18570. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  18571. * @param value1 defines the first control point
  18572. * @param tangent1 defines the first tangent vector
  18573. * @param value2 defines the second control point
  18574. * @param tangent2 defines the second tangent vector
  18575. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  18576. * @returns the new Vector3
  18577. */
  18578. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  18579. /**
  18580. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  18581. * @param start defines the start value
  18582. * @param end defines the end value
  18583. * @param amount max defines amount between both (between 0 and 1)
  18584. * @returns the new Vector3
  18585. */
  18586. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  18587. /**
  18588. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  18589. * @param start defines the start value
  18590. * @param end defines the end value
  18591. * @param amount max defines amount between both (between 0 and 1)
  18592. * @param result defines the Vector3 where to store the result
  18593. */
  18594. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  18595. /**
  18596. * Returns the dot product (float) between the vectors "left" and "right"
  18597. * @param left defines the left operand
  18598. * @param right defines the right operand
  18599. * @returns the dot product
  18600. */
  18601. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  18602. /**
  18603. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  18604. * The cross product is then orthogonal to both "left" and "right"
  18605. * @param left defines the left operand
  18606. * @param right defines the right operand
  18607. * @returns the cross product
  18608. */
  18609. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  18610. /**
  18611. * Sets the given vector "result" with the cross product of "left" and "right"
  18612. * The cross product is then orthogonal to both "left" and "right"
  18613. * @param left defines the left operand
  18614. * @param right defines the right operand
  18615. * @param result defines the Vector3 where to store the result
  18616. */
  18617. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  18618. /**
  18619. * Returns a new Vector3 as the normalization of the given vector
  18620. * @param vector defines the Vector3 to normalize
  18621. * @returns the new Vector3
  18622. */
  18623. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  18624. /**
  18625. * Sets the given vector "result" with the normalization of the given first vector
  18626. * @param vector defines the Vector3 to normalize
  18627. * @param result defines the Vector3 where to store the result
  18628. */
  18629. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  18630. /**
  18631. * Project a Vector3 onto screen space
  18632. * @param vector defines the Vector3 to project
  18633. * @param world defines the world matrix to use
  18634. * @param transform defines the transform (view x projection) matrix to use
  18635. * @param viewport defines the screen viewport to use
  18636. * @returns the new Vector3
  18637. */
  18638. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  18639. /** @hidden */
  18640. private static UnprojectFromInvertedMatrixToRef;
  18641. /**
  18642. * Unproject from screen space to object space
  18643. * @param source defines the screen space Vector3 to use
  18644. * @param viewportWidth defines the current width of the viewport
  18645. * @param viewportHeight defines the current height of the viewport
  18646. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18647. * @param transform defines the transform (view x projection) matrix to use
  18648. * @returns the new Vector3
  18649. */
  18650. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  18651. /**
  18652. * Unproject from screen space to object space
  18653. * @param source defines the screen space Vector3 to use
  18654. * @param viewportWidth defines the current width of the viewport
  18655. * @param viewportHeight defines the current height of the viewport
  18656. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18657. * @param view defines the view matrix to use
  18658. * @param projection defines the projection matrix to use
  18659. * @returns the new Vector3
  18660. */
  18661. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  18662. /**
  18663. * Unproject from screen space to object space
  18664. * @param source defines the screen space Vector3 to use
  18665. * @param viewportWidth defines the current width of the viewport
  18666. * @param viewportHeight defines the current height of the viewport
  18667. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18668. * @param view defines the view matrix to use
  18669. * @param projection defines the projection matrix to use
  18670. * @param result defines the Vector3 where to store the result
  18671. */
  18672. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  18673. /**
  18674. * Unproject from screen space to object space
  18675. * @param sourceX defines the screen space x coordinate to use
  18676. * @param sourceY defines the screen space y coordinate to use
  18677. * @param sourceZ defines the screen space z coordinate to use
  18678. * @param viewportWidth defines the current width of the viewport
  18679. * @param viewportHeight defines the current height of the viewport
  18680. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18681. * @param view defines the view matrix to use
  18682. * @param projection defines the projection matrix to use
  18683. * @param result defines the Vector3 where to store the result
  18684. */
  18685. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  18686. /**
  18687. * Unproject a ray from screen space to object space
  18688. * @param sourceX defines the screen space x coordinate to use
  18689. * @param sourceY defines the screen space y coordinate to use
  18690. * @param viewportWidth defines the current width of the viewport
  18691. * @param viewportHeight defines the current height of the viewport
  18692. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18693. * @param view defines the view matrix to use
  18694. * @param projection defines the projection matrix to use
  18695. * @param ray defines the Ray where to store the result
  18696. */
  18697. static UnprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, ray: Ray): void;
  18698. /**
  18699. * Gets the minimal coordinate values between two Vector3
  18700. * @param left defines the first operand
  18701. * @param right defines the second operand
  18702. * @returns the new Vector3
  18703. */
  18704. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  18705. /**
  18706. * Gets the maximal coordinate values between two Vector3
  18707. * @param left defines the first operand
  18708. * @param right defines the second operand
  18709. * @returns the new Vector3
  18710. */
  18711. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  18712. /**
  18713. * Returns the distance between the vectors "value1" and "value2"
  18714. * @param value1 defines the first operand
  18715. * @param value2 defines the second operand
  18716. * @returns the distance
  18717. */
  18718. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  18719. /**
  18720. * Returns the squared distance between the vectors "value1" and "value2"
  18721. * @param value1 defines the first operand
  18722. * @param value2 defines the second operand
  18723. * @returns the squared distance
  18724. */
  18725. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  18726. /**
  18727. * Returns a new Vector3 located at the center between "value1" and "value2"
  18728. * @param value1 defines the first operand
  18729. * @param value2 defines the second operand
  18730. * @returns the new Vector3
  18731. */
  18732. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  18733. /**
  18734. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  18735. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  18736. * to something in order to rotate it from its local system to the given target system
  18737. * Note: axis1, axis2 and axis3 are normalized during this operation
  18738. * @param axis1 defines the first axis
  18739. * @param axis2 defines the second axis
  18740. * @param axis3 defines the third axis
  18741. * @returns a new Vector3
  18742. */
  18743. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  18744. /**
  18745. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  18746. * @param axis1 defines the first axis
  18747. * @param axis2 defines the second axis
  18748. * @param axis3 defines the third axis
  18749. * @param ref defines the Vector3 where to store the result
  18750. */
  18751. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  18752. }
  18753. /**
  18754. * Vector4 class created for EulerAngle class conversion to Quaternion
  18755. */
  18756. class Vector4 {
  18757. /** x value of the vector */
  18758. x: number;
  18759. /** y value of the vector */
  18760. y: number;
  18761. /** z value of the vector */
  18762. z: number;
  18763. /** w value of the vector */
  18764. w: number;
  18765. /**
  18766. * Creates a Vector4 object from the given floats.
  18767. * @param x x value of the vector
  18768. * @param y y value of the vector
  18769. * @param z z value of the vector
  18770. * @param w w value of the vector
  18771. */
  18772. constructor(
  18773. /** x value of the vector */
  18774. x: number,
  18775. /** y value of the vector */
  18776. y: number,
  18777. /** z value of the vector */
  18778. z: number,
  18779. /** w value of the vector */
  18780. w: number);
  18781. /**
  18782. * Returns the string with the Vector4 coordinates.
  18783. * @returns a string containing all the vector values
  18784. */
  18785. toString(): string;
  18786. /**
  18787. * Returns the string "Vector4".
  18788. * @returns "Vector4"
  18789. */
  18790. getClassName(): string;
  18791. /**
  18792. * Returns the Vector4 hash code.
  18793. * @returns a unique hash code
  18794. */
  18795. getHashCode(): number;
  18796. /**
  18797. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  18798. * @returns the resulting array
  18799. */
  18800. asArray(): number[];
  18801. /**
  18802. * Populates the given array from the given index with the Vector4 coordinates.
  18803. * @param array array to populate
  18804. * @param index index of the array to start at (default: 0)
  18805. * @returns the Vector4.
  18806. */
  18807. toArray(array: FloatArray, index?: number): Vector4;
  18808. /**
  18809. * Adds the given vector to the current Vector4.
  18810. * @param otherVector the vector to add
  18811. * @returns the updated Vector4.
  18812. */
  18813. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  18814. /**
  18815. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  18816. * @param otherVector the vector to add
  18817. * @returns the resulting vector
  18818. */
  18819. add(otherVector: DeepImmutable<Vector4>): Vector4;
  18820. /**
  18821. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  18822. * @param otherVector the vector to add
  18823. * @param result the vector to store the result
  18824. * @returns the current Vector4.
  18825. */
  18826. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  18827. /**
  18828. * Subtract in place the given vector from the current Vector4.
  18829. * @param otherVector the vector to subtract
  18830. * @returns the updated Vector4.
  18831. */
  18832. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  18833. /**
  18834. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  18835. * @param otherVector the vector to add
  18836. * @returns the new vector with the result
  18837. */
  18838. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  18839. /**
  18840. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  18841. * @param otherVector the vector to subtract
  18842. * @param result the vector to store the result
  18843. * @returns the current Vector4.
  18844. */
  18845. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  18846. /**
  18847. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  18848. */
  18849. /**
  18850. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  18851. * @param x value to subtract
  18852. * @param y value to subtract
  18853. * @param z value to subtract
  18854. * @param w value to subtract
  18855. * @returns new vector containing the result
  18856. */
  18857. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  18858. /**
  18859. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  18860. * @param x value to subtract
  18861. * @param y value to subtract
  18862. * @param z value to subtract
  18863. * @param w value to subtract
  18864. * @param result the vector to store the result in
  18865. * @returns the current Vector4.
  18866. */
  18867. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  18868. /**
  18869. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  18870. * @returns a new vector with the negated values
  18871. */
  18872. negate(): Vector4;
  18873. /**
  18874. * Multiplies the current Vector4 coordinates by scale (float).
  18875. * @param scale the number to scale with
  18876. * @returns the updated Vector4.
  18877. */
  18878. scaleInPlace(scale: number): Vector4;
  18879. /**
  18880. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  18881. * @param scale the number to scale with
  18882. * @returns a new vector with the result
  18883. */
  18884. scale(scale: number): Vector4;
  18885. /**
  18886. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  18887. * @param scale the number to scale with
  18888. * @param result a vector to store the result in
  18889. * @returns the current Vector4.
  18890. */
  18891. scaleToRef(scale: number, result: Vector4): Vector4;
  18892. /**
  18893. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  18894. * @param scale defines the scale factor
  18895. * @param result defines the Vector4 object where to store the result
  18896. * @returns the unmodified current Vector4
  18897. */
  18898. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  18899. /**
  18900. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  18901. * @param otherVector the vector to compare against
  18902. * @returns true if they are equal
  18903. */
  18904. equals(otherVector: DeepImmutable<Vector4>): boolean;
  18905. /**
  18906. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  18907. * @param otherVector vector to compare against
  18908. * @param epsilon (Default: very small number)
  18909. * @returns true if they are equal
  18910. */
  18911. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  18912. /**
  18913. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  18914. * @param x x value to compare against
  18915. * @param y y value to compare against
  18916. * @param z z value to compare against
  18917. * @param w w value to compare against
  18918. * @returns true if equal
  18919. */
  18920. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  18921. /**
  18922. * Multiplies in place the current Vector4 by the given one.
  18923. * @param otherVector vector to multiple with
  18924. * @returns the updated Vector4.
  18925. */
  18926. multiplyInPlace(otherVector: Vector4): Vector4;
  18927. /**
  18928. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  18929. * @param otherVector vector to multiple with
  18930. * @returns resulting new vector
  18931. */
  18932. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  18933. /**
  18934. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  18935. * @param otherVector vector to multiple with
  18936. * @param result vector to store the result
  18937. * @returns the current Vector4.
  18938. */
  18939. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  18940. /**
  18941. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  18942. * @param x x value multiply with
  18943. * @param y y value multiply with
  18944. * @param z z value multiply with
  18945. * @param w w value multiply with
  18946. * @returns resulting new vector
  18947. */
  18948. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  18949. /**
  18950. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  18951. * @param otherVector vector to devide with
  18952. * @returns resulting new vector
  18953. */
  18954. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  18955. /**
  18956. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  18957. * @param otherVector vector to devide with
  18958. * @param result vector to store the result
  18959. * @returns the current Vector4.
  18960. */
  18961. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  18962. /**
  18963. * Divides the current Vector3 coordinates by the given ones.
  18964. * @param otherVector vector to devide with
  18965. * @returns the updated Vector3.
  18966. */
  18967. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  18968. /**
  18969. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  18970. * @param other defines the second operand
  18971. * @returns the current updated Vector4
  18972. */
  18973. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  18974. /**
  18975. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  18976. * @param other defines the second operand
  18977. * @returns the current updated Vector4
  18978. */
  18979. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  18980. /**
  18981. * Gets a new Vector4 from current Vector4 floored values
  18982. * @returns a new Vector4
  18983. */
  18984. floor(): Vector4;
  18985. /**
  18986. * Gets a new Vector4 from current Vector3 floored values
  18987. * @returns a new Vector4
  18988. */
  18989. fract(): Vector4;
  18990. /**
  18991. * Returns the Vector4 length (float).
  18992. * @returns the length
  18993. */
  18994. length(): number;
  18995. /**
  18996. * Returns the Vector4 squared length (float).
  18997. * @returns the length squared
  18998. */
  18999. lengthSquared(): number;
  19000. /**
  19001. * Normalizes in place the Vector4.
  19002. * @returns the updated Vector4.
  19003. */
  19004. normalize(): Vector4;
  19005. /**
  19006. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  19007. * @returns this converted to a new vector3
  19008. */
  19009. toVector3(): Vector3;
  19010. /**
  19011. * Returns a new Vector4 copied from the current one.
  19012. * @returns the new cloned vector
  19013. */
  19014. clone(): Vector4;
  19015. /**
  19016. * Updates the current Vector4 with the given one coordinates.
  19017. * @param source the source vector to copy from
  19018. * @returns the updated Vector4.
  19019. */
  19020. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  19021. /**
  19022. * Updates the current Vector4 coordinates with the given floats.
  19023. * @param x float to copy from
  19024. * @param y float to copy from
  19025. * @param z float to copy from
  19026. * @param w float to copy from
  19027. * @returns the updated Vector4.
  19028. */
  19029. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  19030. /**
  19031. * Updates the current Vector4 coordinates with the given floats.
  19032. * @param x float to set from
  19033. * @param y float to set from
  19034. * @param z float to set from
  19035. * @param w float to set from
  19036. * @returns the updated Vector4.
  19037. */
  19038. set(x: number, y: number, z: number, w: number): Vector4;
  19039. /**
  19040. * Copies the given float to the current Vector3 coordinates
  19041. * @param v defines the x, y, z and w coordinates of the operand
  19042. * @returns the current updated Vector3
  19043. */
  19044. setAll(v: number): Vector4;
  19045. /**
  19046. * Returns a new Vector4 set from the starting index of the given array.
  19047. * @param array the array to pull values from
  19048. * @param offset the offset into the array to start at
  19049. * @returns the new vector
  19050. */
  19051. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  19052. /**
  19053. * Updates the given vector "result" from the starting index of the given array.
  19054. * @param array the array to pull values from
  19055. * @param offset the offset into the array to start at
  19056. * @param result the vector to store the result in
  19057. */
  19058. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  19059. /**
  19060. * Updates the given vector "result" from the starting index of the given Float32Array.
  19061. * @param array the array to pull values from
  19062. * @param offset the offset into the array to start at
  19063. * @param result the vector to store the result in
  19064. */
  19065. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  19066. /**
  19067. * Updates the given vector "result" coordinates from the given floats.
  19068. * @param x float to set from
  19069. * @param y float to set from
  19070. * @param z float to set from
  19071. * @param w float to set from
  19072. * @param result the vector to the floats in
  19073. */
  19074. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  19075. /**
  19076. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  19077. * @returns the new vector
  19078. */
  19079. static Zero(): Vector4;
  19080. /**
  19081. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  19082. * @returns the new vector
  19083. */
  19084. static One(): Vector4;
  19085. /**
  19086. * Returns a new normalized Vector4 from the given one.
  19087. * @param vector the vector to normalize
  19088. * @returns the vector
  19089. */
  19090. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  19091. /**
  19092. * Updates the given vector "result" from the normalization of the given one.
  19093. * @param vector the vector to normalize
  19094. * @param result the vector to store the result in
  19095. */
  19096. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  19097. /**
  19098. * Returns a vector with the minimum values from the left and right vectors
  19099. * @param left left vector to minimize
  19100. * @param right right vector to minimize
  19101. * @returns a new vector with the minimum of the left and right vector values
  19102. */
  19103. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  19104. /**
  19105. * Returns a vector with the maximum values from the left and right vectors
  19106. * @param left left vector to maximize
  19107. * @param right right vector to maximize
  19108. * @returns a new vector with the maximum of the left and right vector values
  19109. */
  19110. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  19111. /**
  19112. * Returns the distance (float) between the vectors "value1" and "value2".
  19113. * @param value1 value to calulate the distance between
  19114. * @param value2 value to calulate the distance between
  19115. * @return the distance between the two vectors
  19116. */
  19117. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  19118. /**
  19119. * Returns the squared distance (float) between the vectors "value1" and "value2".
  19120. * @param value1 value to calulate the distance between
  19121. * @param value2 value to calulate the distance between
  19122. * @return the distance between the two vectors squared
  19123. */
  19124. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  19125. /**
  19126. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  19127. * @param value1 value to calulate the center between
  19128. * @param value2 value to calulate the center between
  19129. * @return the center between the two vectors
  19130. */
  19131. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  19132. /**
  19133. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  19134. * This methods computes transformed normalized direction vectors only.
  19135. * @param vector the vector to transform
  19136. * @param transformation the transformation matrix to apply
  19137. * @returns the new vector
  19138. */
  19139. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  19140. /**
  19141. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  19142. * This methods computes transformed normalized direction vectors only.
  19143. * @param vector the vector to transform
  19144. * @param transformation the transformation matrix to apply
  19145. * @param result the vector to store the result in
  19146. */
  19147. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  19148. /**
  19149. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  19150. * This methods computes transformed normalized direction vectors only.
  19151. * @param x value to transform
  19152. * @param y value to transform
  19153. * @param z value to transform
  19154. * @param w value to transform
  19155. * @param transformation the transformation matrix to apply
  19156. * @param result the vector to store the results in
  19157. */
  19158. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  19159. }
  19160. /**
  19161. * Interface for the size containing width and height
  19162. */
  19163. interface ISize {
  19164. /**
  19165. * Width
  19166. */
  19167. width: number;
  19168. /**
  19169. * Heighht
  19170. */
  19171. height: number;
  19172. }
  19173. /**
  19174. * Size containing widht and height
  19175. */
  19176. class Size implements ISize {
  19177. /**
  19178. * Width
  19179. */
  19180. width: number;
  19181. /**
  19182. * Height
  19183. */
  19184. height: number;
  19185. /**
  19186. * Creates a Size object from the given width and height (floats).
  19187. * @param width width of the new size
  19188. * @param height height of the new size
  19189. */
  19190. constructor(width: number, height: number);
  19191. /**
  19192. * Returns a string with the Size width and height
  19193. * @returns a string with the Size width and height
  19194. */
  19195. toString(): string;
  19196. /**
  19197. * "Size"
  19198. * @returns the string "Size"
  19199. */
  19200. getClassName(): string;
  19201. /**
  19202. * Returns the Size hash code.
  19203. * @returns a hash code for a unique width and height
  19204. */
  19205. getHashCode(): number;
  19206. /**
  19207. * Updates the current size from the given one.
  19208. * @param src the given size
  19209. */
  19210. copyFrom(src: Size): void;
  19211. /**
  19212. * Updates in place the current Size from the given floats.
  19213. * @param width width of the new size
  19214. * @param height height of the new size
  19215. * @returns the updated Size.
  19216. */
  19217. copyFromFloats(width: number, height: number): Size;
  19218. /**
  19219. * Updates in place the current Size from the given floats.
  19220. * @param width width to set
  19221. * @param height height to set
  19222. * @returns the updated Size.
  19223. */
  19224. set(width: number, height: number): Size;
  19225. /**
  19226. * Multiplies the width and height by numbers
  19227. * @param w factor to multiple the width by
  19228. * @param h factor to multiple the height by
  19229. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  19230. */
  19231. multiplyByFloats(w: number, h: number): Size;
  19232. /**
  19233. * Clones the size
  19234. * @returns a new Size copied from the given one.
  19235. */
  19236. clone(): Size;
  19237. /**
  19238. * True if the current Size and the given one width and height are strictly equal.
  19239. * @param other the other size to compare against
  19240. * @returns True if the current Size and the given one width and height are strictly equal.
  19241. */
  19242. equals(other: Size): boolean;
  19243. /**
  19244. * The surface of the Size : width * height (float).
  19245. */
  19246. readonly surface: number;
  19247. /**
  19248. * Create a new size of zero
  19249. * @returns a new Size set to (0.0, 0.0)
  19250. */
  19251. static Zero(): Size;
  19252. /**
  19253. * Sums the width and height of two sizes
  19254. * @param otherSize size to add to this size
  19255. * @returns a new Size set as the addition result of the current Size and the given one.
  19256. */
  19257. add(otherSize: Size): Size;
  19258. /**
  19259. * Subtracts the width and height of two
  19260. * @param otherSize size to subtract to this size
  19261. * @returns a new Size set as the subtraction result of the given one from the current Size.
  19262. */
  19263. subtract(otherSize: Size): Size;
  19264. /**
  19265. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  19266. * @param start starting size to lerp between
  19267. * @param end end size to lerp between
  19268. * @param amount amount to lerp between the start and end values
  19269. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  19270. */
  19271. static Lerp(start: Size, end: Size, amount: number): Size;
  19272. }
  19273. /**
  19274. * Class used to store quaternion data
  19275. * @see https://en.wikipedia.org/wiki/Quaternion
  19276. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  19277. */
  19278. class Quaternion {
  19279. /** defines the first component (0 by default) */
  19280. x: number;
  19281. /** defines the second component (0 by default) */
  19282. y: number;
  19283. /** defines the third component (0 by default) */
  19284. z: number;
  19285. /** defines the fourth component (1.0 by default) */
  19286. w: number;
  19287. /**
  19288. * Creates a new Quaternion from the given floats
  19289. * @param x defines the first component (0 by default)
  19290. * @param y defines the second component (0 by default)
  19291. * @param z defines the third component (0 by default)
  19292. * @param w defines the fourth component (1.0 by default)
  19293. */
  19294. constructor(
  19295. /** defines the first component (0 by default) */
  19296. x?: number,
  19297. /** defines the second component (0 by default) */
  19298. y?: number,
  19299. /** defines the third component (0 by default) */
  19300. z?: number,
  19301. /** defines the fourth component (1.0 by default) */
  19302. w?: number);
  19303. /**
  19304. * Gets a string representation for the current quaternion
  19305. * @returns a string with the Quaternion coordinates
  19306. */
  19307. toString(): string;
  19308. /**
  19309. * Gets the class name of the quaternion
  19310. * @returns the string "Quaternion"
  19311. */
  19312. getClassName(): string;
  19313. /**
  19314. * Gets a hash code for this quaternion
  19315. * @returns the quaternion hash code
  19316. */
  19317. getHashCode(): number;
  19318. /**
  19319. * Copy the quaternion to an array
  19320. * @returns a new array populated with 4 elements from the quaternion coordinates
  19321. */
  19322. asArray(): number[];
  19323. /**
  19324. * Check if two quaternions are equals
  19325. * @param otherQuaternion defines the second operand
  19326. * @return true if the current quaternion and the given one coordinates are strictly equals
  19327. */
  19328. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  19329. /**
  19330. * Clone the current quaternion
  19331. * @returns a new quaternion copied from the current one
  19332. */
  19333. clone(): Quaternion;
  19334. /**
  19335. * Copy a quaternion to the current one
  19336. * @param other defines the other quaternion
  19337. * @returns the updated current quaternion
  19338. */
  19339. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  19340. /**
  19341. * Updates the current quaternion with the given float coordinates
  19342. * @param x defines the x coordinate
  19343. * @param y defines the y coordinate
  19344. * @param z defines the z coordinate
  19345. * @param w defines the w coordinate
  19346. * @returns the updated current quaternion
  19347. */
  19348. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  19349. /**
  19350. * Updates the current quaternion from the given float coordinates
  19351. * @param x defines the x coordinate
  19352. * @param y defines the y coordinate
  19353. * @param z defines the z coordinate
  19354. * @param w defines the w coordinate
  19355. * @returns the updated current quaternion
  19356. */
  19357. set(x: number, y: number, z: number, w: number): Quaternion;
  19358. /**
  19359. * Adds two quaternions
  19360. * @param other defines the second operand
  19361. * @returns a new quaternion as the addition result of the given one and the current quaternion
  19362. */
  19363. add(other: DeepImmutable<Quaternion>): Quaternion;
  19364. /**
  19365. * Add a quaternion to the current one
  19366. * @param other defines the quaternion to add
  19367. * @returns the current quaternion
  19368. */
  19369. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  19370. /**
  19371. * Subtract two quaternions
  19372. * @param other defines the second operand
  19373. * @returns a new quaternion as the subtraction result of the given one from the current one
  19374. */
  19375. subtract(other: Quaternion): Quaternion;
  19376. /**
  19377. * Multiplies the current quaternion by a scale factor
  19378. * @param value defines the scale factor
  19379. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  19380. */
  19381. scale(value: number): Quaternion;
  19382. /**
  19383. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  19384. * @param scale defines the scale factor
  19385. * @param result defines the Quaternion object where to store the result
  19386. * @returns the unmodified current quaternion
  19387. */
  19388. scaleToRef(scale: number, result: Quaternion): Quaternion;
  19389. /**
  19390. * Multiplies in place the current quaternion by a scale factor
  19391. * @param value defines the scale factor
  19392. * @returns the current modified quaternion
  19393. */
  19394. scaleInPlace(value: number): Quaternion;
  19395. /**
  19396. * Scale the current quaternion values by a factor and add the result to a given quaternion
  19397. * @param scale defines the scale factor
  19398. * @param result defines the Quaternion object where to store the result
  19399. * @returns the unmodified current quaternion
  19400. */
  19401. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  19402. /**
  19403. * Multiplies two quaternions
  19404. * @param q1 defines the second operand
  19405. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  19406. */
  19407. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  19408. /**
  19409. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  19410. * @param q1 defines the second operand
  19411. * @param result defines the target quaternion
  19412. * @returns the current quaternion
  19413. */
  19414. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  19415. /**
  19416. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  19417. * @param q1 defines the second operand
  19418. * @returns the currentupdated quaternion
  19419. */
  19420. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  19421. /**
  19422. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  19423. * @param ref defines the target quaternion
  19424. * @returns the current quaternion
  19425. */
  19426. conjugateToRef(ref: Quaternion): Quaternion;
  19427. /**
  19428. * Conjugates in place (1-q) the current quaternion
  19429. * @returns the current updated quaternion
  19430. */
  19431. conjugateInPlace(): Quaternion;
  19432. /**
  19433. * Conjugates in place (1-q) the current quaternion
  19434. * @returns a new quaternion
  19435. */
  19436. conjugate(): Quaternion;
  19437. /**
  19438. * Gets length of current quaternion
  19439. * @returns the quaternion length (float)
  19440. */
  19441. length(): number;
  19442. /**
  19443. * Normalize in place the current quaternion
  19444. * @returns the current updated quaternion
  19445. */
  19446. normalize(): Quaternion;
  19447. /**
  19448. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  19449. * @param order is a reserved parameter and is ignore for now
  19450. * @returns a new Vector3 containing the Euler angles
  19451. */
  19452. toEulerAngles(order?: string): Vector3;
  19453. /**
  19454. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  19455. * @param result defines the vector which will be filled with the Euler angles
  19456. * @param order is a reserved parameter and is ignore for now
  19457. * @returns the current unchanged quaternion
  19458. */
  19459. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  19460. /**
  19461. * Updates the given rotation matrix with the current quaternion values
  19462. * @param result defines the target matrix
  19463. * @returns the current unchanged quaternion
  19464. */
  19465. toRotationMatrix(result: Matrix): Quaternion;
  19466. /**
  19467. * Updates the current quaternion from the given rotation matrix values
  19468. * @param matrix defines the source matrix
  19469. * @returns the current updated quaternion
  19470. */
  19471. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  19472. /**
  19473. * Creates a new quaternion from a rotation matrix
  19474. * @param matrix defines the source matrix
  19475. * @returns a new quaternion created from the given rotation matrix values
  19476. */
  19477. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  19478. /**
  19479. * Updates the given quaternion with the given rotation matrix values
  19480. * @param matrix defines the source matrix
  19481. * @param result defines the target quaternion
  19482. */
  19483. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  19484. /**
  19485. * Returns the dot product (float) between the quaternions "left" and "right"
  19486. * @param left defines the left operand
  19487. * @param right defines the right operand
  19488. * @returns the dot product
  19489. */
  19490. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  19491. /**
  19492. * Checks if the two quaternions are close to each other
  19493. * @param quat0 defines the first quaternion to check
  19494. * @param quat1 defines the second quaternion to check
  19495. * @returns true if the two quaternions are close to each other
  19496. */
  19497. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  19498. /**
  19499. * Creates an empty quaternion
  19500. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  19501. */
  19502. static Zero(): Quaternion;
  19503. /**
  19504. * Inverse a given quaternion
  19505. * @param q defines the source quaternion
  19506. * @returns a new quaternion as the inverted current quaternion
  19507. */
  19508. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  19509. /**
  19510. * Inverse a given quaternion
  19511. * @param q defines the source quaternion
  19512. * @param result the quaternion the result will be stored in
  19513. * @returns the result quaternion
  19514. */
  19515. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  19516. /**
  19517. * Creates an identity quaternion
  19518. * @returns the identity quaternion
  19519. */
  19520. static Identity(): Quaternion;
  19521. /**
  19522. * Gets a boolean indicating if the given quaternion is identity
  19523. * @param quaternion defines the quaternion to check
  19524. * @returns true if the quaternion is identity
  19525. */
  19526. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  19527. /**
  19528. * Creates a quaternion from a rotation around an axis
  19529. * @param axis defines the axis to use
  19530. * @param angle defines the angle to use
  19531. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  19532. */
  19533. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  19534. /**
  19535. * Creates a rotation around an axis and stores it into the given quaternion
  19536. * @param axis defines the axis to use
  19537. * @param angle defines the angle to use
  19538. * @param result defines the target quaternion
  19539. * @returns the target quaternion
  19540. */
  19541. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  19542. /**
  19543. * Creates a new quaternion from data stored into an array
  19544. * @param array defines the data source
  19545. * @param offset defines the offset in the source array where the data starts
  19546. * @returns a new quaternion
  19547. */
  19548. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  19549. /**
  19550. * Create a quaternion from Euler rotation angles
  19551. * @param x Pitch
  19552. * @param y Yaw
  19553. * @param z Roll
  19554. * @returns the new Quaternion
  19555. */
  19556. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  19557. /**
  19558. * Updates a quaternion from Euler rotation angles
  19559. * @param x Pitch
  19560. * @param y Yaw
  19561. * @param z Roll
  19562. * @param result the quaternion to store the result
  19563. * @returns the updated quaternion
  19564. */
  19565. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  19566. /**
  19567. * Create a quaternion from Euler rotation vector
  19568. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  19569. * @returns the new Quaternion
  19570. */
  19571. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  19572. /**
  19573. * Updates a quaternion from Euler rotation vector
  19574. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  19575. * @param result the quaternion to store the result
  19576. * @returns the updated quaternion
  19577. */
  19578. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  19579. /**
  19580. * Creates a new quaternion from the given Euler float angles (y, x, z)
  19581. * @param yaw defines the rotation around Y axis
  19582. * @param pitch defines the rotation around X axis
  19583. * @param roll defines the rotation around Z axis
  19584. * @returns the new quaternion
  19585. */
  19586. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  19587. /**
  19588. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  19589. * @param yaw defines the rotation around Y axis
  19590. * @param pitch defines the rotation around X axis
  19591. * @param roll defines the rotation around Z axis
  19592. * @param result defines the target quaternion
  19593. */
  19594. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  19595. /**
  19596. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  19597. * @param alpha defines the rotation around first axis
  19598. * @param beta defines the rotation around second axis
  19599. * @param gamma defines the rotation around third axis
  19600. * @returns the new quaternion
  19601. */
  19602. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  19603. /**
  19604. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  19605. * @param alpha defines the rotation around first axis
  19606. * @param beta defines the rotation around second axis
  19607. * @param gamma defines the rotation around third axis
  19608. * @param result defines the target quaternion
  19609. */
  19610. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  19611. /**
  19612. * 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)
  19613. * @param axis1 defines the first axis
  19614. * @param axis2 defines the second axis
  19615. * @param axis3 defines the third axis
  19616. * @returns the new quaternion
  19617. */
  19618. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  19619. /**
  19620. * 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
  19621. * @param axis1 defines the first axis
  19622. * @param axis2 defines the second axis
  19623. * @param axis3 defines the third axis
  19624. * @param ref defines the target quaternion
  19625. */
  19626. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  19627. /**
  19628. * Interpolates between two quaternions
  19629. * @param left defines first quaternion
  19630. * @param right defines second quaternion
  19631. * @param amount defines the gradient to use
  19632. * @returns the new interpolated quaternion
  19633. */
  19634. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  19635. /**
  19636. * Interpolates between two quaternions and stores it into a target quaternion
  19637. * @param left defines first quaternion
  19638. * @param right defines second quaternion
  19639. * @param amount defines the gradient to use
  19640. * @param result defines the target quaternion
  19641. */
  19642. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  19643. /**
  19644. * Interpolate between two quaternions using Hermite interpolation
  19645. * @param value1 defines first quaternion
  19646. * @param tangent1 defines the incoming tangent
  19647. * @param value2 defines second quaternion
  19648. * @param tangent2 defines the outgoing tangent
  19649. * @param amount defines the target quaternion
  19650. * @returns the new interpolated quaternion
  19651. */
  19652. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  19653. }
  19654. /**
  19655. * Class used to store matrix data (4x4)
  19656. */
  19657. class Matrix {
  19658. private static _updateFlagSeed;
  19659. private static _identityReadOnly;
  19660. private _isIdentity;
  19661. private _isIdentityDirty;
  19662. private _isIdentity3x2;
  19663. private _isIdentity3x2Dirty;
  19664. /**
  19665. * Gets the update flag of the matrix which is an unique number for the matrix.
  19666. * It will be incremented every time the matrix data change.
  19667. * You can use it to speed the comparison between two versions of the same matrix.
  19668. */
  19669. updateFlag: number;
  19670. private readonly _m;
  19671. /**
  19672. * Gets the internal data of the matrix
  19673. */
  19674. readonly m: DeepImmutable<Float32Array>;
  19675. /** @hidden */
  19676. _markAsUpdated(): void;
  19677. /** @hidden */
  19678. private _updateIdentityStatus;
  19679. /**
  19680. * Creates an empty matrix (filled with zeros)
  19681. */
  19682. constructor();
  19683. /**
  19684. * Check if the current matrix is identity
  19685. * @returns true is the matrix is the identity matrix
  19686. */
  19687. isIdentity(): boolean;
  19688. /**
  19689. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  19690. * @returns true is the matrix is the identity matrix
  19691. */
  19692. isIdentityAs3x2(): boolean;
  19693. /**
  19694. * Gets the determinant of the matrix
  19695. * @returns the matrix determinant
  19696. */
  19697. determinant(): number;
  19698. /**
  19699. * Returns the matrix as a Float32Array
  19700. * @returns the matrix underlying array
  19701. */
  19702. toArray(): DeepImmutable<Float32Array>;
  19703. /**
  19704. * Returns the matrix as a Float32Array
  19705. * @returns the matrix underlying array.
  19706. */
  19707. asArray(): DeepImmutable<Float32Array>;
  19708. /**
  19709. * Inverts the current matrix in place
  19710. * @returns the current inverted matrix
  19711. */
  19712. invert(): Matrix;
  19713. /**
  19714. * Sets all the matrix elements to zero
  19715. * @returns the current matrix
  19716. */
  19717. reset(): Matrix;
  19718. /**
  19719. * Adds the current matrix with a second one
  19720. * @param other defines the matrix to add
  19721. * @returns a new matrix as the addition of the current matrix and the given one
  19722. */
  19723. add(other: DeepImmutable<Matrix>): Matrix;
  19724. /**
  19725. * Sets the given matrix "result" to the addition of the current matrix and the given one
  19726. * @param other defines the matrix to add
  19727. * @param result defines the target matrix
  19728. * @returns the current matrix
  19729. */
  19730. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  19731. /**
  19732. * Adds in place the given matrix to the current matrix
  19733. * @param other defines the second operand
  19734. * @returns the current updated matrix
  19735. */
  19736. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  19737. /**
  19738. * Sets the given matrix to the current inverted Matrix
  19739. * @param other defines the target matrix
  19740. * @returns the unmodified current matrix
  19741. */
  19742. invertToRef(other: Matrix): Matrix;
  19743. /**
  19744. * add a value at the specified position in the current Matrix
  19745. * @param index the index of the value within the matrix. between 0 and 15.
  19746. * @param value the value to be added
  19747. * @returns the current updated matrix
  19748. */
  19749. addAtIndex(index: number, value: number): Matrix;
  19750. /**
  19751. * mutiply the specified position in the current Matrix by a value
  19752. * @param index the index of the value within the matrix. between 0 and 15.
  19753. * @param value the value to be added
  19754. * @returns the current updated matrix
  19755. */
  19756. multiplyAtIndex(index: number, value: number): Matrix;
  19757. /**
  19758. * Inserts the translation vector (using 3 floats) in the current matrix
  19759. * @param x defines the 1st component of the translation
  19760. * @param y defines the 2nd component of the translation
  19761. * @param z defines the 3rd component of the translation
  19762. * @returns the current updated matrix
  19763. */
  19764. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  19765. /**
  19766. * Inserts the translation vector in the current matrix
  19767. * @param vector3 defines the translation to insert
  19768. * @returns the current updated matrix
  19769. */
  19770. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  19771. /**
  19772. * Gets the translation value of the current matrix
  19773. * @returns a new Vector3 as the extracted translation from the matrix
  19774. */
  19775. getTranslation(): Vector3;
  19776. /**
  19777. * Fill a Vector3 with the extracted translation from the matrix
  19778. * @param result defines the Vector3 where to store the translation
  19779. * @returns the current matrix
  19780. */
  19781. getTranslationToRef(result: Vector3): Matrix;
  19782. /**
  19783. * Remove rotation and scaling part from the matrix
  19784. * @returns the updated matrix
  19785. */
  19786. removeRotationAndScaling(): Matrix;
  19787. /**
  19788. * Multiply two matrices
  19789. * @param other defines the second operand
  19790. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  19791. */
  19792. multiply(other: DeepImmutable<Matrix>): Matrix;
  19793. /**
  19794. * Copy the current matrix from the given one
  19795. * @param other defines the source matrix
  19796. * @returns the current updated matrix
  19797. */
  19798. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  19799. /**
  19800. * Populates the given array from the starting index with the current matrix values
  19801. * @param array defines the target array
  19802. * @param offset defines the offset in the target array where to start storing values
  19803. * @returns the current matrix
  19804. */
  19805. copyToArray(array: Float32Array, offset?: number): Matrix;
  19806. /**
  19807. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  19808. * @param other defines the second operand
  19809. * @param result defines the matrix where to store the multiplication
  19810. * @returns the current matrix
  19811. */
  19812. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  19813. /**
  19814. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  19815. * @param other defines the second operand
  19816. * @param result defines the array where to store the multiplication
  19817. * @param offset defines the offset in the target array where to start storing values
  19818. * @returns the current matrix
  19819. */
  19820. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  19821. /**
  19822. * Check equality between this matrix and a second one
  19823. * @param value defines the second matrix to compare
  19824. * @returns true is the current matrix and the given one values are strictly equal
  19825. */
  19826. equals(value: DeepImmutable<Matrix>): boolean;
  19827. /**
  19828. * Clone the current matrix
  19829. * @returns a new matrix from the current matrix
  19830. */
  19831. clone(): Matrix;
  19832. /**
  19833. * Returns the name of the current matrix class
  19834. * @returns the string "Matrix"
  19835. */
  19836. getClassName(): string;
  19837. /**
  19838. * Gets the hash code of the current matrix
  19839. * @returns the hash code
  19840. */
  19841. getHashCode(): number;
  19842. /**
  19843. * Decomposes the current Matrix into a translation, rotation and scaling components
  19844. * @param scale defines the scale vector3 given as a reference to update
  19845. * @param rotation defines the rotation quaternion given as a reference to update
  19846. * @param translation defines the translation vector3 given as a reference to update
  19847. * @returns true if operation was successful
  19848. */
  19849. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  19850. /**
  19851. * Gets specific row of the matrix
  19852. * @param index defines the number of the row to get
  19853. * @returns the index-th row of the current matrix as a new Vector4
  19854. */
  19855. getRow(index: number): Nullable<Vector4>;
  19856. /**
  19857. * Sets the index-th row of the current matrix to the vector4 values
  19858. * @param index defines the number of the row to set
  19859. * @param row defines the target vector4
  19860. * @returns the updated current matrix
  19861. */
  19862. setRow(index: number, row: Vector4): Matrix;
  19863. /**
  19864. * Compute the transpose of the matrix
  19865. * @returns the new transposed matrix
  19866. */
  19867. transpose(): Matrix;
  19868. /**
  19869. * Compute the transpose of the matrix and store it in a given matrix
  19870. * @param result defines the target matrix
  19871. * @returns the current matrix
  19872. */
  19873. transposeToRef(result: Matrix): Matrix;
  19874. /**
  19875. * Sets the index-th row of the current matrix with the given 4 x float values
  19876. * @param index defines the row index
  19877. * @param x defines the x component to set
  19878. * @param y defines the y component to set
  19879. * @param z defines the z component to set
  19880. * @param w defines the w component to set
  19881. * @returns the updated current matrix
  19882. */
  19883. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  19884. /**
  19885. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  19886. * @param scale defines the scale factor
  19887. * @returns a new matrix
  19888. */
  19889. scale(scale: number): Matrix;
  19890. /**
  19891. * Scale the current matrix values by a factor to a given result matrix
  19892. * @param scale defines the scale factor
  19893. * @param result defines the matrix to store the result
  19894. * @returns the current matrix
  19895. */
  19896. scaleToRef(scale: number, result: Matrix): Matrix;
  19897. /**
  19898. * Scale the current matrix values by a factor and add the result to a given matrix
  19899. * @param scale defines the scale factor
  19900. * @param result defines the Matrix to store the result
  19901. * @returns the current matrix
  19902. */
  19903. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  19904. /**
  19905. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  19906. * @param ref matrix to store the result
  19907. */
  19908. toNormalMatrix(ref: Matrix): void;
  19909. /**
  19910. * Gets only rotation part of the current matrix
  19911. * @returns a new matrix sets to the extracted rotation matrix from the current one
  19912. */
  19913. getRotationMatrix(): Matrix;
  19914. /**
  19915. * Extracts the rotation matrix from the current one and sets it as the given "result"
  19916. * @param result defines the target matrix to store data to
  19917. * @returns the current matrix
  19918. */
  19919. getRotationMatrixToRef(result: Matrix): Matrix;
  19920. /**
  19921. * Toggles model matrix from being right handed to left handed in place and vice versa
  19922. */
  19923. toggleModelMatrixHandInPlace(): void;
  19924. /**
  19925. * Toggles projection matrix from being right handed to left handed in place and vice versa
  19926. */
  19927. toggleProjectionMatrixHandInPlace(): void;
  19928. /**
  19929. * Creates a matrix from an array
  19930. * @param array defines the source array
  19931. * @param offset defines an offset in the source array
  19932. * @returns a new Matrix set from the starting index of the given array
  19933. */
  19934. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  19935. /**
  19936. * Copy the content of an array into a given matrix
  19937. * @param array defines the source array
  19938. * @param offset defines an offset in the source array
  19939. * @param result defines the target matrix
  19940. */
  19941. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  19942. /**
  19943. * Stores an array into a matrix after having multiplied each component by a given factor
  19944. * @param array defines the source array
  19945. * @param offset defines the offset in the source array
  19946. * @param scale defines the scaling factor
  19947. * @param result defines the target matrix
  19948. */
  19949. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  19950. /**
  19951. * Gets an identity matrix that must not be updated
  19952. */
  19953. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  19954. /**
  19955. * Stores a list of values (16) inside a given matrix
  19956. * @param initialM11 defines 1st value of 1st row
  19957. * @param initialM12 defines 2nd value of 1st row
  19958. * @param initialM13 defines 3rd value of 1st row
  19959. * @param initialM14 defines 4th value of 1st row
  19960. * @param initialM21 defines 1st value of 2nd row
  19961. * @param initialM22 defines 2nd value of 2nd row
  19962. * @param initialM23 defines 3rd value of 2nd row
  19963. * @param initialM24 defines 4th value of 2nd row
  19964. * @param initialM31 defines 1st value of 3rd row
  19965. * @param initialM32 defines 2nd value of 3rd row
  19966. * @param initialM33 defines 3rd value of 3rd row
  19967. * @param initialM34 defines 4th value of 3rd row
  19968. * @param initialM41 defines 1st value of 4th row
  19969. * @param initialM42 defines 2nd value of 4th row
  19970. * @param initialM43 defines 3rd value of 4th row
  19971. * @param initialM44 defines 4th value of 4th row
  19972. * @param result defines the target matrix
  19973. */
  19974. 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;
  19975. /**
  19976. * Creates new matrix from a list of values (16)
  19977. * @param initialM11 defines 1st value of 1st row
  19978. * @param initialM12 defines 2nd value of 1st row
  19979. * @param initialM13 defines 3rd value of 1st row
  19980. * @param initialM14 defines 4th value of 1st row
  19981. * @param initialM21 defines 1st value of 2nd row
  19982. * @param initialM22 defines 2nd value of 2nd row
  19983. * @param initialM23 defines 3rd value of 2nd row
  19984. * @param initialM24 defines 4th value of 2nd row
  19985. * @param initialM31 defines 1st value of 3rd row
  19986. * @param initialM32 defines 2nd value of 3rd row
  19987. * @param initialM33 defines 3rd value of 3rd row
  19988. * @param initialM34 defines 4th value of 3rd row
  19989. * @param initialM41 defines 1st value of 4th row
  19990. * @param initialM42 defines 2nd value of 4th row
  19991. * @param initialM43 defines 3rd value of 4th row
  19992. * @param initialM44 defines 4th value of 4th row
  19993. * @returns the new matrix
  19994. */
  19995. 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;
  19996. /**
  19997. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  19998. * @param scale defines the scale vector3
  19999. * @param rotation defines the rotation quaternion
  20000. * @param translation defines the translation vector3
  20001. * @returns a new matrix
  20002. */
  20003. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  20004. /**
  20005. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  20006. * @param scale defines the scale vector3
  20007. * @param rotation defines the rotation quaternion
  20008. * @param translation defines the translation vector3
  20009. * @param result defines the target matrix
  20010. */
  20011. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  20012. /**
  20013. * Creates a new identity matrix
  20014. * @returns a new identity matrix
  20015. */
  20016. static Identity(): Matrix;
  20017. /**
  20018. * Creates a new identity matrix and stores the result in a given matrix
  20019. * @param result defines the target matrix
  20020. */
  20021. static IdentityToRef(result: Matrix): void;
  20022. /**
  20023. * Creates a new zero matrix
  20024. * @returns a new zero matrix
  20025. */
  20026. static Zero(): Matrix;
  20027. /**
  20028. * Creates a new rotation matrix for "angle" radians around the X axis
  20029. * @param angle defines the angle (in radians) to use
  20030. * @return the new matrix
  20031. */
  20032. static RotationX(angle: number): Matrix;
  20033. /**
  20034. * Creates a new matrix as the invert of a given matrix
  20035. * @param source defines the source matrix
  20036. * @returns the new matrix
  20037. */
  20038. static Invert(source: DeepImmutable<Matrix>): Matrix;
  20039. /**
  20040. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  20041. * @param angle defines the angle (in radians) to use
  20042. * @param result defines the target matrix
  20043. */
  20044. static RotationXToRef(angle: number, result: Matrix): void;
  20045. /**
  20046. * Creates a new rotation matrix for "angle" radians around the Y axis
  20047. * @param angle defines the angle (in radians) to use
  20048. * @return the new matrix
  20049. */
  20050. static RotationY(angle: number): Matrix;
  20051. /**
  20052. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  20053. * @param angle defines the angle (in radians) to use
  20054. * @param result defines the target matrix
  20055. */
  20056. static RotationYToRef(angle: number, result: Matrix): void;
  20057. /**
  20058. * Creates a new rotation matrix for "angle" radians around the Z axis
  20059. * @param angle defines the angle (in radians) to use
  20060. * @return the new matrix
  20061. */
  20062. static RotationZ(angle: number): Matrix;
  20063. /**
  20064. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  20065. * @param angle defines the angle (in radians) to use
  20066. * @param result defines the target matrix
  20067. */
  20068. static RotationZToRef(angle: number, result: Matrix): void;
  20069. /**
  20070. * Creates a new rotation matrix for "angle" radians around the given axis
  20071. * @param axis defines the axis to use
  20072. * @param angle defines the angle (in radians) to use
  20073. * @return the new matrix
  20074. */
  20075. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  20076. /**
  20077. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  20078. * @param axis defines the axis to use
  20079. * @param angle defines the angle (in radians) to use
  20080. * @param result defines the target matrix
  20081. */
  20082. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  20083. /**
  20084. * Creates a rotation matrix
  20085. * @param yaw defines the yaw angle in radians (Y axis)
  20086. * @param pitch defines the pitch angle in radians (X axis)
  20087. * @param roll defines the roll angle in radians (X axis)
  20088. * @returns the new rotation matrix
  20089. */
  20090. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  20091. /**
  20092. * Creates a rotation matrix and stores it in a given matrix
  20093. * @param yaw defines the yaw angle in radians (Y axis)
  20094. * @param pitch defines the pitch angle in radians (X axis)
  20095. * @param roll defines the roll angle in radians (X axis)
  20096. * @param result defines the target matrix
  20097. */
  20098. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  20099. /**
  20100. * Creates a scaling matrix
  20101. * @param x defines the scale factor on X axis
  20102. * @param y defines the scale factor on Y axis
  20103. * @param z defines the scale factor on Z axis
  20104. * @returns the new matrix
  20105. */
  20106. static Scaling(x: number, y: number, z: number): Matrix;
  20107. /**
  20108. * Creates a scaling matrix and stores it in a given matrix
  20109. * @param x defines the scale factor on X axis
  20110. * @param y defines the scale factor on Y axis
  20111. * @param z defines the scale factor on Z axis
  20112. * @param result defines the target matrix
  20113. */
  20114. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  20115. /**
  20116. * Creates a translation matrix
  20117. * @param x defines the translation on X axis
  20118. * @param y defines the translation on Y axis
  20119. * @param z defines the translationon Z axis
  20120. * @returns the new matrix
  20121. */
  20122. static Translation(x: number, y: number, z: number): Matrix;
  20123. /**
  20124. * Creates a translation matrix and stores it in a given matrix
  20125. * @param x defines the translation on X axis
  20126. * @param y defines the translation on Y axis
  20127. * @param z defines the translationon Z axis
  20128. * @param result defines the target matrix
  20129. */
  20130. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  20131. /**
  20132. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  20133. * @param startValue defines the start value
  20134. * @param endValue defines the end value
  20135. * @param gradient defines the gradient factor
  20136. * @returns the new matrix
  20137. */
  20138. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  20139. /**
  20140. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  20141. * @param startValue defines the start value
  20142. * @param endValue defines the end value
  20143. * @param gradient defines the gradient factor
  20144. * @param result defines the Matrix object where to store data
  20145. */
  20146. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  20147. /**
  20148. * Builds a new matrix whose values are computed by:
  20149. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  20150. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  20151. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  20152. * @param startValue defines the first matrix
  20153. * @param endValue defines the second matrix
  20154. * @param gradient defines the gradient between the two matrices
  20155. * @returns the new matrix
  20156. */
  20157. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  20158. /**
  20159. * Update a matrix to values which are computed by:
  20160. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  20161. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  20162. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  20163. * @param startValue defines the first matrix
  20164. * @param endValue defines the second matrix
  20165. * @param gradient defines the gradient between the two matrices
  20166. * @param result defines the target matrix
  20167. */
  20168. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  20169. /**
  20170. * 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"
  20171. * This function works in left handed mode
  20172. * @param eye defines the final position of the entity
  20173. * @param target defines where the entity should look at
  20174. * @param up defines the up vector for the entity
  20175. * @returns the new matrix
  20176. */
  20177. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  20178. /**
  20179. * 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".
  20180. * This function works in left handed mode
  20181. * @param eye defines the final position of the entity
  20182. * @param target defines where the entity should look at
  20183. * @param up defines the up vector for the entity
  20184. * @param result defines the target matrix
  20185. */
  20186. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  20187. /**
  20188. * 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"
  20189. * This function works in right handed mode
  20190. * @param eye defines the final position of the entity
  20191. * @param target defines where the entity should look at
  20192. * @param up defines the up vector for the entity
  20193. * @returns the new matrix
  20194. */
  20195. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  20196. /**
  20197. * 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".
  20198. * This function works in right handed mode
  20199. * @param eye defines the final position of the entity
  20200. * @param target defines where the entity should look at
  20201. * @param up defines the up vector for the entity
  20202. * @param result defines the target matrix
  20203. */
  20204. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  20205. /**
  20206. * Create a left-handed orthographic projection matrix
  20207. * @param width defines the viewport width
  20208. * @param height defines the viewport height
  20209. * @param znear defines the near clip plane
  20210. * @param zfar defines the far clip plane
  20211. * @returns a new matrix as a left-handed orthographic projection matrix
  20212. */
  20213. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  20214. /**
  20215. * Store a left-handed orthographic projection to a given matrix
  20216. * @param width defines the viewport width
  20217. * @param height defines the viewport height
  20218. * @param znear defines the near clip plane
  20219. * @param zfar defines the far clip plane
  20220. * @param result defines the target matrix
  20221. */
  20222. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  20223. /**
  20224. * Create a left-handed orthographic projection matrix
  20225. * @param left defines the viewport left coordinate
  20226. * @param right defines the viewport right coordinate
  20227. * @param bottom defines the viewport bottom coordinate
  20228. * @param top defines the viewport top coordinate
  20229. * @param znear defines the near clip plane
  20230. * @param zfar defines the far clip plane
  20231. * @returns a new matrix as a left-handed orthographic projection matrix
  20232. */
  20233. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  20234. /**
  20235. * Stores a left-handed orthographic projection into a given matrix
  20236. * @param left defines the viewport left coordinate
  20237. * @param right defines the viewport right coordinate
  20238. * @param bottom defines the viewport bottom coordinate
  20239. * @param top defines the viewport top coordinate
  20240. * @param znear defines the near clip plane
  20241. * @param zfar defines the far clip plane
  20242. * @param result defines the target matrix
  20243. */
  20244. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  20245. /**
  20246. * Creates a right-handed orthographic projection matrix
  20247. * @param left defines the viewport left coordinate
  20248. * @param right defines the viewport right coordinate
  20249. * @param bottom defines the viewport bottom coordinate
  20250. * @param top defines the viewport top coordinate
  20251. * @param znear defines the near clip plane
  20252. * @param zfar defines the far clip plane
  20253. * @returns a new matrix as a right-handed orthographic projection matrix
  20254. */
  20255. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  20256. /**
  20257. * Stores a right-handed orthographic projection into a given matrix
  20258. * @param left defines the viewport left coordinate
  20259. * @param right defines the viewport right coordinate
  20260. * @param bottom defines the viewport bottom coordinate
  20261. * @param top defines the viewport top coordinate
  20262. * @param znear defines the near clip plane
  20263. * @param zfar defines the far clip plane
  20264. * @param result defines the target matrix
  20265. */
  20266. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  20267. /**
  20268. * Creates a left-handed perspective projection matrix
  20269. * @param width defines the viewport width
  20270. * @param height defines the viewport height
  20271. * @param znear defines the near clip plane
  20272. * @param zfar defines the far clip plane
  20273. * @returns a new matrix as a left-handed perspective projection matrix
  20274. */
  20275. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  20276. /**
  20277. * Creates a left-handed perspective projection matrix
  20278. * @param fov defines the horizontal field of view
  20279. * @param aspect defines the aspect ratio
  20280. * @param znear defines the near clip plane
  20281. * @param zfar defines the far clip plane
  20282. * @returns a new matrix as a left-handed perspective projection matrix
  20283. */
  20284. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  20285. /**
  20286. * Stores a left-handed perspective projection into a given matrix
  20287. * @param fov defines the horizontal field of view
  20288. * @param aspect defines the aspect ratio
  20289. * @param znear defines the near clip plane
  20290. * @param zfar defines the far clip plane
  20291. * @param result defines the target matrix
  20292. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  20293. */
  20294. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  20295. /**
  20296. * Creates a right-handed perspective projection matrix
  20297. * @param fov defines the horizontal field of view
  20298. * @param aspect defines the aspect ratio
  20299. * @param znear defines the near clip plane
  20300. * @param zfar defines the far clip plane
  20301. * @returns a new matrix as a right-handed perspective projection matrix
  20302. */
  20303. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  20304. /**
  20305. * Stores a right-handed perspective projection into a given matrix
  20306. * @param fov defines the horizontal field of view
  20307. * @param aspect defines the aspect ratio
  20308. * @param znear defines the near clip plane
  20309. * @param zfar defines the far clip plane
  20310. * @param result defines the target matrix
  20311. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  20312. */
  20313. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  20314. /**
  20315. * Stores a perspective projection for WebVR info a given matrix
  20316. * @param fov defines the field of view
  20317. * @param znear defines the near clip plane
  20318. * @param zfar defines the far clip plane
  20319. * @param result defines the target matrix
  20320. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  20321. */
  20322. static PerspectiveFovWebVRToRef(fov: {
  20323. upDegrees: number;
  20324. downDegrees: number;
  20325. leftDegrees: number;
  20326. rightDegrees: number;
  20327. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  20328. /**
  20329. * Computes a complete transformation matrix
  20330. * @param viewport defines the viewport to use
  20331. * @param world defines the world matrix
  20332. * @param view defines the view matrix
  20333. * @param projection defines the projection matrix
  20334. * @param zmin defines the near clip plane
  20335. * @param zmax defines the far clip plane
  20336. * @returns the transformation matrix
  20337. */
  20338. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  20339. /**
  20340. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  20341. * @param matrix defines the matrix to use
  20342. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  20343. */
  20344. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  20345. /**
  20346. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  20347. * @param matrix defines the matrix to use
  20348. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  20349. */
  20350. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  20351. /**
  20352. * Compute the transpose of a given matrix
  20353. * @param matrix defines the matrix to transpose
  20354. * @returns the new matrix
  20355. */
  20356. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  20357. /**
  20358. * Compute the transpose of a matrix and store it in a target matrix
  20359. * @param matrix defines the matrix to transpose
  20360. * @param result defines the target matrix
  20361. */
  20362. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  20363. /**
  20364. * Computes a reflection matrix from a plane
  20365. * @param plane defines the reflection plane
  20366. * @returns a new matrix
  20367. */
  20368. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  20369. /**
  20370. * Computes a reflection matrix from a plane
  20371. * @param plane defines the reflection plane
  20372. * @param result defines the target matrix
  20373. */
  20374. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  20375. /**
  20376. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  20377. * @param xaxis defines the value of the 1st axis
  20378. * @param yaxis defines the value of the 2nd axis
  20379. * @param zaxis defines the value of the 3rd axis
  20380. * @param result defines the target matrix
  20381. */
  20382. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  20383. /**
  20384. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  20385. * @param quat defines the quaternion to use
  20386. * @param result defines the target matrix
  20387. */
  20388. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  20389. }
  20390. /**
  20391. * Represens a plane by the equation ax + by + cz + d = 0
  20392. */
  20393. class Plane {
  20394. /**
  20395. * Normal of the plane (a,b,c)
  20396. */
  20397. normal: Vector3;
  20398. /**
  20399. * d component of the plane
  20400. */
  20401. d: number;
  20402. /**
  20403. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  20404. * @param a a component of the plane
  20405. * @param b b component of the plane
  20406. * @param c c component of the plane
  20407. * @param d d component of the plane
  20408. */
  20409. constructor(a: number, b: number, c: number, d: number);
  20410. /**
  20411. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  20412. */
  20413. asArray(): number[];
  20414. /**
  20415. * @returns a new plane copied from the current Plane.
  20416. */
  20417. clone(): Plane;
  20418. /**
  20419. * @returns the string "Plane".
  20420. */
  20421. getClassName(): string;
  20422. /**
  20423. * @returns the Plane hash code.
  20424. */
  20425. getHashCode(): number;
  20426. /**
  20427. * Normalize the current Plane in place.
  20428. * @returns the updated Plane.
  20429. */
  20430. normalize(): Plane;
  20431. /**
  20432. * Applies a transformation the plane and returns the result
  20433. * @param transformation the transformation matrix to be applied to the plane
  20434. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  20435. */
  20436. transform(transformation: DeepImmutable<Matrix>): Plane;
  20437. /**
  20438. * Calcualtte the dot product between the point and the plane normal
  20439. * @param point point to calculate the dot product with
  20440. * @returns the dot product (float) of the point coordinates and the plane normal.
  20441. */
  20442. dotCoordinate(point: DeepImmutable<Vector3>): number;
  20443. /**
  20444. * Updates the current Plane from the plane defined by the three given points.
  20445. * @param point1 one of the points used to contruct the plane
  20446. * @param point2 one of the points used to contruct the plane
  20447. * @param point3 one of the points used to contruct the plane
  20448. * @returns the updated Plane.
  20449. */
  20450. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  20451. /**
  20452. * Checks if the plane is facing a given direction
  20453. * @param direction the direction to check if the plane is facing
  20454. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  20455. * @returns True is the vector "direction" is the same side than the plane normal.
  20456. */
  20457. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  20458. /**
  20459. * Calculates the distance to a point
  20460. * @param point point to calculate distance to
  20461. * @returns the signed distance (float) from the given point to the Plane.
  20462. */
  20463. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  20464. /**
  20465. * Creates a plane from an array
  20466. * @param array the array to create a plane from
  20467. * @returns a new Plane from the given array.
  20468. */
  20469. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  20470. /**
  20471. * Creates a plane from three points
  20472. * @param point1 point used to create the plane
  20473. * @param point2 point used to create the plane
  20474. * @param point3 point used to create the plane
  20475. * @returns a new Plane defined by the three given points.
  20476. */
  20477. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  20478. /**
  20479. * Creates a plane from an origin point and a normal
  20480. * @param origin origin of the plane to be constructed
  20481. * @param normal normal of the plane to be constructed
  20482. * @returns a new Plane the normal vector to this plane at the given origin point.
  20483. * Note : the vector "normal" is updated because normalized.
  20484. */
  20485. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  20486. /**
  20487. * Calculates the distance from a plane and a point
  20488. * @param origin origin of the plane to be constructed
  20489. * @param normal normal of the plane to be constructed
  20490. * @param point point to calculate distance to
  20491. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  20492. */
  20493. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  20494. }
  20495. /**
  20496. * Class used to represent a viewport on screen
  20497. */
  20498. class Viewport {
  20499. /** viewport left coordinate */
  20500. x: number;
  20501. /** viewport top coordinate */
  20502. y: number;
  20503. /**viewport width */
  20504. width: number;
  20505. /** viewport height */
  20506. height: number;
  20507. /**
  20508. * Creates a Viewport object located at (x, y) and sized (width, height)
  20509. * @param x defines viewport left coordinate
  20510. * @param y defines viewport top coordinate
  20511. * @param width defines the viewport width
  20512. * @param height defines the viewport height
  20513. */
  20514. constructor(
  20515. /** viewport left coordinate */
  20516. x: number,
  20517. /** viewport top coordinate */
  20518. y: number,
  20519. /**viewport width */
  20520. width: number,
  20521. /** viewport height */
  20522. height: number);
  20523. /**
  20524. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  20525. * @param renderWidthOrEngine defines either an engine or the rendering width
  20526. * @param renderHeight defines the rendering height
  20527. * @returns a new Viewport
  20528. */
  20529. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  20530. /**
  20531. * Returns a new Viewport copied from the current one
  20532. * @returns a new Viewport
  20533. */
  20534. clone(): Viewport;
  20535. }
  20536. /**
  20537. * Reprasents a camera frustum
  20538. */
  20539. class Frustum {
  20540. /**
  20541. * Gets the planes representing the frustum
  20542. * @param transform matrix to be applied to the returned planes
  20543. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  20544. */
  20545. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  20546. /**
  20547. * Gets the near frustum plane transformed by the transform matrix
  20548. * @param transform transformation matrix to be applied to the resulting frustum plane
  20549. * @param frustumPlane the resuling frustum plane
  20550. */
  20551. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20552. /**
  20553. * Gets the far frustum plane transformed by the transform matrix
  20554. * @param transform transformation matrix to be applied to the resulting frustum plane
  20555. * @param frustumPlane the resuling frustum plane
  20556. */
  20557. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20558. /**
  20559. * Gets the left frustum plane transformed by the transform matrix
  20560. * @param transform transformation matrix to be applied to the resulting frustum plane
  20561. * @param frustumPlane the resuling frustum plane
  20562. */
  20563. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20564. /**
  20565. * Gets the right frustum plane transformed by the transform matrix
  20566. * @param transform transformation matrix to be applied to the resulting frustum plane
  20567. * @param frustumPlane the resuling frustum plane
  20568. */
  20569. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20570. /**
  20571. * Gets the top frustum plane transformed by the transform matrix
  20572. * @param transform transformation matrix to be applied to the resulting frustum plane
  20573. * @param frustumPlane the resuling frustum plane
  20574. */
  20575. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20576. /**
  20577. * Gets the bottom frustum plane transformed by the transform matrix
  20578. * @param transform transformation matrix to be applied to the resulting frustum plane
  20579. * @param frustumPlane the resuling frustum plane
  20580. */
  20581. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20582. /**
  20583. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  20584. * @param transform transformation matrix to be applied to the resulting frustum planes
  20585. * @param frustumPlanes the resuling frustum planes
  20586. */
  20587. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  20588. }
  20589. /** Defines supported spaces */
  20590. enum Space {
  20591. /** Local (object) space */
  20592. LOCAL = 0,
  20593. /** World space */
  20594. WORLD = 1,
  20595. /** Bone space */
  20596. BONE = 2
  20597. }
  20598. /** Defines the 3 main axes */
  20599. class Axis {
  20600. /** X axis */
  20601. static X: Vector3;
  20602. /** Y axis */
  20603. static Y: Vector3;
  20604. /** Z axis */
  20605. static Z: Vector3;
  20606. }
  20607. /** Class used to represent a Bezier curve */
  20608. class BezierCurve {
  20609. /**
  20610. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  20611. * @param t defines the time
  20612. * @param x1 defines the left coordinate on X axis
  20613. * @param y1 defines the left coordinate on Y axis
  20614. * @param x2 defines the right coordinate on X axis
  20615. * @param y2 defines the right coordinate on Y axis
  20616. * @returns the interpolated value
  20617. */
  20618. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  20619. }
  20620. /**
  20621. * Defines potential orientation for back face culling
  20622. */
  20623. enum Orientation {
  20624. /**
  20625. * Clockwise
  20626. */
  20627. CW = 0,
  20628. /** Counter clockwise */
  20629. CCW = 1
  20630. }
  20631. /**
  20632. * Defines angle representation
  20633. */
  20634. class Angle {
  20635. private _radians;
  20636. /**
  20637. * Creates an Angle object of "radians" radians (float).
  20638. */
  20639. constructor(radians: number);
  20640. /**
  20641. * Get value in degrees
  20642. * @returns the Angle value in degrees (float)
  20643. */
  20644. degrees(): number;
  20645. /**
  20646. * Get value in radians
  20647. * @returns the Angle value in radians (float)
  20648. */
  20649. radians(): number;
  20650. /**
  20651. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  20652. * @param a defines first vector
  20653. * @param b defines second vector
  20654. * @returns a new Angle
  20655. */
  20656. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  20657. /**
  20658. * Gets a new Angle object from the given float in radians
  20659. * @param radians defines the angle value in radians
  20660. * @returns a new Angle
  20661. */
  20662. static FromRadians(radians: number): Angle;
  20663. /**
  20664. * Gets a new Angle object from the given float in degrees
  20665. * @param degrees defines the angle value in degrees
  20666. * @returns a new Angle
  20667. */
  20668. static FromDegrees(degrees: number): Angle;
  20669. }
  20670. /**
  20671. * This represents an arc in a 2d space.
  20672. */
  20673. class Arc2 {
  20674. /** Defines the start point of the arc */
  20675. startPoint: Vector2;
  20676. /** Defines the mid point of the arc */
  20677. midPoint: Vector2;
  20678. /** Defines the end point of the arc */
  20679. endPoint: Vector2;
  20680. /**
  20681. * Defines the center point of the arc.
  20682. */
  20683. centerPoint: Vector2;
  20684. /**
  20685. * Defines the radius of the arc.
  20686. */
  20687. radius: number;
  20688. /**
  20689. * Defines the angle of the arc (from mid point to end point).
  20690. */
  20691. angle: Angle;
  20692. /**
  20693. * Defines the start angle of the arc (from start point to middle point).
  20694. */
  20695. startAngle: Angle;
  20696. /**
  20697. * Defines the orientation of the arc (clock wise/counter clock wise).
  20698. */
  20699. orientation: Orientation;
  20700. /**
  20701. * Creates an Arc object from the three given points : start, middle and end.
  20702. * @param startPoint Defines the start point of the arc
  20703. * @param midPoint Defines the midlle point of the arc
  20704. * @param endPoint Defines the end point of the arc
  20705. */
  20706. constructor(
  20707. /** Defines the start point of the arc */
  20708. startPoint: Vector2,
  20709. /** Defines the mid point of the arc */
  20710. midPoint: Vector2,
  20711. /** Defines the end point of the arc */
  20712. endPoint: Vector2);
  20713. }
  20714. /**
  20715. * Represents a 2D path made up of multiple 2D points
  20716. */
  20717. class Path2 {
  20718. private _points;
  20719. private _length;
  20720. /**
  20721. * If the path start and end point are the same
  20722. */
  20723. closed: boolean;
  20724. /**
  20725. * Creates a Path2 object from the starting 2D coordinates x and y.
  20726. * @param x the starting points x value
  20727. * @param y the starting points y value
  20728. */
  20729. constructor(x: number, y: number);
  20730. /**
  20731. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  20732. * @param x the added points x value
  20733. * @param y the added points y value
  20734. * @returns the updated Path2.
  20735. */
  20736. addLineTo(x: number, y: number): Path2;
  20737. /**
  20738. * 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.
  20739. * @param midX middle point x value
  20740. * @param midY middle point y value
  20741. * @param endX end point x value
  20742. * @param endY end point y value
  20743. * @param numberOfSegments (default: 36)
  20744. * @returns the updated Path2.
  20745. */
  20746. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  20747. /**
  20748. * Closes the Path2.
  20749. * @returns the Path2.
  20750. */
  20751. close(): Path2;
  20752. /**
  20753. * Gets the sum of the distance between each sequential point in the path
  20754. * @returns the Path2 total length (float).
  20755. */
  20756. length(): number;
  20757. /**
  20758. * Gets the points which construct the path
  20759. * @returns the Path2 internal array of points.
  20760. */
  20761. getPoints(): Vector2[];
  20762. /**
  20763. * Retreives the point at the distance aways from the starting point
  20764. * @param normalizedLengthPosition the length along the path to retreive the point from
  20765. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  20766. */
  20767. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  20768. /**
  20769. * Creates a new path starting from an x and y position
  20770. * @param x starting x value
  20771. * @param y starting y value
  20772. * @returns a new Path2 starting at the coordinates (x, y).
  20773. */
  20774. static StartingAt(x: number, y: number): Path2;
  20775. }
  20776. /**
  20777. * Represents a 3D path made up of multiple 3D points
  20778. */
  20779. class Path3D {
  20780. /**
  20781. * an array of Vector3, the curve axis of the Path3D
  20782. */
  20783. path: Vector3[];
  20784. private _curve;
  20785. private _distances;
  20786. private _tangents;
  20787. private _normals;
  20788. private _binormals;
  20789. private _raw;
  20790. /**
  20791. * new Path3D(path, normal, raw)
  20792. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  20793. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  20794. * @param path an array of Vector3, the curve axis of the Path3D
  20795. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  20796. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  20797. */
  20798. constructor(
  20799. /**
  20800. * an array of Vector3, the curve axis of the Path3D
  20801. */
  20802. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  20803. /**
  20804. * Returns the Path3D array of successive Vector3 designing its curve.
  20805. * @returns the Path3D array of successive Vector3 designing its curve.
  20806. */
  20807. getCurve(): Vector3[];
  20808. /**
  20809. * Returns an array populated with tangent vectors on each Path3D curve point.
  20810. * @returns an array populated with tangent vectors on each Path3D curve point.
  20811. */
  20812. getTangents(): Vector3[];
  20813. /**
  20814. * Returns an array populated with normal vectors on each Path3D curve point.
  20815. * @returns an array populated with normal vectors on each Path3D curve point.
  20816. */
  20817. getNormals(): Vector3[];
  20818. /**
  20819. * Returns an array populated with binormal vectors on each Path3D curve point.
  20820. * @returns an array populated with binormal vectors on each Path3D curve point.
  20821. */
  20822. getBinormals(): Vector3[];
  20823. /**
  20824. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  20825. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  20826. */
  20827. getDistances(): number[];
  20828. /**
  20829. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  20830. * @param path path which all values are copied into the curves points
  20831. * @param firstNormal which should be projected onto the curve
  20832. * @returns the same object updated.
  20833. */
  20834. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  20835. private _compute;
  20836. private _getFirstNonNullVector;
  20837. private _getLastNonNullVector;
  20838. private _normalVector;
  20839. }
  20840. /**
  20841. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  20842. * A Curve3 is designed from a series of successive Vector3.
  20843. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  20844. */
  20845. class Curve3 {
  20846. private _points;
  20847. private _length;
  20848. /**
  20849. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  20850. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  20851. * @param v1 (Vector3) the control point
  20852. * @param v2 (Vector3) the end point of the Quadratic Bezier
  20853. * @param nbPoints (integer) the wanted number of points in the curve
  20854. * @returns the created Curve3
  20855. */
  20856. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  20857. /**
  20858. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  20859. * @param v0 (Vector3) the origin point of the Cubic Bezier
  20860. * @param v1 (Vector3) the first control point
  20861. * @param v2 (Vector3) the second control point
  20862. * @param v3 (Vector3) the end point of the Cubic Bezier
  20863. * @param nbPoints (integer) the wanted number of points in the curve
  20864. * @returns the created Curve3
  20865. */
  20866. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  20867. /**
  20868. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  20869. * @param p1 (Vector3) the origin point of the Hermite Spline
  20870. * @param t1 (Vector3) the tangent vector at the origin point
  20871. * @param p2 (Vector3) the end point of the Hermite Spline
  20872. * @param t2 (Vector3) the tangent vector at the end point
  20873. * @param nbPoints (integer) the wanted number of points in the curve
  20874. * @returns the created Curve3
  20875. */
  20876. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  20877. /**
  20878. * Returns a Curve3 object along a CatmullRom Spline curve :
  20879. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  20880. * @param nbPoints (integer) the wanted number of points between each curve control points
  20881. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  20882. * @returns the created Curve3
  20883. */
  20884. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  20885. /**
  20886. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  20887. * A Curve3 is designed from a series of successive Vector3.
  20888. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  20889. * @param points points which make up the curve
  20890. */
  20891. constructor(points: Vector3[]);
  20892. /**
  20893. * @returns the Curve3 stored array of successive Vector3
  20894. */
  20895. getPoints(): Vector3[];
  20896. /**
  20897. * @returns the computed length (float) of the curve.
  20898. */
  20899. length(): number;
  20900. /**
  20901. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  20902. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  20903. * curveA and curveB keep unchanged.
  20904. * @param curve the curve to continue from this curve
  20905. * @returns the newly constructed curve
  20906. */
  20907. continue(curve: DeepImmutable<Curve3>): Curve3;
  20908. private _computeLength;
  20909. }
  20910. /**
  20911. * Contains position and normal vectors for a vertex
  20912. */
  20913. class PositionNormalVertex {
  20914. /** the position of the vertex (defaut: 0,0,0) */
  20915. position: Vector3;
  20916. /** the normal of the vertex (defaut: 0,1,0) */
  20917. normal: Vector3;
  20918. /**
  20919. * Creates a PositionNormalVertex
  20920. * @param position the position of the vertex (defaut: 0,0,0)
  20921. * @param normal the normal of the vertex (defaut: 0,1,0)
  20922. */
  20923. constructor(
  20924. /** the position of the vertex (defaut: 0,0,0) */
  20925. position?: Vector3,
  20926. /** the normal of the vertex (defaut: 0,1,0) */
  20927. normal?: Vector3);
  20928. /**
  20929. * Clones the PositionNormalVertex
  20930. * @returns the cloned PositionNormalVertex
  20931. */
  20932. clone(): PositionNormalVertex;
  20933. }
  20934. /**
  20935. * Contains position, normal and uv vectors for a vertex
  20936. */
  20937. class PositionNormalTextureVertex {
  20938. /** the position of the vertex (defaut: 0,0,0) */
  20939. position: Vector3;
  20940. /** the normal of the vertex (defaut: 0,1,0) */
  20941. normal: Vector3;
  20942. /** the uv of the vertex (default: 0,0) */
  20943. uv: Vector2;
  20944. /**
  20945. * Creates a PositionNormalTextureVertex
  20946. * @param position the position of the vertex (defaut: 0,0,0)
  20947. * @param normal the normal of the vertex (defaut: 0,1,0)
  20948. * @param uv the uv of the vertex (default: 0,0)
  20949. */
  20950. constructor(
  20951. /** the position of the vertex (defaut: 0,0,0) */
  20952. position?: Vector3,
  20953. /** the normal of the vertex (defaut: 0,1,0) */
  20954. normal?: Vector3,
  20955. /** the uv of the vertex (default: 0,0) */
  20956. uv?: Vector2);
  20957. /**
  20958. * Clones the PositionNormalTextureVertex
  20959. * @returns the cloned PositionNormalTextureVertex
  20960. */
  20961. clone(): PositionNormalTextureVertex;
  20962. }
  20963. /**
  20964. * @hidden
  20965. */
  20966. class Tmp {
  20967. static Color3: Color3[];
  20968. static Color4: Color4[];
  20969. static Vector2: Vector2[];
  20970. static Vector3: Vector3[];
  20971. static Vector4: Vector4[];
  20972. static Quaternion: Quaternion[];
  20973. static Matrix: Matrix[];
  20974. }
  20975. }
  20976. declare module BABYLON {
  20977. /**
  20978. * Class representing spherical polynomial coefficients to the 3rd degree
  20979. */
  20980. class SphericalPolynomial {
  20981. /**
  20982. * The x coefficients of the spherical polynomial
  20983. */
  20984. x: Vector3;
  20985. /**
  20986. * The y coefficients of the spherical polynomial
  20987. */
  20988. y: Vector3;
  20989. /**
  20990. * The z coefficients of the spherical polynomial
  20991. */
  20992. z: Vector3;
  20993. /**
  20994. * The xx coefficients of the spherical polynomial
  20995. */
  20996. xx: Vector3;
  20997. /**
  20998. * The yy coefficients of the spherical polynomial
  20999. */
  21000. yy: Vector3;
  21001. /**
  21002. * The zz coefficients of the spherical polynomial
  21003. */
  21004. zz: Vector3;
  21005. /**
  21006. * The xy coefficients of the spherical polynomial
  21007. */
  21008. xy: Vector3;
  21009. /**
  21010. * The yz coefficients of the spherical polynomial
  21011. */
  21012. yz: Vector3;
  21013. /**
  21014. * The zx coefficients of the spherical polynomial
  21015. */
  21016. zx: Vector3;
  21017. /**
  21018. * Adds an ambient color to the spherical polynomial
  21019. * @param color the color to add
  21020. */
  21021. addAmbient(color: Color3): void;
  21022. /**
  21023. * Scales the spherical polynomial by the given amount
  21024. * @param scale the amount to scale
  21025. */
  21026. scale(scale: number): void;
  21027. /**
  21028. * Gets the spherical polynomial from harmonics
  21029. * @param harmonics the spherical harmonics
  21030. * @returns the spherical polynomial
  21031. */
  21032. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21033. /**
  21034. * Constructs a spherical polynomial from an array.
  21035. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21036. * @returns the spherical polynomial
  21037. */
  21038. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21039. }
  21040. /**
  21041. * Class representing spherical harmonics coefficients to the 3rd degree
  21042. */
  21043. class SphericalHarmonics {
  21044. /**
  21045. * The l0,0 coefficients of the spherical harmonics
  21046. */
  21047. l00: Vector3;
  21048. /**
  21049. * The l1,-1 coefficients of the spherical harmonics
  21050. */
  21051. l1_1: Vector3;
  21052. /**
  21053. * The l1,0 coefficients of the spherical harmonics
  21054. */
  21055. l10: Vector3;
  21056. /**
  21057. * The l1,1 coefficients of the spherical harmonics
  21058. */
  21059. l11: Vector3;
  21060. /**
  21061. * The l2,-2 coefficients of the spherical harmonics
  21062. */
  21063. l2_2: Vector3;
  21064. /**
  21065. * The l2,-1 coefficients of the spherical harmonics
  21066. */
  21067. l2_1: Vector3;
  21068. /**
  21069. * The l2,0 coefficients of the spherical harmonics
  21070. */
  21071. l20: Vector3;
  21072. /**
  21073. * The l2,1 coefficients of the spherical harmonics
  21074. */
  21075. l21: Vector3;
  21076. /**
  21077. * The l2,2 coefficients of the spherical harmonics
  21078. */
  21079. lL22: Vector3;
  21080. /**
  21081. * Adds a light to the spherical harmonics
  21082. * @param direction the direction of the light
  21083. * @param color the color of the light
  21084. * @param deltaSolidAngle the delta solid angle of the light
  21085. */
  21086. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21087. /**
  21088. * Scales the spherical harmonics by the given amount
  21089. * @param scale the amount to scale
  21090. */
  21091. scale(scale: number): void;
  21092. /**
  21093. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21094. *
  21095. * ```
  21096. * E_lm = A_l * L_lm
  21097. * ```
  21098. *
  21099. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21100. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21101. * the scaling factors are given in equation 9.
  21102. */
  21103. convertIncidentRadianceToIrradiance(): void;
  21104. /**
  21105. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21106. *
  21107. * ```
  21108. * L = (1/pi) * E * rho
  21109. * ```
  21110. *
  21111. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21112. */
  21113. convertIrradianceToLambertianRadiance(): void;
  21114. /**
  21115. * Gets the spherical harmonics from polynomial
  21116. * @param polynomial the spherical polynomial
  21117. * @returns the spherical harmonics
  21118. */
  21119. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21120. /**
  21121. * Constructs a spherical harmonics from an array.
  21122. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21123. * @returns the spherical harmonics
  21124. */
  21125. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21126. }
  21127. }
  21128. declare module BABYLON {
  21129. /**
  21130. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21131. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21132. * 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;
  21133. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21134. */
  21135. class ColorCurves {
  21136. private _dirty;
  21137. private _tempColor;
  21138. private _globalCurve;
  21139. private _highlightsCurve;
  21140. private _midtonesCurve;
  21141. private _shadowsCurve;
  21142. private _positiveCurve;
  21143. private _negativeCurve;
  21144. private _globalHue;
  21145. private _globalDensity;
  21146. private _globalSaturation;
  21147. private _globalExposure;
  21148. /**
  21149. * Gets the global Hue value.
  21150. * 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).
  21151. */
  21152. /**
  21153. * Sets the global Hue value.
  21154. * 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).
  21155. */
  21156. globalHue: number;
  21157. /**
  21158. * Gets the global Density value.
  21159. * 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.
  21160. * Values less than zero provide a filter of opposite hue.
  21161. */
  21162. /**
  21163. * Sets the global Density value.
  21164. * 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.
  21165. * Values less than zero provide a filter of opposite hue.
  21166. */
  21167. globalDensity: number;
  21168. /**
  21169. * Gets the global Saturation value.
  21170. * 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.
  21171. */
  21172. /**
  21173. * Sets the global Saturation value.
  21174. * 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.
  21175. */
  21176. globalSaturation: number;
  21177. /**
  21178. * Gets the global Exposure value.
  21179. * 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.
  21180. */
  21181. /**
  21182. * Sets the global Exposure value.
  21183. * 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.
  21184. */
  21185. globalExposure: number;
  21186. private _highlightsHue;
  21187. private _highlightsDensity;
  21188. private _highlightsSaturation;
  21189. private _highlightsExposure;
  21190. /**
  21191. * Gets the highlights Hue value.
  21192. * 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).
  21193. */
  21194. /**
  21195. * Sets the highlights Hue value.
  21196. * 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).
  21197. */
  21198. highlightsHue: number;
  21199. /**
  21200. * Gets the highlights Density value.
  21201. * 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.
  21202. * Values less than zero provide a filter of opposite hue.
  21203. */
  21204. /**
  21205. * Sets the highlights Density value.
  21206. * 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.
  21207. * Values less than zero provide a filter of opposite hue.
  21208. */
  21209. highlightsDensity: number;
  21210. /**
  21211. * Gets the highlights Saturation value.
  21212. * 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.
  21213. */
  21214. /**
  21215. * Sets the highlights Saturation value.
  21216. * 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.
  21217. */
  21218. highlightsSaturation: number;
  21219. /**
  21220. * Gets the highlights Exposure value.
  21221. * 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.
  21222. */
  21223. /**
  21224. * Sets the highlights Exposure value.
  21225. * 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.
  21226. */
  21227. highlightsExposure: number;
  21228. private _midtonesHue;
  21229. private _midtonesDensity;
  21230. private _midtonesSaturation;
  21231. private _midtonesExposure;
  21232. /**
  21233. * Gets the midtones Hue value.
  21234. * 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).
  21235. */
  21236. /**
  21237. * Sets the midtones Hue value.
  21238. * 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).
  21239. */
  21240. midtonesHue: number;
  21241. /**
  21242. * Gets the midtones Density value.
  21243. * 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.
  21244. * Values less than zero provide a filter of opposite hue.
  21245. */
  21246. /**
  21247. * Sets the midtones Density value.
  21248. * 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.
  21249. * Values less than zero provide a filter of opposite hue.
  21250. */
  21251. midtonesDensity: number;
  21252. /**
  21253. * Gets the midtones Saturation value.
  21254. * 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.
  21255. */
  21256. /**
  21257. * Sets the midtones Saturation value.
  21258. * 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.
  21259. */
  21260. midtonesSaturation: number;
  21261. /**
  21262. * Gets the midtones Exposure value.
  21263. * 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.
  21264. */
  21265. /**
  21266. * Sets the midtones Exposure value.
  21267. * 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.
  21268. */
  21269. midtonesExposure: number;
  21270. private _shadowsHue;
  21271. private _shadowsDensity;
  21272. private _shadowsSaturation;
  21273. private _shadowsExposure;
  21274. /**
  21275. * Gets the shadows Hue value.
  21276. * 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).
  21277. */
  21278. /**
  21279. * Sets the shadows Hue value.
  21280. * 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).
  21281. */
  21282. shadowsHue: number;
  21283. /**
  21284. * Gets the shadows Density value.
  21285. * 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.
  21286. * Values less than zero provide a filter of opposite hue.
  21287. */
  21288. /**
  21289. * Sets the shadows Density value.
  21290. * 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.
  21291. * Values less than zero provide a filter of opposite hue.
  21292. */
  21293. shadowsDensity: number;
  21294. /**
  21295. * Gets the shadows Saturation value.
  21296. * 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.
  21297. */
  21298. /**
  21299. * Sets the shadows Saturation value.
  21300. * 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.
  21301. */
  21302. shadowsSaturation: number;
  21303. /**
  21304. * Gets the shadows Exposure value.
  21305. * 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.
  21306. */
  21307. /**
  21308. * Sets the shadows Exposure value.
  21309. * 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.
  21310. */
  21311. shadowsExposure: number;
  21312. /**
  21313. * Returns the class name
  21314. * @returns The class name
  21315. */
  21316. getClassName(): string;
  21317. /**
  21318. * Binds the color curves to the shader.
  21319. * @param colorCurves The color curve to bind
  21320. * @param effect The effect to bind to
  21321. * @param positiveUniform The positive uniform shader parameter
  21322. * @param neutralUniform The neutral uniform shader parameter
  21323. * @param negativeUniform The negative uniform shader parameter
  21324. */
  21325. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  21326. /**
  21327. * Prepare the list of uniforms associated with the ColorCurves effects.
  21328. * @param uniformsList The list of uniforms used in the effect
  21329. */
  21330. static PrepareUniforms(uniformsList: string[]): void;
  21331. /**
  21332. * Returns color grading data based on a hue, density, saturation and exposure value.
  21333. * @param filterHue The hue of the color filter.
  21334. * @param filterDensity The density of the color filter.
  21335. * @param saturation The saturation.
  21336. * @param exposure The exposure.
  21337. * @param result The result data container.
  21338. */
  21339. private getColorGradingDataToRef;
  21340. /**
  21341. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  21342. * @param value The input slider value in range [-100,100].
  21343. * @returns Adjusted value.
  21344. */
  21345. private static applyColorGradingSliderNonlinear;
  21346. /**
  21347. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  21348. * @param hue The hue (H) input.
  21349. * @param saturation The saturation (S) input.
  21350. * @param brightness The brightness (B) input.
  21351. * @result An RGBA color represented as Vector4.
  21352. */
  21353. private static fromHSBToRef;
  21354. /**
  21355. * Returns a value clamped between min and max
  21356. * @param value The value to clamp
  21357. * @param min The minimum of value
  21358. * @param max The maximum of value
  21359. * @returns The clamped value.
  21360. */
  21361. private static clamp;
  21362. /**
  21363. * Clones the current color curve instance.
  21364. * @return The cloned curves
  21365. */
  21366. clone(): ColorCurves;
  21367. /**
  21368. * Serializes the current color curve instance to a json representation.
  21369. * @return a JSON representation
  21370. */
  21371. serialize(): any;
  21372. /**
  21373. * Parses the color curve from a json representation.
  21374. * @param source the JSON source to parse
  21375. * @return The parsed curves
  21376. */
  21377. static Parse(source: any): ColorCurves;
  21378. }
  21379. }
  21380. declare module BABYLON {
  21381. /**
  21382. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  21383. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  21384. */
  21385. class EffectFallbacks {
  21386. private _defines;
  21387. private _currentRank;
  21388. private _maxRank;
  21389. private _mesh;
  21390. /**
  21391. * Removes the fallback from the bound mesh.
  21392. */
  21393. unBindMesh(): void;
  21394. /**
  21395. * Adds a fallback on the specified property.
  21396. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  21397. * @param define The name of the define in the shader
  21398. */
  21399. addFallback(rank: number, define: string): void;
  21400. /**
  21401. * Sets the mesh to use CPU skinning when needing to fallback.
  21402. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  21403. * @param mesh The mesh to use the fallbacks.
  21404. */
  21405. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  21406. /**
  21407. * Checks to see if more fallbacks are still availible.
  21408. */
  21409. readonly isMoreFallbacks: boolean;
  21410. /**
  21411. * Removes the defines that shoould be removed when falling back.
  21412. * @param currentDefines defines the current define statements for the shader.
  21413. * @param effect defines the current effect we try to compile
  21414. * @returns The resulting defines with defines of the current rank removed.
  21415. */
  21416. reduce(currentDefines: string, effect: Effect): string;
  21417. }
  21418. /**
  21419. * Options to be used when creating an effect.
  21420. */
  21421. class EffectCreationOptions {
  21422. /**
  21423. * Atrributes that will be used in the shader.
  21424. */
  21425. attributes: string[];
  21426. /**
  21427. * Uniform varible names that will be set in the shader.
  21428. */
  21429. uniformsNames: string[];
  21430. /**
  21431. * Uniform buffer varible names that will be set in the shader.
  21432. */
  21433. uniformBuffersNames: string[];
  21434. /**
  21435. * Sampler texture variable names that will be set in the shader.
  21436. */
  21437. samplers: string[];
  21438. /**
  21439. * Define statements that will be set in the shader.
  21440. */
  21441. defines: any;
  21442. /**
  21443. * Possible fallbacks for this effect to improve performance when needed.
  21444. */
  21445. fallbacks: Nullable<EffectFallbacks>;
  21446. /**
  21447. * Callback that will be called when the shader is compiled.
  21448. */
  21449. onCompiled: Nullable<(effect: Effect) => void>;
  21450. /**
  21451. * Callback that will be called if an error occurs during shader compilation.
  21452. */
  21453. onError: Nullable<(effect: Effect, errors: string) => void>;
  21454. /**
  21455. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  21456. */
  21457. indexParameters: any;
  21458. /**
  21459. * Max number of lights that can be used in the shader.
  21460. */
  21461. maxSimultaneousLights: number;
  21462. /**
  21463. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  21464. */
  21465. transformFeedbackVaryings: Nullable<string[]>;
  21466. }
  21467. /**
  21468. * Effect containing vertex and fragment shader that can be executed on an object.
  21469. */
  21470. class Effect {
  21471. /**
  21472. * Name of the effect.
  21473. */
  21474. name: any;
  21475. /**
  21476. * String container all the define statements that should be set on the shader.
  21477. */
  21478. defines: string;
  21479. /**
  21480. * Callback that will be called when the shader is compiled.
  21481. */
  21482. onCompiled: Nullable<(effect: Effect) => void>;
  21483. /**
  21484. * Callback that will be called if an error occurs during shader compilation.
  21485. */
  21486. onError: Nullable<(effect: Effect, errors: string) => void>;
  21487. /**
  21488. * Callback that will be called when effect is bound.
  21489. */
  21490. onBind: Nullable<(effect: Effect) => void>;
  21491. /**
  21492. * Unique ID of the effect.
  21493. */
  21494. uniqueId: number;
  21495. /**
  21496. * Observable that will be called when the shader is compiled.
  21497. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  21498. */
  21499. onCompileObservable: Observable<Effect>;
  21500. /**
  21501. * Observable that will be called if an error occurs during shader compilation.
  21502. */
  21503. onErrorObservable: Observable<Effect>;
  21504. /** @hidden */
  21505. _onBindObservable: Nullable<Observable<Effect>>;
  21506. /**
  21507. * Observable that will be called when effect is bound.
  21508. */
  21509. readonly onBindObservable: Observable<Effect>;
  21510. /** @hidden */
  21511. _bonesComputationForcedToCPU: boolean;
  21512. private static _uniqueIdSeed;
  21513. private _engine;
  21514. private _uniformBuffersNames;
  21515. private _uniformsNames;
  21516. private _samplers;
  21517. private _isReady;
  21518. private _compilationError;
  21519. private _attributesNames;
  21520. private _attributes;
  21521. private _uniforms;
  21522. /**
  21523. * Key for the effect.
  21524. * @hidden
  21525. */
  21526. _key: string;
  21527. private _indexParameters;
  21528. private _fallbacks;
  21529. private _vertexSourceCode;
  21530. private _fragmentSourceCode;
  21531. private _vertexSourceCodeOverride;
  21532. private _fragmentSourceCodeOverride;
  21533. private _transformFeedbackVaryings;
  21534. /**
  21535. * Compiled shader to webGL program.
  21536. * @hidden
  21537. */
  21538. _program: WebGLProgram;
  21539. private _valueCache;
  21540. private static _baseCache;
  21541. /**
  21542. * Instantiates an effect.
  21543. * An effect can be used to create/manage/execute vertex and fragment shaders.
  21544. * @param baseName Name of the effect.
  21545. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  21546. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  21547. * @param samplers List of sampler variables that will be passed to the shader.
  21548. * @param engine Engine to be used to render the effect
  21549. * @param defines Define statements to be added to the shader.
  21550. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  21551. * @param onCompiled Callback that will be called when the shader is compiled.
  21552. * @param onError Callback that will be called if an error occurs during shader compilation.
  21553. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  21554. */
  21555. 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);
  21556. /**
  21557. * Unique key for this effect
  21558. */
  21559. readonly key: string;
  21560. /**
  21561. * If the effect has been compiled and prepared.
  21562. * @returns if the effect is compiled and prepared.
  21563. */
  21564. isReady(): boolean;
  21565. /**
  21566. * The engine the effect was initialized with.
  21567. * @returns the engine.
  21568. */
  21569. getEngine(): Engine;
  21570. /**
  21571. * The compiled webGL program for the effect
  21572. * @returns the webGL program.
  21573. */
  21574. getProgram(): WebGLProgram;
  21575. /**
  21576. * The set of names of attribute variables for the shader.
  21577. * @returns An array of attribute names.
  21578. */
  21579. getAttributesNames(): string[];
  21580. /**
  21581. * Returns the attribute at the given index.
  21582. * @param index The index of the attribute.
  21583. * @returns The location of the attribute.
  21584. */
  21585. getAttributeLocation(index: number): number;
  21586. /**
  21587. * Returns the attribute based on the name of the variable.
  21588. * @param name of the attribute to look up.
  21589. * @returns the attribute location.
  21590. */
  21591. getAttributeLocationByName(name: string): number;
  21592. /**
  21593. * The number of attributes.
  21594. * @returns the numnber of attributes.
  21595. */
  21596. getAttributesCount(): number;
  21597. /**
  21598. * Gets the index of a uniform variable.
  21599. * @param uniformName of the uniform to look up.
  21600. * @returns the index.
  21601. */
  21602. getUniformIndex(uniformName: string): number;
  21603. /**
  21604. * Returns the attribute based on the name of the variable.
  21605. * @param uniformName of the uniform to look up.
  21606. * @returns the location of the uniform.
  21607. */
  21608. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  21609. /**
  21610. * Returns an array of sampler variable names
  21611. * @returns The array of sampler variable neames.
  21612. */
  21613. getSamplers(): string[];
  21614. /**
  21615. * The error from the last compilation.
  21616. * @returns the error string.
  21617. */
  21618. getCompilationError(): string;
  21619. /**
  21620. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  21621. * @param func The callback to be used.
  21622. */
  21623. executeWhenCompiled(func: (effect: Effect) => void): void;
  21624. private _checkIsReady;
  21625. /** @hidden */
  21626. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  21627. /** @hidden */
  21628. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  21629. /** @hidden */
  21630. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  21631. private _processShaderConversion;
  21632. private _processIncludes;
  21633. private _processPrecision;
  21634. /**
  21635. * Recompiles the webGL program
  21636. * @param vertexSourceCode The source code for the vertex shader.
  21637. * @param fragmentSourceCode The source code for the fragment shader.
  21638. * @param onCompiled Callback called when completed.
  21639. * @param onError Callback called on error.
  21640. * @hidden
  21641. */
  21642. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  21643. /**
  21644. * Gets the uniform locations of the the specified variable names
  21645. * @param names THe names of the variables to lookup.
  21646. * @returns Array of locations in the same order as variable names.
  21647. */
  21648. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  21649. /**
  21650. * Prepares the effect
  21651. * @hidden
  21652. */
  21653. _prepareEffect(): void;
  21654. /**
  21655. * Checks if the effect is supported. (Must be called after compilation)
  21656. */
  21657. readonly isSupported: boolean;
  21658. /**
  21659. * Binds a texture to the engine to be used as output of the shader.
  21660. * @param channel Name of the output variable.
  21661. * @param texture Texture to bind.
  21662. * @hidden
  21663. */
  21664. _bindTexture(channel: string, texture: InternalTexture): void;
  21665. /**
  21666. * Sets a texture on the engine to be used in the shader.
  21667. * @param channel Name of the sampler variable.
  21668. * @param texture Texture to set.
  21669. */
  21670. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  21671. /**
  21672. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  21673. * @param channel Name of the sampler variable.
  21674. * @param texture Texture to set.
  21675. */
  21676. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  21677. /**
  21678. * Sets an array of textures on the engine to be used in the shader.
  21679. * @param channel Name of the variable.
  21680. * @param textures Textures to set.
  21681. */
  21682. setTextureArray(channel: string, textures: BaseTexture[]): void;
  21683. /**
  21684. * 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)
  21685. * @param channel Name of the sampler variable.
  21686. * @param postProcess Post process to get the input texture from.
  21687. */
  21688. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  21689. /**
  21690. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  21691. * 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)
  21692. * @param channel Name of the sampler variable.
  21693. * @param postProcess Post process to get the output texture from.
  21694. */
  21695. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  21696. /** @hidden */
  21697. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  21698. /** @hidden */
  21699. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  21700. /** @hidden */
  21701. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  21702. /** @hidden */
  21703. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  21704. /**
  21705. * Binds a buffer to a uniform.
  21706. * @param buffer Buffer to bind.
  21707. * @param name Name of the uniform variable to bind to.
  21708. */
  21709. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  21710. /**
  21711. * Binds block to a uniform.
  21712. * @param blockName Name of the block to bind.
  21713. * @param index Index to bind.
  21714. */
  21715. bindUniformBlock(blockName: string, index: number): void;
  21716. /**
  21717. * Sets an interger value on a uniform variable.
  21718. * @param uniformName Name of the variable.
  21719. * @param value Value to be set.
  21720. * @returns this effect.
  21721. */
  21722. setInt(uniformName: string, value: number): Effect;
  21723. /**
  21724. * Sets an int array on a uniform variable.
  21725. * @param uniformName Name of the variable.
  21726. * @param array array to be set.
  21727. * @returns this effect.
  21728. */
  21729. setIntArray(uniformName: string, array: Int32Array): Effect;
  21730. /**
  21731. * 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)
  21732. * @param uniformName Name of the variable.
  21733. * @param array array to be set.
  21734. * @returns this effect.
  21735. */
  21736. setIntArray2(uniformName: string, array: Int32Array): Effect;
  21737. /**
  21738. * 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)
  21739. * @param uniformName Name of the variable.
  21740. * @param array array to be set.
  21741. * @returns this effect.
  21742. */
  21743. setIntArray3(uniformName: string, array: Int32Array): Effect;
  21744. /**
  21745. * 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)
  21746. * @param uniformName Name of the variable.
  21747. * @param array array to be set.
  21748. * @returns this effect.
  21749. */
  21750. setIntArray4(uniformName: string, array: Int32Array): Effect;
  21751. /**
  21752. * Sets an float array on a uniform variable.
  21753. * @param uniformName Name of the variable.
  21754. * @param array array to be set.
  21755. * @returns this effect.
  21756. */
  21757. setFloatArray(uniformName: string, array: Float32Array): Effect;
  21758. /**
  21759. * 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)
  21760. * @param uniformName Name of the variable.
  21761. * @param array array to be set.
  21762. * @returns this effect.
  21763. */
  21764. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  21765. /**
  21766. * 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)
  21767. * @param uniformName Name of the variable.
  21768. * @param array array to be set.
  21769. * @returns this effect.
  21770. */
  21771. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  21772. /**
  21773. * 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)
  21774. * @param uniformName Name of the variable.
  21775. * @param array array to be set.
  21776. * @returns this effect.
  21777. */
  21778. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  21779. /**
  21780. * Sets an array on a uniform variable.
  21781. * @param uniformName Name of the variable.
  21782. * @param array array to be set.
  21783. * @returns this effect.
  21784. */
  21785. setArray(uniformName: string, array: number[]): Effect;
  21786. /**
  21787. * 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)
  21788. * @param uniformName Name of the variable.
  21789. * @param array array to be set.
  21790. * @returns this effect.
  21791. */
  21792. setArray2(uniformName: string, array: number[]): Effect;
  21793. /**
  21794. * 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)
  21795. * @param uniformName Name of the variable.
  21796. * @param array array to be set.
  21797. * @returns this effect.
  21798. */
  21799. setArray3(uniformName: string, array: number[]): Effect;
  21800. /**
  21801. * 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)
  21802. * @param uniformName Name of the variable.
  21803. * @param array array to be set.
  21804. * @returns this effect.
  21805. */
  21806. setArray4(uniformName: string, array: number[]): Effect;
  21807. /**
  21808. * Sets matrices on a uniform variable.
  21809. * @param uniformName Name of the variable.
  21810. * @param matrices matrices to be set.
  21811. * @returns this effect.
  21812. */
  21813. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  21814. /**
  21815. * Sets matrix on a uniform variable.
  21816. * @param uniformName Name of the variable.
  21817. * @param matrix matrix to be set.
  21818. * @returns this effect.
  21819. */
  21820. setMatrix(uniformName: string, matrix: Matrix): Effect;
  21821. /**
  21822. * 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)
  21823. * @param uniformName Name of the variable.
  21824. * @param matrix matrix to be set.
  21825. * @returns this effect.
  21826. */
  21827. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  21828. /**
  21829. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  21830. * @param uniformName Name of the variable.
  21831. * @param matrix matrix to be set.
  21832. * @returns this effect.
  21833. */
  21834. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  21835. /**
  21836. * Sets a float on a uniform variable.
  21837. * @param uniformName Name of the variable.
  21838. * @param value value to be set.
  21839. * @returns this effect.
  21840. */
  21841. setFloat(uniformName: string, value: number): Effect;
  21842. /**
  21843. * Sets a boolean on a uniform variable.
  21844. * @param uniformName Name of the variable.
  21845. * @param bool value to be set.
  21846. * @returns this effect.
  21847. */
  21848. setBool(uniformName: string, bool: boolean): Effect;
  21849. /**
  21850. * Sets a Vector2 on a uniform variable.
  21851. * @param uniformName Name of the variable.
  21852. * @param vector2 vector2 to be set.
  21853. * @returns this effect.
  21854. */
  21855. setVector2(uniformName: string, vector2: Vector2): Effect;
  21856. /**
  21857. * Sets a float2 on a uniform variable.
  21858. * @param uniformName Name of the variable.
  21859. * @param x First float in float2.
  21860. * @param y Second float in float2.
  21861. * @returns this effect.
  21862. */
  21863. setFloat2(uniformName: string, x: number, y: number): Effect;
  21864. /**
  21865. * Sets a Vector3 on a uniform variable.
  21866. * @param uniformName Name of the variable.
  21867. * @param vector3 Value to be set.
  21868. * @returns this effect.
  21869. */
  21870. setVector3(uniformName: string, vector3: Vector3): Effect;
  21871. /**
  21872. * Sets a float3 on a uniform variable.
  21873. * @param uniformName Name of the variable.
  21874. * @param x First float in float3.
  21875. * @param y Second float in float3.
  21876. * @param z Third float in float3.
  21877. * @returns this effect.
  21878. */
  21879. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  21880. /**
  21881. * Sets a Vector4 on a uniform variable.
  21882. * @param uniformName Name of the variable.
  21883. * @param vector4 Value to be set.
  21884. * @returns this effect.
  21885. */
  21886. setVector4(uniformName: string, vector4: Vector4): Effect;
  21887. /**
  21888. * Sets a float4 on a uniform variable.
  21889. * @param uniformName Name of the variable.
  21890. * @param x First float in float4.
  21891. * @param y Second float in float4.
  21892. * @param z Third float in float4.
  21893. * @param w Fourth float in float4.
  21894. * @returns this effect.
  21895. */
  21896. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  21897. /**
  21898. * Sets a Color3 on a uniform variable.
  21899. * @param uniformName Name of the variable.
  21900. * @param color3 Value to be set.
  21901. * @returns this effect.
  21902. */
  21903. setColor3(uniformName: string, color3: Color3): Effect;
  21904. /**
  21905. * Sets a Color4 on a uniform variable.
  21906. * @param uniformName Name of the variable.
  21907. * @param color3 Value to be set.
  21908. * @param alpha Alpha value to be set.
  21909. * @returns this effect.
  21910. */
  21911. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  21912. /**
  21913. * Sets a Color4 on a uniform variable
  21914. * @param uniformName defines the name of the variable
  21915. * @param color4 defines the value to be set
  21916. * @returns this effect.
  21917. */
  21918. setDirectColor4(uniformName: string, color4: Color4): Effect;
  21919. /**
  21920. * This function will add a new shader to the shader store
  21921. * @param name the name of the shader
  21922. * @param pixelShader optional pixel shader content
  21923. * @param vertexShader optional vertex shader content
  21924. */
  21925. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  21926. /**
  21927. * Store of each shader (The can be looked up using effect.key)
  21928. */
  21929. static ShadersStore: {
  21930. [key: string]: string;
  21931. };
  21932. /**
  21933. * Store of each included file for a shader (The can be looked up using effect.key)
  21934. */
  21935. static IncludesShadersStore: {
  21936. [key: string]: string;
  21937. };
  21938. /**
  21939. * Resets the cache of effects.
  21940. */
  21941. static ResetCache(): void;
  21942. }
  21943. }
  21944. declare module BABYLON {
  21945. /**
  21946. * This represents all the required information to add a fresnel effect on a material:
  21947. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  21948. */
  21949. class FresnelParameters {
  21950. private _isEnabled;
  21951. /**
  21952. * Define if the fresnel effect is enable or not.
  21953. */
  21954. isEnabled: boolean;
  21955. /**
  21956. * Define the color used on edges (grazing angle)
  21957. */
  21958. leftColor: Color3;
  21959. /**
  21960. * Define the color used on center
  21961. */
  21962. rightColor: Color3;
  21963. /**
  21964. * Define bias applied to computed fresnel term
  21965. */
  21966. bias: number;
  21967. /**
  21968. * Defined the power exponent applied to fresnel term
  21969. */
  21970. power: number;
  21971. /**
  21972. * Clones the current fresnel and its valuues
  21973. * @returns a clone fresnel configuration
  21974. */
  21975. clone(): FresnelParameters;
  21976. /**
  21977. * Serializes the current fresnel parameters to a JSON representation.
  21978. * @return the JSON serialization
  21979. */
  21980. serialize(): any;
  21981. /**
  21982. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  21983. * @param parsedFresnelParameters Define the JSON representation
  21984. * @returns the parsed parameters
  21985. */
  21986. static Parse(parsedFresnelParameters: any): FresnelParameters;
  21987. }
  21988. }
  21989. declare module BABYLON {
  21990. /**
  21991. * Interface to follow in your material defines to integrate easily the
  21992. * Image proccessing functions.
  21993. * @hidden
  21994. */
  21995. interface IImageProcessingConfigurationDefines {
  21996. IMAGEPROCESSING: boolean;
  21997. VIGNETTE: boolean;
  21998. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21999. VIGNETTEBLENDMODEOPAQUE: boolean;
  22000. TONEMAPPING: boolean;
  22001. TONEMAPPING_ACES: boolean;
  22002. CONTRAST: boolean;
  22003. EXPOSURE: boolean;
  22004. COLORCURVES: boolean;
  22005. COLORGRADING: boolean;
  22006. COLORGRADING3D: boolean;
  22007. SAMPLER3DGREENDEPTH: boolean;
  22008. SAMPLER3DBGRMAP: boolean;
  22009. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22010. }
  22011. /**
  22012. * @hidden
  22013. */
  22014. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22015. IMAGEPROCESSING: boolean;
  22016. VIGNETTE: boolean;
  22017. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22018. VIGNETTEBLENDMODEOPAQUE: boolean;
  22019. TONEMAPPING: boolean;
  22020. TONEMAPPING_ACES: boolean;
  22021. CONTRAST: boolean;
  22022. COLORCURVES: boolean;
  22023. COLORGRADING: boolean;
  22024. COLORGRADING3D: boolean;
  22025. SAMPLER3DGREENDEPTH: boolean;
  22026. SAMPLER3DBGRMAP: boolean;
  22027. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22028. EXPOSURE: boolean;
  22029. constructor();
  22030. }
  22031. /**
  22032. * This groups together the common properties used for image processing either in direct forward pass
  22033. * or through post processing effect depending on the use of the image processing pipeline in your scene
  22034. * or not.
  22035. */
  22036. class ImageProcessingConfiguration {
  22037. /**
  22038. * Default tone mapping applied in BabylonJS.
  22039. */
  22040. static readonly TONEMAPPING_STANDARD: number;
  22041. /**
  22042. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  22043. * to other engines rendering to increase portability.
  22044. */
  22045. static readonly TONEMAPPING_ACES: number;
  22046. /**
  22047. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  22048. */
  22049. colorCurves: Nullable<ColorCurves>;
  22050. private _colorCurvesEnabled;
  22051. /**
  22052. * Gets wether the color curves effect is enabled.
  22053. */
  22054. /**
  22055. * Sets wether the color curves effect is enabled.
  22056. */
  22057. colorCurvesEnabled: boolean;
  22058. private _colorGradingTexture;
  22059. /**
  22060. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  22061. */
  22062. /**
  22063. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  22064. */
  22065. colorGradingTexture: Nullable<BaseTexture>;
  22066. private _colorGradingEnabled;
  22067. /**
  22068. * Gets wether the color grading effect is enabled.
  22069. */
  22070. /**
  22071. * Sets wether the color grading effect is enabled.
  22072. */
  22073. colorGradingEnabled: boolean;
  22074. private _colorGradingWithGreenDepth;
  22075. /**
  22076. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  22077. */
  22078. /**
  22079. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  22080. */
  22081. colorGradingWithGreenDepth: boolean;
  22082. private _colorGradingBGR;
  22083. /**
  22084. * Gets wether the color grading texture contains BGR values.
  22085. */
  22086. /**
  22087. * Sets wether the color grading texture contains BGR values.
  22088. */
  22089. colorGradingBGR: boolean;
  22090. /** @hidden */
  22091. _exposure: number;
  22092. /**
  22093. * Gets the Exposure used in the effect.
  22094. */
  22095. /**
  22096. * Sets the Exposure used in the effect.
  22097. */
  22098. exposure: number;
  22099. private _toneMappingEnabled;
  22100. /**
  22101. * Gets wether the tone mapping effect is enabled.
  22102. */
  22103. /**
  22104. * Sets wether the tone mapping effect is enabled.
  22105. */
  22106. toneMappingEnabled: boolean;
  22107. private _toneMappingType;
  22108. /**
  22109. * Gets the type of tone mapping effect.
  22110. */
  22111. /**
  22112. * Sets the type of tone mapping effect used in BabylonJS.
  22113. */
  22114. toneMappingType: number;
  22115. protected _contrast: number;
  22116. /**
  22117. * Gets the contrast used in the effect.
  22118. */
  22119. /**
  22120. * Sets the contrast used in the effect.
  22121. */
  22122. contrast: number;
  22123. /**
  22124. * Vignette stretch size.
  22125. */
  22126. vignetteStretch: number;
  22127. /**
  22128. * Vignette centre X Offset.
  22129. */
  22130. vignetteCentreX: number;
  22131. /**
  22132. * Vignette centre Y Offset.
  22133. */
  22134. vignetteCentreY: number;
  22135. /**
  22136. * Vignette weight or intensity of the vignette effect.
  22137. */
  22138. vignetteWeight: number;
  22139. /**
  22140. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  22141. * if vignetteEnabled is set to true.
  22142. */
  22143. vignetteColor: Color4;
  22144. /**
  22145. * Camera field of view used by the Vignette effect.
  22146. */
  22147. vignetteCameraFov: number;
  22148. private _vignetteBlendMode;
  22149. /**
  22150. * Gets the vignette blend mode allowing different kind of effect.
  22151. */
  22152. /**
  22153. * Sets the vignette blend mode allowing different kind of effect.
  22154. */
  22155. vignetteBlendMode: number;
  22156. private _vignetteEnabled;
  22157. /**
  22158. * Gets wether the vignette effect is enabled.
  22159. */
  22160. /**
  22161. * Sets wether the vignette effect is enabled.
  22162. */
  22163. vignetteEnabled: boolean;
  22164. private _applyByPostProcess;
  22165. /**
  22166. * Gets wether the image processing is applied through a post process or not.
  22167. */
  22168. /**
  22169. * Sets wether the image processing is applied through a post process or not.
  22170. */
  22171. applyByPostProcess: boolean;
  22172. private _isEnabled;
  22173. /**
  22174. * Gets wether the image processing is enabled or not.
  22175. */
  22176. /**
  22177. * Sets wether the image processing is enabled or not.
  22178. */
  22179. isEnabled: boolean;
  22180. /**
  22181. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  22182. */
  22183. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  22184. /**
  22185. * Method called each time the image processing information changes requires to recompile the effect.
  22186. */
  22187. protected _updateParameters(): void;
  22188. /**
  22189. * Gets the current class name.
  22190. * @return "ImageProcessingConfiguration"
  22191. */
  22192. getClassName(): string;
  22193. /**
  22194. * Prepare the list of uniforms associated with the Image Processing effects.
  22195. * @param uniforms The list of uniforms used in the effect
  22196. * @param defines the list of defines currently in use
  22197. */
  22198. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  22199. /**
  22200. * Prepare the list of samplers associated with the Image Processing effects.
  22201. * @param samplersList The list of uniforms used in the effect
  22202. * @param defines the list of defines currently in use
  22203. */
  22204. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  22205. /**
  22206. * Prepare the list of defines associated to the shader.
  22207. * @param defines the list of defines to complete
  22208. * @param forPostProcess Define if we are currently in post process mode or not
  22209. */
  22210. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  22211. /**
  22212. * Returns true if all the image processing information are ready.
  22213. * @returns True if ready, otherwise, false
  22214. */
  22215. isReady(): boolean;
  22216. /**
  22217. * Binds the image processing to the shader.
  22218. * @param effect The effect to bind to
  22219. * @param aspectRatio Define the current aspect ratio of the effect
  22220. */
  22221. bind(effect: Effect, aspectRatio?: number): void;
  22222. /**
  22223. * Clones the current image processing instance.
  22224. * @return The cloned image processing
  22225. */
  22226. clone(): ImageProcessingConfiguration;
  22227. /**
  22228. * Serializes the current image processing instance to a json representation.
  22229. * @return a JSON representation
  22230. */
  22231. serialize(): any;
  22232. /**
  22233. * Parses the image processing from a json representation.
  22234. * @param source the JSON source to parse
  22235. * @return The parsed image processing
  22236. */
  22237. static Parse(source: any): ImageProcessingConfiguration;
  22238. private static _VIGNETTEMODE_MULTIPLY;
  22239. private static _VIGNETTEMODE_OPAQUE;
  22240. /**
  22241. * Used to apply the vignette as a mix with the pixel color.
  22242. */
  22243. static readonly VIGNETTEMODE_MULTIPLY: number;
  22244. /**
  22245. * Used to apply the vignette as a replacement of the pixel color.
  22246. */
  22247. static readonly VIGNETTEMODE_OPAQUE: number;
  22248. }
  22249. }
  22250. declare module BABYLON {
  22251. /**
  22252. * Manages the defines for the Material
  22253. */
  22254. class MaterialDefines {
  22255. private _keys;
  22256. private _isDirty;
  22257. /** @hidden */
  22258. _renderId: number;
  22259. /** @hidden */
  22260. _areLightsDirty: boolean;
  22261. /** @hidden */
  22262. _areAttributesDirty: boolean;
  22263. /** @hidden */
  22264. _areTexturesDirty: boolean;
  22265. /** @hidden */
  22266. _areFresnelDirty: boolean;
  22267. /** @hidden */
  22268. _areMiscDirty: boolean;
  22269. /** @hidden */
  22270. _areImageProcessingDirty: boolean;
  22271. /** @hidden */
  22272. _normals: boolean;
  22273. /** @hidden */
  22274. _uvs: boolean;
  22275. /** @hidden */
  22276. _needNormals: boolean;
  22277. /** @hidden */
  22278. _needUVs: boolean;
  22279. /**
  22280. * Specifies if the material needs to be re-calculated
  22281. */
  22282. readonly isDirty: boolean;
  22283. /**
  22284. * Marks the material to indicate that it has been re-calculated
  22285. */
  22286. markAsProcessed(): void;
  22287. /**
  22288. * Marks the material to indicate that it needs to be re-calculated
  22289. */
  22290. markAsUnprocessed(): void;
  22291. /**
  22292. * Marks the material to indicate all of its defines need to be re-calculated
  22293. */
  22294. markAllAsDirty(): void;
  22295. /**
  22296. * Marks the material to indicate that image processing needs to be re-calculated
  22297. */
  22298. markAsImageProcessingDirty(): void;
  22299. /**
  22300. * Marks the material to indicate the lights need to be re-calculated
  22301. */
  22302. markAsLightDirty(): void;
  22303. /**
  22304. * Marks the attribute state as changed
  22305. */
  22306. markAsAttributesDirty(): void;
  22307. /**
  22308. * Marks the texture state as changed
  22309. */
  22310. markAsTexturesDirty(): void;
  22311. /**
  22312. * Marks the fresnel state as changed
  22313. */
  22314. markAsFresnelDirty(): void;
  22315. /**
  22316. * Marks the misc state as changed
  22317. */
  22318. markAsMiscDirty(): void;
  22319. /**
  22320. * Rebuilds the material defines
  22321. */
  22322. rebuild(): void;
  22323. /**
  22324. * Specifies if two material defines are equal
  22325. * @param other - A material define instance to compare to
  22326. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  22327. */
  22328. isEqual(other: MaterialDefines): boolean;
  22329. /**
  22330. * Clones this instance's defines to another instance
  22331. * @param other - material defines to clone values to
  22332. */
  22333. cloneTo(other: MaterialDefines): void;
  22334. /**
  22335. * Resets the material define values
  22336. */
  22337. reset(): void;
  22338. /**
  22339. * Converts the material define values to a string
  22340. * @returns - String of material define information
  22341. */
  22342. toString(): string;
  22343. }
  22344. /**
  22345. * Base class for the main features of a material in Babylon.js
  22346. */
  22347. class Material implements IAnimatable {
  22348. private static _TriangleFillMode;
  22349. private static _WireFrameFillMode;
  22350. private static _PointFillMode;
  22351. private static _PointListDrawMode;
  22352. private static _LineListDrawMode;
  22353. private static _LineLoopDrawMode;
  22354. private static _LineStripDrawMode;
  22355. private static _TriangleStripDrawMode;
  22356. private static _TriangleFanDrawMode;
  22357. /**
  22358. * Returns the triangle fill mode
  22359. */
  22360. static readonly TriangleFillMode: number;
  22361. /**
  22362. * Returns the wireframe mode
  22363. */
  22364. static readonly WireFrameFillMode: number;
  22365. /**
  22366. * Returns the point fill mode
  22367. */
  22368. static readonly PointFillMode: number;
  22369. /**
  22370. * Returns the point list draw mode
  22371. */
  22372. static readonly PointListDrawMode: number;
  22373. /**
  22374. * Returns the line list draw mode
  22375. */
  22376. static readonly LineListDrawMode: number;
  22377. /**
  22378. * Returns the line loop draw mode
  22379. */
  22380. static readonly LineLoopDrawMode: number;
  22381. /**
  22382. * Returns the line strip draw mode
  22383. */
  22384. static readonly LineStripDrawMode: number;
  22385. /**
  22386. * Returns the triangle strip draw mode
  22387. */
  22388. static readonly TriangleStripDrawMode: number;
  22389. /**
  22390. * Returns the triangle fan draw mode
  22391. */
  22392. static readonly TriangleFanDrawMode: number;
  22393. /**
  22394. * Stores the clock-wise side orientation
  22395. */
  22396. private static _ClockWiseSideOrientation;
  22397. /**
  22398. * Stores the counter clock-wise side orientation
  22399. */
  22400. private static _CounterClockWiseSideOrientation;
  22401. /**
  22402. * Returns the clock-wise side orientation
  22403. */
  22404. static readonly ClockWiseSideOrientation: number;
  22405. /**
  22406. * Returns the counter clock-wise side orientation
  22407. */
  22408. static readonly CounterClockWiseSideOrientation: number;
  22409. /**
  22410. * The dirty texture flag value
  22411. */
  22412. static readonly TextureDirtyFlag: number;
  22413. /**
  22414. * The dirty light flag value
  22415. */
  22416. static readonly LightDirtyFlag: number;
  22417. /**
  22418. * The dirty fresnel flag value
  22419. */
  22420. static readonly FresnelDirtyFlag: number;
  22421. /**
  22422. * The dirty attribute flag value
  22423. */
  22424. static readonly AttributesDirtyFlag: number;
  22425. /**
  22426. * The dirty misc flag value
  22427. */
  22428. static readonly MiscDirtyFlag: number;
  22429. /**
  22430. * The all dirty flag value
  22431. */
  22432. static readonly AllDirtyFlag: number;
  22433. /**
  22434. * The ID of the material
  22435. */
  22436. id: string;
  22437. /**
  22438. * Gets or sets the unique id of the material
  22439. */
  22440. uniqueId: number;
  22441. /**
  22442. * The name of the material
  22443. */
  22444. name: string;
  22445. /**
  22446. * Gets or sets user defined metadata
  22447. */
  22448. metadata: any;
  22449. /**
  22450. * For internal use only. Please do not use.
  22451. */
  22452. reservedDataStore: any;
  22453. /**
  22454. * Specifies if the ready state should be checked on each call
  22455. */
  22456. checkReadyOnEveryCall: boolean;
  22457. /**
  22458. * Specifies if the ready state should be checked once
  22459. */
  22460. checkReadyOnlyOnce: boolean;
  22461. /**
  22462. * The state of the material
  22463. */
  22464. state: string;
  22465. /**
  22466. * The alpha value of the material
  22467. */
  22468. protected _alpha: number;
  22469. /**
  22470. * Sets the alpha value of the material
  22471. */
  22472. /**
  22473. * Gets the alpha value of the material
  22474. */
  22475. alpha: number;
  22476. /**
  22477. * Specifies if back face culling is enabled
  22478. */
  22479. protected _backFaceCulling: boolean;
  22480. /**
  22481. * Sets the back-face culling state
  22482. */
  22483. /**
  22484. * Gets the back-face culling state
  22485. */
  22486. backFaceCulling: boolean;
  22487. /**
  22488. * Stores the value for side orientation
  22489. */
  22490. sideOrientation: number;
  22491. /**
  22492. * Callback triggered when the material is compiled
  22493. */
  22494. onCompiled: (effect: Effect) => void;
  22495. /**
  22496. * Callback triggered when an error occurs
  22497. */
  22498. onError: (effect: Effect, errors: string) => void;
  22499. /**
  22500. * Callback triggered to get the render target textures
  22501. */
  22502. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22503. /**
  22504. * Gets a boolean indicating that current material needs to register RTT
  22505. */
  22506. readonly hasRenderTargetTextures: boolean;
  22507. /**
  22508. * Specifies if the material should be serialized
  22509. */
  22510. doNotSerialize: boolean;
  22511. /**
  22512. * @hidden
  22513. */
  22514. _storeEffectOnSubMeshes: boolean;
  22515. /**
  22516. * Stores the animations for the material
  22517. */
  22518. animations: Array<Animation>;
  22519. /**
  22520. * An event triggered when the material is disposed
  22521. */
  22522. onDisposeObservable: Observable<Material>;
  22523. /**
  22524. * An observer which watches for dispose events
  22525. */
  22526. private _onDisposeObserver;
  22527. private _onUnBindObservable;
  22528. /**
  22529. * Called during a dispose event
  22530. */
  22531. onDispose: () => void;
  22532. private _onBindObservable;
  22533. /**
  22534. * An event triggered when the material is bound
  22535. */
  22536. readonly onBindObservable: Observable<AbstractMesh>;
  22537. /**
  22538. * An observer which watches for bind events
  22539. */
  22540. private _onBindObserver;
  22541. /**
  22542. * Called during a bind event
  22543. */
  22544. onBind: (Mesh: AbstractMesh) => void;
  22545. /**
  22546. * An event triggered when the material is unbound
  22547. */
  22548. readonly onUnBindObservable: Observable<Material>;
  22549. /**
  22550. * Stores the value of the alpha mode
  22551. */
  22552. private _alphaMode;
  22553. /**
  22554. * Sets the value of the alpha mode.
  22555. *
  22556. * | Value | Type | Description |
  22557. * | --- | --- | --- |
  22558. * | 0 | ALPHA_DISABLE | |
  22559. * | 1 | ALPHA_ADD | |
  22560. * | 2 | ALPHA_COMBINE | |
  22561. * | 3 | ALPHA_SUBTRACT | |
  22562. * | 4 | ALPHA_MULTIPLY | |
  22563. * | 5 | ALPHA_MAXIMIZED | |
  22564. * | 6 | ALPHA_ONEONE | |
  22565. * | 7 | ALPHA_PREMULTIPLIED | |
  22566. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22567. * | 9 | ALPHA_INTERPOLATE | |
  22568. * | 10 | ALPHA_SCREENMODE | |
  22569. *
  22570. */
  22571. /**
  22572. * Gets the value of the alpha mode
  22573. */
  22574. alphaMode: number;
  22575. /**
  22576. * Stores the state of the need depth pre-pass value
  22577. */
  22578. private _needDepthPrePass;
  22579. /**
  22580. * Sets the need depth pre-pass value
  22581. */
  22582. /**
  22583. * Gets the depth pre-pass value
  22584. */
  22585. needDepthPrePass: boolean;
  22586. /**
  22587. * Specifies if depth writing should be disabled
  22588. */
  22589. disableDepthWrite: boolean;
  22590. /**
  22591. * Specifies if depth writing should be forced
  22592. */
  22593. forceDepthWrite: boolean;
  22594. /**
  22595. * Specifies if there should be a separate pass for culling
  22596. */
  22597. separateCullingPass: boolean;
  22598. /**
  22599. * Stores the state specifing if fog should be enabled
  22600. */
  22601. private _fogEnabled;
  22602. /**
  22603. * Sets the state for enabling fog
  22604. */
  22605. /**
  22606. * Gets the value of the fog enabled state
  22607. */
  22608. fogEnabled: boolean;
  22609. /**
  22610. * Stores the size of points
  22611. */
  22612. pointSize: number;
  22613. /**
  22614. * Stores the z offset value
  22615. */
  22616. zOffset: number;
  22617. /**
  22618. * Gets a value specifying if wireframe mode is enabled
  22619. */
  22620. /**
  22621. * Sets the state of wireframe mode
  22622. */
  22623. wireframe: boolean;
  22624. /**
  22625. * Gets the value specifying if point clouds are enabled
  22626. */
  22627. /**
  22628. * Sets the state of point cloud mode
  22629. */
  22630. pointsCloud: boolean;
  22631. /**
  22632. * Gets the material fill mode
  22633. */
  22634. /**
  22635. * Sets the material fill mode
  22636. */
  22637. fillMode: number;
  22638. /**
  22639. * @hidden
  22640. * Stores the effects for the material
  22641. */
  22642. _effect: Nullable<Effect>;
  22643. /**
  22644. * @hidden
  22645. * Specifies if the material was previously ready
  22646. */
  22647. _wasPreviouslyReady: boolean;
  22648. /**
  22649. * Specifies if uniform buffers should be used
  22650. */
  22651. private _useUBO;
  22652. /**
  22653. * Stores a reference to the scene
  22654. */
  22655. private _scene;
  22656. /**
  22657. * Stores the fill mode state
  22658. */
  22659. private _fillMode;
  22660. /**
  22661. * Specifies if the depth write state should be cached
  22662. */
  22663. private _cachedDepthWriteState;
  22664. /**
  22665. * Stores the uniform buffer
  22666. */
  22667. protected _uniformBuffer: UniformBuffer;
  22668. /** @hidden */
  22669. _indexInSceneMaterialArray: number;
  22670. /** @hidden */
  22671. meshMap: Nullable<{
  22672. [id: string]: AbstractMesh | undefined;
  22673. }>;
  22674. /**
  22675. * Creates a material instance
  22676. * @param name defines the name of the material
  22677. * @param scene defines the scene to reference
  22678. * @param doNotAdd specifies if the material should be added to the scene
  22679. */
  22680. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22681. /**
  22682. * Returns a string representation of the current material
  22683. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22684. * @returns a string with material information
  22685. */
  22686. toString(fullDetails?: boolean): string;
  22687. /**
  22688. * Gets the class name of the material
  22689. * @returns a string with the class name of the material
  22690. */
  22691. getClassName(): string;
  22692. /**
  22693. * Specifies if updates for the material been locked
  22694. */
  22695. readonly isFrozen: boolean;
  22696. /**
  22697. * Locks updates for the material
  22698. */
  22699. freeze(): void;
  22700. /**
  22701. * Unlocks updates for the material
  22702. */
  22703. unfreeze(): void;
  22704. /**
  22705. * Specifies if the material is ready to be used
  22706. * @param mesh defines the mesh to check
  22707. * @param useInstances specifies if instances should be used
  22708. * @returns a boolean indicating if the material is ready to be used
  22709. */
  22710. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22711. /**
  22712. * Specifies that the submesh is ready to be used
  22713. * @param mesh defines the mesh to check
  22714. * @param subMesh defines which submesh to check
  22715. * @param useInstances specifies that instances should be used
  22716. * @returns a boolean indicating that the submesh is ready or not
  22717. */
  22718. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22719. /**
  22720. * Returns the material effect
  22721. * @returns the effect associated with the material
  22722. */
  22723. getEffect(): Nullable<Effect>;
  22724. /**
  22725. * Returns the current scene
  22726. * @returns a Scene
  22727. */
  22728. getScene(): Scene;
  22729. /**
  22730. * Specifies if the material will require alpha blending
  22731. * @returns a boolean specifying if alpha blending is needed
  22732. */
  22733. needAlphaBlending(): boolean;
  22734. /**
  22735. * Specifies if the mesh will require alpha blending
  22736. * @param mesh defines the mesh to check
  22737. * @returns a boolean specifying if alpha blending is needed for the mesh
  22738. */
  22739. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22740. /**
  22741. * Specifies if this material should be rendered in alpha test mode
  22742. * @returns a boolean specifying if an alpha test is needed.
  22743. */
  22744. needAlphaTesting(): boolean;
  22745. /**
  22746. * Gets the texture used for the alpha test
  22747. * @returns the texture to use for alpha testing
  22748. */
  22749. getAlphaTestTexture(): Nullable<BaseTexture>;
  22750. /**
  22751. * Marks the material to indicate that it needs to be re-calculated
  22752. */
  22753. markDirty(): void;
  22754. /** @hidden */
  22755. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22756. /**
  22757. * Binds the material to the mesh
  22758. * @param world defines the world transformation matrix
  22759. * @param mesh defines the mesh to bind the material to
  22760. */
  22761. bind(world: Matrix, mesh?: Mesh): void;
  22762. /**
  22763. * Binds the submesh to the material
  22764. * @param world defines the world transformation matrix
  22765. * @param mesh defines the mesh containing the submesh
  22766. * @param subMesh defines the submesh to bind the material to
  22767. */
  22768. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22769. /**
  22770. * Binds the world matrix to the material
  22771. * @param world defines the world transformation matrix
  22772. */
  22773. bindOnlyWorldMatrix(world: Matrix): void;
  22774. /**
  22775. * Binds the scene's uniform buffer to the effect.
  22776. * @param effect defines the effect to bind to the scene uniform buffer
  22777. * @param sceneUbo defines the uniform buffer storing scene data
  22778. */
  22779. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22780. /**
  22781. * Binds the view matrix to the effect
  22782. * @param effect defines the effect to bind the view matrix to
  22783. */
  22784. bindView(effect: Effect): void;
  22785. /**
  22786. * Binds the view projection matrix to the effect
  22787. * @param effect defines the effect to bind the view projection matrix to
  22788. */
  22789. bindViewProjection(effect: Effect): void;
  22790. /**
  22791. * Specifies if material alpha testing should be turned on for the mesh
  22792. * @param mesh defines the mesh to check
  22793. */
  22794. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22795. /**
  22796. * Processes to execute after binding the material to a mesh
  22797. * @param mesh defines the rendered mesh
  22798. */
  22799. protected _afterBind(mesh?: Mesh): void;
  22800. /**
  22801. * Unbinds the material from the mesh
  22802. */
  22803. unbind(): void;
  22804. /**
  22805. * Gets the active textures from the material
  22806. * @returns an array of textures
  22807. */
  22808. getActiveTextures(): BaseTexture[];
  22809. /**
  22810. * Specifies if the material uses a texture
  22811. * @param texture defines the texture to check against the material
  22812. * @returns a boolean specifying if the material uses the texture
  22813. */
  22814. hasTexture(texture: BaseTexture): boolean;
  22815. /**
  22816. * Makes a duplicate of the material, and gives it a new name
  22817. * @param name defines the new name for the duplicated material
  22818. * @returns the cloned material
  22819. */
  22820. clone(name: string): Nullable<Material>;
  22821. /**
  22822. * Gets the meshes bound to the material
  22823. * @returns an array of meshes bound to the material
  22824. */
  22825. getBindedMeshes(): AbstractMesh[];
  22826. /**
  22827. * Force shader compilation
  22828. * @param mesh defines the mesh associated with this material
  22829. * @param onCompiled defines a function to execute once the material is compiled
  22830. * @param options defines the options to configure the compilation
  22831. */
  22832. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22833. clipPlane: boolean;
  22834. }>): void;
  22835. /**
  22836. * Force shader compilation
  22837. * @param mesh defines the mesh that will use this material
  22838. * @param options defines additional options for compiling the shaders
  22839. * @returns a promise that resolves when the compilation completes
  22840. */
  22841. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22842. clipPlane: boolean;
  22843. }>): Promise<void>;
  22844. private static readonly _ImageProcessingDirtyCallBack;
  22845. private static readonly _TextureDirtyCallBack;
  22846. private static readonly _FresnelDirtyCallBack;
  22847. private static readonly _MiscDirtyCallBack;
  22848. private static readonly _LightsDirtyCallBack;
  22849. private static readonly _AttributeDirtyCallBack;
  22850. private static _FresnelAndMiscDirtyCallBack;
  22851. private static _TextureAndMiscDirtyCallBack;
  22852. private static readonly _DirtyCallbackArray;
  22853. private static readonly _RunDirtyCallBacks;
  22854. /**
  22855. * Marks a define in the material to indicate that it needs to be re-computed
  22856. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22857. */
  22858. markAsDirty(flag: number): void;
  22859. /**
  22860. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22861. * @param func defines a function which checks material defines against the submeshes
  22862. */
  22863. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22864. /**
  22865. * Indicates that image processing needs to be re-calculated for all submeshes
  22866. */
  22867. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22868. /**
  22869. * Indicates that textures need to be re-calculated for all submeshes
  22870. */
  22871. protected _markAllSubMeshesAsTexturesDirty(): void;
  22872. /**
  22873. * Indicates that fresnel needs to be re-calculated for all submeshes
  22874. */
  22875. protected _markAllSubMeshesAsFresnelDirty(): void;
  22876. /**
  22877. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22878. */
  22879. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22880. /**
  22881. * Indicates that lights need to be re-calculated for all submeshes
  22882. */
  22883. protected _markAllSubMeshesAsLightsDirty(): void;
  22884. /**
  22885. * Indicates that attributes need to be re-calculated for all submeshes
  22886. */
  22887. protected _markAllSubMeshesAsAttributesDirty(): void;
  22888. /**
  22889. * Indicates that misc needs to be re-calculated for all submeshes
  22890. */
  22891. protected _markAllSubMeshesAsMiscDirty(): void;
  22892. /**
  22893. * Indicates that textures and misc need to be re-calculated for all submeshes
  22894. */
  22895. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22896. /**
  22897. * Disposes the material
  22898. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22899. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22900. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22901. */
  22902. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22903. /** @hidden */
  22904. private releaseVertexArrayObject;
  22905. /**
  22906. * Serializes this material
  22907. * @returns the serialized material object
  22908. */
  22909. serialize(): any;
  22910. /**
  22911. * Creates a MultiMaterial from parsed MultiMaterial data.
  22912. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22913. * @param scene defines the hosting scene
  22914. * @returns a new MultiMaterial
  22915. */
  22916. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22917. /**
  22918. * Creates a material from parsed material data
  22919. * @param parsedMaterial defines parsed material data
  22920. * @param scene defines the hosting scene
  22921. * @param rootUrl defines the root URL to use to load textures
  22922. * @returns a new material
  22923. */
  22924. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22925. }
  22926. }
  22927. declare module BABYLON {
  22928. /**
  22929. * "Static Class" containing the most commonly used helper while dealing with material for
  22930. * rendering purpose.
  22931. *
  22932. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  22933. *
  22934. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  22935. */
  22936. class MaterialHelper {
  22937. /**
  22938. * Bind the current view position to an effect.
  22939. * @param effect The effect to be bound
  22940. * @param scene The scene the eyes position is used from
  22941. */
  22942. static BindEyePosition(effect: Effect, scene: Scene): void;
  22943. /**
  22944. * Helps preparing the defines values about the UVs in used in the effect.
  22945. * UVs are shared as much as we can accross channels in the shaders.
  22946. * @param texture The texture we are preparing the UVs for
  22947. * @param defines The defines to update
  22948. * @param key The channel key "diffuse", "specular"... used in the shader
  22949. */
  22950. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  22951. /**
  22952. * Binds a texture matrix value to its corrsponding uniform
  22953. * @param texture The texture to bind the matrix for
  22954. * @param uniformBuffer The uniform buffer receivin the data
  22955. * @param key The channel key "diffuse", "specular"... used in the shader
  22956. */
  22957. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  22958. /**
  22959. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  22960. * @param mesh defines the current mesh
  22961. * @param scene defines the current scene
  22962. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  22963. * @param pointsCloud defines if point cloud rendering has to be turned on
  22964. * @param fogEnabled defines if fog has to be turned on
  22965. * @param alphaTest defines if alpha testing has to be turned on
  22966. * @param defines defines the current list of defines
  22967. */
  22968. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  22969. /**
  22970. * Helper used to prepare the list of defines associated with frame values for shader compilation
  22971. * @param scene defines the current scene
  22972. * @param engine defines the current engine
  22973. * @param defines specifies the list of active defines
  22974. * @param useInstances defines if instances have to be turned on
  22975. * @param useClipPlane defines if clip plane have to be turned on
  22976. */
  22977. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  22978. /**
  22979. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  22980. * @param mesh The mesh containing the geometry data we will draw
  22981. * @param defines The defines to update
  22982. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  22983. * @param useBones Precise whether bones should be used or not (override mesh info)
  22984. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  22985. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  22986. * @returns false if defines are considered not dirty and have not been checked
  22987. */
  22988. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  22989. /**
  22990. * Prepares the defines related to the light information passed in parameter
  22991. * @param scene The scene we are intending to draw
  22992. * @param mesh The mesh the effect is compiling for
  22993. * @param defines The defines to update
  22994. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  22995. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  22996. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  22997. * @returns true if normals will be required for the rest of the effect
  22998. */
  22999. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  23000. /**
  23001. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  23002. * that won t be acctive due to defines being turned off.
  23003. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  23004. * @param samplersList The samplers list
  23005. * @param defines The defines helping in the list generation
  23006. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  23007. */
  23008. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  23009. /**
  23010. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  23011. * @param defines The defines to update while falling back
  23012. * @param fallbacks The authorized effect fallbacks
  23013. * @param maxSimultaneousLights The maximum number of lights allowed
  23014. * @param rank the current rank of the Effect
  23015. * @returns The newly affected rank
  23016. */
  23017. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  23018. /**
  23019. * Prepares the list of attributes required for morph targets according to the effect defines.
  23020. * @param attribs The current list of supported attribs
  23021. * @param mesh The mesh to prepare the morph targets attributes for
  23022. * @param defines The current Defines of the effect
  23023. */
  23024. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  23025. /**
  23026. * Prepares the list of attributes required for bones according to the effect defines.
  23027. * @param attribs The current list of supported attribs
  23028. * @param mesh The mesh to prepare the bones attributes for
  23029. * @param defines The current Defines of the effect
  23030. * @param fallbacks The current efffect fallback strategy
  23031. */
  23032. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  23033. /**
  23034. * Prepares the list of attributes required for instances according to the effect defines.
  23035. * @param attribs The current list of supported attribs
  23036. * @param defines The current Defines of the effect
  23037. */
  23038. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  23039. /**
  23040. * Binds the light shadow information to the effect for the given mesh.
  23041. * @param light The light containing the generator
  23042. * @param scene The scene the lights belongs to
  23043. * @param mesh The mesh we are binding the information to render
  23044. * @param lightIndex The light index in the effect used to render the mesh
  23045. * @param effect The effect we are binding the data to
  23046. */
  23047. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  23048. /**
  23049. * Binds the light information to the effect.
  23050. * @param light The light containing the generator
  23051. * @param effect The effect we are binding the data to
  23052. * @param lightIndex The light index in the effect used to render
  23053. */
  23054. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  23055. /**
  23056. * Binds the lights information from the scene to the effect for the given mesh.
  23057. * @param scene The scene the lights belongs to
  23058. * @param mesh The mesh we are binding the information to render
  23059. * @param effect The effect we are binding the data to
  23060. * @param defines The generated defines for the effect
  23061. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  23062. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  23063. */
  23064. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  23065. private static _tempFogColor;
  23066. /**
  23067. * Binds the fog information from the scene to the effect for the given mesh.
  23068. * @param scene The scene the lights belongs to
  23069. * @param mesh The mesh we are binding the information to render
  23070. * @param effect The effect we are binding the data to
  23071. * @param linearSpace Defines if the fog effect is applied in linear space
  23072. */
  23073. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  23074. /**
  23075. * Binds the bones information from the mesh to the effect.
  23076. * @param mesh The mesh we are binding the information to render
  23077. * @param effect The effect we are binding the data to
  23078. */
  23079. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  23080. /**
  23081. * Binds the morph targets information from the mesh to the effect.
  23082. * @param abstractMesh The mesh we are binding the information to render
  23083. * @param effect The effect we are binding the data to
  23084. */
  23085. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  23086. /**
  23087. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  23088. * @param defines The generated defines used in the effect
  23089. * @param effect The effect we are binding the data to
  23090. * @param scene The scene we are willing to render with logarithmic scale for
  23091. */
  23092. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  23093. /**
  23094. * Binds the clip plane information from the scene to the effect.
  23095. * @param scene The scene the clip plane information are extracted from
  23096. * @param effect The effect we are binding the data to
  23097. */
  23098. static BindClipPlane(effect: Effect, scene: Scene): void;
  23099. }
  23100. }
  23101. declare module BABYLON {
  23102. /**
  23103. * A multi-material is used to apply different materials to different parts of the same object without the need of
  23104. * separate meshes. This can be use to improve performances.
  23105. * @see http://doc.babylonjs.com/how_to/multi_materials
  23106. */
  23107. class MultiMaterial extends Material {
  23108. private _subMaterials;
  23109. /**
  23110. * Gets or Sets the list of Materials used within the multi material.
  23111. * They need to be ordered according to the submeshes order in the associated mesh
  23112. */
  23113. subMaterials: Nullable<Material>[];
  23114. /**
  23115. * Function used to align with Node.getChildren()
  23116. * @returns the list of Materials used within the multi material
  23117. */
  23118. getChildren(): Nullable<Material>[];
  23119. /**
  23120. * Instantiates a new Multi Material
  23121. * A multi-material is used to apply different materials to different parts of the same object without the need of
  23122. * separate meshes. This can be use to improve performances.
  23123. * @see http://doc.babylonjs.com/how_to/multi_materials
  23124. * @param name Define the name in the scene
  23125. * @param scene Define the scene the material belongs to
  23126. */
  23127. constructor(name: string, scene: Scene);
  23128. private _hookArray;
  23129. /**
  23130. * Get one of the submaterial by its index in the submaterials array
  23131. * @param index The index to look the sub material at
  23132. * @returns The Material if the index has been defined
  23133. */
  23134. getSubMaterial(index: number): Nullable<Material>;
  23135. /**
  23136. * Get the list of active textures for the whole sub materials list.
  23137. * @returns All the textures that will be used during the rendering
  23138. */
  23139. getActiveTextures(): BaseTexture[];
  23140. /**
  23141. * Gets the current class name of the material e.g. "MultiMaterial"
  23142. * Mainly use in serialization.
  23143. * @returns the class name
  23144. */
  23145. getClassName(): string;
  23146. /**
  23147. * Checks if the material is ready to render the requested sub mesh
  23148. * @param mesh Define the mesh the submesh belongs to
  23149. * @param subMesh Define the sub mesh to look readyness for
  23150. * @param useInstances Define whether or not the material is used with instances
  23151. * @returns true if ready, otherwise false
  23152. */
  23153. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  23154. /**
  23155. * Clones the current material and its related sub materials
  23156. * @param name Define the name of the newly cloned material
  23157. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  23158. * @returns the cloned material
  23159. */
  23160. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  23161. /**
  23162. * Serializes the materials into a JSON representation.
  23163. * @returns the JSON representation
  23164. */
  23165. serialize(): any;
  23166. /**
  23167. * Dispose the material and release its associated resources
  23168. * @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)
  23169. * @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)
  23170. */
  23171. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  23172. }
  23173. }
  23174. declare module BABYLON {
  23175. /**
  23176. * Base class of materials working in push mode in babylon JS
  23177. * @hidden
  23178. */
  23179. class PushMaterial extends Material {
  23180. protected _activeEffect: Effect;
  23181. protected _normalMatrix: Matrix;
  23182. /**
  23183. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  23184. * This means that the material can keep using a previous shader while a new one is being compiled.
  23185. * This is mostly used when shader parallel compilation is supported (true by default)
  23186. */
  23187. allowShaderHotSwapping: boolean;
  23188. constructor(name: string, scene: Scene);
  23189. getEffect(): Effect;
  23190. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23191. /**
  23192. * Binds the given world matrix to the active effect
  23193. *
  23194. * @param world the matrix to bind
  23195. */
  23196. bindOnlyWorldMatrix(world: Matrix): void;
  23197. /**
  23198. * Binds the given normal matrix to the active effect
  23199. *
  23200. * @param normalMatrix the matrix to bind
  23201. */
  23202. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  23203. bind(world: Matrix, mesh?: Mesh): void;
  23204. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  23205. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  23206. }
  23207. }
  23208. declare module BABYLON {
  23209. /**
  23210. * Defines the options associated with the creation of a shader material.
  23211. */
  23212. interface IShaderMaterialOptions {
  23213. /**
  23214. * Does the material work in alpha blend mode
  23215. */
  23216. needAlphaBlending: boolean;
  23217. /**
  23218. * Does the material work in alpha test mode
  23219. */
  23220. needAlphaTesting: boolean;
  23221. /**
  23222. * The list of attribute names used in the shader
  23223. */
  23224. attributes: string[];
  23225. /**
  23226. * The list of unifrom names used in the shader
  23227. */
  23228. uniforms: string[];
  23229. /**
  23230. * The list of UBO names used in the shader
  23231. */
  23232. uniformBuffers: string[];
  23233. /**
  23234. * The list of sampler names used in the shader
  23235. */
  23236. samplers: string[];
  23237. /**
  23238. * The list of defines used in the shader
  23239. */
  23240. defines: string[];
  23241. }
  23242. /**
  23243. * 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.
  23244. *
  23245. * This returned material effects how the mesh will look based on the code in the shaders.
  23246. *
  23247. * @see http://doc.babylonjs.com/how_to/shader_material
  23248. */
  23249. class ShaderMaterial extends Material {
  23250. private _shaderPath;
  23251. private _options;
  23252. private _textures;
  23253. private _textureArrays;
  23254. private _floats;
  23255. private _ints;
  23256. private _floatsArrays;
  23257. private _colors3;
  23258. private _colors3Arrays;
  23259. private _colors4;
  23260. private _vectors2;
  23261. private _vectors3;
  23262. private _vectors4;
  23263. private _matrices;
  23264. private _matrices3x3;
  23265. private _matrices2x2;
  23266. private _vectors2Arrays;
  23267. private _vectors3Arrays;
  23268. private _cachedWorldViewMatrix;
  23269. private _renderId;
  23270. /**
  23271. * Instantiate a new shader material.
  23272. * 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.
  23273. * This returned material effects how the mesh will look based on the code in the shaders.
  23274. * @see http://doc.babylonjs.com/how_to/shader_material
  23275. * @param name Define the name of the material in the scene
  23276. * @param scene Define the scene the material belongs to
  23277. * @param shaderPath Defines the route to the shader code in one of three ways:
  23278. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  23279. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  23280. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  23281. * @param options Define the options used to create the shader
  23282. */
  23283. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  23284. /**
  23285. * Gets the current class name of the material e.g. "ShaderMaterial"
  23286. * Mainly use in serialization.
  23287. * @returns the class name
  23288. */
  23289. getClassName(): string;
  23290. /**
  23291. * Specifies if the material will require alpha blending
  23292. * @returns a boolean specifying if alpha blending is needed
  23293. */
  23294. needAlphaBlending(): boolean;
  23295. /**
  23296. * Specifies if this material should be rendered in alpha test mode
  23297. * @returns a boolean specifying if an alpha test is needed.
  23298. */
  23299. needAlphaTesting(): boolean;
  23300. private _checkUniform;
  23301. /**
  23302. * Set a texture in the shader.
  23303. * @param name Define the name of the uniform samplers as defined in the shader
  23304. * @param texture Define the texture to bind to this sampler
  23305. * @return the material itself allowing "fluent" like uniform updates
  23306. */
  23307. setTexture(name: string, texture: Texture): ShaderMaterial;
  23308. /**
  23309. * Set a texture array in the shader.
  23310. * @param name Define the name of the uniform sampler array as defined in the shader
  23311. * @param textures Define the list of textures to bind to this sampler
  23312. * @return the material itself allowing "fluent" like uniform updates
  23313. */
  23314. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  23315. /**
  23316. * Set a float in the shader.
  23317. * @param name Define the name of the uniform as defined in the shader
  23318. * @param value Define the value to give to the uniform
  23319. * @return the material itself allowing "fluent" like uniform updates
  23320. */
  23321. setFloat(name: string, value: number): ShaderMaterial;
  23322. /**
  23323. * Set a int in the shader.
  23324. * @param name Define the name of the uniform as defined in the shader
  23325. * @param value Define the value to give to the uniform
  23326. * @return the material itself allowing "fluent" like uniform updates
  23327. */
  23328. setInt(name: string, value: number): ShaderMaterial;
  23329. /**
  23330. * Set an array of floats in the shader.
  23331. * @param name Define the name of the uniform as defined in the shader
  23332. * @param value Define the value to give to the uniform
  23333. * @return the material itself allowing "fluent" like uniform updates
  23334. */
  23335. setFloats(name: string, value: number[]): ShaderMaterial;
  23336. /**
  23337. * Set a vec3 in the shader from a Color3.
  23338. * @param name Define the name of the uniform as defined in the shader
  23339. * @param value Define the value to give to the uniform
  23340. * @return the material itself allowing "fluent" like uniform updates
  23341. */
  23342. setColor3(name: string, value: Color3): ShaderMaterial;
  23343. /**
  23344. * Set a vec3 array in the shader from a Color3 array.
  23345. * @param name Define the name of the uniform as defined in the shader
  23346. * @param value Define the value to give to the uniform
  23347. * @return the material itself allowing "fluent" like uniform updates
  23348. */
  23349. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  23350. /**
  23351. * Set a vec4 in the shader from a Color4.
  23352. * @param name Define the name of the uniform as defined in the shader
  23353. * @param value Define the value to give to the uniform
  23354. * @return the material itself allowing "fluent" like uniform updates
  23355. */
  23356. setColor4(name: string, value: Color4): ShaderMaterial;
  23357. /**
  23358. * Set a vec2 in the shader from a Vector2.
  23359. * @param name Define the name of the uniform as defined in the shader
  23360. * @param value Define the value to give to the uniform
  23361. * @return the material itself allowing "fluent" like uniform updates
  23362. */
  23363. setVector2(name: string, value: Vector2): ShaderMaterial;
  23364. /**
  23365. * Set a vec3 in the shader from a Vector3.
  23366. * @param name Define the name of the uniform as defined in the shader
  23367. * @param value Define the value to give to the uniform
  23368. * @return the material itself allowing "fluent" like uniform updates
  23369. */
  23370. setVector3(name: string, value: Vector3): ShaderMaterial;
  23371. /**
  23372. * Set a vec4 in the shader from a Vector4.
  23373. * @param name Define the name of the uniform as defined in the shader
  23374. * @param value Define the value to give to the uniform
  23375. * @return the material itself allowing "fluent" like uniform updates
  23376. */
  23377. setVector4(name: string, value: Vector4): ShaderMaterial;
  23378. /**
  23379. * Set a mat4 in the shader from a Matrix.
  23380. * @param name Define the name of the uniform as defined in the shader
  23381. * @param value Define the value to give to the uniform
  23382. * @return the material itself allowing "fluent" like uniform updates
  23383. */
  23384. setMatrix(name: string, value: Matrix): ShaderMaterial;
  23385. /**
  23386. * Set a mat3 in the shader from a Float32Array.
  23387. * @param name Define the name of the uniform as defined in the shader
  23388. * @param value Define the value to give to the uniform
  23389. * @return the material itself allowing "fluent" like uniform updates
  23390. */
  23391. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  23392. /**
  23393. * Set a mat2 in the shader from a Float32Array.
  23394. * @param name Define the name of the uniform as defined in the shader
  23395. * @param value Define the value to give to the uniform
  23396. * @return the material itself allowing "fluent" like uniform updates
  23397. */
  23398. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  23399. /**
  23400. * Set a vec2 array in the shader from a number array.
  23401. * @param name Define the name of the uniform as defined in the shader
  23402. * @param value Define the value to give to the uniform
  23403. * @return the material itself allowing "fluent" like uniform updates
  23404. */
  23405. setArray2(name: string, value: number[]): ShaderMaterial;
  23406. /**
  23407. * Set a vec3 array in the shader from a number array.
  23408. * @param name Define the name of the uniform as defined in the shader
  23409. * @param value Define the value to give to the uniform
  23410. * @return the material itself allowing "fluent" like uniform updates
  23411. */
  23412. setArray3(name: string, value: number[]): ShaderMaterial;
  23413. private _checkCache;
  23414. /**
  23415. * Checks if the material is ready to render the requested mesh
  23416. * @param mesh Define the mesh to render
  23417. * @param useInstances Define whether or not the material is used with instances
  23418. * @returns true if ready, otherwise false
  23419. */
  23420. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23421. /**
  23422. * Binds the world matrix to the material
  23423. * @param world defines the world transformation matrix
  23424. */
  23425. bindOnlyWorldMatrix(world: Matrix): void;
  23426. /**
  23427. * Binds the material to the mesh
  23428. * @param world defines the world transformation matrix
  23429. * @param mesh defines the mesh to bind the material to
  23430. */
  23431. bind(world: Matrix, mesh?: Mesh): void;
  23432. /**
  23433. * Gets the active textures from the material
  23434. * @returns an array of textures
  23435. */
  23436. getActiveTextures(): BaseTexture[];
  23437. /**
  23438. * Specifies if the material uses a texture
  23439. * @param texture defines the texture to check against the material
  23440. * @returns a boolean specifying if the material uses the texture
  23441. */
  23442. hasTexture(texture: BaseTexture): boolean;
  23443. /**
  23444. * Makes a duplicate of the material, and gives it a new name
  23445. * @param name defines the new name for the duplicated material
  23446. * @returns the cloned material
  23447. */
  23448. clone(name: string): ShaderMaterial;
  23449. /**
  23450. * Disposes the material
  23451. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23452. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23453. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23454. */
  23455. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23456. /**
  23457. * Serializes this material in a JSON representation
  23458. * @returns the serialized material object
  23459. */
  23460. serialize(): any;
  23461. /**
  23462. * Creates a shader material from parsed shader material data
  23463. * @param source defines the JSON represnetation of the material
  23464. * @param scene defines the hosting scene
  23465. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23466. * @returns a new material
  23467. */
  23468. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  23469. }
  23470. }
  23471. declare module BABYLON {
  23472. /** @hidden */
  23473. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23474. MAINUV1: boolean;
  23475. MAINUV2: boolean;
  23476. DIFFUSE: boolean;
  23477. DIFFUSEDIRECTUV: number;
  23478. AMBIENT: boolean;
  23479. AMBIENTDIRECTUV: number;
  23480. OPACITY: boolean;
  23481. OPACITYDIRECTUV: number;
  23482. OPACITYRGB: boolean;
  23483. REFLECTION: boolean;
  23484. EMISSIVE: boolean;
  23485. EMISSIVEDIRECTUV: number;
  23486. SPECULAR: boolean;
  23487. SPECULARDIRECTUV: number;
  23488. BUMP: boolean;
  23489. BUMPDIRECTUV: number;
  23490. PARALLAX: boolean;
  23491. PARALLAXOCCLUSION: boolean;
  23492. SPECULAROVERALPHA: boolean;
  23493. CLIPPLANE: boolean;
  23494. CLIPPLANE2: boolean;
  23495. CLIPPLANE3: boolean;
  23496. CLIPPLANE4: boolean;
  23497. ALPHATEST: boolean;
  23498. DEPTHPREPASS: boolean;
  23499. ALPHAFROMDIFFUSE: boolean;
  23500. POINTSIZE: boolean;
  23501. FOG: boolean;
  23502. SPECULARTERM: boolean;
  23503. DIFFUSEFRESNEL: boolean;
  23504. OPACITYFRESNEL: boolean;
  23505. REFLECTIONFRESNEL: boolean;
  23506. REFRACTIONFRESNEL: boolean;
  23507. EMISSIVEFRESNEL: boolean;
  23508. FRESNEL: boolean;
  23509. NORMAL: boolean;
  23510. UV1: boolean;
  23511. UV2: boolean;
  23512. VERTEXCOLOR: boolean;
  23513. VERTEXALPHA: boolean;
  23514. NUM_BONE_INFLUENCERS: number;
  23515. BonesPerMesh: number;
  23516. BONETEXTURE: boolean;
  23517. INSTANCES: boolean;
  23518. GLOSSINESS: boolean;
  23519. ROUGHNESS: boolean;
  23520. EMISSIVEASILLUMINATION: boolean;
  23521. LINKEMISSIVEWITHDIFFUSE: boolean;
  23522. REFLECTIONFRESNELFROMSPECULAR: boolean;
  23523. LIGHTMAP: boolean;
  23524. LIGHTMAPDIRECTUV: number;
  23525. OBJECTSPACE_NORMALMAP: boolean;
  23526. USELIGHTMAPASSHADOWMAP: boolean;
  23527. REFLECTIONMAP_3D: boolean;
  23528. REFLECTIONMAP_SPHERICAL: boolean;
  23529. REFLECTIONMAP_PLANAR: boolean;
  23530. REFLECTIONMAP_CUBIC: boolean;
  23531. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  23532. REFLECTIONMAP_PROJECTION: boolean;
  23533. REFLECTIONMAP_SKYBOX: boolean;
  23534. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  23535. REFLECTIONMAP_EXPLICIT: boolean;
  23536. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  23537. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  23538. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  23539. INVERTCUBICMAP: boolean;
  23540. LOGARITHMICDEPTH: boolean;
  23541. REFRACTION: boolean;
  23542. REFRACTIONMAP_3D: boolean;
  23543. REFLECTIONOVERALPHA: boolean;
  23544. TWOSIDEDLIGHTING: boolean;
  23545. SHADOWFLOAT: boolean;
  23546. MORPHTARGETS: boolean;
  23547. MORPHTARGETS_NORMAL: boolean;
  23548. MORPHTARGETS_TANGENT: boolean;
  23549. NUM_MORPH_INFLUENCERS: number;
  23550. NONUNIFORMSCALING: boolean;
  23551. PREMULTIPLYALPHA: boolean;
  23552. IMAGEPROCESSING: boolean;
  23553. VIGNETTE: boolean;
  23554. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23555. VIGNETTEBLENDMODEOPAQUE: boolean;
  23556. TONEMAPPING: boolean;
  23557. TONEMAPPING_ACES: boolean;
  23558. CONTRAST: boolean;
  23559. COLORCURVES: boolean;
  23560. COLORGRADING: boolean;
  23561. COLORGRADING3D: boolean;
  23562. SAMPLER3DGREENDEPTH: boolean;
  23563. SAMPLER3DBGRMAP: boolean;
  23564. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23565. /**
  23566. * If the reflection texture on this material is in linear color space
  23567. * @hidden
  23568. */
  23569. IS_REFLECTION_LINEAR: boolean;
  23570. /**
  23571. * If the refraction texture on this material is in linear color space
  23572. * @hidden
  23573. */
  23574. IS_REFRACTION_LINEAR: boolean;
  23575. EXPOSURE: boolean;
  23576. constructor();
  23577. setReflectionMode(modeToEnable: string): void;
  23578. }
  23579. /**
  23580. * This is the default material used in Babylon. It is the best trade off between quality
  23581. * and performances.
  23582. * @see http://doc.babylonjs.com/babylon101/materials
  23583. */
  23584. class StandardMaterial extends PushMaterial {
  23585. private _diffuseTexture;
  23586. /**
  23587. * The basic texture of the material as viewed under a light.
  23588. */
  23589. diffuseTexture: Nullable<BaseTexture>;
  23590. private _ambientTexture;
  23591. /**
  23592. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  23593. */
  23594. ambientTexture: Nullable<BaseTexture>;
  23595. private _opacityTexture;
  23596. /**
  23597. * Define the transparency of the material from a texture.
  23598. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  23599. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  23600. */
  23601. opacityTexture: Nullable<BaseTexture>;
  23602. private _reflectionTexture;
  23603. /**
  23604. * Define the texture used to display the reflection.
  23605. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23606. */
  23607. reflectionTexture: Nullable<BaseTexture>;
  23608. private _emissiveTexture;
  23609. /**
  23610. * Define texture of the material as if self lit.
  23611. * This will be mixed in the final result even in the absence of light.
  23612. */
  23613. emissiveTexture: Nullable<BaseTexture>;
  23614. private _specularTexture;
  23615. /**
  23616. * Define how the color and intensity of the highlight given by the light in the material.
  23617. */
  23618. specularTexture: Nullable<BaseTexture>;
  23619. private _bumpTexture;
  23620. /**
  23621. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  23622. * 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.
  23623. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  23624. */
  23625. bumpTexture: Nullable<BaseTexture>;
  23626. private _lightmapTexture;
  23627. /**
  23628. * Complex lighting can be computationally expensive to compute at runtime.
  23629. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  23630. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  23631. */
  23632. lightmapTexture: Nullable<BaseTexture>;
  23633. private _refractionTexture;
  23634. /**
  23635. * Define the texture used to display the refraction.
  23636. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23637. */
  23638. refractionTexture: Nullable<BaseTexture>;
  23639. /**
  23640. * The color of the material lit by the environmental background lighting.
  23641. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  23642. */
  23643. ambientColor: Color3;
  23644. /**
  23645. * The basic color of the material as viewed under a light.
  23646. */
  23647. diffuseColor: Color3;
  23648. /**
  23649. * Define how the color and intensity of the highlight given by the light in the material.
  23650. */
  23651. specularColor: Color3;
  23652. /**
  23653. * Define the color of the material as if self lit.
  23654. * This will be mixed in the final result even in the absence of light.
  23655. */
  23656. emissiveColor: Color3;
  23657. /**
  23658. * Defines how sharp are the highlights in the material.
  23659. * The bigger the value the sharper giving a more glossy feeling to the result.
  23660. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  23661. */
  23662. specularPower: number;
  23663. private _useAlphaFromDiffuseTexture;
  23664. /**
  23665. * Does the transparency come from the diffuse texture alpha channel.
  23666. */
  23667. useAlphaFromDiffuseTexture: boolean;
  23668. private _useEmissiveAsIllumination;
  23669. /**
  23670. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  23671. */
  23672. useEmissiveAsIllumination: boolean;
  23673. private _linkEmissiveWithDiffuse;
  23674. /**
  23675. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  23676. * the emissive level when the final color is close to one.
  23677. */
  23678. linkEmissiveWithDiffuse: boolean;
  23679. private _useSpecularOverAlpha;
  23680. /**
  23681. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  23682. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  23683. */
  23684. useSpecularOverAlpha: boolean;
  23685. private _useReflectionOverAlpha;
  23686. /**
  23687. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  23688. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  23689. */
  23690. useReflectionOverAlpha: boolean;
  23691. private _disableLighting;
  23692. /**
  23693. * Does lights from the scene impacts this material.
  23694. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  23695. */
  23696. disableLighting: boolean;
  23697. private _useObjectSpaceNormalMap;
  23698. /**
  23699. * Allows using an object space normal map (instead of tangent space).
  23700. */
  23701. useObjectSpaceNormalMap: boolean;
  23702. private _useParallax;
  23703. /**
  23704. * Is parallax enabled or not.
  23705. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  23706. */
  23707. useParallax: boolean;
  23708. private _useParallaxOcclusion;
  23709. /**
  23710. * Is parallax occlusion enabled or not.
  23711. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  23712. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  23713. */
  23714. useParallaxOcclusion: boolean;
  23715. /**
  23716. * 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.
  23717. */
  23718. parallaxScaleBias: number;
  23719. private _roughness;
  23720. /**
  23721. * Helps to define how blurry the reflections should appears in the material.
  23722. */
  23723. roughness: number;
  23724. /**
  23725. * In case of refraction, define the value of the indice of refraction.
  23726. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23727. */
  23728. indexOfRefraction: number;
  23729. /**
  23730. * Invert the refraction texture alongside the y axis.
  23731. * It can be useful with procedural textures or probe for instance.
  23732. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23733. */
  23734. invertRefractionY: boolean;
  23735. /**
  23736. * Defines the alpha limits in alpha test mode.
  23737. */
  23738. alphaCutOff: number;
  23739. private _useLightmapAsShadowmap;
  23740. /**
  23741. * In case of light mapping, define whether the map contains light or shadow informations.
  23742. */
  23743. useLightmapAsShadowmap: boolean;
  23744. private _diffuseFresnelParameters;
  23745. /**
  23746. * Define the diffuse fresnel parameters of the material.
  23747. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23748. */
  23749. diffuseFresnelParameters: FresnelParameters;
  23750. private _opacityFresnelParameters;
  23751. /**
  23752. * Define the opacity fresnel parameters of the material.
  23753. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23754. */
  23755. opacityFresnelParameters: FresnelParameters;
  23756. private _reflectionFresnelParameters;
  23757. /**
  23758. * Define the reflection fresnel parameters of the material.
  23759. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23760. */
  23761. reflectionFresnelParameters: FresnelParameters;
  23762. private _refractionFresnelParameters;
  23763. /**
  23764. * Define the refraction fresnel parameters of the material.
  23765. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23766. */
  23767. refractionFresnelParameters: FresnelParameters;
  23768. private _emissiveFresnelParameters;
  23769. /**
  23770. * Define the emissive fresnel parameters of the material.
  23771. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23772. */
  23773. emissiveFresnelParameters: FresnelParameters;
  23774. private _useReflectionFresnelFromSpecular;
  23775. /**
  23776. * If true automatically deducts the fresnels values from the material specularity.
  23777. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23778. */
  23779. useReflectionFresnelFromSpecular: boolean;
  23780. private _useGlossinessFromSpecularMapAlpha;
  23781. /**
  23782. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  23783. */
  23784. useGlossinessFromSpecularMapAlpha: boolean;
  23785. private _maxSimultaneousLights;
  23786. /**
  23787. * Defines the maximum number of lights that can be used in the material
  23788. */
  23789. maxSimultaneousLights: number;
  23790. private _invertNormalMapX;
  23791. /**
  23792. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  23793. */
  23794. invertNormalMapX: boolean;
  23795. private _invertNormalMapY;
  23796. /**
  23797. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  23798. */
  23799. invertNormalMapY: boolean;
  23800. private _twoSidedLighting;
  23801. /**
  23802. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  23803. */
  23804. twoSidedLighting: boolean;
  23805. /**
  23806. * Default configuration related to image processing available in the standard Material.
  23807. */
  23808. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23809. /**
  23810. * Gets the image processing configuration used either in this material.
  23811. */
  23812. /**
  23813. * Sets the Default image processing configuration used either in the this material.
  23814. *
  23815. * If sets to null, the scene one is in use.
  23816. */
  23817. imageProcessingConfiguration: ImageProcessingConfiguration;
  23818. /**
  23819. * Keep track of the image processing observer to allow dispose and replace.
  23820. */
  23821. private _imageProcessingObserver;
  23822. /**
  23823. * Attaches a new image processing configuration to the Standard Material.
  23824. * @param configuration
  23825. */
  23826. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23827. /**
  23828. * Gets wether the color curves effect is enabled.
  23829. */
  23830. /**
  23831. * Sets wether the color curves effect is enabled.
  23832. */
  23833. cameraColorCurvesEnabled: boolean;
  23834. /**
  23835. * Gets wether the color grading effect is enabled.
  23836. */
  23837. /**
  23838. * Gets wether the color grading effect is enabled.
  23839. */
  23840. cameraColorGradingEnabled: boolean;
  23841. /**
  23842. * Gets wether tonemapping is enabled or not.
  23843. */
  23844. /**
  23845. * Sets wether tonemapping is enabled or not
  23846. */
  23847. cameraToneMappingEnabled: boolean;
  23848. /**
  23849. * The camera exposure used on this material.
  23850. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23851. * This corresponds to a photographic exposure.
  23852. */
  23853. /**
  23854. * The camera exposure used on this material.
  23855. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23856. * This corresponds to a photographic exposure.
  23857. */
  23858. cameraExposure: number;
  23859. /**
  23860. * Gets The camera contrast used on this material.
  23861. */
  23862. /**
  23863. * Sets The camera contrast used on this material.
  23864. */
  23865. cameraContrast: number;
  23866. /**
  23867. * Gets the Color Grading 2D Lookup Texture.
  23868. */
  23869. /**
  23870. * Sets the Color Grading 2D Lookup Texture.
  23871. */
  23872. cameraColorGradingTexture: Nullable<BaseTexture>;
  23873. /**
  23874. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23875. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23876. * 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;
  23877. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23878. */
  23879. /**
  23880. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23881. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23882. * 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;
  23883. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23884. */
  23885. cameraColorCurves: Nullable<ColorCurves>;
  23886. /**
  23887. * Custom callback helping to override the default shader used in the material.
  23888. */
  23889. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  23890. protected _renderTargets: SmartArray<RenderTargetTexture>;
  23891. protected _worldViewProjectionMatrix: Matrix;
  23892. protected _globalAmbientColor: Color3;
  23893. protected _useLogarithmicDepth: boolean;
  23894. /**
  23895. * Instantiates a new standard material.
  23896. * This is the default material used in Babylon. It is the best trade off between quality
  23897. * and performances.
  23898. * @see http://doc.babylonjs.com/babylon101/materials
  23899. * @param name Define the name of the material in the scene
  23900. * @param scene Define the scene the material belong to
  23901. */
  23902. constructor(name: string, scene: Scene);
  23903. /**
  23904. * Gets a boolean indicating that current material needs to register RTT
  23905. */
  23906. readonly hasRenderTargetTextures: boolean;
  23907. /**
  23908. * Gets the current class name of the material e.g. "StandardMaterial"
  23909. * Mainly use in serialization.
  23910. * @returns the class name
  23911. */
  23912. getClassName(): string;
  23913. /**
  23914. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  23915. * You can try switching to logarithmic depth.
  23916. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  23917. */
  23918. useLogarithmicDepth: boolean;
  23919. /**
  23920. * Specifies if the material will require alpha blending
  23921. * @returns a boolean specifying if alpha blending is needed
  23922. */
  23923. needAlphaBlending(): boolean;
  23924. /**
  23925. * Specifies if this material should be rendered in alpha test mode
  23926. * @returns a boolean specifying if an alpha test is needed.
  23927. */
  23928. needAlphaTesting(): boolean;
  23929. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  23930. /**
  23931. * Get the texture used for alpha test purpose.
  23932. * @returns the diffuse texture in case of the standard material.
  23933. */
  23934. getAlphaTestTexture(): Nullable<BaseTexture>;
  23935. /**
  23936. * Get if the submesh is ready to be used and all its information available.
  23937. * Child classes can use it to update shaders
  23938. * @param mesh defines the mesh to check
  23939. * @param subMesh defines which submesh to check
  23940. * @param useInstances specifies that instances should be used
  23941. * @returns a boolean indicating that the submesh is ready or not
  23942. */
  23943. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23944. /**
  23945. * Builds the material UBO layouts.
  23946. * Used internally during the effect preparation.
  23947. */
  23948. buildUniformLayout(): void;
  23949. /**
  23950. * Unbinds the material from the mesh
  23951. */
  23952. unbind(): void;
  23953. /**
  23954. * Binds the submesh to this material by preparing the effect and shader to draw
  23955. * @param world defines the world transformation matrix
  23956. * @param mesh defines the mesh containing the submesh
  23957. * @param subMesh defines the submesh to bind the material to
  23958. */
  23959. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23960. /**
  23961. * Get the list of animatables in the material.
  23962. * @returns the list of animatables object used in the material
  23963. */
  23964. getAnimatables(): IAnimatable[];
  23965. /**
  23966. * Gets the active textures from the material
  23967. * @returns an array of textures
  23968. */
  23969. getActiveTextures(): BaseTexture[];
  23970. /**
  23971. * Specifies if the material uses a texture
  23972. * @param texture defines the texture to check against the material
  23973. * @returns a boolean specifying if the material uses the texture
  23974. */
  23975. hasTexture(texture: BaseTexture): boolean;
  23976. /**
  23977. * Disposes the material
  23978. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23979. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23980. */
  23981. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  23982. /**
  23983. * Makes a duplicate of the material, and gives it a new name
  23984. * @param name defines the new name for the duplicated material
  23985. * @returns the cloned material
  23986. */
  23987. clone(name: string): StandardMaterial;
  23988. /**
  23989. * Serializes this material in a JSON representation
  23990. * @returns the serialized material object
  23991. */
  23992. serialize(): any;
  23993. /**
  23994. * Creates a standard material from parsed material data
  23995. * @param source defines the JSON represnetation of the material
  23996. * @param scene defines the hosting scene
  23997. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23998. * @returns a new material
  23999. */
  24000. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  24001. private static _DiffuseTextureEnabled;
  24002. /**
  24003. * Are diffuse textures enabled in the application.
  24004. */
  24005. static DiffuseTextureEnabled: boolean;
  24006. private static _AmbientTextureEnabled;
  24007. /**
  24008. * Are ambient textures enabled in the application.
  24009. */
  24010. static AmbientTextureEnabled: boolean;
  24011. private static _OpacityTextureEnabled;
  24012. /**
  24013. * Are opacity textures enabled in the application.
  24014. */
  24015. static OpacityTextureEnabled: boolean;
  24016. private static _ReflectionTextureEnabled;
  24017. /**
  24018. * Are reflection textures enabled in the application.
  24019. */
  24020. static ReflectionTextureEnabled: boolean;
  24021. private static _EmissiveTextureEnabled;
  24022. /**
  24023. * Are emissive textures enabled in the application.
  24024. */
  24025. static EmissiveTextureEnabled: boolean;
  24026. private static _SpecularTextureEnabled;
  24027. /**
  24028. * Are specular textures enabled in the application.
  24029. */
  24030. static SpecularTextureEnabled: boolean;
  24031. private static _BumpTextureEnabled;
  24032. /**
  24033. * Are bump textures enabled in the application.
  24034. */
  24035. static BumpTextureEnabled: boolean;
  24036. private static _LightmapTextureEnabled;
  24037. /**
  24038. * Are lightmap textures enabled in the application.
  24039. */
  24040. static LightmapTextureEnabled: boolean;
  24041. private static _RefractionTextureEnabled;
  24042. /**
  24043. * Are refraction textures enabled in the application.
  24044. */
  24045. static RefractionTextureEnabled: boolean;
  24046. private static _ColorGradingTextureEnabled;
  24047. /**
  24048. * Are color grading textures enabled in the application.
  24049. */
  24050. static ColorGradingTextureEnabled: boolean;
  24051. private static _FresnelEnabled;
  24052. /**
  24053. * Are fresnels enabled in the application.
  24054. */
  24055. static FresnelEnabled: boolean;
  24056. }
  24057. }
  24058. declare module BABYLON {
  24059. /**
  24060. * Uniform buffer objects.
  24061. *
  24062. * Handles blocks of uniform on the GPU.
  24063. *
  24064. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  24065. *
  24066. * For more information, please refer to :
  24067. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  24068. */
  24069. class UniformBuffer {
  24070. private _engine;
  24071. private _buffer;
  24072. private _data;
  24073. private _bufferData;
  24074. private _dynamic?;
  24075. private _uniformLocations;
  24076. private _uniformSizes;
  24077. private _uniformLocationPointer;
  24078. private _needSync;
  24079. private _noUBO;
  24080. private _currentEffect;
  24081. private static _MAX_UNIFORM_SIZE;
  24082. private static _tempBuffer;
  24083. /**
  24084. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  24085. * This is dynamic to allow compat with webgl 1 and 2.
  24086. * You will need to pass the name of the uniform as well as the value.
  24087. */
  24088. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  24089. /**
  24090. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  24091. * This is dynamic to allow compat with webgl 1 and 2.
  24092. * You will need to pass the name of the uniform as well as the value.
  24093. */
  24094. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  24095. /**
  24096. * Lambda to Update a single float in a uniform buffer.
  24097. * This is dynamic to allow compat with webgl 1 and 2.
  24098. * You will need to pass the name of the uniform as well as the value.
  24099. */
  24100. updateFloat: (name: string, x: number) => void;
  24101. /**
  24102. * Lambda to Update a vec2 of float in a uniform buffer.
  24103. * This is dynamic to allow compat with webgl 1 and 2.
  24104. * You will need to pass the name of the uniform as well as the value.
  24105. */
  24106. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  24107. /**
  24108. * Lambda to Update a vec3 of float in a uniform buffer.
  24109. * This is dynamic to allow compat with webgl 1 and 2.
  24110. * You will need to pass the name of the uniform as well as the value.
  24111. */
  24112. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  24113. /**
  24114. * Lambda to Update a vec4 of float in a uniform buffer.
  24115. * This is dynamic to allow compat with webgl 1 and 2.
  24116. * You will need to pass the name of the uniform as well as the value.
  24117. */
  24118. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  24119. /**
  24120. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  24121. * This is dynamic to allow compat with webgl 1 and 2.
  24122. * You will need to pass the name of the uniform as well as the value.
  24123. */
  24124. updateMatrix: (name: string, mat: Matrix) => void;
  24125. /**
  24126. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  24127. * This is dynamic to allow compat with webgl 1 and 2.
  24128. * You will need to pass the name of the uniform as well as the value.
  24129. */
  24130. updateVector3: (name: string, vector: Vector3) => void;
  24131. /**
  24132. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  24133. * This is dynamic to allow compat with webgl 1 and 2.
  24134. * You will need to pass the name of the uniform as well as the value.
  24135. */
  24136. updateVector4: (name: string, vector: Vector4) => void;
  24137. /**
  24138. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  24139. * This is dynamic to allow compat with webgl 1 and 2.
  24140. * You will need to pass the name of the uniform as well as the value.
  24141. */
  24142. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  24143. /**
  24144. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  24145. * This is dynamic to allow compat with webgl 1 and 2.
  24146. * You will need to pass the name of the uniform as well as the value.
  24147. */
  24148. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  24149. /**
  24150. * Instantiates a new Uniform buffer objects.
  24151. *
  24152. * Handles blocks of uniform on the GPU.
  24153. *
  24154. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  24155. *
  24156. * For more information, please refer to :
  24157. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  24158. * @param engine Define the engine the buffer is associated with
  24159. * @param data Define the data contained in the buffer
  24160. * @param dynamic Define if the buffer is updatable
  24161. */
  24162. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  24163. /**
  24164. * Indicates if the buffer is using the WebGL2 UBO implementation,
  24165. * or just falling back on setUniformXXX calls.
  24166. */
  24167. readonly useUbo: boolean;
  24168. /**
  24169. * Indicates if the WebGL underlying uniform buffer is in sync
  24170. * with the javascript cache data.
  24171. */
  24172. readonly isSync: boolean;
  24173. /**
  24174. * Indicates if the WebGL underlying uniform buffer is dynamic.
  24175. * Also, a dynamic UniformBuffer will disable cache verification and always
  24176. * update the underlying WebGL uniform buffer to the GPU.
  24177. * @returns if Dynamic, otherwise false
  24178. */
  24179. isDynamic(): boolean;
  24180. /**
  24181. * The data cache on JS side.
  24182. * @returns the underlying data as a float array
  24183. */
  24184. getData(): Float32Array;
  24185. /**
  24186. * The underlying WebGL Uniform buffer.
  24187. * @returns the webgl buffer
  24188. */
  24189. getBuffer(): Nullable<WebGLBuffer>;
  24190. /**
  24191. * std140 layout specifies how to align data within an UBO structure.
  24192. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  24193. * for specs.
  24194. */
  24195. private _fillAlignment;
  24196. /**
  24197. * Adds an uniform in the buffer.
  24198. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  24199. * for the layout to be correct !
  24200. * @param name Name of the uniform, as used in the uniform block in the shader.
  24201. * @param size Data size, or data directly.
  24202. */
  24203. addUniform(name: string, size: number | number[]): void;
  24204. /**
  24205. * Adds a Matrix 4x4 to the uniform buffer.
  24206. * @param name Name of the uniform, as used in the uniform block in the shader.
  24207. * @param mat A 4x4 matrix.
  24208. */
  24209. addMatrix(name: string, mat: Matrix): void;
  24210. /**
  24211. * Adds a vec2 to the uniform buffer.
  24212. * @param name Name of the uniform, as used in the uniform block in the shader.
  24213. * @param x Define the x component value of the vec2
  24214. * @param y Define the y component value of the vec2
  24215. */
  24216. addFloat2(name: string, x: number, y: number): void;
  24217. /**
  24218. * Adds a vec3 to the uniform buffer.
  24219. * @param name Name of the uniform, as used in the uniform block in the shader.
  24220. * @param x Define the x component value of the vec3
  24221. * @param y Define the y component value of the vec3
  24222. * @param z Define the z component value of the vec3
  24223. */
  24224. addFloat3(name: string, x: number, y: number, z: number): void;
  24225. /**
  24226. * Adds a vec3 to the uniform buffer.
  24227. * @param name Name of the uniform, as used in the uniform block in the shader.
  24228. * @param color Define the vec3 from a Color
  24229. */
  24230. addColor3(name: string, color: Color3): void;
  24231. /**
  24232. * Adds a vec4 to the uniform buffer.
  24233. * @param name Name of the uniform, as used in the uniform block in the shader.
  24234. * @param color Define the rgb components from a Color
  24235. * @param alpha Define the a component of the vec4
  24236. */
  24237. addColor4(name: string, color: Color3, alpha: number): void;
  24238. /**
  24239. * Adds a vec3 to the uniform buffer.
  24240. * @param name Name of the uniform, as used in the uniform block in the shader.
  24241. * @param vector Define the vec3 components from a Vector
  24242. */
  24243. addVector3(name: string, vector: Vector3): void;
  24244. /**
  24245. * Adds a Matrix 3x3 to the uniform buffer.
  24246. * @param name Name of the uniform, as used in the uniform block in the shader.
  24247. */
  24248. addMatrix3x3(name: string): void;
  24249. /**
  24250. * Adds a Matrix 2x2 to the uniform buffer.
  24251. * @param name Name of the uniform, as used in the uniform block in the shader.
  24252. */
  24253. addMatrix2x2(name: string): void;
  24254. /**
  24255. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  24256. */
  24257. create(): void;
  24258. /** @hidden */
  24259. _rebuild(): void;
  24260. /**
  24261. * Updates the WebGL Uniform Buffer on the GPU.
  24262. * If the `dynamic` flag is set to true, no cache comparison is done.
  24263. * Otherwise, the buffer will be updated only if the cache differs.
  24264. */
  24265. update(): void;
  24266. /**
  24267. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  24268. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  24269. * @param data Define the flattened data
  24270. * @param size Define the size of the data.
  24271. */
  24272. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  24273. private _updateMatrix3x3ForUniform;
  24274. private _updateMatrix3x3ForEffect;
  24275. private _updateMatrix2x2ForEffect;
  24276. private _updateMatrix2x2ForUniform;
  24277. private _updateFloatForEffect;
  24278. private _updateFloatForUniform;
  24279. private _updateFloat2ForEffect;
  24280. private _updateFloat2ForUniform;
  24281. private _updateFloat3ForEffect;
  24282. private _updateFloat3ForUniform;
  24283. private _updateFloat4ForEffect;
  24284. private _updateFloat4ForUniform;
  24285. private _updateMatrixForEffect;
  24286. private _updateMatrixForUniform;
  24287. private _updateVector3ForEffect;
  24288. private _updateVector3ForUniform;
  24289. private _updateVector4ForEffect;
  24290. private _updateVector4ForUniform;
  24291. private _updateColor3ForEffect;
  24292. private _updateColor3ForUniform;
  24293. private _updateColor4ForEffect;
  24294. private _updateColor4ForUniform;
  24295. /**
  24296. * Sets a sampler uniform on the effect.
  24297. * @param name Define the name of the sampler.
  24298. * @param texture Define the texture to set in the sampler
  24299. */
  24300. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  24301. /**
  24302. * Directly updates the value of the uniform in the cache AND on the GPU.
  24303. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  24304. * @param data Define the flattened data
  24305. */
  24306. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  24307. /**
  24308. * Binds this uniform buffer to an effect.
  24309. * @param effect Define the effect to bind the buffer to
  24310. * @param name Name of the uniform block in the shader.
  24311. */
  24312. bindToEffect(effect: Effect, name: string): void;
  24313. /**
  24314. * Disposes the uniform buffer.
  24315. */
  24316. dispose(): void;
  24317. }
  24318. }
  24319. declare module BABYLON {
  24320. /**
  24321. * Defines a target to use with MorphTargetManager
  24322. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24323. */
  24324. class MorphTarget implements IAnimatable {
  24325. /** defines the name of the target */
  24326. name: string;
  24327. /**
  24328. * Gets or sets the list of animations
  24329. */
  24330. animations: Animation[];
  24331. private _scene;
  24332. private _positions;
  24333. private _normals;
  24334. private _tangents;
  24335. private _influence;
  24336. /**
  24337. * Observable raised when the influence changes
  24338. */
  24339. onInfluenceChanged: Observable<boolean>;
  24340. /** @hidden */
  24341. _onDataLayoutChanged: Observable<void>;
  24342. /**
  24343. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  24344. */
  24345. influence: number;
  24346. /**
  24347. * Gets or sets the id of the morph Target
  24348. */
  24349. id: string;
  24350. private _animationPropertiesOverride;
  24351. /**
  24352. * Gets or sets the animation properties override
  24353. */
  24354. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24355. /**
  24356. * Creates a new MorphTarget
  24357. * @param name defines the name of the target
  24358. * @param influence defines the influence to use
  24359. */
  24360. constructor(
  24361. /** defines the name of the target */
  24362. name: string, influence?: number, scene?: Nullable<Scene>);
  24363. /**
  24364. * Gets a boolean defining if the target contains position data
  24365. */
  24366. readonly hasPositions: boolean;
  24367. /**
  24368. * Gets a boolean defining if the target contains normal data
  24369. */
  24370. readonly hasNormals: boolean;
  24371. /**
  24372. * Gets a boolean defining if the target contains tangent data
  24373. */
  24374. readonly hasTangents: boolean;
  24375. /**
  24376. * Affects position data to this target
  24377. * @param data defines the position data to use
  24378. */
  24379. setPositions(data: Nullable<FloatArray>): void;
  24380. /**
  24381. * Gets the position data stored in this target
  24382. * @returns a FloatArray containing the position data (or null if not present)
  24383. */
  24384. getPositions(): Nullable<FloatArray>;
  24385. /**
  24386. * Affects normal data to this target
  24387. * @param data defines the normal data to use
  24388. */
  24389. setNormals(data: Nullable<FloatArray>): void;
  24390. /**
  24391. * Gets the normal data stored in this target
  24392. * @returns a FloatArray containing the normal data (or null if not present)
  24393. */
  24394. getNormals(): Nullable<FloatArray>;
  24395. /**
  24396. * Affects tangent data to this target
  24397. * @param data defines the tangent data to use
  24398. */
  24399. setTangents(data: Nullable<FloatArray>): void;
  24400. /**
  24401. * Gets the tangent data stored in this target
  24402. * @returns a FloatArray containing the tangent data (or null if not present)
  24403. */
  24404. getTangents(): Nullable<FloatArray>;
  24405. /**
  24406. * Serializes the current target into a Serialization object
  24407. * @returns the serialized object
  24408. */
  24409. serialize(): any;
  24410. /**
  24411. * Returns the string "MorphTarget"
  24412. * @returns "MorphTarget"
  24413. */
  24414. getClassName(): string;
  24415. /**
  24416. * Creates a new target from serialized data
  24417. * @param serializationObject defines the serialized data to use
  24418. * @returns a new MorphTarget
  24419. */
  24420. static Parse(serializationObject: any): MorphTarget;
  24421. /**
  24422. * Creates a MorphTarget from mesh data
  24423. * @param mesh defines the source mesh
  24424. * @param name defines the name to use for the new target
  24425. * @param influence defines the influence to attach to the target
  24426. * @returns a new MorphTarget
  24427. */
  24428. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  24429. }
  24430. }
  24431. declare module BABYLON {
  24432. /**
  24433. * This class is used to deform meshes using morphing between different targets
  24434. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24435. */
  24436. class MorphTargetManager {
  24437. private _targets;
  24438. private _targetInfluenceChangedObservers;
  24439. private _targetDataLayoutChangedObservers;
  24440. private _activeTargets;
  24441. private _scene;
  24442. private _influences;
  24443. private _supportsNormals;
  24444. private _supportsTangents;
  24445. private _vertexCount;
  24446. private _uniqueId;
  24447. private _tempInfluences;
  24448. /**
  24449. * Creates a new MorphTargetManager
  24450. * @param scene defines the current scene
  24451. */
  24452. constructor(scene?: Nullable<Scene>);
  24453. /**
  24454. * Gets the unique ID of this manager
  24455. */
  24456. readonly uniqueId: number;
  24457. /**
  24458. * Gets the number of vertices handled by this manager
  24459. */
  24460. readonly vertexCount: number;
  24461. /**
  24462. * Gets a boolean indicating if this manager supports morphing of normals
  24463. */
  24464. readonly supportsNormals: boolean;
  24465. /**
  24466. * Gets a boolean indicating if this manager supports morphing of tangents
  24467. */
  24468. readonly supportsTangents: boolean;
  24469. /**
  24470. * Gets the number of targets stored in this manager
  24471. */
  24472. readonly numTargets: number;
  24473. /**
  24474. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24475. */
  24476. readonly numInfluencers: number;
  24477. /**
  24478. * Gets the list of influences (one per target)
  24479. */
  24480. readonly influences: Float32Array;
  24481. /**
  24482. * Gets the active target at specified index. An active target is a target with an influence > 0
  24483. * @param index defines the index to check
  24484. * @returns the requested target
  24485. */
  24486. getActiveTarget(index: number): MorphTarget;
  24487. /**
  24488. * Gets the target at specified index
  24489. * @param index defines the index to check
  24490. * @returns the requested target
  24491. */
  24492. getTarget(index: number): MorphTarget;
  24493. /**
  24494. * Add a new target to this manager
  24495. * @param target defines the target to add
  24496. */
  24497. addTarget(target: MorphTarget): void;
  24498. /**
  24499. * Removes a target from the manager
  24500. * @param target defines the target to remove
  24501. */
  24502. removeTarget(target: MorphTarget): void;
  24503. /**
  24504. * Serializes the current manager into a Serialization object
  24505. * @returns the serialized object
  24506. */
  24507. serialize(): any;
  24508. private _syncActiveTargets;
  24509. /**
  24510. * Syncrhonize the targets with all the meshes using this morph target manager
  24511. */
  24512. synchronize(): void;
  24513. /**
  24514. * Creates a new MorphTargetManager from serialized data
  24515. * @param serializationObject defines the serialized data
  24516. * @param scene defines the hosting scene
  24517. * @returns the new MorphTargetManager
  24518. */
  24519. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24520. }
  24521. }
  24522. declare module BABYLON {
  24523. /**
  24524. * Class used to enable access to IndexedDB
  24525. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  24526. */
  24527. class Database implements IOfflineProvider {
  24528. private _callbackManifestChecked;
  24529. private _currentSceneUrl;
  24530. private _db;
  24531. private _enableSceneOffline;
  24532. private _enableTexturesOffline;
  24533. private _manifestVersionFound;
  24534. private _mustUpdateRessources;
  24535. private _hasReachedQuota;
  24536. private _isSupported;
  24537. private _idbFactory;
  24538. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  24539. private static IsUASupportingBlobStorage;
  24540. /**
  24541. * Gets a boolean indicating if Database storate is enabled (off by default)
  24542. */
  24543. static IDBStorageEnabled: boolean;
  24544. /**
  24545. * Gets a boolean indicating if scene must be saved in the database
  24546. */
  24547. readonly enableSceneOffline: boolean;
  24548. /**
  24549. * Gets a boolean indicating if textures must be saved in the database
  24550. */
  24551. readonly enableTexturesOffline: boolean;
  24552. /**
  24553. * Creates a new Database
  24554. * @param urlToScene defines the url to load the scene
  24555. * @param callbackManifestChecked defines the callback to use when manifest is checked
  24556. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  24557. */
  24558. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  24559. private static _ParseURL;
  24560. private static _ReturnFullUrlLocation;
  24561. private _checkManifestFile;
  24562. /**
  24563. * Open the database and make it available
  24564. * @param successCallback defines the callback to call on success
  24565. * @param errorCallback defines the callback to call on error
  24566. */
  24567. open(successCallback: () => void, errorCallback: () => void): void;
  24568. /**
  24569. * Loads an image from the database
  24570. * @param url defines the url to load from
  24571. * @param image defines the target DOM image
  24572. */
  24573. loadImage(url: string, image: HTMLImageElement): void;
  24574. private _loadImageFromDBAsync;
  24575. private _saveImageIntoDBAsync;
  24576. private _checkVersionFromDB;
  24577. private _loadVersionFromDBAsync;
  24578. private _saveVersionIntoDBAsync;
  24579. /**
  24580. * Loads a file from database
  24581. * @param url defines the URL to load from
  24582. * @param sceneLoaded defines a callback to call on success
  24583. * @param progressCallBack defines a callback to call when progress changed
  24584. * @param errorCallback defines a callback to call on error
  24585. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  24586. */
  24587. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  24588. private _loadFileAsync;
  24589. private _saveFileAsync;
  24590. }
  24591. }
  24592. declare module BABYLON {
  24593. /**
  24594. * Class used to enable access to offline support
  24595. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  24596. */
  24597. interface IOfflineProvider {
  24598. /**
  24599. * Gets a boolean indicating if scene must be saved in the database
  24600. */
  24601. enableSceneOffline: boolean;
  24602. /**
  24603. * Gets a boolean indicating if textures must be saved in the database
  24604. */
  24605. enableTexturesOffline: boolean;
  24606. /**
  24607. * Open the offline support and make it available
  24608. * @param successCallback defines the callback to call on success
  24609. * @param errorCallback defines the callback to call on error
  24610. */
  24611. open(successCallback: () => void, errorCallback: () => void): void;
  24612. /**
  24613. * Loads an image from the offline support
  24614. * @param url defines the url to load from
  24615. * @param image defines the target DOM image
  24616. */
  24617. loadImage(url: string, image: HTMLImageElement): void;
  24618. /**
  24619. * Loads a file from offline support
  24620. * @param url defines the URL to load from
  24621. * @param sceneLoaded defines a callback to call on success
  24622. * @param progressCallBack defines a callback to call when progress changed
  24623. * @param errorCallback defines a callback to call on error
  24624. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  24625. */
  24626. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  24627. }
  24628. }
  24629. declare module BABYLON {
  24630. /**
  24631. * Class used to store all common mesh properties
  24632. */
  24633. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24634. /** No occlusion */
  24635. static OCCLUSION_TYPE_NONE: number;
  24636. /** Occlusion set to optimisitic */
  24637. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24638. /** Occlusion set to strict */
  24639. static OCCLUSION_TYPE_STRICT: number;
  24640. /** Use an accurante occlusion algorithm */
  24641. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24642. /** Use a conservative occlusion algorithm */
  24643. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24644. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  24645. static readonly CULLINGSTRATEGY_STANDARD: number;
  24646. /** Culling strategy with bounding sphere only and then frustum culling */
  24647. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24648. /**
  24649. * No billboard
  24650. */
  24651. static readonly BILLBOARDMODE_NONE: number;
  24652. /** Billboard on X axis */
  24653. static readonly BILLBOARDMODE_X: number;
  24654. /** Billboard on Y axis */
  24655. static readonly BILLBOARDMODE_Y: number;
  24656. /** Billboard on Z axis */
  24657. static readonly BILLBOARDMODE_Z: number;
  24658. /** Billboard on all axes */
  24659. static readonly BILLBOARDMODE_ALL: number;
  24660. private _facetData;
  24661. /** Gets ot sets the culling strategy to use to find visible meshes */
  24662. cullingStrategy: number;
  24663. /**
  24664. * Gets the number of facets in the mesh
  24665. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24666. */
  24667. readonly facetNb: number;
  24668. /**
  24669. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24670. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24671. */
  24672. partitioningSubdivisions: number;
  24673. /**
  24674. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24675. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24676. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24677. */
  24678. partitioningBBoxRatio: number;
  24679. /**
  24680. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24681. * Works only for updatable meshes.
  24682. * Doesn't work with multi-materials
  24683. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24684. */
  24685. mustDepthSortFacets: boolean;
  24686. /**
  24687. * The location (Vector3) where the facet depth sort must be computed from.
  24688. * By default, the active camera position.
  24689. * Used only when facet depth sort is enabled
  24690. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24691. */
  24692. facetDepthSortFrom: Vector3;
  24693. /**
  24694. * gets a boolean indicating if facetData is enabled
  24695. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24696. */
  24697. readonly isFacetDataEnabled: boolean;
  24698. /** @hidden */
  24699. _updateNonUniformScalingState(value: boolean): boolean;
  24700. /**
  24701. * An event triggered when this mesh collides with another one
  24702. */
  24703. onCollideObservable: Observable<AbstractMesh>;
  24704. private _onCollideObserver;
  24705. /** Set a function to call when this mesh collides with another one */
  24706. onCollide: () => void;
  24707. /**
  24708. * An event triggered when the collision's position changes
  24709. */
  24710. onCollisionPositionChangeObservable: Observable<Vector3>;
  24711. private _onCollisionPositionChangeObserver;
  24712. /** Set a function to call when the collision's position changes */
  24713. onCollisionPositionChange: () => void;
  24714. /**
  24715. * An event triggered when material is changed
  24716. */
  24717. onMaterialChangedObservable: Observable<AbstractMesh>;
  24718. /**
  24719. * Gets or sets the orientation for POV movement & rotation
  24720. */
  24721. definedFacingForward: boolean;
  24722. /** @hidden */
  24723. _occlusionQuery: Nullable<WebGLQuery>;
  24724. private _visibility;
  24725. /**
  24726. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24727. */
  24728. /**
  24729. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24730. */
  24731. visibility: number;
  24732. /** Gets or sets the alpha index used to sort transparent meshes
  24733. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24734. */
  24735. alphaIndex: number;
  24736. /**
  24737. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24738. */
  24739. isVisible: boolean;
  24740. /**
  24741. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24742. */
  24743. isPickable: boolean;
  24744. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24745. showSubMeshesBoundingBox: boolean;
  24746. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24747. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24748. */
  24749. isBlocker: boolean;
  24750. /**
  24751. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24752. */
  24753. enablePointerMoveEvents: boolean;
  24754. /**
  24755. * Specifies the rendering group id for this mesh (0 by default)
  24756. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24757. */
  24758. renderingGroupId: number;
  24759. private _material;
  24760. /** Gets or sets current material */
  24761. material: Nullable<Material>;
  24762. private _receiveShadows;
  24763. /**
  24764. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24765. * @see http://doc.babylonjs.com/babylon101/shadows
  24766. */
  24767. receiveShadows: boolean;
  24768. /** Defines color to use when rendering outline */
  24769. outlineColor: Color3;
  24770. /** Define width to use when rendering outline */
  24771. outlineWidth: number;
  24772. /** Defines color to use when rendering overlay */
  24773. overlayColor: Color3;
  24774. /** Defines alpha to use when rendering overlay */
  24775. overlayAlpha: number;
  24776. private _hasVertexAlpha;
  24777. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24778. hasVertexAlpha: boolean;
  24779. private _useVertexColors;
  24780. /** 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) */
  24781. useVertexColors: boolean;
  24782. private _computeBonesUsingShaders;
  24783. /**
  24784. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24785. */
  24786. computeBonesUsingShaders: boolean;
  24787. private _numBoneInfluencers;
  24788. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24789. numBoneInfluencers: number;
  24790. private _applyFog;
  24791. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24792. applyFog: boolean;
  24793. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24794. useOctreeForRenderingSelection: boolean;
  24795. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24796. useOctreeForPicking: boolean;
  24797. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24798. useOctreeForCollisions: boolean;
  24799. private _layerMask;
  24800. /**
  24801. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24802. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24803. */
  24804. layerMask: number;
  24805. /**
  24806. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24807. */
  24808. alwaysSelectAsActiveMesh: boolean;
  24809. /**
  24810. * Gets or sets the current action manager
  24811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24812. */
  24813. actionManager: Nullable<ActionManager>;
  24814. private _checkCollisions;
  24815. private _collisionMask;
  24816. private _collisionGroup;
  24817. /**
  24818. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24819. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24820. */
  24821. ellipsoid: Vector3;
  24822. /**
  24823. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24824. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24825. */
  24826. ellipsoidOffset: Vector3;
  24827. private _collider;
  24828. private _oldPositionForCollisions;
  24829. private _diffPositionForCollisions;
  24830. /**
  24831. * Gets or sets a collision mask used to mask collisions (default is -1).
  24832. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24833. */
  24834. collisionMask: number;
  24835. /**
  24836. * Gets or sets the current collision group mask (-1 by default).
  24837. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24838. */
  24839. collisionGroup: number;
  24840. /**
  24841. * Defines edge width used when edgesRenderer is enabled
  24842. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24843. */
  24844. edgesWidth: number;
  24845. /**
  24846. * Defines edge color used when edgesRenderer is enabled
  24847. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24848. */
  24849. edgesColor: Color4;
  24850. /** @hidden */
  24851. _edgesRenderer: Nullable<IEdgesRenderer>;
  24852. /** @hidden */
  24853. _masterMesh: Nullable<AbstractMesh>;
  24854. /** @hidden */
  24855. _boundingInfo: Nullable<BoundingInfo>;
  24856. /** @hidden */
  24857. _renderId: number;
  24858. /**
  24859. * Gets or sets the list of subMeshes
  24860. * @see http://doc.babylonjs.com/how_to/multi_materials
  24861. */
  24862. subMeshes: SubMesh[];
  24863. /** @hidden */
  24864. _intersectionsInProgress: AbstractMesh[];
  24865. /** @hidden */
  24866. _unIndexed: boolean;
  24867. /** @hidden */
  24868. _lightSources: Light[];
  24869. /** @hidden */
  24870. readonly _positions: Nullable<Vector3[]>;
  24871. /** @hidden */
  24872. _waitingActions: any;
  24873. /** @hidden */
  24874. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24875. private _skeleton;
  24876. /** @hidden */
  24877. _bonesTransformMatrices: Nullable<Float32Array>;
  24878. /**
  24879. * Gets or sets a skeleton to apply skining transformations
  24880. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24881. */
  24882. skeleton: Nullable<Skeleton>;
  24883. /**
  24884. * An event triggered when the mesh is rebuilt.
  24885. */
  24886. onRebuildObservable: Observable<AbstractMesh>;
  24887. /**
  24888. * Creates a new AbstractMesh
  24889. * @param name defines the name of the mesh
  24890. * @param scene defines the hosting scene
  24891. */
  24892. constructor(name: string, scene?: Nullable<Scene>);
  24893. /**
  24894. * Returns the string "AbstractMesh"
  24895. * @returns "AbstractMesh"
  24896. */
  24897. getClassName(): string;
  24898. /**
  24899. * Gets a string representation of the current mesh
  24900. * @param fullDetails defines a boolean indicating if full details must be included
  24901. * @returns a string representation of the current mesh
  24902. */
  24903. toString(fullDetails?: boolean): string;
  24904. /** @hidden */
  24905. _rebuild(): void;
  24906. /** @hidden */
  24907. _resyncLightSources(): void;
  24908. /** @hidden */
  24909. _resyncLighSource(light: Light): void;
  24910. /** @hidden */
  24911. _unBindEffect(): void;
  24912. /** @hidden */
  24913. _removeLightSource(light: Light): void;
  24914. private _markSubMeshesAsDirty;
  24915. /** @hidden */
  24916. _markSubMeshesAsLightDirty(): void;
  24917. /** @hidden */
  24918. _markSubMeshesAsAttributesDirty(): void;
  24919. /** @hidden */
  24920. _markSubMeshesAsMiscDirty(): void;
  24921. /**
  24922. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24923. */
  24924. scaling: Vector3;
  24925. /**
  24926. * Returns true if the mesh is blocked. Implemented by child classes
  24927. */
  24928. readonly isBlocked: boolean;
  24929. /**
  24930. * Returns the mesh itself by default. Implemented by child classes
  24931. * @param camera defines the camera to use to pick the right LOD level
  24932. * @returns the currentAbstractMesh
  24933. */
  24934. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24935. /**
  24936. * Returns 0 by default. Implemented by child classes
  24937. * @returns an integer
  24938. */
  24939. getTotalVertices(): number;
  24940. /**
  24941. * Returns a positive integer : the total number of indices in this mesh geometry.
  24942. * @returns the numner of indices or zero if the mesh has no geometry.
  24943. */
  24944. getTotalIndices(): number;
  24945. /**
  24946. * Returns null by default. Implemented by child classes
  24947. * @returns null
  24948. */
  24949. getIndices(): Nullable<IndicesArray>;
  24950. /**
  24951. * Returns the array of the requested vertex data kind. Implemented by child classes
  24952. * @param kind defines the vertex data kind to use
  24953. * @returns null
  24954. */
  24955. getVerticesData(kind: string): Nullable<FloatArray>;
  24956. /**
  24957. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24958. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24959. * Note that a new underlying VertexBuffer object is created each call.
  24960. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24961. * @param kind defines vertex data kind:
  24962. * * BABYLON.VertexBuffer.PositionKind
  24963. * * BABYLON.VertexBuffer.UVKind
  24964. * * BABYLON.VertexBuffer.UV2Kind
  24965. * * BABYLON.VertexBuffer.UV3Kind
  24966. * * BABYLON.VertexBuffer.UV4Kind
  24967. * * BABYLON.VertexBuffer.UV5Kind
  24968. * * BABYLON.VertexBuffer.UV6Kind
  24969. * * BABYLON.VertexBuffer.ColorKind
  24970. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24971. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24972. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24973. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24974. * @param data defines the data source
  24975. * @param updatable defines if the data must be flagged as updatable (or static)
  24976. * @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
  24977. * @returns the current mesh
  24978. */
  24979. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24980. /**
  24981. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24982. * If the mesh has no geometry, it is simply returned as it is.
  24983. * @param kind defines vertex data kind:
  24984. * * BABYLON.VertexBuffer.PositionKind
  24985. * * BABYLON.VertexBuffer.UVKind
  24986. * * BABYLON.VertexBuffer.UV2Kind
  24987. * * BABYLON.VertexBuffer.UV3Kind
  24988. * * BABYLON.VertexBuffer.UV4Kind
  24989. * * BABYLON.VertexBuffer.UV5Kind
  24990. * * BABYLON.VertexBuffer.UV6Kind
  24991. * * BABYLON.VertexBuffer.ColorKind
  24992. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24993. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24994. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24995. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24996. * @param data defines the data source
  24997. * @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
  24998. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24999. * @returns the current mesh
  25000. */
  25001. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25002. /**
  25003. * Sets the mesh indices,
  25004. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25005. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25006. * @param totalVertices Defines the total number of vertices
  25007. * @returns the current mesh
  25008. */
  25009. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25010. /**
  25011. * Gets a boolean indicating if specific vertex data is present
  25012. * @param kind defines the vertex data kind to use
  25013. * @returns true is data kind is present
  25014. */
  25015. isVerticesDataPresent(kind: string): boolean;
  25016. /**
  25017. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25018. * @returns a BoundingInfo
  25019. */
  25020. getBoundingInfo(): BoundingInfo;
  25021. /**
  25022. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25023. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  25024. * @returns the current mesh
  25025. */
  25026. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  25027. /**
  25028. * Overwrite the current bounding info
  25029. * @param boundingInfo defines the new bounding info
  25030. * @returns the current mesh
  25031. */
  25032. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25033. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25034. readonly useBones: boolean;
  25035. /** @hidden */
  25036. _preActivate(): void;
  25037. /** @hidden */
  25038. _preActivateForIntermediateRendering(renderId: number): void;
  25039. /** @hidden */
  25040. _activate(renderId: number): void;
  25041. /**
  25042. * Gets the current world matrix
  25043. * @returns a Matrix
  25044. */
  25045. getWorldMatrix(): Matrix;
  25046. /** @hidden */
  25047. _getWorldMatrixDeterminant(): number;
  25048. /**
  25049. * Perform relative position change from the point of view of behind the front of the mesh.
  25050. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25051. * Supports definition of mesh facing forward or backward
  25052. * @param amountRight defines the distance on the right axis
  25053. * @param amountUp defines the distance on the up axis
  25054. * @param amountForward defines the distance on the forward axis
  25055. * @returns the current mesh
  25056. */
  25057. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25058. /**
  25059. * Calculate relative position change from the point of view of behind the front of the mesh.
  25060. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25061. * Supports definition of mesh facing forward or backward
  25062. * @param amountRight defines the distance on the right axis
  25063. * @param amountUp defines the distance on the up axis
  25064. * @param amountForward defines the distance on the forward axis
  25065. * @returns the new displacement vector
  25066. */
  25067. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25068. /**
  25069. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25070. * Supports definition of mesh facing forward or backward
  25071. * @param flipBack defines the flip
  25072. * @param twirlClockwise defines the twirl
  25073. * @param tiltRight defines the tilt
  25074. * @returns the current mesh
  25075. */
  25076. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25077. /**
  25078. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25079. * Supports definition of mesh facing forward or backward.
  25080. * @param flipBack defines the flip
  25081. * @param twirlClockwise defines the twirl
  25082. * @param tiltRight defines the tilt
  25083. * @returns the new rotation vector
  25084. */
  25085. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25086. /**
  25087. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  25088. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25089. * @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
  25090. * @returns the new bounding vectors
  25091. */
  25092. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25093. min: Vector3;
  25094. max: Vector3;
  25095. };
  25096. /**
  25097. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25098. * This means the mesh underlying bounding box and sphere are recomputed.
  25099. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25100. * @returns the current mesh
  25101. */
  25102. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25103. /** @hidden */
  25104. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25105. /** @hidden */
  25106. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25107. /** @hidden */
  25108. _updateBoundingInfo(): AbstractMesh;
  25109. /** @hidden */
  25110. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25111. /** @hidden */
  25112. protected _afterComputeWorldMatrix(): void;
  25113. /**
  25114. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25115. * A mesh is in the frustum if its bounding box intersects the frustum
  25116. * @param frustumPlanes defines the frustum to test
  25117. * @returns true if the mesh is in the frustum planes
  25118. */
  25119. isInFrustum(frustumPlanes: Plane[]): boolean;
  25120. /**
  25121. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25122. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25123. * @param frustumPlanes defines the frustum to test
  25124. * @returns true if the mesh is completely in the frustum planes
  25125. */
  25126. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25127. /**
  25128. * True if the mesh intersects another mesh or a SolidParticle object
  25129. * @param mesh defines a target mesh or SolidParticle to test
  25130. * @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)
  25131. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25132. * @returns true if there is an intersection
  25133. */
  25134. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25135. /**
  25136. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25137. * @param point defines the point to test
  25138. * @returns true if there is an intersection
  25139. */
  25140. intersectsPoint(point: Vector3): boolean;
  25141. /**
  25142. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25143. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25144. */
  25145. checkCollisions: boolean;
  25146. /**
  25147. * Gets Collider object used to compute collisions (not physics)
  25148. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25149. */
  25150. readonly collider: Collider;
  25151. /**
  25152. * Move the mesh using collision engine
  25153. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25154. * @param displacement defines the requested displacement vector
  25155. * @returns the current mesh
  25156. */
  25157. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25158. private _onCollisionPositionChange;
  25159. /** @hidden */
  25160. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25161. /** @hidden */
  25162. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25163. /** @hidden */
  25164. _checkCollision(collider: Collider): AbstractMesh;
  25165. /** @hidden */
  25166. _generatePointsArray(): boolean;
  25167. /**
  25168. * Checks if the passed Ray intersects with the mesh
  25169. * @param ray defines the ray to use
  25170. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25171. * @returns the picking info
  25172. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25173. */
  25174. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  25175. /**
  25176. * Clones the current mesh
  25177. * @param name defines the mesh name
  25178. * @param newParent defines the new mesh parent
  25179. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25180. * @returns the new mesh
  25181. */
  25182. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25183. /**
  25184. * Disposes all the submeshes of the current meshnp
  25185. * @returns the current mesh
  25186. */
  25187. releaseSubMeshes(): AbstractMesh;
  25188. /**
  25189. * Releases resources associated with this abstract mesh.
  25190. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25191. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25192. */
  25193. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25194. /**
  25195. * Adds the passed mesh as a child to the current mesh
  25196. * @param mesh defines the child mesh
  25197. * @returns the current mesh
  25198. */
  25199. addChild(mesh: AbstractMesh): AbstractMesh;
  25200. /**
  25201. * Removes the passed mesh from the current mesh children list
  25202. * @param mesh defines the child mesh
  25203. * @returns the current mesh
  25204. */
  25205. removeChild(mesh: AbstractMesh): AbstractMesh;
  25206. /** @hidden */
  25207. private _initFacetData;
  25208. /**
  25209. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25210. * This method can be called within the render loop.
  25211. * 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
  25212. * @returns the current mesh
  25213. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25214. */
  25215. updateFacetData(): AbstractMesh;
  25216. /**
  25217. * Returns the facetLocalNormals array.
  25218. * The normals are expressed in the mesh local spac
  25219. * @returns an array of Vector3
  25220. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25221. */
  25222. getFacetLocalNormals(): Vector3[];
  25223. /**
  25224. * Returns the facetLocalPositions array.
  25225. * The facet positions are expressed in the mesh local space
  25226. * @returns an array of Vector3
  25227. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25228. */
  25229. getFacetLocalPositions(): Vector3[];
  25230. /**
  25231. * Returns the facetLocalPartioning array
  25232. * @returns an array of array of numbers
  25233. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25234. */
  25235. getFacetLocalPartitioning(): number[][];
  25236. /**
  25237. * Returns the i-th facet position in the world system.
  25238. * This method allocates a new Vector3 per call
  25239. * @param i defines the facet index
  25240. * @returns a new Vector3
  25241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25242. */
  25243. getFacetPosition(i: number): Vector3;
  25244. /**
  25245. * Sets the reference Vector3 with the i-th facet position in the world system
  25246. * @param i defines the facet index
  25247. * @param ref defines the target vector
  25248. * @returns the current mesh
  25249. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25250. */
  25251. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25252. /**
  25253. * Returns the i-th facet normal in the world system.
  25254. * This method allocates a new Vector3 per call
  25255. * @param i defines the facet index
  25256. * @returns a new Vector3
  25257. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25258. */
  25259. getFacetNormal(i: number): Vector3;
  25260. /**
  25261. * Sets the reference Vector3 with the i-th facet normal in the world system
  25262. * @param i defines the facet index
  25263. * @param ref defines the target vector
  25264. * @returns the current mesh
  25265. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25266. */
  25267. getFacetNormalToRef(i: number, ref: Vector3): this;
  25268. /**
  25269. * 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)
  25270. * @param x defines x coordinate
  25271. * @param y defines y coordinate
  25272. * @param z defines z coordinate
  25273. * @returns the array of facet indexes
  25274. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25275. */
  25276. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25277. /**
  25278. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25279. * @param projected sets as the (x,y,z) world projection on the facet
  25280. * @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
  25281. * @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
  25282. * @param x defines x coordinate
  25283. * @param y defines y coordinate
  25284. * @param z defines z coordinate
  25285. * @returns the face index if found (or null instead)
  25286. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25287. */
  25288. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25289. /**
  25290. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25291. * @param projected sets as the (x,y,z) local projection on the facet
  25292. * @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
  25293. * @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
  25294. * @param x defines x coordinate
  25295. * @param y defines y coordinate
  25296. * @param z defines z coordinate
  25297. * @returns the face index if found (or null instead)
  25298. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25299. */
  25300. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25301. /**
  25302. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25303. * @returns the parameters
  25304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25305. */
  25306. getFacetDataParameters(): any;
  25307. /**
  25308. * Disables the feature FacetData and frees the related memory
  25309. * @returns the current mesh
  25310. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25311. */
  25312. disableFacetData(): AbstractMesh;
  25313. /**
  25314. * Updates the AbstractMesh indices array
  25315. * @param indices defines the data source
  25316. * @returns the current mesh
  25317. */
  25318. updateIndices(indices: IndicesArray): AbstractMesh;
  25319. /**
  25320. * Creates new normals data for the mesh
  25321. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25322. * @returns the current mesh
  25323. */
  25324. createNormals(updatable: boolean): AbstractMesh;
  25325. /**
  25326. * Align the mesh with a normal
  25327. * @param normal defines the normal to use
  25328. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25329. * @returns the current mesh
  25330. */
  25331. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25332. /** @hidden */
  25333. _checkOcclusionQuery(): boolean;
  25334. }
  25335. }
  25336. declare module BABYLON {
  25337. /**
  25338. * Class used to store data that will be store in GPU memory
  25339. */
  25340. class Buffer {
  25341. private _engine;
  25342. private _buffer;
  25343. /** @hidden */
  25344. _data: Nullable<DataArray>;
  25345. private _updatable;
  25346. private _instanced;
  25347. /**
  25348. * Gets the byte stride.
  25349. */
  25350. readonly byteStride: number;
  25351. /**
  25352. * Constructor
  25353. * @param engine the engine
  25354. * @param data the data to use for this buffer
  25355. * @param updatable whether the data is updatable
  25356. * @param stride the stride (optional)
  25357. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  25358. * @param instanced whether the buffer is instanced (optional)
  25359. * @param useBytes set to true if the stride in in bytes (optional)
  25360. */
  25361. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  25362. /**
  25363. * Create a new VertexBuffer based on the current buffer
  25364. * @param kind defines the vertex buffer kind (position, normal, etc.)
  25365. * @param offset defines offset in the buffer (0 by default)
  25366. * @param size defines the size in floats of attributes (position is 3 for instance)
  25367. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  25368. * @param instanced defines if the vertex buffer contains indexed data
  25369. * @param useBytes defines if the offset and stride are in bytes
  25370. * @returns the new vertex buffer
  25371. */
  25372. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  25373. /**
  25374. * Gets a boolean indicating if the Buffer is updatable?
  25375. * @returns true if the buffer is updatable
  25376. */
  25377. isUpdatable(): boolean;
  25378. /**
  25379. * Gets current buffer's data
  25380. * @returns a DataArray or null
  25381. */
  25382. getData(): Nullable<DataArray>;
  25383. /**
  25384. * Gets underlying native buffer
  25385. * @returns underlying native buffer
  25386. */
  25387. getBuffer(): Nullable<WebGLBuffer>;
  25388. /**
  25389. * Gets the stride in float32 units (i.e. byte stride / 4).
  25390. * May not be an integer if the byte stride is not divisible by 4.
  25391. * DEPRECATED. Use byteStride instead.
  25392. * @returns the stride in float32 units
  25393. */
  25394. getStrideSize(): number;
  25395. /**
  25396. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  25397. * @param data defines the data to store
  25398. */
  25399. create(data?: Nullable<DataArray>): void;
  25400. /** @hidden */
  25401. _rebuild(): void;
  25402. /**
  25403. * Update current buffer data
  25404. * @param data defines the data to store
  25405. */
  25406. update(data: DataArray): void;
  25407. /**
  25408. * Updates the data directly.
  25409. * @param data the new data
  25410. * @param offset the new offset
  25411. * @param vertexCount the vertex count (optional)
  25412. * @param useBytes set to true if the offset is in bytes
  25413. */
  25414. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  25415. /**
  25416. * Release all resources
  25417. */
  25418. dispose(): void;
  25419. }
  25420. }
  25421. declare module BABYLON {
  25422. /**
  25423. * Class for building Constructive Solid Geometry
  25424. */
  25425. class CSG {
  25426. private polygons;
  25427. /**
  25428. * The world matrix
  25429. */
  25430. matrix: Matrix;
  25431. /**
  25432. * Stores the position
  25433. */
  25434. position: Vector3;
  25435. /**
  25436. * Stores the rotation
  25437. */
  25438. rotation: Vector3;
  25439. /**
  25440. * Stores the rotation quaternion
  25441. */
  25442. rotationQuaternion: Nullable<Quaternion>;
  25443. /**
  25444. * Stores the scaling vector
  25445. */
  25446. scaling: Vector3;
  25447. /**
  25448. * Convert the BABYLON.Mesh to BABYLON.CSG
  25449. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  25450. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  25451. */
  25452. static FromMesh(mesh: Mesh): CSG;
  25453. /**
  25454. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  25455. * @param polygons Polygons used to construct a BABYLON.CSG solid
  25456. */
  25457. private static FromPolygons;
  25458. /**
  25459. * Clones, or makes a deep copy, of the BABYLON.CSG
  25460. * @returns A new BABYLON.CSG
  25461. */
  25462. clone(): CSG;
  25463. /**
  25464. * Unions this CSG with another CSG
  25465. * @param csg The CSG to union against this CSG
  25466. * @returns The unioned CSG
  25467. */
  25468. union(csg: CSG): CSG;
  25469. /**
  25470. * Unions this CSG with another CSG in place
  25471. * @param csg The CSG to union against this CSG
  25472. */
  25473. unionInPlace(csg: CSG): void;
  25474. /**
  25475. * Subtracts this CSG with another CSG
  25476. * @param csg The CSG to subtract against this CSG
  25477. * @returns A new BABYLON.CSG
  25478. */
  25479. subtract(csg: CSG): CSG;
  25480. /**
  25481. * Subtracts this CSG with another CSG in place
  25482. * @param csg The CSG to subtact against this CSG
  25483. */
  25484. subtractInPlace(csg: CSG): void;
  25485. /**
  25486. * Intersect this CSG with another CSG
  25487. * @param csg The CSG to intersect against this CSG
  25488. * @returns A new BABYLON.CSG
  25489. */
  25490. intersect(csg: CSG): CSG;
  25491. /**
  25492. * Intersects this CSG with another CSG in place
  25493. * @param csg The CSG to intersect against this CSG
  25494. */
  25495. intersectInPlace(csg: CSG): void;
  25496. /**
  25497. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  25498. * not modified.
  25499. * @returns A new BABYLON.CSG solid with solid and empty space switched
  25500. */
  25501. inverse(): CSG;
  25502. /**
  25503. * Inverses the BABYLON.CSG in place
  25504. */
  25505. inverseInPlace(): void;
  25506. /**
  25507. * This is used to keep meshes transformations so they can be restored
  25508. * when we build back a Babylon Mesh
  25509. * NB : All CSG operations are performed in world coordinates
  25510. * @param csg The BABYLON.CSG to copy the transform attributes from
  25511. * @returns This BABYLON.CSG
  25512. */
  25513. copyTransformAttributes(csg: CSG): CSG;
  25514. /**
  25515. * Build Raw mesh from CSG
  25516. * Coordinates here are in world space
  25517. * @param name The name of the mesh geometry
  25518. * @param scene The BABYLON.Scene
  25519. * @param keepSubMeshes Specifies if the submeshes should be kept
  25520. * @returns A new BABYLON.Mesh
  25521. */
  25522. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  25523. /**
  25524. * Build Mesh from CSG taking material and transforms into account
  25525. * @param name The name of the BABYLON.Mesh
  25526. * @param material The material of the BABYLON.Mesh
  25527. * @param scene The BABYLON.Scene
  25528. * @param keepSubMeshes Specifies if submeshes should be kept
  25529. * @returns The new BABYLON.Mesh
  25530. */
  25531. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  25532. }
  25533. }
  25534. declare module BABYLON {
  25535. /**
  25536. * Class used to store geometry data (vertex buffers + index buffer)
  25537. */
  25538. class Geometry implements IGetSetVerticesData {
  25539. /**
  25540. * Gets or sets the ID of the geometry
  25541. */
  25542. id: string;
  25543. /**
  25544. * Gets or sets the unique ID of the geometry
  25545. */
  25546. uniqueId: number;
  25547. /**
  25548. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25549. */
  25550. delayLoadState: number;
  25551. /**
  25552. * Gets the file containing the data to load when running in delay load state
  25553. */
  25554. delayLoadingFile: Nullable<string>;
  25555. /**
  25556. * Callback called when the geometry is updated
  25557. */
  25558. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25559. private _scene;
  25560. private _engine;
  25561. private _meshes;
  25562. private _totalVertices;
  25563. /** @hidden */
  25564. _indices: IndicesArray;
  25565. /** @hidden */
  25566. _vertexBuffers: {
  25567. [key: string]: VertexBuffer;
  25568. };
  25569. private _isDisposed;
  25570. private _extend;
  25571. private _boundingBias;
  25572. /** @hidden */
  25573. _delayInfo: Array<string>;
  25574. private _indexBuffer;
  25575. private _indexBufferIsUpdatable;
  25576. /** @hidden */
  25577. _boundingInfo: Nullable<BoundingInfo>;
  25578. /** @hidden */
  25579. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25580. /** @hidden */
  25581. _softwareSkinningFrameId: number;
  25582. private _vertexArrayObjects;
  25583. private _updatable;
  25584. /** @hidden */
  25585. _positions: Nullable<Vector3[]>;
  25586. /**
  25587. * 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
  25588. */
  25589. /**
  25590. * 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
  25591. */
  25592. boundingBias: Vector2;
  25593. /**
  25594. * Static function used to attach a new empty geometry to a mesh
  25595. * @param mesh defines the mesh to attach the geometry to
  25596. * @returns the new Geometry
  25597. */
  25598. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25599. /**
  25600. * Creates a new geometry
  25601. * @param id defines the unique ID
  25602. * @param scene defines the hosting scene
  25603. * @param vertexData defines the VertexData used to get geometry data
  25604. * @param updatable defines if geometry must be updatable (false by default)
  25605. * @param mesh defines the mesh that will be associated with the geometry
  25606. */
  25607. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25608. /**
  25609. * Gets the current extend of the geometry
  25610. */
  25611. readonly extend: {
  25612. minimum: Vector3;
  25613. maximum: Vector3;
  25614. };
  25615. /**
  25616. * Gets the hosting scene
  25617. * @returns the hosting Scene
  25618. */
  25619. getScene(): Scene;
  25620. /**
  25621. * Gets the hosting engine
  25622. * @returns the hosting Engine
  25623. */
  25624. getEngine(): Engine;
  25625. /**
  25626. * Defines if the geometry is ready to use
  25627. * @returns true if the geometry is ready to be used
  25628. */
  25629. isReady(): boolean;
  25630. /**
  25631. * Gets a value indicating that the geometry should not be serialized
  25632. */
  25633. readonly doNotSerialize: boolean;
  25634. /** @hidden */
  25635. _rebuild(): void;
  25636. /**
  25637. * Affects all geometry data in one call
  25638. * @param vertexData defines the geometry data
  25639. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25640. */
  25641. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25642. /**
  25643. * Set specific vertex data
  25644. * @param kind defines the data kind (Position, normal, etc...)
  25645. * @param data defines the vertex data to use
  25646. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25647. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25648. */
  25649. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25650. /**
  25651. * Removes a specific vertex data
  25652. * @param kind defines the data kind (Position, normal, etc...)
  25653. */
  25654. removeVerticesData(kind: string): void;
  25655. /**
  25656. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25657. * @param buffer defines the vertex buffer to use
  25658. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25659. */
  25660. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25661. /**
  25662. * Update a specific vertex buffer
  25663. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25664. * It will do nothing if the buffer is not updatable
  25665. * @param kind defines the data kind (Position, normal, etc...)
  25666. * @param data defines the data to use
  25667. * @param offset defines the offset in the target buffer where to store the data
  25668. * @param useBytes set to true if the offset is in bytes
  25669. */
  25670. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25671. /**
  25672. * Update a specific vertex buffer
  25673. * This function will create a new buffer if the current one is not updatable
  25674. * @param kind defines the data kind (Position, normal, etc...)
  25675. * @param data defines the data to use
  25676. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25677. */
  25678. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25679. private _updateBoundingInfo;
  25680. /** @hidden */
  25681. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25682. /**
  25683. * Gets total number of vertices
  25684. * @returns the total number of vertices
  25685. */
  25686. getTotalVertices(): number;
  25687. /**
  25688. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25689. * @param kind defines the data kind (Position, normal, etc...)
  25690. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25691. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25692. * @returns a float array containing vertex data
  25693. */
  25694. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25695. /**
  25696. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25697. * @param kind defines the data kind (Position, normal, etc...)
  25698. * @returns true if the vertex buffer with the specified kind is updatable
  25699. */
  25700. isVertexBufferUpdatable(kind: string): boolean;
  25701. /**
  25702. * Gets a specific vertex buffer
  25703. * @param kind defines the data kind (Position, normal, etc...)
  25704. * @returns a VertexBuffer
  25705. */
  25706. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25707. /**
  25708. * Returns all vertex buffers
  25709. * @return an object holding all vertex buffers indexed by kind
  25710. */
  25711. getVertexBuffers(): Nullable<{
  25712. [key: string]: VertexBuffer;
  25713. }>;
  25714. /**
  25715. * Gets a boolean indicating if specific vertex buffer is present
  25716. * @param kind defines the data kind (Position, normal, etc...)
  25717. * @returns true if data is present
  25718. */
  25719. isVerticesDataPresent(kind: string): boolean;
  25720. /**
  25721. * Gets a list of all attached data kinds (Position, normal, etc...)
  25722. * @returns a list of string containing all kinds
  25723. */
  25724. getVerticesDataKinds(): string[];
  25725. /**
  25726. * Update index buffer
  25727. * @param indices defines the indices to store in the index buffer
  25728. * @param offset defines the offset in the target buffer where to store the data
  25729. */
  25730. updateIndices(indices: IndicesArray, offset?: number): void;
  25731. /**
  25732. * Creates a new index buffer
  25733. * @param indices defines the indices to store in the index buffer
  25734. * @param totalVertices defines the total number of vertices (could be null)
  25735. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25736. */
  25737. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25738. /**
  25739. * Return the total number of indices
  25740. * @returns the total number of indices
  25741. */
  25742. getTotalIndices(): number;
  25743. /**
  25744. * Gets the index buffer array
  25745. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25746. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25747. * @returns the index buffer array
  25748. */
  25749. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25750. /**
  25751. * Gets the index buffer
  25752. * @return the index buffer
  25753. */
  25754. getIndexBuffer(): Nullable<WebGLBuffer>;
  25755. /** @hidden */
  25756. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25757. /**
  25758. * Release the associated resources for a specific mesh
  25759. * @param mesh defines the source mesh
  25760. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25761. */
  25762. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25763. /**
  25764. * Apply current geometry to a given mesh
  25765. * @param mesh defines the mesh to apply geometry to
  25766. */
  25767. applyToMesh(mesh: Mesh): void;
  25768. private _updateExtend;
  25769. private _applyToMesh;
  25770. private notifyUpdate;
  25771. /**
  25772. * Load the geometry if it was flagged as delay loaded
  25773. * @param scene defines the hosting scene
  25774. * @param onLoaded defines a callback called when the geometry is loaded
  25775. */
  25776. load(scene: Scene, onLoaded?: () => void): void;
  25777. private _queueLoad;
  25778. /**
  25779. * Invert the geometry to move from a right handed system to a left handed one.
  25780. */
  25781. toLeftHanded(): void;
  25782. /** @hidden */
  25783. _resetPointsArrayCache(): void;
  25784. /** @hidden */
  25785. _generatePointsArray(): boolean;
  25786. /**
  25787. * Gets a value indicating if the geometry is disposed
  25788. * @returns true if the geometry was disposed
  25789. */
  25790. isDisposed(): boolean;
  25791. private _disposeVertexArrayObjects;
  25792. /**
  25793. * Free all associated resources
  25794. */
  25795. dispose(): void;
  25796. /**
  25797. * Clone the current geometry into a new geometry
  25798. * @param id defines the unique ID of the new geometry
  25799. * @returns a new geometry object
  25800. */
  25801. copy(id: string): Geometry;
  25802. /**
  25803. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25804. * @return a JSON representation of the current geometry data (without the vertices data)
  25805. */
  25806. serialize(): any;
  25807. private toNumberArray;
  25808. /**
  25809. * Serialize all vertices data into a JSON oject
  25810. * @returns a JSON representation of the current geometry data
  25811. */
  25812. serializeVerticeData(): any;
  25813. /**
  25814. * Extracts a clone of a mesh geometry
  25815. * @param mesh defines the source mesh
  25816. * @param id defines the unique ID of the new geometry object
  25817. * @returns the new geometry object
  25818. */
  25819. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25820. /**
  25821. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25822. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25823. * Be aware Math.random() could cause collisions, but:
  25824. * "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"
  25825. * @returns a string containing a new GUID
  25826. */
  25827. static RandomId(): string;
  25828. /** @hidden */
  25829. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25830. private static _CleanMatricesWeights;
  25831. /**
  25832. * Create a new geometry from persisted data (Using .babylon file format)
  25833. * @param parsedVertexData defines the persisted data
  25834. * @param scene defines the hosting scene
  25835. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25836. * @returns the new geometry object
  25837. */
  25838. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25839. }
  25840. /**
  25841. * Abstract class used to provide common services for all typed geometries
  25842. * @hidden
  25843. */
  25844. class _PrimitiveGeometry extends Geometry {
  25845. private _canBeRegenerated;
  25846. private _beingRegenerated;
  25847. /**
  25848. * Creates a new typed geometry
  25849. * @param id defines the unique ID of the geometry
  25850. * @param scene defines the hosting scene
  25851. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25852. * @param mesh defines the hosting mesh (can be null)
  25853. */
  25854. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25855. /**
  25856. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25857. * @returns true if the geometry can be regenerated
  25858. */
  25859. canBeRegenerated(): boolean;
  25860. /**
  25861. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25862. */
  25863. regenerate(): void;
  25864. /**
  25865. * Clone the geometry
  25866. * @param id defines the unique ID of the new geometry
  25867. * @returns the new geometry
  25868. */
  25869. asNewGeometry(id: string): Geometry;
  25870. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25871. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25872. /** @hidden */
  25873. _regenerateVertexData(): VertexData;
  25874. copy(id: string): Geometry;
  25875. serialize(): any;
  25876. }
  25877. /**
  25878. * Creates a ribbon geometry
  25879. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25880. */
  25881. class RibbonGeometry extends _PrimitiveGeometry {
  25882. /**
  25883. * Defines the array of paths to use
  25884. */
  25885. pathArray: Vector3[][];
  25886. /**
  25887. * Defines if the last and first points of each path in your pathArray must be joined
  25888. */
  25889. closeArray: boolean;
  25890. /**
  25891. * Defines if the last and first points of each path in your pathArray must be joined
  25892. */
  25893. closePath: boolean;
  25894. /**
  25895. * Defines the offset between points
  25896. */
  25897. offset: number;
  25898. /**
  25899. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25900. */
  25901. side: number;
  25902. /**
  25903. * Creates a ribbon geometry
  25904. * @param id defines the unique ID of the geometry
  25905. * @param scene defines the hosting scene
  25906. * @param pathArray defines the array of paths to use
  25907. * @param closeArray defines if the last path and the first path must be joined
  25908. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25909. * @param offset defines the offset between points
  25910. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25911. * @param mesh defines the hosting mesh (can be null)
  25912. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25913. */
  25914. constructor(id: string, scene: Scene,
  25915. /**
  25916. * Defines the array of paths to use
  25917. */
  25918. pathArray: Vector3[][],
  25919. /**
  25920. * Defines if the last and first points of each path in your pathArray must be joined
  25921. */
  25922. closeArray: boolean,
  25923. /**
  25924. * Defines if the last and first points of each path in your pathArray must be joined
  25925. */
  25926. closePath: boolean,
  25927. /**
  25928. * Defines the offset between points
  25929. */
  25930. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25931. /**
  25932. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25933. */
  25934. side?: number);
  25935. /** @hidden */
  25936. _regenerateVertexData(): VertexData;
  25937. copy(id: string): Geometry;
  25938. }
  25939. /**
  25940. * Creates a box geometry
  25941. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25942. */
  25943. class BoxGeometry extends _PrimitiveGeometry {
  25944. /**
  25945. * Defines the zise of the box (width, height and depth are the same)
  25946. */
  25947. size: number;
  25948. /**
  25949. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25950. */
  25951. side: number;
  25952. /**
  25953. * Creates a box geometry
  25954. * @param id defines the unique ID of the geometry
  25955. * @param scene defines the hosting scene
  25956. * @param size defines the zise of the box (width, height and depth are the same)
  25957. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25958. * @param mesh defines the hosting mesh (can be null)
  25959. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25960. */
  25961. constructor(id: string, scene: Scene,
  25962. /**
  25963. * Defines the zise of the box (width, height and depth are the same)
  25964. */
  25965. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25966. /**
  25967. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25968. */
  25969. side?: number);
  25970. /** @hidden */
  25971. _regenerateVertexData(): VertexData;
  25972. copy(id: string): Geometry;
  25973. serialize(): any;
  25974. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25975. }
  25976. /**
  25977. * Creates a sphere geometry
  25978. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25979. */
  25980. class SphereGeometry extends _PrimitiveGeometry {
  25981. /**
  25982. * Defines the number of segments to use to create the sphere
  25983. */
  25984. segments: number;
  25985. /**
  25986. * Defines the diameter of the sphere
  25987. */
  25988. diameter: number;
  25989. /**
  25990. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25991. */
  25992. side: number;
  25993. /**
  25994. * Create a new sphere geometry
  25995. * @param id defines the unique ID of the geometry
  25996. * @param scene defines the hosting scene
  25997. * @param segments defines the number of segments to use to create the sphere
  25998. * @param diameter defines the diameter of the sphere
  25999. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26000. * @param mesh defines the hosting mesh (can be null)
  26001. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26002. */
  26003. constructor(id: string, scene: Scene,
  26004. /**
  26005. * Defines the number of segments to use to create the sphere
  26006. */
  26007. segments: number,
  26008. /**
  26009. * Defines the diameter of the sphere
  26010. */
  26011. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26012. /**
  26013. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26014. */
  26015. side?: number);
  26016. /** @hidden */
  26017. _regenerateVertexData(): VertexData;
  26018. copy(id: string): Geometry;
  26019. serialize(): any;
  26020. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  26021. }
  26022. /**
  26023. * Creates a disc geometry
  26024. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26025. */
  26026. class DiscGeometry extends _PrimitiveGeometry {
  26027. /**
  26028. * Defines the radius of the disc
  26029. */
  26030. radius: number;
  26031. /**
  26032. * Defines the tesselation factor to apply to the disc
  26033. */
  26034. tessellation: number;
  26035. /**
  26036. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26037. */
  26038. side: number;
  26039. /**
  26040. * Creates a new disc geometry
  26041. * @param id defines the unique ID of the geometry
  26042. * @param scene defines the hosting scene
  26043. * @param radius defines the radius of the disc
  26044. * @param tessellation defines the tesselation factor to apply to the disc
  26045. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26046. * @param mesh defines the hosting mesh (can be null)
  26047. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26048. */
  26049. constructor(id: string, scene: Scene,
  26050. /**
  26051. * Defines the radius of the disc
  26052. */
  26053. radius: number,
  26054. /**
  26055. * Defines the tesselation factor to apply to the disc
  26056. */
  26057. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26058. /**
  26059. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26060. */
  26061. side?: number);
  26062. /** @hidden */
  26063. _regenerateVertexData(): VertexData;
  26064. copy(id: string): Geometry;
  26065. }
  26066. /**
  26067. * Creates a new cylinder geometry
  26068. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  26069. */
  26070. class CylinderGeometry extends _PrimitiveGeometry {
  26071. /**
  26072. * Defines the height of the cylinder
  26073. */
  26074. height: number;
  26075. /**
  26076. * Defines the diameter of the cylinder's top cap
  26077. */
  26078. diameterTop: number;
  26079. /**
  26080. * Defines the diameter of the cylinder's bottom cap
  26081. */
  26082. diameterBottom: number;
  26083. /**
  26084. * Defines the tessellation factor to apply to the cylinder
  26085. */
  26086. tessellation: number;
  26087. /**
  26088. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  26089. */
  26090. subdivisions: number;
  26091. /**
  26092. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26093. */
  26094. side: number;
  26095. /**
  26096. * Creates a new cylinder geometry
  26097. * @param id defines the unique ID of the geometry
  26098. * @param scene defines the hosting scene
  26099. * @param height defines the height of the cylinder
  26100. * @param diameterTop defines the diameter of the cylinder's top cap
  26101. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  26102. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  26103. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  26104. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26105. * @param mesh defines the hosting mesh (can be null)
  26106. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26107. */
  26108. constructor(id: string, scene: Scene,
  26109. /**
  26110. * Defines the height of the cylinder
  26111. */
  26112. height: number,
  26113. /**
  26114. * Defines the diameter of the cylinder's top cap
  26115. */
  26116. diameterTop: number,
  26117. /**
  26118. * Defines the diameter of the cylinder's bottom cap
  26119. */
  26120. diameterBottom: number,
  26121. /**
  26122. * Defines the tessellation factor to apply to the cylinder
  26123. */
  26124. tessellation: number,
  26125. /**
  26126. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  26127. */
  26128. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26129. /**
  26130. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26131. */
  26132. side?: number);
  26133. /** @hidden */
  26134. _regenerateVertexData(): VertexData;
  26135. copy(id: string): Geometry;
  26136. serialize(): any;
  26137. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  26138. }
  26139. /**
  26140. * Creates a new torus geometry
  26141. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  26142. */
  26143. class TorusGeometry extends _PrimitiveGeometry {
  26144. /**
  26145. * Defines the diameter of the torus
  26146. */
  26147. diameter: number;
  26148. /**
  26149. * Defines the thickness of the torus (ie. internal diameter)
  26150. */
  26151. thickness: number;
  26152. /**
  26153. * Defines the tesselation factor to apply to the torus
  26154. */
  26155. tessellation: number;
  26156. /**
  26157. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26158. */
  26159. side: number;
  26160. /**
  26161. * Creates a new torus geometry
  26162. * @param id defines the unique ID of the geometry
  26163. * @param scene defines the hosting scene
  26164. * @param diameter defines the diameter of the torus
  26165. * @param thickness defines the thickness of the torus (ie. internal diameter)
  26166. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  26167. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26168. * @param mesh defines the hosting mesh (can be null)
  26169. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26170. */
  26171. constructor(id: string, scene: Scene,
  26172. /**
  26173. * Defines the diameter of the torus
  26174. */
  26175. diameter: number,
  26176. /**
  26177. * Defines the thickness of the torus (ie. internal diameter)
  26178. */
  26179. thickness: number,
  26180. /**
  26181. * Defines the tesselation factor to apply to the torus
  26182. */
  26183. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26184. /**
  26185. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26186. */
  26187. side?: number);
  26188. /** @hidden */
  26189. _regenerateVertexData(): VertexData;
  26190. copy(id: string): Geometry;
  26191. serialize(): any;
  26192. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  26193. }
  26194. /**
  26195. * Creates a new ground geometry
  26196. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  26197. */
  26198. class GroundGeometry extends _PrimitiveGeometry {
  26199. /**
  26200. * Defines the width of the ground
  26201. */
  26202. width: number;
  26203. /**
  26204. * Defines the height of the ground
  26205. */
  26206. height: number;
  26207. /**
  26208. * Defines the subdivisions to apply to the ground
  26209. */
  26210. subdivisions: number;
  26211. /**
  26212. * Creates a new ground geometry
  26213. * @param id defines the unique ID of the geometry
  26214. * @param scene defines the hosting scene
  26215. * @param width defines the width of the ground
  26216. * @param height defines the height of the ground
  26217. * @param subdivisions defines the subdivisions to apply to the ground
  26218. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26219. * @param mesh defines the hosting mesh (can be null)
  26220. */
  26221. constructor(id: string, scene: Scene,
  26222. /**
  26223. * Defines the width of the ground
  26224. */
  26225. width: number,
  26226. /**
  26227. * Defines the height of the ground
  26228. */
  26229. height: number,
  26230. /**
  26231. * Defines the subdivisions to apply to the ground
  26232. */
  26233. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  26234. /** @hidden */
  26235. _regenerateVertexData(): VertexData;
  26236. copy(id: string): Geometry;
  26237. serialize(): any;
  26238. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  26239. }
  26240. /**
  26241. * Creates a tiled ground geometry
  26242. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  26243. */
  26244. class TiledGroundGeometry extends _PrimitiveGeometry {
  26245. /**
  26246. * Defines the minimum value on X axis
  26247. */
  26248. xmin: number;
  26249. /**
  26250. * Defines the minimum value on Z axis
  26251. */
  26252. zmin: number;
  26253. /**
  26254. * Defines the maximum value on X axis
  26255. */
  26256. xmax: number;
  26257. /**
  26258. * Defines the maximum value on Z axis
  26259. */
  26260. zmax: number;
  26261. /**
  26262. * Defines the subdivisions to apply to the ground
  26263. */
  26264. subdivisions: {
  26265. w: number;
  26266. h: number;
  26267. };
  26268. /**
  26269. * Defines the precision to use when computing the tiles
  26270. */
  26271. precision: {
  26272. w: number;
  26273. h: number;
  26274. };
  26275. /**
  26276. * Creates a tiled ground geometry
  26277. * @param id defines the unique ID of the geometry
  26278. * @param scene defines the hosting scene
  26279. * @param xmin defines the minimum value on X axis
  26280. * @param zmin defines the minimum value on Z axis
  26281. * @param xmax defines the maximum value on X axis
  26282. * @param zmax defines the maximum value on Z axis
  26283. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  26284. * @param precision defines the precision to use when computing the tiles
  26285. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26286. * @param mesh defines the hosting mesh (can be null)
  26287. */
  26288. constructor(id: string, scene: Scene,
  26289. /**
  26290. * Defines the minimum value on X axis
  26291. */
  26292. xmin: number,
  26293. /**
  26294. * Defines the minimum value on Z axis
  26295. */
  26296. zmin: number,
  26297. /**
  26298. * Defines the maximum value on X axis
  26299. */
  26300. xmax: number,
  26301. /**
  26302. * Defines the maximum value on Z axis
  26303. */
  26304. zmax: number,
  26305. /**
  26306. * Defines the subdivisions to apply to the ground
  26307. */
  26308. subdivisions: {
  26309. w: number;
  26310. h: number;
  26311. },
  26312. /**
  26313. * Defines the precision to use when computing the tiles
  26314. */
  26315. precision: {
  26316. w: number;
  26317. h: number;
  26318. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  26319. /** @hidden */
  26320. _regenerateVertexData(): VertexData;
  26321. copy(id: string): Geometry;
  26322. }
  26323. /**
  26324. * Creates a plane geometry
  26325. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  26326. */
  26327. class PlaneGeometry extends _PrimitiveGeometry {
  26328. /**
  26329. * Defines the size of the plane (width === height)
  26330. */
  26331. size: number;
  26332. /**
  26333. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26334. */
  26335. side: number;
  26336. /**
  26337. * Creates a plane geometry
  26338. * @param id defines the unique ID of the geometry
  26339. * @param scene defines the hosting scene
  26340. * @param size defines the size of the plane (width === height)
  26341. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26342. * @param mesh defines the hosting mesh (can be null)
  26343. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26344. */
  26345. constructor(id: string, scene: Scene,
  26346. /**
  26347. * Defines the size of the plane (width === height)
  26348. */
  26349. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26350. /**
  26351. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26352. */
  26353. side?: number);
  26354. /** @hidden */
  26355. _regenerateVertexData(): VertexData;
  26356. copy(id: string): Geometry;
  26357. serialize(): any;
  26358. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  26359. }
  26360. /**
  26361. * Creates a torus knot geometry
  26362. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  26363. */
  26364. class TorusKnotGeometry extends _PrimitiveGeometry {
  26365. /**
  26366. * Defines the radius of the torus knot
  26367. */
  26368. radius: number;
  26369. /**
  26370. * Defines the thickness of the torus knot tube
  26371. */
  26372. tube: number;
  26373. /**
  26374. * Defines the number of radial segments
  26375. */
  26376. radialSegments: number;
  26377. /**
  26378. * Defines the number of tubular segments
  26379. */
  26380. tubularSegments: number;
  26381. /**
  26382. * Defines the first number of windings
  26383. */
  26384. p: number;
  26385. /**
  26386. * Defines the second number of windings
  26387. */
  26388. q: number;
  26389. /**
  26390. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26391. */
  26392. side: number;
  26393. /**
  26394. * Creates a torus knot geometry
  26395. * @param id defines the unique ID of the geometry
  26396. * @param scene defines the hosting scene
  26397. * @param radius defines the radius of the torus knot
  26398. * @param tube defines the thickness of the torus knot tube
  26399. * @param radialSegments defines the number of radial segments
  26400. * @param tubularSegments defines the number of tubular segments
  26401. * @param p defines the first number of windings
  26402. * @param q defines the second number of windings
  26403. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26404. * @param mesh defines the hosting mesh (can be null)
  26405. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26406. */
  26407. constructor(id: string, scene: Scene,
  26408. /**
  26409. * Defines the radius of the torus knot
  26410. */
  26411. radius: number,
  26412. /**
  26413. * Defines the thickness of the torus knot tube
  26414. */
  26415. tube: number,
  26416. /**
  26417. * Defines the number of radial segments
  26418. */
  26419. radialSegments: number,
  26420. /**
  26421. * Defines the number of tubular segments
  26422. */
  26423. tubularSegments: number,
  26424. /**
  26425. * Defines the first number of windings
  26426. */
  26427. p: number,
  26428. /**
  26429. * Defines the second number of windings
  26430. */
  26431. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26432. /**
  26433. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26434. */
  26435. side?: number);
  26436. /** @hidden */
  26437. _regenerateVertexData(): VertexData;
  26438. copy(id: string): Geometry;
  26439. serialize(): any;
  26440. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  26441. }
  26442. }
  26443. declare module BABYLON {
  26444. /**
  26445. * Mesh representing the gorund
  26446. */
  26447. class GroundMesh extends Mesh {
  26448. /** If octree should be generated */
  26449. generateOctree: boolean;
  26450. private _heightQuads;
  26451. /** @hidden */
  26452. _subdivisionsX: number;
  26453. /** @hidden */
  26454. _subdivisionsY: number;
  26455. /** @hidden */
  26456. _width: number;
  26457. /** @hidden */
  26458. _height: number;
  26459. /** @hidden */
  26460. _minX: number;
  26461. /** @hidden */
  26462. _maxX: number;
  26463. /** @hidden */
  26464. _minZ: number;
  26465. /** @hidden */
  26466. _maxZ: number;
  26467. constructor(name: string, scene: Scene);
  26468. /**
  26469. * "GroundMesh"
  26470. * @returns "GroundMesh"
  26471. */
  26472. getClassName(): string;
  26473. /**
  26474. * The minimum of x and y subdivisions
  26475. */
  26476. readonly subdivisions: number;
  26477. /**
  26478. * X subdivisions
  26479. */
  26480. readonly subdivisionsX: number;
  26481. /**
  26482. * Y subdivisions
  26483. */
  26484. readonly subdivisionsY: number;
  26485. /**
  26486. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26487. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26488. * @param chunksCount the number of subdivisions for x and y
  26489. * @param octreeBlocksSize (Default: 32)
  26490. */
  26491. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26492. /**
  26493. * Returns a height (y) value in the Worl system :
  26494. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26495. * @param x x coordinate
  26496. * @param z z coordinate
  26497. * @returns the ground y position if (x, z) are outside the ground surface.
  26498. */
  26499. getHeightAtCoordinates(x: number, z: number): number;
  26500. /**
  26501. * Returns a normalized vector (Vector3) orthogonal to the ground
  26502. * at the ground coordinates (x, z) expressed in the World system.
  26503. * @param x x coordinate
  26504. * @param z z coordinate
  26505. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26506. */
  26507. getNormalAtCoordinates(x: number, z: number): Vector3;
  26508. /**
  26509. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26510. * at the ground coordinates (x, z) expressed in the World system.
  26511. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26512. * @param x x coordinate
  26513. * @param z z coordinate
  26514. * @param ref vector to store the result
  26515. * @returns the GroundMesh.
  26516. */
  26517. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26518. /**
  26519. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26520. * if the ground has been updated.
  26521. * This can be used in the render loop.
  26522. * @returns the GroundMesh.
  26523. */
  26524. updateCoordinateHeights(): GroundMesh;
  26525. private _getFacetAt;
  26526. private _initHeightQuads;
  26527. private _computeHeightQuads;
  26528. /**
  26529. * Serializes this ground mesh
  26530. * @param serializationObject object to write serialization to
  26531. */
  26532. serialize(serializationObject: any): void;
  26533. /**
  26534. * Parses a serialized ground mesh
  26535. * @param parsedMesh the serialized mesh
  26536. * @param scene the scene to create the ground mesh in
  26537. * @returns the created ground mesh
  26538. */
  26539. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26540. }
  26541. }
  26542. declare module BABYLON {
  26543. /**
  26544. * Creates an instance based on a source mesh.
  26545. */
  26546. class InstancedMesh extends AbstractMesh {
  26547. private _sourceMesh;
  26548. private _currentLOD;
  26549. /** @hidden */
  26550. _indexInSourceMeshInstanceArray: number;
  26551. constructor(name: string, source: Mesh);
  26552. /**
  26553. * Returns the string "InstancedMesh".
  26554. */
  26555. getClassName(): string;
  26556. /**
  26557. * If the source mesh receives shadows
  26558. */
  26559. readonly receiveShadows: boolean;
  26560. /**
  26561. * The material of the source mesh
  26562. */
  26563. readonly material: Nullable<Material>;
  26564. /**
  26565. * Visibility of the source mesh
  26566. */
  26567. readonly visibility: number;
  26568. /**
  26569. * Skeleton of the source mesh
  26570. */
  26571. readonly skeleton: Nullable<Skeleton>;
  26572. /**
  26573. * Rendering ground id of the source mesh
  26574. */
  26575. renderingGroupId: number;
  26576. /**
  26577. * Returns the total number of vertices (integer).
  26578. */
  26579. getTotalVertices(): number;
  26580. /**
  26581. * Returns a positive integer : the total number of indices in this mesh geometry.
  26582. * @returns the numner of indices or zero if the mesh has no geometry.
  26583. */
  26584. getTotalIndices(): number;
  26585. /**
  26586. * The source mesh of the instance
  26587. */
  26588. readonly sourceMesh: Mesh;
  26589. /**
  26590. * Is this node ready to be used/rendered
  26591. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26592. * @return {boolean} is it ready
  26593. */
  26594. isReady(completeCheck?: boolean): boolean;
  26595. /**
  26596. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26597. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26598. * @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.
  26599. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26600. */
  26601. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26602. /**
  26603. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26604. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26605. * The `data` are either a numeric array either a Float32Array.
  26606. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26607. * 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).
  26608. * Note that a new underlying VertexBuffer object is created each call.
  26609. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26610. *
  26611. * Possible `kind` values :
  26612. * - BABYLON.VertexBuffer.PositionKind
  26613. * - BABYLON.VertexBuffer.UVKind
  26614. * - BABYLON.VertexBuffer.UV2Kind
  26615. * - BABYLON.VertexBuffer.UV3Kind
  26616. * - BABYLON.VertexBuffer.UV4Kind
  26617. * - BABYLON.VertexBuffer.UV5Kind
  26618. * - BABYLON.VertexBuffer.UV6Kind
  26619. * - BABYLON.VertexBuffer.ColorKind
  26620. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26621. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26622. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26623. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26624. *
  26625. * Returns the Mesh.
  26626. */
  26627. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26628. /**
  26629. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26630. * If the mesh has no geometry, it is simply returned as it is.
  26631. * The `data` are either a numeric array either a Float32Array.
  26632. * No new underlying VertexBuffer object is created.
  26633. * 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.
  26634. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26635. *
  26636. * Possible `kind` values :
  26637. * - BABYLON.VertexBuffer.PositionKind
  26638. * - BABYLON.VertexBuffer.UVKind
  26639. * - BABYLON.VertexBuffer.UV2Kind
  26640. * - BABYLON.VertexBuffer.UV3Kind
  26641. * - BABYLON.VertexBuffer.UV4Kind
  26642. * - BABYLON.VertexBuffer.UV5Kind
  26643. * - BABYLON.VertexBuffer.UV6Kind
  26644. * - BABYLON.VertexBuffer.ColorKind
  26645. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26646. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26647. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26648. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26649. *
  26650. * Returns the Mesh.
  26651. */
  26652. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26653. /**
  26654. * Sets the mesh indices.
  26655. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26656. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26657. * This method creates a new index buffer each call.
  26658. * Returns the Mesh.
  26659. */
  26660. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26661. /**
  26662. * Boolean : True if the mesh owns the requested kind of data.
  26663. */
  26664. isVerticesDataPresent(kind: string): boolean;
  26665. /**
  26666. * Returns an array of indices (IndicesArray).
  26667. */
  26668. getIndices(): Nullable<IndicesArray>;
  26669. readonly _positions: Nullable<Vector3[]>;
  26670. /**
  26671. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26672. * This means the mesh underlying bounding box and sphere are recomputed.
  26673. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26674. * @returns the current mesh
  26675. */
  26676. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  26677. /** @hidden */
  26678. _preActivate(): InstancedMesh;
  26679. /** @hidden */
  26680. _activate(renderId: number): InstancedMesh;
  26681. /**
  26682. * Returns the current associated LOD AbstractMesh.
  26683. */
  26684. getLOD(camera: Camera): AbstractMesh;
  26685. /** @hidden */
  26686. _syncSubMeshes(): InstancedMesh;
  26687. /** @hidden */
  26688. _generatePointsArray(): boolean;
  26689. /**
  26690. * Creates a new InstancedMesh from the current mesh.
  26691. * - name (string) : the cloned mesh name
  26692. * - newParent (optional Node) : the optional Node to parent the clone to.
  26693. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26694. *
  26695. * Returns the clone.
  26696. */
  26697. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26698. /**
  26699. * Disposes the InstancedMesh.
  26700. * Returns nothing.
  26701. */
  26702. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26703. }
  26704. }
  26705. declare module BABYLON {
  26706. /**
  26707. * Line mesh
  26708. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26709. */
  26710. class LinesMesh extends Mesh {
  26711. /**
  26712. * If vertex color should be applied to the mesh
  26713. */
  26714. useVertexColor?: boolean | undefined;
  26715. /**
  26716. * If vertex alpha should be applied to the mesh
  26717. */
  26718. useVertexAlpha?: boolean | undefined;
  26719. /**
  26720. * Color of the line (Default: White)
  26721. */
  26722. color: Color3;
  26723. /**
  26724. * Alpha of the line (Default: 1)
  26725. */
  26726. alpha: number;
  26727. /**
  26728. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26729. * This margin is expressed in world space coordinates, so its value may vary.
  26730. * Default value is 0.1
  26731. */
  26732. intersectionThreshold: number;
  26733. private _colorShader;
  26734. /**
  26735. * Creates a new LinesMesh
  26736. * @param name defines the name
  26737. * @param scene defines the hosting scene
  26738. * @param parent defines the parent mesh if any
  26739. * @param source defines the optional source LinesMesh used to clone data from
  26740. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26741. * When false, achieved by calling a clone(), also passing False.
  26742. * This will make creation of children, recursive.
  26743. * @param useVertexColor defines if this LinesMesh supports vertex color
  26744. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26745. */
  26746. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26747. /**
  26748. * If vertex color should be applied to the mesh
  26749. */
  26750. useVertexColor?: boolean | undefined,
  26751. /**
  26752. * If vertex alpha should be applied to the mesh
  26753. */
  26754. useVertexAlpha?: boolean | undefined);
  26755. /**
  26756. * Returns the string "LineMesh"
  26757. */
  26758. getClassName(): string;
  26759. /**
  26760. * @hidden
  26761. */
  26762. /**
  26763. * @hidden
  26764. */
  26765. material: Material;
  26766. /**
  26767. * @hidden
  26768. */
  26769. readonly checkCollisions: boolean;
  26770. /** @hidden */
  26771. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26772. /** @hidden */
  26773. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26774. /**
  26775. * Disposes of the line mesh
  26776. * @param doNotRecurse If children should be disposed
  26777. */
  26778. dispose(doNotRecurse?: boolean): void;
  26779. /**
  26780. * Returns a new LineMesh object cloned from the current one.
  26781. */
  26782. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26783. /**
  26784. * Creates a new InstancedLinesMesh object from the mesh model.
  26785. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26786. * @param name defines the name of the new instance
  26787. * @returns a new InstancedLinesMesh
  26788. */
  26789. createInstance(name: string): InstancedLinesMesh;
  26790. }
  26791. /**
  26792. * Creates an instance based on a source LinesMesh
  26793. */
  26794. class InstancedLinesMesh extends InstancedMesh {
  26795. /**
  26796. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26797. * This margin is expressed in world space coordinates, so its value may vary.
  26798. * Initilized with the intersectionThreshold value of the source LinesMesh
  26799. */
  26800. intersectionThreshold: number;
  26801. constructor(name: string, source: LinesMesh);
  26802. /**
  26803. * Returns the string "InstancedLinesMesh".
  26804. */
  26805. getClassName(): string;
  26806. }
  26807. }
  26808. declare module BABYLON {
  26809. /**
  26810. * @hidden
  26811. **/
  26812. class _CreationDataStorage {
  26813. closePath?: boolean;
  26814. closeArray?: boolean;
  26815. idx: number[];
  26816. dashSize: number;
  26817. gapSize: number;
  26818. path3D: Path3D;
  26819. pathArray: Vector3[][];
  26820. arc: number;
  26821. radius: number;
  26822. cap: number;
  26823. tessellation: number;
  26824. }
  26825. /**
  26826. * @hidden
  26827. **/
  26828. class _InstanceDataStorage {
  26829. visibleInstances: any;
  26830. renderIdForInstances: number[];
  26831. batchCache: _InstancesBatch;
  26832. instancesBufferSize: number;
  26833. instancesBuffer: Nullable<Buffer>;
  26834. instancesData: Float32Array;
  26835. overridenInstanceCount: number;
  26836. }
  26837. /**
  26838. * @hidden
  26839. **/
  26840. class _InstancesBatch {
  26841. mustReturn: boolean;
  26842. visibleInstances: Nullable<InstancedMesh[]>[];
  26843. renderSelf: boolean[];
  26844. }
  26845. /**
  26846. * Class used to represent renderable models
  26847. */
  26848. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26849. /**
  26850. * Mesh side orientation : usually the external or front surface
  26851. */
  26852. static readonly FRONTSIDE: number;
  26853. /**
  26854. * Mesh side orientation : usually the internal or back surface
  26855. */
  26856. static readonly BACKSIDE: number;
  26857. /**
  26858. * Mesh side orientation : both internal and external or front and back surfaces
  26859. */
  26860. static readonly DOUBLESIDE: number;
  26861. /**
  26862. * Mesh side orientation : by default, `FRONTSIDE`
  26863. */
  26864. static readonly DEFAULTSIDE: number;
  26865. /**
  26866. * Mesh cap setting : no cap
  26867. */
  26868. static readonly NO_CAP: number;
  26869. /**
  26870. * Mesh cap setting : one cap at the beginning of the mesh
  26871. */
  26872. static readonly CAP_START: number;
  26873. /**
  26874. * Mesh cap setting : one cap at the end of the mesh
  26875. */
  26876. static readonly CAP_END: number;
  26877. /**
  26878. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26879. */
  26880. static readonly CAP_ALL: number;
  26881. private _onBeforeRenderObservable;
  26882. private _onAfterRenderObservable;
  26883. private _onBeforeDrawObservable;
  26884. /**
  26885. * An event triggered before rendering the mesh
  26886. */
  26887. readonly onBeforeRenderObservable: Observable<Mesh>;
  26888. /**
  26889. * An event triggered after rendering the mesh
  26890. */
  26891. readonly onAfterRenderObservable: Observable<Mesh>;
  26892. /**
  26893. * An event triggered before drawing the mesh
  26894. */
  26895. readonly onBeforeDrawObservable: Observable<Mesh>;
  26896. private _onBeforeDrawObserver;
  26897. /**
  26898. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26899. */
  26900. onBeforeDraw: () => void;
  26901. /**
  26902. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26903. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26904. */
  26905. delayLoadState: number;
  26906. /**
  26907. * Gets the list of instances created from this mesh
  26908. * it is not supposed to be modified manually.
  26909. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26910. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26911. */
  26912. instances: InstancedMesh[];
  26913. /**
  26914. * Gets the file containing delay loading data for this mesh
  26915. */
  26916. delayLoadingFile: string;
  26917. /** @hidden */
  26918. _binaryInfo: any;
  26919. private _LODLevels;
  26920. /**
  26921. * User defined function used to change how LOD level selection is done
  26922. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26923. */
  26924. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26925. private _morphTargetManager;
  26926. /**
  26927. * Gets or sets the morph target manager
  26928. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26929. */
  26930. morphTargetManager: Nullable<MorphTargetManager>;
  26931. /** @hidden */
  26932. _creationDataStorage: Nullable<_CreationDataStorage>;
  26933. /** @hidden */
  26934. _geometry: Nullable<Geometry>;
  26935. /** @hidden */
  26936. _delayInfo: Array<string>;
  26937. /** @hidden */
  26938. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26939. /** @hidden */
  26940. _instanceDataStorage: _InstanceDataStorage;
  26941. private _effectiveMaterial;
  26942. /** @hidden */
  26943. _shouldGenerateFlatShading: boolean;
  26944. private _preActivateId;
  26945. /** @hidden */
  26946. _originalBuilderSideOrientation: number;
  26947. /**
  26948. * Use this property to change the original side orientation defined at construction time
  26949. */
  26950. overrideMaterialSideOrientation: Nullable<number>;
  26951. private _areNormalsFrozen;
  26952. private _sourcePositions;
  26953. private _sourceNormals;
  26954. private _source;
  26955. private meshMap;
  26956. /**
  26957. * Gets the source mesh (the one used to clone this one from)
  26958. */
  26959. readonly source: Nullable<Mesh>;
  26960. /**
  26961. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26962. */
  26963. isUnIndexed: boolean;
  26964. /**
  26965. * @constructor
  26966. * @param name The value used by scene.getMeshByName() to do a lookup.
  26967. * @param scene The scene to add this mesh to.
  26968. * @param parent The parent of this mesh, if it has one
  26969. * @param source An optional Mesh from which geometry is shared, cloned.
  26970. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26971. * When false, achieved by calling a clone(), also passing False.
  26972. * This will make creation of children, recursive.
  26973. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26974. */
  26975. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26976. /**
  26977. * Gets the class name
  26978. * @returns the string "Mesh".
  26979. */
  26980. getClassName(): string;
  26981. /**
  26982. * Returns a description of this mesh
  26983. * @param fullDetails define if full details about this mesh must be used
  26984. * @returns a descriptive string representing this mesh
  26985. */
  26986. toString(fullDetails?: boolean): string;
  26987. /** @hidden */
  26988. _unBindEffect(): void;
  26989. /**
  26990. * Gets a boolean indicating if this mesh has LOD
  26991. */
  26992. readonly hasLODLevels: boolean;
  26993. /**
  26994. * Gets the list of MeshLODLevel associated with the current mesh
  26995. * @returns an array of MeshLODLevel
  26996. */
  26997. getLODLevels(): MeshLODLevel[];
  26998. private _sortLODLevels;
  26999. /**
  27000. * Add a mesh as LOD level triggered at the given distance.
  27001. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27002. * @param distance The distance from the center of the object to show this level
  27003. * @param mesh The mesh to be added as LOD level (can be null)
  27004. * @return This mesh (for chaining)
  27005. */
  27006. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27007. /**
  27008. * Returns the LOD level mesh at the passed distance or null if not found.
  27009. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27010. * @param distance The distance from the center of the object to show this level
  27011. * @returns a Mesh or `null`
  27012. */
  27013. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27014. /**
  27015. * Remove a mesh from the LOD array
  27016. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27017. * @param mesh defines the mesh to be removed
  27018. * @return This mesh (for chaining)
  27019. */
  27020. removeLODLevel(mesh: Mesh): Mesh;
  27021. /**
  27022. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27023. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27024. * @param camera defines the camera to use to compute distance
  27025. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27026. * @return This mesh (for chaining)
  27027. */
  27028. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27029. /**
  27030. * Gets the mesh internal Geometry object
  27031. */
  27032. readonly geometry: Nullable<Geometry>;
  27033. /**
  27034. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27035. * @returns the total number of vertices
  27036. */
  27037. getTotalVertices(): number;
  27038. /**
  27039. * Returns the content of an associated vertex buffer
  27040. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27041. * - BABYLON.VertexBuffer.PositionKind
  27042. * - BABYLON.VertexBuffer.UVKind
  27043. * - BABYLON.VertexBuffer.UV2Kind
  27044. * - BABYLON.VertexBuffer.UV3Kind
  27045. * - BABYLON.VertexBuffer.UV4Kind
  27046. * - BABYLON.VertexBuffer.UV5Kind
  27047. * - BABYLON.VertexBuffer.UV6Kind
  27048. * - BABYLON.VertexBuffer.ColorKind
  27049. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27050. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27051. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27052. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27053. * @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
  27054. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27055. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27056. */
  27057. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27058. /**
  27059. * Returns the mesh VertexBuffer object from the requested `kind`
  27060. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27061. * - BABYLON.VertexBuffer.PositionKind
  27062. * - BABYLON.VertexBuffer.UVKind
  27063. * - BABYLON.VertexBuffer.UV2Kind
  27064. * - BABYLON.VertexBuffer.UV3Kind
  27065. * - BABYLON.VertexBuffer.UV4Kind
  27066. * - BABYLON.VertexBuffer.UV5Kind
  27067. * - BABYLON.VertexBuffer.UV6Kind
  27068. * - BABYLON.VertexBuffer.ColorKind
  27069. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27070. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27071. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27072. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27073. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27074. */
  27075. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27076. /**
  27077. * Tests if a specific vertex buffer is associated with this mesh
  27078. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27079. * - BABYLON.VertexBuffer.PositionKind
  27080. * - BABYLON.VertexBuffer.UVKind
  27081. * - BABYLON.VertexBuffer.UV2Kind
  27082. * - BABYLON.VertexBuffer.UV3Kind
  27083. * - BABYLON.VertexBuffer.UV4Kind
  27084. * - BABYLON.VertexBuffer.UV5Kind
  27085. * - BABYLON.VertexBuffer.UV6Kind
  27086. * - BABYLON.VertexBuffer.ColorKind
  27087. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27088. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27089. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27090. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27091. * @returns a boolean
  27092. */
  27093. isVerticesDataPresent(kind: string): boolean;
  27094. /**
  27095. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27096. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27097. * - BABYLON.VertexBuffer.PositionKind
  27098. * - BABYLON.VertexBuffer.UVKind
  27099. * - BABYLON.VertexBuffer.UV2Kind
  27100. * - BABYLON.VertexBuffer.UV3Kind
  27101. * - BABYLON.VertexBuffer.UV4Kind
  27102. * - BABYLON.VertexBuffer.UV5Kind
  27103. * - BABYLON.VertexBuffer.UV6Kind
  27104. * - BABYLON.VertexBuffer.ColorKind
  27105. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27106. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27107. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27108. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27109. * @returns a boolean
  27110. */
  27111. isVertexBufferUpdatable(kind: string): boolean;
  27112. /**
  27113. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27114. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27115. * - BABYLON.VertexBuffer.PositionKind
  27116. * - BABYLON.VertexBuffer.UVKind
  27117. * - BABYLON.VertexBuffer.UV2Kind
  27118. * - BABYLON.VertexBuffer.UV3Kind
  27119. * - BABYLON.VertexBuffer.UV4Kind
  27120. * - BABYLON.VertexBuffer.UV5Kind
  27121. * - BABYLON.VertexBuffer.UV6Kind
  27122. * - BABYLON.VertexBuffer.ColorKind
  27123. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27124. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27125. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27126. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27127. * @returns an array of strings
  27128. */
  27129. getVerticesDataKinds(): string[];
  27130. /**
  27131. * Returns a positive integer : the total number of indices in this mesh geometry.
  27132. * @returns the numner of indices or zero if the mesh has no geometry.
  27133. */
  27134. getTotalIndices(): number;
  27135. /**
  27136. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27137. * @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.
  27138. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27139. * @returns the indices array or an empty array if the mesh has no geometry
  27140. */
  27141. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27142. readonly isBlocked: boolean;
  27143. /**
  27144. * Determine if the current mesh is ready to be rendered
  27145. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27146. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27147. * @returns true if all associated assets are ready (material, textures, shaders)
  27148. */
  27149. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27150. /**
  27151. * 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.
  27152. */
  27153. readonly areNormalsFrozen: boolean;
  27154. /**
  27155. * 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.
  27156. * @returns the current mesh
  27157. */
  27158. freezeNormals(): Mesh;
  27159. /**
  27160. * 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
  27161. * @returns the current mesh
  27162. */
  27163. unfreezeNormals(): Mesh;
  27164. /**
  27165. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27166. */
  27167. overridenInstanceCount: number;
  27168. /** @hidden */
  27169. _preActivate(): Mesh;
  27170. /** @hidden */
  27171. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27172. /** @hidden */
  27173. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27174. /**
  27175. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27176. * This means the mesh underlying bounding box and sphere are recomputed.
  27177. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27178. * @returns the current mesh
  27179. */
  27180. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27181. /** @hidden */
  27182. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27183. /**
  27184. * This function will subdivide the mesh into multiple submeshes
  27185. * @param count defines the expected number of submeshes
  27186. */
  27187. subdivide(count: number): void;
  27188. /**
  27189. * Copy a FloatArray into a specific associated vertex buffer
  27190. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27191. * - BABYLON.VertexBuffer.PositionKind
  27192. * - BABYLON.VertexBuffer.UVKind
  27193. * - BABYLON.VertexBuffer.UV2Kind
  27194. * - BABYLON.VertexBuffer.UV3Kind
  27195. * - BABYLON.VertexBuffer.UV4Kind
  27196. * - BABYLON.VertexBuffer.UV5Kind
  27197. * - BABYLON.VertexBuffer.UV6Kind
  27198. * - BABYLON.VertexBuffer.ColorKind
  27199. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27200. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27201. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27202. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27203. * @param data defines the data source
  27204. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27205. * @param stride defines the data stride size (can be null)
  27206. * @returns the current mesh
  27207. */
  27208. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  27209. /**
  27210. * Flags an associated vertex buffer as updatable
  27211. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27212. * - BABYLON.VertexBuffer.PositionKind
  27213. * - BABYLON.VertexBuffer.UVKind
  27214. * - BABYLON.VertexBuffer.UV2Kind
  27215. * - BABYLON.VertexBuffer.UV3Kind
  27216. * - BABYLON.VertexBuffer.UV4Kind
  27217. * - BABYLON.VertexBuffer.UV5Kind
  27218. * - BABYLON.VertexBuffer.UV6Kind
  27219. * - BABYLON.VertexBuffer.ColorKind
  27220. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27221. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27222. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27223. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27224. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27225. */
  27226. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27227. /**
  27228. * Sets the mesh global Vertex Buffer
  27229. * @param buffer defines the buffer to use
  27230. * @returns the current mesh
  27231. */
  27232. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27233. /**
  27234. * Update a specific associated vertex buffer
  27235. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27236. * - BABYLON.VertexBuffer.PositionKind
  27237. * - BABYLON.VertexBuffer.UVKind
  27238. * - BABYLON.VertexBuffer.UV2Kind
  27239. * - BABYLON.VertexBuffer.UV3Kind
  27240. * - BABYLON.VertexBuffer.UV4Kind
  27241. * - BABYLON.VertexBuffer.UV5Kind
  27242. * - BABYLON.VertexBuffer.UV6Kind
  27243. * - BABYLON.VertexBuffer.ColorKind
  27244. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27245. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27246. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27247. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27248. * @param data defines the data source
  27249. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27250. * @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)
  27251. * @returns the current mesh
  27252. */
  27253. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  27254. /**
  27255. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27256. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27257. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27258. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27259. * @returns the current mesh
  27260. */
  27261. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27262. /**
  27263. * Creates a un-shared specific occurence of the geometry for the mesh.
  27264. * @returns the current mesh
  27265. */
  27266. makeGeometryUnique(): Mesh;
  27267. /**
  27268. * Set the index buffer of this mesh
  27269. * @param indices defines the source data
  27270. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27271. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27272. * @returns the current mesh
  27273. */
  27274. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  27275. /**
  27276. * Update the current index buffer
  27277. * @param indices defines the source data
  27278. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27279. * @returns the current mesh
  27280. */
  27281. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  27282. /**
  27283. * Invert the geometry to move from a right handed system to a left handed one.
  27284. * @returns the current mesh
  27285. */
  27286. toLeftHanded(): Mesh;
  27287. /** @hidden */
  27288. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27289. /** @hidden */
  27290. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  27291. /**
  27292. * Registers for this mesh a javascript function called just before the rendering process
  27293. * @param func defines the function to call before rendering this mesh
  27294. * @returns the current mesh
  27295. */
  27296. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27297. /**
  27298. * Disposes a previously registered javascript function called before the rendering
  27299. * @param func defines the function to remove
  27300. * @returns the current mesh
  27301. */
  27302. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27303. /**
  27304. * Registers for this mesh a javascript function called just after the rendering is complete
  27305. * @param func defines the function to call after rendering this mesh
  27306. * @returns the current mesh
  27307. */
  27308. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27309. /**
  27310. * Disposes a previously registered javascript function called after the rendering.
  27311. * @param func defines the function to remove
  27312. * @returns the current mesh
  27313. */
  27314. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27315. /** @hidden */
  27316. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  27317. /** @hidden */
  27318. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27319. /** @hidden */
  27320. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27321. /**
  27322. * 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
  27323. * @param subMesh defines the subMesh to render
  27324. * @param enableAlphaMode defines if alpha mode can be changed
  27325. * @returns the current mesh
  27326. */
  27327. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  27328. private _onBeforeDraw;
  27329. /**
  27330. * Renormalize the mesh and patch it up if there are no weights
  27331. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27332. * However in the case of zero weights then we set just a single influence to 1.
  27333. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27334. */
  27335. cleanMatrixWeights(): void;
  27336. private normalizeSkinFourWeights;
  27337. private normalizeSkinWeightsAndExtra;
  27338. /**
  27339. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27340. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27341. * the user know there was an issue with importing the mesh
  27342. * @returns a validation object with skinned, valid and report string
  27343. */
  27344. validateSkinning(): {
  27345. skinned: boolean;
  27346. valid: boolean;
  27347. report: string;
  27348. };
  27349. /** @hidden */
  27350. _checkDelayState(): Mesh;
  27351. private _queueLoad;
  27352. /**
  27353. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27354. * A mesh is in the frustum if its bounding box intersects the frustum
  27355. * @param frustumPlanes defines the frustum to test
  27356. * @returns true if the mesh is in the frustum planes
  27357. */
  27358. isInFrustum(frustumPlanes: Plane[]): boolean;
  27359. /**
  27360. * Sets the mesh material by the material or multiMaterial `id` property
  27361. * @param id is a string identifying the material or the multiMaterial
  27362. * @returns the current mesh
  27363. */
  27364. setMaterialByID(id: string): Mesh;
  27365. /**
  27366. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27367. * @returns an array of IAnimatable
  27368. */
  27369. getAnimatables(): IAnimatable[];
  27370. /**
  27371. * Modifies the mesh geometry according to the passed transformation matrix.
  27372. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27373. * The mesh normals are modified using the same transformation.
  27374. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27375. * @param transform defines the transform matrix to use
  27376. * @see http://doc.babylonjs.com/resources/baking_transformations
  27377. * @returns the current mesh
  27378. */
  27379. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27380. /**
  27381. * Modifies the mesh geometry according to its own current World Matrix.
  27382. * The mesh World Matrix is then reset.
  27383. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27384. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27385. * @see http://doc.babylonjs.com/resources/baking_transformations
  27386. * @returns the current mesh
  27387. */
  27388. bakeCurrentTransformIntoVertices(): Mesh;
  27389. /** @hidden */
  27390. readonly _positions: Nullable<Vector3[]>;
  27391. /** @hidden */
  27392. _resetPointsArrayCache(): Mesh;
  27393. /** @hidden */
  27394. _generatePointsArray(): boolean;
  27395. /**
  27396. * Returns a new Mesh object generated from the current mesh properties.
  27397. * This method must not get confused with createInstance()
  27398. * @param name is a string, the name given to the new mesh
  27399. * @param newParent can be any Node object (default `null`)
  27400. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27401. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27402. * @returns a new mesh
  27403. */
  27404. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27405. /**
  27406. * Releases resources associated with this mesh.
  27407. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27408. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27409. */
  27410. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27411. /**
  27412. * Modifies the mesh geometry according to a displacement map.
  27413. * 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.
  27414. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27415. * @param url is a string, the URL from the image file is to be downloaded.
  27416. * @param minHeight is the lower limit of the displacement.
  27417. * @param maxHeight is the upper limit of the displacement.
  27418. * @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.
  27419. * @param uvOffset is an optional vector2 used to offset UV.
  27420. * @param uvScale is an optional vector2 used to scale UV.
  27421. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  27422. * @returns the Mesh.
  27423. */
  27424. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27425. /**
  27426. * Modifies the mesh geometry according to a displacementMap buffer.
  27427. * 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.
  27428. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27429. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27430. * @param heightMapWidth is the width of the buffer image.
  27431. * @param heightMapHeight is the height of the buffer image.
  27432. * @param minHeight is the lower limit of the displacement.
  27433. * @param maxHeight is the upper limit of the displacement.
  27434. * @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.
  27435. * @param uvOffset is an optional vector2 used to offset UV.
  27436. * @param uvScale is an optional vector2 used to scale UV.
  27437. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  27438. * @returns the Mesh.
  27439. */
  27440. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27441. /**
  27442. * Modify the mesh to get a flat shading rendering.
  27443. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27444. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27445. * @returns current mesh
  27446. */
  27447. convertToFlatShadedMesh(): Mesh;
  27448. /**
  27449. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27450. * In other words, more vertices, no more indices and a single bigger VBO.
  27451. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27452. * @returns current mesh
  27453. */
  27454. convertToUnIndexedMesh(): Mesh;
  27455. /**
  27456. * Inverses facet orientations.
  27457. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27458. * @param flipNormals will also inverts the normals
  27459. * @returns current mesh
  27460. */
  27461. flipFaces(flipNormals?: boolean): Mesh;
  27462. /**
  27463. * Creates a new InstancedMesh object from the mesh model.
  27464. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27465. * @param name defines the name of the new instance
  27466. * @returns a new InstancedMesh
  27467. */
  27468. createInstance(name: string): InstancedMesh;
  27469. /**
  27470. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27471. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27472. * @returns the current mesh
  27473. */
  27474. synchronizeInstances(): Mesh;
  27475. /**
  27476. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27477. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27478. * This should be used together with the simplification to avoid disappearing triangles.
  27479. * @param successCallback an optional success callback to be called after the optimization finished.
  27480. * @returns the current mesh
  27481. */
  27482. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27483. /**
  27484. * Serialize current mesh
  27485. * @param serializationObject defines the object which will receive the serialization data
  27486. */
  27487. serialize(serializationObject: any): void;
  27488. /** @hidden */
  27489. _syncGeometryWithMorphTargetManager(): void;
  27490. /**
  27491. * Returns a new Mesh object parsed from the source provided.
  27492. * @param parsedMesh is the source
  27493. * @param scene defines the hosting scene
  27494. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27495. * @returns a new Mesh
  27496. */
  27497. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27498. /**
  27499. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27500. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27501. * @param name defines the name of the mesh to create
  27502. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27503. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27504. * @param closePath creates a seam between the first and the last points of each path of the path array
  27505. * @param offset is taken in account only if the `pathArray` is containing a single path
  27506. * @param scene defines the hosting scene
  27507. * @param updatable defines if the mesh must be flagged as updatable
  27508. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27509. * @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)
  27510. * @returns a new Mesh
  27511. */
  27512. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27513. /**
  27514. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27515. * @param name defines the name of the mesh to create
  27516. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27517. * @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
  27518. * @param scene defines the hosting scene
  27519. * @param updatable defines if the mesh must be flagged as updatable
  27520. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27521. * @returns a new Mesh
  27522. */
  27523. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27524. /**
  27525. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27526. * @param name defines the name of the mesh to create
  27527. * @param size sets the size (float) of each box side (default 1)
  27528. * @param scene defines the hosting scene
  27529. * @param updatable defines if the mesh must be flagged as updatable
  27530. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27531. * @returns a new Mesh
  27532. */
  27533. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27534. /**
  27535. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27536. * @param name defines the name of the mesh to create
  27537. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27538. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27539. * @param scene defines the hosting scene
  27540. * @param updatable defines if the mesh must be flagged as updatable
  27541. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27542. * @returns a new Mesh
  27543. */
  27544. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27545. /**
  27546. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27547. * @param name defines the name of the mesh to create
  27548. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27549. * @param diameterTop set the top cap diameter (floats, default 1)
  27550. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27551. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27552. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27553. * @param scene defines the hosting scene
  27554. * @param updatable defines if the mesh must be flagged as updatable
  27555. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27556. * @returns a new Mesh
  27557. */
  27558. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27559. /**
  27560. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27561. * @param name defines the name of the mesh to create
  27562. * @param diameter sets the diameter size (float) of the torus (default 1)
  27563. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27564. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27565. * @param scene defines the hosting scene
  27566. * @param updatable defines if the mesh must be flagged as updatable
  27567. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27568. * @returns a new Mesh
  27569. */
  27570. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27571. /**
  27572. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27573. * @param name defines the name of the mesh to create
  27574. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27575. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27576. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27577. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27578. * @param p the number of windings on X axis (positive integers, default 2)
  27579. * @param q the number of windings on Y axis (positive integers, default 3)
  27580. * @param scene defines the hosting scene
  27581. * @param updatable defines if the mesh must be flagged as updatable
  27582. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27583. * @returns a new Mesh
  27584. */
  27585. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27586. /**
  27587. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27588. * @param name defines the name of the mesh to create
  27589. * @param points is an array successive Vector3
  27590. * @param scene defines the hosting scene
  27591. * @param updatable defines if the mesh must be flagged as updatable
  27592. * @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).
  27593. * @returns a new Mesh
  27594. */
  27595. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27596. /**
  27597. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27598. * @param name defines the name of the mesh to create
  27599. * @param points is an array successive Vector3
  27600. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27601. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27602. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27603. * @param scene defines the hosting scene
  27604. * @param updatable defines if the mesh must be flagged as updatable
  27605. * @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)
  27606. * @returns a new Mesh
  27607. */
  27608. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27609. /**
  27610. * Creates a polygon mesh.
  27611. * Please consider using the same method from the MeshBuilder class instead.
  27612. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27613. * 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.
  27614. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27615. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27616. * Remember you can only change the shape positions, not their number when updating a polygon.
  27617. */
  27618. /**
  27619. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27620. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27621. * @param name defines the name of the mesh to create
  27622. * @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
  27623. * @param scene defines the hosting scene
  27624. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27625. * @param updatable defines if the mesh must be flagged as updatable
  27626. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27627. * @returns a new Mesh
  27628. */
  27629. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27630. /**
  27631. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27632. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27633. * @param name defines the name of the mesh to create
  27634. * @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
  27635. * @param depth defines the height of extrusion
  27636. * @param scene defines the hosting scene
  27637. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27638. * @param updatable defines if the mesh must be flagged as updatable
  27639. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27640. * @returns a new Mesh
  27641. */
  27642. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27643. /**
  27644. * Creates an extruded shape mesh.
  27645. * 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
  27646. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27647. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27648. * @param name defines the name of the mesh to create
  27649. * @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
  27650. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27651. * @param scale is the value to scale the shape
  27652. * @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
  27653. * @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
  27654. * @param scene defines the hosting scene
  27655. * @param updatable defines if the mesh must be flagged as updatable
  27656. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27657. * @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)
  27658. * @returns a new Mesh
  27659. */
  27660. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27661. /**
  27662. * Creates an custom extruded shape mesh.
  27663. * The custom extrusion is a parametric shape.
  27664. * It has no predefined shape. Its final shape will depend on the input parameters.
  27665. * Please consider using the same method from the MeshBuilder class instead
  27666. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27667. * @param name defines the name of the mesh to create
  27668. * @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
  27669. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27670. * @param scaleFunction is a custom Javascript function called on each path point
  27671. * @param rotationFunction is a custom Javascript function called on each path point
  27672. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27673. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27674. * @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
  27675. * @param scene defines the hosting scene
  27676. * @param updatable defines if the mesh must be flagged as updatable
  27677. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27678. * @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)
  27679. * @returns a new Mesh
  27680. */
  27681. 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;
  27682. /**
  27683. * Creates lathe mesh.
  27684. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27685. * Please consider using the same method from the MeshBuilder class instead
  27686. * @param name defines the name of the mesh to create
  27687. * @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
  27688. * @param radius is the radius value of the lathe
  27689. * @param tessellation is the side number of the lathe.
  27690. * @param scene defines the hosting scene
  27691. * @param updatable defines if the mesh must be flagged as updatable
  27692. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27693. * @returns a new Mesh
  27694. */
  27695. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27696. /**
  27697. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27698. * @param name defines the name of the mesh to create
  27699. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27700. * @param scene defines the hosting scene
  27701. * @param updatable defines if the mesh must be flagged as updatable
  27702. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27703. * @returns a new Mesh
  27704. */
  27705. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27706. /**
  27707. * Creates a ground mesh.
  27708. * Please consider using the same method from the MeshBuilder class instead
  27709. * @param name defines the name of the mesh to create
  27710. * @param width set the width of the ground
  27711. * @param height set the height of the ground
  27712. * @param subdivisions sets the number of subdivisions per side
  27713. * @param scene defines the hosting scene
  27714. * @param updatable defines if the mesh must be flagged as updatable
  27715. * @returns a new Mesh
  27716. */
  27717. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27718. /**
  27719. * Creates a tiled ground mesh.
  27720. * Please consider using the same method from the MeshBuilder class instead
  27721. * @param name defines the name of the mesh to create
  27722. * @param xmin set the ground minimum X coordinate
  27723. * @param zmin set the ground minimum Y coordinate
  27724. * @param xmax set the ground maximum X coordinate
  27725. * @param zmax set the ground maximum Z coordinate
  27726. * @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
  27727. * @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
  27728. * @param scene defines the hosting scene
  27729. * @param updatable defines if the mesh must be flagged as updatable
  27730. * @returns a new Mesh
  27731. */
  27732. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27733. w: number;
  27734. h: number;
  27735. }, precision: {
  27736. w: number;
  27737. h: number;
  27738. }, scene: Scene, updatable?: boolean): Mesh;
  27739. /**
  27740. * Creates a ground mesh from a height map.
  27741. * Please consider using the same method from the MeshBuilder class instead
  27742. * @see http://doc.babylonjs.com/babylon101/height_map
  27743. * @param name defines the name of the mesh to create
  27744. * @param url sets the URL of the height map image resource
  27745. * @param width set the ground width size
  27746. * @param height set the ground height size
  27747. * @param subdivisions sets the number of subdivision per side
  27748. * @param minHeight is the minimum altitude on the ground
  27749. * @param maxHeight is the maximum altitude on the ground
  27750. * @param scene defines the hosting scene
  27751. * @param updatable defines if the mesh must be flagged as updatable
  27752. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27753. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27754. * @returns a new Mesh
  27755. */
  27756. 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;
  27757. /**
  27758. * Creates a tube mesh.
  27759. * The tube is a parametric shape.
  27760. * It has no predefined shape. Its final shape will depend on the input parameters.
  27761. * Please consider using the same method from the MeshBuilder class instead
  27762. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27763. * @param name defines the name of the mesh to create
  27764. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27765. * @param radius sets the tube radius size
  27766. * @param tessellation is the number of sides on the tubular surface
  27767. * @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
  27768. * @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
  27769. * @param scene defines the hosting scene
  27770. * @param updatable defines if the mesh must be flagged as updatable
  27771. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27772. * @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)
  27773. * @returns a new Mesh
  27774. */
  27775. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27776. (i: number, distance: number): number;
  27777. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27778. /**
  27779. * Creates a polyhedron mesh.
  27780. * Please consider using the same method from the MeshBuilder class instead.
  27781. * * 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
  27782. * * The parameter `size` (positive float, default 1) sets the polygon size
  27783. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27784. * * 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`
  27785. * * 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
  27786. * * 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)`)
  27787. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  27788. * * 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
  27789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27790. * * 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
  27791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27792. * @param name defines the name of the mesh to create
  27793. * @param options defines the options used to create the mesh
  27794. * @param scene defines the hosting scene
  27795. * @returns a new Mesh
  27796. */
  27797. static CreatePolyhedron(name: string, options: {
  27798. type?: number;
  27799. size?: number;
  27800. sizeX?: number;
  27801. sizeY?: number;
  27802. sizeZ?: number;
  27803. custom?: any;
  27804. faceUV?: Vector4[];
  27805. faceColors?: Color4[];
  27806. updatable?: boolean;
  27807. sideOrientation?: number;
  27808. }, scene: Scene): Mesh;
  27809. /**
  27810. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27811. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27812. * * 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`)
  27813. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27814. * * 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
  27815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27816. * * 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
  27817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27818. * @param name defines the name of the mesh
  27819. * @param options defines the options used to create the mesh
  27820. * @param scene defines the hosting scene
  27821. * @returns a new Mesh
  27822. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27823. */
  27824. static CreateIcoSphere(name: string, options: {
  27825. radius?: number;
  27826. flat?: boolean;
  27827. subdivisions?: number;
  27828. sideOrientation?: number;
  27829. updatable?: boolean;
  27830. }, scene: Scene): Mesh;
  27831. /**
  27832. * Creates a decal mesh.
  27833. * Please consider using the same method from the MeshBuilder class instead.
  27834. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27835. * @param name defines the name of the mesh
  27836. * @param sourceMesh defines the mesh receiving the decal
  27837. * @param position sets the position of the decal in world coordinates
  27838. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27839. * @param size sets the decal scaling
  27840. * @param angle sets the angle to rotate the decal
  27841. * @returns a new Mesh
  27842. */
  27843. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27844. /**
  27845. * Prepare internal position array for software CPU skinning
  27846. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27847. */
  27848. setPositionsForCPUSkinning(): Float32Array;
  27849. /**
  27850. * Prepare internal normal array for software CPU skinning
  27851. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27852. */
  27853. setNormalsForCPUSkinning(): Float32Array;
  27854. /**
  27855. * Updates the vertex buffer by applying transformation from the bones
  27856. * @param skeleton defines the skeleton to apply to current mesh
  27857. * @returns the current mesh
  27858. */
  27859. applySkeleton(skeleton: Skeleton): Mesh;
  27860. /**
  27861. * 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
  27862. * @param meshes defines the list of meshes to scan
  27863. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27864. */
  27865. static MinMax(meshes: AbstractMesh[]): {
  27866. min: Vector3;
  27867. max: Vector3;
  27868. };
  27869. /**
  27870. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27871. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27872. * @returns a vector3
  27873. */
  27874. static Center(meshesOrMinMaxVector: {
  27875. min: Vector3;
  27876. max: Vector3;
  27877. } | AbstractMesh[]): Vector3;
  27878. /**
  27879. * Merge the array of meshes into a single mesh for performance reasons.
  27880. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27881. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27882. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27883. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27884. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27885. * @returns a new mesh
  27886. */
  27887. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27888. /** @hidden */
  27889. addInstance(instance: InstancedMesh): void;
  27890. /** @hidden */
  27891. removeInstance(instance: InstancedMesh): void;
  27892. }
  27893. }
  27894. declare module BABYLON {
  27895. /**
  27896. * Define an interface for all classes that will get and set the data on vertices
  27897. */
  27898. interface IGetSetVerticesData {
  27899. /**
  27900. * Gets a boolean indicating if specific vertex data is present
  27901. * @param kind defines the vertex data kind to use
  27902. * @returns true is data kind is present
  27903. */
  27904. isVerticesDataPresent(kind: string): boolean;
  27905. /**
  27906. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27907. * @param kind defines the data kind (Position, normal, etc...)
  27908. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27909. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27910. * @returns a float array containing vertex data
  27911. */
  27912. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27913. /**
  27914. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27915. * @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.
  27916. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27917. * @returns the indices array or an empty array if the mesh has no geometry
  27918. */
  27919. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27920. /**
  27921. * Set specific vertex data
  27922. * @param kind defines the data kind (Position, normal, etc...)
  27923. * @param data defines the vertex data to use
  27924. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27925. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27926. */
  27927. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27928. /**
  27929. * Update a specific associated vertex buffer
  27930. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27931. * - BABYLON.VertexBuffer.PositionKind
  27932. * - BABYLON.VertexBuffer.UVKind
  27933. * - BABYLON.VertexBuffer.UV2Kind
  27934. * - BABYLON.VertexBuffer.UV3Kind
  27935. * - BABYLON.VertexBuffer.UV4Kind
  27936. * - BABYLON.VertexBuffer.UV5Kind
  27937. * - BABYLON.VertexBuffer.UV6Kind
  27938. * - BABYLON.VertexBuffer.ColorKind
  27939. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27940. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27941. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27942. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27943. * @param data defines the data source
  27944. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27945. * @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)
  27946. */
  27947. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27948. /**
  27949. * Creates a new index buffer
  27950. * @param indices defines the indices to store in the index buffer
  27951. * @param totalVertices defines the total number of vertices (could be null)
  27952. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27953. */
  27954. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27955. }
  27956. /**
  27957. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27958. */
  27959. class VertexData {
  27960. /**
  27961. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27962. */
  27963. positions: Nullable<FloatArray>;
  27964. /**
  27965. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27966. */
  27967. normals: Nullable<FloatArray>;
  27968. /**
  27969. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27970. */
  27971. tangents: Nullable<FloatArray>;
  27972. /**
  27973. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27974. */
  27975. uvs: Nullable<FloatArray>;
  27976. /**
  27977. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27978. */
  27979. uvs2: Nullable<FloatArray>;
  27980. /**
  27981. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27982. */
  27983. uvs3: Nullable<FloatArray>;
  27984. /**
  27985. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27986. */
  27987. uvs4: Nullable<FloatArray>;
  27988. /**
  27989. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27990. */
  27991. uvs5: Nullable<FloatArray>;
  27992. /**
  27993. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27994. */
  27995. uvs6: Nullable<FloatArray>;
  27996. /**
  27997. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27998. */
  27999. colors: Nullable<FloatArray>;
  28000. /**
  28001. * 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).
  28002. */
  28003. matricesIndices: Nullable<FloatArray>;
  28004. /**
  28005. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  28006. */
  28007. matricesWeights: Nullable<FloatArray>;
  28008. /**
  28009. * An array extending the number of possible indices
  28010. */
  28011. matricesIndicesExtra: Nullable<FloatArray>;
  28012. /**
  28013. * An array extending the number of possible weights when the number of indices is extended
  28014. */
  28015. matricesWeightsExtra: Nullable<FloatArray>;
  28016. /**
  28017. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  28018. */
  28019. indices: Nullable<IndicesArray>;
  28020. /**
  28021. * Uses the passed data array to set the set the values for the specified kind of data
  28022. * @param data a linear array of floating numbers
  28023. * @param kind the type of data that is being set, eg positions, colors etc
  28024. */
  28025. set(data: FloatArray, kind: string): void;
  28026. /**
  28027. * Associates the vertexData to the passed Mesh.
  28028. * Sets it as updatable or not (default `false`)
  28029. * @param mesh the mesh the vertexData is applied to
  28030. * @param updatable when used and having the value true allows new data to update the vertexData
  28031. * @returns the VertexData
  28032. */
  28033. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  28034. /**
  28035. * Associates the vertexData to the passed Geometry.
  28036. * Sets it as updatable or not (default `false`)
  28037. * @param geometry the geometry the vertexData is applied to
  28038. * @param updatable when used and having the value true allows new data to update the vertexData
  28039. * @returns VertexData
  28040. */
  28041. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  28042. /**
  28043. * Updates the associated mesh
  28044. * @param mesh the mesh to be updated
  28045. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  28046. * @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
  28047. * @returns VertexData
  28048. */
  28049. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  28050. /**
  28051. * Updates the associated geometry
  28052. * @param geometry the geometry to be updated
  28053. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  28054. * @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
  28055. * @returns VertexData.
  28056. */
  28057. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  28058. private _applyTo;
  28059. private _update;
  28060. /**
  28061. * Transforms each position and each normal of the vertexData according to the passed Matrix
  28062. * @param matrix the transforming matrix
  28063. * @returns the VertexData
  28064. */
  28065. transform(matrix: Matrix): VertexData;
  28066. /**
  28067. * Merges the passed VertexData into the current one
  28068. * @param other the VertexData to be merged into the current one
  28069. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  28070. * @returns the modified VertexData
  28071. */
  28072. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  28073. private _mergeElement;
  28074. private _validate;
  28075. /**
  28076. * Serializes the VertexData
  28077. * @returns a serialized object
  28078. */
  28079. serialize(): any;
  28080. /**
  28081. * Extracts the vertexData from a mesh
  28082. * @param mesh the mesh from which to extract the VertexData
  28083. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  28084. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  28085. * @returns the object VertexData associated to the passed mesh
  28086. */
  28087. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  28088. /**
  28089. * Extracts the vertexData from the geometry
  28090. * @param geometry the geometry from which to extract the VertexData
  28091. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  28092. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  28093. * @returns the object VertexData associated to the passed mesh
  28094. */
  28095. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  28096. private static _ExtractFrom;
  28097. /**
  28098. * Creates the VertexData for a Ribbon
  28099. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  28100. * * pathArray array of paths, each of which an array of successive Vector3
  28101. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  28102. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  28103. * * 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
  28104. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28105. * * 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)
  28106. * * 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)
  28107. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  28108. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  28109. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  28110. * @returns the VertexData of the ribbon
  28111. */
  28112. static CreateRibbon(options: {
  28113. pathArray: Vector3[][];
  28114. closeArray?: boolean;
  28115. closePath?: boolean;
  28116. offset?: number;
  28117. sideOrientation?: number;
  28118. frontUVs?: Vector4;
  28119. backUVs?: Vector4;
  28120. invertUV?: boolean;
  28121. uvs?: Vector2[];
  28122. colors?: Color4[];
  28123. }): VertexData;
  28124. /**
  28125. * Creates the VertexData for a box
  28126. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28127. * * size sets the width, height and depth of the box to the value of size, optional default 1
  28128. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  28129. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  28130. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  28131. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  28132. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  28133. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28134. * * 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)
  28135. * * 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)
  28136. * @returns the VertexData of the box
  28137. */
  28138. static CreateBox(options: {
  28139. size?: number;
  28140. width?: number;
  28141. height?: number;
  28142. depth?: number;
  28143. faceUV?: Vector4[];
  28144. faceColors?: Color4[];
  28145. sideOrientation?: number;
  28146. frontUVs?: Vector4;
  28147. backUVs?: Vector4;
  28148. }): VertexData;
  28149. /**
  28150. * Creates the VertexData for an ellipsoid, defaults to a sphere
  28151. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28152. * * segments sets the number of horizontal strips optional, default 32
  28153. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  28154. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  28155. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  28156. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  28157. * * 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
  28158. * * 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
  28159. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28160. * * 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)
  28161. * * 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)
  28162. * @returns the VertexData of the ellipsoid
  28163. */
  28164. static CreateSphere(options: {
  28165. segments?: number;
  28166. diameter?: number;
  28167. diameterX?: number;
  28168. diameterY?: number;
  28169. diameterZ?: number;
  28170. arc?: number;
  28171. slice?: number;
  28172. sideOrientation?: number;
  28173. frontUVs?: Vector4;
  28174. backUVs?: Vector4;
  28175. }): VertexData;
  28176. /**
  28177. * Creates the VertexData for a cylinder, cone or prism
  28178. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28179. * * height sets the height (y direction) of the cylinder, optional, default 2
  28180. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  28181. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  28182. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  28183. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  28184. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  28185. * * 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
  28186. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28187. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28188. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  28189. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  28190. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28191. * * 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)
  28192. * * 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)
  28193. * @returns the VertexData of the cylinder, cone or prism
  28194. */
  28195. static CreateCylinder(options: {
  28196. height?: number;
  28197. diameterTop?: number;
  28198. diameterBottom?: number;
  28199. diameter?: number;
  28200. tessellation?: number;
  28201. subdivisions?: number;
  28202. arc?: number;
  28203. faceColors?: Color4[];
  28204. faceUV?: Vector4[];
  28205. hasRings?: boolean;
  28206. enclose?: boolean;
  28207. sideOrientation?: number;
  28208. frontUVs?: Vector4;
  28209. backUVs?: Vector4;
  28210. }): VertexData;
  28211. /**
  28212. * Creates the VertexData for a torus
  28213. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28214. * * diameter the diameter of the torus, optional default 1
  28215. * * thickness the diameter of the tube forming the torus, optional default 0.5
  28216. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  28217. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28218. * * 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)
  28219. * * 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)
  28220. * @returns the VertexData of the torus
  28221. */
  28222. static CreateTorus(options: {
  28223. diameter?: number;
  28224. thickness?: number;
  28225. tessellation?: number;
  28226. sideOrientation?: number;
  28227. frontUVs?: Vector4;
  28228. backUVs?: Vector4;
  28229. }): VertexData;
  28230. /**
  28231. * Creates the VertexData of the LineSystem
  28232. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  28233. * - lines an array of lines, each line being an array of successive Vector3
  28234. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  28235. * @returns the VertexData of the LineSystem
  28236. */
  28237. static CreateLineSystem(options: {
  28238. lines: Vector3[][];
  28239. colors?: Nullable<Color4[][]>;
  28240. }): VertexData;
  28241. /**
  28242. * Create the VertexData for a DashedLines
  28243. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  28244. * - points an array successive Vector3
  28245. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  28246. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  28247. * - dashNb the intended total number of dashes, optional, default 200
  28248. * @returns the VertexData for the DashedLines
  28249. */
  28250. static CreateDashedLines(options: {
  28251. points: Vector3[];
  28252. dashSize?: number;
  28253. gapSize?: number;
  28254. dashNb?: number;
  28255. }): VertexData;
  28256. /**
  28257. * Creates the VertexData for a Ground
  28258. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  28259. * - width the width (x direction) of the ground, optional, default 1
  28260. * - height the height (z direction) of the ground, optional, default 1
  28261. * - subdivisions the number of subdivisions per side, optional, default 1
  28262. * @returns the VertexData of the Ground
  28263. */
  28264. static CreateGround(options: {
  28265. width?: number;
  28266. height?: number;
  28267. subdivisions?: number;
  28268. subdivisionsX?: number;
  28269. subdivisionsY?: number;
  28270. }): VertexData;
  28271. /**
  28272. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  28273. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  28274. * * xmin the ground minimum X coordinate, optional, default -1
  28275. * * zmin the ground minimum Z coordinate, optional, default -1
  28276. * * xmax the ground maximum X coordinate, optional, default 1
  28277. * * zmax the ground maximum Z coordinate, optional, default 1
  28278. * * 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}
  28279. * * 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}
  28280. * @returns the VertexData of the TiledGround
  28281. */
  28282. static CreateTiledGround(options: {
  28283. xmin: number;
  28284. zmin: number;
  28285. xmax: number;
  28286. zmax: number;
  28287. subdivisions?: {
  28288. w: number;
  28289. h: number;
  28290. };
  28291. precision?: {
  28292. w: number;
  28293. h: number;
  28294. };
  28295. }): VertexData;
  28296. /**
  28297. * Creates the VertexData of the Ground designed from a heightmap
  28298. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  28299. * * width the width (x direction) of the ground
  28300. * * height the height (z direction) of the ground
  28301. * * subdivisions the number of subdivisions per side
  28302. * * minHeight the minimum altitude on the ground, optional, default 0
  28303. * * maxHeight the maximum altitude on the ground, optional default 1
  28304. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  28305. * * buffer the array holding the image color data
  28306. * * bufferWidth the width of image
  28307. * * bufferHeight the height of image
  28308. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  28309. * @returns the VertexData of the Ground designed from a heightmap
  28310. */
  28311. static CreateGroundFromHeightMap(options: {
  28312. width: number;
  28313. height: number;
  28314. subdivisions: number;
  28315. minHeight: number;
  28316. maxHeight: number;
  28317. colorFilter: Color3;
  28318. buffer: Uint8Array;
  28319. bufferWidth: number;
  28320. bufferHeight: number;
  28321. alphaFilter: number;
  28322. }): VertexData;
  28323. /**
  28324. * Creates the VertexData for a Plane
  28325. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  28326. * * size sets the width and height of the plane to the value of size, optional default 1
  28327. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  28328. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  28329. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28330. * * 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)
  28331. * * 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)
  28332. * @returns the VertexData of the box
  28333. */
  28334. static CreatePlane(options: {
  28335. size?: number;
  28336. width?: number;
  28337. height?: number;
  28338. sideOrientation?: number;
  28339. frontUVs?: Vector4;
  28340. backUVs?: Vector4;
  28341. }): VertexData;
  28342. /**
  28343. * Creates the VertexData of the Disc or regular Polygon
  28344. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  28345. * * radius the radius of the disc, optional default 0.5
  28346. * * tessellation the number of polygon sides, optional, default 64
  28347. * * 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
  28348. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28349. * * 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)
  28350. * * 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)
  28351. * @returns the VertexData of the box
  28352. */
  28353. static CreateDisc(options: {
  28354. radius?: number;
  28355. tessellation?: number;
  28356. arc?: number;
  28357. sideOrientation?: number;
  28358. frontUVs?: Vector4;
  28359. backUVs?: Vector4;
  28360. }): VertexData;
  28361. /**
  28362. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  28363. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  28364. * @param polygon a mesh built from polygonTriangulation.build()
  28365. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28366. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28367. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28368. * @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)
  28369. * @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)
  28370. * @returns the VertexData of the Polygon
  28371. */
  28372. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  28373. /**
  28374. * Creates the VertexData of the IcoSphere
  28375. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  28376. * * radius the radius of the IcoSphere, optional default 1
  28377. * * radiusX allows stretching in the x direction, optional, default radius
  28378. * * radiusY allows stretching in the y direction, optional, default radius
  28379. * * radiusZ allows stretching in the z direction, optional, default radius
  28380. * * flat when true creates a flat shaded mesh, optional, default true
  28381. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28382. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28383. * * 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)
  28384. * * 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)
  28385. * @returns the VertexData of the IcoSphere
  28386. */
  28387. static CreateIcoSphere(options: {
  28388. radius?: number;
  28389. radiusX?: number;
  28390. radiusY?: number;
  28391. radiusZ?: number;
  28392. flat?: boolean;
  28393. subdivisions?: number;
  28394. sideOrientation?: number;
  28395. frontUVs?: Vector4;
  28396. backUVs?: Vector4;
  28397. }): VertexData;
  28398. /**
  28399. * Creates the VertexData for a Polyhedron
  28400. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  28401. * * type provided types are:
  28402. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  28403. * * 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)
  28404. * * size the size of the IcoSphere, optional default 1
  28405. * * sizeX allows stretching in the x direction, optional, default size
  28406. * * sizeY allows stretching in the y direction, optional, default size
  28407. * * sizeZ allows stretching in the z direction, optional, default size
  28408. * * 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
  28409. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28410. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28411. * * flat when true creates a flat shaded mesh, optional, default true
  28412. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28413. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28414. * * 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)
  28415. * * 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)
  28416. * @returns the VertexData of the Polyhedron
  28417. */
  28418. static CreatePolyhedron(options: {
  28419. type?: number;
  28420. size?: number;
  28421. sizeX?: number;
  28422. sizeY?: number;
  28423. sizeZ?: number;
  28424. custom?: any;
  28425. faceUV?: Vector4[];
  28426. faceColors?: Color4[];
  28427. flat?: boolean;
  28428. sideOrientation?: number;
  28429. frontUVs?: Vector4;
  28430. backUVs?: Vector4;
  28431. }): VertexData;
  28432. /**
  28433. * Creates the VertexData for a TorusKnot
  28434. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  28435. * * radius the radius of the torus knot, optional, default 2
  28436. * * tube the thickness of the tube, optional, default 0.5
  28437. * * radialSegments the number of sides on each tube segments, optional, default 32
  28438. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  28439. * * p the number of windings around the z axis, optional, default 2
  28440. * * q the number of windings around the x axis, optional, default 3
  28441. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28442. * * 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)
  28443. * * 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)
  28444. * @returns the VertexData of the Torus Knot
  28445. */
  28446. static CreateTorusKnot(options: {
  28447. radius?: number;
  28448. tube?: number;
  28449. radialSegments?: number;
  28450. tubularSegments?: number;
  28451. p?: number;
  28452. q?: number;
  28453. sideOrientation?: number;
  28454. frontUVs?: Vector4;
  28455. backUVs?: Vector4;
  28456. }): VertexData;
  28457. /**
  28458. * Compute normals for given positions and indices
  28459. * @param positions an array of vertex positions, [...., x, y, z, ......]
  28460. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  28461. * @param normals an array of vertex normals, [...., x, y, z, ......]
  28462. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  28463. * * facetNormals : optional array of facet normals (vector3)
  28464. * * facetPositions : optional array of facet positions (vector3)
  28465. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  28466. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  28467. * * bInfo : optional bounding info, required for facetPartitioning computation
  28468. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  28469. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  28470. * * useRightHandedSystem: optional boolean to for right handed system computation
  28471. * * depthSort : optional boolean to enable the facet depth sort computation
  28472. * * distanceTo : optional Vector3 to compute the facet depth from this location
  28473. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  28474. */
  28475. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  28476. facetNormals?: any;
  28477. facetPositions?: any;
  28478. facetPartitioning?: any;
  28479. ratio?: number;
  28480. bInfo?: any;
  28481. bbSize?: Vector3;
  28482. subDiv?: any;
  28483. useRightHandedSystem?: boolean;
  28484. depthSort?: boolean;
  28485. distanceTo?: Vector3;
  28486. depthSortedFacets?: any;
  28487. }): void;
  28488. private static _ComputeSides;
  28489. /**
  28490. * Applies VertexData created from the imported parameters to the geometry
  28491. * @param parsedVertexData the parsed data from an imported file
  28492. * @param geometry the geometry to apply the VertexData to
  28493. */
  28494. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  28495. }
  28496. }
  28497. declare module BABYLON {
  28498. /**
  28499. * Class containing static functions to help procedurally build meshes
  28500. */
  28501. class MeshBuilder {
  28502. private static updateSideOrientation;
  28503. /**
  28504. * Creates a box mesh
  28505. * * The parameter `size` sets the size (float) of each box side (default 1)
  28506. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  28507. * * 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)
  28508. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28512. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  28513. * @param name defines the name of the mesh
  28514. * @param options defines the options used to create the mesh
  28515. * @param scene defines the hosting scene
  28516. * @returns the box mesh
  28517. */
  28518. static CreateBox(name: string, options: {
  28519. size?: number;
  28520. width?: number;
  28521. height?: number;
  28522. depth?: number;
  28523. faceUV?: Vector4[];
  28524. faceColors?: Color4[];
  28525. sideOrientation?: number;
  28526. frontUVs?: Vector4;
  28527. backUVs?: Vector4;
  28528. updatable?: boolean;
  28529. }, scene?: Nullable<Scene>): Mesh;
  28530. /**
  28531. * Creates a sphere mesh
  28532. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  28533. * * 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`)
  28534. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  28535. * * 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
  28536. * * 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)
  28537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28540. * @param name defines the name of the mesh
  28541. * @param options defines the options used to create the mesh
  28542. * @param scene defines the hosting scene
  28543. * @returns the sphere mesh
  28544. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  28545. */
  28546. static CreateSphere(name: string, options: {
  28547. segments?: number;
  28548. diameter?: number;
  28549. diameterX?: number;
  28550. diameterY?: number;
  28551. diameterZ?: number;
  28552. arc?: number;
  28553. slice?: number;
  28554. sideOrientation?: number;
  28555. frontUVs?: Vector4;
  28556. backUVs?: Vector4;
  28557. updatable?: boolean;
  28558. }, scene: any): Mesh;
  28559. /**
  28560. * Creates a plane polygonal mesh. By default, this is a disc
  28561. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28562. * * 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
  28563. * * 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
  28564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28567. * @param name defines the name of the mesh
  28568. * @param options defines the options used to create the mesh
  28569. * @param scene defines the hosting scene
  28570. * @returns the plane polygonal mesh
  28571. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28572. */
  28573. static CreateDisc(name: string, options: {
  28574. radius?: number;
  28575. tessellation?: number;
  28576. arc?: number;
  28577. updatable?: boolean;
  28578. sideOrientation?: number;
  28579. frontUVs?: Vector4;
  28580. backUVs?: Vector4;
  28581. }, scene?: Nullable<Scene>): Mesh;
  28582. /**
  28583. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28584. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28585. * * 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`)
  28586. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28587. * * 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
  28588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28591. * @param name defines the name of the mesh
  28592. * @param options defines the options used to create the mesh
  28593. * @param scene defines the hosting scene
  28594. * @returns the icosahedron mesh
  28595. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28596. */
  28597. static CreateIcoSphere(name: string, options: {
  28598. radius?: number;
  28599. radiusX?: number;
  28600. radiusY?: number;
  28601. radiusZ?: number;
  28602. flat?: boolean;
  28603. subdivisions?: number;
  28604. sideOrientation?: number;
  28605. frontUVs?: Vector4;
  28606. backUVs?: Vector4;
  28607. updatable?: boolean;
  28608. }, scene: Scene): Mesh;
  28609. /**
  28610. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28611. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28612. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28613. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28614. * * 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
  28615. * * 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
  28616. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  28617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28618. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28619. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28620. * * 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
  28621. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28622. * * 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
  28623. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28625. * @param name defines the name of the mesh
  28626. * @param options defines the options used to create the mesh
  28627. * @param scene defines the hosting scene
  28628. * @returns the ribbon mesh
  28629. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  28630. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28631. */
  28632. static CreateRibbon(name: string, options: {
  28633. pathArray: Vector3[][];
  28634. closeArray?: boolean;
  28635. closePath?: boolean;
  28636. offset?: number;
  28637. updatable?: boolean;
  28638. sideOrientation?: number;
  28639. frontUVs?: Vector4;
  28640. backUVs?: Vector4;
  28641. instance?: Mesh;
  28642. invertUV?: boolean;
  28643. uvs?: Vector2[];
  28644. colors?: Color4[];
  28645. }, scene?: Nullable<Scene>): Mesh;
  28646. /**
  28647. * Creates a cylinder or a cone mesh
  28648. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28649. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28650. * * 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.
  28651. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28652. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28653. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28654. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28655. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28656. * * 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).
  28657. * * 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
  28658. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28659. * * 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
  28660. * * 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.
  28661. * * If `enclose` is false, a ring surface is one element.
  28662. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28663. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  28664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28667. * @param name defines the name of the mesh
  28668. * @param options defines the options used to create the mesh
  28669. * @param scene defines the hosting scene
  28670. * @returns the cylinder mesh
  28671. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  28672. */
  28673. static CreateCylinder(name: string, options: {
  28674. height?: number;
  28675. diameterTop?: number;
  28676. diameterBottom?: number;
  28677. diameter?: number;
  28678. tessellation?: number;
  28679. subdivisions?: number;
  28680. arc?: number;
  28681. faceColors?: Color4[];
  28682. faceUV?: Vector4[];
  28683. updatable?: boolean;
  28684. hasRings?: boolean;
  28685. enclose?: boolean;
  28686. sideOrientation?: number;
  28687. frontUVs?: Vector4;
  28688. backUVs?: Vector4;
  28689. }, scene: any): Mesh;
  28690. /**
  28691. * Creates a torus mesh
  28692. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28693. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28694. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28696. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28698. * @param name defines the name of the mesh
  28699. * @param options defines the options used to create the mesh
  28700. * @param scene defines the hosting scene
  28701. * @returns the torus mesh
  28702. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  28703. */
  28704. static CreateTorus(name: string, options: {
  28705. diameter?: number;
  28706. thickness?: number;
  28707. tessellation?: number;
  28708. updatable?: boolean;
  28709. sideOrientation?: number;
  28710. frontUVs?: Vector4;
  28711. backUVs?: Vector4;
  28712. }, scene: any): Mesh;
  28713. /**
  28714. * Creates a torus knot mesh
  28715. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28716. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28717. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28718. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28722. * @param name defines the name of the mesh
  28723. * @param options defines the options used to create the mesh
  28724. * @param scene defines the hosting scene
  28725. * @returns the torus knot mesh
  28726. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  28727. */
  28728. static CreateTorusKnot(name: string, options: {
  28729. radius?: number;
  28730. tube?: number;
  28731. radialSegments?: number;
  28732. tubularSegments?: number;
  28733. p?: number;
  28734. q?: number;
  28735. updatable?: boolean;
  28736. sideOrientation?: number;
  28737. frontUVs?: Vector4;
  28738. backUVs?: Vector4;
  28739. }, scene: any): Mesh;
  28740. /**
  28741. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28742. * * 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
  28743. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28744. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28745. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28746. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28747. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28748. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  28749. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28752. * @param name defines the name of the new line system
  28753. * @param options defines the options used to create the line system
  28754. * @param scene defines the hosting scene
  28755. * @returns a new line system mesh
  28756. */
  28757. static CreateLineSystem(name: string, options: {
  28758. lines: Vector3[][];
  28759. updatable?: boolean;
  28760. instance?: Nullable<LinesMesh>;
  28761. colors?: Nullable<Color4[][]>;
  28762. useVertexAlpha?: boolean;
  28763. }, scene: Nullable<Scene>): LinesMesh;
  28764. /**
  28765. * Creates a line mesh
  28766. * 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
  28767. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28768. * * The parameter `points` is an array successive Vector3
  28769. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  28770. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28771. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28772. * * When updating an instance, remember that only point positions can change, not the number of points
  28773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28774. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  28775. * @param name defines the name of the new line system
  28776. * @param options defines the options used to create the line system
  28777. * @param scene defines the hosting scene
  28778. * @returns a new line mesh
  28779. */
  28780. static CreateLines(name: string, options: {
  28781. points: Vector3[];
  28782. updatable?: boolean;
  28783. instance?: Nullable<LinesMesh>;
  28784. colors?: Color4[];
  28785. useVertexAlpha?: boolean;
  28786. }, scene?: Nullable<Scene>): LinesMesh;
  28787. /**
  28788. * Creates a dashed line mesh
  28789. * * 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
  28790. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28791. * * The parameter `points` is an array successive Vector3
  28792. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28793. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28794. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28795. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  28796. * * When updating an instance, remember that only point positions can change, not the number of points
  28797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28798. * @param name defines the name of the mesh
  28799. * @param options defines the options used to create the mesh
  28800. * @param scene defines the hosting scene
  28801. * @returns the dashed line mesh
  28802. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28803. */
  28804. static CreateDashedLines(name: string, options: {
  28805. points: Vector3[];
  28806. dashSize?: number;
  28807. gapSize?: number;
  28808. dashNb?: number;
  28809. updatable?: boolean;
  28810. instance?: LinesMesh;
  28811. }, scene?: Nullable<Scene>): LinesMesh;
  28812. /**
  28813. * 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.
  28814. * * 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.
  28815. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28816. * * 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.
  28817. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28818. * * 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
  28819. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  28820. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28823. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28825. * @param name defines the name of the mesh
  28826. * @param options defines the options used to create the mesh
  28827. * @param scene defines the hosting scene
  28828. * @returns the extruded shape mesh
  28829. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28830. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28831. */
  28832. static ExtrudeShape(name: string, options: {
  28833. shape: Vector3[];
  28834. path: Vector3[];
  28835. scale?: number;
  28836. rotation?: number;
  28837. cap?: number;
  28838. updatable?: boolean;
  28839. sideOrientation?: number;
  28840. frontUVs?: Vector4;
  28841. backUVs?: Vector4;
  28842. instance?: Mesh;
  28843. invertUV?: boolean;
  28844. }, scene?: Nullable<Scene>): Mesh;
  28845. /**
  28846. * Creates an custom extruded shape mesh.
  28847. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28848. * * 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.
  28849. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28850. * * 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
  28851. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28852. * * 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
  28853. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28854. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28855. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28856. * * 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
  28857. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  28858. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28860. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28861. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28863. * @param name defines the name of the mesh
  28864. * @param options defines the options used to create the mesh
  28865. * @param scene defines the hosting scene
  28866. * @returns the custom extruded shape mesh
  28867. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28868. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28869. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28870. */
  28871. static ExtrudeShapeCustom(name: string, options: {
  28872. shape: Vector3[];
  28873. path: Vector3[];
  28874. scaleFunction?: any;
  28875. rotationFunction?: any;
  28876. ribbonCloseArray?: boolean;
  28877. ribbonClosePath?: boolean;
  28878. cap?: number;
  28879. updatable?: boolean;
  28880. sideOrientation?: number;
  28881. frontUVs?: Vector4;
  28882. backUVs?: Vector4;
  28883. instance?: Mesh;
  28884. invertUV?: boolean;
  28885. }, scene: Scene): Mesh;
  28886. /**
  28887. * Creates lathe mesh.
  28888. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28889. * * 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
  28890. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28891. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28892. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28893. * * 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
  28894. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28895. * * 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
  28896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28897. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28898. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28900. * @param name defines the name of the mesh
  28901. * @param options defines the options used to create the mesh
  28902. * @param scene defines the hosting scene
  28903. * @returns the lathe mesh
  28904. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28905. */
  28906. static CreateLathe(name: string, options: {
  28907. shape: Vector3[];
  28908. radius?: number;
  28909. tessellation?: number;
  28910. clip?: number;
  28911. arc?: number;
  28912. closed?: boolean;
  28913. updatable?: boolean;
  28914. sideOrientation?: number;
  28915. frontUVs?: Vector4;
  28916. backUVs?: Vector4;
  28917. cap?: number;
  28918. invertUV?: boolean;
  28919. }, scene: Scene): Mesh;
  28920. /**
  28921. * Creates a plane mesh
  28922. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28923. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28924. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28926. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28928. * @param name defines the name of the mesh
  28929. * @param options defines the options used to create the mesh
  28930. * @param scene defines the hosting scene
  28931. * @returns the plane mesh
  28932. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  28933. */
  28934. static CreatePlane(name: string, options: {
  28935. size?: number;
  28936. width?: number;
  28937. height?: number;
  28938. sideOrientation?: number;
  28939. frontUVs?: Vector4;
  28940. backUVs?: Vector4;
  28941. updatable?: boolean;
  28942. sourcePlane?: Plane;
  28943. }, scene: Scene): Mesh;
  28944. /**
  28945. * Creates a ground mesh
  28946. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28947. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28949. * @param name defines the name of the mesh
  28950. * @param options defines the options used to create the mesh
  28951. * @param scene defines the hosting scene
  28952. * @returns the ground mesh
  28953. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  28954. */
  28955. static CreateGround(name: string, options: {
  28956. width?: number;
  28957. height?: number;
  28958. subdivisions?: number;
  28959. subdivisionsX?: number;
  28960. subdivisionsY?: number;
  28961. updatable?: boolean;
  28962. }, scene: any): Mesh;
  28963. /**
  28964. * Creates a tiled ground mesh
  28965. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28966. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28967. * * 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
  28968. * * 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
  28969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28970. * @param name defines the name of the mesh
  28971. * @param options defines the options used to create the mesh
  28972. * @param scene defines the hosting scene
  28973. * @returns the tiled ground mesh
  28974. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  28975. */
  28976. static CreateTiledGround(name: string, options: {
  28977. xmin: number;
  28978. zmin: number;
  28979. xmax: number;
  28980. zmax: number;
  28981. subdivisions?: {
  28982. w: number;
  28983. h: number;
  28984. };
  28985. precision?: {
  28986. w: number;
  28987. h: number;
  28988. };
  28989. updatable?: boolean;
  28990. }, scene: Scene): Mesh;
  28991. /**
  28992. * Creates a ground mesh from a height map
  28993. * * The parameter `url` sets the URL of the height map image resource.
  28994. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28995. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28996. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28997. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28998. * * 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.
  28999. * * 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).
  29000. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29002. * @param name defines the name of the mesh
  29003. * @param url defines the url to the height map
  29004. * @param options defines the options used to create the mesh
  29005. * @param scene defines the hosting scene
  29006. * @returns the ground mesh
  29007. * @see https://doc.babylonjs.com/babylon101/height_map
  29008. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  29009. */
  29010. static CreateGroundFromHeightMap(name: string, url: string, options: {
  29011. width?: number;
  29012. height?: number;
  29013. subdivisions?: number;
  29014. minHeight?: number;
  29015. maxHeight?: number;
  29016. colorFilter?: Color3;
  29017. alphaFilter?: number;
  29018. updatable?: boolean;
  29019. onReady?: (mesh: GroundMesh) => void;
  29020. }, scene: Scene): GroundMesh;
  29021. /**
  29022. * Creates a polygon mesh
  29023. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  29024. * * 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
  29025. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29027. * * 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)
  29028. * * Remember you can only change the shape positions, not their number when updating a polygon
  29029. * @param name defines the name of the mesh
  29030. * @param options defines the options used to create the mesh
  29031. * @param scene defines the hosting scene
  29032. * @returns the polygon mesh
  29033. */
  29034. static CreatePolygon(name: string, options: {
  29035. shape: Vector3[];
  29036. holes?: Vector3[][];
  29037. depth?: number;
  29038. faceUV?: Vector4[];
  29039. faceColors?: Color4[];
  29040. updatable?: boolean;
  29041. sideOrientation?: number;
  29042. frontUVs?: Vector4;
  29043. backUVs?: Vector4;
  29044. }, scene: Scene): Mesh;
  29045. /**
  29046. * Creates an extruded polygon mesh, with depth in the Y direction.
  29047. * * 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)
  29048. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  29049. * @param name defines the name of the mesh
  29050. * @param options defines the options used to create the mesh
  29051. * @param scene defines the hosting scene
  29052. * @returns the polygon mesh
  29053. */
  29054. static ExtrudePolygon(name: string, options: {
  29055. shape: Vector3[];
  29056. holes?: Vector3[][];
  29057. depth?: number;
  29058. faceUV?: Vector4[];
  29059. faceColors?: Color4[];
  29060. updatable?: boolean;
  29061. sideOrientation?: number;
  29062. frontUVs?: Vector4;
  29063. backUVs?: Vector4;
  29064. }, scene: Scene): Mesh;
  29065. /**
  29066. * Creates a tube mesh.
  29067. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  29068. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  29069. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  29070. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  29071. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  29072. * * 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)
  29073. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  29074. * * 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
  29075. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  29076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29077. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29078. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  29079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29080. * @param name defines the name of the mesh
  29081. * @param options defines the options used to create the mesh
  29082. * @param scene defines the hosting scene
  29083. * @returns the tube mesh
  29084. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29085. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  29086. */
  29087. static CreateTube(name: string, options: {
  29088. path: Vector3[];
  29089. radius?: number;
  29090. tessellation?: number;
  29091. radiusFunction?: {
  29092. (i: number, distance: number): number;
  29093. };
  29094. cap?: number;
  29095. arc?: number;
  29096. updatable?: boolean;
  29097. sideOrientation?: number;
  29098. frontUVs?: Vector4;
  29099. backUVs?: Vector4;
  29100. instance?: Mesh;
  29101. invertUV?: boolean;
  29102. }, scene: Scene): Mesh;
  29103. /**
  29104. * Creates a polyhedron mesh
  29105. * * 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
  29106. * * The parameter `size` (positive float, default 1) sets the polygon size
  29107. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29108. * * 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`
  29109. * * 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
  29110. * * 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)`)
  29111. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  29112. * * 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
  29113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29114. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29116. * @param name defines the name of the mesh
  29117. * @param options defines the options used to create the mesh
  29118. * @param scene defines the hosting scene
  29119. * @returns the polyhedron mesh
  29120. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  29121. */
  29122. static CreatePolyhedron(name: string, options: {
  29123. type?: number;
  29124. size?: number;
  29125. sizeX?: number;
  29126. sizeY?: number;
  29127. sizeZ?: number;
  29128. custom?: any;
  29129. faceUV?: Vector4[];
  29130. faceColors?: Color4[];
  29131. flat?: boolean;
  29132. updatable?: boolean;
  29133. sideOrientation?: number;
  29134. frontUVs?: Vector4;
  29135. backUVs?: Vector4;
  29136. }, scene: Scene): Mesh;
  29137. /**
  29138. * Creates a decal mesh.
  29139. * 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
  29140. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  29141. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  29142. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  29143. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  29144. * @param name defines the name of the mesh
  29145. * @param sourceMesh defines the mesh where the decal must be applied
  29146. * @param options defines the options used to create the mesh
  29147. * @param scene defines the hosting scene
  29148. * @returns the decal mesh
  29149. * @see https://doc.babylonjs.com/how_to/decals
  29150. */
  29151. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  29152. position?: Vector3;
  29153. normal?: Vector3;
  29154. size?: Vector3;
  29155. angle?: number;
  29156. }): Mesh;
  29157. private static _ExtrudeShapeGeneric;
  29158. }
  29159. }
  29160. declare module BABYLON {
  29161. /**
  29162. * Class used to represent a specific level of detail of a mesh
  29163. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  29164. */
  29165. class MeshLODLevel {
  29166. /** Defines the distance where this level should star being displayed */
  29167. distance: number;
  29168. /** Defines the mesh to use to render this level */
  29169. mesh: Nullable<Mesh>;
  29170. /**
  29171. * Creates a new LOD level
  29172. * @param distance defines the distance where this level should star being displayed
  29173. * @param mesh defines the mesh to use to render this level
  29174. */
  29175. constructor(
  29176. /** Defines the distance where this level should star being displayed */
  29177. distance: number,
  29178. /** Defines the mesh to use to render this level */
  29179. mesh: Nullable<Mesh>);
  29180. }
  29181. }
  29182. declare module BABYLON {
  29183. /**
  29184. * A simplifier interface for future simplification implementations
  29185. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29186. */
  29187. interface ISimplifier {
  29188. /**
  29189. * Simplification of a given mesh according to the given settings.
  29190. * Since this requires computation, it is assumed that the function runs async.
  29191. * @param settings The settings of the simplification, including quality and distance
  29192. * @param successCallback A callback that will be called after the mesh was simplified.
  29193. * @param errorCallback in case of an error, this callback will be called. optional.
  29194. */
  29195. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  29196. }
  29197. /**
  29198. * Expected simplification settings.
  29199. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  29200. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29201. */
  29202. interface ISimplificationSettings {
  29203. /**
  29204. * Gets or sets the expected quality
  29205. */
  29206. quality: number;
  29207. /**
  29208. * Gets or sets the distance when this optimized version should be used
  29209. */
  29210. distance: number;
  29211. /**
  29212. * Gets an already optimized mesh
  29213. */
  29214. optimizeMesh?: boolean;
  29215. }
  29216. /**
  29217. * Class used to specify simplification options
  29218. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29219. */
  29220. class SimplificationSettings implements ISimplificationSettings {
  29221. /** expected quality */
  29222. quality: number;
  29223. /** distance when this optimized version should be used */
  29224. distance: number;
  29225. /** already optimized mesh */
  29226. optimizeMesh?: boolean | undefined;
  29227. /**
  29228. * Creates a SimplificationSettings
  29229. * @param quality expected quality
  29230. * @param distance distance when this optimized version should be used
  29231. * @param optimizeMesh already optimized mesh
  29232. */
  29233. constructor(
  29234. /** expected quality */
  29235. quality: number,
  29236. /** distance when this optimized version should be used */
  29237. distance: number,
  29238. /** already optimized mesh */
  29239. optimizeMesh?: boolean | undefined);
  29240. }
  29241. /**
  29242. * Interface used to define a simplification task
  29243. */
  29244. interface ISimplificationTask {
  29245. /**
  29246. * Array of settings
  29247. */
  29248. settings: Array<ISimplificationSettings>;
  29249. /**
  29250. * Simplification type
  29251. */
  29252. simplificationType: SimplificationType;
  29253. /**
  29254. * Mesh to simplify
  29255. */
  29256. mesh: Mesh;
  29257. /**
  29258. * Callback called on success
  29259. */
  29260. successCallback?: () => void;
  29261. /**
  29262. * Defines if parallel processing can be used
  29263. */
  29264. parallelProcessing: boolean;
  29265. }
  29266. /**
  29267. * Queue used to order the simplification tasks
  29268. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29269. */
  29270. class SimplificationQueue {
  29271. private _simplificationArray;
  29272. /**
  29273. * Gets a boolean indicating that the process is still running
  29274. */
  29275. running: boolean;
  29276. /**
  29277. * Creates a new queue
  29278. */
  29279. constructor();
  29280. /**
  29281. * Adds a new simplification task
  29282. * @param task defines a task to add
  29283. */
  29284. addTask(task: ISimplificationTask): void;
  29285. /**
  29286. * Execute next task
  29287. */
  29288. executeNext(): void;
  29289. /**
  29290. * Execute a simplification task
  29291. * @param task defines the task to run
  29292. */
  29293. runSimplification(task: ISimplificationTask): void;
  29294. private getSimplifier;
  29295. }
  29296. /**
  29297. * The implemented types of simplification
  29298. * At the moment only Quadratic Error Decimation is implemented
  29299. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29300. */
  29301. enum SimplificationType {
  29302. /** Quadratic error decimation */
  29303. QUADRATIC = 0
  29304. }
  29305. }
  29306. declare module BABYLON {
  29307. interface Scene {
  29308. /** @hidden (Backing field) */
  29309. _simplificationQueue: SimplificationQueue;
  29310. /**
  29311. * Gets or sets the simplification queue attached to the scene
  29312. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29313. */
  29314. simplificationQueue: SimplificationQueue;
  29315. }
  29316. interface Mesh {
  29317. /**
  29318. * Simplify the mesh according to the given array of settings.
  29319. * Function will return immediately and will simplify async
  29320. * @param settings a collection of simplification settings
  29321. * @param parallelProcessing should all levels calculate parallel or one after the other
  29322. * @param simplificationType the type of simplification to run
  29323. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  29324. * @returns the current mesh
  29325. */
  29326. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  29327. }
  29328. /**
  29329. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  29330. * created in a scene
  29331. */
  29332. class SimplicationQueueSceneComponent implements ISceneComponent {
  29333. /**
  29334. * The component name helpfull to identify the component in the list of scene components.
  29335. */
  29336. readonly name: string;
  29337. /**
  29338. * The scene the component belongs to.
  29339. */
  29340. scene: Scene;
  29341. /**
  29342. * Creates a new instance of the component for the given scene
  29343. * @param scene Defines the scene to register the component in
  29344. */
  29345. constructor(scene: Scene);
  29346. /**
  29347. * Registers the component in a given scene
  29348. */
  29349. register(): void;
  29350. /**
  29351. * Rebuilds the elements related to this component in case of
  29352. * context lost for instance.
  29353. */
  29354. rebuild(): void;
  29355. /**
  29356. * Disposes the component and the associated ressources
  29357. */
  29358. dispose(): void;
  29359. private _beforeCameraUpdate;
  29360. }
  29361. }
  29362. declare module BABYLON {
  29363. /**
  29364. * Polygon
  29365. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29366. */
  29367. class Polygon {
  29368. /**
  29369. * Creates a rectangle
  29370. * @param xmin bottom X coord
  29371. * @param ymin bottom Y coord
  29372. * @param xmax top X coord
  29373. * @param ymax top Y coord
  29374. * @returns points that make the resulting rectation
  29375. */
  29376. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  29377. /**
  29378. * Creates a circle
  29379. * @param radius radius of circle
  29380. * @param cx scale in x
  29381. * @param cy scale in y
  29382. * @param numberOfSides number of sides that make up the circle
  29383. * @returns points that make the resulting circle
  29384. */
  29385. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  29386. /**
  29387. * Creates a polygon from input string
  29388. * @param input Input polygon data
  29389. * @returns the parsed points
  29390. */
  29391. static Parse(input: string): Vector2[];
  29392. /**
  29393. * Starts building a polygon from x and y coordinates
  29394. * @param x x coordinate
  29395. * @param y y coordinate
  29396. * @returns the started path2
  29397. */
  29398. static StartingAt(x: number, y: number): Path2;
  29399. }
  29400. /**
  29401. * Builds a polygon
  29402. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  29403. */
  29404. class PolygonMeshBuilder {
  29405. private _points;
  29406. private _outlinepoints;
  29407. private _holes;
  29408. private _name;
  29409. private _scene;
  29410. private _epoints;
  29411. private _eholes;
  29412. private _addToepoint;
  29413. /**
  29414. * Creates a PolygonMeshBuilder
  29415. * @param name name of the builder
  29416. * @param contours Path of the polygon
  29417. * @param scene scene to add to
  29418. */
  29419. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  29420. /**
  29421. * Adds a whole within the polygon
  29422. * @param hole Array of points defining the hole
  29423. * @returns this
  29424. */
  29425. addHole(hole: Vector2[]): PolygonMeshBuilder;
  29426. /**
  29427. * Creates the polygon
  29428. * @param updatable If the mesh should be updatable
  29429. * @param depth The depth of the mesh created
  29430. * @returns the created mesh
  29431. */
  29432. build(updatable?: boolean, depth?: number): Mesh;
  29433. /**
  29434. * Adds a side to the polygon
  29435. * @param positions points that make the polygon
  29436. * @param normals normals of the polygon
  29437. * @param uvs uvs of the polygon
  29438. * @param indices indices of the polygon
  29439. * @param bounds bounds of the polygon
  29440. * @param points points of the polygon
  29441. * @param depth depth of the polygon
  29442. * @param flip flip of the polygon
  29443. */
  29444. private addSide;
  29445. }
  29446. }
  29447. declare module BABYLON {
  29448. /**
  29449. * Base class for submeshes
  29450. */
  29451. class BaseSubMesh {
  29452. /** @hidden */
  29453. _materialDefines: Nullable<MaterialDefines>;
  29454. /** @hidden */
  29455. _materialEffect: Nullable<Effect>;
  29456. /**
  29457. * Gets associated effect
  29458. */
  29459. readonly effect: Nullable<Effect>;
  29460. /**
  29461. * Sets associated effect (effect used to render this submesh)
  29462. * @param effect defines the effect to associate with
  29463. * @param defines defines the set of defines used to compile this effect
  29464. */
  29465. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29466. }
  29467. /**
  29468. * Defines a subdivision inside a mesh
  29469. */
  29470. class SubMesh extends BaseSubMesh implements ICullable {
  29471. /** the material index to use */
  29472. materialIndex: number;
  29473. /** vertex index start */
  29474. verticesStart: number;
  29475. /** vertices count */
  29476. verticesCount: number;
  29477. /** index start */
  29478. indexStart: number;
  29479. /** indices count */
  29480. indexCount: number;
  29481. /** @hidden */
  29482. _linesIndexCount: number;
  29483. private _mesh;
  29484. private _renderingMesh;
  29485. private _boundingInfo;
  29486. private _linesIndexBuffer;
  29487. /** @hidden */
  29488. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29489. /** @hidden */
  29490. _trianglePlanes: Plane[];
  29491. /** @hidden */
  29492. _lastColliderTransformMatrix: Matrix;
  29493. /** @hidden */
  29494. _renderId: number;
  29495. /** @hidden */
  29496. _alphaIndex: number;
  29497. /** @hidden */
  29498. _distanceToCamera: number;
  29499. /** @hidden */
  29500. _id: number;
  29501. private _currentMaterial;
  29502. /**
  29503. * Add a new submesh to a mesh
  29504. * @param materialIndex defines the material index to use
  29505. * @param verticesStart defines vertex index start
  29506. * @param verticesCount defines vertices count
  29507. * @param indexStart defines index start
  29508. * @param indexCount defines indices count
  29509. * @param mesh defines the parent mesh
  29510. * @param renderingMesh defines an optional rendering mesh
  29511. * @param createBoundingBox defines if bounding box should be created for this submesh
  29512. * @returns the new submesh
  29513. */
  29514. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29515. /**
  29516. * Creates a new submesh
  29517. * @param materialIndex defines the material index to use
  29518. * @param verticesStart defines vertex index start
  29519. * @param verticesCount defines vertices count
  29520. * @param indexStart defines index start
  29521. * @param indexCount defines indices count
  29522. * @param mesh defines the parent mesh
  29523. * @param renderingMesh defines an optional rendering mesh
  29524. * @param createBoundingBox defines if bounding box should be created for this submesh
  29525. */
  29526. constructor(
  29527. /** the material index to use */
  29528. materialIndex: number,
  29529. /** vertex index start */
  29530. verticesStart: number,
  29531. /** vertices count */
  29532. verticesCount: number,
  29533. /** index start */
  29534. indexStart: number,
  29535. /** indices count */
  29536. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  29537. /**
  29538. * Returns true if this submesh covers the entire parent mesh
  29539. * @ignorenaming
  29540. */
  29541. readonly IsGlobal: boolean;
  29542. /**
  29543. * Returns the submesh BoudingInfo object
  29544. * @returns current bounding info (or mesh's one if the submesh is global)
  29545. */
  29546. getBoundingInfo(): BoundingInfo;
  29547. /**
  29548. * Sets the submesh BoundingInfo
  29549. * @param boundingInfo defines the new bounding info to use
  29550. * @returns the SubMesh
  29551. */
  29552. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29553. /**
  29554. * Returns the mesh of the current submesh
  29555. * @return the parent mesh
  29556. */
  29557. getMesh(): AbstractMesh;
  29558. /**
  29559. * Returns the rendering mesh of the submesh
  29560. * @returns the rendering mesh (could be different from parent mesh)
  29561. */
  29562. getRenderingMesh(): Mesh;
  29563. /**
  29564. * Returns the submesh material
  29565. * @returns null or the current material
  29566. */
  29567. getMaterial(): Nullable<Material>;
  29568. /**
  29569. * Sets a new updated BoundingInfo object to the submesh
  29570. * @returns the SubMesh
  29571. */
  29572. refreshBoundingInfo(): SubMesh;
  29573. /** @hidden */
  29574. _checkCollision(collider: Collider): boolean;
  29575. /**
  29576. * Updates the submesh BoundingInfo
  29577. * @param world defines the world matrix to use to update the bounding info
  29578. * @returns the submesh
  29579. */
  29580. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  29581. /**
  29582. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29583. * @param frustumPlanes defines the frustum planes
  29584. * @returns true if the submesh is intersecting with the frustum
  29585. */
  29586. isInFrustum(frustumPlanes: Plane[]): boolean;
  29587. /**
  29588. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29589. * @param frustumPlanes defines the frustum planes
  29590. * @returns true if the submesh is inside the frustum
  29591. */
  29592. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29593. /**
  29594. * Renders the submesh
  29595. * @param enableAlphaMode defines if alpha needs to be used
  29596. * @returns the submesh
  29597. */
  29598. render(enableAlphaMode: boolean): SubMesh;
  29599. /**
  29600. * @hidden
  29601. */
  29602. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29603. /**
  29604. * Checks if the submesh intersects with a ray
  29605. * @param ray defines the ray to test
  29606. * @returns true is the passed ray intersects the submesh bounding box
  29607. */
  29608. canIntersects(ray: Ray): boolean;
  29609. /**
  29610. * Intersects current submesh with a ray
  29611. * @param ray defines the ray to test
  29612. * @param positions defines mesh's positions array
  29613. * @param indices defines mesh's indices array
  29614. * @param fastCheck defines if only bounding info should be used
  29615. * @returns intersection info or null if no intersection
  29616. */
  29617. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29618. /** @hidden */
  29619. private _intersectLines;
  29620. /** @hidden */
  29621. private _intersectTriangles;
  29622. /** @hidden */
  29623. _rebuild(): void;
  29624. /**
  29625. * Creates a new submesh from the passed mesh
  29626. * @param newMesh defines the new hosting mesh
  29627. * @param newRenderingMesh defines an optional rendering mesh
  29628. * @returns the new submesh
  29629. */
  29630. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29631. /**
  29632. * Release associated resources
  29633. */
  29634. dispose(): void;
  29635. /**
  29636. * Creates a new submesh from indices data
  29637. * @param materialIndex the index of the main mesh material
  29638. * @param startIndex the index where to start the copy in the mesh indices array
  29639. * @param indexCount the number of indices to copy then from the startIndex
  29640. * @param mesh the main mesh to create the submesh from
  29641. * @param renderingMesh the optional rendering mesh
  29642. * @returns a new submesh
  29643. */
  29644. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29645. }
  29646. }
  29647. declare module BABYLON {
  29648. /**
  29649. * 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.
  29650. * @see https://doc.babylonjs.com/how_to/transformnode
  29651. */
  29652. class TransformNode extends Node {
  29653. /**
  29654. * Object will not rotate to face the camera
  29655. */
  29656. static BILLBOARDMODE_NONE: number;
  29657. /**
  29658. * Object will rotate to face the camera but only on the x axis
  29659. */
  29660. static BILLBOARDMODE_X: number;
  29661. /**
  29662. * Object will rotate to face the camera but only on the y axis
  29663. */
  29664. static BILLBOARDMODE_Y: number;
  29665. /**
  29666. * Object will rotate to face the camera but only on the z axis
  29667. */
  29668. static BILLBOARDMODE_Z: number;
  29669. /**
  29670. * Object will rotate to face the camera
  29671. */
  29672. static BILLBOARDMODE_ALL: number;
  29673. private _forward;
  29674. private _forwardInverted;
  29675. private _up;
  29676. private _right;
  29677. private _rightInverted;
  29678. private _position;
  29679. private _rotation;
  29680. private _rotationQuaternion;
  29681. protected _scaling: Vector3;
  29682. protected _isDirty: boolean;
  29683. private _transformToBoneReferal;
  29684. /**
  29685. * Set the billboard mode. Default is 0.
  29686. *
  29687. * | Value | Type | Description |
  29688. * | --- | --- | --- |
  29689. * | 0 | BILLBOARDMODE_NONE | |
  29690. * | 1 | BILLBOARDMODE_X | |
  29691. * | 2 | BILLBOARDMODE_Y | |
  29692. * | 4 | BILLBOARDMODE_Z | |
  29693. * | 7 | BILLBOARDMODE_ALL | |
  29694. *
  29695. */
  29696. billboardMode: number;
  29697. /**
  29698. * 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
  29699. */
  29700. scalingDeterminant: number;
  29701. /**
  29702. * Sets the distance of the object to max, often used by skybox
  29703. */
  29704. infiniteDistance: boolean;
  29705. /**
  29706. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29707. * By default the system will update normals to compensate
  29708. */
  29709. ignoreNonUniformScaling: boolean;
  29710. /** @hidden */
  29711. _poseMatrix: Matrix;
  29712. /** @hidden */
  29713. _localMatrix: Matrix;
  29714. private _absolutePosition;
  29715. private _pivotMatrix;
  29716. private _pivotMatrixInverse;
  29717. protected _postMultiplyPivotMatrix: boolean;
  29718. protected _isWorldMatrixFrozen: boolean;
  29719. /** @hidden */
  29720. _indexInSceneTransformNodesArray: number;
  29721. /**
  29722. * An event triggered after the world matrix is updated
  29723. */
  29724. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29725. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29726. /**
  29727. * Gets a string identifying the name of the class
  29728. * @returns "TransformNode" string
  29729. */
  29730. getClassName(): string;
  29731. /**
  29732. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29733. */
  29734. position: Vector3;
  29735. /**
  29736. * 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)).
  29737. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29738. */
  29739. rotation: Vector3;
  29740. /**
  29741. * 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)).
  29742. */
  29743. scaling: Vector3;
  29744. /**
  29745. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29746. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29747. */
  29748. rotationQuaternion: Nullable<Quaternion>;
  29749. /**
  29750. * The forward direction of that transform in world space.
  29751. */
  29752. readonly forward: Vector3;
  29753. /**
  29754. * The up direction of that transform in world space.
  29755. */
  29756. readonly up: Vector3;
  29757. /**
  29758. * The right direction of that transform in world space.
  29759. */
  29760. readonly right: Vector3;
  29761. /**
  29762. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29763. * @param matrix the matrix to copy the pose from
  29764. * @returns this TransformNode.
  29765. */
  29766. updatePoseMatrix(matrix: Matrix): TransformNode;
  29767. /**
  29768. * Returns the mesh Pose matrix.
  29769. * @returns the pose matrix
  29770. */
  29771. getPoseMatrix(): Matrix;
  29772. /** @hidden */
  29773. _isSynchronized(): boolean;
  29774. /** @hidden */
  29775. _initCache(): void;
  29776. /**
  29777. * Flag the transform node as dirty (Forcing it to update everything)
  29778. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29779. * @returns this transform node
  29780. */
  29781. markAsDirty(property: string): TransformNode;
  29782. /**
  29783. * Returns the current mesh absolute position.
  29784. * Returns a Vector3.
  29785. */
  29786. readonly absolutePosition: Vector3;
  29787. /**
  29788. * Sets a new matrix to apply before all other transformation
  29789. * @param matrix defines the transform matrix
  29790. * @returns the current TransformNode
  29791. */
  29792. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29793. /**
  29794. * Sets a new pivot matrix to the current node
  29795. * @param matrix defines the new pivot matrix to use
  29796. * @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
  29797. * @returns the current TransformNode
  29798. */
  29799. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29800. /**
  29801. * Returns the mesh pivot matrix.
  29802. * Default : Identity.
  29803. * @returns the matrix
  29804. */
  29805. getPivotMatrix(): Matrix;
  29806. /**
  29807. * Prevents the World matrix to be computed any longer.
  29808. * @returns the TransformNode.
  29809. */
  29810. freezeWorldMatrix(): TransformNode;
  29811. /**
  29812. * Allows back the World matrix computation.
  29813. * @returns the TransformNode.
  29814. */
  29815. unfreezeWorldMatrix(): this;
  29816. /**
  29817. * True if the World matrix has been frozen.
  29818. */
  29819. readonly isWorldMatrixFrozen: boolean;
  29820. /**
  29821. * Retuns the mesh absolute position in the World.
  29822. * @returns a Vector3.
  29823. */
  29824. getAbsolutePosition(): Vector3;
  29825. /**
  29826. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29827. * @param absolutePosition the absolute position to set
  29828. * @returns the TransformNode.
  29829. */
  29830. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29831. /**
  29832. * Sets the mesh position in its local space.
  29833. * @param vector3 the position to set in localspace
  29834. * @returns the TransformNode.
  29835. */
  29836. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29837. /**
  29838. * Returns the mesh position in the local space from the current World matrix values.
  29839. * @returns a new Vector3.
  29840. */
  29841. getPositionExpressedInLocalSpace(): Vector3;
  29842. /**
  29843. * Translates the mesh along the passed Vector3 in its local space.
  29844. * @param vector3 the distance to translate in localspace
  29845. * @returns the TransformNode.
  29846. */
  29847. locallyTranslate(vector3: Vector3): TransformNode;
  29848. private static _lookAtVectorCache;
  29849. /**
  29850. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29851. * @param targetPoint the position (must be in same space as current mesh) to look at
  29852. * @param yawCor optional yaw (y-axis) correction in radians
  29853. * @param pitchCor optional pitch (x-axis) correction in radians
  29854. * @param rollCor optional roll (z-axis) correction in radians
  29855. * @param space the choosen space of the target
  29856. * @returns the TransformNode.
  29857. */
  29858. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29859. /**
  29860. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29861. * This Vector3 is expressed in the World space.
  29862. * @param localAxis axis to rotate
  29863. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29864. */
  29865. getDirection(localAxis: Vector3): Vector3;
  29866. /**
  29867. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29868. * localAxis is expressed in the mesh local space.
  29869. * result is computed in the Wordl space from the mesh World matrix.
  29870. * @param localAxis axis to rotate
  29871. * @param result the resulting transformnode
  29872. * @returns this TransformNode.
  29873. */
  29874. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29875. /**
  29876. * Sets this transform node rotation to the given local axis.
  29877. * @param localAxis the axis in local space
  29878. * @param yawCor optional yaw (y-axis) correction in radians
  29879. * @param pitchCor optional pitch (x-axis) correction in radians
  29880. * @param rollCor optional roll (z-axis) correction in radians
  29881. * @returns this TransformNode
  29882. */
  29883. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  29884. /**
  29885. * Sets a new pivot point to the current node
  29886. * @param point defines the new pivot point to use
  29887. * @param space defines if the point is in world or local space (local by default)
  29888. * @returns the current TransformNode
  29889. */
  29890. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29891. /**
  29892. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29893. * @returns the pivot point
  29894. */
  29895. getPivotPoint(): Vector3;
  29896. /**
  29897. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29898. * @param result the vector3 to store the result
  29899. * @returns this TransformNode.
  29900. */
  29901. getPivotPointToRef(result: Vector3): TransformNode;
  29902. /**
  29903. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29904. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29905. */
  29906. getAbsolutePivotPoint(): Vector3;
  29907. /**
  29908. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29909. * @param result vector3 to store the result
  29910. * @returns this TransformNode.
  29911. */
  29912. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29913. /**
  29914. * Defines the passed node as the parent of the current node.
  29915. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29916. * @param node the node ot set as the parent
  29917. * @returns this TransformNode.
  29918. */
  29919. setParent(node: Nullable<Node>): TransformNode;
  29920. private _nonUniformScaling;
  29921. /**
  29922. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29923. */
  29924. readonly nonUniformScaling: boolean;
  29925. /** @hidden */
  29926. _updateNonUniformScalingState(value: boolean): boolean;
  29927. /**
  29928. * Attach the current TransformNode to another TransformNode associated with a bone
  29929. * @param bone Bone affecting the TransformNode
  29930. * @param affectedTransformNode TransformNode associated with the bone
  29931. * @returns this object
  29932. */
  29933. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29934. /**
  29935. * Detach the transform node if its associated with a bone
  29936. * @returns this object
  29937. */
  29938. detachFromBone(): TransformNode;
  29939. private static _rotationAxisCache;
  29940. /**
  29941. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29942. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29943. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29944. * The passed axis is also normalized.
  29945. * @param axis the axis to rotate around
  29946. * @param amount the amount to rotate in radians
  29947. * @param space Space to rotate in (Default: local)
  29948. * @returns the TransformNode.
  29949. */
  29950. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29951. /**
  29952. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29953. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29954. * The passed axis is also normalized. .
  29955. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29956. * @param point the point to rotate around
  29957. * @param axis the axis to rotate around
  29958. * @param amount the amount to rotate in radians
  29959. * @returns the TransformNode
  29960. */
  29961. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29962. /**
  29963. * Translates the mesh along the axis vector for the passed distance in the given space.
  29964. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29965. * @param axis the axis to translate in
  29966. * @param distance the distance to translate
  29967. * @param space Space to rotate in (Default: local)
  29968. * @returns the TransformNode.
  29969. */
  29970. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29971. /**
  29972. * Adds a rotation step to the mesh current rotation.
  29973. * x, y, z are Euler angles expressed in radians.
  29974. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29975. * This means this rotation is made in the mesh local space only.
  29976. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29977. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29978. * ```javascript
  29979. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29980. * ```
  29981. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29982. * 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.
  29983. * @param x Rotation to add
  29984. * @param y Rotation to add
  29985. * @param z Rotation to add
  29986. * @returns the TransformNode.
  29987. */
  29988. addRotation(x: number, y: number, z: number): TransformNode;
  29989. /**
  29990. * Computes the world matrix of the node
  29991. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29992. * @returns the world matrix
  29993. */
  29994. computeWorldMatrix(force?: boolean): Matrix;
  29995. protected _afterComputeWorldMatrix(): void;
  29996. /**
  29997. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29998. * @param func callback function to add
  29999. *
  30000. * @returns the TransformNode.
  30001. */
  30002. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  30003. /**
  30004. * Removes a registered callback function.
  30005. * @param func callback function to remove
  30006. * @returns the TransformNode.
  30007. */
  30008. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  30009. /**
  30010. * Gets the position of the current mesh in camera space
  30011. * @param camera defines the camera to use
  30012. * @returns a position
  30013. */
  30014. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  30015. /**
  30016. * Returns the distance from the mesh to the active camera
  30017. * @param camera defines the camera to use
  30018. * @returns the distance
  30019. */
  30020. getDistanceToCamera(camera?: Nullable<Camera>): number;
  30021. /**
  30022. * Clone the current transform node
  30023. * @param name Name of the new clone
  30024. * @param newParent New parent for the clone
  30025. * @param doNotCloneChildren Do not clone children hierarchy
  30026. * @returns the new transform node
  30027. */
  30028. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  30029. /**
  30030. * Serializes the objects information.
  30031. * @param currentSerializationObject defines the object to serialize in
  30032. * @returns the serialized object
  30033. */
  30034. serialize(currentSerializationObject?: any): any;
  30035. /**
  30036. * Returns a new TransformNode object parsed from the source provided.
  30037. * @param parsedTransformNode is the source.
  30038. * @param scene the scne the object belongs to
  30039. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  30040. * @returns a new TransformNode object parsed from the source provided.
  30041. */
  30042. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  30043. /**
  30044. * Releases resources associated with this transform node.
  30045. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30046. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30047. */
  30048. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30049. }
  30050. }
  30051. declare module BABYLON {
  30052. /**
  30053. * Specialized buffer used to store vertex data
  30054. */
  30055. class VertexBuffer {
  30056. /** @hidden */
  30057. _buffer: Buffer;
  30058. private _kind;
  30059. private _size;
  30060. private _ownsBuffer;
  30061. private _instanced;
  30062. private _instanceDivisor;
  30063. /**
  30064. * The byte type.
  30065. */
  30066. static readonly BYTE: number;
  30067. /**
  30068. * The unsigned byte type.
  30069. */
  30070. static readonly UNSIGNED_BYTE: number;
  30071. /**
  30072. * The short type.
  30073. */
  30074. static readonly SHORT: number;
  30075. /**
  30076. * The unsigned short type.
  30077. */
  30078. static readonly UNSIGNED_SHORT: number;
  30079. /**
  30080. * The integer type.
  30081. */
  30082. static readonly INT: number;
  30083. /**
  30084. * The unsigned integer type.
  30085. */
  30086. static readonly UNSIGNED_INT: number;
  30087. /**
  30088. * The float type.
  30089. */
  30090. static readonly FLOAT: number;
  30091. /**
  30092. * Gets or sets the instance divisor when in instanced mode
  30093. */
  30094. instanceDivisor: number;
  30095. /**
  30096. * Gets the byte stride.
  30097. */
  30098. readonly byteStride: number;
  30099. /**
  30100. * Gets the byte offset.
  30101. */
  30102. readonly byteOffset: number;
  30103. /**
  30104. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  30105. */
  30106. readonly normalized: boolean;
  30107. /**
  30108. * Gets the data type of each component in the array.
  30109. */
  30110. readonly type: number;
  30111. /**
  30112. * Constructor
  30113. * @param engine the engine
  30114. * @param data the data to use for this vertex buffer
  30115. * @param kind the vertex buffer kind
  30116. * @param updatable whether the data is updatable
  30117. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  30118. * @param stride the stride (optional)
  30119. * @param instanced whether the buffer is instanced (optional)
  30120. * @param offset the offset of the data (optional)
  30121. * @param size the number of components (optional)
  30122. * @param type the type of the component (optional)
  30123. * @param normalized whether the data contains normalized data (optional)
  30124. * @param useBytes set to true if stride and offset are in bytes (optional)
  30125. */
  30126. 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);
  30127. /** @hidden */
  30128. _rebuild(): void;
  30129. /**
  30130. * Returns the kind of the VertexBuffer (string)
  30131. * @returns a string
  30132. */
  30133. getKind(): string;
  30134. /**
  30135. * Gets a boolean indicating if the VertexBuffer is updatable?
  30136. * @returns true if the buffer is updatable
  30137. */
  30138. isUpdatable(): boolean;
  30139. /**
  30140. * Gets current buffer's data
  30141. * @returns a DataArray or null
  30142. */
  30143. getData(): Nullable<DataArray>;
  30144. /**
  30145. * Gets underlying native buffer
  30146. * @returns underlying native buffer
  30147. */
  30148. getBuffer(): Nullable<WebGLBuffer>;
  30149. /**
  30150. * Gets the stride in float32 units (i.e. byte stride / 4).
  30151. * May not be an integer if the byte stride is not divisible by 4.
  30152. * DEPRECATED. Use byteStride instead.
  30153. * @returns the stride in float32 units
  30154. */
  30155. getStrideSize(): number;
  30156. /**
  30157. * Returns the offset as a multiple of the type byte length.
  30158. * DEPRECATED. Use byteOffset instead.
  30159. * @returns the offset in bytes
  30160. */
  30161. getOffset(): number;
  30162. /**
  30163. * Returns the number of components per vertex attribute (integer)
  30164. * @returns the size in float
  30165. */
  30166. getSize(): number;
  30167. /**
  30168. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  30169. * @returns true if this buffer is instanced
  30170. */
  30171. getIsInstanced(): boolean;
  30172. /**
  30173. * Returns the instancing divisor, zero for non-instanced (integer).
  30174. * @returns a number
  30175. */
  30176. getInstanceDivisor(): number;
  30177. /**
  30178. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  30179. * @param data defines the data to store
  30180. */
  30181. create(data?: DataArray): void;
  30182. /**
  30183. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  30184. * This function will create a new buffer if the current one is not updatable
  30185. * @param data defines the data to store
  30186. */
  30187. update(data: DataArray): void;
  30188. /**
  30189. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  30190. * Returns the directly updated WebGLBuffer.
  30191. * @param data the new data
  30192. * @param offset the new offset
  30193. * @param useBytes set to true if the offset is in bytes
  30194. */
  30195. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  30196. /**
  30197. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  30198. */
  30199. dispose(): void;
  30200. /**
  30201. * Enumerates each value of this vertex buffer as numbers.
  30202. * @param count the number of values to enumerate
  30203. * @param callback the callback function called for each value
  30204. */
  30205. forEach(count: number, callback: (value: number, index: number) => void): void;
  30206. /**
  30207. * Positions
  30208. */
  30209. static readonly PositionKind: string;
  30210. /**
  30211. * Normals
  30212. */
  30213. static readonly NormalKind: string;
  30214. /**
  30215. * Tangents
  30216. */
  30217. static readonly TangentKind: string;
  30218. /**
  30219. * Texture coordinates
  30220. */
  30221. static readonly UVKind: string;
  30222. /**
  30223. * Texture coordinates 2
  30224. */
  30225. static readonly UV2Kind: string;
  30226. /**
  30227. * Texture coordinates 3
  30228. */
  30229. static readonly UV3Kind: string;
  30230. /**
  30231. * Texture coordinates 4
  30232. */
  30233. static readonly UV4Kind: string;
  30234. /**
  30235. * Texture coordinates 5
  30236. */
  30237. static readonly UV5Kind: string;
  30238. /**
  30239. * Texture coordinates 6
  30240. */
  30241. static readonly UV6Kind: string;
  30242. /**
  30243. * Colors
  30244. */
  30245. static readonly ColorKind: string;
  30246. /**
  30247. * Matrix indices (for bones)
  30248. */
  30249. static readonly MatricesIndicesKind: string;
  30250. /**
  30251. * Matrix weights (for bones)
  30252. */
  30253. static readonly MatricesWeightsKind: string;
  30254. /**
  30255. * Additional matrix indices (for bones)
  30256. */
  30257. static readonly MatricesIndicesExtraKind: string;
  30258. /**
  30259. * Additional matrix weights (for bones)
  30260. */
  30261. static readonly MatricesWeightsExtraKind: string;
  30262. /**
  30263. * Deduces the stride given a kind.
  30264. * @param kind The kind string to deduce
  30265. * @returns The deduced stride
  30266. */
  30267. static DeduceStride(kind: string): number;
  30268. /**
  30269. * Gets the byte length of the given type.
  30270. * @param type the type
  30271. * @returns the number of bytes
  30272. */
  30273. static GetTypeByteLength(type: number): number;
  30274. /**
  30275. * Enumerates each value of the given parameters as numbers.
  30276. * @param data the data to enumerate
  30277. * @param byteOffset the byte offset of the data
  30278. * @param byteStride the byte stride of the data
  30279. * @param componentCount the number of components per element
  30280. * @param componentType the type of the component
  30281. * @param count the total number of components
  30282. * @param normalized whether the data is normalized
  30283. * @param callback the callback function called for each value
  30284. */
  30285. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  30286. private static _GetFloatValue;
  30287. }
  30288. }
  30289. declare module BABYLON {
  30290. /**
  30291. * This represents the base class for particle system in Babylon.
  30292. * 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.
  30293. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  30294. * @example https://doc.babylonjs.com/babylon101/particles
  30295. */
  30296. class BaseParticleSystem {
  30297. /**
  30298. * Source color is added to the destination color without alpha affecting the result
  30299. */
  30300. static BLENDMODE_ONEONE: number;
  30301. /**
  30302. * Blend current color and particle color using particle’s alpha
  30303. */
  30304. static BLENDMODE_STANDARD: number;
  30305. /**
  30306. * Add current color and particle color multiplied by particle’s alpha
  30307. */
  30308. static BLENDMODE_ADD: number;
  30309. /**
  30310. * Multiply current color with particle color
  30311. */
  30312. static BLENDMODE_MULTIPLY: number;
  30313. /**
  30314. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  30315. */
  30316. static BLENDMODE_MULTIPLYADD: number;
  30317. /**
  30318. * List of animations used by the particle system.
  30319. */
  30320. animations: Animation[];
  30321. /**
  30322. * The id of the Particle system.
  30323. */
  30324. id: string;
  30325. /**
  30326. * The friendly name of the Particle system.
  30327. */
  30328. name: string;
  30329. /**
  30330. * The rendering group used by the Particle system to chose when to render.
  30331. */
  30332. renderingGroupId: number;
  30333. /**
  30334. * The emitter represents the Mesh or position we are attaching the particle system to.
  30335. */
  30336. emitter: Nullable<AbstractMesh | Vector3>;
  30337. /**
  30338. * The maximum number of particles to emit per frame
  30339. */
  30340. emitRate: number;
  30341. /**
  30342. * If you want to launch only a few particles at once, that can be done, as well.
  30343. */
  30344. manualEmitCount: number;
  30345. /**
  30346. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30347. */
  30348. updateSpeed: number;
  30349. /**
  30350. * The amount of time the particle system is running (depends of the overall update speed).
  30351. */
  30352. targetStopDuration: number;
  30353. /**
  30354. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30355. */
  30356. disposeOnStop: boolean;
  30357. /**
  30358. * Minimum power of emitting particles.
  30359. */
  30360. minEmitPower: number;
  30361. /**
  30362. * Maximum power of emitting particles.
  30363. */
  30364. maxEmitPower: number;
  30365. /**
  30366. * Minimum life time of emitting particles.
  30367. */
  30368. minLifeTime: number;
  30369. /**
  30370. * Maximum life time of emitting particles.
  30371. */
  30372. maxLifeTime: number;
  30373. /**
  30374. * Minimum Size of emitting particles.
  30375. */
  30376. minSize: number;
  30377. /**
  30378. * Maximum Size of emitting particles.
  30379. */
  30380. maxSize: number;
  30381. /**
  30382. * Minimum scale of emitting particles on X axis.
  30383. */
  30384. minScaleX: number;
  30385. /**
  30386. * Maximum scale of emitting particles on X axis.
  30387. */
  30388. maxScaleX: number;
  30389. /**
  30390. * Minimum scale of emitting particles on Y axis.
  30391. */
  30392. minScaleY: number;
  30393. /**
  30394. * Maximum scale of emitting particles on Y axis.
  30395. */
  30396. maxScaleY: number;
  30397. /**
  30398. * Gets or sets the minimal initial rotation in radians.
  30399. */
  30400. minInitialRotation: number;
  30401. /**
  30402. * Gets or sets the maximal initial rotation in radians.
  30403. */
  30404. maxInitialRotation: number;
  30405. /**
  30406. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30407. */
  30408. minAngularSpeed: number;
  30409. /**
  30410. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30411. */
  30412. maxAngularSpeed: number;
  30413. /**
  30414. * The texture used to render each particle. (this can be a spritesheet)
  30415. */
  30416. particleTexture: Nullable<Texture>;
  30417. /**
  30418. * The layer mask we are rendering the particles through.
  30419. */
  30420. layerMask: number;
  30421. /**
  30422. * This can help using your own shader to render the particle system.
  30423. * The according effect will be created
  30424. */
  30425. customShader: any;
  30426. /**
  30427. * By default particle system starts as soon as they are created. This prevents the
  30428. * automatic start to happen and let you decide when to start emitting particles.
  30429. */
  30430. preventAutoStart: boolean;
  30431. private _noiseTexture;
  30432. /**
  30433. * Gets or sets a texture used to add random noise to particle positions
  30434. */
  30435. noiseTexture: Nullable<ProceduralTexture>;
  30436. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30437. noiseStrength: Vector3;
  30438. /**
  30439. * Callback triggered when the particle animation is ending.
  30440. */
  30441. onAnimationEnd: Nullable<() => void>;
  30442. /**
  30443. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  30444. */
  30445. blendMode: number;
  30446. /**
  30447. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30448. * to override the particles.
  30449. */
  30450. forceDepthWrite: boolean;
  30451. /** 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 */
  30452. preWarmCycles: number;
  30453. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  30454. preWarmStepOffset: number;
  30455. /**
  30456. * 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)
  30457. */
  30458. spriteCellChangeSpeed: number;
  30459. /**
  30460. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30461. */
  30462. startSpriteCellID: number;
  30463. /**
  30464. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30465. */
  30466. endSpriteCellID: number;
  30467. /**
  30468. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30469. */
  30470. spriteCellWidth: number;
  30471. /**
  30472. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30473. */
  30474. spriteCellHeight: number;
  30475. /**
  30476. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30477. */
  30478. spriteRandomStartCell: boolean;
  30479. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30480. translationPivot: Vector2;
  30481. /** @hidden */
  30482. protected _isAnimationSheetEnabled: boolean;
  30483. /**
  30484. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30485. */
  30486. beginAnimationOnStart: boolean;
  30487. /**
  30488. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30489. */
  30490. beginAnimationFrom: number;
  30491. /**
  30492. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30493. */
  30494. beginAnimationTo: number;
  30495. /**
  30496. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30497. */
  30498. beginAnimationLoop: boolean;
  30499. /**
  30500. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  30501. */
  30502. isAnimationSheetEnabled: boolean;
  30503. /**
  30504. * Get hosting scene
  30505. * @returns the scene
  30506. */
  30507. getScene(): Scene;
  30508. /**
  30509. * You can use gravity if you want to give an orientation to your particles.
  30510. */
  30511. gravity: Vector3;
  30512. protected _colorGradients: Nullable<Array<ColorGradient>>;
  30513. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  30514. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  30515. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  30516. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  30517. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  30518. protected _dragGradients: Nullable<Array<FactorGradient>>;
  30519. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  30520. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  30521. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  30522. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  30523. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  30524. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  30525. /**
  30526. * Defines the delay in milliseconds before starting the system (0 by default)
  30527. */
  30528. startDelay: number;
  30529. /**
  30530. * Gets the current list of drag gradients.
  30531. * You must use addDragGradient and removeDragGradient to udpate this list
  30532. * @returns the list of drag gradients
  30533. */
  30534. getDragGradients(): Nullable<Array<FactorGradient>>;
  30535. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30536. limitVelocityDamping: number;
  30537. /**
  30538. * Gets the current list of limit velocity gradients.
  30539. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30540. * @returns the list of limit velocity gradients
  30541. */
  30542. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30543. /**
  30544. * Gets the current list of color gradients.
  30545. * You must use addColorGradient and removeColorGradient to udpate this list
  30546. * @returns the list of color gradients
  30547. */
  30548. getColorGradients(): Nullable<Array<ColorGradient>>;
  30549. /**
  30550. * Gets the current list of size gradients.
  30551. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30552. * @returns the list of size gradients
  30553. */
  30554. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30555. /**
  30556. * Gets the current list of color remap gradients.
  30557. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30558. * @returns the list of color remap gradients
  30559. */
  30560. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30561. /**
  30562. * Gets the current list of alpha remap gradients.
  30563. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30564. * @returns the list of alpha remap gradients
  30565. */
  30566. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30567. /**
  30568. * Gets the current list of life time gradients.
  30569. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30570. * @returns the list of life time gradients
  30571. */
  30572. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30573. /**
  30574. * Gets the current list of angular speed gradients.
  30575. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30576. * @returns the list of angular speed gradients
  30577. */
  30578. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30579. /**
  30580. * Gets the current list of velocity gradients.
  30581. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30582. * @returns the list of velocity gradients
  30583. */
  30584. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30585. /**
  30586. * Gets the current list of start size gradients.
  30587. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30588. * @returns the list of start size gradients
  30589. */
  30590. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30591. /**
  30592. * Gets the current list of emit rate gradients.
  30593. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30594. * @returns the list of emit rate gradients
  30595. */
  30596. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30597. /**
  30598. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30599. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30600. */
  30601. direction1: Vector3;
  30602. /**
  30603. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30604. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30605. */
  30606. direction2: Vector3;
  30607. /**
  30608. * 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.
  30609. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30610. */
  30611. minEmitBox: Vector3;
  30612. /**
  30613. * 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.
  30614. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30615. */
  30616. maxEmitBox: Vector3;
  30617. /**
  30618. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30619. */
  30620. color1: Color4;
  30621. /**
  30622. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30623. */
  30624. color2: Color4;
  30625. /**
  30626. * Color the particle will have at the end of its lifetime
  30627. */
  30628. colorDead: Color4;
  30629. /**
  30630. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  30631. */
  30632. textureMask: Color4;
  30633. /**
  30634. * The particle emitter type defines the emitter used by the particle system.
  30635. * It can be for example box, sphere, or cone...
  30636. */
  30637. particleEmitterType: IParticleEmitterType;
  30638. /** @hidden */
  30639. _isSubEmitter: boolean;
  30640. /**
  30641. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30642. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30643. */
  30644. billboardMode: number;
  30645. protected _isBillboardBased: boolean;
  30646. /**
  30647. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30648. */
  30649. isBillboardBased: boolean;
  30650. /**
  30651. * The scene the particle system belongs to.
  30652. */
  30653. protected _scene: Scene;
  30654. /**
  30655. * Local cache of defines for image processing.
  30656. */
  30657. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  30658. /**
  30659. * Default configuration related to image processing available in the standard Material.
  30660. */
  30661. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30662. /**
  30663. * Gets the image processing configuration used either in this material.
  30664. */
  30665. /**
  30666. * Sets the Default image processing configuration used either in the this material.
  30667. *
  30668. * If sets to null, the scene one is in use.
  30669. */
  30670. imageProcessingConfiguration: ImageProcessingConfiguration;
  30671. /**
  30672. * Attaches a new image processing configuration to the Standard Material.
  30673. * @param configuration
  30674. */
  30675. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30676. /** @hidden */
  30677. protected _reset(): void;
  30678. /** @hidden */
  30679. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  30680. /**
  30681. * Instantiates a particle system.
  30682. * 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.
  30683. * @param name The name of the particle system
  30684. */
  30685. constructor(name: string);
  30686. /**
  30687. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30688. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30689. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30690. * @returns the emitter
  30691. */
  30692. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30693. /**
  30694. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30695. * @param radius The radius of the hemisphere to emit from
  30696. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30697. * @returns the emitter
  30698. */
  30699. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  30700. /**
  30701. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30702. * @param radius The radius of the sphere to emit from
  30703. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30704. * @returns the emitter
  30705. */
  30706. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  30707. /**
  30708. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30709. * @param radius The radius of the sphere to emit from
  30710. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30711. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30712. * @returns the emitter
  30713. */
  30714. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  30715. /**
  30716. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30717. * @param radius The radius of the emission cylinder
  30718. * @param height The height of the emission cylinder
  30719. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30720. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30721. * @returns the emitter
  30722. */
  30723. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  30724. /**
  30725. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30726. * @param radius The radius of the cylinder to emit from
  30727. * @param height The height of the emission cylinder
  30728. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30729. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30730. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30731. * @returns the emitter
  30732. */
  30733. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  30734. /**
  30735. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30736. * @param radius The radius of the cone to emit from
  30737. * @param angle The base angle of the cone
  30738. * @returns the emitter
  30739. */
  30740. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  30741. /**
  30742. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30743. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30744. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30745. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30746. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30747. * @returns the emitter
  30748. */
  30749. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30750. }
  30751. }
  30752. declare module BABYLON {
  30753. /**
  30754. * This represents a GPU particle system in Babylon
  30755. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  30756. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  30757. */
  30758. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  30759. /**
  30760. * The layer mask we are rendering the particles through.
  30761. */
  30762. layerMask: number;
  30763. private _capacity;
  30764. private _activeCount;
  30765. private _currentActiveCount;
  30766. private _accumulatedCount;
  30767. private _renderEffect;
  30768. private _updateEffect;
  30769. private _buffer0;
  30770. private _buffer1;
  30771. private _spriteBuffer;
  30772. private _updateVAO;
  30773. private _renderVAO;
  30774. private _targetIndex;
  30775. private _sourceBuffer;
  30776. private _targetBuffer;
  30777. private _engine;
  30778. private _currentRenderId;
  30779. private _started;
  30780. private _stopped;
  30781. private _timeDelta;
  30782. private _randomTexture;
  30783. private _randomTexture2;
  30784. private _attributesStrideSize;
  30785. private _updateEffectOptions;
  30786. private _randomTextureSize;
  30787. private _actualFrame;
  30788. private readonly _rawTextureWidth;
  30789. /**
  30790. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  30791. */
  30792. static readonly IsSupported: boolean;
  30793. /**
  30794. * An event triggered when the system is disposed.
  30795. */
  30796. onDisposeObservable: Observable<GPUParticleSystem>;
  30797. /**
  30798. * Gets the maximum number of particles active at the same time.
  30799. * @returns The max number of active particles.
  30800. */
  30801. getCapacity(): number;
  30802. /**
  30803. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30804. * to override the particles.
  30805. */
  30806. forceDepthWrite: boolean;
  30807. /**
  30808. * Gets or set the number of active particles
  30809. */
  30810. activeParticleCount: number;
  30811. private _preWarmDone;
  30812. /**
  30813. * Is this system ready to be used/rendered
  30814. * @return true if the system is ready
  30815. */
  30816. isReady(): boolean;
  30817. /**
  30818. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30819. * @returns True if it has been started, otherwise false.
  30820. */
  30821. isStarted(): boolean;
  30822. /**
  30823. * Starts the particle system and begins to emit
  30824. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30825. */
  30826. start(delay?: number): void;
  30827. /**
  30828. * Stops the particle system.
  30829. */
  30830. stop(): void;
  30831. /**
  30832. * Remove all active particles
  30833. */
  30834. reset(): void;
  30835. /**
  30836. * Returns the string "GPUParticleSystem"
  30837. * @returns a string containing the class name
  30838. */
  30839. getClassName(): string;
  30840. private _colorGradientsTexture;
  30841. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  30842. /**
  30843. * Adds a new color gradient
  30844. * @param gradient defines the gradient to use (between 0 and 1)
  30845. * @param color1 defines the color to affect to the specified gradient
  30846. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30847. * @returns the current particle system
  30848. */
  30849. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  30850. /**
  30851. * Remove a specific color gradient
  30852. * @param gradient defines the gradient to remove
  30853. * @returns the current particle system
  30854. */
  30855. removeColorGradient(gradient: number): GPUParticleSystem;
  30856. private _angularSpeedGradientsTexture;
  30857. private _sizeGradientsTexture;
  30858. private _velocityGradientsTexture;
  30859. private _limitVelocityGradientsTexture;
  30860. private _dragGradientsTexture;
  30861. private _addFactorGradient;
  30862. /**
  30863. * Adds a new size gradient
  30864. * @param gradient defines the gradient to use (between 0 and 1)
  30865. * @param factor defines the size factor to affect to the specified gradient
  30866. * @returns the current particle system
  30867. */
  30868. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  30869. /**
  30870. * Remove a specific size gradient
  30871. * @param gradient defines the gradient to remove
  30872. * @returns the current particle system
  30873. */
  30874. removeSizeGradient(gradient: number): GPUParticleSystem;
  30875. /**
  30876. * Adds a new angular speed gradient
  30877. * @param gradient defines the gradient to use (between 0 and 1)
  30878. * @param factor defines the angular speed to affect to the specified gradient
  30879. * @returns the current particle system
  30880. */
  30881. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  30882. /**
  30883. * Remove a specific angular speed gradient
  30884. * @param gradient defines the gradient to remove
  30885. * @returns the current particle system
  30886. */
  30887. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  30888. /**
  30889. * Adds a new velocity gradient
  30890. * @param gradient defines the gradient to use (between 0 and 1)
  30891. * @param factor defines the velocity to affect to the specified gradient
  30892. * @returns the current particle system
  30893. */
  30894. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30895. /**
  30896. * Remove a specific velocity gradient
  30897. * @param gradient defines the gradient to remove
  30898. * @returns the current particle system
  30899. */
  30900. removeVelocityGradient(gradient: number): GPUParticleSystem;
  30901. /**
  30902. * Adds a new limit velocity gradient
  30903. * @param gradient defines the gradient to use (between 0 and 1)
  30904. * @param factor defines the limit velocity value to affect to the specified gradient
  30905. * @returns the current particle system
  30906. */
  30907. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30908. /**
  30909. * Remove a specific limit velocity gradient
  30910. * @param gradient defines the gradient to remove
  30911. * @returns the current particle system
  30912. */
  30913. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  30914. /**
  30915. * Adds a new drag gradient
  30916. * @param gradient defines the gradient to use (between 0 and 1)
  30917. * @param factor defines the drag value to affect to the specified gradient
  30918. * @returns the current particle system
  30919. */
  30920. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  30921. /**
  30922. * Remove a specific drag gradient
  30923. * @param gradient defines the gradient to remove
  30924. * @returns the current particle system
  30925. */
  30926. removeDragGradient(gradient: number): GPUParticleSystem;
  30927. /**
  30928. * Not supported by GPUParticleSystem
  30929. * @param gradient defines the gradient to use (between 0 and 1)
  30930. * @param factor defines the emit rate value to affect to the specified gradient
  30931. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30932. * @returns the current particle system
  30933. */
  30934. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30935. /**
  30936. * Not supported by GPUParticleSystem
  30937. * @param gradient defines the gradient to remove
  30938. * @returns the current particle system
  30939. */
  30940. removeEmitRateGradient(gradient: number): IParticleSystem;
  30941. /**
  30942. * Not supported by GPUParticleSystem
  30943. * @param gradient defines the gradient to use (between 0 and 1)
  30944. * @param factor defines the start size value to affect to the specified gradient
  30945. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30946. * @returns the current particle system
  30947. */
  30948. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30949. /**
  30950. * Not supported by GPUParticleSystem
  30951. * @param gradient defines the gradient to remove
  30952. * @returns the current particle system
  30953. */
  30954. removeStartSizeGradient(gradient: number): IParticleSystem;
  30955. /**
  30956. * Not supported by GPUParticleSystem
  30957. * @param gradient defines the gradient to use (between 0 and 1)
  30958. * @param min defines the color remap minimal range
  30959. * @param max defines the color remap maximal range
  30960. * @returns the current particle system
  30961. */
  30962. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30963. /**
  30964. * Not supported by GPUParticleSystem
  30965. * @param gradient defines the gradient to remove
  30966. * @returns the current particle system
  30967. */
  30968. removeColorRemapGradient(gradient: number): IParticleSystem;
  30969. /**
  30970. * Not supported by GPUParticleSystem
  30971. * @param gradient defines the gradient to use (between 0 and 1)
  30972. * @param min defines the alpha remap minimal range
  30973. * @param max defines the alpha remap maximal range
  30974. * @returns the current particle system
  30975. */
  30976. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30977. /**
  30978. * Not supported by GPUParticleSystem
  30979. * @param gradient defines the gradient to remove
  30980. * @returns the current particle system
  30981. */
  30982. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  30983. /**
  30984. * Not supported by GPUParticleSystem
  30985. * @param gradient defines the gradient to use (between 0 and 1)
  30986. * @param color defines the color to affect to the specified gradient
  30987. * @returns the current particle system
  30988. */
  30989. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  30990. /**
  30991. * Not supported by GPUParticleSystem
  30992. * @param gradient defines the gradient to remove
  30993. * @returns the current particle system
  30994. */
  30995. removeRampGradient(gradient: number): IParticleSystem;
  30996. /**
  30997. * Not supported by GPUParticleSystem
  30998. * @returns the list of ramp gradients
  30999. */
  31000. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31001. /**
  31002. * Not supported by GPUParticleSystem
  31003. * Gets or sets a boolean indicating that ramp gradients must be used
  31004. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31005. */
  31006. useRampGradients: boolean;
  31007. /**
  31008. * Not supported by GPUParticleSystem
  31009. * @param gradient defines the gradient to use (between 0 and 1)
  31010. * @param factor defines the life time factor to affect to the specified gradient
  31011. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31012. * @returns the current particle system
  31013. */
  31014. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31015. /**
  31016. * Not supported by GPUParticleSystem
  31017. * @param gradient defines the gradient to remove
  31018. * @returns the current particle system
  31019. */
  31020. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31021. /**
  31022. * Instantiates a GPU particle system.
  31023. * 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.
  31024. * @param name The name of the particle system
  31025. * @param options The options used to create the system
  31026. * @param scene The scene the particle system belongs to
  31027. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31028. */
  31029. constructor(name: string, options: Partial<{
  31030. capacity: number;
  31031. randomTextureSize: number;
  31032. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  31033. protected _reset(): void;
  31034. private _createUpdateVAO;
  31035. private _createRenderVAO;
  31036. private _initialize;
  31037. /** @hidden */
  31038. _recreateUpdateEffect(): void;
  31039. /** @hidden */
  31040. _recreateRenderEffect(): void;
  31041. /**
  31042. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  31043. * @param preWarm defines if we are in the pre-warmimg phase
  31044. */
  31045. animate(preWarm?: boolean): void;
  31046. private _createFactorGradientTexture;
  31047. private _createSizeGradientTexture;
  31048. private _createAngularSpeedGradientTexture;
  31049. private _createVelocityGradientTexture;
  31050. private _createLimitVelocityGradientTexture;
  31051. private _createDragGradientTexture;
  31052. private _createColorGradientTexture;
  31053. /**
  31054. * Renders the particle system in its current state
  31055. * @param preWarm defines if the system should only update the particles but not render them
  31056. * @returns the current number of particles
  31057. */
  31058. render(preWarm?: boolean): number;
  31059. /**
  31060. * Rebuilds the particle system
  31061. */
  31062. rebuild(): void;
  31063. private _releaseBuffers;
  31064. private _releaseVAOs;
  31065. /**
  31066. * Disposes the particle system and free the associated resources
  31067. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31068. */
  31069. dispose(disposeTexture?: boolean): void;
  31070. /**
  31071. * Clones the particle system.
  31072. * @param name The name of the cloned object
  31073. * @param newEmitter The new emitter to use
  31074. * @returns the cloned particle system
  31075. */
  31076. clone(name: string, newEmitter: any): GPUParticleSystem;
  31077. /**
  31078. * Serializes the particle system to a JSON object.
  31079. * @returns the JSON object
  31080. */
  31081. serialize(): any;
  31082. /**
  31083. * Parses a JSON object to create a GPU particle system.
  31084. * @param parsedParticleSystem The JSON object to parse
  31085. * @param scene The scene to create the particle system in
  31086. * @param rootUrl The root url to use to load external dependencies like texture
  31087. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  31088. * @returns the parsed GPU particle system
  31089. */
  31090. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  31091. }
  31092. }
  31093. declare module BABYLON {
  31094. /**
  31095. * Interface representing a particle system in Babylon.js.
  31096. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  31097. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  31098. */
  31099. interface IParticleSystem {
  31100. /**
  31101. * List of animations used by the particle system.
  31102. */
  31103. animations: Animation[];
  31104. /**
  31105. * The id of the Particle system.
  31106. */
  31107. id: string;
  31108. /**
  31109. * The name of the Particle system.
  31110. */
  31111. name: string;
  31112. /**
  31113. * The emitter represents the Mesh or position we are attaching the particle system to.
  31114. */
  31115. emitter: Nullable<AbstractMesh | Vector3>;
  31116. /**
  31117. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  31118. */
  31119. isBillboardBased: boolean;
  31120. /**
  31121. * The rendering group used by the Particle system to chose when to render.
  31122. */
  31123. renderingGroupId: number;
  31124. /**
  31125. * The layer mask we are rendering the particles through.
  31126. */
  31127. layerMask: number;
  31128. /**
  31129. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31130. */
  31131. updateSpeed: number;
  31132. /**
  31133. * The amount of time the particle system is running (depends of the overall update speed).
  31134. */
  31135. targetStopDuration: number;
  31136. /**
  31137. * The texture used to render each particle. (this can be a spritesheet)
  31138. */
  31139. particleTexture: Nullable<Texture>;
  31140. /**
  31141. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  31142. */
  31143. blendMode: number;
  31144. /**
  31145. * Minimum life time of emitting particles.
  31146. */
  31147. minLifeTime: number;
  31148. /**
  31149. * Maximum life time of emitting particles.
  31150. */
  31151. maxLifeTime: number;
  31152. /**
  31153. * Minimum Size of emitting particles.
  31154. */
  31155. minSize: number;
  31156. /**
  31157. * Maximum Size of emitting particles.
  31158. */
  31159. maxSize: number;
  31160. /**
  31161. * Minimum scale of emitting particles on X axis.
  31162. */
  31163. minScaleX: number;
  31164. /**
  31165. * Maximum scale of emitting particles on X axis.
  31166. */
  31167. maxScaleX: number;
  31168. /**
  31169. * Minimum scale of emitting particles on Y axis.
  31170. */
  31171. minScaleY: number;
  31172. /**
  31173. * Maximum scale of emitting particles on Y axis.
  31174. */
  31175. maxScaleY: number;
  31176. /**
  31177. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31178. */
  31179. color1: Color4;
  31180. /**
  31181. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31182. */
  31183. color2: Color4;
  31184. /**
  31185. * Color the particle will have at the end of its lifetime.
  31186. */
  31187. colorDead: Color4;
  31188. /**
  31189. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  31190. */
  31191. emitRate: number;
  31192. /**
  31193. * You can use gravity if you want to give an orientation to your particles.
  31194. */
  31195. gravity: Vector3;
  31196. /**
  31197. * Minimum power of emitting particles.
  31198. */
  31199. minEmitPower: number;
  31200. /**
  31201. * Maximum power of emitting particles.
  31202. */
  31203. maxEmitPower: number;
  31204. /**
  31205. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31206. */
  31207. minAngularSpeed: number;
  31208. /**
  31209. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31210. */
  31211. maxAngularSpeed: number;
  31212. /**
  31213. * Gets or sets the minimal initial rotation in radians.
  31214. */
  31215. minInitialRotation: number;
  31216. /**
  31217. * Gets or sets the maximal initial rotation in radians.
  31218. */
  31219. maxInitialRotation: number;
  31220. /**
  31221. * The particle emitter type defines the emitter used by the particle system.
  31222. * It can be for example box, sphere, or cone...
  31223. */
  31224. particleEmitterType: Nullable<IParticleEmitterType>;
  31225. /**
  31226. * Defines the delay in milliseconds before starting the system (0 by default)
  31227. */
  31228. startDelay: number;
  31229. /**
  31230. * 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
  31231. */
  31232. preWarmCycles: number;
  31233. /**
  31234. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  31235. */
  31236. preWarmStepOffset: number;
  31237. /**
  31238. * 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)
  31239. */
  31240. spriteCellChangeSpeed: number;
  31241. /**
  31242. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  31243. */
  31244. startSpriteCellID: number;
  31245. /**
  31246. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  31247. */
  31248. endSpriteCellID: number;
  31249. /**
  31250. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  31251. */
  31252. spriteCellWidth: number;
  31253. /**
  31254. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  31255. */
  31256. spriteCellHeight: number;
  31257. /**
  31258. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31259. */
  31260. spriteRandomStartCell: boolean;
  31261. /**
  31262. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  31263. */
  31264. isAnimationSheetEnabled: boolean;
  31265. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31266. translationPivot: Vector2;
  31267. /**
  31268. * Gets or sets a texture used to add random noise to particle positions
  31269. */
  31270. noiseTexture: Nullable<BaseTexture>;
  31271. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31272. noiseStrength: Vector3;
  31273. /**
  31274. * Gets or sets the billboard mode to use when isBillboardBased = true.
  31275. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  31276. */
  31277. billboardMode: number;
  31278. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  31279. limitVelocityDamping: number;
  31280. /**
  31281. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31282. */
  31283. beginAnimationOnStart: boolean;
  31284. /**
  31285. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31286. */
  31287. beginAnimationFrom: number;
  31288. /**
  31289. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31290. */
  31291. beginAnimationTo: number;
  31292. /**
  31293. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31294. */
  31295. beginAnimationLoop: boolean;
  31296. /**
  31297. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31298. */
  31299. disposeOnStop: boolean;
  31300. /**
  31301. * Gets the maximum number of particles active at the same time.
  31302. * @returns The max number of active particles.
  31303. */
  31304. getCapacity(): number;
  31305. /**
  31306. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31307. * @returns True if it has been started, otherwise false.
  31308. */
  31309. isStarted(): boolean;
  31310. /**
  31311. * Animates the particle system for this frame.
  31312. */
  31313. animate(): void;
  31314. /**
  31315. * Renders the particle system in its current state.
  31316. * @returns the current number of particles
  31317. */
  31318. render(): number;
  31319. /**
  31320. * Dispose the particle system and frees its associated resources.
  31321. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31322. */
  31323. dispose(disposeTexture?: boolean): void;
  31324. /**
  31325. * Clones the particle system.
  31326. * @param name The name of the cloned object
  31327. * @param newEmitter The new emitter to use
  31328. * @returns the cloned particle system
  31329. */
  31330. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  31331. /**
  31332. * Serializes the particle system to a JSON object.
  31333. * @returns the JSON object
  31334. */
  31335. serialize(): any;
  31336. /**
  31337. * Rebuild the particle system
  31338. */
  31339. rebuild(): void;
  31340. /**
  31341. * Starts the particle system and begins to emit
  31342. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  31343. */
  31344. start(delay?: number): void;
  31345. /**
  31346. * Stops the particle system.
  31347. */
  31348. stop(): void;
  31349. /**
  31350. * Remove all active particles
  31351. */
  31352. reset(): void;
  31353. /**
  31354. * Is this system ready to be used/rendered
  31355. * @return true if the system is ready
  31356. */
  31357. isReady(): boolean;
  31358. /**
  31359. * Adds a new color gradient
  31360. * @param gradient defines the gradient to use (between 0 and 1)
  31361. * @param color1 defines the color to affect to the specified gradient
  31362. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31363. * @returns the current particle system
  31364. */
  31365. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31366. /**
  31367. * Remove a specific color gradient
  31368. * @param gradient defines the gradient to remove
  31369. * @returns the current particle system
  31370. */
  31371. removeColorGradient(gradient: number): IParticleSystem;
  31372. /**
  31373. * Adds a new size gradient
  31374. * @param gradient defines the gradient to use (between 0 and 1)
  31375. * @param factor defines the size factor to affect to the specified gradient
  31376. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31377. * @returns the current particle system
  31378. */
  31379. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31380. /**
  31381. * Remove a specific size gradient
  31382. * @param gradient defines the gradient to remove
  31383. * @returns the current particle system
  31384. */
  31385. removeSizeGradient(gradient: number): IParticleSystem;
  31386. /**
  31387. * Gets the current list of color gradients.
  31388. * You must use addColorGradient and removeColorGradient to udpate this list
  31389. * @returns the list of color gradients
  31390. */
  31391. getColorGradients(): Nullable<Array<ColorGradient>>;
  31392. /**
  31393. * Gets the current list of size gradients.
  31394. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31395. * @returns the list of size gradients
  31396. */
  31397. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31398. /**
  31399. * Gets the current list of angular speed gradients.
  31400. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31401. * @returns the list of angular speed gradients
  31402. */
  31403. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31404. /**
  31405. * Adds a new angular speed gradient
  31406. * @param gradient defines the gradient to use (between 0 and 1)
  31407. * @param factor defines the angular speed to affect to the specified gradient
  31408. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31409. * @returns the current particle system
  31410. */
  31411. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31412. /**
  31413. * Remove a specific angular speed gradient
  31414. * @param gradient defines the gradient to remove
  31415. * @returns the current particle system
  31416. */
  31417. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31418. /**
  31419. * Gets the current list of velocity gradients.
  31420. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31421. * @returns the list of velocity gradients
  31422. */
  31423. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31424. /**
  31425. * Adds a new velocity gradient
  31426. * @param gradient defines the gradient to use (between 0 and 1)
  31427. * @param factor defines the velocity to affect to the specified gradient
  31428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31429. * @returns the current particle system
  31430. */
  31431. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31432. /**
  31433. * Remove a specific velocity gradient
  31434. * @param gradient defines the gradient to remove
  31435. * @returns the current particle system
  31436. */
  31437. removeVelocityGradient(gradient: number): IParticleSystem;
  31438. /**
  31439. * Gets the current list of limit velocity gradients.
  31440. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31441. * @returns the list of limit velocity gradients
  31442. */
  31443. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31444. /**
  31445. * Adds a new limit velocity gradient
  31446. * @param gradient defines the gradient to use (between 0 and 1)
  31447. * @param factor defines the limit velocity to affect to the specified gradient
  31448. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31449. * @returns the current particle system
  31450. */
  31451. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31452. /**
  31453. * Remove a specific limit velocity gradient
  31454. * @param gradient defines the gradient to remove
  31455. * @returns the current particle system
  31456. */
  31457. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31458. /**
  31459. * Adds a new drag gradient
  31460. * @param gradient defines the gradient to use (between 0 and 1)
  31461. * @param factor defines the drag to affect to the specified gradient
  31462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31463. * @returns the current particle system
  31464. */
  31465. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31466. /**
  31467. * Remove a specific drag gradient
  31468. * @param gradient defines the gradient to remove
  31469. * @returns the current particle system
  31470. */
  31471. removeDragGradient(gradient: number): IParticleSystem;
  31472. /**
  31473. * Gets the current list of drag gradients.
  31474. * You must use addDragGradient and removeDragGradient to udpate this list
  31475. * @returns the list of drag gradients
  31476. */
  31477. getDragGradients(): Nullable<Array<FactorGradient>>;
  31478. /**
  31479. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31480. * @param gradient defines the gradient to use (between 0 and 1)
  31481. * @param factor defines the emit rate to affect to the specified gradient
  31482. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31483. * @returns the current particle system
  31484. */
  31485. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31486. /**
  31487. * Remove a specific emit rate gradient
  31488. * @param gradient defines the gradient to remove
  31489. * @returns the current particle system
  31490. */
  31491. removeEmitRateGradient(gradient: number): IParticleSystem;
  31492. /**
  31493. * Gets the current list of emit rate gradients.
  31494. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31495. * @returns the list of emit rate gradients
  31496. */
  31497. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31498. /**
  31499. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31500. * @param gradient defines the gradient to use (between 0 and 1)
  31501. * @param factor defines the start size to affect to the specified gradient
  31502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31503. * @returns the current particle system
  31504. */
  31505. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31506. /**
  31507. * Remove a specific start size gradient
  31508. * @param gradient defines the gradient to remove
  31509. * @returns the current particle system
  31510. */
  31511. removeStartSizeGradient(gradient: number): IParticleSystem;
  31512. /**
  31513. * Gets the current list of start size gradients.
  31514. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31515. * @returns the list of start size gradients
  31516. */
  31517. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31518. /**
  31519. * Adds a new life time gradient
  31520. * @param gradient defines the gradient to use (between 0 and 1)
  31521. * @param factor defines the life time factor to affect to the specified gradient
  31522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31523. * @returns the current particle system
  31524. */
  31525. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31526. /**
  31527. * Remove a specific life time gradient
  31528. * @param gradient defines the gradient to remove
  31529. * @returns the current particle system
  31530. */
  31531. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31532. /**
  31533. * Gets the current list of life time gradients.
  31534. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31535. * @returns the list of life time gradients
  31536. */
  31537. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31538. /**
  31539. * Gets the current list of color gradients.
  31540. * You must use addColorGradient and removeColorGradient to udpate this list
  31541. * @returns the list of color gradients
  31542. */
  31543. getColorGradients(): Nullable<Array<ColorGradient>>;
  31544. /**
  31545. * Adds a new ramp gradient used to remap particle colors
  31546. * @param gradient defines the gradient to use (between 0 and 1)
  31547. * @param color defines the color to affect to the specified gradient
  31548. * @returns the current particle system
  31549. */
  31550. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31551. /**
  31552. * Gets the current list of ramp gradients.
  31553. * You must use addRampGradient and removeRampGradient to udpate this list
  31554. * @returns the list of ramp gradients
  31555. */
  31556. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31557. /** Gets or sets a boolean indicating that ramp gradients must be used
  31558. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31559. */
  31560. useRampGradients: boolean;
  31561. /**
  31562. * Adds a new color remap gradient
  31563. * @param gradient defines the gradient to use (between 0 and 1)
  31564. * @param min defines the color remap minimal range
  31565. * @param max defines the color remap maximal range
  31566. * @returns the current particle system
  31567. */
  31568. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31569. /**
  31570. * Gets the current list of color remap gradients.
  31571. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31572. * @returns the list of color remap gradients
  31573. */
  31574. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31575. /**
  31576. * Adds a new alpha remap gradient
  31577. * @param gradient defines the gradient to use (between 0 and 1)
  31578. * @param min defines the alpha remap minimal range
  31579. * @param max defines the alpha remap maximal range
  31580. * @returns the current particle system
  31581. */
  31582. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31583. /**
  31584. * Gets the current list of alpha remap gradients.
  31585. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31586. * @returns the list of alpha remap gradients
  31587. */
  31588. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31589. /**
  31590. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31591. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31592. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31593. * @returns the emitter
  31594. */
  31595. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31596. /**
  31597. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31598. * @param radius The radius of the hemisphere to emit from
  31599. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31600. * @returns the emitter
  31601. */
  31602. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  31603. /**
  31604. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31605. * @param radius The radius of the sphere to emit from
  31606. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31607. * @returns the emitter
  31608. */
  31609. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  31610. /**
  31611. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31612. * @param radius The radius of the sphere to emit from
  31613. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31614. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31615. * @returns the emitter
  31616. */
  31617. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31618. /**
  31619. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31620. * @param radius The radius of the emission cylinder
  31621. * @param height The height of the emission cylinder
  31622. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31623. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31624. * @returns the emitter
  31625. */
  31626. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  31627. /**
  31628. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31629. * @param radius The radius of the cylinder to emit from
  31630. * @param height The height of the emission cylinder
  31631. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31632. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31633. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31634. * @returns the emitter
  31635. */
  31636. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31637. /**
  31638. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31639. * @param radius The radius of the cone to emit from
  31640. * @param angle The base angle of the cone
  31641. * @returns the emitter
  31642. */
  31643. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  31644. /**
  31645. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31646. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31647. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31648. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31649. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31650. * @returns the emitter
  31651. */
  31652. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31653. /**
  31654. * Get hosting scene
  31655. * @returns the scene
  31656. */
  31657. getScene(): Scene;
  31658. }
  31659. }
  31660. declare module BABYLON {
  31661. /**
  31662. * A particle represents one of the element emitted by a particle system.
  31663. * This is mainly define by its coordinates, direction, velocity and age.
  31664. */
  31665. class Particle {
  31666. /**
  31667. * The particle system the particle belongs to.
  31668. */
  31669. particleSystem: ParticleSystem;
  31670. private static _Count;
  31671. /**
  31672. * Unique ID of the particle
  31673. */
  31674. id: number;
  31675. /**
  31676. * The world position of the particle in the scene.
  31677. */
  31678. position: Vector3;
  31679. /**
  31680. * The world direction of the particle in the scene.
  31681. */
  31682. direction: Vector3;
  31683. /**
  31684. * The color of the particle.
  31685. */
  31686. color: Color4;
  31687. /**
  31688. * The color change of the particle per step.
  31689. */
  31690. colorStep: Color4;
  31691. /**
  31692. * Defines how long will the life of the particle be.
  31693. */
  31694. lifeTime: number;
  31695. /**
  31696. * The current age of the particle.
  31697. */
  31698. age: number;
  31699. /**
  31700. * The current size of the particle.
  31701. */
  31702. size: number;
  31703. /**
  31704. * The current scale of the particle.
  31705. */
  31706. scale: Vector2;
  31707. /**
  31708. * The current angle of the particle.
  31709. */
  31710. angle: number;
  31711. /**
  31712. * Defines how fast is the angle changing.
  31713. */
  31714. angularSpeed: number;
  31715. /**
  31716. * Defines the cell index used by the particle to be rendered from a sprite.
  31717. */
  31718. cellIndex: number;
  31719. /**
  31720. * The information required to support color remapping
  31721. */
  31722. remapData: Vector4;
  31723. /** @hidden */
  31724. _randomCellOffset?: number;
  31725. /** @hidden */
  31726. _initialDirection: Nullable<Vector3>;
  31727. /** @hidden */
  31728. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  31729. /** @hidden */
  31730. _initialStartSpriteCellID: number;
  31731. /** @hidden */
  31732. _initialEndSpriteCellID: number;
  31733. /** @hidden */
  31734. _currentColorGradient: Nullable<ColorGradient>;
  31735. /** @hidden */
  31736. _currentColor1: Color4;
  31737. /** @hidden */
  31738. _currentColor2: Color4;
  31739. /** @hidden */
  31740. _currentSizeGradient: Nullable<FactorGradient>;
  31741. /** @hidden */
  31742. _currentSize1: number;
  31743. /** @hidden */
  31744. _currentSize2: number;
  31745. /** @hidden */
  31746. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  31747. /** @hidden */
  31748. _currentAngularSpeed1: number;
  31749. /** @hidden */
  31750. _currentAngularSpeed2: number;
  31751. /** @hidden */
  31752. _currentVelocityGradient: Nullable<FactorGradient>;
  31753. /** @hidden */
  31754. _currentVelocity1: number;
  31755. /** @hidden */
  31756. _currentVelocity2: number;
  31757. /** @hidden */
  31758. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  31759. /** @hidden */
  31760. _currentLimitVelocity1: number;
  31761. /** @hidden */
  31762. _currentLimitVelocity2: number;
  31763. /** @hidden */
  31764. _currentDragGradient: Nullable<FactorGradient>;
  31765. /** @hidden */
  31766. _currentDrag1: number;
  31767. /** @hidden */
  31768. _currentDrag2: number;
  31769. /** @hidden */
  31770. _randomNoiseCoordinates1: Vector3;
  31771. /** @hidden */
  31772. _randomNoiseCoordinates2: Vector3;
  31773. /**
  31774. * Creates a new instance Particle
  31775. * @param particleSystem the particle system the particle belongs to
  31776. */
  31777. constructor(
  31778. /**
  31779. * The particle system the particle belongs to.
  31780. */
  31781. particleSystem: ParticleSystem);
  31782. private updateCellInfoFromSystem;
  31783. /**
  31784. * Defines how the sprite cell index is updated for the particle
  31785. */
  31786. updateCellIndex(): void;
  31787. /** @hidden */
  31788. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  31789. /** @hidden */
  31790. _inheritParticleInfoToSubEmitters(): void;
  31791. /** @hidden */
  31792. _reset(): void;
  31793. /**
  31794. * Copy the properties of particle to another one.
  31795. * @param other the particle to copy the information to.
  31796. */
  31797. copyTo(other: Particle): void;
  31798. }
  31799. }
  31800. declare module BABYLON {
  31801. /**
  31802. * This class is made for on one-liner static method to help creating particle system set.
  31803. */
  31804. class ParticleHelper {
  31805. /**
  31806. * Gets or sets base Assets URL
  31807. */
  31808. static BaseAssetsUrl: string;
  31809. /**
  31810. * Create a default particle system that you can tweak
  31811. * @param emitter defines the emitter to use
  31812. * @param capacity defines the system capacity (default is 500 particles)
  31813. * @param scene defines the hosting scene
  31814. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  31815. * @returns the new Particle system
  31816. */
  31817. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  31818. /**
  31819. * This is the main static method (one-liner) of this helper to create different particle systems
  31820. * @param type This string represents the type to the particle system to create
  31821. * @param scene The scene where the particle system should live
  31822. * @param gpu If the system will use gpu
  31823. * @returns the ParticleSystemSet created
  31824. */
  31825. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  31826. /**
  31827. * Static function used to export a particle system to a ParticleSystemSet variable.
  31828. * Please note that the emitter shape is not exported
  31829. * @param systems defines the particle systems to export
  31830. * @returns the created particle system set
  31831. */
  31832. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  31833. }
  31834. }
  31835. declare module BABYLON {
  31836. /**
  31837. * This represents a particle system in Babylon.
  31838. * 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.
  31839. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31840. * @example https://doc.babylonjs.com/babylon101/particles
  31841. */
  31842. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  31843. /**
  31844. * Billboard mode will only apply to Y axis
  31845. */
  31846. static readonly BILLBOARDMODE_Y: number;
  31847. /**
  31848. * Billboard mode will apply to all axes
  31849. */
  31850. static readonly BILLBOARDMODE_ALL: number;
  31851. /**
  31852. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  31853. */
  31854. static readonly BILLBOARDMODE_STRETCHED: number;
  31855. /**
  31856. * This function can be defined to provide custom update for active particles.
  31857. * This function will be called instead of regular update (age, position, color, etc.).
  31858. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  31859. */
  31860. updateFunction: (particles: Particle[]) => void;
  31861. private _emitterWorldMatrix;
  31862. /**
  31863. * This function can be defined to specify initial direction for every new particle.
  31864. * It by default use the emitterType defined function
  31865. */
  31866. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  31867. /**
  31868. * This function can be defined to specify initial position for every new particle.
  31869. * It by default use the emitterType defined function
  31870. */
  31871. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  31872. /**
  31873. * @hidden
  31874. */
  31875. _inheritedVelocityOffset: Vector3;
  31876. /**
  31877. * An event triggered when the system is disposed
  31878. */
  31879. onDisposeObservable: Observable<ParticleSystem>;
  31880. private _onDisposeObserver;
  31881. /**
  31882. * Sets a callback that will be triggered when the system is disposed
  31883. */
  31884. onDispose: () => void;
  31885. private _particles;
  31886. private _epsilon;
  31887. private _capacity;
  31888. private _stockParticles;
  31889. private _newPartsExcess;
  31890. private _vertexData;
  31891. private _vertexBuffer;
  31892. private _vertexBuffers;
  31893. private _spriteBuffer;
  31894. private _indexBuffer;
  31895. private _effect;
  31896. private _customEffect;
  31897. private _cachedDefines;
  31898. private _scaledColorStep;
  31899. private _colorDiff;
  31900. private _scaledDirection;
  31901. private _scaledGravity;
  31902. private _currentRenderId;
  31903. private _alive;
  31904. private _useInstancing;
  31905. private _started;
  31906. private _stopped;
  31907. private _actualFrame;
  31908. private _scaledUpdateSpeed;
  31909. private _vertexBufferSize;
  31910. /** @hidden */
  31911. _currentEmitRateGradient: Nullable<FactorGradient>;
  31912. /** @hidden */
  31913. _currentEmitRate1: number;
  31914. /** @hidden */
  31915. _currentEmitRate2: number;
  31916. /** @hidden */
  31917. _currentStartSizeGradient: Nullable<FactorGradient>;
  31918. /** @hidden */
  31919. _currentStartSize1: number;
  31920. /** @hidden */
  31921. _currentStartSize2: number;
  31922. private readonly _rawTextureWidth;
  31923. private _rampGradientsTexture;
  31924. private _useRampGradients;
  31925. /** Gets or sets a boolean indicating that ramp gradients must be used
  31926. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31927. */
  31928. useRampGradients: boolean;
  31929. /**
  31930. * 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.
  31931. * 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: [])
  31932. */
  31933. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  31934. private _subEmitters;
  31935. /**
  31936. * @hidden
  31937. * If the particle systems emitter should be disposed when the particle system is disposed
  31938. */
  31939. _disposeEmitterOnDispose: boolean;
  31940. /**
  31941. * The current active Sub-systems, this property is used by the root particle system only.
  31942. */
  31943. activeSubSystems: Array<ParticleSystem>;
  31944. private _rootParticleSystem;
  31945. /**
  31946. * Gets the current list of active particles
  31947. */
  31948. readonly particles: Particle[];
  31949. /**
  31950. * Returns the string "ParticleSystem"
  31951. * @returns a string containing the class name
  31952. */
  31953. getClassName(): string;
  31954. /**
  31955. * Instantiates a particle system.
  31956. * 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.
  31957. * @param name The name of the particle system
  31958. * @param capacity The max number of particles alive at the same time
  31959. * @param scene The scene the particle system belongs to
  31960. * @param customEffect a custom effect used to change the way particles are rendered by default
  31961. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31962. * @param epsilon Offset used to render the particles
  31963. */
  31964. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  31965. private _addFactorGradient;
  31966. private _removeFactorGradient;
  31967. /**
  31968. * Adds a new life time gradient
  31969. * @param gradient defines the gradient to use (between 0 and 1)
  31970. * @param factor defines the life time factor to affect to the specified gradient
  31971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31972. * @returns the current particle system
  31973. */
  31974. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31975. /**
  31976. * Remove a specific life time gradient
  31977. * @param gradient defines the gradient to remove
  31978. * @returns the current particle system
  31979. */
  31980. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31981. /**
  31982. * Adds a new size gradient
  31983. * @param gradient defines the gradient to use (between 0 and 1)
  31984. * @param factor defines the size factor to affect to the specified gradient
  31985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31986. * @returns the current particle system
  31987. */
  31988. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31989. /**
  31990. * Remove a specific size gradient
  31991. * @param gradient defines the gradient to remove
  31992. * @returns the current particle system
  31993. */
  31994. removeSizeGradient(gradient: number): IParticleSystem;
  31995. /**
  31996. * Adds a new color remap gradient
  31997. * @param gradient defines the gradient to use (between 0 and 1)
  31998. * @param min defines the color remap minimal range
  31999. * @param max defines the color remap maximal range
  32000. * @returns the current particle system
  32001. */
  32002. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32003. /**
  32004. * Remove a specific color remap gradient
  32005. * @param gradient defines the gradient to remove
  32006. * @returns the current particle system
  32007. */
  32008. removeColorRemapGradient(gradient: number): IParticleSystem;
  32009. /**
  32010. * Adds a new alpha remap gradient
  32011. * @param gradient defines the gradient to use (between 0 and 1)
  32012. * @param min defines the alpha remap minimal range
  32013. * @param max defines the alpha remap maximal range
  32014. * @returns the current particle system
  32015. */
  32016. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32017. /**
  32018. * Remove a specific alpha remap gradient
  32019. * @param gradient defines the gradient to remove
  32020. * @returns the current particle system
  32021. */
  32022. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  32023. /**
  32024. * Adds a new angular speed gradient
  32025. * @param gradient defines the gradient to use (between 0 and 1)
  32026. * @param factor defines the angular speed to affect to the specified gradient
  32027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32028. * @returns the current particle system
  32029. */
  32030. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32031. /**
  32032. * Remove a specific angular speed gradient
  32033. * @param gradient defines the gradient to remove
  32034. * @returns the current particle system
  32035. */
  32036. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  32037. /**
  32038. * Adds a new velocity gradient
  32039. * @param gradient defines the gradient to use (between 0 and 1)
  32040. * @param factor defines the velocity to affect to the specified gradient
  32041. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32042. * @returns the current particle system
  32043. */
  32044. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32045. /**
  32046. * Remove a specific velocity gradient
  32047. * @param gradient defines the gradient to remove
  32048. * @returns the current particle system
  32049. */
  32050. removeVelocityGradient(gradient: number): IParticleSystem;
  32051. /**
  32052. * Adds a new limit velocity gradient
  32053. * @param gradient defines the gradient to use (between 0 and 1)
  32054. * @param factor defines the limit velocity value to affect to the specified gradient
  32055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32056. * @returns the current particle system
  32057. */
  32058. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32059. /**
  32060. * Remove a specific limit velocity gradient
  32061. * @param gradient defines the gradient to remove
  32062. * @returns the current particle system
  32063. */
  32064. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  32065. /**
  32066. * Adds a new drag gradient
  32067. * @param gradient defines the gradient to use (between 0 and 1)
  32068. * @param factor defines the drag value to affect to the specified gradient
  32069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32070. * @returns the current particle system
  32071. */
  32072. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32073. /**
  32074. * Remove a specific drag gradient
  32075. * @param gradient defines the gradient to remove
  32076. * @returns the current particle system
  32077. */
  32078. removeDragGradient(gradient: number): IParticleSystem;
  32079. /**
  32080. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  32081. * @param gradient defines the gradient to use (between 0 and 1)
  32082. * @param factor defines the emit rate value to affect to the specified gradient
  32083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32084. * @returns the current particle system
  32085. */
  32086. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32087. /**
  32088. * Remove a specific emit rate gradient
  32089. * @param gradient defines the gradient to remove
  32090. * @returns the current particle system
  32091. */
  32092. removeEmitRateGradient(gradient: number): IParticleSystem;
  32093. /**
  32094. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  32095. * @param gradient defines the gradient to use (between 0 and 1)
  32096. * @param factor defines the start size value to affect to the specified gradient
  32097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32098. * @returns the current particle system
  32099. */
  32100. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32101. /**
  32102. * Remove a specific start size gradient
  32103. * @param gradient defines the gradient to remove
  32104. * @returns the current particle system
  32105. */
  32106. removeStartSizeGradient(gradient: number): IParticleSystem;
  32107. private _createRampGradientTexture;
  32108. /**
  32109. * Gets the current list of ramp gradients.
  32110. * You must use addRampGradient and removeRampGradient to udpate this list
  32111. * @returns the list of ramp gradients
  32112. */
  32113. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32114. /**
  32115. * Adds a new ramp gradient used to remap particle colors
  32116. * @param gradient defines the gradient to use (between 0 and 1)
  32117. * @param color defines the color to affect to the specified gradient
  32118. * @returns the current particle system
  32119. */
  32120. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  32121. /**
  32122. * Remove a specific ramp gradient
  32123. * @param gradient defines the gradient to remove
  32124. * @returns the current particle system
  32125. */
  32126. removeRampGradient(gradient: number): ParticleSystem;
  32127. /**
  32128. * Adds a new color gradient
  32129. * @param gradient defines the gradient to use (between 0 and 1)
  32130. * @param color1 defines the color to affect to the specified gradient
  32131. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32132. * @returns this particle system
  32133. */
  32134. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32135. /**
  32136. * Remove a specific color gradient
  32137. * @param gradient defines the gradient to remove
  32138. * @returns this particle system
  32139. */
  32140. removeColorGradient(gradient: number): IParticleSystem;
  32141. private _fetchR;
  32142. protected _reset(): void;
  32143. private _resetEffect;
  32144. private _createVertexBuffers;
  32145. private _createIndexBuffer;
  32146. /**
  32147. * Gets the maximum number of particles active at the same time.
  32148. * @returns The max number of active particles.
  32149. */
  32150. getCapacity(): number;
  32151. /**
  32152. * Gets whether there are still active particles in the system.
  32153. * @returns True if it is alive, otherwise false.
  32154. */
  32155. isAlive(): boolean;
  32156. /**
  32157. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32158. * @returns True if it has been started, otherwise false.
  32159. */
  32160. isStarted(): boolean;
  32161. private _prepareSubEmitterInternalArray;
  32162. /**
  32163. * Starts the particle system and begins to emit
  32164. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  32165. */
  32166. start(delay?: number): void;
  32167. /**
  32168. * Stops the particle system.
  32169. * @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.
  32170. */
  32171. stop(stopSubEmitters?: boolean): void;
  32172. /**
  32173. * Remove all active particles
  32174. */
  32175. reset(): void;
  32176. /**
  32177. * @hidden (for internal use only)
  32178. */
  32179. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  32180. /**
  32181. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  32182. * Its lifetime will start back at 0.
  32183. */
  32184. recycleParticle: (particle: Particle) => void;
  32185. private _stopSubEmitters;
  32186. private _createParticle;
  32187. private _removeFromRoot;
  32188. private _emitFromParticle;
  32189. private _update;
  32190. /** @hidden */
  32191. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  32192. /** @hidden */
  32193. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  32194. /** @hidden */
  32195. private _getEffect;
  32196. /**
  32197. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32198. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  32199. */
  32200. animate(preWarmOnly?: boolean): void;
  32201. private _appendParticleVertices;
  32202. /**
  32203. * Rebuilds the particle system.
  32204. */
  32205. rebuild(): void;
  32206. /**
  32207. * Is this system ready to be used/rendered
  32208. * @return true if the system is ready
  32209. */
  32210. isReady(): boolean;
  32211. private _render;
  32212. /**
  32213. * Renders the particle system in its current state.
  32214. * @returns the current number of particles
  32215. */
  32216. render(): number;
  32217. /**
  32218. * Disposes the particle system and free the associated resources
  32219. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32220. */
  32221. dispose(disposeTexture?: boolean): void;
  32222. /**
  32223. * Clones the particle system.
  32224. * @param name The name of the cloned object
  32225. * @param newEmitter The new emitter to use
  32226. * @returns the cloned particle system
  32227. */
  32228. clone(name: string, newEmitter: any): ParticleSystem;
  32229. /**
  32230. * Serializes the particle system to a JSON object.
  32231. * @returns the JSON object
  32232. */
  32233. serialize(): any;
  32234. /** @hidden */
  32235. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  32236. /** @hidden */
  32237. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  32238. /**
  32239. * Parses a JSON object to create a particle system.
  32240. * @param parsedParticleSystem The JSON object to parse
  32241. * @param scene The scene to create the particle system in
  32242. * @param rootUrl The root url to use to load external dependencies like texture
  32243. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32244. * @returns the Parsed particle system
  32245. */
  32246. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  32247. }
  32248. }
  32249. declare module BABYLON {
  32250. interface Engine {
  32251. /**
  32252. * Create an effect to use with particle systems.
  32253. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  32254. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  32255. * @param uniformsNames defines a list of attribute names
  32256. * @param samplers defines an array of string used to represent textures
  32257. * @param defines defines the string containing the defines to use to compile the shaders
  32258. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32259. * @param onCompiled defines a function to call when the effect creation is successful
  32260. * @param onError defines a function to call when the effect creation has failed
  32261. * @returns the new Effect
  32262. */
  32263. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  32264. }
  32265. interface Mesh {
  32266. /**
  32267. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  32268. * @returns an array of IParticleSystem
  32269. */
  32270. getEmittedParticleSystems(): IParticleSystem[];
  32271. /**
  32272. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  32273. * @returns an array of IParticleSystem
  32274. */
  32275. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  32276. }
  32277. }
  32278. declare module BABYLON {
  32279. /**
  32280. * Represents a set of particle systems working together to create a specific effect
  32281. */
  32282. class ParticleSystemSet implements IDisposable {
  32283. private _emitterCreationOptions;
  32284. private _emitterNode;
  32285. /**
  32286. * Gets the particle system list
  32287. */
  32288. systems: IParticleSystem[];
  32289. /**
  32290. * Gets the emitter node used with this set
  32291. */
  32292. readonly emitterNode: Nullable<TransformNode>;
  32293. /**
  32294. * Creates a new emitter mesh as a sphere
  32295. * @param options defines the options used to create the sphere
  32296. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  32297. * @param scene defines the hosting scene
  32298. */
  32299. setEmitterAsSphere(options: {
  32300. diameter: number;
  32301. segments: number;
  32302. color: Color3;
  32303. }, renderingGroupId: number, scene: Scene): void;
  32304. /**
  32305. * Starts all particle systems of the set
  32306. * @param emitter defines an optional mesh to use as emitter for the particle systems
  32307. */
  32308. start(emitter?: AbstractMesh): void;
  32309. /**
  32310. * Release all associated resources
  32311. */
  32312. dispose(): void;
  32313. /**
  32314. * Serialize the set into a JSON compatible object
  32315. * @returns a JSON compatible representation of the set
  32316. */
  32317. serialize(): any;
  32318. /**
  32319. * Parse a new ParticleSystemSet from a serialized source
  32320. * @param data defines a JSON compatible representation of the set
  32321. * @param scene defines the hosting scene
  32322. * @param gpu defines if we want GPU particles or CPU particles
  32323. * @returns a new ParticleSystemSet
  32324. */
  32325. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  32326. }
  32327. }
  32328. declare module BABYLON {
  32329. /**
  32330. * Represents one particle of a solid particle system.
  32331. */
  32332. class SolidParticle {
  32333. /**
  32334. * particle global index
  32335. */
  32336. idx: number;
  32337. /**
  32338. * The color of the particle
  32339. */
  32340. color: Nullable<Color4>;
  32341. /**
  32342. * The world space position of the particle.
  32343. */
  32344. position: Vector3;
  32345. /**
  32346. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32347. */
  32348. rotation: Vector3;
  32349. /**
  32350. * The world space rotation quaternion of the particle.
  32351. */
  32352. rotationQuaternion: Nullable<Quaternion>;
  32353. /**
  32354. * The scaling of the particle.
  32355. */
  32356. scaling: Vector3;
  32357. /**
  32358. * The uvs of the particle.
  32359. */
  32360. uvs: Vector4;
  32361. /**
  32362. * The current speed of the particle.
  32363. */
  32364. velocity: Vector3;
  32365. /**
  32366. * The pivot point in the particle local space.
  32367. */
  32368. pivot: Vector3;
  32369. /**
  32370. * Must the particle be translated from its pivot point in its local space ?
  32371. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32372. * Default : false
  32373. */
  32374. translateFromPivot: boolean;
  32375. /**
  32376. * Is the particle active or not ?
  32377. */
  32378. alive: boolean;
  32379. /**
  32380. * Is the particle visible or not ?
  32381. */
  32382. isVisible: boolean;
  32383. /**
  32384. * Index of this particle in the global "positions" array (Internal use)
  32385. * @hidden
  32386. */
  32387. _pos: number;
  32388. /**
  32389. * @hidden Index of this particle in the global "indices" array (Internal use)
  32390. */
  32391. _ind: number;
  32392. /**
  32393. * @hidden ModelShape of this particle (Internal use)
  32394. */
  32395. _model: ModelShape;
  32396. /**
  32397. * ModelShape id of this particle
  32398. */
  32399. shapeId: number;
  32400. /**
  32401. * Index of the particle in its shape id (Internal use)
  32402. */
  32403. idxInShape: number;
  32404. /**
  32405. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32406. */
  32407. _modelBoundingInfo: BoundingInfo;
  32408. /**
  32409. * @hidden Particle BoundingInfo object (Internal use)
  32410. */
  32411. _boundingInfo: BoundingInfo;
  32412. /**
  32413. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32414. */
  32415. _sps: SolidParticleSystem;
  32416. /**
  32417. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32418. */
  32419. _stillInvisible: boolean;
  32420. /**
  32421. * @hidden Last computed particle rotation matrix
  32422. */
  32423. _rotationMatrix: number[];
  32424. /**
  32425. * Parent particle Id, if any.
  32426. * Default null.
  32427. */
  32428. parentId: Nullable<number>;
  32429. /**
  32430. * @hidden Internal global position in the SPS.
  32431. */
  32432. _globalPosition: Vector3;
  32433. /**
  32434. * Creates a Solid Particle object.
  32435. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32436. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  32437. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32438. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32439. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32440. * @param shapeId (integer) is the model shape identifier in the SPS.
  32441. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32442. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32443. */
  32444. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  32445. /**
  32446. * Legacy support, changed scale to scaling
  32447. */
  32448. /**
  32449. * Legacy support, changed scale to scaling
  32450. */
  32451. scale: Vector3;
  32452. /**
  32453. * Legacy support, changed quaternion to rotationQuaternion
  32454. */
  32455. /**
  32456. * Legacy support, changed quaternion to rotationQuaternion
  32457. */
  32458. quaternion: Nullable<Quaternion>;
  32459. /**
  32460. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32461. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32462. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32463. * @returns true if it intersects
  32464. */
  32465. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32466. /**
  32467. * get the rotation matrix of the particle
  32468. * @hidden
  32469. */
  32470. getRotationMatrix(m: Matrix): void;
  32471. }
  32472. /**
  32473. * Represents the shape of the model used by one particle of a solid particle system.
  32474. * SPS internal tool, don't use it manually.
  32475. */
  32476. class ModelShape {
  32477. /**
  32478. * The shape id
  32479. * @hidden
  32480. */
  32481. shapeID: number;
  32482. /**
  32483. * flat array of model positions (internal use)
  32484. * @hidden
  32485. */
  32486. _shape: Vector3[];
  32487. /**
  32488. * flat array of model UVs (internal use)
  32489. * @hidden
  32490. */
  32491. _shapeUV: number[];
  32492. /**
  32493. * length of the shape in the model indices array (internal use)
  32494. * @hidden
  32495. */
  32496. _indicesLength: number;
  32497. /**
  32498. * Custom position function (internal use)
  32499. * @hidden
  32500. */
  32501. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32502. /**
  32503. * Custom vertex function (internal use)
  32504. * @hidden
  32505. */
  32506. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32507. /**
  32508. * 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.
  32509. * SPS internal tool, don't use it manually.
  32510. * @hidden
  32511. */
  32512. 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>);
  32513. }
  32514. /**
  32515. * Represents a Depth Sorted Particle in the solid particle system.
  32516. */
  32517. class DepthSortedParticle {
  32518. /**
  32519. * Index of the particle in the "indices" array
  32520. */
  32521. ind: number;
  32522. /**
  32523. * Length of the particle shape in the "indices" array
  32524. */
  32525. indicesLength: number;
  32526. /**
  32527. * Squared distance from the particle to the camera
  32528. */
  32529. sqDistance: number;
  32530. }
  32531. }
  32532. declare module BABYLON {
  32533. /**
  32534. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32535. *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.
  32536. * The SPS is also a particle system. It provides some methods to manage the particles.
  32537. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32538. *
  32539. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  32540. */
  32541. class SolidParticleSystem implements IDisposable {
  32542. /**
  32543. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32544. * Example : var p = SPS.particles[i];
  32545. */
  32546. particles: SolidParticle[];
  32547. /**
  32548. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32549. */
  32550. nbParticles: number;
  32551. /**
  32552. * If the particles must ever face the camera (default false). Useful for planar particles.
  32553. */
  32554. billboard: boolean;
  32555. /**
  32556. * Recompute normals when adding a shape
  32557. */
  32558. recomputeNormals: boolean;
  32559. /**
  32560. * This a counter ofr your own usage. It's not set by any SPS functions.
  32561. */
  32562. counter: number;
  32563. /**
  32564. * The SPS name. This name is also given to the underlying mesh.
  32565. */
  32566. name: string;
  32567. /**
  32568. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32569. */
  32570. mesh: Mesh;
  32571. /**
  32572. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32573. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  32574. */
  32575. vars: any;
  32576. /**
  32577. * This array is populated when the SPS is set as 'pickable'.
  32578. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32579. * Each element of this array is an object `{idx: int, faceId: int}`.
  32580. * `idx` is the picked particle index in the `SPS.particles` array
  32581. * `faceId` is the picked face index counted within this particle.
  32582. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  32583. */
  32584. pickedParticles: {
  32585. idx: number;
  32586. faceId: number;
  32587. }[];
  32588. /**
  32589. * This array is populated when `enableDepthSort` is set to true.
  32590. * Each element of this array is an instance of the class DepthSortedParticle.
  32591. */
  32592. depthSortedParticles: DepthSortedParticle[];
  32593. /**
  32594. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32595. * @hidden
  32596. */
  32597. _bSphereOnly: boolean;
  32598. /**
  32599. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32600. * @hidden
  32601. */
  32602. _bSphereRadiusFactor: number;
  32603. private _scene;
  32604. private _positions;
  32605. private _indices;
  32606. private _normals;
  32607. private _colors;
  32608. private _uvs;
  32609. private _indices32;
  32610. private _positions32;
  32611. private _normals32;
  32612. private _fixedNormal32;
  32613. private _colors32;
  32614. private _uvs32;
  32615. private _index;
  32616. private _updatable;
  32617. private _pickable;
  32618. private _isVisibilityBoxLocked;
  32619. private _alwaysVisible;
  32620. private _depthSort;
  32621. private _shapeCounter;
  32622. private _copy;
  32623. private _color;
  32624. private _computeParticleColor;
  32625. private _computeParticleTexture;
  32626. private _computeParticleRotation;
  32627. private _computeParticleVertex;
  32628. private _computeBoundingBox;
  32629. private _depthSortParticles;
  32630. private _camera;
  32631. private _mustUnrotateFixedNormals;
  32632. private _particlesIntersect;
  32633. private _needs32Bits;
  32634. /**
  32635. * Creates a SPS (Solid Particle System) object.
  32636. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32637. * @param scene (Scene) is the scene in which the SPS is added.
  32638. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32639. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32640. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32641. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32642. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32643. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32644. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32645. */
  32646. constructor(name: string, scene: Scene, options?: {
  32647. updatable?: boolean;
  32648. isPickable?: boolean;
  32649. enableDepthSort?: boolean;
  32650. particleIntersection?: boolean;
  32651. boundingSphereOnly?: boolean;
  32652. bSphereRadiusFactor?: number;
  32653. });
  32654. /**
  32655. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32656. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32657. * @returns the created mesh
  32658. */
  32659. buildMesh(): Mesh;
  32660. /**
  32661. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32662. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32663. * Thus the particles generated from `digest()` have their property `position` set yet.
  32664. * @param mesh ( Mesh ) is the mesh to be digested
  32665. * @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
  32666. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32667. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32668. * @returns the current SPS
  32669. */
  32670. digest(mesh: Mesh, options?: {
  32671. facetNb?: number;
  32672. number?: number;
  32673. delta?: number;
  32674. }): SolidParticleSystem;
  32675. private _unrotateFixedNormals;
  32676. private _resetCopy;
  32677. private _meshBuilder;
  32678. private _posToShape;
  32679. private _uvsToShapeUV;
  32680. private _addParticle;
  32681. /**
  32682. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32683. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  32684. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32685. * @param nb (positive integer) the number of particles to be created from this model
  32686. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32687. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32688. * @returns the number of shapes in the system
  32689. */
  32690. addShape(mesh: Mesh, nb: number, options?: {
  32691. positionFunction?: any;
  32692. vertexFunction?: any;
  32693. }): number;
  32694. private _rebuildParticle;
  32695. /**
  32696. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32697. * @returns the SPS.
  32698. */
  32699. rebuildMesh(): SolidParticleSystem;
  32700. /**
  32701. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32702. * This method calls `updateParticle()` for each particle of the SPS.
  32703. * For an animated SPS, it is usually called within the render loop.
  32704. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32705. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32706. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32707. * @returns the SPS.
  32708. */
  32709. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32710. /**
  32711. * Disposes the SPS.
  32712. */
  32713. dispose(): void;
  32714. /**
  32715. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32716. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32717. * @returns the SPS.
  32718. */
  32719. refreshVisibleSize(): SolidParticleSystem;
  32720. /**
  32721. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32722. * @param size the size (float) of the visibility box
  32723. * note : this doesn't lock the SPS mesh bounding box.
  32724. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32725. */
  32726. setVisibilityBox(size: number): void;
  32727. /**
  32728. * Gets whether the SPS as always visible or not
  32729. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32730. */
  32731. /**
  32732. * Sets the SPS as always visible or not
  32733. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32734. */
  32735. isAlwaysVisible: boolean;
  32736. /**
  32737. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32738. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32739. */
  32740. /**
  32741. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32742. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32743. */
  32744. isVisibilityBoxLocked: boolean;
  32745. /**
  32746. * Tells to `setParticles()` to compute the particle rotations or not.
  32747. * Default value : true. The SPS is faster when it's set to false.
  32748. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32749. */
  32750. /**
  32751. * Gets if `setParticles()` computes the particle rotations or not.
  32752. * Default value : true. The SPS is faster when it's set to false.
  32753. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32754. */
  32755. computeParticleRotation: boolean;
  32756. /**
  32757. * Tells to `setParticles()` to compute the particle colors or not.
  32758. * Default value : true. The SPS is faster when it's set to false.
  32759. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32760. */
  32761. /**
  32762. * Gets if `setParticles()` computes the particle colors or not.
  32763. * Default value : true. The SPS is faster when it's set to false.
  32764. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32765. */
  32766. computeParticleColor: boolean;
  32767. /**
  32768. * Gets if `setParticles()` computes the particle textures or not.
  32769. * Default value : true. The SPS is faster when it's set to false.
  32770. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32771. */
  32772. computeParticleTexture: boolean;
  32773. /**
  32774. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32775. * Default value : false. The SPS is faster when it's set to false.
  32776. * Note : the particle custom vertex positions aren't stored values.
  32777. */
  32778. /**
  32779. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32780. * Default value : false. The SPS is faster when it's set to false.
  32781. * Note : the particle custom vertex positions aren't stored values.
  32782. */
  32783. computeParticleVertex: boolean;
  32784. /**
  32785. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32786. */
  32787. /**
  32788. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32789. */
  32790. computeBoundingBox: boolean;
  32791. /**
  32792. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32793. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32794. * Default : `true`
  32795. */
  32796. /**
  32797. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32798. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32799. * Default : `true`
  32800. */
  32801. depthSortParticles: boolean;
  32802. /**
  32803. * This function does nothing. It may be overwritten to set all the particle first values.
  32804. * The SPS doesn't call this function, you may have to call it by your own.
  32805. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32806. */
  32807. initParticles(): void;
  32808. /**
  32809. * This function does nothing. It may be overwritten to recycle a particle.
  32810. * The SPS doesn't call this function, you may have to call it by your own.
  32811. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32812. * @param particle The particle to recycle
  32813. * @returns the recycled particle
  32814. */
  32815. recycleParticle(particle: SolidParticle): SolidParticle;
  32816. /**
  32817. * Updates a particle : this function should be overwritten by the user.
  32818. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32819. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32820. * @example : just set a particle position or velocity and recycle conditions
  32821. * @param particle The particle to update
  32822. * @returns the updated particle
  32823. */
  32824. updateParticle(particle: SolidParticle): SolidParticle;
  32825. /**
  32826. * Updates a vertex of a particle : it can be overwritten by the user.
  32827. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32828. * @param particle the current particle
  32829. * @param vertex the current index of the current particle
  32830. * @param pt the index of the current vertex in the particle shape
  32831. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  32832. * @example : just set a vertex particle position
  32833. * @returns the updated vertex
  32834. */
  32835. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  32836. /**
  32837. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32838. * This does nothing and may be overwritten by the user.
  32839. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32840. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32841. * @param update the boolean update value actually passed to setParticles()
  32842. */
  32843. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32844. /**
  32845. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32846. * This will be passed three parameters.
  32847. * This does nothing and may be overwritten by the user.
  32848. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32849. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32850. * @param update the boolean update value actually passed to setParticles()
  32851. */
  32852. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32853. }
  32854. }
  32855. declare module BABYLON {
  32856. /**
  32857. * Type of sub emitter
  32858. */
  32859. enum SubEmitterType {
  32860. /**
  32861. * Attached to the particle over it's lifetime
  32862. */
  32863. ATTACHED = 0,
  32864. /**
  32865. * Created when the particle dies
  32866. */
  32867. END = 1
  32868. }
  32869. /**
  32870. * Sub emitter class used to emit particles from an existing particle
  32871. */
  32872. class SubEmitter {
  32873. /**
  32874. * the particle system to be used by the sub emitter
  32875. */
  32876. particleSystem: ParticleSystem;
  32877. /**
  32878. * Type of the submitter (Default: END)
  32879. */
  32880. type: SubEmitterType;
  32881. /**
  32882. * 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)
  32883. * Note: This only is supported when using an emitter of type Mesh
  32884. */
  32885. inheritDirection: boolean;
  32886. /**
  32887. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  32888. */
  32889. inheritedVelocityAmount: number;
  32890. /**
  32891. * Creates a sub emitter
  32892. * @param particleSystem the particle system to be used by the sub emitter
  32893. */
  32894. constructor(
  32895. /**
  32896. * the particle system to be used by the sub emitter
  32897. */
  32898. particleSystem: ParticleSystem);
  32899. /**
  32900. * Clones the sub emitter
  32901. * @returns the cloned sub emitter
  32902. */
  32903. clone(): SubEmitter;
  32904. /**
  32905. * Serialize current object to a JSON object
  32906. * @returns the serialized object
  32907. */
  32908. serialize(): any;
  32909. /**
  32910. * Creates a new SubEmitter from a serialized JSON version
  32911. * @param serializationObject defines the JSON object to read from
  32912. * @param scene defines the hosting scene
  32913. * @param rootUrl defines the rootUrl for data loading
  32914. * @returns a new SubEmitter
  32915. */
  32916. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  32917. /** Release associated resources */
  32918. dispose(): void;
  32919. }
  32920. }
  32921. declare module BABYLON {
  32922. /**
  32923. * Interface used to describe a physics joint
  32924. */
  32925. interface PhysicsImpostorJoint {
  32926. /** Defines the main impostor to which the joint is linked */
  32927. mainImpostor: PhysicsImpostor;
  32928. /** Defines the impostor that is connected to the main impostor using this joint */
  32929. connectedImpostor: PhysicsImpostor;
  32930. /** Defines the joint itself */
  32931. joint: PhysicsJoint;
  32932. }
  32933. /** @hidden */
  32934. interface IPhysicsEnginePlugin {
  32935. world: any;
  32936. name: string;
  32937. setGravity(gravity: Vector3): void;
  32938. setTimeStep(timeStep: number): void;
  32939. getTimeStep(): number;
  32940. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32941. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32942. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32943. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32944. removePhysicsBody(impostor: PhysicsImpostor): void;
  32945. generateJoint(joint: PhysicsImpostorJoint): void;
  32946. removeJoint(joint: PhysicsImpostorJoint): void;
  32947. isSupported(): boolean;
  32948. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32949. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32950. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32951. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32952. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32953. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32954. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32955. getBodyMass(impostor: PhysicsImpostor): number;
  32956. getBodyFriction(impostor: PhysicsImpostor): number;
  32957. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32958. getBodyRestitution(impostor: PhysicsImpostor): number;
  32959. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32960. sleepBody(impostor: PhysicsImpostor): void;
  32961. wakeUpBody(impostor: PhysicsImpostor): void;
  32962. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32963. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32964. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32965. getRadius(impostor: PhysicsImpostor): number;
  32966. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32967. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32968. dispose(): void;
  32969. }
  32970. /**
  32971. * Interface used to define a physics engine
  32972. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32973. */
  32974. interface IPhysicsEngine {
  32975. /**
  32976. * Gets the gravity vector used by the simulation
  32977. */
  32978. gravity: Vector3;
  32979. /**
  32980. * Sets the gravity vector used by the simulation
  32981. * @param gravity defines the gravity vector to use
  32982. */
  32983. setGravity(gravity: Vector3): void;
  32984. /**
  32985. * Set the time step of the physics engine.
  32986. * Default is 1/60.
  32987. * To slow it down, enter 1/600 for example.
  32988. * To speed it up, 1/30
  32989. * @param newTimeStep the new timestep to apply to this world.
  32990. */
  32991. setTimeStep(newTimeStep: number): void;
  32992. /**
  32993. * Get the time step of the physics engine.
  32994. * @returns the current time step
  32995. */
  32996. getTimeStep(): number;
  32997. /**
  32998. * Release all resources
  32999. */
  33000. dispose(): void;
  33001. /**
  33002. * Gets the name of the current physics plugin
  33003. * @returns the name of the plugin
  33004. */
  33005. getPhysicsPluginName(): string;
  33006. /**
  33007. * Adding a new impostor for the impostor tracking.
  33008. * This will be done by the impostor itself.
  33009. * @param impostor the impostor to add
  33010. */
  33011. addImpostor(impostor: PhysicsImpostor): void;
  33012. /**
  33013. * Remove an impostor from the engine.
  33014. * This impostor and its mesh will not longer be updated by the physics engine.
  33015. * @param impostor the impostor to remove
  33016. */
  33017. removeImpostor(impostor: PhysicsImpostor): void;
  33018. /**
  33019. * Add a joint to the physics engine
  33020. * @param mainImpostor defines the main impostor to which the joint is added.
  33021. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33022. * @param joint defines the joint that will connect both impostors.
  33023. */
  33024. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33025. /**
  33026. * Removes a joint from the simulation
  33027. * @param mainImpostor defines the impostor used with the joint
  33028. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33029. * @param joint defines the joint to remove
  33030. */
  33031. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33032. /**
  33033. * Gets the current plugin used to run the simulation
  33034. * @returns current plugin
  33035. */
  33036. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33037. /**
  33038. * Gets the list of physic impostors
  33039. * @returns an array of PhysicsImpostor
  33040. */
  33041. getImpostors(): Array<PhysicsImpostor>;
  33042. /**
  33043. * Gets the impostor for a physics enabled object
  33044. * @param object defines the object impersonated by the impostor
  33045. * @returns the PhysicsImpostor or null if not found
  33046. */
  33047. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33048. /**
  33049. * Gets the impostor for a physics body object
  33050. * @param body defines physics body used by the impostor
  33051. * @returns the PhysicsImpostor or null if not found
  33052. */
  33053. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33054. /**
  33055. * Called by the scene. No need to call it.
  33056. * @param delta defines the timespam between frames
  33057. */
  33058. _step(delta: number): void;
  33059. }
  33060. }
  33061. declare module BABYLON {
  33062. /**
  33063. * Class used to control physics engine
  33064. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33065. */
  33066. class PhysicsEngine implements IPhysicsEngine {
  33067. private _physicsPlugin;
  33068. /**
  33069. * Global value used to control the smallest number supported by the simulation
  33070. */
  33071. static Epsilon: number;
  33072. private _impostors;
  33073. private _joints;
  33074. /**
  33075. * Gets the gravity vector used by the simulation
  33076. */
  33077. gravity: Vector3;
  33078. /**
  33079. * Creates a new Physics Engine
  33080. * @param gravity defines the gravity vector used by the simulation
  33081. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  33082. */
  33083. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  33084. /**
  33085. * Sets the gravity vector used by the simulation
  33086. * @param gravity defines the gravity vector to use
  33087. */
  33088. setGravity(gravity: Vector3): void;
  33089. /**
  33090. * Set the time step of the physics engine.
  33091. * Default is 1/60.
  33092. * To slow it down, enter 1/600 for example.
  33093. * To speed it up, 1/30
  33094. * @param newTimeStep defines the new timestep to apply to this world.
  33095. */
  33096. setTimeStep(newTimeStep?: number): void;
  33097. /**
  33098. * Get the time step of the physics engine.
  33099. * @returns the current time step
  33100. */
  33101. getTimeStep(): number;
  33102. /**
  33103. * Release all resources
  33104. */
  33105. dispose(): void;
  33106. /**
  33107. * Gets the name of the current physics plugin
  33108. * @returns the name of the plugin
  33109. */
  33110. getPhysicsPluginName(): string;
  33111. /**
  33112. * Adding a new impostor for the impostor tracking.
  33113. * This will be done by the impostor itself.
  33114. * @param impostor the impostor to add
  33115. */
  33116. addImpostor(impostor: PhysicsImpostor): void;
  33117. /**
  33118. * Remove an impostor from the engine.
  33119. * This impostor and its mesh will not longer be updated by the physics engine.
  33120. * @param impostor the impostor to remove
  33121. */
  33122. removeImpostor(impostor: PhysicsImpostor): void;
  33123. /**
  33124. * Add a joint to the physics engine
  33125. * @param mainImpostor defines the main impostor to which the joint is added.
  33126. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33127. * @param joint defines the joint that will connect both impostors.
  33128. */
  33129. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33130. /**
  33131. * Removes a joint from the simulation
  33132. * @param mainImpostor defines the impostor used with the joint
  33133. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33134. * @param joint defines the joint to remove
  33135. */
  33136. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33137. /**
  33138. * Called by the scene. No need to call it.
  33139. * @param delta defines the timespam between frames
  33140. */
  33141. _step(delta: number): void;
  33142. /**
  33143. * Gets the current plugin used to run the simulation
  33144. * @returns current plugin
  33145. */
  33146. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33147. /**
  33148. * Gets the list of physic impostors
  33149. * @returns an array of PhysicsImpostor
  33150. */
  33151. getImpostors(): Array<PhysicsImpostor>;
  33152. /**
  33153. * Gets the impostor for a physics enabled object
  33154. * @param object defines the object impersonated by the impostor
  33155. * @returns the PhysicsImpostor or null if not found
  33156. */
  33157. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33158. /**
  33159. * Gets the impostor for a physics body object
  33160. * @param body defines physics body used by the impostor
  33161. * @returns the PhysicsImpostor or null if not found
  33162. */
  33163. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33164. }
  33165. }
  33166. declare module BABYLON {
  33167. interface Scene {
  33168. /** @hidden (Backing field) */
  33169. _physicsEngine: Nullable<IPhysicsEngine>;
  33170. /**
  33171. * Gets the current physics engine
  33172. * @returns a IPhysicsEngine or null if none attached
  33173. */
  33174. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  33175. /**
  33176. * Enables physics to the current scene
  33177. * @param gravity defines the scene's gravity for the physics engine
  33178. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  33179. * @return a boolean indicating if the physics engine was initialized
  33180. */
  33181. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  33182. /**
  33183. * Disables and disposes the physics engine associated with the scene
  33184. */
  33185. disablePhysicsEngine(): void;
  33186. /**
  33187. * Gets a boolean indicating if there is an active physics engine
  33188. * @returns a boolean indicating if there is an active physics engine
  33189. */
  33190. isPhysicsEnabled(): boolean;
  33191. /**
  33192. * Deletes a physics compound impostor
  33193. * @param compound defines the compound to delete
  33194. */
  33195. deleteCompoundImpostor(compound: any): void;
  33196. /**
  33197. * An event triggered when physic simulation is about to be run
  33198. */
  33199. onBeforePhysicsObservable: Observable<Scene>;
  33200. /**
  33201. * An event triggered when physic simulation has been done
  33202. */
  33203. onAfterPhysicsObservable: Observable<Scene>;
  33204. }
  33205. interface AbstractMesh {
  33206. /** @hidden */
  33207. _physicsImpostor: Nullable<PhysicsImpostor>;
  33208. /**
  33209. * Gets or sets impostor used for physic simulation
  33210. * @see http://doc.babylonjs.com/features/physics_engine
  33211. */
  33212. physicsImpostor: Nullable<PhysicsImpostor>;
  33213. /**
  33214. * Gets the current physics impostor
  33215. * @see http://doc.babylonjs.com/features/physics_engine
  33216. * @returns a physics impostor or null
  33217. */
  33218. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  33219. /** Apply a physic impulse to the mesh
  33220. * @param force defines the force to apply
  33221. * @param contactPoint defines where to apply the force
  33222. * @returns the current mesh
  33223. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33224. */
  33225. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  33226. /**
  33227. * Creates a physic joint between two meshes
  33228. * @param otherMesh defines the other mesh to use
  33229. * @param pivot1 defines the pivot to use on this mesh
  33230. * @param pivot2 defines the pivot to use on the other mesh
  33231. * @param options defines additional options (can be plugin dependent)
  33232. * @returns the current mesh
  33233. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  33234. */
  33235. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  33236. /** @hidden */
  33237. _disposePhysicsObserver: Nullable<Observer<Node>>;
  33238. }
  33239. /**
  33240. * Defines the physics engine scene component responsible to manage a physics engine
  33241. */
  33242. class PhysicsEngineSceneComponent implements ISceneComponent {
  33243. /**
  33244. * The component name helpful to identify the component in the list of scene components.
  33245. */
  33246. readonly name: string;
  33247. /**
  33248. * The scene the component belongs to.
  33249. */
  33250. scene: Scene;
  33251. /**
  33252. * Creates a new instance of the component for the given scene
  33253. * @param scene Defines the scene to register the component in
  33254. */
  33255. constructor(scene: Scene);
  33256. /**
  33257. * Registers the component in a given scene
  33258. */
  33259. register(): void;
  33260. /**
  33261. * Rebuilds the elements related to this component in case of
  33262. * context lost for instance.
  33263. */
  33264. rebuild(): void;
  33265. /**
  33266. * Disposes the component and the associated ressources
  33267. */
  33268. dispose(): void;
  33269. }
  33270. }
  33271. declare module BABYLON {
  33272. /**
  33273. * A helper for physics simulations
  33274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33275. */
  33276. class PhysicsHelper {
  33277. private _scene;
  33278. private _physicsEngine;
  33279. /**
  33280. * Initializes the Physics helper
  33281. * @param scene Babylon.js scene
  33282. */
  33283. constructor(scene: Scene);
  33284. /**
  33285. * Applies a radial explosion impulse
  33286. * @param origin the origin of the explosion
  33287. * @param radius the explosion radius
  33288. * @param strength the explosion strength
  33289. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33290. * @returns A physics radial explosion event, or null
  33291. */
  33292. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33293. /**
  33294. * Applies a radial explosion force
  33295. * @param origin the origin of the explosion
  33296. * @param radius the explosion radius
  33297. * @param strength the explosion strength
  33298. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33299. * @returns A physics radial explosion event, or null
  33300. */
  33301. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33302. /**
  33303. * Creates a gravitational field
  33304. * @param origin the origin of the explosion
  33305. * @param radius the explosion radius
  33306. * @param strength the explosion strength
  33307. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33308. * @returns A physics gravitational field event, or null
  33309. */
  33310. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  33311. /**
  33312. * Creates a physics updraft event
  33313. * @param origin the origin of the updraft
  33314. * @param radius the radius of the updraft
  33315. * @param strength the strength of the updraft
  33316. * @param height the height of the updraft
  33317. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  33318. * @returns A physics updraft event, or null
  33319. */
  33320. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  33321. /**
  33322. * Creates a physics vortex event
  33323. * @param origin the of the vortex
  33324. * @param radius the radius of the vortex
  33325. * @param strength the strength of the vortex
  33326. * @param height the height of the vortex
  33327. * @returns a Physics vortex event, or null
  33328. * A physics vortex event or null
  33329. */
  33330. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  33331. }
  33332. /**
  33333. * Represents a physics radial explosion event
  33334. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33335. */
  33336. class PhysicsRadialExplosionEvent {
  33337. private _scene;
  33338. private _sphere;
  33339. private _sphereOptions;
  33340. private _rays;
  33341. private _dataFetched;
  33342. /**
  33343. * Initializes a radial explosioin event
  33344. * @param scene BabylonJS scene
  33345. */
  33346. constructor(scene: Scene);
  33347. /**
  33348. * Returns the data related to the radial explosion event (sphere & rays).
  33349. * @returns The radial explosion event data
  33350. */
  33351. getData(): PhysicsRadialExplosionEventData;
  33352. /**
  33353. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  33354. * @param impostor A physics imposter
  33355. * @param origin the origin of the explosion
  33356. * @param radius the explosion radius
  33357. * @param strength the explosion strength
  33358. * @param falloff possible options: Constant & Linear
  33359. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  33360. */
  33361. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  33362. /**
  33363. * Disposes the sphere.
  33364. * @param force Specifies if the sphere should be disposed by force
  33365. */
  33366. dispose(force?: boolean): void;
  33367. /*** Helpers ***/
  33368. private _prepareSphere;
  33369. private _intersectsWithSphere;
  33370. }
  33371. /**
  33372. * Represents a gravitational field event
  33373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33374. */
  33375. class PhysicsGravitationalFieldEvent {
  33376. private _physicsHelper;
  33377. private _scene;
  33378. private _origin;
  33379. private _radius;
  33380. private _strength;
  33381. private _falloff;
  33382. private _tickCallback;
  33383. private _sphere;
  33384. private _dataFetched;
  33385. /**
  33386. * Initializes the physics gravitational field event
  33387. * @param physicsHelper A physics helper
  33388. * @param scene BabylonJS scene
  33389. * @param origin The origin position of the gravitational field event
  33390. * @param radius The radius of the gravitational field event
  33391. * @param strength The strength of the gravitational field event
  33392. * @param falloff The falloff for the gravitational field event
  33393. */
  33394. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  33395. /**
  33396. * Returns the data related to the gravitational field event (sphere).
  33397. * @returns A gravitational field event
  33398. */
  33399. getData(): PhysicsGravitationalFieldEventData;
  33400. /**
  33401. * Enables the gravitational field.
  33402. */
  33403. enable(): void;
  33404. /**
  33405. * Disables the gravitational field.
  33406. */
  33407. disable(): void;
  33408. /**
  33409. * Disposes the sphere.
  33410. * @param force The force to dispose from the gravitational field event
  33411. */
  33412. dispose(force?: boolean): void;
  33413. private _tick;
  33414. }
  33415. /**
  33416. * Represents a physics updraft event
  33417. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33418. */
  33419. class PhysicsUpdraftEvent {
  33420. private _scene;
  33421. private _origin;
  33422. private _radius;
  33423. private _strength;
  33424. private _height;
  33425. private _updraftMode;
  33426. private _physicsEngine;
  33427. private _originTop;
  33428. private _originDirection;
  33429. private _tickCallback;
  33430. private _cylinder;
  33431. private _cylinderPosition;
  33432. private _dataFetched;
  33433. /**
  33434. * Initializes the physics updraft event
  33435. * @param _scene BabylonJS scene
  33436. * @param _origin The origin position of the updraft
  33437. * @param _radius The radius of the updraft
  33438. * @param _strength The strength of the updraft
  33439. * @param _height The height of the updraft
  33440. * @param _updraftMode The mode of the updraft
  33441. */
  33442. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  33443. /**
  33444. * Returns the data related to the updraft event (cylinder).
  33445. * @returns A physics updraft event
  33446. */
  33447. getData(): PhysicsUpdraftEventData;
  33448. /**
  33449. * Enables the updraft.
  33450. */
  33451. enable(): void;
  33452. /**
  33453. * Disables the cortex.
  33454. */
  33455. disable(): void;
  33456. /**
  33457. * Disposes the sphere.
  33458. * @param force Specifies if the updraft should be disposed by force
  33459. */
  33460. dispose(force?: boolean): void;
  33461. private getImpostorForceAndContactPoint;
  33462. private _tick;
  33463. /*** Helpers ***/
  33464. private _prepareCylinder;
  33465. private _intersectsWithCylinder;
  33466. }
  33467. /**
  33468. * Represents a physics vortex event
  33469. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33470. */
  33471. class PhysicsVortexEvent {
  33472. private _scene;
  33473. private _origin;
  33474. private _radius;
  33475. private _strength;
  33476. private _height;
  33477. private _physicsEngine;
  33478. private _originTop;
  33479. private _centripetalForceThreshold;
  33480. private _updraftMultiplier;
  33481. private _tickCallback;
  33482. private _cylinder;
  33483. private _cylinderPosition;
  33484. private _dataFetched;
  33485. /**
  33486. * Initializes the physics vortex event
  33487. * @param _scene The BabylonJS scene
  33488. * @param _origin The origin position of the vortex
  33489. * @param _radius The radius of the vortex
  33490. * @param _strength The strength of the vortex
  33491. * @param _height The height of the vortex
  33492. */
  33493. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  33494. /**
  33495. * Returns the data related to the vortex event (cylinder).
  33496. * @returns The physics vortex event data
  33497. */
  33498. getData(): PhysicsVortexEventData;
  33499. /**
  33500. * Enables the vortex.
  33501. */
  33502. enable(): void;
  33503. /**
  33504. * Disables the cortex.
  33505. */
  33506. disable(): void;
  33507. /**
  33508. * Disposes the sphere.
  33509. * @param force
  33510. */
  33511. dispose(force?: boolean): void;
  33512. private getImpostorForceAndContactPoint;
  33513. private _tick;
  33514. /*** Helpers ***/
  33515. private _prepareCylinder;
  33516. private _intersectsWithCylinder;
  33517. }
  33518. /**
  33519. * The strenght of the force in correspondence to the distance of the affected object
  33520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33521. */
  33522. enum PhysicsRadialImpulseFalloff {
  33523. /** Defines that impulse is constant in strength across it's whole radius */
  33524. Constant = 0,
  33525. /** DEfines that impulse gets weaker if it's further from the origin */
  33526. Linear = 1
  33527. }
  33528. /**
  33529. * The strength of the force in correspondence to the distance of the affected object
  33530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33531. */
  33532. enum PhysicsUpdraftMode {
  33533. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  33534. Center = 0,
  33535. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  33536. Perpendicular = 1
  33537. }
  33538. /**
  33539. * Interface for a physics force and contact point
  33540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33541. */
  33542. interface PhysicsForceAndContactPoint {
  33543. /**
  33544. * The force applied at the contact point
  33545. */
  33546. force: Vector3;
  33547. /**
  33548. * The contact point
  33549. */
  33550. contactPoint: Vector3;
  33551. }
  33552. /**
  33553. * Interface for radial explosion event data
  33554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33555. */
  33556. interface PhysicsRadialExplosionEventData {
  33557. /**
  33558. * A sphere used for the radial explosion event
  33559. */
  33560. sphere: Mesh;
  33561. /**
  33562. * An array of rays for the radial explosion event
  33563. */
  33564. rays: Array<Ray>;
  33565. }
  33566. /**
  33567. * Interface for gravitational field event data
  33568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33569. */
  33570. interface PhysicsGravitationalFieldEventData {
  33571. /**
  33572. * A sphere mesh used for the gravitational field event
  33573. */
  33574. sphere: Mesh;
  33575. }
  33576. /**
  33577. * Interface for updraft event data
  33578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33579. */
  33580. interface PhysicsUpdraftEventData {
  33581. /**
  33582. * A cylinder used for the updraft event
  33583. */
  33584. cylinder: Mesh;
  33585. }
  33586. /**
  33587. * Interface for vortex event data
  33588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33589. */
  33590. interface PhysicsVortexEventData {
  33591. /**
  33592. * A cylinder used for the vortex event
  33593. */
  33594. cylinder: Mesh;
  33595. }
  33596. }
  33597. declare module BABYLON {
  33598. /**
  33599. * The interface for the physics imposter parameters
  33600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33601. */
  33602. interface PhysicsImpostorParameters {
  33603. /**
  33604. * The mass of the physics imposter
  33605. */
  33606. mass: number;
  33607. /**
  33608. * The friction of the physics imposter
  33609. */
  33610. friction?: number;
  33611. /**
  33612. * The coefficient of restitution of the physics imposter
  33613. */
  33614. restitution?: number;
  33615. /**
  33616. * The native options of the physics imposter
  33617. */
  33618. nativeOptions?: any;
  33619. /**
  33620. * Specifies if the parent should be ignored
  33621. */
  33622. ignoreParent?: boolean;
  33623. /**
  33624. * Specifies if bi-directional transformations should be disabled
  33625. */
  33626. disableBidirectionalTransformation?: boolean;
  33627. }
  33628. /**
  33629. * Interface for a physics-enabled object
  33630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33631. */
  33632. interface IPhysicsEnabledObject {
  33633. /**
  33634. * The position of the physics-enabled object
  33635. */
  33636. position: Vector3;
  33637. /**
  33638. * The rotation of the physics-enabled object
  33639. */
  33640. rotationQuaternion: Nullable<Quaternion>;
  33641. /**
  33642. * The scale of the physics-enabled object
  33643. */
  33644. scaling: Vector3;
  33645. /**
  33646. * The rotation of the physics-enabled object
  33647. */
  33648. rotation?: Vector3;
  33649. /**
  33650. * The parent of the physics-enabled object
  33651. */
  33652. parent?: any;
  33653. /**
  33654. * The bounding info of the physics-enabled object
  33655. * @returns The bounding info of the physics-enabled object
  33656. */
  33657. getBoundingInfo(): BoundingInfo;
  33658. /**
  33659. * Computes the world matrix
  33660. * @param force Specifies if the world matrix should be computed by force
  33661. * @returns A world matrix
  33662. */
  33663. computeWorldMatrix(force: boolean): Matrix;
  33664. /**
  33665. * Gets the world matrix
  33666. * @returns A world matrix
  33667. */
  33668. getWorldMatrix?(): Matrix;
  33669. /**
  33670. * Gets the child meshes
  33671. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33672. * @returns An array of abstract meshes
  33673. */
  33674. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33675. /**
  33676. * Gets the vertex data
  33677. * @param kind The type of vertex data
  33678. * @returns A nullable array of numbers, or a float32 array
  33679. */
  33680. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33681. /**
  33682. * Gets the indices from the mesh
  33683. * @returns A nullable array of index arrays
  33684. */
  33685. getIndices?(): Nullable<IndicesArray>;
  33686. /**
  33687. * Gets the scene from the mesh
  33688. * @returns the indices array or null
  33689. */
  33690. getScene?(): Scene;
  33691. /**
  33692. * Gets the absolute position from the mesh
  33693. * @returns the absolute position
  33694. */
  33695. getAbsolutePosition(): Vector3;
  33696. /**
  33697. * Gets the absolute pivot point from the mesh
  33698. * @returns the absolute pivot point
  33699. */
  33700. getAbsolutePivotPoint(): Vector3;
  33701. /**
  33702. * Rotates the mesh
  33703. * @param axis The axis of rotation
  33704. * @param amount The amount of rotation
  33705. * @param space The space of the rotation
  33706. * @returns The rotation transform node
  33707. */
  33708. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33709. /**
  33710. * Translates the mesh
  33711. * @param axis The axis of translation
  33712. * @param distance The distance of translation
  33713. * @param space The space of the translation
  33714. * @returns The transform node
  33715. */
  33716. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33717. /**
  33718. * Sets the absolute position of the mesh
  33719. * @param absolutePosition The absolute position of the mesh
  33720. * @returns The transform node
  33721. */
  33722. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33723. /**
  33724. * Gets the class name of the mesh
  33725. * @returns The class name
  33726. */
  33727. getClassName(): string;
  33728. }
  33729. /**
  33730. * Represents a physics imposter
  33731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33732. */
  33733. class PhysicsImpostor {
  33734. /**
  33735. * The physics-enabled object used as the physics imposter
  33736. */
  33737. object: IPhysicsEnabledObject;
  33738. /**
  33739. * The type of the physics imposter
  33740. */
  33741. type: number;
  33742. private _options;
  33743. private _scene?;
  33744. /**
  33745. * The default object size of the imposter
  33746. */
  33747. static DEFAULT_OBJECT_SIZE: Vector3;
  33748. /**
  33749. * The identity quaternion of the imposter
  33750. */
  33751. static IDENTITY_QUATERNION: Quaternion;
  33752. private _physicsEngine;
  33753. private _physicsBody;
  33754. private _bodyUpdateRequired;
  33755. private _onBeforePhysicsStepCallbacks;
  33756. private _onAfterPhysicsStepCallbacks;
  33757. private _onPhysicsCollideCallbacks;
  33758. private _deltaPosition;
  33759. private _deltaRotation;
  33760. private _deltaRotationConjugated;
  33761. private _parent;
  33762. private _isDisposed;
  33763. private static _tmpVecs;
  33764. private static _tmpQuat;
  33765. /**
  33766. * Specifies if the physics imposter is disposed
  33767. */
  33768. readonly isDisposed: boolean;
  33769. /**
  33770. * Gets the mass of the physics imposter
  33771. */
  33772. mass: number;
  33773. /**
  33774. * Gets the coefficient of friction
  33775. */
  33776. /**
  33777. * Sets the coefficient of friction
  33778. */
  33779. friction: number;
  33780. /**
  33781. * Gets the coefficient of restitution
  33782. */
  33783. /**
  33784. * Sets the coefficient of restitution
  33785. */
  33786. restitution: number;
  33787. /**
  33788. * The unique id of the physics imposter
  33789. * set by the physics engine when adding this impostor to the array
  33790. */
  33791. uniqueId: number;
  33792. private _joints;
  33793. /**
  33794. * Initializes the physics imposter
  33795. * @param object The physics-enabled object used as the physics imposter
  33796. * @param type The type of the physics imposter
  33797. * @param _options The options for the physics imposter
  33798. * @param _scene The Babylon scene
  33799. */
  33800. constructor(
  33801. /**
  33802. * The physics-enabled object used as the physics imposter
  33803. */
  33804. object: IPhysicsEnabledObject,
  33805. /**
  33806. * The type of the physics imposter
  33807. */
  33808. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33809. /**
  33810. * This function will completly initialize this impostor.
  33811. * It will create a new body - but only if this mesh has no parent.
  33812. * If it has, this impostor will not be used other than to define the impostor
  33813. * of the child mesh.
  33814. * @hidden
  33815. */
  33816. _init(): void;
  33817. private _getPhysicsParent;
  33818. /**
  33819. * Should a new body be generated.
  33820. * @returns boolean specifying if body initialization is required
  33821. */
  33822. isBodyInitRequired(): boolean;
  33823. /**
  33824. * Sets the updated scaling
  33825. * @param updated Specifies if the scaling is updated
  33826. */
  33827. setScalingUpdated(updated: boolean): void;
  33828. /**
  33829. * Force a regeneration of this or the parent's impostor's body.
  33830. * Use under cautious - This will remove all joints already implemented.
  33831. */
  33832. forceUpdate(): void;
  33833. /**
  33834. * Gets the body that holds this impostor. Either its own, or its parent.
  33835. */
  33836. /**
  33837. * Set the physics body. Used mainly by the physics engine/plugin
  33838. */
  33839. physicsBody: any;
  33840. /**
  33841. * Get the parent of the physics imposter
  33842. * @returns Physics imposter or null
  33843. */
  33844. /**
  33845. * Sets the parent of the physics imposter
  33846. */
  33847. parent: Nullable<PhysicsImpostor>;
  33848. /**
  33849. * Resets the update flags
  33850. */
  33851. resetUpdateFlags(): void;
  33852. /**
  33853. * Gets the object extend size
  33854. * @returns the object extend size
  33855. */
  33856. getObjectExtendSize(): Vector3;
  33857. /**
  33858. * Gets the object center
  33859. * @returns The object center
  33860. */
  33861. getObjectCenter(): Vector3;
  33862. /**
  33863. * Get a specific parametes from the options parameter
  33864. * @param paramName The object parameter name
  33865. * @returns The object parameter
  33866. */
  33867. getParam(paramName: string): any;
  33868. /**
  33869. * Sets a specific parameter in the options given to the physics plugin
  33870. * @param paramName The parameter name
  33871. * @param value The value of the parameter
  33872. */
  33873. setParam(paramName: string, value: number): void;
  33874. /**
  33875. * Specifically change the body's mass option. Won't recreate the physics body object
  33876. * @param mass The mass of the physics imposter
  33877. */
  33878. setMass(mass: number): void;
  33879. /**
  33880. * Gets the linear velocity
  33881. * @returns linear velocity or null
  33882. */
  33883. getLinearVelocity(): Nullable<Vector3>;
  33884. /**
  33885. * Sets the linear velocity
  33886. * @param velocity linear velocity or null
  33887. */
  33888. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33889. /**
  33890. * Gets the angular velocity
  33891. * @returns angular velocity or null
  33892. */
  33893. getAngularVelocity(): Nullable<Vector3>;
  33894. /**
  33895. * Sets the angular velocity
  33896. * @param velocity The velocity or null
  33897. */
  33898. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33899. /**
  33900. * Execute a function with the physics plugin native code
  33901. * Provide a function the will have two variables - the world object and the physics body object
  33902. * @param func The function to execute with the physics plugin native code
  33903. */
  33904. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33905. /**
  33906. * Register a function that will be executed before the physics world is stepping forward
  33907. * @param func The function to execute before the physics world is stepped forward
  33908. */
  33909. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33910. /**
  33911. * Unregister a function that will be executed before the physics world is stepping forward
  33912. * @param func The function to execute before the physics world is stepped forward
  33913. */
  33914. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33915. /**
  33916. * Register a function that will be executed after the physics step
  33917. * @param func The function to execute after physics step
  33918. */
  33919. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33920. /**
  33921. * Unregisters a function that will be executed after the physics step
  33922. * @param func The function to execute after physics step
  33923. */
  33924. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33925. /**
  33926. * register a function that will be executed when this impostor collides against a different body
  33927. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33928. * @param func Callback that is executed on collision
  33929. */
  33930. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33931. /**
  33932. * Unregisters the physics imposter on contact
  33933. * @param collideAgainst The physics object to collide against
  33934. * @param func Callback to execute on collision
  33935. */
  33936. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33937. private _tmpQuat;
  33938. private _tmpQuat2;
  33939. /**
  33940. * Get the parent rotation
  33941. * @returns The parent rotation
  33942. */
  33943. getParentsRotation(): Quaternion;
  33944. /**
  33945. * this function is executed by the physics engine.
  33946. */
  33947. beforeStep: () => void;
  33948. /**
  33949. * this function is executed by the physics engine
  33950. */
  33951. afterStep: () => void;
  33952. /**
  33953. * Legacy collision detection event support
  33954. */
  33955. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33956. /**
  33957. * event and body object due to cannon's event-based architecture.
  33958. */
  33959. onCollide: (e: {
  33960. body: any;
  33961. }) => void;
  33962. /**
  33963. * Apply a force
  33964. * @param force The force to apply
  33965. * @param contactPoint The contact point for the force
  33966. * @returns The physics imposter
  33967. */
  33968. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33969. /**
  33970. * Apply an impulse
  33971. * @param force The impulse force
  33972. * @param contactPoint The contact point for the impulse force
  33973. * @returns The physics imposter
  33974. */
  33975. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33976. /**
  33977. * A help function to create a joint
  33978. * @param otherImpostor A physics imposter used to create a joint
  33979. * @param jointType The type of joint
  33980. * @param jointData The data for the joint
  33981. * @returns The physics imposter
  33982. */
  33983. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33984. /**
  33985. * Add a joint to this impostor with a different impostor
  33986. * @param otherImpostor A physics imposter used to add a joint
  33987. * @param joint The joint to add
  33988. * @returns The physics imposter
  33989. */
  33990. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33991. /**
  33992. * Will keep this body still, in a sleep mode.
  33993. * @returns the physics imposter
  33994. */
  33995. sleep(): PhysicsImpostor;
  33996. /**
  33997. * Wake the body up.
  33998. * @returns The physics imposter
  33999. */
  34000. wakeUp(): PhysicsImpostor;
  34001. /**
  34002. * Clones the physics imposter
  34003. * @param newObject The physics imposter clones to this physics-enabled object
  34004. * @returns A nullable physics imposter
  34005. */
  34006. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  34007. /**
  34008. * Disposes the physics imposter
  34009. */
  34010. dispose(): void;
  34011. /**
  34012. * Sets the delta position
  34013. * @param position The delta position amount
  34014. */
  34015. setDeltaPosition(position: Vector3): void;
  34016. /**
  34017. * Sets the delta rotation
  34018. * @param rotation The delta rotation amount
  34019. */
  34020. setDeltaRotation(rotation: Quaternion): void;
  34021. /**
  34022. * Gets the box size of the physics imposter and stores the result in the input parameter
  34023. * @param result Stores the box size
  34024. * @returns The physics imposter
  34025. */
  34026. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  34027. /**
  34028. * Gets the radius of the physics imposter
  34029. * @returns Radius of the physics imposter
  34030. */
  34031. getRadius(): number;
  34032. /**
  34033. * Sync a bone with this impostor
  34034. * @param bone The bone to sync to the impostor.
  34035. * @param boneMesh The mesh that the bone is influencing.
  34036. * @param jointPivot The pivot of the joint / bone in local space.
  34037. * @param distToJoint Optional distance from the impostor to the joint.
  34038. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34039. */
  34040. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  34041. /**
  34042. * Sync impostor to a bone
  34043. * @param bone The bone that the impostor will be synced to.
  34044. * @param boneMesh The mesh that the bone is influencing.
  34045. * @param jointPivot The pivot of the joint / bone in local space.
  34046. * @param distToJoint Optional distance from the impostor to the joint.
  34047. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34048. * @param boneAxis Optional vector3 axis the bone is aligned with
  34049. */
  34050. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  34051. /**
  34052. * No-Imposter type
  34053. */
  34054. static NoImpostor: number;
  34055. /**
  34056. * Sphere-Imposter type
  34057. */
  34058. static SphereImpostor: number;
  34059. /**
  34060. * Box-Imposter type
  34061. */
  34062. static BoxImpostor: number;
  34063. /**
  34064. * Plane-Imposter type
  34065. */
  34066. static PlaneImpostor: number;
  34067. /**
  34068. * Mesh-imposter type
  34069. */
  34070. static MeshImpostor: number;
  34071. /**
  34072. * Cylinder-Imposter type
  34073. */
  34074. static CylinderImpostor: number;
  34075. /**
  34076. * Particle-Imposter type
  34077. */
  34078. static ParticleImpostor: number;
  34079. /**
  34080. * Heightmap-Imposter type
  34081. */
  34082. static HeightmapImpostor: number;
  34083. }
  34084. }
  34085. declare module BABYLON {
  34086. /**
  34087. * Interface for Physics-Joint data
  34088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34089. */
  34090. interface PhysicsJointData {
  34091. /**
  34092. * The main pivot of the joint
  34093. */
  34094. mainPivot?: Vector3;
  34095. /**
  34096. * The connected pivot of the joint
  34097. */
  34098. connectedPivot?: Vector3;
  34099. /**
  34100. * The main axis of the joint
  34101. */
  34102. mainAxis?: Vector3;
  34103. /**
  34104. * The connected axis of the joint
  34105. */
  34106. connectedAxis?: Vector3;
  34107. /**
  34108. * The collision of the joint
  34109. */
  34110. collision?: boolean;
  34111. /**
  34112. * Native Oimo/Cannon/Energy data
  34113. */
  34114. nativeParams?: any;
  34115. }
  34116. /**
  34117. * This is a holder class for the physics joint created by the physics plugin
  34118. * It holds a set of functions to control the underlying joint
  34119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34120. */
  34121. class PhysicsJoint {
  34122. /**
  34123. * The type of the physics joint
  34124. */
  34125. type: number;
  34126. /**
  34127. * The data for the physics joint
  34128. */
  34129. jointData: PhysicsJointData;
  34130. private _physicsJoint;
  34131. protected _physicsPlugin: IPhysicsEnginePlugin;
  34132. /**
  34133. * Initializes the physics joint
  34134. * @param type The type of the physics joint
  34135. * @param jointData The data for the physics joint
  34136. */
  34137. constructor(
  34138. /**
  34139. * The type of the physics joint
  34140. */
  34141. type: number,
  34142. /**
  34143. * The data for the physics joint
  34144. */
  34145. jointData: PhysicsJointData);
  34146. /**
  34147. * Gets the physics joint
  34148. */
  34149. /**
  34150. * Sets the physics joint
  34151. */
  34152. physicsJoint: any;
  34153. /**
  34154. * Sets the physics plugin
  34155. */
  34156. physicsPlugin: IPhysicsEnginePlugin;
  34157. /**
  34158. * Execute a function that is physics-plugin specific.
  34159. * @param {Function} func the function that will be executed.
  34160. * It accepts two parameters: the physics world and the physics joint
  34161. */
  34162. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  34163. /**
  34164. * Distance-Joint type
  34165. */
  34166. static DistanceJoint: number;
  34167. /**
  34168. * Hinge-Joint type
  34169. */
  34170. static HingeJoint: number;
  34171. /**
  34172. * Ball-and-Socket joint type
  34173. */
  34174. static BallAndSocketJoint: number;
  34175. /**
  34176. * Wheel-Joint type
  34177. */
  34178. static WheelJoint: number;
  34179. /**
  34180. * Slider-Joint type
  34181. */
  34182. static SliderJoint: number;
  34183. /**
  34184. * Prismatic-Joint type
  34185. */
  34186. static PrismaticJoint: number;
  34187. /**
  34188. * Universal-Joint type
  34189. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  34190. */
  34191. static UniversalJoint: number;
  34192. /**
  34193. * Hinge-Joint 2 type
  34194. */
  34195. static Hinge2Joint: number;
  34196. /**
  34197. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  34198. */
  34199. static PointToPointJoint: number;
  34200. /**
  34201. * Spring-Joint type
  34202. */
  34203. static SpringJoint: number;
  34204. /**
  34205. * Lock-Joint type
  34206. */
  34207. static LockJoint: number;
  34208. }
  34209. /**
  34210. * A class representing a physics distance joint
  34211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34212. */
  34213. class DistanceJoint extends PhysicsJoint {
  34214. /**
  34215. *
  34216. * @param jointData The data for the Distance-Joint
  34217. */
  34218. constructor(jointData: DistanceJointData);
  34219. /**
  34220. * Update the predefined distance.
  34221. * @param maxDistance The maximum preferred distance
  34222. * @param minDistance The minimum preferred distance
  34223. */
  34224. updateDistance(maxDistance: number, minDistance?: number): void;
  34225. }
  34226. /**
  34227. * Represents a Motor-Enabled Joint
  34228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34229. */
  34230. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  34231. /**
  34232. * Initializes the Motor-Enabled Joint
  34233. * @param type The type of the joint
  34234. * @param jointData The physica joint data for the joint
  34235. */
  34236. constructor(type: number, jointData: PhysicsJointData);
  34237. /**
  34238. * Set the motor values.
  34239. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34240. * @param force the force to apply
  34241. * @param maxForce max force for this motor.
  34242. */
  34243. setMotor(force?: number, maxForce?: number): void;
  34244. /**
  34245. * Set the motor's limits.
  34246. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34247. * @param upperLimit The upper limit of the motor
  34248. * @param lowerLimit The lower limit of the motor
  34249. */
  34250. setLimit(upperLimit: number, lowerLimit?: number): void;
  34251. }
  34252. /**
  34253. * This class represents a single physics Hinge-Joint
  34254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34255. */
  34256. class HingeJoint extends MotorEnabledJoint {
  34257. /**
  34258. * Initializes the Hinge-Joint
  34259. * @param jointData The joint data for the Hinge-Joint
  34260. */
  34261. constructor(jointData: PhysicsJointData);
  34262. /**
  34263. * Set the motor values.
  34264. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34265. * @param {number} force the force to apply
  34266. * @param {number} maxForce max force for this motor.
  34267. */
  34268. setMotor(force?: number, maxForce?: number): void;
  34269. /**
  34270. * Set the motor's limits.
  34271. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34272. * @param upperLimit The upper limit of the motor
  34273. * @param lowerLimit The lower limit of the motor
  34274. */
  34275. setLimit(upperLimit: number, lowerLimit?: number): void;
  34276. }
  34277. /**
  34278. * This class represents a dual hinge physics joint (same as wheel joint)
  34279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34280. */
  34281. class Hinge2Joint extends MotorEnabledJoint {
  34282. /**
  34283. * Initializes the Hinge2-Joint
  34284. * @param jointData The joint data for the Hinge2-Joint
  34285. */
  34286. constructor(jointData: PhysicsJointData);
  34287. /**
  34288. * Set the motor values.
  34289. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34290. * @param {number} force the force to apply
  34291. * @param {number} maxForce max force for this motor.
  34292. * @param {motorIndex} the motor's index, 0 or 1.
  34293. */
  34294. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34295. /**
  34296. * Set the motor limits.
  34297. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34298. * @param {number} upperLimit the upper limit
  34299. * @param {number} lowerLimit lower limit
  34300. * @param {motorIndex} the motor's index, 0 or 1.
  34301. */
  34302. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34303. }
  34304. /**
  34305. * Interface for a motor enabled joint
  34306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34307. */
  34308. interface IMotorEnabledJoint {
  34309. /**
  34310. * Physics joint
  34311. */
  34312. physicsJoint: any;
  34313. /**
  34314. * Sets the motor of the motor-enabled joint
  34315. * @param force The force of the motor
  34316. * @param maxForce The maximum force of the motor
  34317. * @param motorIndex The index of the motor
  34318. */
  34319. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34320. /**
  34321. * Sets the limit of the motor
  34322. * @param upperLimit The upper limit of the motor
  34323. * @param lowerLimit The lower limit of the motor
  34324. * @param motorIndex The index of the motor
  34325. */
  34326. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34327. }
  34328. /**
  34329. * Joint data for a Distance-Joint
  34330. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34331. */
  34332. interface DistanceJointData extends PhysicsJointData {
  34333. /**
  34334. * Max distance the 2 joint objects can be apart
  34335. */
  34336. maxDistance: number;
  34337. }
  34338. /**
  34339. * Joint data from a spring joint
  34340. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34341. */
  34342. interface SpringJointData extends PhysicsJointData {
  34343. /**
  34344. * Length of the spring
  34345. */
  34346. length: number;
  34347. /**
  34348. * Stiffness of the spring
  34349. */
  34350. stiffness: number;
  34351. /**
  34352. * Damping of the spring
  34353. */
  34354. damping: number;
  34355. /** this callback will be called when applying the force to the impostors. */
  34356. forceApplicationCallback: () => void;
  34357. }
  34358. }
  34359. declare module BABYLON {
  34360. interface AbstractScene {
  34361. /**
  34362. * The list of reflection probes added to the scene
  34363. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34364. */
  34365. reflectionProbes: Array<ReflectionProbe>;
  34366. /**
  34367. * Removes the given reflection probe from this scene.
  34368. * @param toRemove The reflection probe to remove
  34369. * @returns The index of the removed reflection probe
  34370. */
  34371. removeReflectionProbe(toRemove: ReflectionProbe): number;
  34372. /**
  34373. * Adds the given reflection probe to this scene.
  34374. * @param newReflectionProbe The reflection probe to add
  34375. */
  34376. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  34377. }
  34378. /**
  34379. * Class used to generate realtime reflection / refraction cube textures
  34380. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34381. */
  34382. class ReflectionProbe {
  34383. /** defines the name of the probe */
  34384. name: string;
  34385. private _scene;
  34386. private _renderTargetTexture;
  34387. private _projectionMatrix;
  34388. private _viewMatrix;
  34389. private _target;
  34390. private _add;
  34391. private _attachedMesh;
  34392. private _invertYAxis;
  34393. /** Gets or sets probe position (center of the cube map) */
  34394. position: Vector3;
  34395. /**
  34396. * Creates a new reflection probe
  34397. * @param name defines the name of the probe
  34398. * @param size defines the texture resolution (for each face)
  34399. * @param scene defines the hosting scene
  34400. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  34401. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  34402. */
  34403. constructor(
  34404. /** defines the name of the probe */
  34405. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  34406. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  34407. samples: number;
  34408. /** Gets or sets the refresh rate to use (on every frame by default) */
  34409. refreshRate: number;
  34410. /**
  34411. * Gets the hosting scene
  34412. * @returns a Scene
  34413. */
  34414. getScene(): Scene;
  34415. /** Gets the internal CubeTexture used to render to */
  34416. readonly cubeTexture: RenderTargetTexture;
  34417. /** Gets the list of meshes to render */
  34418. readonly renderList: Nullable<AbstractMesh[]>;
  34419. /**
  34420. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  34421. * @param mesh defines the mesh to attach to
  34422. */
  34423. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  34424. /**
  34425. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  34426. * @param renderingGroupId The rendering group id corresponding to its index
  34427. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34428. */
  34429. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34430. /**
  34431. * Clean all associated resources
  34432. */
  34433. dispose(): void;
  34434. /**
  34435. * Converts the reflection probe information to a readable string for debug purpose.
  34436. * @param fullDetails Supports for multiple levels of logging within scene loading
  34437. * @returns the human readable reflection probe info
  34438. */
  34439. toString(fullDetails?: boolean): string;
  34440. /**
  34441. * Get the class name of the relfection probe.
  34442. * @returns "ReflectionProbe"
  34443. */
  34444. getClassName(): string;
  34445. /**
  34446. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  34447. * @returns The JSON representation of the texture
  34448. */
  34449. serialize(): any;
  34450. /**
  34451. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  34452. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  34453. * @param scene Define the scene the parsed reflection probe should be instantiated in
  34454. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  34455. * @returns The parsed reflection probe if successful
  34456. */
  34457. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  34458. }
  34459. }
  34460. declare module BABYLON {
  34461. interface Scene {
  34462. /** @hidden (Backing field) */
  34463. _boundingBoxRenderer: BoundingBoxRenderer;
  34464. /** @hidden (Backing field) */
  34465. _forceShowBoundingBoxes: boolean;
  34466. /**
  34467. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  34468. */
  34469. forceShowBoundingBoxes: boolean;
  34470. /**
  34471. * Gets the bounding box renderer associated with the scene
  34472. * @returns a BoundingBoxRenderer
  34473. */
  34474. getBoundingBoxRenderer(): BoundingBoxRenderer;
  34475. }
  34476. interface AbstractMesh {
  34477. /** @hidden (Backing field) */
  34478. _showBoundingBox: boolean;
  34479. /**
  34480. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  34481. */
  34482. showBoundingBox: boolean;
  34483. }
  34484. /**
  34485. * Component responsible of rendering the bounding box of the meshes in a scene.
  34486. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  34487. */
  34488. class BoundingBoxRenderer implements ISceneComponent {
  34489. /**
  34490. * The component name helpfull to identify the component in the list of scene components.
  34491. */
  34492. readonly name: string;
  34493. /**
  34494. * The scene the component belongs to.
  34495. */
  34496. scene: Scene;
  34497. /**
  34498. * Color of the bounding box lines placed in front of an object
  34499. */
  34500. frontColor: Color3;
  34501. /**
  34502. * Color of the bounding box lines placed behind an object
  34503. */
  34504. backColor: Color3;
  34505. /**
  34506. * Defines if the renderer should show the back lines or not
  34507. */
  34508. showBackLines: boolean;
  34509. /**
  34510. * @hidden
  34511. */
  34512. renderList: SmartArray<BoundingBox>;
  34513. private _colorShader;
  34514. private _vertexBuffers;
  34515. private _indexBuffer;
  34516. /**
  34517. * Instantiates a new bounding box renderer in a scene.
  34518. * @param scene the scene the renderer renders in
  34519. */
  34520. constructor(scene: Scene);
  34521. /**
  34522. * Registers the component in a given scene
  34523. */
  34524. register(): void;
  34525. private _evaluateSubMesh;
  34526. private _activeMesh;
  34527. private _prepareRessources;
  34528. private _createIndexBuffer;
  34529. /**
  34530. * Rebuilds the elements related to this component in case of
  34531. * context lost for instance.
  34532. */
  34533. rebuild(): void;
  34534. /**
  34535. * @hidden
  34536. */
  34537. reset(): void;
  34538. /**
  34539. * Render the bounding boxes of a specific rendering group
  34540. * @param renderingGroupId defines the rendering group to render
  34541. */
  34542. render(renderingGroupId: number): void;
  34543. /**
  34544. * In case of occlusion queries, we can render the occlusion bounding box through this method
  34545. * @param mesh Define the mesh to render the occlusion bounding box for
  34546. */
  34547. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  34548. /**
  34549. * Dispose and release the resources attached to this renderer.
  34550. */
  34551. dispose(): void;
  34552. }
  34553. }
  34554. declare module BABYLON {
  34555. /**
  34556. * This represents a depth renderer in Babylon.
  34557. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  34558. */
  34559. class DepthRenderer {
  34560. private _scene;
  34561. private _depthMap;
  34562. private _effect;
  34563. private _cachedDefines;
  34564. private _camera;
  34565. /**
  34566. * Specifiess that the depth renderer will only be used within
  34567. * the camera it is created for.
  34568. * This can help forcing its rendering during the camera processing.
  34569. */
  34570. useOnlyInActiveCamera: boolean;
  34571. /**
  34572. * Instantiates a depth renderer
  34573. * @param scene The scene the renderer belongs to
  34574. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  34575. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  34576. */
  34577. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  34578. /**
  34579. * Creates the depth rendering effect and checks if the effect is ready.
  34580. * @param subMesh The submesh to be used to render the depth map of
  34581. * @param useInstances If multiple world instances should be used
  34582. * @returns if the depth renderer is ready to render the depth map
  34583. */
  34584. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34585. /**
  34586. * Gets the texture which the depth map will be written to.
  34587. * @returns The depth map texture
  34588. */
  34589. getDepthMap(): RenderTargetTexture;
  34590. /**
  34591. * Disposes of the depth renderer.
  34592. */
  34593. dispose(): void;
  34594. }
  34595. }
  34596. declare module BABYLON {
  34597. interface Scene {
  34598. /** @hidden (Backing field) */
  34599. _depthRenderer: {
  34600. [id: string]: DepthRenderer;
  34601. };
  34602. /**
  34603. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  34604. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  34605. * @returns the created depth renderer
  34606. */
  34607. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  34608. /**
  34609. * Disables a depth renderer for a given camera
  34610. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  34611. */
  34612. disableDepthRenderer(camera?: Nullable<Camera>): void;
  34613. }
  34614. /**
  34615. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  34616. * in several rendering techniques.
  34617. */
  34618. class DepthRendererSceneComponent implements ISceneComponent {
  34619. /**
  34620. * The component name helpfull to identify the component in the list of scene components.
  34621. */
  34622. readonly name: string;
  34623. /**
  34624. * The scene the component belongs to.
  34625. */
  34626. scene: Scene;
  34627. /**
  34628. * Creates a new instance of the component for the given scene
  34629. * @param scene Defines the scene to register the component in
  34630. */
  34631. constructor(scene: Scene);
  34632. /**
  34633. * Registers the component in a given scene
  34634. */
  34635. register(): void;
  34636. /**
  34637. * Rebuilds the elements related to this component in case of
  34638. * context lost for instance.
  34639. */
  34640. rebuild(): void;
  34641. /**
  34642. * Disposes the component and the associated ressources
  34643. */
  34644. dispose(): void;
  34645. private _gatherRenderTargets;
  34646. private _gatherActiveCameraRenderTargets;
  34647. }
  34648. }
  34649. declare module BABYLON {
  34650. interface AbstractMesh {
  34651. /**
  34652. * Disables the mesh edge rendering mode
  34653. * @returns the currentAbstractMesh
  34654. */
  34655. disableEdgesRendering(): AbstractMesh;
  34656. /**
  34657. * Enables the edge rendering mode on the mesh.
  34658. * This mode makes the mesh edges visible
  34659. * @param epsilon defines the maximal distance between two angles to detect a face
  34660. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34661. * @returns the currentAbstractMesh
  34662. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34663. */
  34664. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34665. /**
  34666. * Gets the edgesRenderer associated with the mesh
  34667. */
  34668. edgesRenderer: Nullable<EdgesRenderer>;
  34669. }
  34670. interface LinesMesh {
  34671. /**
  34672. * Enables the edge rendering mode on the mesh.
  34673. * This mode makes the mesh edges visible
  34674. * @param epsilon defines the maximal distance between two angles to detect a face
  34675. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34676. * @returns the currentAbstractMesh
  34677. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34678. */
  34679. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34680. }
  34681. interface InstancedLinesMesh {
  34682. /**
  34683. * Enables the edge rendering mode on the mesh.
  34684. * This mode makes the mesh edges visible
  34685. * @param epsilon defines the maximal distance between two angles to detect a face
  34686. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34687. * @returns the current InstancedLinesMesh
  34688. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34689. */
  34690. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  34691. }
  34692. /**
  34693. * Defines the minimum contract an Edges renderer should follow.
  34694. */
  34695. interface IEdgesRenderer extends IDisposable {
  34696. /**
  34697. * Gets or sets a boolean indicating if the edgesRenderer is active
  34698. */
  34699. isEnabled: boolean;
  34700. /**
  34701. * Renders the edges of the attached mesh,
  34702. */
  34703. render(): void;
  34704. /**
  34705. * Checks wether or not the edges renderer is ready to render.
  34706. * @return true if ready, otherwise false.
  34707. */
  34708. isReady(): boolean;
  34709. }
  34710. /**
  34711. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  34712. */
  34713. class EdgesRenderer implements IEdgesRenderer {
  34714. /**
  34715. * Define the size of the edges with an orthographic camera
  34716. */
  34717. edgesWidthScalerForOrthographic: number;
  34718. /**
  34719. * Define the size of the edges with a perspective camera
  34720. */
  34721. edgesWidthScalerForPerspective: number;
  34722. protected _source: AbstractMesh;
  34723. protected _linesPositions: number[];
  34724. protected _linesNormals: number[];
  34725. protected _linesIndices: number[];
  34726. protected _epsilon: number;
  34727. protected _indicesCount: number;
  34728. protected _lineShader: ShaderMaterial;
  34729. protected _ib: WebGLBuffer;
  34730. protected _buffers: {
  34731. [key: string]: Nullable<VertexBuffer>;
  34732. };
  34733. protected _checkVerticesInsteadOfIndices: boolean;
  34734. private _meshRebuildObserver;
  34735. private _meshDisposeObserver;
  34736. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  34737. isEnabled: boolean;
  34738. /**
  34739. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  34740. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  34741. * @param source Mesh used to create edges
  34742. * @param epsilon sum of angles in adjacency to check for edge
  34743. * @param checkVerticesInsteadOfIndices
  34744. * @param generateEdgesLines - should generate Lines or only prepare resources.
  34745. */
  34746. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  34747. protected _prepareRessources(): void;
  34748. /** @hidden */
  34749. _rebuild(): void;
  34750. /**
  34751. * Releases the required resources for the edges renderer
  34752. */
  34753. dispose(): void;
  34754. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  34755. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  34756. /**
  34757. * Checks if the pair of p0 and p1 is en edge
  34758. * @param faceIndex
  34759. * @param edge
  34760. * @param faceNormals
  34761. * @param p0
  34762. * @param p1
  34763. * @private
  34764. */
  34765. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  34766. /**
  34767. * push line into the position, normal and index buffer
  34768. * @protected
  34769. */
  34770. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  34771. /**
  34772. * Generates lines edges from adjacencjes
  34773. * @private
  34774. */
  34775. _generateEdgesLines(): void;
  34776. /**
  34777. * Checks wether or not the edges renderer is ready to render.
  34778. * @return true if ready, otherwise false.
  34779. */
  34780. isReady(): boolean;
  34781. /**
  34782. * Renders the edges of the attached mesh,
  34783. */
  34784. render(): void;
  34785. }
  34786. }
  34787. declare module BABYLON {
  34788. /**
  34789. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  34790. */
  34791. class GeometryBufferRenderer {
  34792. /**
  34793. * Constant used to retrieve the position texture index in the G-Buffer textures array
  34794. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  34795. */
  34796. static readonly POSITION_TEXTURE_TYPE: number;
  34797. /**
  34798. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  34799. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  34800. */
  34801. static readonly VELOCITY_TEXTURE_TYPE: number;
  34802. /**
  34803. * Dictionary used to store the previous transformation matrices of each rendered mesh
  34804. * in order to compute objects velocities when enableVelocity is set to "true"
  34805. * @hidden
  34806. */
  34807. _previousTransformationMatrices: {
  34808. [index: number]: Matrix;
  34809. };
  34810. private _scene;
  34811. private _multiRenderTarget;
  34812. private _ratio;
  34813. private _enablePosition;
  34814. private _enableVelocity;
  34815. private _positionIndex;
  34816. private _velocityIndex;
  34817. protected _effect: Effect;
  34818. protected _cachedDefines: string;
  34819. /**
  34820. * Set the render list (meshes to be rendered) used in the G buffer.
  34821. */
  34822. renderList: Mesh[];
  34823. /**
  34824. * Gets wether or not G buffer are supported by the running hardware.
  34825. * This requires draw buffer supports
  34826. */
  34827. readonly isSupported: boolean;
  34828. /**
  34829. * Returns the index of the given texture type in the G-Buffer textures array
  34830. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  34831. * @returns the index of the given texture type in the G-Buffer textures array
  34832. */
  34833. getTextureIndex(textureType: number): number;
  34834. /**
  34835. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  34836. */
  34837. /**
  34838. * Sets whether or not objects positions are enabled for the G buffer.
  34839. */
  34840. enablePosition: boolean;
  34841. /**
  34842. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  34843. */
  34844. /**
  34845. * Sets wether or not objects velocities are enabled for the G buffer.
  34846. */
  34847. enableVelocity: boolean;
  34848. /**
  34849. * Gets the scene associated with the buffer.
  34850. */
  34851. readonly scene: Scene;
  34852. /**
  34853. * Gets the ratio used by the buffer during its creation.
  34854. * How big is the buffer related to the main canvas.
  34855. */
  34856. readonly ratio: number;
  34857. /**
  34858. * Creates a new G Buffer for the scene
  34859. * @param scene The scene the buffer belongs to
  34860. * @param ratio How big is the buffer related to the main canvas.
  34861. */
  34862. constructor(scene: Scene, ratio?: number);
  34863. /**
  34864. * Checks wether everything is ready to render a submesh to the G buffer.
  34865. * @param subMesh the submesh to check readiness for
  34866. * @param useInstances is the mesh drawn using instance or not
  34867. * @returns true if ready otherwise false
  34868. */
  34869. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34870. /**
  34871. * Gets the current underlying G Buffer.
  34872. * @returns the buffer
  34873. */
  34874. getGBuffer(): MultiRenderTarget;
  34875. /**
  34876. * Gets the number of samples used to render the buffer (anti aliasing).
  34877. */
  34878. /**
  34879. * Sets the number of samples used to render the buffer (anti aliasing).
  34880. */
  34881. samples: number;
  34882. /**
  34883. * Disposes the renderer and frees up associated resources.
  34884. */
  34885. dispose(): void;
  34886. protected _createRenderTargets(): void;
  34887. }
  34888. }
  34889. declare module BABYLON {
  34890. interface Scene {
  34891. /** @hidden (Backing field) */
  34892. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  34893. /**
  34894. * Gets or Sets the current geometry buffer associated to the scene.
  34895. */
  34896. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  34897. /**
  34898. * Enables a GeometryBufferRender and associates it with the scene
  34899. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  34900. * @returns the GeometryBufferRenderer
  34901. */
  34902. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  34903. /**
  34904. * Disables the GeometryBufferRender associated with the scene
  34905. */
  34906. disableGeometryBufferRenderer(): void;
  34907. }
  34908. /**
  34909. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  34910. * in several rendering techniques.
  34911. */
  34912. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  34913. /**
  34914. * The component name helpful to identify the component in the list of scene components.
  34915. */
  34916. readonly name: string;
  34917. /**
  34918. * The scene the component belongs to.
  34919. */
  34920. scene: Scene;
  34921. /**
  34922. * Creates a new instance of the component for the given scene
  34923. * @param scene Defines the scene to register the component in
  34924. */
  34925. constructor(scene: Scene);
  34926. /**
  34927. * Registers the component in a given scene
  34928. */
  34929. register(): void;
  34930. /**
  34931. * Rebuilds the elements related to this component in case of
  34932. * context lost for instance.
  34933. */
  34934. rebuild(): void;
  34935. /**
  34936. * Disposes the component and the associated ressources
  34937. */
  34938. dispose(): void;
  34939. private _gatherRenderTargets;
  34940. }
  34941. }
  34942. declare module BABYLON {
  34943. /**
  34944. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  34945. */
  34946. class LineEdgesRenderer extends EdgesRenderer {
  34947. /**
  34948. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  34949. * @param source LineMesh used to generate edges
  34950. * @param epsilon not important (specified angle for edge detection)
  34951. * @param checkVerticesInsteadOfIndices not important for LineMesh
  34952. */
  34953. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  34954. /**
  34955. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  34956. */
  34957. _generateEdgesLines(): void;
  34958. }
  34959. }
  34960. declare module BABYLON {
  34961. interface Scene {
  34962. /** @hidden */
  34963. _outlineRenderer: OutlineRenderer;
  34964. /**
  34965. * Gets the outline renderer associated with the scene
  34966. * @returns a OutlineRenderer
  34967. */
  34968. getOutlineRenderer(): OutlineRenderer;
  34969. }
  34970. interface AbstractMesh {
  34971. /** @hidden (Backing field) */
  34972. _renderOutline: boolean;
  34973. /**
  34974. * Gets or sets a boolean indicating if the outline must be rendered as well
  34975. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  34976. */
  34977. renderOutline: boolean;
  34978. /** @hidden (Backing field) */
  34979. _renderOverlay: boolean;
  34980. /**
  34981. * Gets or sets a boolean indicating if the overlay must be rendered as well
  34982. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  34983. */
  34984. renderOverlay: boolean;
  34985. }
  34986. /**
  34987. * This class is responsible to draw bothe outline/overlay of meshes.
  34988. * It should not be used directly but through the available method on mesh.
  34989. */
  34990. class OutlineRenderer implements ISceneComponent {
  34991. /**
  34992. * The name of the component. Each component must have a unique name.
  34993. */
  34994. name: string;
  34995. /**
  34996. * The scene the component belongs to.
  34997. */
  34998. scene: Scene;
  34999. /**
  35000. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  35001. */
  35002. zOffset: number;
  35003. private _engine;
  35004. private _effect;
  35005. private _cachedDefines;
  35006. private _savedDepthWrite;
  35007. /**
  35008. * Instantiates a new outline renderer. (There could be only one per scene).
  35009. * @param scene Defines the scene it belongs to
  35010. */
  35011. constructor(scene: Scene);
  35012. /**
  35013. * Register the component to one instance of a scene.
  35014. */
  35015. register(): void;
  35016. /**
  35017. * Rebuilds the elements related to this component in case of
  35018. * context lost for instance.
  35019. */
  35020. rebuild(): void;
  35021. /**
  35022. * Disposes the component and the associated ressources.
  35023. */
  35024. dispose(): void;
  35025. /**
  35026. * Renders the outline in the canvas.
  35027. * @param subMesh Defines the sumesh to render
  35028. * @param batch Defines the batch of meshes in case of instances
  35029. * @param useOverlay Defines if the rendering is for the overlay or the outline
  35030. */
  35031. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  35032. /**
  35033. * Returns whether or not the outline renderer is ready for a given submesh.
  35034. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  35035. * @param subMesh Defines the submesh to check readyness for
  35036. * @param useInstances Defines wheter wee are trying to render instances or not
  35037. * @returns true if ready otherwise false
  35038. */
  35039. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35040. private _beforeRenderingMesh;
  35041. private _afterRenderingMesh;
  35042. }
  35043. }
  35044. declare module BABYLON {
  35045. /**
  35046. * This represents the object necessary to create a rendering group.
  35047. * This is exclusively used and created by the rendering manager.
  35048. * To modify the behavior, you use the available helpers in your scene or meshes.
  35049. * @hidden
  35050. */
  35051. class RenderingGroup {
  35052. index: number;
  35053. private _scene;
  35054. private _opaqueSubMeshes;
  35055. private _transparentSubMeshes;
  35056. private _alphaTestSubMeshes;
  35057. private _depthOnlySubMeshes;
  35058. private _particleSystems;
  35059. private _spriteManagers;
  35060. private _opaqueSortCompareFn;
  35061. private _alphaTestSortCompareFn;
  35062. private _transparentSortCompareFn;
  35063. private _renderOpaque;
  35064. private _renderAlphaTest;
  35065. private _renderTransparent;
  35066. private _edgesRenderers;
  35067. onBeforeTransparentRendering: () => void;
  35068. /**
  35069. * Set the opaque sort comparison function.
  35070. * If null the sub meshes will be render in the order they were created
  35071. */
  35072. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35073. /**
  35074. * Set the alpha test sort comparison function.
  35075. * If null the sub meshes will be render in the order they were created
  35076. */
  35077. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35078. /**
  35079. * Set the transparent sort comparison function.
  35080. * If null the sub meshes will be render in the order they were created
  35081. */
  35082. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35083. /**
  35084. * Creates a new rendering group.
  35085. * @param index The rendering group index
  35086. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  35087. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  35088. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  35089. */
  35090. 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>);
  35091. /**
  35092. * Render all the sub meshes contained in the group.
  35093. * @param customRenderFunction Used to override the default render behaviour of the group.
  35094. * @returns true if rendered some submeshes.
  35095. */
  35096. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  35097. /**
  35098. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  35099. * @param subMeshes The submeshes to render
  35100. */
  35101. private renderOpaqueSorted;
  35102. /**
  35103. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  35104. * @param subMeshes The submeshes to render
  35105. */
  35106. private renderAlphaTestSorted;
  35107. /**
  35108. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  35109. * @param subMeshes The submeshes to render
  35110. */
  35111. private renderTransparentSorted;
  35112. /**
  35113. * Renders the submeshes in a specified order.
  35114. * @param subMeshes The submeshes to sort before render
  35115. * @param sortCompareFn The comparison function use to sort
  35116. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  35117. * @param transparent Specifies to activate blending if true
  35118. */
  35119. private static renderSorted;
  35120. /**
  35121. * Renders the submeshes in the order they were dispatched (no sort applied).
  35122. * @param subMeshes The submeshes to render
  35123. */
  35124. private static renderUnsorted;
  35125. /**
  35126. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35127. * are rendered back to front if in the same alpha index.
  35128. *
  35129. * @param a The first submesh
  35130. * @param b The second submesh
  35131. * @returns The result of the comparison
  35132. */
  35133. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  35134. /**
  35135. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35136. * are rendered back to front.
  35137. *
  35138. * @param a The first submesh
  35139. * @param b The second submesh
  35140. * @returns The result of the comparison
  35141. */
  35142. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  35143. /**
  35144. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35145. * are rendered front to back (prevent overdraw).
  35146. *
  35147. * @param a The first submesh
  35148. * @param b The second submesh
  35149. * @returns The result of the comparison
  35150. */
  35151. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  35152. /**
  35153. * Resets the different lists of submeshes to prepare a new frame.
  35154. */
  35155. prepare(): void;
  35156. dispose(): void;
  35157. /**
  35158. * Inserts the submesh in its correct queue depending on its material.
  35159. * @param subMesh The submesh to dispatch
  35160. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35161. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35162. */
  35163. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35164. dispatchSprites(spriteManager: ISpriteManager): void;
  35165. dispatchParticles(particleSystem: IParticleSystem): void;
  35166. private _renderParticles;
  35167. private _renderSprites;
  35168. }
  35169. }
  35170. declare module BABYLON {
  35171. /**
  35172. * Interface describing the different options available in the rendering manager
  35173. * regarding Auto Clear between groups.
  35174. */
  35175. interface IRenderingManagerAutoClearSetup {
  35176. /**
  35177. * Defines whether or not autoclear is enable.
  35178. */
  35179. autoClear: boolean;
  35180. /**
  35181. * Defines whether or not to autoclear the depth buffer.
  35182. */
  35183. depth: boolean;
  35184. /**
  35185. * Defines whether or not to autoclear the stencil buffer.
  35186. */
  35187. stencil: boolean;
  35188. }
  35189. /**
  35190. * This is the manager responsible of all the rendering for meshes sprites and particles.
  35191. * It is enable to manage the different groups as well as the different necessary sort functions.
  35192. * This should not be used directly aside of the few static configurations
  35193. */
  35194. class RenderingManager {
  35195. /**
  35196. * The max id used for rendering groups (not included)
  35197. */
  35198. static MAX_RENDERINGGROUPS: number;
  35199. /**
  35200. * The min id used for rendering groups (included)
  35201. */
  35202. static MIN_RENDERINGGROUPS: number;
  35203. /**
  35204. * Used to globally prevent autoclearing scenes.
  35205. */
  35206. static AUTOCLEAR: boolean;
  35207. /**
  35208. * @hidden
  35209. */
  35210. _useSceneAutoClearSetup: boolean;
  35211. private _scene;
  35212. private _renderingGroups;
  35213. private _depthStencilBufferAlreadyCleaned;
  35214. private _autoClearDepthStencil;
  35215. private _customOpaqueSortCompareFn;
  35216. private _customAlphaTestSortCompareFn;
  35217. private _customTransparentSortCompareFn;
  35218. private _renderingGroupInfo;
  35219. /**
  35220. * Instantiates a new rendering group for a particular scene
  35221. * @param scene Defines the scene the groups belongs to
  35222. */
  35223. constructor(scene: Scene);
  35224. private _clearDepthStencilBuffer;
  35225. /**
  35226. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  35227. * @hidden
  35228. */
  35229. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  35230. /**
  35231. * Resets the different information of the group to prepare a new frame
  35232. * @hidden
  35233. */
  35234. reset(): void;
  35235. /**
  35236. * Dispose and release the group and its associated resources.
  35237. * @hidden
  35238. */
  35239. dispose(): void;
  35240. /**
  35241. * Clear the info related to rendering groups preventing retention points during dispose.
  35242. */
  35243. freeRenderingGroups(): void;
  35244. private _prepareRenderingGroup;
  35245. /**
  35246. * Add a sprite manager to the rendering manager in order to render it this frame.
  35247. * @param spriteManager Define the sprite manager to render
  35248. */
  35249. dispatchSprites(spriteManager: ISpriteManager): void;
  35250. /**
  35251. * Add a particle system to the rendering manager in order to render it this frame.
  35252. * @param particleSystem Define the particle system to render
  35253. */
  35254. dispatchParticles(particleSystem: IParticleSystem): void;
  35255. /**
  35256. * Add a submesh to the manager in order to render it this frame
  35257. * @param subMesh The submesh to dispatch
  35258. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35259. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35260. */
  35261. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35262. /**
  35263. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35264. * This allowed control for front to back rendering or reversly depending of the special needs.
  35265. *
  35266. * @param renderingGroupId The rendering group id corresponding to its index
  35267. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35268. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35269. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35270. */
  35271. 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;
  35272. /**
  35273. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35274. *
  35275. * @param renderingGroupId The rendering group id corresponding to its index
  35276. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35277. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35278. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35279. */
  35280. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35281. /**
  35282. * Gets the current auto clear configuration for one rendering group of the rendering
  35283. * manager.
  35284. * @param index the rendering group index to get the information for
  35285. * @returns The auto clear setup for the requested rendering group
  35286. */
  35287. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35288. }
  35289. }
  35290. declare module BABYLON {
  35291. /**
  35292. * Renders a layer on top of an existing scene
  35293. */
  35294. class UtilityLayerRenderer implements IDisposable {
  35295. /** the original scene that will be rendered on top of */
  35296. originalScene: Scene;
  35297. private _pointerCaptures;
  35298. private _lastPointerEvents;
  35299. private static _DefaultUtilityLayer;
  35300. private static _DefaultKeepDepthUtilityLayer;
  35301. /**
  35302. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  35303. */
  35304. pickUtilitySceneFirst: boolean;
  35305. /**
  35306. * 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)
  35307. */
  35308. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  35309. /**
  35310. * 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)
  35311. */
  35312. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  35313. /**
  35314. * The scene that is rendered on top of the original scene
  35315. */
  35316. utilityLayerScene: Scene;
  35317. /**
  35318. * If the utility layer should automatically be rendered on top of existing scene
  35319. */
  35320. shouldRender: boolean;
  35321. /**
  35322. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  35323. */
  35324. onlyCheckPointerDownEvents: boolean;
  35325. /**
  35326. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  35327. */
  35328. processAllEvents: boolean;
  35329. /**
  35330. * Observable raised when the pointer move from the utility layer scene to the main scene
  35331. */
  35332. onPointerOutObservable: Observable<number>;
  35333. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  35334. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  35335. private _afterRenderObserver;
  35336. private _sceneDisposeObserver;
  35337. private _originalPointerObserver;
  35338. /**
  35339. * Instantiates a UtilityLayerRenderer
  35340. * @param originalScene the original scene that will be rendered on top of
  35341. * @param handleEvents boolean indicating if the utility layer should handle events
  35342. */
  35343. constructor(
  35344. /** the original scene that will be rendered on top of */
  35345. originalScene: Scene, handleEvents?: boolean);
  35346. private _notifyObservers;
  35347. /**
  35348. * Renders the utility layers scene on top of the original scene
  35349. */
  35350. render(): void;
  35351. /**
  35352. * Disposes of the renderer
  35353. */
  35354. dispose(): void;
  35355. private _updateCamera;
  35356. }
  35357. }
  35358. declare module BABYLON {
  35359. /**
  35360. * Class used to represent a sprite
  35361. * @see http://doc.babylonjs.com/babylon101/sprites
  35362. */
  35363. class Sprite {
  35364. /** defines the name */
  35365. name: string;
  35366. /** Gets or sets the current world position */
  35367. position: Vector3;
  35368. /** Gets or sets the main color */
  35369. color: Color4;
  35370. /** Gets or sets the width */
  35371. width: number;
  35372. /** Gets or sets the height */
  35373. height: number;
  35374. /** Gets or sets rotation angle */
  35375. angle: number;
  35376. /** Gets or sets the cell index in the sprite sheet */
  35377. cellIndex: number;
  35378. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  35379. invertU: number;
  35380. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  35381. invertV: number;
  35382. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  35383. disposeWhenFinishedAnimating: boolean;
  35384. /** Gets the list of attached animations */
  35385. animations: Animation[];
  35386. /** Gets or sets a boolean indicating if the sprite can be picked */
  35387. isPickable: boolean;
  35388. /**
  35389. * Gets or sets the associated action manager
  35390. */
  35391. actionManager: Nullable<ActionManager>;
  35392. private _animationStarted;
  35393. private _loopAnimation;
  35394. private _fromIndex;
  35395. private _toIndex;
  35396. private _delay;
  35397. private _direction;
  35398. private _manager;
  35399. private _time;
  35400. private _onAnimationEnd;
  35401. /**
  35402. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  35403. */
  35404. isVisible: boolean;
  35405. /**
  35406. * Gets or sets the sprite size
  35407. */
  35408. size: number;
  35409. /**
  35410. * Creates a new Sprite
  35411. * @param name defines the name
  35412. * @param manager defines the manager
  35413. */
  35414. constructor(
  35415. /** defines the name */
  35416. name: string, manager: ISpriteManager);
  35417. /**
  35418. * Starts an animation
  35419. * @param from defines the initial key
  35420. * @param to defines the end key
  35421. * @param loop defines if the animation must loop
  35422. * @param delay defines the start delay (in ms)
  35423. * @param onAnimationEnd defines a callback to call when animation ends
  35424. */
  35425. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  35426. /** Stops current animation (if any) */
  35427. stopAnimation(): void;
  35428. /** @hidden */
  35429. _animate(deltaTime: number): void;
  35430. /** Release associated resources */
  35431. dispose(): void;
  35432. }
  35433. }
  35434. declare module BABYLON {
  35435. /**
  35436. * Defines the minimum interface to fullfil in order to be a sprite manager.
  35437. */
  35438. interface ISpriteManager extends IDisposable {
  35439. /**
  35440. * Restricts the camera to viewing objects with the same layerMask.
  35441. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  35442. */
  35443. layerMask: number;
  35444. /**
  35445. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35446. */
  35447. isPickable: boolean;
  35448. /**
  35449. * Specifies the rendering group id for this mesh (0 by default)
  35450. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35451. */
  35452. renderingGroupId: number;
  35453. /**
  35454. * Defines the list of sprites managed by the manager.
  35455. */
  35456. sprites: Array<Sprite>;
  35457. /**
  35458. * Tests the intersection of a sprite with a specific ray.
  35459. * @param ray The ray we are sending to test the collision
  35460. * @param camera The camera space we are sending rays in
  35461. * @param predicate A predicate allowing excluding sprites from the list of object to test
  35462. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  35463. * @returns picking info or null.
  35464. */
  35465. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  35466. /**
  35467. * Renders the list of sprites on screen.
  35468. */
  35469. render(): void;
  35470. }
  35471. /**
  35472. * Class used to manage multiple sprites on the same spritesheet
  35473. * @see http://doc.babylonjs.com/babylon101/sprites
  35474. */
  35475. class SpriteManager implements ISpriteManager {
  35476. /** defines the manager's name */
  35477. name: string;
  35478. /** Gets the list of sprites */
  35479. sprites: Sprite[];
  35480. /** Gets or sets the rendering group id (0 by default) */
  35481. renderingGroupId: number;
  35482. /** Gets or sets camera layer mask */
  35483. layerMask: number;
  35484. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  35485. fogEnabled: boolean;
  35486. /** Gets or sets a boolean indicating if the sprites are pickable */
  35487. isPickable: boolean;
  35488. /** Defines the default width of a cell in the spritesheet */
  35489. cellWidth: number;
  35490. /** Defines the default height of a cell in the spritesheet */
  35491. cellHeight: number;
  35492. /**
  35493. * An event triggered when the manager is disposed.
  35494. */
  35495. onDisposeObservable: Observable<SpriteManager>;
  35496. private _onDisposeObserver;
  35497. /**
  35498. * Callback called when the manager is disposed
  35499. */
  35500. onDispose: () => void;
  35501. private _capacity;
  35502. private _spriteTexture;
  35503. private _epsilon;
  35504. private _scene;
  35505. private _vertexData;
  35506. private _buffer;
  35507. private _vertexBuffers;
  35508. private _indexBuffer;
  35509. private _effectBase;
  35510. private _effectFog;
  35511. /**
  35512. * Gets or sets the spritesheet texture
  35513. */
  35514. texture: Texture;
  35515. /**
  35516. * Creates a new sprite manager
  35517. * @param name defines the manager's name
  35518. * @param imgUrl defines the sprite sheet url
  35519. * @param capacity defines the maximum allowed number of sprites
  35520. * @param cellSize defines the size of a sprite cell
  35521. * @param scene defines the hosting scene
  35522. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  35523. * @param samplingMode defines the smapling mode to use with spritesheet
  35524. */
  35525. constructor(
  35526. /** defines the manager's name */
  35527. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  35528. private _appendSpriteVertex;
  35529. /**
  35530. * Intersects the sprites with a ray
  35531. * @param ray defines the ray to intersect with
  35532. * @param camera defines the current active camera
  35533. * @param predicate defines a predicate used to select candidate sprites
  35534. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  35535. * @returns null if no hit or a PickingInfo
  35536. */
  35537. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  35538. /**
  35539. * Render all child sprites
  35540. */
  35541. render(): void;
  35542. /**
  35543. * Release associated resources
  35544. */
  35545. dispose(): void;
  35546. }
  35547. }
  35548. declare module BABYLON {
  35549. interface Scene {
  35550. /** @hidden */
  35551. _pointerOverSprite: Nullable<Sprite>;
  35552. /** @hidden */
  35553. _pickedDownSprite: Nullable<Sprite>;
  35554. /** @hidden */
  35555. _tempSpritePickingRay: Nullable<Ray>;
  35556. /**
  35557. * All of the sprite managers added to this scene
  35558. * @see http://doc.babylonjs.com/babylon101/sprites
  35559. */
  35560. spriteManagers: Array<ISpriteManager>;
  35561. /**
  35562. * An event triggered when sprites rendering is about to start
  35563. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  35564. */
  35565. onBeforeSpritesRenderingObservable: Observable<Scene>;
  35566. /**
  35567. * An event triggered when sprites rendering is done
  35568. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  35569. */
  35570. onAfterSpritesRenderingObservable: Observable<Scene>;
  35571. /** @hidden */
  35572. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35573. /** Launch a ray to try to pick a sprite in the scene
  35574. * @param x position on screen
  35575. * @param y position on screen
  35576. * @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
  35577. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35578. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35579. * @returns a PickingInfo
  35580. */
  35581. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35582. /** Use the given ray to pick a sprite in the scene
  35583. * @param ray The ray (in world space) to use to pick meshes
  35584. * @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
  35585. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35586. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  35587. * @returns a PickingInfo
  35588. */
  35589. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35590. /**
  35591. * Force the sprite under the pointer
  35592. * @param sprite defines the sprite to use
  35593. */
  35594. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  35595. /**
  35596. * Gets the sprite under the pointer
  35597. * @returns a Sprite or null if no sprite is under the pointer
  35598. */
  35599. getPointerOverSprite(): Nullable<Sprite>;
  35600. }
  35601. /**
  35602. * Defines the sprite scene component responsible to manage sprites
  35603. * in a given scene.
  35604. */
  35605. class SpriteSceneComponent implements ISceneComponent {
  35606. /**
  35607. * The component name helpfull to identify the component in the list of scene components.
  35608. */
  35609. readonly name: string;
  35610. /**
  35611. * The scene the component belongs to.
  35612. */
  35613. scene: Scene;
  35614. /** @hidden */
  35615. private _spritePredicate;
  35616. /**
  35617. * Creates a new instance of the component for the given scene
  35618. * @param scene Defines the scene to register the component in
  35619. */
  35620. constructor(scene: Scene);
  35621. /**
  35622. * Registers the component in a given scene
  35623. */
  35624. register(): void;
  35625. /**
  35626. * Rebuilds the elements related to this component in case of
  35627. * context lost for instance.
  35628. */
  35629. rebuild(): void;
  35630. /**
  35631. * Disposes the component and the associated ressources.
  35632. */
  35633. dispose(): void;
  35634. private _pickSpriteButKeepRay;
  35635. private _pointerMove;
  35636. private _pointerDown;
  35637. private _pointerUp;
  35638. }
  35639. }
  35640. declare module BABYLON {
  35641. /**
  35642. * Postprocess used to generate anaglyphic rendering
  35643. */
  35644. class AnaglyphPostProcess extends PostProcess {
  35645. private _passedProcess;
  35646. /**
  35647. * Creates a new AnaglyphPostProcess
  35648. * @param name defines postprocess name
  35649. * @param options defines creation options or target ratio scale
  35650. * @param rigCameras defines cameras using this postprocess
  35651. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  35652. * @param engine defines hosting engine
  35653. * @param reusable defines if the postprocess will be reused multiple times per frame
  35654. */
  35655. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  35656. }
  35657. }
  35658. declare module BABYLON {
  35659. /**
  35660. * Post process used to render in black and white
  35661. */
  35662. class BlackAndWhitePostProcess extends PostProcess {
  35663. /**
  35664. * Linear about to convert he result to black and white (default: 1)
  35665. */
  35666. degree: number;
  35667. /**
  35668. * Creates a black and white post process
  35669. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  35670. * @param name The name of the effect.
  35671. * @param options The required width/height ratio to downsize to before computing the render pass.
  35672. * @param camera The camera to apply the render pass to.
  35673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35674. * @param engine The engine which the post process will be applied. (default: current engine)
  35675. * @param reusable If the post process can be reused on the same frame. (default: false)
  35676. */
  35677. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35678. }
  35679. }
  35680. declare module BABYLON {
  35681. /**
  35682. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  35683. */
  35684. class BloomEffect extends PostProcessRenderEffect {
  35685. private bloomScale;
  35686. /**
  35687. * @hidden Internal
  35688. */
  35689. _effects: Array<PostProcess>;
  35690. /**
  35691. * @hidden Internal
  35692. */
  35693. _downscale: ExtractHighlightsPostProcess;
  35694. private _blurX;
  35695. private _blurY;
  35696. private _merge;
  35697. /**
  35698. * The luminance threshold to find bright areas of the image to bloom.
  35699. */
  35700. threshold: number;
  35701. /**
  35702. * The strength of the bloom.
  35703. */
  35704. weight: number;
  35705. /**
  35706. * Specifies the size of the bloom blur kernel, relative to the final output size
  35707. */
  35708. kernel: number;
  35709. /**
  35710. * Creates a new instance of @see BloomEffect
  35711. * @param scene The scene the effect belongs to.
  35712. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  35713. * @param bloomKernel The size of the kernel to be used when applying the blur.
  35714. * @param bloomWeight The the strength of bloom.
  35715. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  35716. * @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)
  35717. */
  35718. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  35719. /**
  35720. * Disposes each of the internal effects for a given camera.
  35721. * @param camera The camera to dispose the effect on.
  35722. */
  35723. disposeEffects(camera: Camera): void;
  35724. /**
  35725. * @hidden Internal
  35726. */
  35727. _updateEffects(): void;
  35728. /**
  35729. * Internal
  35730. * @returns if all the contained post processes are ready.
  35731. * @hidden
  35732. */
  35733. _isReady(): boolean;
  35734. }
  35735. }
  35736. declare module BABYLON {
  35737. /**
  35738. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  35739. */
  35740. class BloomMergePostProcess extends PostProcess {
  35741. /** Weight of the bloom to be added to the original input. */
  35742. weight: number;
  35743. /**
  35744. * Creates a new instance of @see BloomMergePostProcess
  35745. * @param name The name of the effect.
  35746. * @param originalFromInput Post process which's input will be used for the merge.
  35747. * @param blurred Blurred highlights post process which's output will be used.
  35748. * @param weight Weight of the bloom to be added to the original input.
  35749. * @param options The required width/height ratio to downsize to before computing the render pass.
  35750. * @param camera The camera to apply the render pass to.
  35751. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35752. * @param engine The engine which the post process will be applied. (default: current engine)
  35753. * @param reusable If the post process can be reused on the same frame. (default: false)
  35754. * @param textureType Type of textures used when performing the post process. (default: 0)
  35755. * @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)
  35756. */
  35757. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  35758. /** Weight of the bloom to be added to the original input. */
  35759. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35760. }
  35761. }
  35762. declare module BABYLON {
  35763. /**
  35764. * The Blur Post Process which blurs an image based on a kernel and direction.
  35765. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  35766. */
  35767. class BlurPostProcess extends PostProcess {
  35768. /** The direction in which to blur the image. */
  35769. direction: Vector2;
  35770. private blockCompilation;
  35771. protected _kernel: number;
  35772. protected _idealKernel: number;
  35773. protected _packedFloat: boolean;
  35774. private _staticDefines;
  35775. /**
  35776. * Sets the length in pixels of the blur sample region
  35777. */
  35778. /**
  35779. * Gets the length in pixels of the blur sample region
  35780. */
  35781. kernel: number;
  35782. /**
  35783. * Sets wether or not the blur needs to unpack/repack floats
  35784. */
  35785. /**
  35786. * Gets wether or not the blur is unpacking/repacking floats
  35787. */
  35788. packedFloat: boolean;
  35789. /**
  35790. * Creates a new instance BlurPostProcess
  35791. * @param name The name of the effect.
  35792. * @param direction The direction in which to blur the image.
  35793. * @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.
  35794. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35795. * @param camera The camera to apply the render pass to.
  35796. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35797. * @param engine The engine which the post process will be applied. (default: current engine)
  35798. * @param reusable If the post process can be reused on the same frame. (default: false)
  35799. * @param textureType Type of textures used when performing the post process. (default: 0)
  35800. * @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)
  35801. */
  35802. constructor(name: string,
  35803. /** The direction in which to blur the image. */
  35804. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  35805. /**
  35806. * Updates the effect with the current post process compile time values and recompiles the shader.
  35807. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35808. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35809. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35810. * @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
  35811. * @param onCompiled Called when the shader has been compiled.
  35812. * @param onError Called if there is an error when compiling a shader.
  35813. */
  35814. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35815. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35816. /**
  35817. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  35818. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  35819. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  35820. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  35821. * The gaps between physical kernels are compensated for in the weighting of the samples
  35822. * @param idealKernel Ideal blur kernel.
  35823. * @return Nearest best kernel.
  35824. */
  35825. protected _nearestBestKernel(idealKernel: number): number;
  35826. /**
  35827. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  35828. * @param x The point on the Gaussian distribution to sample.
  35829. * @return the value of the Gaussian function at x.
  35830. */
  35831. protected _gaussianWeight(x: number): number;
  35832. /**
  35833. * Generates a string that can be used as a floating point number in GLSL.
  35834. * @param x Value to print.
  35835. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  35836. * @return GLSL float string.
  35837. */
  35838. protected _glslFloat(x: number, decimalFigures?: number): string;
  35839. }
  35840. }
  35841. declare module BABYLON {
  35842. /**
  35843. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  35844. */
  35845. class ChromaticAberrationPostProcess extends PostProcess {
  35846. /**
  35847. * The amount of seperation of rgb channels (default: 30)
  35848. */
  35849. aberrationAmount: number;
  35850. /**
  35851. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  35852. */
  35853. radialIntensity: number;
  35854. /**
  35855. * 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))
  35856. */
  35857. direction: Vector2;
  35858. /**
  35859. * 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))
  35860. */
  35861. centerPosition: Vector2;
  35862. /**
  35863. * Creates a new instance ChromaticAberrationPostProcess
  35864. * @param name The name of the effect.
  35865. * @param screenWidth The width of the screen to apply the effect on.
  35866. * @param screenHeight The height of the screen to apply the effect on.
  35867. * @param options The required width/height ratio to downsize to before computing the render pass.
  35868. * @param camera The camera to apply the render pass to.
  35869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35870. * @param engine The engine which the post process will be applied. (default: current engine)
  35871. * @param reusable If the post process can be reused on the same frame. (default: false)
  35872. * @param textureType Type of textures used when performing the post process. (default: 0)
  35873. * @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)
  35874. */
  35875. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35876. }
  35877. }
  35878. declare module BABYLON {
  35879. /**
  35880. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  35881. */
  35882. class CircleOfConfusionPostProcess extends PostProcess {
  35883. /**
  35884. * 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.
  35885. */
  35886. lensSize: number;
  35887. /**
  35888. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  35889. */
  35890. fStop: number;
  35891. /**
  35892. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  35893. */
  35894. focusDistance: number;
  35895. /**
  35896. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  35897. */
  35898. focalLength: number;
  35899. private _depthTexture;
  35900. /**
  35901. * Creates a new instance CircleOfConfusionPostProcess
  35902. * @param name The name of the effect.
  35903. * @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.
  35904. * @param options The required width/height ratio to downsize to before computing the render pass.
  35905. * @param camera The camera to apply the render pass to.
  35906. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35907. * @param engine The engine which the post process will be applied. (default: current engine)
  35908. * @param reusable If the post process can be reused on the same frame. (default: false)
  35909. * @param textureType Type of textures used when performing the post process. (default: 0)
  35910. * @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)
  35911. */
  35912. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35913. /**
  35914. * 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.
  35915. */
  35916. depthTexture: RenderTargetTexture;
  35917. }
  35918. }
  35919. declare module BABYLON {
  35920. /**
  35921. *
  35922. * This post-process allows the modification of rendered colors by using
  35923. * a 'look-up table' (LUT). This effect is also called Color Grading.
  35924. *
  35925. * The object needs to be provided an url to a texture containing the color
  35926. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  35927. * Use an image editing software to tweak the LUT to match your needs.
  35928. *
  35929. * For an example of a color LUT, see here:
  35930. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  35931. * For explanations on color grading, see here:
  35932. * @see http://udn.epicgames.com/Three/ColorGrading.html
  35933. *
  35934. */
  35935. class ColorCorrectionPostProcess extends PostProcess {
  35936. private _colorTableTexture;
  35937. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35938. }
  35939. }
  35940. declare module BABYLON {
  35941. /**
  35942. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  35943. * input texture to perform effects such as edge detection or sharpening
  35944. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35945. */
  35946. class ConvolutionPostProcess extends PostProcess {
  35947. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  35948. kernel: number[];
  35949. /**
  35950. * Creates a new instance ConvolutionPostProcess
  35951. * @param name The name of the effect.
  35952. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  35953. * @param options The required width/height ratio to downsize to before computing the render pass.
  35954. * @param camera The camera to apply the render pass to.
  35955. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35956. * @param engine The engine which the post process will be applied. (default: current engine)
  35957. * @param reusable If the post process can be reused on the same frame. (default: false)
  35958. * @param textureType Type of textures used when performing the post process. (default: 0)
  35959. */
  35960. constructor(name: string,
  35961. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  35962. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35963. /**
  35964. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35965. */
  35966. static EdgeDetect0Kernel: number[];
  35967. /**
  35968. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35969. */
  35970. static EdgeDetect1Kernel: number[];
  35971. /**
  35972. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35973. */
  35974. static EdgeDetect2Kernel: number[];
  35975. /**
  35976. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35977. */
  35978. static SharpenKernel: number[];
  35979. /**
  35980. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35981. */
  35982. static EmbossKernel: number[];
  35983. /**
  35984. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35985. */
  35986. static GaussianKernel: number[];
  35987. }
  35988. }
  35989. declare module BABYLON {
  35990. /**
  35991. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  35992. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  35993. * based on samples that have a large difference in distance than the center pixel.
  35994. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  35995. */
  35996. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  35997. direction: Vector2;
  35998. /**
  35999. * Creates a new instance CircleOfConfusionPostProcess
  36000. * @param name The name of the effect.
  36001. * @param scene The scene the effect belongs to.
  36002. * @param direction The direction the blur should be applied.
  36003. * @param kernel The size of the kernel used to blur.
  36004. * @param options The required width/height ratio to downsize to before computing the render pass.
  36005. * @param camera The camera to apply the render pass to.
  36006. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  36007. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  36008. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36009. * @param engine The engine which the post process will be applied. (default: current engine)
  36010. * @param reusable If the post process can be reused on the same frame. (default: false)
  36011. * @param textureType Type of textures used when performing the post process. (default: 0)
  36012. * @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)
  36013. */
  36014. 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);
  36015. }
  36016. }
  36017. declare module BABYLON {
  36018. /**
  36019. * Specifies the level of max blur that should be applied when using the depth of field effect
  36020. */
  36021. enum DepthOfFieldEffectBlurLevel {
  36022. /**
  36023. * Subtle blur
  36024. */
  36025. Low = 0,
  36026. /**
  36027. * Medium blur
  36028. */
  36029. Medium = 1,
  36030. /**
  36031. * Large blur
  36032. */
  36033. High = 2
  36034. }
  36035. /**
  36036. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  36037. */
  36038. class DepthOfFieldEffect extends PostProcessRenderEffect {
  36039. private _circleOfConfusion;
  36040. /**
  36041. * @hidden Internal, blurs from high to low
  36042. */
  36043. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  36044. private _depthOfFieldBlurY;
  36045. private _dofMerge;
  36046. /**
  36047. * @hidden Internal post processes in depth of field effect
  36048. */
  36049. _effects: Array<PostProcess>;
  36050. /**
  36051. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  36052. */
  36053. focalLength: number;
  36054. /**
  36055. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  36056. */
  36057. fStop: number;
  36058. /**
  36059. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  36060. */
  36061. focusDistance: number;
  36062. /**
  36063. * 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.
  36064. */
  36065. lensSize: number;
  36066. /**
  36067. * Creates a new instance DepthOfFieldEffect
  36068. * @param scene The scene the effect belongs to.
  36069. * @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.
  36070. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  36071. * @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)
  36072. */
  36073. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  36074. /**
  36075. * 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.
  36076. */
  36077. depthTexture: RenderTargetTexture;
  36078. /**
  36079. * Disposes each of the internal effects for a given camera.
  36080. * @param camera The camera to dispose the effect on.
  36081. */
  36082. disposeEffects(camera: Camera): void;
  36083. /**
  36084. * @hidden Internal
  36085. */
  36086. _updateEffects(): void;
  36087. /**
  36088. * Internal
  36089. * @returns if all the contained post processes are ready.
  36090. * @hidden
  36091. */
  36092. _isReady(): boolean;
  36093. }
  36094. }
  36095. declare module BABYLON {
  36096. /**
  36097. * Options to be set when merging outputs from the default pipeline.
  36098. */
  36099. class DepthOfFieldMergePostProcessOptions {
  36100. /**
  36101. * The original image to merge on top of
  36102. */
  36103. originalFromInput: PostProcess;
  36104. /**
  36105. * Parameters to perform the merge of the depth of field effect
  36106. */
  36107. depthOfField?: {
  36108. circleOfConfusion: PostProcess;
  36109. blurSteps: Array<PostProcess>;
  36110. };
  36111. /**
  36112. * Parameters to perform the merge of bloom effect
  36113. */
  36114. bloom?: {
  36115. blurred: PostProcess;
  36116. weight: number;
  36117. };
  36118. }
  36119. /**
  36120. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  36121. */
  36122. class DepthOfFieldMergePostProcess extends PostProcess {
  36123. private blurSteps;
  36124. /**
  36125. * Creates a new instance of DepthOfFieldMergePostProcess
  36126. * @param name The name of the effect.
  36127. * @param originalFromInput Post process which's input will be used for the merge.
  36128. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  36129. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  36130. * @param options The required width/height ratio to downsize to before computing the render pass.
  36131. * @param camera The camera to apply the render pass to.
  36132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36133. * @param engine The engine which the post process will be applied. (default: current engine)
  36134. * @param reusable If the post process can be reused on the same frame. (default: false)
  36135. * @param textureType Type of textures used when performing the post process. (default: 0)
  36136. * @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)
  36137. */
  36138. 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);
  36139. /**
  36140. * Updates the effect with the current post process compile time values and recompiles the shader.
  36141. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  36142. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  36143. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  36144. * @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
  36145. * @param onCompiled Called when the shader has been compiled.
  36146. * @param onError Called if there is an error when compiling a shader.
  36147. */
  36148. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  36149. }
  36150. }
  36151. declare module BABYLON {
  36152. /**
  36153. * DisplayPassPostProcess which produces an output the same as it's input
  36154. */
  36155. class DisplayPassPostProcess extends PostProcess {
  36156. /**
  36157. * Creates the DisplayPassPostProcess
  36158. * @param name The name of the effect.
  36159. * @param options The required width/height ratio to downsize to before computing the render pass.
  36160. * @param camera The camera to apply the render pass to.
  36161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36162. * @param engine The engine which the post process will be applied. (default: current engine)
  36163. * @param reusable If the post process can be reused on the same frame. (default: false)
  36164. */
  36165. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36166. }
  36167. }
  36168. declare module BABYLON {
  36169. /**
  36170. * 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.
  36171. */
  36172. class ExtractHighlightsPostProcess extends PostProcess {
  36173. /**
  36174. * The luminance threshold, pixels below this value will be set to black.
  36175. */
  36176. threshold: number;
  36177. /** @hidden */
  36178. _exposure: number;
  36179. /**
  36180. * Post process which has the input texture to be used when performing highlight extraction
  36181. * @hidden
  36182. */
  36183. _inputPostProcess: Nullable<PostProcess>;
  36184. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36185. }
  36186. }
  36187. declare module BABYLON {
  36188. /**
  36189. * Applies a kernel filter to the image
  36190. */
  36191. class FilterPostProcess extends PostProcess {
  36192. /** The matrix to be applied to the image */
  36193. kernelMatrix: Matrix;
  36194. /**
  36195. *
  36196. * @param name The name of the effect.
  36197. * @param kernelMatrix The matrix to be applied to the image
  36198. * @param options The required width/height ratio to downsize to before computing the render pass.
  36199. * @param camera The camera to apply the render pass to.
  36200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36201. * @param engine The engine which the post process will be applied. (default: current engine)
  36202. * @param reusable If the post process can be reused on the same frame. (default: false)
  36203. */
  36204. constructor(name: string,
  36205. /** The matrix to be applied to the image */
  36206. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36207. }
  36208. }
  36209. declare module BABYLON {
  36210. /**
  36211. * Fxaa post process
  36212. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  36213. */
  36214. class FxaaPostProcess extends PostProcess {
  36215. /** @hidden */
  36216. texelWidth: number;
  36217. /** @hidden */
  36218. texelHeight: number;
  36219. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  36220. private _getDefines;
  36221. }
  36222. }
  36223. declare module BABYLON {
  36224. /**
  36225. * The GrainPostProcess adds noise to the image at mid luminance levels
  36226. */
  36227. class GrainPostProcess extends PostProcess {
  36228. /**
  36229. * The intensity of the grain added (default: 30)
  36230. */
  36231. intensity: number;
  36232. /**
  36233. * If the grain should be randomized on every frame
  36234. */
  36235. animated: boolean;
  36236. /**
  36237. * Creates a new instance of @see GrainPostProcess
  36238. * @param name The name of the effect.
  36239. * @param options The required width/height ratio to downsize to before computing the render pass.
  36240. * @param camera The camera to apply the render pass to.
  36241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36242. * @param engine The engine which the post process will be applied. (default: current engine)
  36243. * @param reusable If the post process can be reused on the same frame. (default: false)
  36244. * @param textureType Type of textures used when performing the post process. (default: 0)
  36245. * @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)
  36246. */
  36247. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36248. }
  36249. }
  36250. declare module BABYLON {
  36251. /**
  36252. * Extracts highlights from the image
  36253. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36254. */
  36255. class HighlightsPostProcess extends PostProcess {
  36256. /**
  36257. * Extracts highlights from the image
  36258. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36259. * @param name The name of the effect.
  36260. * @param options The required width/height ratio to downsize to before computing the render pass.
  36261. * @param camera The camera to apply the render pass to.
  36262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36263. * @param engine The engine which the post process will be applied. (default: current engine)
  36264. * @param reusable If the post process can be reused on the same frame. (default: false)
  36265. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  36266. */
  36267. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  36268. }
  36269. }
  36270. declare module BABYLON {
  36271. /**
  36272. * ImageProcessingPostProcess
  36273. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  36274. */
  36275. class ImageProcessingPostProcess extends PostProcess {
  36276. /**
  36277. * Default configuration related to image processing available in the PBR Material.
  36278. */
  36279. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36280. /**
  36281. * Gets the image processing configuration used either in this material.
  36282. */
  36283. /**
  36284. * Sets the Default image processing configuration used either in the this material.
  36285. *
  36286. * If sets to null, the scene one is in use.
  36287. */
  36288. imageProcessingConfiguration: ImageProcessingConfiguration;
  36289. /**
  36290. * Keep track of the image processing observer to allow dispose and replace.
  36291. */
  36292. private _imageProcessingObserver;
  36293. /**
  36294. * Attaches a new image processing configuration to the PBR Material.
  36295. * @param configuration
  36296. */
  36297. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  36298. /**
  36299. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  36300. */
  36301. /**
  36302. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  36303. */
  36304. colorCurves: Nullable<ColorCurves>;
  36305. /**
  36306. * Gets wether the color curves effect is enabled.
  36307. */
  36308. /**
  36309. * Sets wether the color curves effect is enabled.
  36310. */
  36311. colorCurvesEnabled: boolean;
  36312. /**
  36313. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  36314. */
  36315. /**
  36316. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  36317. */
  36318. colorGradingTexture: Nullable<BaseTexture>;
  36319. /**
  36320. * Gets wether the color grading effect is enabled.
  36321. */
  36322. /**
  36323. * Gets wether the color grading effect is enabled.
  36324. */
  36325. colorGradingEnabled: boolean;
  36326. /**
  36327. * Gets exposure used in the effect.
  36328. */
  36329. /**
  36330. * Sets exposure used in the effect.
  36331. */
  36332. exposure: number;
  36333. /**
  36334. * Gets wether tonemapping is enabled or not.
  36335. */
  36336. /**
  36337. * Sets wether tonemapping is enabled or not
  36338. */
  36339. toneMappingEnabled: boolean;
  36340. /**
  36341. * Gets contrast used in the effect.
  36342. */
  36343. /**
  36344. * Sets contrast used in the effect.
  36345. */
  36346. contrast: number;
  36347. /**
  36348. * Gets Vignette stretch size.
  36349. */
  36350. /**
  36351. * Sets Vignette stretch size.
  36352. */
  36353. vignetteStretch: number;
  36354. /**
  36355. * Gets Vignette centre X Offset.
  36356. */
  36357. /**
  36358. * Sets Vignette centre X Offset.
  36359. */
  36360. vignetteCentreX: number;
  36361. /**
  36362. * Gets Vignette centre Y Offset.
  36363. */
  36364. /**
  36365. * Sets Vignette centre Y Offset.
  36366. */
  36367. vignetteCentreY: number;
  36368. /**
  36369. * Gets Vignette weight or intensity of the vignette effect.
  36370. */
  36371. /**
  36372. * Sets Vignette weight or intensity of the vignette effect.
  36373. */
  36374. vignetteWeight: number;
  36375. /**
  36376. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  36377. * if vignetteEnabled is set to true.
  36378. */
  36379. /**
  36380. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  36381. * if vignetteEnabled is set to true.
  36382. */
  36383. vignetteColor: Color4;
  36384. /**
  36385. * Gets Camera field of view used by the Vignette effect.
  36386. */
  36387. /**
  36388. * Sets Camera field of view used by the Vignette effect.
  36389. */
  36390. vignetteCameraFov: number;
  36391. /**
  36392. * Gets the vignette blend mode allowing different kind of effect.
  36393. */
  36394. /**
  36395. * Sets the vignette blend mode allowing different kind of effect.
  36396. */
  36397. vignetteBlendMode: number;
  36398. /**
  36399. * Gets wether the vignette effect is enabled.
  36400. */
  36401. /**
  36402. * Sets wether the vignette effect is enabled.
  36403. */
  36404. vignetteEnabled: boolean;
  36405. private _fromLinearSpace;
  36406. /**
  36407. * Gets wether the input of the processing is in Gamma or Linear Space.
  36408. */
  36409. /**
  36410. * Sets wether the input of the processing is in Gamma or Linear Space.
  36411. */
  36412. fromLinearSpace: boolean;
  36413. /**
  36414. * Defines cache preventing GC.
  36415. */
  36416. private _defines;
  36417. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  36418. /**
  36419. * "ImageProcessingPostProcess"
  36420. * @returns "ImageProcessingPostProcess"
  36421. */
  36422. getClassName(): string;
  36423. protected _updateParameters(): void;
  36424. dispose(camera?: Camera): void;
  36425. }
  36426. }
  36427. declare module BABYLON {
  36428. /**
  36429. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  36430. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  36431. * As an example, all you have to do is to create the post-process:
  36432. * var mb = new BABYLON.MotionBlurPostProcess(
  36433. * 'mb', // The name of the effect.
  36434. * scene, // The scene containing the objects to blur according to their velocity.
  36435. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  36436. * camera // The camera to apply the render pass to.
  36437. * );
  36438. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  36439. */
  36440. class MotionBlurPostProcess extends PostProcess {
  36441. /**
  36442. * Defines how much the image is blurred by the movement. Default value is equal to 1
  36443. */
  36444. motionStrength: number;
  36445. /**
  36446. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  36447. */
  36448. /**
  36449. * Sets the number of iterations to be used for motion blur quality
  36450. */
  36451. motionBlurSamples: number;
  36452. private _motionBlurSamples;
  36453. private _geometryBufferRenderer;
  36454. /**
  36455. * Creates a new instance MotionBlurPostProcess
  36456. * @param name The name of the effect.
  36457. * @param scene The scene containing the objects to blur according to their velocity.
  36458. * @param options The required width/height ratio to downsize to before computing the render pass.
  36459. * @param camera The camera to apply the render pass to.
  36460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36461. * @param engine The engine which the post process will be applied. (default: current engine)
  36462. * @param reusable If the post process can be reused on the same frame. (default: false)
  36463. * @param textureType Type of textures used when performing the post process. (default: 0)
  36464. * @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)
  36465. */
  36466. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36467. /**
  36468. * Disposes the post process.
  36469. * @param camera The camera to dispose the post process on.
  36470. */
  36471. dispose(camera?: Camera): void;
  36472. }
  36473. }
  36474. declare module BABYLON {
  36475. /**
  36476. * PassPostProcess which produces an output the same as it's input
  36477. */
  36478. class PassPostProcess extends PostProcess {
  36479. /**
  36480. * Creates the PassPostProcess
  36481. * @param name The name of the effect.
  36482. * @param options The required width/height ratio to downsize to before computing the render pass.
  36483. * @param camera The camera to apply the render pass to.
  36484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36485. * @param engine The engine which the post process will be applied. (default: current engine)
  36486. * @param reusable If the post process can be reused on the same frame. (default: false)
  36487. * @param textureType The type of texture to be used when performing the post processing.
  36488. * @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)
  36489. */
  36490. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36491. }
  36492. /**
  36493. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36494. */
  36495. class PassCubePostProcess extends PostProcess {
  36496. private _face;
  36497. /**
  36498. * Gets or sets the cube face to display.
  36499. * * 0 is +X
  36500. * * 1 is -X
  36501. * * 2 is +Y
  36502. * * 3 is -Y
  36503. * * 4 is +Z
  36504. * * 5 is -Z
  36505. */
  36506. face: number;
  36507. /**
  36508. * Creates the PassCubePostProcess
  36509. * @param name The name of the effect.
  36510. * @param options The required width/height ratio to downsize to before computing the render pass.
  36511. * @param camera The camera to apply the render pass to.
  36512. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36513. * @param engine The engine which the post process will be applied. (default: current engine)
  36514. * @param reusable If the post process can be reused on the same frame. (default: false)
  36515. * @param textureType The type of texture to be used when performing the post processing.
  36516. * @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)
  36517. */
  36518. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36519. }
  36520. }
  36521. declare module BABYLON {
  36522. /**
  36523. * Size options for a post process
  36524. */
  36525. type PostProcessOptions = {
  36526. width: number;
  36527. height: number;
  36528. };
  36529. /**
  36530. * PostProcess can be used to apply a shader to a texture after it has been rendered
  36531. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36532. */
  36533. class PostProcess {
  36534. /** Name of the PostProcess. */
  36535. name: string;
  36536. /**
  36537. * Width of the texture to apply the post process on
  36538. */
  36539. width: number;
  36540. /**
  36541. * Height of the texture to apply the post process on
  36542. */
  36543. height: number;
  36544. /**
  36545. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  36546. * @hidden
  36547. */
  36548. _outputTexture: Nullable<InternalTexture>;
  36549. /**
  36550. * Sampling mode used by the shader
  36551. * See https://doc.babylonjs.com/classes/3.1/texture
  36552. */
  36553. renderTargetSamplingMode: number;
  36554. /**
  36555. * Clear color to use when screen clearing
  36556. */
  36557. clearColor: Color4;
  36558. /**
  36559. * If the buffer needs to be cleared before applying the post process. (default: true)
  36560. * Should be set to false if shader will overwrite all previous pixels.
  36561. */
  36562. autoClear: boolean;
  36563. /**
  36564. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  36565. */
  36566. alphaMode: number;
  36567. /**
  36568. * Sets the setAlphaBlendConstants of the babylon engine
  36569. */
  36570. alphaConstants: Color4;
  36571. /**
  36572. * Animations to be used for the post processing
  36573. */
  36574. animations: Animation[];
  36575. /**
  36576. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  36577. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  36578. */
  36579. enablePixelPerfectMode: boolean;
  36580. /**
  36581. * Force the postprocess to be applied without taking in account viewport
  36582. */
  36583. forceFullscreenViewport: boolean;
  36584. /**
  36585. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  36586. *
  36587. * | Value | Type | Description |
  36588. * | ----- | ----------------------------------- | ----------- |
  36589. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  36590. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  36591. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  36592. *
  36593. */
  36594. scaleMode: number;
  36595. /**
  36596. * Force textures to be a power of two (default: false)
  36597. */
  36598. alwaysForcePOT: boolean;
  36599. private _samples;
  36600. /**
  36601. * Number of sample textures (default: 1)
  36602. */
  36603. samples: number;
  36604. /**
  36605. * Modify the scale of the post process to be the same as the viewport (default: false)
  36606. */
  36607. adaptScaleToCurrentViewport: boolean;
  36608. private _camera;
  36609. private _scene;
  36610. private _engine;
  36611. private _options;
  36612. private _reusable;
  36613. private _textureType;
  36614. /**
  36615. * Smart array of input and output textures for the post process.
  36616. * @hidden
  36617. */
  36618. _textures: SmartArray<InternalTexture>;
  36619. /**
  36620. * The index in _textures that corresponds to the output texture.
  36621. * @hidden
  36622. */
  36623. _currentRenderTextureInd: number;
  36624. private _effect;
  36625. private _samplers;
  36626. private _fragmentUrl;
  36627. private _vertexUrl;
  36628. private _parameters;
  36629. private _scaleRatio;
  36630. protected _indexParameters: any;
  36631. private _shareOutputWithPostProcess;
  36632. private _texelSize;
  36633. private _forcedOutputTexture;
  36634. /**
  36635. * An event triggered when the postprocess is activated.
  36636. */
  36637. onActivateObservable: Observable<Camera>;
  36638. private _onActivateObserver;
  36639. /**
  36640. * A function that is added to the onActivateObservable
  36641. */
  36642. onActivate: Nullable<(camera: Camera) => void>;
  36643. /**
  36644. * An event triggered when the postprocess changes its size.
  36645. */
  36646. onSizeChangedObservable: Observable<PostProcess>;
  36647. private _onSizeChangedObserver;
  36648. /**
  36649. * A function that is added to the onSizeChangedObservable
  36650. */
  36651. onSizeChanged: (postProcess: PostProcess) => void;
  36652. /**
  36653. * An event triggered when the postprocess applies its effect.
  36654. */
  36655. onApplyObservable: Observable<Effect>;
  36656. private _onApplyObserver;
  36657. /**
  36658. * A function that is added to the onApplyObservable
  36659. */
  36660. onApply: (effect: Effect) => void;
  36661. /**
  36662. * An event triggered before rendering the postprocess
  36663. */
  36664. onBeforeRenderObservable: Observable<Effect>;
  36665. private _onBeforeRenderObserver;
  36666. /**
  36667. * A function that is added to the onBeforeRenderObservable
  36668. */
  36669. onBeforeRender: (effect: Effect) => void;
  36670. /**
  36671. * An event triggered after rendering the postprocess
  36672. */
  36673. onAfterRenderObservable: Observable<Effect>;
  36674. private _onAfterRenderObserver;
  36675. /**
  36676. * A function that is added to the onAfterRenderObservable
  36677. */
  36678. onAfterRender: (efect: Effect) => void;
  36679. /**
  36680. * 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
  36681. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  36682. */
  36683. inputTexture: InternalTexture;
  36684. /**
  36685. * Gets the camera which post process is applied to.
  36686. * @returns The camera the post process is applied to.
  36687. */
  36688. getCamera(): Camera;
  36689. /**
  36690. * Gets the texel size of the postprocess.
  36691. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  36692. */
  36693. readonly texelSize: Vector2;
  36694. /**
  36695. * Creates a new instance PostProcess
  36696. * @param name The name of the PostProcess.
  36697. * @param fragmentUrl The url of the fragment shader to be used.
  36698. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  36699. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  36700. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  36701. * @param camera The camera to apply the render pass to.
  36702. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36703. * @param engine The engine which the post process will be applied. (default: current engine)
  36704. * @param reusable If the post process can be reused on the same frame. (default: false)
  36705. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  36706. * @param textureType Type of textures used when performing the post process. (default: 0)
  36707. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  36708. * @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
  36709. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  36710. */
  36711. constructor(
  36712. /** Name of the PostProcess. */
  36713. 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);
  36714. /**
  36715. * Gets the engine which this post process belongs to.
  36716. * @returns The engine the post process was enabled with.
  36717. */
  36718. getEngine(): Engine;
  36719. /**
  36720. * The effect that is created when initializing the post process.
  36721. * @returns The created effect corrisponding the the postprocess.
  36722. */
  36723. getEffect(): Effect;
  36724. /**
  36725. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  36726. * @param postProcess The post process to share the output with.
  36727. * @returns This post process.
  36728. */
  36729. shareOutputWith(postProcess: PostProcess): PostProcess;
  36730. /**
  36731. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  36732. * This should be called if the post process that shares output with this post process is disabled/disposed.
  36733. */
  36734. useOwnOutput(): void;
  36735. /**
  36736. * Updates the effect with the current post process compile time values and recompiles the shader.
  36737. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  36738. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  36739. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  36740. * @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
  36741. * @param onCompiled Called when the shader has been compiled.
  36742. * @param onError Called if there is an error when compiling a shader.
  36743. */
  36744. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  36745. /**
  36746. * The post process is reusable if it can be used multiple times within one frame.
  36747. * @returns If the post process is reusable
  36748. */
  36749. isReusable(): boolean;
  36750. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  36751. markTextureDirty(): void;
  36752. /**
  36753. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  36754. * 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.
  36755. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  36756. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  36757. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  36758. * @returns The target texture that was bound to be written to.
  36759. */
  36760. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  36761. /**
  36762. * If the post process is supported.
  36763. */
  36764. readonly isSupported: boolean;
  36765. /**
  36766. * The aspect ratio of the output texture.
  36767. */
  36768. readonly aspectRatio: number;
  36769. /**
  36770. * Get a value indicating if the post-process is ready to be used
  36771. * @returns true if the post-process is ready (shader is compiled)
  36772. */
  36773. isReady(): boolean;
  36774. /**
  36775. * Binds all textures and uniforms to the shader, this will be run on every pass.
  36776. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  36777. */
  36778. apply(): Nullable<Effect>;
  36779. private _disposeTextures;
  36780. /**
  36781. * Disposes the post process.
  36782. * @param camera The camera to dispose the post process on.
  36783. */
  36784. dispose(camera?: Camera): void;
  36785. }
  36786. }
  36787. declare module BABYLON {
  36788. /**
  36789. * PostProcessManager is used to manage one or more post processes or post process pipelines
  36790. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36791. */
  36792. class PostProcessManager {
  36793. private _scene;
  36794. private _indexBuffer;
  36795. private _vertexBuffers;
  36796. /**
  36797. * Creates a new instance PostProcess
  36798. * @param scene The scene that the post process is associated with.
  36799. */
  36800. constructor(scene: Scene);
  36801. private _prepareBuffers;
  36802. private _buildIndexBuffer;
  36803. /**
  36804. * Rebuilds the vertex buffers of the manager.
  36805. * @hidden
  36806. */
  36807. _rebuild(): void;
  36808. /**
  36809. * Prepares a frame to be run through a post process.
  36810. * @param sourceTexture The input texture to the post procesess. (default: null)
  36811. * @param postProcesses An array of post processes to be run. (default: null)
  36812. * @returns True if the post processes were able to be run.
  36813. * @hidden
  36814. */
  36815. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  36816. /**
  36817. * Manually render a set of post processes to a texture.
  36818. * @param postProcesses An array of post processes to be run.
  36819. * @param targetTexture The target texture to render to.
  36820. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  36821. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  36822. * @param lodLevel defines which lod of the texture to render to
  36823. */
  36824. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  36825. /**
  36826. * Finalize the result of the output of the postprocesses.
  36827. * @param doNotPresent If true the result will not be displayed to the screen.
  36828. * @param targetTexture The target texture to render to.
  36829. * @param faceIndex The index of the face to bind the target texture to.
  36830. * @param postProcesses The array of post processes to render.
  36831. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  36832. * @hidden
  36833. */
  36834. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  36835. /**
  36836. * Disposes of the post process manager.
  36837. */
  36838. dispose(): void;
  36839. }
  36840. }
  36841. declare module BABYLON {
  36842. /**
  36843. * Post process which applies a refractin texture
  36844. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  36845. */
  36846. class RefractionPostProcess extends PostProcess {
  36847. /** the base color of the refraction (used to taint the rendering) */
  36848. color: Color3;
  36849. /** simulated refraction depth */
  36850. depth: number;
  36851. /** the coefficient of the base color (0 to remove base color tainting) */
  36852. colorLevel: number;
  36853. private _refTexture;
  36854. private _ownRefractionTexture;
  36855. /**
  36856. * Gets or sets the refraction texture
  36857. * Please note that you are responsible for disposing the texture if you set it manually
  36858. */
  36859. refractionTexture: Texture;
  36860. /**
  36861. * Initializes the RefractionPostProcess
  36862. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  36863. * @param name The name of the effect.
  36864. * @param refractionTextureUrl Url of the refraction texture to use
  36865. * @param color the base color of the refraction (used to taint the rendering)
  36866. * @param depth simulated refraction depth
  36867. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  36868. * @param camera The camera to apply the render pass to.
  36869. * @param options The required width/height ratio to downsize to before computing the render pass.
  36870. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36871. * @param engine The engine which the post process will be applied. (default: current engine)
  36872. * @param reusable If the post process can be reused on the same frame. (default: false)
  36873. */
  36874. constructor(name: string, refractionTextureUrl: string,
  36875. /** the base color of the refraction (used to taint the rendering) */
  36876. color: Color3,
  36877. /** simulated refraction depth */
  36878. depth: number,
  36879. /** the coefficient of the base color (0 to remove base color tainting) */
  36880. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36881. /**
  36882. * Disposes of the post process
  36883. * @param camera Camera to dispose post process on
  36884. */
  36885. dispose(camera: Camera): void;
  36886. }
  36887. }
  36888. declare module BABYLON {
  36889. /**
  36890. * The SharpenPostProcess applies a sharpen kernel to every pixel
  36891. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  36892. */
  36893. class SharpenPostProcess extends PostProcess {
  36894. /**
  36895. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  36896. */
  36897. colorAmount: number;
  36898. /**
  36899. * How much sharpness should be applied (default: 0.3)
  36900. */
  36901. edgeAmount: number;
  36902. /**
  36903. * Creates a new instance ConvolutionPostProcess
  36904. * @param name The name of the effect.
  36905. * @param options The required width/height ratio to downsize to before computing the render pass.
  36906. * @param camera The camera to apply the render pass to.
  36907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36908. * @param engine The engine which the post process will be applied. (default: current engine)
  36909. * @param reusable If the post process can be reused on the same frame. (default: false)
  36910. * @param textureType Type of textures used when performing the post process. (default: 0)
  36911. * @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)
  36912. */
  36913. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36914. }
  36915. }
  36916. declare module BABYLON {
  36917. /**
  36918. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36919. */
  36920. class StereoscopicInterlacePostProcess extends PostProcess {
  36921. private _stepSize;
  36922. private _passedProcess;
  36923. /**
  36924. * Initializes a StereoscopicInterlacePostProcess
  36925. * @param name The name of the effect.
  36926. * @param rigCameras The rig cameras to be appled to the post process
  36927. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36929. * @param engine The engine which the post process will be applied. (default: current engine)
  36930. * @param reusable If the post process can be reused on the same frame. (default: false)
  36931. */
  36932. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36933. }
  36934. }
  36935. declare module BABYLON {
  36936. /** Defines operator used for tonemapping */
  36937. enum TonemappingOperator {
  36938. /** Hable */
  36939. Hable = 0,
  36940. /** Reinhard */
  36941. Reinhard = 1,
  36942. /** HejiDawson */
  36943. HejiDawson = 2,
  36944. /** Photographic */
  36945. Photographic = 3
  36946. }
  36947. /**
  36948. * Defines a post process to apply tone mapping
  36949. */
  36950. class TonemapPostProcess extends PostProcess {
  36951. private _operator;
  36952. /** Defines the required exposure adjustement */
  36953. exposureAdjustment: number;
  36954. /**
  36955. * Creates a new TonemapPostProcess
  36956. * @param name defines the name of the postprocess
  36957. * @param _operator defines the operator to use
  36958. * @param exposureAdjustment defines the required exposure adjustement
  36959. * @param camera defines the camera to use (can be null)
  36960. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  36961. * @param engine defines the hosting engine (can be ignore if camera is set)
  36962. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  36963. */
  36964. constructor(name: string, _operator: TonemappingOperator,
  36965. /** Defines the required exposure adjustement */
  36966. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  36967. }
  36968. }
  36969. declare module BABYLON {
  36970. /**
  36971. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  36972. */
  36973. class VolumetricLightScatteringPostProcess extends PostProcess {
  36974. private _volumetricLightScatteringPass;
  36975. private _volumetricLightScatteringRTT;
  36976. private _viewPort;
  36977. private _screenCoordinates;
  36978. private _cachedDefines;
  36979. /**
  36980. * If not undefined, the mesh position is computed from the attached node position
  36981. */
  36982. attachedNode: {
  36983. position: Vector3;
  36984. };
  36985. /**
  36986. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  36987. */
  36988. customMeshPosition: Vector3;
  36989. /**
  36990. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  36991. */
  36992. useCustomMeshPosition: boolean;
  36993. /**
  36994. * If the post-process should inverse the light scattering direction
  36995. */
  36996. invert: boolean;
  36997. /**
  36998. * The internal mesh used by the post-process
  36999. */
  37000. mesh: Mesh;
  37001. /**
  37002. * @hidden
  37003. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  37004. */
  37005. useDiffuseColor: boolean;
  37006. /**
  37007. * Array containing the excluded meshes not rendered in the internal pass
  37008. */
  37009. excludedMeshes: AbstractMesh[];
  37010. /**
  37011. * Controls the overall intensity of the post-process
  37012. */
  37013. exposure: number;
  37014. /**
  37015. * Dissipates each sample's contribution in range [0, 1]
  37016. */
  37017. decay: number;
  37018. /**
  37019. * Controls the overall intensity of each sample
  37020. */
  37021. weight: number;
  37022. /**
  37023. * Controls the density of each sample
  37024. */
  37025. density: number;
  37026. /**
  37027. * @constructor
  37028. * @param name The post-process name
  37029. * @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)
  37030. * @param camera The camera that the post-process will be attached to
  37031. * @param mesh The mesh used to create the light scattering
  37032. * @param samples The post-process quality, default 100
  37033. * @param samplingModeThe post-process filtering mode
  37034. * @param engine The babylon engine
  37035. * @param reusable If the post-process is reusable
  37036. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  37037. */
  37038. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  37039. /**
  37040. * Returns the string "VolumetricLightScatteringPostProcess"
  37041. * @returns "VolumetricLightScatteringPostProcess"
  37042. */
  37043. getClassName(): string;
  37044. private _isReady;
  37045. /**
  37046. * Sets the new light position for light scattering effect
  37047. * @param position The new custom light position
  37048. */
  37049. setCustomMeshPosition(position: Vector3): void;
  37050. /**
  37051. * Returns the light position for light scattering effect
  37052. * @return Vector3 The custom light position
  37053. */
  37054. getCustomMeshPosition(): Vector3;
  37055. /**
  37056. * Disposes the internal assets and detaches the post-process from the camera
  37057. */
  37058. dispose(camera: Camera): void;
  37059. /**
  37060. * Returns the render target texture used by the post-process
  37061. * @return the render target texture used by the post-process
  37062. */
  37063. getPass(): RenderTargetTexture;
  37064. private _meshExcluded;
  37065. private _createPass;
  37066. private _updateMeshScreenCoordinates;
  37067. /**
  37068. * Creates a default mesh for the Volumeric Light Scattering post-process
  37069. * @param name The mesh name
  37070. * @param scene The scene where to create the mesh
  37071. * @return the default mesh
  37072. */
  37073. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  37074. }
  37075. }
  37076. declare module BABYLON {
  37077. /**
  37078. * VRDistortionCorrectionPostProcess used for mobile VR
  37079. */
  37080. class VRDistortionCorrectionPostProcess extends PostProcess {
  37081. private _isRightEye;
  37082. private _distortionFactors;
  37083. private _postProcessScaleFactor;
  37084. private _lensCenterOffset;
  37085. private _scaleIn;
  37086. private _scaleFactor;
  37087. private _lensCenter;
  37088. /**
  37089. * Initializes the VRDistortionCorrectionPostProcess
  37090. * @param name The name of the effect.
  37091. * @param camera The camera to apply the render pass to.
  37092. * @param isRightEye If this is for the right eye distortion
  37093. * @param vrMetrics All the required metrics for the VR camera
  37094. */
  37095. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37096. }
  37097. }
  37098. declare module BABYLON {
  37099. /**
  37100. * @hidden
  37101. **/
  37102. class _AlphaState {
  37103. private _isAlphaBlendDirty;
  37104. private _isBlendFunctionParametersDirty;
  37105. private _isBlendEquationParametersDirty;
  37106. private _isBlendConstantsDirty;
  37107. private _alphaBlend;
  37108. private _blendFunctionParameters;
  37109. private _blendEquationParameters;
  37110. private _blendConstants;
  37111. /**
  37112. * Initializes the state.
  37113. */
  37114. constructor();
  37115. readonly isDirty: boolean;
  37116. alphaBlend: boolean;
  37117. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  37118. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  37119. setAlphaEquationParameters(rgb: number, alpha: number): void;
  37120. reset(): void;
  37121. apply(gl: WebGLRenderingContext): void;
  37122. }
  37123. }
  37124. declare module BABYLON {
  37125. /**
  37126. * @hidden
  37127. **/
  37128. class _DepthCullingState {
  37129. private _isDepthTestDirty;
  37130. private _isDepthMaskDirty;
  37131. private _isDepthFuncDirty;
  37132. private _isCullFaceDirty;
  37133. private _isCullDirty;
  37134. private _isZOffsetDirty;
  37135. private _isFrontFaceDirty;
  37136. private _depthTest;
  37137. private _depthMask;
  37138. private _depthFunc;
  37139. private _cull;
  37140. private _cullFace;
  37141. private _zOffset;
  37142. private _frontFace;
  37143. /**
  37144. * Initializes the state.
  37145. */
  37146. constructor();
  37147. readonly isDirty: boolean;
  37148. zOffset: number;
  37149. cullFace: Nullable<number>;
  37150. cull: Nullable<boolean>;
  37151. depthFunc: Nullable<number>;
  37152. depthMask: boolean;
  37153. depthTest: boolean;
  37154. frontFace: Nullable<number>;
  37155. reset(): void;
  37156. apply(gl: WebGLRenderingContext): void;
  37157. }
  37158. }
  37159. declare module BABYLON {
  37160. /**
  37161. * @hidden
  37162. **/
  37163. class _StencilState {
  37164. private _isStencilTestDirty;
  37165. private _isStencilMaskDirty;
  37166. private _isStencilFuncDirty;
  37167. private _isStencilOpDirty;
  37168. private _stencilTest;
  37169. private _stencilMask;
  37170. private _stencilFunc;
  37171. private _stencilFuncRef;
  37172. private _stencilFuncMask;
  37173. private _stencilOpStencilFail;
  37174. private _stencilOpDepthFail;
  37175. private _stencilOpStencilDepthPass;
  37176. readonly isDirty: boolean;
  37177. stencilFunc: number;
  37178. stencilFuncRef: number;
  37179. stencilFuncMask: number;
  37180. stencilOpStencilFail: number;
  37181. stencilOpDepthFail: number;
  37182. stencilOpStencilDepthPass: number;
  37183. stencilMask: number;
  37184. stencilTest: boolean;
  37185. constructor();
  37186. reset(): void;
  37187. apply(gl: WebGLRenderingContext): void;
  37188. }
  37189. }
  37190. declare module BABYLON {
  37191. /**
  37192. * Class used to evalaute queries containing `and` and `or` operators
  37193. */
  37194. class AndOrNotEvaluator {
  37195. /**
  37196. * Evaluate a query
  37197. * @param query defines the query to evaluate
  37198. * @param evaluateCallback defines the callback used to filter result
  37199. * @returns true if the query matches
  37200. */
  37201. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  37202. private static _HandleParenthesisContent;
  37203. private static _SimplifyNegation;
  37204. }
  37205. }
  37206. declare module BABYLON {
  37207. /**
  37208. * Defines the list of states available for a task inside a AssetsManager
  37209. */
  37210. enum AssetTaskState {
  37211. /**
  37212. * Initialization
  37213. */
  37214. INIT = 0,
  37215. /**
  37216. * Running
  37217. */
  37218. RUNNING = 1,
  37219. /**
  37220. * Done
  37221. */
  37222. DONE = 2,
  37223. /**
  37224. * Error
  37225. */
  37226. ERROR = 3
  37227. }
  37228. /**
  37229. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  37230. */
  37231. abstract class AbstractAssetTask {
  37232. /**
  37233. * Task name
  37234. */ name: string;
  37235. /**
  37236. * Callback called when the task is successful
  37237. */
  37238. onSuccess: (task: any) => void;
  37239. /**
  37240. * Callback called when the task is not successful
  37241. */
  37242. onError: (task: any, message?: string, exception?: any) => void;
  37243. /**
  37244. * Creates a new AssetsManager
  37245. * @param name defines the name of the task
  37246. */
  37247. constructor(
  37248. /**
  37249. * Task name
  37250. */ name: string);
  37251. private _isCompleted;
  37252. private _taskState;
  37253. private _errorObject;
  37254. /**
  37255. * Get if the task is completed
  37256. */
  37257. readonly isCompleted: boolean;
  37258. /**
  37259. * Gets the current state of the task
  37260. */
  37261. readonly taskState: AssetTaskState;
  37262. /**
  37263. * Gets the current error object (if task is in error)
  37264. */
  37265. readonly errorObject: {
  37266. message?: string;
  37267. exception?: any;
  37268. };
  37269. /**
  37270. * Internal only
  37271. * @hidden
  37272. */
  37273. _setErrorObject(message?: string, exception?: any): void;
  37274. /**
  37275. * Execute the current task
  37276. * @param scene defines the scene where you want your assets to be loaded
  37277. * @param onSuccess is a callback called when the task is successfully executed
  37278. * @param onError is a callback called if an error occurs
  37279. */
  37280. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37281. /**
  37282. * Execute the current task
  37283. * @param scene defines the scene where you want your assets to be loaded
  37284. * @param onSuccess is a callback called when the task is successfully executed
  37285. * @param onError is a callback called if an error occurs
  37286. */
  37287. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37288. /**
  37289. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  37290. * This can be used with failed tasks that have the reason for failure fixed.
  37291. */
  37292. reset(): void;
  37293. private onErrorCallback;
  37294. private onDoneCallback;
  37295. }
  37296. /**
  37297. * Define the interface used by progress events raised during assets loading
  37298. */
  37299. interface IAssetsProgressEvent {
  37300. /**
  37301. * Defines the number of remaining tasks to process
  37302. */
  37303. remainingCount: number;
  37304. /**
  37305. * Defines the total number of tasks
  37306. */
  37307. totalCount: number;
  37308. /**
  37309. * Defines the task that was just processed
  37310. */
  37311. task: AbstractAssetTask;
  37312. }
  37313. /**
  37314. * Class used to share progress information about assets loading
  37315. */
  37316. class AssetsProgressEvent implements IAssetsProgressEvent {
  37317. /**
  37318. * Defines the number of remaining tasks to process
  37319. */
  37320. remainingCount: number;
  37321. /**
  37322. * Defines the total number of tasks
  37323. */
  37324. totalCount: number;
  37325. /**
  37326. * Defines the task that was just processed
  37327. */
  37328. task: AbstractAssetTask;
  37329. /**
  37330. * Creates a AssetsProgressEvent
  37331. * @param remainingCount defines the number of remaining tasks to process
  37332. * @param totalCount defines the total number of tasks
  37333. * @param task defines the task that was just processed
  37334. */
  37335. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  37336. }
  37337. /**
  37338. * Define a task used by AssetsManager to load meshes
  37339. */
  37340. class MeshAssetTask extends AbstractAssetTask {
  37341. /**
  37342. * Defines the name of the task
  37343. */
  37344. name: string;
  37345. /**
  37346. * Defines the list of mesh's names you want to load
  37347. */
  37348. meshesNames: any;
  37349. /**
  37350. * Defines the root url to use as a base to load your meshes and associated resources
  37351. */
  37352. rootUrl: string;
  37353. /**
  37354. * Defines the filename of the scene to load from
  37355. */
  37356. sceneFilename: string;
  37357. /**
  37358. * Gets the list of loaded meshes
  37359. */
  37360. loadedMeshes: Array<AbstractMesh>;
  37361. /**
  37362. * Gets the list of loaded particle systems
  37363. */
  37364. loadedParticleSystems: Array<IParticleSystem>;
  37365. /**
  37366. * Gets the list of loaded skeletons
  37367. */
  37368. loadedSkeletons: Array<Skeleton>;
  37369. /**
  37370. * Callback called when the task is successful
  37371. */
  37372. onSuccess: (task: MeshAssetTask) => void;
  37373. /**
  37374. * Callback called when the task is successful
  37375. */
  37376. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  37377. /**
  37378. * Creates a new MeshAssetTask
  37379. * @param name defines the name of the task
  37380. * @param meshesNames defines the list of mesh's names you want to load
  37381. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  37382. * @param sceneFilename defines the filename of the scene to load from
  37383. */
  37384. constructor(
  37385. /**
  37386. * Defines the name of the task
  37387. */
  37388. name: string,
  37389. /**
  37390. * Defines the list of mesh's names you want to load
  37391. */
  37392. meshesNames: any,
  37393. /**
  37394. * Defines the root url to use as a base to load your meshes and associated resources
  37395. */
  37396. rootUrl: string,
  37397. /**
  37398. * Defines the filename of the scene to load from
  37399. */
  37400. sceneFilename: string);
  37401. /**
  37402. * Execute the current task
  37403. * @param scene defines the scene where you want your assets to be loaded
  37404. * @param onSuccess is a callback called when the task is successfully executed
  37405. * @param onError is a callback called if an error occurs
  37406. */
  37407. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37408. }
  37409. /**
  37410. * Define a task used by AssetsManager to load text content
  37411. */
  37412. class TextFileAssetTask extends AbstractAssetTask {
  37413. /**
  37414. * Defines the name of the task
  37415. */
  37416. name: string;
  37417. /**
  37418. * Defines the location of the file to load
  37419. */
  37420. url: string;
  37421. /**
  37422. * Gets the loaded text string
  37423. */
  37424. text: string;
  37425. /**
  37426. * Callback called when the task is successful
  37427. */
  37428. onSuccess: (task: TextFileAssetTask) => void;
  37429. /**
  37430. * Callback called when the task is successful
  37431. */
  37432. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  37433. /**
  37434. * Creates a new TextFileAssetTask object
  37435. * @param name defines the name of the task
  37436. * @param url defines the location of the file to load
  37437. */
  37438. constructor(
  37439. /**
  37440. * Defines the name of the task
  37441. */
  37442. name: string,
  37443. /**
  37444. * Defines the location of the file to load
  37445. */
  37446. url: string);
  37447. /**
  37448. * Execute the current task
  37449. * @param scene defines the scene where you want your assets to be loaded
  37450. * @param onSuccess is a callback called when the task is successfully executed
  37451. * @param onError is a callback called if an error occurs
  37452. */
  37453. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37454. }
  37455. /**
  37456. * Define a task used by AssetsManager to load binary data
  37457. */
  37458. class BinaryFileAssetTask extends AbstractAssetTask {
  37459. /**
  37460. * Defines the name of the task
  37461. */
  37462. name: string;
  37463. /**
  37464. * Defines the location of the file to load
  37465. */
  37466. url: string;
  37467. /**
  37468. * Gets the lodaded data (as an array buffer)
  37469. */
  37470. data: ArrayBuffer;
  37471. /**
  37472. * Callback called when the task is successful
  37473. */
  37474. onSuccess: (task: BinaryFileAssetTask) => void;
  37475. /**
  37476. * Callback called when the task is successful
  37477. */
  37478. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37479. /**
  37480. * Creates a new BinaryFileAssetTask object
  37481. * @param name defines the name of the new task
  37482. * @param url defines the location of the file to load
  37483. */
  37484. constructor(
  37485. /**
  37486. * Defines the name of the task
  37487. */
  37488. name: string,
  37489. /**
  37490. * Defines the location of the file to load
  37491. */
  37492. url: string);
  37493. /**
  37494. * Execute the current task
  37495. * @param scene defines the scene where you want your assets to be loaded
  37496. * @param onSuccess is a callback called when the task is successfully executed
  37497. * @param onError is a callback called if an error occurs
  37498. */
  37499. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37500. }
  37501. /**
  37502. * Define a task used by AssetsManager to load images
  37503. */
  37504. class ImageAssetTask extends AbstractAssetTask {
  37505. /**
  37506. * Defines the name of the task
  37507. */
  37508. name: string;
  37509. /**
  37510. * Defines the location of the image to load
  37511. */
  37512. url: string;
  37513. /**
  37514. * Gets the loaded images
  37515. */
  37516. image: HTMLImageElement;
  37517. /**
  37518. * Callback called when the task is successful
  37519. */
  37520. onSuccess: (task: ImageAssetTask) => void;
  37521. /**
  37522. * Callback called when the task is successful
  37523. */
  37524. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37525. /**
  37526. * Creates a new ImageAssetTask
  37527. * @param name defines the name of the task
  37528. * @param url defines the location of the image to load
  37529. */
  37530. constructor(
  37531. /**
  37532. * Defines the name of the task
  37533. */
  37534. name: string,
  37535. /**
  37536. * Defines the location of the image to load
  37537. */
  37538. url: string);
  37539. /**
  37540. * Execute the current task
  37541. * @param scene defines the scene where you want your assets to be loaded
  37542. * @param onSuccess is a callback called when the task is successfully executed
  37543. * @param onError is a callback called if an error occurs
  37544. */
  37545. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37546. }
  37547. /**
  37548. * Defines the interface used by texture loading tasks
  37549. */
  37550. interface ITextureAssetTask<TEX extends BaseTexture> {
  37551. /**
  37552. * Gets the loaded texture
  37553. */
  37554. texture: TEX;
  37555. }
  37556. /**
  37557. * Define a task used by AssetsManager to load 2D textures
  37558. */
  37559. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37560. /**
  37561. * Defines the name of the task
  37562. */
  37563. name: string;
  37564. /**
  37565. * Defines the location of the file to load
  37566. */
  37567. url: string;
  37568. /**
  37569. * Defines if mipmap should not be generated (default is false)
  37570. */
  37571. noMipmap?: boolean | undefined;
  37572. /**
  37573. * Defines if texture must be inverted on Y axis (default is false)
  37574. */
  37575. invertY?: boolean | undefined;
  37576. /**
  37577. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37578. */
  37579. samplingMode: number;
  37580. /**
  37581. * Gets the loaded texture
  37582. */
  37583. texture: Texture;
  37584. /**
  37585. * Callback called when the task is successful
  37586. */
  37587. onSuccess: (task: TextureAssetTask) => void;
  37588. /**
  37589. * Callback called when the task is successful
  37590. */
  37591. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37592. /**
  37593. * Creates a new TextureAssetTask object
  37594. * @param name defines the name of the task
  37595. * @param url defines the location of the file to load
  37596. * @param noMipmap defines if mipmap should not be generated (default is false)
  37597. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37598. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37599. */
  37600. constructor(
  37601. /**
  37602. * Defines the name of the task
  37603. */
  37604. name: string,
  37605. /**
  37606. * Defines the location of the file to load
  37607. */
  37608. url: string,
  37609. /**
  37610. * Defines if mipmap should not be generated (default is false)
  37611. */
  37612. noMipmap?: boolean | undefined,
  37613. /**
  37614. * Defines if texture must be inverted on Y axis (default is false)
  37615. */
  37616. invertY?: boolean | undefined,
  37617. /**
  37618. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37619. */
  37620. samplingMode?: number);
  37621. /**
  37622. * Execute the current task
  37623. * @param scene defines the scene where you want your assets to be loaded
  37624. * @param onSuccess is a callback called when the task is successfully executed
  37625. * @param onError is a callback called if an error occurs
  37626. */
  37627. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37628. }
  37629. /**
  37630. * Define a task used by AssetsManager to load cube textures
  37631. */
  37632. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37633. /**
  37634. * Defines the name of the task
  37635. */
  37636. name: string;
  37637. /**
  37638. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37639. */
  37640. url: string;
  37641. /**
  37642. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37643. */
  37644. extensions?: string[] | undefined;
  37645. /**
  37646. * Defines if mipmaps should not be generated (default is false)
  37647. */
  37648. noMipmap?: boolean | undefined;
  37649. /**
  37650. * Defines the explicit list of files (undefined by default)
  37651. */
  37652. files?: string[] | undefined;
  37653. /**
  37654. * Gets the loaded texture
  37655. */
  37656. texture: CubeTexture;
  37657. /**
  37658. * Callback called when the task is successful
  37659. */
  37660. onSuccess: (task: CubeTextureAssetTask) => void;
  37661. /**
  37662. * Callback called when the task is successful
  37663. */
  37664. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37665. /**
  37666. * Creates a new CubeTextureAssetTask
  37667. * @param name defines the name of the task
  37668. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37669. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37670. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37671. * @param files defines the explicit list of files (undefined by default)
  37672. */
  37673. constructor(
  37674. /**
  37675. * Defines the name of the task
  37676. */
  37677. name: string,
  37678. /**
  37679. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37680. */
  37681. url: string,
  37682. /**
  37683. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37684. */
  37685. extensions?: string[] | undefined,
  37686. /**
  37687. * Defines if mipmaps should not be generated (default is false)
  37688. */
  37689. noMipmap?: boolean | undefined,
  37690. /**
  37691. * Defines the explicit list of files (undefined by default)
  37692. */
  37693. files?: string[] | undefined);
  37694. /**
  37695. * Execute the current task
  37696. * @param scene defines the scene where you want your assets to be loaded
  37697. * @param onSuccess is a callback called when the task is successfully executed
  37698. * @param onError is a callback called if an error occurs
  37699. */
  37700. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37701. }
  37702. /**
  37703. * Define a task used by AssetsManager to load HDR cube textures
  37704. */
  37705. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37706. /**
  37707. * Defines the name of the task
  37708. */
  37709. name: string;
  37710. /**
  37711. * Defines the location of the file to load
  37712. */
  37713. url: string;
  37714. /**
  37715. * Defines the desired size (the more it increases the longer the generation will be)
  37716. */
  37717. size: number;
  37718. /**
  37719. * Defines if mipmaps should not be generated (default is false)
  37720. */
  37721. noMipmap: boolean;
  37722. /**
  37723. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37724. */
  37725. generateHarmonics: boolean;
  37726. /**
  37727. * 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)
  37728. */
  37729. gammaSpace: boolean;
  37730. /**
  37731. * Internal Use Only
  37732. */
  37733. reserved: boolean;
  37734. /**
  37735. * Gets the loaded texture
  37736. */
  37737. texture: HDRCubeTexture;
  37738. /**
  37739. * Callback called when the task is successful
  37740. */
  37741. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37742. /**
  37743. * Callback called when the task is successful
  37744. */
  37745. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37746. /**
  37747. * Creates a new HDRCubeTextureAssetTask object
  37748. * @param name defines the name of the task
  37749. * @param url defines the location of the file to load
  37750. * @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.
  37751. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37752. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37753. * @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)
  37754. * @param reserved Internal use only
  37755. */
  37756. constructor(
  37757. /**
  37758. * Defines the name of the task
  37759. */
  37760. name: string,
  37761. /**
  37762. * Defines the location of the file to load
  37763. */
  37764. url: string,
  37765. /**
  37766. * Defines the desired size (the more it increases the longer the generation will be)
  37767. */
  37768. size: number,
  37769. /**
  37770. * Defines if mipmaps should not be generated (default is false)
  37771. */
  37772. noMipmap?: boolean,
  37773. /**
  37774. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37775. */
  37776. generateHarmonics?: boolean,
  37777. /**
  37778. * 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)
  37779. */
  37780. gammaSpace?: boolean,
  37781. /**
  37782. * Internal Use Only
  37783. */
  37784. reserved?: boolean);
  37785. /**
  37786. * Execute the current task
  37787. * @param scene defines the scene where you want your assets to be loaded
  37788. * @param onSuccess is a callback called when the task is successfully executed
  37789. * @param onError is a callback called if an error occurs
  37790. */
  37791. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37792. }
  37793. /**
  37794. * This class can be used to easily import assets into a scene
  37795. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37796. */
  37797. class AssetsManager {
  37798. private _scene;
  37799. private _isLoading;
  37800. protected _tasks: AbstractAssetTask[];
  37801. protected _waitingTasksCount: number;
  37802. protected _totalTasksCount: number;
  37803. /**
  37804. * Callback called when all tasks are processed
  37805. */
  37806. onFinish: (tasks: AbstractAssetTask[]) => void;
  37807. /**
  37808. * Callback called when a task is successful
  37809. */
  37810. onTaskSuccess: (task: AbstractAssetTask) => void;
  37811. /**
  37812. * Callback called when a task had an error
  37813. */
  37814. onTaskError: (task: AbstractAssetTask) => void;
  37815. /**
  37816. * Callback called when a task is done (whatever the result is)
  37817. */
  37818. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37819. /**
  37820. * Observable called when all tasks are processed
  37821. */
  37822. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37823. /**
  37824. * Observable called when a task had an error
  37825. */
  37826. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37827. /**
  37828. * Observable called when a task is successful
  37829. */
  37830. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37831. /**
  37832. * Observable called when a task is done (whatever the result is)
  37833. */
  37834. onProgressObservable: Observable<IAssetsProgressEvent>;
  37835. /**
  37836. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37837. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37838. */
  37839. useDefaultLoadingScreen: boolean;
  37840. /**
  37841. * Creates a new AssetsManager
  37842. * @param scene defines the scene to work on
  37843. */
  37844. constructor(scene: Scene);
  37845. /**
  37846. * Add a MeshAssetTask to the list of active tasks
  37847. * @param taskName defines the name of the new task
  37848. * @param meshesNames defines the name of meshes to load
  37849. * @param rootUrl defines the root url to use to locate files
  37850. * @param sceneFilename defines the filename of the scene file
  37851. * @returns a new MeshAssetTask object
  37852. */
  37853. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37854. /**
  37855. * Add a TextFileAssetTask to the list of active tasks
  37856. * @param taskName defines the name of the new task
  37857. * @param url defines the url of the file to load
  37858. * @returns a new TextFileAssetTask object
  37859. */
  37860. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37861. /**
  37862. * Add a BinaryFileAssetTask to the list of active tasks
  37863. * @param taskName defines the name of the new task
  37864. * @param url defines the url of the file to load
  37865. * @returns a new BinaryFileAssetTask object
  37866. */
  37867. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37868. /**
  37869. * Add a ImageAssetTask to the list of active tasks
  37870. * @param taskName defines the name of the new task
  37871. * @param url defines the url of the file to load
  37872. * @returns a new ImageAssetTask object
  37873. */
  37874. addImageTask(taskName: string, url: string): ImageAssetTask;
  37875. /**
  37876. * Add a TextureAssetTask to the list of active tasks
  37877. * @param taskName defines the name of the new task
  37878. * @param url defines the url of the file to load
  37879. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37880. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37881. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37882. * @returns a new TextureAssetTask object
  37883. */
  37884. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37885. /**
  37886. * Add a CubeTextureAssetTask to the list of active tasks
  37887. * @param taskName defines the name of the new task
  37888. * @param url defines the url of the file to load
  37889. * @param extensions defines the extension to use to load the cube map (can be null)
  37890. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37891. * @param files defines the list of files to load (can be null)
  37892. * @returns a new CubeTextureAssetTask object
  37893. */
  37894. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  37895. /**
  37896. *
  37897. * Add a HDRCubeTextureAssetTask to the list of active tasks
  37898. * @param taskName defines the name of the new task
  37899. * @param url defines the url of the file to load
  37900. * @param size defines the size you want for the cubemap (can be null)
  37901. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37902. * @param generateHarmonics defines if you want to automatically generate (true by default)
  37903. * @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)
  37904. * @param reserved Internal use only
  37905. * @returns a new HDRCubeTextureAssetTask object
  37906. */
  37907. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  37908. /**
  37909. * Remove a task from the assets manager.
  37910. * @param task the task to remove
  37911. */
  37912. removeTask(task: AbstractAssetTask): void;
  37913. private _decreaseWaitingTasksCount;
  37914. private _runTask;
  37915. /**
  37916. * Reset the AssetsManager and remove all tasks
  37917. * @return the current instance of the AssetsManager
  37918. */
  37919. reset(): AssetsManager;
  37920. /**
  37921. * Start the loading process
  37922. * @return the current instance of the AssetsManager
  37923. */
  37924. load(): AssetsManager;
  37925. }
  37926. }
  37927. declare module BABYLON {
  37928. /**
  37929. * Direct draw surface info
  37930. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  37931. */
  37932. interface DDSInfo {
  37933. /**
  37934. * Width of the texture
  37935. */
  37936. width: number;
  37937. /**
  37938. * Width of the texture
  37939. */
  37940. height: number;
  37941. /**
  37942. * Number of Mipmaps for the texture
  37943. * @see https://en.wikipedia.org/wiki/Mipmap
  37944. */
  37945. mipmapCount: number;
  37946. /**
  37947. * If the textures format is a known fourCC format
  37948. * @see https://www.fourcc.org/
  37949. */
  37950. isFourCC: boolean;
  37951. /**
  37952. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  37953. */
  37954. isRGB: boolean;
  37955. /**
  37956. * If the texture is a lumincance format
  37957. */
  37958. isLuminance: boolean;
  37959. /**
  37960. * If this is a cube texture
  37961. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  37962. */
  37963. isCube: boolean;
  37964. /**
  37965. * If the texture is a compressed format eg. FOURCC_DXT1
  37966. */
  37967. isCompressed: boolean;
  37968. /**
  37969. * The dxgiFormat of the texture
  37970. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  37971. */
  37972. dxgiFormat: number;
  37973. /**
  37974. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  37975. */
  37976. textureType: number;
  37977. /**
  37978. * Sphericle polynomial created for the dds texture
  37979. */
  37980. sphericalPolynomial?: SphericalPolynomial;
  37981. }
  37982. /**
  37983. * Class used to provide DDS decompression tools
  37984. */
  37985. class DDSTools {
  37986. /**
  37987. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  37988. */
  37989. static StoreLODInAlphaChannel: boolean;
  37990. /**
  37991. * Gets DDS information from an array buffer
  37992. * @param arrayBuffer defines the array buffer to read data from
  37993. * @returns the DDS information
  37994. */
  37995. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  37996. private static _FloatView;
  37997. private static _Int32View;
  37998. private static _ToHalfFloat;
  37999. private static _FromHalfFloat;
  38000. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  38001. private static _GetHalfFloatRGBAArrayBuffer;
  38002. private static _GetFloatRGBAArrayBuffer;
  38003. private static _GetFloatAsUIntRGBAArrayBuffer;
  38004. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  38005. private static _GetRGBAArrayBuffer;
  38006. private static _ExtractLongWordOrder;
  38007. private static _GetRGBArrayBuffer;
  38008. private static _GetLuminanceArrayBuffer;
  38009. /**
  38010. * Uploads DDS Levels to a Babylon Texture
  38011. * @hidden
  38012. */
  38013. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  38014. }
  38015. }
  38016. declare module BABYLON {
  38017. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38018. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38019. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38020. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38021. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38022. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38023. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38024. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38025. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38026. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38027. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38028. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38029. /**
  38030. * Decorator used to define property that can be serialized as reference to a camera
  38031. * @param sourceName defines the name of the property to decorate
  38032. */
  38033. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38034. /**
  38035. * Class used to help serialization objects
  38036. */
  38037. class SerializationHelper {
  38038. /**
  38039. * Static function used to serialized a specific entity
  38040. * @param entity defines the entity to serialize
  38041. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38042. * @returns a JSON compatible object representing the serialization of the entity
  38043. */
  38044. static Serialize<T>(entity: T, serializationObject?: any): any;
  38045. /**
  38046. * Creates a new entity from a serialization data object
  38047. * @param creationFunction defines a function used to instanciated the new entity
  38048. * @param source defines the source serialization data
  38049. * @param scene defines the hosting scene
  38050. * @param rootUrl defines the root url for resources
  38051. * @returns a new entity
  38052. */
  38053. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38054. /**
  38055. * Clones an object
  38056. * @param creationFunction defines the function used to instanciate the new object
  38057. * @param source defines the source object
  38058. * @returns the cloned object
  38059. */
  38060. static Clone<T>(creationFunction: () => T, source: T): T;
  38061. /**
  38062. * Instanciates a new object based on a source one (some data will be shared between both object)
  38063. * @param creationFunction defines the function used to instanciate the new object
  38064. * @param source defines the source object
  38065. * @returns the new object
  38066. */
  38067. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38068. }
  38069. }
  38070. declare module BABYLON {
  38071. /**
  38072. * Wrapper class for promise with external resolve and reject.
  38073. */
  38074. class Deferred<T> {
  38075. /**
  38076. * The promise associated with this deferred object.
  38077. */
  38078. readonly promise: Promise<T>;
  38079. private _resolve;
  38080. private _reject;
  38081. /**
  38082. * The resolve method of the promise associated with this deferred object.
  38083. */
  38084. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  38085. /**
  38086. * The reject method of the promise associated with this deferred object.
  38087. */
  38088. readonly reject: (reason?: any) => void;
  38089. /**
  38090. * Constructor for this deferred object.
  38091. */
  38092. constructor();
  38093. }
  38094. }
  38095. declare module BABYLON {
  38096. /**
  38097. * Raw texture data and descriptor sufficient for WebGL texture upload
  38098. */
  38099. interface EnvironmentTextureInfo {
  38100. /**
  38101. * Version of the environment map
  38102. */
  38103. version: number;
  38104. /**
  38105. * Width of image
  38106. */
  38107. width: number;
  38108. /**
  38109. * Irradiance information stored in the file.
  38110. */
  38111. irradiance: any;
  38112. /**
  38113. * Specular information stored in the file.
  38114. */
  38115. specular: any;
  38116. }
  38117. /**
  38118. * Sets of helpers addressing the serialization and deserialization of environment texture
  38119. * stored in a BabylonJS env file.
  38120. * Those files are usually stored as .env files.
  38121. */
  38122. class EnvironmentTextureTools {
  38123. /**
  38124. * Magic number identifying the env file.
  38125. */
  38126. private static _MagicBytes;
  38127. /**
  38128. * Gets the environment info from an env file.
  38129. * @param data The array buffer containing the .env bytes.
  38130. * @returns the environment file info (the json header) if successfully parsed.
  38131. */
  38132. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  38133. /**
  38134. * Creates an environment texture from a loaded cube texture.
  38135. * @param texture defines the cube texture to convert in env file
  38136. * @return a promise containing the environment data if succesfull.
  38137. */
  38138. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  38139. /**
  38140. * Creates a JSON representation of the spherical data.
  38141. * @param texture defines the texture containing the polynomials
  38142. * @return the JSON representation of the spherical info
  38143. */
  38144. private static _CreateEnvTextureIrradiance;
  38145. /**
  38146. * Uploads the texture info contained in the env file to the GPU.
  38147. * @param texture defines the internal texture to upload to
  38148. * @param arrayBuffer defines the buffer cotaining the data to load
  38149. * @param info defines the texture info retrieved through the GetEnvInfo method
  38150. * @returns a promise
  38151. */
  38152. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  38153. /**
  38154. * Uploads the levels of image data to the GPU.
  38155. * @param texture defines the internal texture to upload to
  38156. * @param imageData defines the array buffer views of image data [mipmap][face]
  38157. * @returns a promise
  38158. */
  38159. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  38160. /**
  38161. * Uploads spherical polynomials information to the texture.
  38162. * @param texture defines the texture we are trying to upload the information to
  38163. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  38164. */
  38165. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  38166. }
  38167. }
  38168. declare module BABYLON {
  38169. /**
  38170. * Class used to help managing file picking and drag'n'drop
  38171. */
  38172. class FilesInput {
  38173. /**
  38174. * List of files ready to be loaded
  38175. */
  38176. static FilesToLoad: {
  38177. [key: string]: File;
  38178. };
  38179. /**
  38180. * Callback called when a file is processed
  38181. */
  38182. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  38183. private _engine;
  38184. private _currentScene;
  38185. private _sceneLoadedCallback;
  38186. private _progressCallback;
  38187. private _additionalRenderLoopLogicCallback;
  38188. private _textureLoadingCallback;
  38189. private _startingProcessingFilesCallback;
  38190. private _onReloadCallback;
  38191. private _errorCallback;
  38192. private _elementToMonitor;
  38193. private _sceneFileToLoad;
  38194. private _filesToLoad;
  38195. /**
  38196. * Creates a new FilesInput
  38197. * @param engine defines the rendering engine
  38198. * @param scene defines the hosting scene
  38199. * @param sceneLoadedCallback callback called when scene is loaded
  38200. * @param progressCallback callback called to track progress
  38201. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  38202. * @param textureLoadingCallback callback called when a texture is loading
  38203. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  38204. * @param onReloadCallback callback called when a reload is requested
  38205. * @param errorCallback callback call if an error occurs
  38206. */
  38207. 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);
  38208. private _dragEnterHandler;
  38209. private _dragOverHandler;
  38210. private _dropHandler;
  38211. /**
  38212. * Calls this function to listen to drag'n'drop events on a specific DOM element
  38213. * @param elementToMonitor defines the DOM element to track
  38214. */
  38215. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  38216. /**
  38217. * Release all associated resources
  38218. */
  38219. dispose(): void;
  38220. private renderFunction;
  38221. private drag;
  38222. private drop;
  38223. private _traverseFolder;
  38224. private _processFiles;
  38225. /**
  38226. * Load files from a drop event
  38227. * @param event defines the drop event to use as source
  38228. */
  38229. loadFiles(event: any): void;
  38230. private _processReload;
  38231. /**
  38232. * Reload the current scene from the loaded files
  38233. */
  38234. reload(): void;
  38235. }
  38236. }
  38237. declare module BABYLON {
  38238. /**
  38239. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  38240. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  38241. */
  38242. class KhronosTextureContainer {
  38243. /** contents of the KTX container file */
  38244. arrayBuffer: any;
  38245. private static HEADER_LEN;
  38246. private static COMPRESSED_2D;
  38247. private static COMPRESSED_3D;
  38248. private static TEX_2D;
  38249. private static TEX_3D;
  38250. /**
  38251. * Gets the openGL type
  38252. */
  38253. glType: number;
  38254. /**
  38255. * Gets the openGL type size
  38256. */
  38257. glTypeSize: number;
  38258. /**
  38259. * Gets the openGL format
  38260. */
  38261. glFormat: number;
  38262. /**
  38263. * Gets the openGL internal format
  38264. */
  38265. glInternalFormat: number;
  38266. /**
  38267. * Gets the base internal format
  38268. */
  38269. glBaseInternalFormat: number;
  38270. /**
  38271. * Gets image width in pixel
  38272. */
  38273. pixelWidth: number;
  38274. /**
  38275. * Gets image height in pixel
  38276. */
  38277. pixelHeight: number;
  38278. /**
  38279. * Gets image depth in pixels
  38280. */
  38281. pixelDepth: number;
  38282. /**
  38283. * Gets the number of array elements
  38284. */
  38285. numberOfArrayElements: number;
  38286. /**
  38287. * Gets the number of faces
  38288. */
  38289. numberOfFaces: number;
  38290. /**
  38291. * Gets the number of mipmap levels
  38292. */
  38293. numberOfMipmapLevels: number;
  38294. /**
  38295. * Gets the bytes of key value data
  38296. */
  38297. bytesOfKeyValueData: number;
  38298. /**
  38299. * Gets the load type
  38300. */
  38301. loadType: number;
  38302. /**
  38303. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  38304. */
  38305. isInvalid: boolean;
  38306. /**
  38307. * Creates a new KhronosTextureContainer
  38308. * @param arrayBuffer contents of the KTX container file
  38309. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  38310. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  38311. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  38312. */
  38313. constructor(
  38314. /** contents of the KTX container file */
  38315. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  38316. /**
  38317. * Revert the endianness of a value.
  38318. * Not as fast hardware based, but will probably never need to use
  38319. * @param val defines the value to convert
  38320. * @returns the new value
  38321. */
  38322. switchEndianness(val: number): number;
  38323. /**
  38324. * Uploads KTX content to a Babylon Texture.
  38325. * It is assumed that the texture has already been created & is currently bound
  38326. * @hidden
  38327. */
  38328. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  38329. private _upload2DCompressedLevels;
  38330. }
  38331. }
  38332. declare module BABYLON {
  38333. /**
  38334. * A class serves as a medium between the observable and its observers
  38335. */
  38336. class EventState {
  38337. /**
  38338. * Create a new EventState
  38339. * @param mask defines the mask associated with this state
  38340. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38341. * @param target defines the original target of the state
  38342. * @param currentTarget defines the current target of the state
  38343. */
  38344. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  38345. /**
  38346. * Initialize the current event state
  38347. * @param mask defines the mask associated with this state
  38348. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38349. * @param target defines the original target of the state
  38350. * @param currentTarget defines the current target of the state
  38351. * @returns the current event state
  38352. */
  38353. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  38354. /**
  38355. * An Observer can set this property to true to prevent subsequent observers of being notified
  38356. */
  38357. skipNextObservers: boolean;
  38358. /**
  38359. * Get the mask value that were used to trigger the event corresponding to this EventState object
  38360. */
  38361. mask: number;
  38362. /**
  38363. * The object that originally notified the event
  38364. */
  38365. target?: any;
  38366. /**
  38367. * The current object in the bubbling phase
  38368. */
  38369. currentTarget?: any;
  38370. /**
  38371. * This will be populated with the return value of the last function that was executed.
  38372. * If it is the first function in the callback chain it will be the event data.
  38373. */
  38374. lastReturnValue?: any;
  38375. }
  38376. /**
  38377. * Represent an Observer registered to a given Observable object.
  38378. */
  38379. class Observer<T> {
  38380. /**
  38381. * Defines the callback to call when the observer is notified
  38382. */
  38383. callback: (eventData: T, eventState: EventState) => void;
  38384. /**
  38385. * Defines the mask of the observer (used to filter notifications)
  38386. */
  38387. mask: number;
  38388. /**
  38389. * Defines the current scope used to restore the JS context
  38390. */
  38391. scope: any;
  38392. /** @hidden */
  38393. _willBeUnregistered: boolean;
  38394. /**
  38395. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  38396. */
  38397. unregisterOnNextCall: boolean;
  38398. /**
  38399. * Creates a new observer
  38400. * @param callback defines the callback to call when the observer is notified
  38401. * @param mask defines the mask of the observer (used to filter notifications)
  38402. * @param scope defines the current scope used to restore the JS context
  38403. */
  38404. constructor(
  38405. /**
  38406. * Defines the callback to call when the observer is notified
  38407. */
  38408. callback: (eventData: T, eventState: EventState) => void,
  38409. /**
  38410. * Defines the mask of the observer (used to filter notifications)
  38411. */
  38412. mask: number,
  38413. /**
  38414. * Defines the current scope used to restore the JS context
  38415. */
  38416. scope?: any);
  38417. }
  38418. /**
  38419. * Represent a list of observers registered to multiple Observables object.
  38420. */
  38421. class MultiObserver<T> {
  38422. private _observers;
  38423. private _observables;
  38424. /**
  38425. * Release associated resources
  38426. */
  38427. dispose(): void;
  38428. /**
  38429. * Raise a callback when one of the observable will notify
  38430. * @param observables defines a list of observables to watch
  38431. * @param callback defines the callback to call on notification
  38432. * @param mask defines the mask used to filter notifications
  38433. * @param scope defines the current scope used to restore the JS context
  38434. * @returns the new MultiObserver
  38435. */
  38436. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  38437. }
  38438. /**
  38439. * The Observable class is a simple implementation of the Observable pattern.
  38440. *
  38441. * 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.
  38442. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  38443. * 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).
  38444. * 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.
  38445. */
  38446. class Observable<T> {
  38447. private _observers;
  38448. private _eventState;
  38449. private _onObserverAdded;
  38450. /**
  38451. * Creates a new observable
  38452. * @param onObserverAdded defines a callback to call when a new observer is added
  38453. */
  38454. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  38455. /**
  38456. * Create a new Observer with the specified callback
  38457. * @param callback the callback that will be executed for that Observer
  38458. * @param mask the mask used to filter observers
  38459. * @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.
  38460. * @param scope optional scope for the callback to be called from
  38461. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38462. * @returns the new observer created for the callback
  38463. */
  38464. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38465. /**
  38466. * Create a new Observer with the specified callback and unregisters after the next notification
  38467. * @param callback the callback that will be executed for that Observer
  38468. * @returns the new observer created for the callback
  38469. */
  38470. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38471. /**
  38472. * Remove an Observer from the Observable object
  38473. * @param observer the instance of the Observer to remove
  38474. * @returns false if it doesn't belong to this Observable
  38475. */
  38476. remove(observer: Nullable<Observer<T>>): boolean;
  38477. /**
  38478. * Remove a callback from the Observable object
  38479. * @param callback the callback to remove
  38480. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38481. * @returns false if it doesn't belong to this Observable
  38482. */
  38483. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38484. private _deferUnregister;
  38485. private _remove;
  38486. /**
  38487. * Notify all Observers by calling their respective callback with the given data
  38488. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38489. * @param eventData defines the data to send to all observers
  38490. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38491. * @param target defines the original target of the state
  38492. * @param currentTarget defines the current target of the state
  38493. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38494. */
  38495. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38496. /**
  38497. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38498. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38499. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38500. * and it is crucial that all callbacks will be executed.
  38501. * The order of the callbacks is kept, callbacks are not executed parallel.
  38502. *
  38503. * @param eventData The data to be sent to each callback
  38504. * @param mask is used to filter observers defaults to -1
  38505. * @param target defines the callback target (see EventState)
  38506. * @param currentTarget defines he current object in the bubbling phase
  38507. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38508. */
  38509. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38510. /**
  38511. * Notify a specific observer
  38512. * @param observer defines the observer to notify
  38513. * @param eventData defines the data to be sent to each callback
  38514. * @param mask is used to filter observers defaults to -1
  38515. */
  38516. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38517. /**
  38518. * Gets a boolean indicating if the observable has at least one observer
  38519. * @returns true is the Observable has at least one Observer registered
  38520. */
  38521. hasObservers(): boolean;
  38522. /**
  38523. * Clear the list of observers
  38524. */
  38525. clear(): void;
  38526. /**
  38527. * Clone the current observable
  38528. * @returns a new observable
  38529. */
  38530. clone(): Observable<T>;
  38531. /**
  38532. * Does this observable handles observer registered with a given mask
  38533. * @param mask defines the mask to be tested
  38534. * @return whether or not one observer registered with the given mask is handeled
  38535. **/
  38536. hasSpecificMask(mask?: number): boolean;
  38537. }
  38538. }
  38539. declare module BABYLON {
  38540. /**
  38541. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38542. */
  38543. class PerformanceMonitor {
  38544. private _enabled;
  38545. private _rollingFrameTime;
  38546. private _lastFrameTimeMs;
  38547. /**
  38548. * constructor
  38549. * @param frameSampleSize The number of samples required to saturate the sliding window
  38550. */
  38551. constructor(frameSampleSize?: number);
  38552. /**
  38553. * Samples current frame
  38554. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38555. */
  38556. sampleFrame(timeMs?: number): void;
  38557. /**
  38558. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38559. */
  38560. readonly averageFrameTime: number;
  38561. /**
  38562. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38563. */
  38564. readonly averageFrameTimeVariance: number;
  38565. /**
  38566. * Returns the frame time of the most recent frame
  38567. */
  38568. readonly instantaneousFrameTime: number;
  38569. /**
  38570. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38571. */
  38572. readonly averageFPS: number;
  38573. /**
  38574. * Returns the average framerate in frames per second using the most recent frame time
  38575. */
  38576. readonly instantaneousFPS: number;
  38577. /**
  38578. * Returns true if enough samples have been taken to completely fill the sliding window
  38579. */
  38580. readonly isSaturated: boolean;
  38581. /**
  38582. * Enables contributions to the sliding window sample set
  38583. */
  38584. enable(): void;
  38585. /**
  38586. * Disables contributions to the sliding window sample set
  38587. * Samples will not be interpolated over the disabled period
  38588. */
  38589. disable(): void;
  38590. /**
  38591. * Returns true if sampling is enabled
  38592. */
  38593. readonly isEnabled: boolean;
  38594. /**
  38595. * Resets performance monitor
  38596. */
  38597. reset(): void;
  38598. }
  38599. /**
  38600. * RollingAverage
  38601. *
  38602. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38603. */
  38604. class RollingAverage {
  38605. /**
  38606. * Current average
  38607. */
  38608. average: number;
  38609. /**
  38610. * Current variance
  38611. */
  38612. variance: number;
  38613. protected _samples: Array<number>;
  38614. protected _sampleCount: number;
  38615. protected _pos: number;
  38616. protected _m2: number;
  38617. /**
  38618. * constructor
  38619. * @param length The number of samples required to saturate the sliding window
  38620. */
  38621. constructor(length: number);
  38622. /**
  38623. * Adds a sample to the sample set
  38624. * @param v The sample value
  38625. */
  38626. add(v: number): void;
  38627. /**
  38628. * Returns previously added values or null if outside of history or outside the sliding window domain
  38629. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38630. * @return Value previously recorded with add() or null if outside of range
  38631. */
  38632. history(i: number): number;
  38633. /**
  38634. * Returns true if enough samples have been taken to completely fill the sliding window
  38635. * @return true if sample-set saturated
  38636. */
  38637. isSaturated(): boolean;
  38638. /**
  38639. * Resets the rolling average (equivalent to 0 samples taken so far)
  38640. */
  38641. reset(): void;
  38642. /**
  38643. * Wraps a value around the sample range boundaries
  38644. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38645. * @return Wrapped position in sample range
  38646. */
  38647. protected _wrapPosition(i: number): number;
  38648. }
  38649. }
  38650. declare module BABYLON {
  38651. /**
  38652. * Helper class that provides a small promise polyfill
  38653. */
  38654. class PromisePolyfill {
  38655. /**
  38656. * Static function used to check if the polyfill is required
  38657. * If this is the case then the function will inject the polyfill to window.Promise
  38658. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38659. */
  38660. static Apply(force?: boolean): void;
  38661. }
  38662. }
  38663. declare module BABYLON {
  38664. /**
  38665. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38666. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38667. */
  38668. class SceneOptimization {
  38669. /**
  38670. * Defines the priority of this optimization (0 by default which means first in the list)
  38671. */
  38672. priority: number;
  38673. /**
  38674. * Gets a string describing the action executed by the current optimization
  38675. * @returns description string
  38676. */
  38677. getDescription(): string;
  38678. /**
  38679. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38680. * @param scene defines the current scene where to apply this optimization
  38681. * @param optimizer defines the current optimizer
  38682. * @returns true if everything that can be done was applied
  38683. */
  38684. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38685. /**
  38686. * Creates the SceneOptimization object
  38687. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38688. * @param desc defines the description associated with the optimization
  38689. */
  38690. constructor(
  38691. /**
  38692. * Defines the priority of this optimization (0 by default which means first in the list)
  38693. */
  38694. priority?: number);
  38695. }
  38696. /**
  38697. * Defines an optimization used to reduce the size of render target textures
  38698. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38699. */
  38700. class TextureOptimization extends SceneOptimization {
  38701. /**
  38702. * Defines the priority of this optimization (0 by default which means first in the list)
  38703. */
  38704. priority: number;
  38705. /**
  38706. * 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
  38707. */
  38708. maximumSize: number;
  38709. /**
  38710. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38711. */
  38712. step: number;
  38713. /**
  38714. * Gets a string describing the action executed by the current optimization
  38715. * @returns description string
  38716. */
  38717. getDescription(): string;
  38718. /**
  38719. * Creates the TextureOptimization object
  38720. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38721. * @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
  38722. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38723. */
  38724. constructor(
  38725. /**
  38726. * Defines the priority of this optimization (0 by default which means first in the list)
  38727. */
  38728. priority?: number,
  38729. /**
  38730. * 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
  38731. */
  38732. maximumSize?: number,
  38733. /**
  38734. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38735. */
  38736. step?: number);
  38737. /**
  38738. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38739. * @param scene defines the current scene where to apply this optimization
  38740. * @param optimizer defines the current optimizer
  38741. * @returns true if everything that can be done was applied
  38742. */
  38743. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38744. }
  38745. /**
  38746. * Defines an optimization used to increase or decrease the rendering resolution
  38747. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38748. */
  38749. class HardwareScalingOptimization extends SceneOptimization {
  38750. /**
  38751. * Defines the priority of this optimization (0 by default which means first in the list)
  38752. */
  38753. priority: number;
  38754. /**
  38755. * Defines the maximum scale to use (2 by default)
  38756. */
  38757. maximumScale: number;
  38758. /**
  38759. * Defines the step to use between two passes (0.5 by default)
  38760. */
  38761. step: number;
  38762. private _currentScale;
  38763. private _directionOffset;
  38764. /**
  38765. * Gets a string describing the action executed by the current optimization
  38766. * @return description string
  38767. */
  38768. getDescription(): string;
  38769. /**
  38770. * Creates the HardwareScalingOptimization object
  38771. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38772. * @param maximumScale defines the maximum scale to use (2 by default)
  38773. * @param step defines the step to use between two passes (0.5 by default)
  38774. */
  38775. constructor(
  38776. /**
  38777. * Defines the priority of this optimization (0 by default which means first in the list)
  38778. */
  38779. priority?: number,
  38780. /**
  38781. * Defines the maximum scale to use (2 by default)
  38782. */
  38783. maximumScale?: number,
  38784. /**
  38785. * Defines the step to use between two passes (0.5 by default)
  38786. */
  38787. step?: number);
  38788. /**
  38789. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38790. * @param scene defines the current scene where to apply this optimization
  38791. * @param optimizer defines the current optimizer
  38792. * @returns true if everything that can be done was applied
  38793. */
  38794. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38795. }
  38796. /**
  38797. * Defines an optimization used to remove shadows
  38798. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38799. */
  38800. class ShadowsOptimization extends SceneOptimization {
  38801. /**
  38802. * Gets a string describing the action executed by the current optimization
  38803. * @return description string
  38804. */
  38805. getDescription(): string;
  38806. /**
  38807. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38808. * @param scene defines the current scene where to apply this optimization
  38809. * @param optimizer defines the current optimizer
  38810. * @returns true if everything that can be done was applied
  38811. */
  38812. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38813. }
  38814. /**
  38815. * Defines an optimization used to turn post-processes off
  38816. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38817. */
  38818. class PostProcessesOptimization extends SceneOptimization {
  38819. /**
  38820. * Gets a string describing the action executed by the current optimization
  38821. * @return description string
  38822. */
  38823. getDescription(): string;
  38824. /**
  38825. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38826. * @param scene defines the current scene where to apply this optimization
  38827. * @param optimizer defines the current optimizer
  38828. * @returns true if everything that can be done was applied
  38829. */
  38830. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38831. }
  38832. /**
  38833. * Defines an optimization used to turn lens flares off
  38834. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38835. */
  38836. class LensFlaresOptimization extends SceneOptimization {
  38837. /**
  38838. * Gets a string describing the action executed by the current optimization
  38839. * @return description string
  38840. */
  38841. getDescription(): string;
  38842. /**
  38843. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38844. * @param scene defines the current scene where to apply this optimization
  38845. * @param optimizer defines the current optimizer
  38846. * @returns true if everything that can be done was applied
  38847. */
  38848. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38849. }
  38850. /**
  38851. * Defines an optimization based on user defined callback.
  38852. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38853. */
  38854. class CustomOptimization extends SceneOptimization {
  38855. /**
  38856. * Callback called to apply the custom optimization.
  38857. */
  38858. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38859. /**
  38860. * Callback called to get custom description
  38861. */
  38862. onGetDescription: () => string;
  38863. /**
  38864. * Gets a string describing the action executed by the current optimization
  38865. * @returns description string
  38866. */
  38867. getDescription(): string;
  38868. /**
  38869. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38870. * @param scene defines the current scene where to apply this optimization
  38871. * @param optimizer defines the current optimizer
  38872. * @returns true if everything that can be done was applied
  38873. */
  38874. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38875. }
  38876. /**
  38877. * Defines an optimization used to turn particles off
  38878. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38879. */
  38880. class ParticlesOptimization extends SceneOptimization {
  38881. /**
  38882. * Gets a string describing the action executed by the current optimization
  38883. * @return description string
  38884. */
  38885. getDescription(): string;
  38886. /**
  38887. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38888. * @param scene defines the current scene where to apply this optimization
  38889. * @param optimizer defines the current optimizer
  38890. * @returns true if everything that can be done was applied
  38891. */
  38892. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38893. }
  38894. /**
  38895. * Defines an optimization used to turn render targets off
  38896. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38897. */
  38898. class RenderTargetsOptimization extends SceneOptimization {
  38899. /**
  38900. * Gets a string describing the action executed by the current optimization
  38901. * @return description string
  38902. */
  38903. getDescription(): string;
  38904. /**
  38905. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38906. * @param scene defines the current scene where to apply this optimization
  38907. * @param optimizer defines the current optimizer
  38908. * @returns true if everything that can be done was applied
  38909. */
  38910. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38911. }
  38912. /**
  38913. * Defines an optimization used to merge meshes with compatible materials
  38914. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38915. */
  38916. class MergeMeshesOptimization extends SceneOptimization {
  38917. private static _UpdateSelectionTree;
  38918. /**
  38919. * Gets or sets a boolean which defines if optimization octree has to be updated
  38920. */
  38921. /**
  38922. * Gets or sets a boolean which defines if optimization octree has to be updated
  38923. */
  38924. static UpdateSelectionTree: boolean;
  38925. /**
  38926. * Gets a string describing the action executed by the current optimization
  38927. * @return description string
  38928. */
  38929. getDescription(): string;
  38930. private _canBeMerged;
  38931. /**
  38932. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38933. * @param scene defines the current scene where to apply this optimization
  38934. * @param optimizer defines the current optimizer
  38935. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  38936. * @returns true if everything that can be done was applied
  38937. */
  38938. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  38939. }
  38940. /**
  38941. * Defines a list of options used by SceneOptimizer
  38942. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38943. */
  38944. class SceneOptimizerOptions {
  38945. /**
  38946. * Defines the target frame rate to reach (60 by default)
  38947. */
  38948. targetFrameRate: number;
  38949. /**
  38950. * Defines the interval between two checkes (2000ms by default)
  38951. */
  38952. trackerDuration: number;
  38953. /**
  38954. * Gets the list of optimizations to apply
  38955. */
  38956. optimizations: SceneOptimization[];
  38957. /**
  38958. * Creates a new list of options used by SceneOptimizer
  38959. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  38960. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  38961. */
  38962. constructor(
  38963. /**
  38964. * Defines the target frame rate to reach (60 by default)
  38965. */
  38966. targetFrameRate?: number,
  38967. /**
  38968. * Defines the interval between two checkes (2000ms by default)
  38969. */
  38970. trackerDuration?: number);
  38971. /**
  38972. * Add a new optimization
  38973. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  38974. * @returns the current SceneOptimizerOptions
  38975. */
  38976. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  38977. /**
  38978. * Add a new custom optimization
  38979. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  38980. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  38981. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38982. * @returns the current SceneOptimizerOptions
  38983. */
  38984. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  38985. /**
  38986. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  38987. * @param targetFrameRate defines the target frame rate (60 by default)
  38988. * @returns a SceneOptimizerOptions object
  38989. */
  38990. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38991. /**
  38992. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  38993. * @param targetFrameRate defines the target frame rate (60 by default)
  38994. * @returns a SceneOptimizerOptions object
  38995. */
  38996. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38997. /**
  38998. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  38999. * @param targetFrameRate defines the target frame rate (60 by default)
  39000. * @returns a SceneOptimizerOptions object
  39001. */
  39002. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39003. }
  39004. /**
  39005. * Class used to run optimizations in order to reach a target frame rate
  39006. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39007. */
  39008. class SceneOptimizer implements IDisposable {
  39009. private _isRunning;
  39010. private _options;
  39011. private _scene;
  39012. private _currentPriorityLevel;
  39013. private _targetFrameRate;
  39014. private _trackerDuration;
  39015. private _currentFrameRate;
  39016. private _sceneDisposeObserver;
  39017. private _improvementMode;
  39018. /**
  39019. * Defines an observable called when the optimizer reaches the target frame rate
  39020. */
  39021. onSuccessObservable: Observable<SceneOptimizer>;
  39022. /**
  39023. * Defines an observable called when the optimizer enables an optimization
  39024. */
  39025. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  39026. /**
  39027. * Defines an observable called when the optimizer is not able to reach the target frame rate
  39028. */
  39029. onFailureObservable: Observable<SceneOptimizer>;
  39030. /**
  39031. * Gets a boolean indicating if the optimizer is in improvement mode
  39032. */
  39033. readonly isInImprovementMode: boolean;
  39034. /**
  39035. * Gets the current priority level (0 at start)
  39036. */
  39037. readonly currentPriorityLevel: number;
  39038. /**
  39039. * Gets the current frame rate checked by the SceneOptimizer
  39040. */
  39041. readonly currentFrameRate: number;
  39042. /**
  39043. * Gets or sets the current target frame rate (60 by default)
  39044. */
  39045. /**
  39046. * Gets or sets the current target frame rate (60 by default)
  39047. */
  39048. targetFrameRate: number;
  39049. /**
  39050. * Gets or sets the current interval between two checks (every 2000ms by default)
  39051. */
  39052. /**
  39053. * Gets or sets the current interval between two checks (every 2000ms by default)
  39054. */
  39055. trackerDuration: number;
  39056. /**
  39057. * Gets the list of active optimizations
  39058. */
  39059. readonly optimizations: SceneOptimization[];
  39060. /**
  39061. * Creates a new SceneOptimizer
  39062. * @param scene defines the scene to work on
  39063. * @param options defines the options to use with the SceneOptimizer
  39064. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  39065. * @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)
  39066. */
  39067. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  39068. /**
  39069. * Stops the current optimizer
  39070. */
  39071. stop(): void;
  39072. /**
  39073. * Reset the optimizer to initial step (current priority level = 0)
  39074. */
  39075. reset(): void;
  39076. /**
  39077. * Start the optimizer. By default it will try to reach a specific framerate
  39078. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  39079. */
  39080. start(): void;
  39081. private _checkCurrentState;
  39082. /**
  39083. * Release all resources
  39084. */
  39085. dispose(): void;
  39086. /**
  39087. * Helper function to create a SceneOptimizer with one single line of code
  39088. * @param scene defines the scene to work on
  39089. * @param options defines the options to use with the SceneOptimizer
  39090. * @param onSuccess defines a callback to call on success
  39091. * @param onFailure defines a callback to call on failure
  39092. * @returns the new SceneOptimizer object
  39093. */
  39094. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  39095. }
  39096. }
  39097. declare module BABYLON {
  39098. /**
  39099. * Class used to serialize a scene into a string
  39100. */
  39101. class SceneSerializer {
  39102. /**
  39103. * Clear cache used by a previous serialization
  39104. */
  39105. static ClearCache(): void;
  39106. /**
  39107. * Serialize a scene into a JSON compatible object
  39108. * @param scene defines the scene to serialize
  39109. * @returns a JSON compatible object
  39110. */
  39111. static Serialize(scene: Scene): any;
  39112. /**
  39113. * Serialize a mesh into a JSON compatible object
  39114. * @param toSerialize defines the mesh to serialize
  39115. * @param withParents defines if parents must be serialized as well
  39116. * @param withChildren defines if children must be serialized as well
  39117. * @returns a JSON compatible object
  39118. */
  39119. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  39120. }
  39121. }
  39122. declare module BABYLON {
  39123. /**
  39124. * Defines an array and its length.
  39125. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  39126. */
  39127. interface ISmartArrayLike<T> {
  39128. /**
  39129. * The data of the array.
  39130. */
  39131. data: Array<T>;
  39132. /**
  39133. * The active length of the array.
  39134. */
  39135. length: number;
  39136. }
  39137. /**
  39138. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39139. */
  39140. class SmartArray<T> implements ISmartArrayLike<T> {
  39141. /**
  39142. * The full set of data from the array.
  39143. */
  39144. data: Array<T>;
  39145. /**
  39146. * The active length of the array.
  39147. */
  39148. length: number;
  39149. protected _id: number;
  39150. /**
  39151. * Instantiates a Smart Array.
  39152. * @param capacity defines the default capacity of the array.
  39153. */
  39154. constructor(capacity: number);
  39155. /**
  39156. * Pushes a value at the end of the active data.
  39157. * @param value defines the object to push in the array.
  39158. */
  39159. push(value: T): void;
  39160. /**
  39161. * Iterates over the active data and apply the lambda to them.
  39162. * @param func defines the action to apply on each value.
  39163. */
  39164. forEach(func: (content: T) => void): void;
  39165. /**
  39166. * Sorts the full sets of data.
  39167. * @param compareFn defines the comparison function to apply.
  39168. */
  39169. sort(compareFn: (a: T, b: T) => number): void;
  39170. /**
  39171. * Resets the active data to an empty array.
  39172. */
  39173. reset(): void;
  39174. /**
  39175. * Releases all the data from the array as well as the array.
  39176. */
  39177. dispose(): void;
  39178. /**
  39179. * Concats the active data with a given array.
  39180. * @param array defines the data to concatenate with.
  39181. */
  39182. concat(array: any): void;
  39183. /**
  39184. * Returns the position of a value in the active data.
  39185. * @param value defines the value to find the index for
  39186. * @returns the index if found in the active data otherwise -1
  39187. */
  39188. indexOf(value: T): number;
  39189. /**
  39190. * Returns whether an element is part of the active data.
  39191. * @param value defines the value to look for
  39192. * @returns true if found in the active data otherwise false
  39193. */
  39194. contains(value: T): boolean;
  39195. private static _GlobalId;
  39196. }
  39197. /**
  39198. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39199. * The data in this array can only be present once
  39200. */
  39201. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  39202. private _duplicateId;
  39203. /**
  39204. * Pushes a value at the end of the active data.
  39205. * THIS DOES NOT PREVENT DUPPLICATE DATA
  39206. * @param value defines the object to push in the array.
  39207. */
  39208. push(value: T): void;
  39209. /**
  39210. * Pushes a value at the end of the active data.
  39211. * If the data is already present, it won t be added again
  39212. * @param value defines the object to push in the array.
  39213. * @returns true if added false if it was already present
  39214. */
  39215. pushNoDuplicate(value: T): boolean;
  39216. /**
  39217. * Resets the active data to an empty array.
  39218. */
  39219. reset(): void;
  39220. /**
  39221. * Concats the active data with a given array.
  39222. * This ensures no dupplicate will be present in the result.
  39223. * @param array defines the data to concatenate with.
  39224. */
  39225. concatWithNoDuplicate(array: any): void;
  39226. }
  39227. }
  39228. declare module BABYLON {
  39229. /**
  39230. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39231. * The underlying implementation relies on an associative array to ensure the best performances.
  39232. * The value can be anything including 'null' but except 'undefined'
  39233. */
  39234. class StringDictionary<T> {
  39235. /**
  39236. * This will clear this dictionary and copy the content from the 'source' one.
  39237. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39238. * @param source the dictionary to take the content from and copy to this dictionary
  39239. */
  39240. copyFrom(source: StringDictionary<T>): void;
  39241. /**
  39242. * Get a value based from its key
  39243. * @param key the given key to get the matching value from
  39244. * @return the value if found, otherwise undefined is returned
  39245. */
  39246. get(key: string): T | undefined;
  39247. /**
  39248. * Get a value from its key or add it if it doesn't exist.
  39249. * This method will ensure you that a given key/data will be present in the dictionary.
  39250. * @param key the given key to get the matching value from
  39251. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39252. * The factory will only be invoked if there's no data for the given key.
  39253. * @return the value corresponding to the key.
  39254. */
  39255. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39256. /**
  39257. * Get a value from its key if present in the dictionary otherwise add it
  39258. * @param key the key to get the value from
  39259. * @param val if there's no such key/value pair in the dictionary add it with this value
  39260. * @return the value corresponding to the key
  39261. */
  39262. getOrAdd(key: string, val: T): T;
  39263. /**
  39264. * Check if there's a given key in the dictionary
  39265. * @param key the key to check for
  39266. * @return true if the key is present, false otherwise
  39267. */
  39268. contains(key: string): boolean;
  39269. /**
  39270. * Add a new key and its corresponding value
  39271. * @param key the key to add
  39272. * @param value the value corresponding to the key
  39273. * @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
  39274. */
  39275. add(key: string, value: T): boolean;
  39276. /**
  39277. * Update a specific value associated to a key
  39278. * @param key defines the key to use
  39279. * @param value defines the value to store
  39280. * @returns true if the value was updated (or false if the key was not found)
  39281. */
  39282. set(key: string, value: T): boolean;
  39283. /**
  39284. * Get the element of the given key and remove it from the dictionary
  39285. * @param key defines the key to search
  39286. * @returns the value associated with the key or null if not found
  39287. */
  39288. getAndRemove(key: string): Nullable<T>;
  39289. /**
  39290. * Remove a key/value from the dictionary.
  39291. * @param key the key to remove
  39292. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39293. */
  39294. remove(key: string): boolean;
  39295. /**
  39296. * Clear the whole content of the dictionary
  39297. */
  39298. clear(): void;
  39299. /**
  39300. * Gets the current count
  39301. */
  39302. readonly count: number;
  39303. /**
  39304. * Execute a callback on each key/val of the dictionary.
  39305. * Note that you can remove any element in this dictionary in the callback implementation
  39306. * @param callback the callback to execute on a given key/value pair
  39307. */
  39308. forEach(callback: (key: string, val: T) => void): void;
  39309. /**
  39310. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39311. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39312. * Note that you can remove any element in this dictionary in the callback implementation
  39313. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39314. * @returns the first item
  39315. */
  39316. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39317. private _count;
  39318. private _data;
  39319. }
  39320. }
  39321. declare module BABYLON {
  39322. /**
  39323. * Class used to store custom tags
  39324. */
  39325. class Tags {
  39326. /**
  39327. * Adds support for tags on the given object
  39328. * @param obj defines the object to use
  39329. */
  39330. static EnableFor(obj: any): void;
  39331. /**
  39332. * Removes tags support
  39333. * @param obj defines the object to use
  39334. */
  39335. static DisableFor(obj: any): void;
  39336. /**
  39337. * Gets a boolean indicating if the given object has tags
  39338. * @param obj defines the object to use
  39339. * @returns a boolean
  39340. */
  39341. static HasTags(obj: any): boolean;
  39342. /**
  39343. * Gets the tags available on a given object
  39344. * @param obj defines the object to use
  39345. * @param asString defines if the tags must be returned as a string instead of an array of strings
  39346. * @returns the tags
  39347. */
  39348. static GetTags(obj: any, asString?: boolean): any;
  39349. /**
  39350. * Adds tags to an object
  39351. * @param obj defines the object to use
  39352. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  39353. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  39354. */
  39355. static AddTagsTo(obj: any, tagsString: string): void;
  39356. /**
  39357. * @hidden
  39358. */
  39359. static _AddTagTo(obj: any, tag: string): void;
  39360. /**
  39361. * Removes specific tags from a specific object
  39362. * @param obj defines the object to use
  39363. * @param tagsString defines the tags to remove
  39364. */
  39365. static RemoveTagsFrom(obj: any, tagsString: string): void;
  39366. /**
  39367. * @hidden
  39368. */
  39369. static _RemoveTagFrom(obj: any, tag: string): void;
  39370. /**
  39371. * Defines if tags hosted on an object match a given query
  39372. * @param obj defines the object to use
  39373. * @param tagsQuery defines the tag query
  39374. * @returns a boolean
  39375. */
  39376. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  39377. }
  39378. }
  39379. declare module BABYLON {
  39380. /**
  39381. * Class used to host texture specific utilities
  39382. */
  39383. class TextureTools {
  39384. /**
  39385. * Uses the GPU to create a copy texture rescaled at a given size
  39386. * @param texture Texture to copy from
  39387. * @param width defines the desired width
  39388. * @param height defines the desired height
  39389. * @param useBilinearMode defines if bilinear mode has to be used
  39390. * @return the generated texture
  39391. */
  39392. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  39393. /**
  39394. * Gets an environment BRDF texture for a given scene
  39395. * @param scene defines the hosting scene
  39396. * @returns the environment BRDF texture
  39397. */
  39398. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  39399. private static _environmentBRDFBase64Texture;
  39400. }
  39401. }
  39402. declare module BABYLON {
  39403. /**
  39404. * Based on jsTGALoader - Javascript loader for TGA file
  39405. * By Vincent Thibault
  39406. * @see http://blog.robrowser.com/javascript-tga-loader.html
  39407. */
  39408. class TGATools {
  39409. private static _TYPE_INDEXED;
  39410. private static _TYPE_RGB;
  39411. private static _TYPE_GREY;
  39412. private static _TYPE_RLE_INDEXED;
  39413. private static _TYPE_RLE_RGB;
  39414. private static _TYPE_RLE_GREY;
  39415. private static _ORIGIN_MASK;
  39416. private static _ORIGIN_SHIFT;
  39417. private static _ORIGIN_BL;
  39418. private static _ORIGIN_BR;
  39419. private static _ORIGIN_UL;
  39420. private static _ORIGIN_UR;
  39421. /**
  39422. * Gets the header of a TGA file
  39423. * @param data defines the TGA data
  39424. * @returns the header
  39425. */
  39426. static GetTGAHeader(data: Uint8Array): any;
  39427. /**
  39428. * Uploads TGA content to a Babylon Texture
  39429. * @hidden
  39430. */
  39431. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  39432. /** @hidden */
  39433. 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;
  39434. /** @hidden */
  39435. 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;
  39436. /** @hidden */
  39437. 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;
  39438. /** @hidden */
  39439. 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;
  39440. /** @hidden */
  39441. 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;
  39442. /** @hidden */
  39443. 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;
  39444. }
  39445. }
  39446. declare module BABYLON {
  39447. /**
  39448. * Interface for any object that can request an animation frame
  39449. */
  39450. interface ICustomAnimationFrameRequester {
  39451. /**
  39452. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  39453. */
  39454. renderFunction?: Function;
  39455. /**
  39456. * Called to request the next frame to render to
  39457. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39458. */
  39459. requestAnimationFrame: Function;
  39460. /**
  39461. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39462. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39463. */
  39464. requestID?: number;
  39465. }
  39466. /**
  39467. * Interface containing an array of animations
  39468. */
  39469. interface IAnimatable {
  39470. /**
  39471. * Array of animations
  39472. */
  39473. animations: Array<Animation>;
  39474. }
  39475. /** Interface used by value gradients (color, factor, ...) */
  39476. interface IValueGradient {
  39477. /**
  39478. * Gets or sets the gradient value (between 0 and 1)
  39479. */
  39480. gradient: number;
  39481. }
  39482. /** Class used to store color4 gradient */
  39483. class ColorGradient implements IValueGradient {
  39484. /**
  39485. * Gets or sets the gradient value (between 0 and 1)
  39486. */
  39487. gradient: number;
  39488. /**
  39489. * Gets or sets first associated color
  39490. */
  39491. color1: Color4;
  39492. /**
  39493. * Gets or sets second associated color
  39494. */
  39495. color2?: Color4;
  39496. /**
  39497. * Will get a color picked randomly between color1 and color2.
  39498. * If color2 is undefined then color1 will be used
  39499. * @param result defines the target Color4 to store the result in
  39500. */
  39501. getColorToRef(result: Color4): void;
  39502. }
  39503. /** Class used to store color 3 gradient */
  39504. class Color3Gradient implements IValueGradient {
  39505. /**
  39506. * Gets or sets the gradient value (between 0 and 1)
  39507. */
  39508. gradient: number;
  39509. /**
  39510. * Gets or sets the associated color
  39511. */
  39512. color: Color3;
  39513. }
  39514. /** Class used to store factor gradient */
  39515. class FactorGradient implements IValueGradient {
  39516. /**
  39517. * Gets or sets the gradient value (between 0 and 1)
  39518. */
  39519. gradient: number;
  39520. /**
  39521. * Gets or sets first associated factor
  39522. */
  39523. factor1: number;
  39524. /**
  39525. * Gets or sets second associated factor
  39526. */
  39527. factor2?: number;
  39528. /**
  39529. * Will get a number picked randomly between factor1 and factor2.
  39530. * If factor2 is undefined then factor1 will be used
  39531. * @returns the picked number
  39532. */
  39533. getFactor(): number;
  39534. }
  39535. /**
  39536. * @ignore
  39537. * Application error to support additional information when loading a file
  39538. */
  39539. class LoadFileError extends Error {
  39540. /** defines the optional XHR request */
  39541. request?: XMLHttpRequest | undefined;
  39542. private static _setPrototypeOf;
  39543. /**
  39544. * Creates a new LoadFileError
  39545. * @param message defines the message of the error
  39546. * @param request defines the optional XHR request
  39547. */
  39548. constructor(message: string,
  39549. /** defines the optional XHR request */
  39550. request?: XMLHttpRequest | undefined);
  39551. }
  39552. /**
  39553. * Class used to define a retry strategy when error happens while loading assets
  39554. */
  39555. class RetryStrategy {
  39556. /**
  39557. * Function used to defines an exponential back off strategy
  39558. * @param maxRetries defines the maximum number of retries (3 by default)
  39559. * @param baseInterval defines the interval between retries
  39560. * @returns the strategy function to use
  39561. */
  39562. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39563. }
  39564. /**
  39565. * File request interface
  39566. */
  39567. interface IFileRequest {
  39568. /**
  39569. * Raised when the request is complete (success or error).
  39570. */
  39571. onCompleteObservable: Observable<IFileRequest>;
  39572. /**
  39573. * Aborts the request for a file.
  39574. */
  39575. abort: () => void;
  39576. }
  39577. /**
  39578. * Class containing a set of static utilities functions
  39579. */
  39580. class Tools {
  39581. /**
  39582. * Gets or sets the base URL to use to load assets
  39583. */
  39584. static BaseUrl: string;
  39585. /**
  39586. * Enable/Disable Custom HTTP Request Headers globally.
  39587. * default = false
  39588. * @see CustomRequestHeaders
  39589. */
  39590. static UseCustomRequestHeaders: boolean;
  39591. /**
  39592. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39593. * i.e. when loading files, where the server/service expects an Authorization header.
  39594. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  39595. */
  39596. static CustomRequestHeaders: {
  39597. [key: string]: string;
  39598. };
  39599. /**
  39600. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39601. */
  39602. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39603. /**
  39604. * Default behaviour for cors in the application.
  39605. * It can be a string if the expected behavior is identical in the entire app.
  39606. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39607. */
  39608. static CorsBehavior: string | ((url: string | string[]) => string);
  39609. /**
  39610. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39611. * @ignorenaming
  39612. */
  39613. static UseFallbackTexture: boolean;
  39614. /**
  39615. * Use this object to register external classes like custom textures or material
  39616. * to allow the laoders to instantiate them
  39617. */
  39618. static RegisteredExternalClasses: {
  39619. [key: string]: Object;
  39620. };
  39621. /**
  39622. * Texture content used if a texture cannot loaded
  39623. * @ignorenaming
  39624. */
  39625. static fallbackTexture: string;
  39626. /**
  39627. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39628. * @param u defines the coordinate on X axis
  39629. * @param v defines the coordinate on Y axis
  39630. * @param width defines the width of the source data
  39631. * @param height defines the height of the source data
  39632. * @param pixels defines the source byte array
  39633. * @param color defines the output color
  39634. */
  39635. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39636. /**
  39637. * Interpolates between a and b via alpha
  39638. * @param a The lower value (returned when alpha = 0)
  39639. * @param b The upper value (returned when alpha = 1)
  39640. * @param alpha The interpolation-factor
  39641. * @return The mixed value
  39642. */
  39643. static Mix(a: number, b: number, alpha: number): number;
  39644. /**
  39645. * Tries to instantiate a new object from a given class name
  39646. * @param className defines the class name to instantiate
  39647. * @returns the new object or null if the system was not able to do the instantiation
  39648. */
  39649. static Instantiate(className: string): any;
  39650. /**
  39651. * Provides a slice function that will work even on IE
  39652. * @param data defines the array to slice
  39653. * @param start defines the start of the data (optional)
  39654. * @param end defines the end of the data (optional)
  39655. * @returns the new sliced array
  39656. */
  39657. static Slice<T>(data: T, start?: number, end?: number): T;
  39658. /**
  39659. * Polyfill for setImmediate
  39660. * @param action defines the action to execute after the current execution block
  39661. */
  39662. static SetImmediate(action: () => void): void;
  39663. /**
  39664. * Function indicating if a number is an exponent of 2
  39665. * @param value defines the value to test
  39666. * @returns true if the value is an exponent of 2
  39667. */
  39668. static IsExponentOfTwo(value: number): boolean;
  39669. private static _tmpFloatArray;
  39670. /**
  39671. * Returns the nearest 32-bit single precision float representation of a Number
  39672. * @param value A Number. If the parameter is of a different type, it will get converted
  39673. * to a number or to NaN if it cannot be converted
  39674. * @returns number
  39675. */
  39676. static FloatRound(value: number): number;
  39677. /**
  39678. * Find the next highest power of two.
  39679. * @param x Number to start search from.
  39680. * @return Next highest power of two.
  39681. */
  39682. static CeilingPOT(x: number): number;
  39683. /**
  39684. * Find the next lowest power of two.
  39685. * @param x Number to start search from.
  39686. * @return Next lowest power of two.
  39687. */
  39688. static FloorPOT(x: number): number;
  39689. /**
  39690. * Find the nearest power of two.
  39691. * @param x Number to start search from.
  39692. * @return Next nearest power of two.
  39693. */
  39694. static NearestPOT(x: number): number;
  39695. /**
  39696. * Get the closest exponent of two
  39697. * @param value defines the value to approximate
  39698. * @param max defines the maximum value to return
  39699. * @param mode defines how to define the closest value
  39700. * @returns closest exponent of two of the given value
  39701. */
  39702. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39703. /**
  39704. * Extracts the filename from a path
  39705. * @param path defines the path to use
  39706. * @returns the filename
  39707. */
  39708. static GetFilename(path: string): string;
  39709. /**
  39710. * Extracts the "folder" part of a path (everything before the filename).
  39711. * @param uri The URI to extract the info from
  39712. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39713. * @returns The "folder" part of the path
  39714. */
  39715. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39716. /**
  39717. * Extracts text content from a DOM element hierarchy
  39718. * @param element defines the root element
  39719. * @returns a string
  39720. */
  39721. static GetDOMTextContent(element: HTMLElement): string;
  39722. /**
  39723. * Convert an angle in radians to degrees
  39724. * @param angle defines the angle to convert
  39725. * @returns the angle in degrees
  39726. */
  39727. static ToDegrees(angle: number): number;
  39728. /**
  39729. * Convert an angle in degrees to radians
  39730. * @param angle defines the angle to convert
  39731. * @returns the angle in radians
  39732. */
  39733. static ToRadians(angle: number): number;
  39734. /**
  39735. * Encode a buffer to a base64 string
  39736. * @param buffer defines the buffer to encode
  39737. * @returns the encoded string
  39738. */
  39739. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39740. /**
  39741. * Extracts minimum and maximum values from a list of indexed positions
  39742. * @param positions defines the positions to use
  39743. * @param indices defines the indices to the positions
  39744. * @param indexStart defines the start index
  39745. * @param indexCount defines the end index
  39746. * @param bias defines bias value to add to the result
  39747. * @return minimum and maximum values
  39748. */
  39749. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39750. minimum: Vector3;
  39751. maximum: Vector3;
  39752. };
  39753. /**
  39754. * Extracts minimum and maximum values from a list of positions
  39755. * @param positions defines the positions to use
  39756. * @param start defines the start index in the positions array
  39757. * @param count defines the number of positions to handle
  39758. * @param bias defines bias value to add to the result
  39759. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39760. * @return minimum and maximum values
  39761. */
  39762. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39763. minimum: Vector3;
  39764. maximum: Vector3;
  39765. };
  39766. /**
  39767. * Returns an array if obj is not an array
  39768. * @param obj defines the object to evaluate as an array
  39769. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39770. * @returns either obj directly if obj is an array or a new array containing obj
  39771. */
  39772. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39773. /**
  39774. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39775. * @param size the number of element to construct and put in the array
  39776. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39777. * @returns a new array filled with new objects
  39778. */
  39779. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39780. /**
  39781. * Gets the pointer prefix to use
  39782. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39783. */
  39784. static GetPointerPrefix(): string;
  39785. /**
  39786. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39787. * @param func - the function to be called
  39788. * @param requester - the object that will request the next frame. Falls back to window.
  39789. * @returns frame number
  39790. */
  39791. static QueueNewFrame(func: () => void, requester?: any): number;
  39792. /**
  39793. * Ask the browser to promote the current element to fullscreen rendering mode
  39794. * @param element defines the DOM element to promote
  39795. */
  39796. static RequestFullscreen(element: HTMLElement): void;
  39797. /**
  39798. * Asks the browser to exit fullscreen mode
  39799. */
  39800. static ExitFullscreen(): void;
  39801. /**
  39802. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39803. * @param url define the url we are trying
  39804. * @param element define the dom element where to configure the cors policy
  39805. */
  39806. static SetCorsBehavior(url: string | string[], element: {
  39807. crossOrigin: string | null;
  39808. }): void;
  39809. /**
  39810. * Removes unwanted characters from an url
  39811. * @param url defines the url to clean
  39812. * @returns the cleaned url
  39813. */
  39814. static CleanUrl(url: string): string;
  39815. /**
  39816. * Gets or sets a function used to pre-process url before using them to load assets
  39817. */
  39818. static PreprocessUrl: (url: string) => string;
  39819. /**
  39820. * Loads an image as an HTMLImageElement.
  39821. * @param input url string, ArrayBuffer, or Blob to load
  39822. * @param onLoad callback called when the image successfully loads
  39823. * @param onError callback called when the image fails to load
  39824. * @param offlineProvider offline provider for caching
  39825. * @returns the HTMLImageElement of the loaded image
  39826. */
  39827. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39828. /**
  39829. * Loads a file
  39830. * @param url url string, ArrayBuffer, or Blob to load
  39831. * @param onSuccess callback called when the file successfully loads
  39832. * @param onProgress callback called while file is loading (if the server supports this mode)
  39833. * @param offlineProvider defines the offline provider for caching
  39834. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39835. * @param onError callback called when the file fails to load
  39836. * @returns a file request object
  39837. */
  39838. 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;
  39839. /**
  39840. * Load a script (identified by an url). When the url returns, the
  39841. * content of this file is added into a new script element, attached to the DOM (body element)
  39842. * @param scriptUrl defines the url of the script to laod
  39843. * @param onSuccess defines the callback called when the script is loaded
  39844. * @param onError defines the callback to call if an error occurs
  39845. */
  39846. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39847. /**
  39848. * Loads a file from a blob
  39849. * @param fileToLoad defines the blob to use
  39850. * @param callback defines the callback to call when data is loaded
  39851. * @param progressCallback defines the callback to call during loading process
  39852. * @returns a file request object
  39853. */
  39854. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39855. /**
  39856. * Loads a file
  39857. * @param fileToLoad defines the file to load
  39858. * @param callback defines the callback to call when data is loaded
  39859. * @param progressCallBack defines the callback to call during loading process
  39860. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39861. * @returns a file request object
  39862. */
  39863. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39864. /**
  39865. * Creates a data url from a given string content
  39866. * @param content defines the content to convert
  39867. * @returns the new data url link
  39868. */
  39869. static FileAsURL(content: string): string;
  39870. /**
  39871. * Format the given number to a specific decimal format
  39872. * @param value defines the number to format
  39873. * @param decimals defines the number of decimals to use
  39874. * @returns the formatted string
  39875. */
  39876. static Format(value: number, decimals?: number): string;
  39877. /**
  39878. * Checks if a given vector is inside a specific range
  39879. * @param v defines the vector to test
  39880. * @param min defines the minimum range
  39881. * @param max defines the maximum range
  39882. */
  39883. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39884. /**
  39885. * Tries to copy an object by duplicating every property
  39886. * @param source defines the source object
  39887. * @param destination defines the target object
  39888. * @param doNotCopyList defines a list of properties to avoid
  39889. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39890. */
  39891. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39892. /**
  39893. * Gets a boolean indicating if the given object has no own property
  39894. * @param obj defines the object to test
  39895. * @returns true if object has no own property
  39896. */
  39897. static IsEmpty(obj: any): boolean;
  39898. /**
  39899. * Function used to register events at window level
  39900. * @param events defines the events to register
  39901. */
  39902. static RegisterTopRootEvents(events: {
  39903. name: string;
  39904. handler: Nullable<(e: FocusEvent) => any>;
  39905. }[]): void;
  39906. /**
  39907. * Function used to unregister events from window level
  39908. * @param events defines the events to unregister
  39909. */
  39910. static UnregisterTopRootEvents(events: {
  39911. name: string;
  39912. handler: Nullable<(e: FocusEvent) => any>;
  39913. }[]): void;
  39914. /**
  39915. * Dumps the current bound framebuffer
  39916. * @param width defines the rendering width
  39917. * @param height defines the rendering height
  39918. * @param engine defines the hosting engine
  39919. * @param successCallback defines the callback triggered once the data are available
  39920. * @param mimeType defines the mime type of the result
  39921. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39922. */
  39923. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39924. /**
  39925. * Converts the canvas data to blob.
  39926. * This acts as a polyfill for browsers not supporting the to blob function.
  39927. * @param canvas Defines the canvas to extract the data from
  39928. * @param successCallback Defines the callback triggered once the data are available
  39929. * @param mimeType Defines the mime type of the result
  39930. */
  39931. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39932. /**
  39933. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39934. * @param successCallback defines the callback triggered once the data are available
  39935. * @param mimeType defines the mime type of the result
  39936. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39937. */
  39938. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39939. /**
  39940. * Downloads a blob in the browser
  39941. * @param blob defines the blob to download
  39942. * @param fileName defines the name of the downloaded file
  39943. */
  39944. static Download(blob: Blob, fileName: string): void;
  39945. /**
  39946. * Captures a screenshot of the current rendering
  39947. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39948. * @param engine defines the rendering engine
  39949. * @param camera defines the source camera
  39950. * @param size This parameter can be set to a single number or to an object with the
  39951. * following (optional) properties: precision, width, height. If a single number is passed,
  39952. * it will be used for both width and height. If an object is passed, the screenshot size
  39953. * will be derived from the parameters. The precision property is a multiplier allowing
  39954. * rendering at a higher or lower resolution
  39955. * @param successCallback defines the callback receives a single parameter which contains the
  39956. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39957. * src parameter of an <img> to display it
  39958. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39959. * Check your browser for supported MIME types
  39960. */
  39961. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  39962. /**
  39963. * Generates an image screenshot from the specified camera.
  39964. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39965. * @param engine The engine to use for rendering
  39966. * @param camera The camera to use for rendering
  39967. * @param size This parameter can be set to a single number or to an object with the
  39968. * following (optional) properties: precision, width, height. If a single number is passed,
  39969. * it will be used for both width and height. If an object is passed, the screenshot size
  39970. * will be derived from the parameters. The precision property is a multiplier allowing
  39971. * rendering at a higher or lower resolution
  39972. * @param successCallback The callback receives a single parameter which contains the
  39973. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39974. * src parameter of an <img> to display it
  39975. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39976. * Check your browser for supported MIME types
  39977. * @param samples Texture samples (default: 1)
  39978. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39979. * @param fileName A name for for the downloaded file.
  39980. */
  39981. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39982. /**
  39983. * Validates if xhr data is correct
  39984. * @param xhr defines the request to validate
  39985. * @param dataType defines the expected data type
  39986. * @returns true if data is correct
  39987. */
  39988. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  39989. /**
  39990. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39991. * Be aware Math.random() could cause collisions, but:
  39992. * "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"
  39993. * @returns a pseudo random id
  39994. */
  39995. static RandomId(): string;
  39996. /**
  39997. * Test if the given uri is a base64 string
  39998. * @param uri The uri to test
  39999. * @return True if the uri is a base64 string or false otherwise
  40000. */
  40001. static IsBase64(uri: string): boolean;
  40002. /**
  40003. * Decode the given base64 uri.
  40004. * @param uri The uri to decode
  40005. * @return The decoded base64 data.
  40006. */
  40007. static DecodeBase64(uri: string): ArrayBuffer;
  40008. /**
  40009. * No log
  40010. */
  40011. static readonly NoneLogLevel: number;
  40012. /**
  40013. * Only message logs
  40014. */
  40015. static readonly MessageLogLevel: number;
  40016. /**
  40017. * Only warning logs
  40018. */
  40019. static readonly WarningLogLevel: number;
  40020. /**
  40021. * Only error logs
  40022. */
  40023. static readonly ErrorLogLevel: number;
  40024. /**
  40025. * All logs
  40026. */
  40027. static readonly AllLogLevel: number;
  40028. private static _LogCache;
  40029. /**
  40030. * Gets a value indicating the number of loading errors
  40031. * @ignorenaming
  40032. */
  40033. static errorsCount: number;
  40034. /**
  40035. * Callback called when a new log is added
  40036. */
  40037. static OnNewCacheEntry: (entry: string) => void;
  40038. private static _AddLogEntry;
  40039. private static _FormatMessage;
  40040. private static _LogDisabled;
  40041. private static _LogEnabled;
  40042. private static _WarnDisabled;
  40043. private static _WarnEnabled;
  40044. private static _ErrorDisabled;
  40045. private static _ErrorEnabled;
  40046. /**
  40047. * Log a message to the console
  40048. */
  40049. static Log: (message: string) => void;
  40050. /**
  40051. * Write a warning message to the console
  40052. */
  40053. static Warn: (message: string) => void;
  40054. /**
  40055. * Write an error message to the console
  40056. */
  40057. static Error: (message: string) => void;
  40058. /**
  40059. * Gets current log cache (list of logs)
  40060. */
  40061. static readonly LogCache: string;
  40062. /**
  40063. * Clears the log cache
  40064. */
  40065. static ClearLogCache(): void;
  40066. /**
  40067. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40068. */
  40069. static LogLevels: number;
  40070. /**
  40071. * Checks if the loaded document was accessed via `file:`-Protocol.
  40072. * @returns boolean
  40073. */
  40074. static IsFileURL(): boolean;
  40075. /**
  40076. * Checks if the window object exists
  40077. * @returns true if the window object exists
  40078. */
  40079. static IsWindowObjectExist(): boolean;
  40080. /**
  40081. * No performance log
  40082. */
  40083. static readonly PerformanceNoneLogLevel: number;
  40084. /**
  40085. * Use user marks to log performance
  40086. */
  40087. static readonly PerformanceUserMarkLogLevel: number;
  40088. /**
  40089. * Log performance to the console
  40090. */
  40091. static readonly PerformanceConsoleLogLevel: number;
  40092. private static _performance;
  40093. /**
  40094. * Sets the current performance log level
  40095. */
  40096. static PerformanceLogLevel: number;
  40097. private static _StartPerformanceCounterDisabled;
  40098. private static _EndPerformanceCounterDisabled;
  40099. private static _StartUserMark;
  40100. private static _EndUserMark;
  40101. private static _StartPerformanceConsole;
  40102. private static _EndPerformanceConsole;
  40103. /**
  40104. * Injects the @see CustomRequestHeaders into the given request
  40105. * @param request the request that should be used for injection
  40106. */
  40107. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  40108. /**
  40109. * Starts a performance counter
  40110. */
  40111. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40112. /**
  40113. * Ends a specific performance coutner
  40114. */
  40115. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40116. /**
  40117. * Gets either window.performance.now() if supported or Date.now() else
  40118. */
  40119. static readonly Now: number;
  40120. /**
  40121. * This method will return the name of the class used to create the instance of the given object.
  40122. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40123. * @param object the object to get the class name from
  40124. * @param isType defines if the object is actually a type
  40125. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40126. */
  40127. static GetClassName(object: any, isType?: boolean): string;
  40128. /**
  40129. * Gets the first element of an array satisfying a given predicate
  40130. * @param array defines the array to browse
  40131. * @param predicate defines the predicate to use
  40132. * @returns null if not found or the element
  40133. */
  40134. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40135. /**
  40136. * This method will return the name of the full name of the class, including its owning module (if any).
  40137. * 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).
  40138. * @param object the object to get the class name from
  40139. * @param isType defines if the object is actually a type
  40140. * @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.
  40141. * @ignorenaming
  40142. */
  40143. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40144. /**
  40145. * Returns a promise that resolves after the given amount of time.
  40146. * @param delay Number of milliseconds to delay
  40147. * @returns Promise that resolves after the given amount of time
  40148. */
  40149. static DelayAsync(delay: number): Promise<void>;
  40150. /**
  40151. * Gets the current gradient from an array of IValueGradient
  40152. * @param ratio defines the current ratio to get
  40153. * @param gradients defines the array of IValueGradient
  40154. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  40155. */
  40156. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  40157. }
  40158. /**
  40159. * This class is used to track a performance counter which is number based.
  40160. * The user has access to many properties which give statistics of different nature.
  40161. *
  40162. * The implementer can track two kinds of Performance Counter: time and count.
  40163. * 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.
  40164. * 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.
  40165. */
  40166. class PerfCounter {
  40167. /**
  40168. * Gets or sets a global boolean to turn on and off all the counters
  40169. */
  40170. static Enabled: boolean;
  40171. /**
  40172. * Returns the smallest value ever
  40173. */
  40174. readonly min: number;
  40175. /**
  40176. * Returns the biggest value ever
  40177. */
  40178. readonly max: number;
  40179. /**
  40180. * Returns the average value since the performance counter is running
  40181. */
  40182. readonly average: number;
  40183. /**
  40184. * Returns the average value of the last second the counter was monitored
  40185. */
  40186. readonly lastSecAverage: number;
  40187. /**
  40188. * Returns the current value
  40189. */
  40190. readonly current: number;
  40191. /**
  40192. * Gets the accumulated total
  40193. */
  40194. readonly total: number;
  40195. /**
  40196. * Gets the total value count
  40197. */
  40198. readonly count: number;
  40199. /**
  40200. * Creates a new counter
  40201. */
  40202. constructor();
  40203. /**
  40204. * Call this method to start monitoring a new frame.
  40205. * 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.
  40206. */
  40207. fetchNewFrame(): void;
  40208. /**
  40209. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40210. * @param newCount the count value to add to the monitored count
  40211. * @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.
  40212. */
  40213. addCount(newCount: number, fetchResult: boolean): void;
  40214. /**
  40215. * Start monitoring this performance counter
  40216. */
  40217. beginMonitoring(): void;
  40218. /**
  40219. * Compute the time lapsed since the previous beginMonitoring() call.
  40220. * @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
  40221. */
  40222. endMonitoring(newFrame?: boolean): void;
  40223. private _fetchResult;
  40224. private _startMonitoringTime;
  40225. private _min;
  40226. private _max;
  40227. private _average;
  40228. private _current;
  40229. private _totalValueCount;
  40230. private _totalAccumulated;
  40231. private _lastSecAverage;
  40232. private _lastSecAccumulated;
  40233. private _lastSecTime;
  40234. private _lastSecValueCount;
  40235. }
  40236. /**
  40237. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40238. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40239. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40240. * @param name The name of the class, case should be preserved
  40241. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40242. */
  40243. function className(name: string, module?: string): (target: Object) => void;
  40244. /**
  40245. * An implementation of a loop for asynchronous functions.
  40246. */
  40247. class AsyncLoop {
  40248. /**
  40249. * Defines the number of iterations for the loop
  40250. */
  40251. iterations: number;
  40252. /**
  40253. * Defines the current index of the loop.
  40254. */
  40255. index: number;
  40256. private _done;
  40257. private _fn;
  40258. private _successCallback;
  40259. /**
  40260. * Constructor.
  40261. * @param iterations the number of iterations.
  40262. * @param func the function to run each iteration
  40263. * @param successCallback the callback that will be called upon succesful execution
  40264. * @param offset starting offset.
  40265. */
  40266. constructor(
  40267. /**
  40268. * Defines the number of iterations for the loop
  40269. */
  40270. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40271. /**
  40272. * Execute the next iteration. Must be called after the last iteration was finished.
  40273. */
  40274. executeNext(): void;
  40275. /**
  40276. * Break the loop and run the success callback.
  40277. */
  40278. breakLoop(): void;
  40279. /**
  40280. * Create and run an async loop.
  40281. * @param iterations the number of iterations.
  40282. * @param fn the function to run each iteration
  40283. * @param successCallback the callback that will be called upon succesful execution
  40284. * @param offset starting offset.
  40285. * @returns the created async loop object
  40286. */
  40287. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40288. /**
  40289. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40290. * @param iterations total number of iterations
  40291. * @param syncedIterations number of synchronous iterations in each async iteration.
  40292. * @param fn the function to call each iteration.
  40293. * @param callback a success call back that will be called when iterating stops.
  40294. * @param breakFunction a break condition (optional)
  40295. * @param timeout timeout settings for the setTimeout function. default - 0.
  40296. * @returns the created async loop object
  40297. */
  40298. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40299. }
  40300. }
  40301. interface HTMLCanvasElement {
  40302. /** Track wether a record is in progress */
  40303. isRecording: boolean;
  40304. /** Capture Stream method defined by some browsers */
  40305. captureStream(fps?: number): MediaStream;
  40306. }
  40307. interface MediaRecorder {
  40308. /** Starts recording */
  40309. start(timeSlice: number): void;
  40310. /** Stops recording */
  40311. stop(): void;
  40312. /** Event raised when an error arised. */
  40313. onerror: (event: ErrorEvent) => void;
  40314. /** Event raised when the recording stops. */
  40315. onstop: (event: Event) => void;
  40316. /** Event raised when a new chunk of data is available and should be tracked. */
  40317. ondataavailable: (event: Event) => void;
  40318. }
  40319. interface MediaRecorderOptions {
  40320. /** The mime type you want to use as the recording container for the new MediaRecorder */
  40321. mimeType?: string;
  40322. /** The chosen bitrate for the audio component of the media. */
  40323. audioBitsPerSecond?: number;
  40324. /** The chosen bitrate for the video component of the media. */
  40325. videoBitsPerSecond?: number;
  40326. /** 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. */
  40327. bitsPerSecond?: number;
  40328. }
  40329. interface MediaRecorderConstructor {
  40330. /**
  40331. * A reference to the prototype.
  40332. */
  40333. readonly prototype: MediaRecorder;
  40334. /**
  40335. * Creates a new MediaRecorder.
  40336. * @param stream Defines the stream to record.
  40337. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  40338. */
  40339. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  40340. }
  40341. /**
  40342. * MediaRecoreder object available in some browsers.
  40343. */
  40344. declare var MediaRecorder: MediaRecorderConstructor;
  40345. declare module BABYLON {
  40346. /**
  40347. * This represents the different options avilable for the video capture.
  40348. */
  40349. interface VideoRecorderOptions {
  40350. /** Defines the mime type of the video */
  40351. mimeType: string;
  40352. /** Defines the video the video should be recorded at */
  40353. fps: number;
  40354. /** Defines the chunk size for the recording data */
  40355. recordChunckSize: number;
  40356. }
  40357. /**
  40358. * This can helps recording videos from BabylonJS.
  40359. * This is based on the available WebRTC functionalities of the browser.
  40360. *
  40361. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  40362. */
  40363. class VideoRecorder {
  40364. private static readonly _defaultOptions;
  40365. /**
  40366. * Returns wehther or not the VideoRecorder is available in your browser.
  40367. * @param engine Defines the Babylon Engine to check the support for
  40368. * @returns true if supported otherwise false
  40369. */
  40370. static IsSupported(engine: Engine): boolean;
  40371. private readonly _options;
  40372. private _canvas;
  40373. private _mediaRecorder;
  40374. private _recordedChunks;
  40375. private _fileName;
  40376. private _resolve;
  40377. private _reject;
  40378. /**
  40379. * True wether a recording is already in progress.
  40380. */
  40381. readonly isRecording: boolean;
  40382. /**
  40383. * Create a new VideoCapture object which can help converting what you see in Babylon to
  40384. * a video file.
  40385. * @param engine Defines the BabylonJS Engine you wish to record
  40386. * @param options Defines options that can be used to customized the capture
  40387. */
  40388. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  40389. /**
  40390. * Stops the current recording before the default capture timeout passed in the startRecording
  40391. * functions.
  40392. */
  40393. stopRecording(): void;
  40394. /**
  40395. * Starts recording the canvas for a max duration specified in parameters.
  40396. * @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.
  40397. * @param maxDuration Defines the maximum recording time in seconds.
  40398. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  40399. * @return a promise callback at the end of the recording with the video data in Blob.
  40400. */
  40401. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  40402. /**
  40403. * Releases internal resources used during the recording.
  40404. */
  40405. dispose(): void;
  40406. private _handleDataAvailable;
  40407. private _handleError;
  40408. private _handleStop;
  40409. }
  40410. }
  40411. declare module BABYLON {
  40412. /**
  40413. * Defines the potential axis of a Joystick
  40414. */
  40415. enum JoystickAxis {
  40416. /** X axis */
  40417. X = 0,
  40418. /** Y axis */
  40419. Y = 1,
  40420. /** Z axis */
  40421. Z = 2
  40422. }
  40423. /**
  40424. * Class used to define virtual joystick (used in touch mode)
  40425. */
  40426. class VirtualJoystick {
  40427. /**
  40428. * Gets or sets a boolean indicating that left and right values must be inverted
  40429. */
  40430. reverseLeftRight: boolean;
  40431. /**
  40432. * Gets or sets a boolean indicating that up and down values must be inverted
  40433. */
  40434. reverseUpDown: boolean;
  40435. /**
  40436. * Gets the offset value for the position (ie. the change of the position value)
  40437. */
  40438. deltaPosition: Vector3;
  40439. /**
  40440. * Gets a boolean indicating if the virtual joystick was pressed
  40441. */
  40442. pressed: boolean;
  40443. /**
  40444. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40445. */
  40446. static Canvas: Nullable<HTMLCanvasElement>;
  40447. private static _globalJoystickIndex;
  40448. private static vjCanvasContext;
  40449. private static vjCanvasWidth;
  40450. private static vjCanvasHeight;
  40451. private static halfWidth;
  40452. private _action;
  40453. private _axisTargetedByLeftAndRight;
  40454. private _axisTargetedByUpAndDown;
  40455. private _joystickSensibility;
  40456. private _inversedSensibility;
  40457. private _joystickPointerID;
  40458. private _joystickColor;
  40459. private _joystickPointerPos;
  40460. private _joystickPreviousPointerPos;
  40461. private _joystickPointerStartPos;
  40462. private _deltaJoystickVector;
  40463. private _leftJoystick;
  40464. private _touches;
  40465. private _onPointerDownHandlerRef;
  40466. private _onPointerMoveHandlerRef;
  40467. private _onPointerUpHandlerRef;
  40468. private _onResize;
  40469. /**
  40470. * Creates a new virtual joystick
  40471. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40472. */
  40473. constructor(leftJoystick?: boolean);
  40474. /**
  40475. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40476. * @param newJoystickSensibility defines the new sensibility
  40477. */
  40478. setJoystickSensibility(newJoystickSensibility: number): void;
  40479. private _onPointerDown;
  40480. private _onPointerMove;
  40481. private _onPointerUp;
  40482. /**
  40483. * Change the color of the virtual joystick
  40484. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40485. */
  40486. setJoystickColor(newColor: string): void;
  40487. /**
  40488. * Defines a callback to call when the joystick is touched
  40489. * @param action defines the callback
  40490. */
  40491. setActionOnTouch(action: () => any): void;
  40492. /**
  40493. * Defines which axis you'd like to control for left & right
  40494. * @param axis defines the axis to use
  40495. */
  40496. setAxisForLeftRight(axis: JoystickAxis): void;
  40497. /**
  40498. * Defines which axis you'd like to control for up & down
  40499. * @param axis defines the axis to use
  40500. */
  40501. setAxisForUpDown(axis: JoystickAxis): void;
  40502. private _drawVirtualJoystick;
  40503. /**
  40504. * Release internal HTML canvas
  40505. */
  40506. releaseCanvas(): void;
  40507. }
  40508. }
  40509. declare module BABYLON {
  40510. /**
  40511. * Helper class to push actions to a pool of workers.
  40512. */
  40513. class WorkerPool implements IDisposable {
  40514. private _workerInfos;
  40515. private _pendingActions;
  40516. /**
  40517. * Constructor
  40518. * @param workers Array of workers to use for actions
  40519. */
  40520. constructor(workers: Array<Worker>);
  40521. /**
  40522. * Terminates all workers and clears any pending actions.
  40523. */
  40524. dispose(): void;
  40525. /**
  40526. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40527. * pended until a worker has completed its action.
  40528. * @param action The action to perform. Call onComplete when the action is complete.
  40529. */
  40530. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40531. private _execute;
  40532. }
  40533. }
  40534. declare module BABYLON {
  40535. /**
  40536. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40537. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40538. */
  40539. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40540. /**
  40541. * Gets the name of the behavior.
  40542. */
  40543. readonly name: string;
  40544. private _zoomStopsAnimation;
  40545. private _idleRotationSpeed;
  40546. private _idleRotationWaitTime;
  40547. private _idleRotationSpinupTime;
  40548. /**
  40549. * Sets the flag that indicates if user zooming should stop animation.
  40550. */
  40551. /**
  40552. * Gets the flag that indicates if user zooming should stop animation.
  40553. */
  40554. zoomStopsAnimation: boolean;
  40555. /**
  40556. * Sets the default speed at which the camera rotates around the model.
  40557. */
  40558. /**
  40559. * Gets the default speed at which the camera rotates around the model.
  40560. */
  40561. idleRotationSpeed: number;
  40562. /**
  40563. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40564. */
  40565. /**
  40566. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40567. */
  40568. idleRotationWaitTime: number;
  40569. /**
  40570. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40571. */
  40572. /**
  40573. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40574. */
  40575. idleRotationSpinupTime: number;
  40576. /**
  40577. * Gets a value indicating if the camera is currently rotating because of this behavior
  40578. */
  40579. readonly rotationInProgress: boolean;
  40580. private _onPrePointerObservableObserver;
  40581. private _onAfterCheckInputsObserver;
  40582. private _attachedCamera;
  40583. private _isPointerDown;
  40584. private _lastFrameTime;
  40585. private _lastInteractionTime;
  40586. private _cameraRotationSpeed;
  40587. /**
  40588. * Initializes the behavior.
  40589. */
  40590. init(): void;
  40591. /**
  40592. * Attaches the behavior to its arc rotate camera.
  40593. * @param camera Defines the camera to attach the behavior to
  40594. */
  40595. attach(camera: ArcRotateCamera): void;
  40596. /**
  40597. * Detaches the behavior from its current arc rotate camera.
  40598. */
  40599. detach(): void;
  40600. /**
  40601. * Returns true if user is scrolling.
  40602. * @return true if user is scrolling.
  40603. */
  40604. private _userIsZooming;
  40605. private _lastFrameRadius;
  40606. private _shouldAnimationStopForInteraction;
  40607. /**
  40608. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40609. */
  40610. private _applyUserInteraction;
  40611. private _userIsMoving;
  40612. }
  40613. }
  40614. declare module BABYLON {
  40615. /**
  40616. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40617. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40618. */
  40619. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40620. /**
  40621. * Gets the name of the behavior.
  40622. */
  40623. readonly name: string;
  40624. /**
  40625. * The easing function used by animations
  40626. */
  40627. static EasingFunction: BackEase;
  40628. /**
  40629. * The easing mode used by animations
  40630. */
  40631. static EasingMode: number;
  40632. /**
  40633. * The duration of the animation, in milliseconds
  40634. */
  40635. transitionDuration: number;
  40636. /**
  40637. * Length of the distance animated by the transition when lower radius is reached
  40638. */
  40639. lowerRadiusTransitionRange: number;
  40640. /**
  40641. * Length of the distance animated by the transition when upper radius is reached
  40642. */
  40643. upperRadiusTransitionRange: number;
  40644. private _autoTransitionRange;
  40645. /**
  40646. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40647. */
  40648. /**
  40649. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40650. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40651. */
  40652. autoTransitionRange: boolean;
  40653. private _attachedCamera;
  40654. private _onAfterCheckInputsObserver;
  40655. private _onMeshTargetChangedObserver;
  40656. /**
  40657. * Initializes the behavior.
  40658. */
  40659. init(): void;
  40660. /**
  40661. * Attaches the behavior to its arc rotate camera.
  40662. * @param camera Defines the camera to attach the behavior to
  40663. */
  40664. attach(camera: ArcRotateCamera): void;
  40665. /**
  40666. * Detaches the behavior from its current arc rotate camera.
  40667. */
  40668. detach(): void;
  40669. private _radiusIsAnimating;
  40670. private _radiusBounceTransition;
  40671. private _animatables;
  40672. private _cachedWheelPrecision;
  40673. /**
  40674. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40675. * @param radiusLimit The limit to check against.
  40676. * @return Bool to indicate if at limit.
  40677. */
  40678. private _isRadiusAtLimit;
  40679. /**
  40680. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40681. * @param radiusDelta The delta by which to animate to. Can be negative.
  40682. */
  40683. private _applyBoundRadiusAnimation;
  40684. /**
  40685. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40686. */
  40687. protected _clearAnimationLocks(): void;
  40688. /**
  40689. * Stops and removes all animations that have been applied to the camera
  40690. */
  40691. stopAllAnimations(): void;
  40692. }
  40693. }
  40694. declare module BABYLON {
  40695. /**
  40696. * 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.
  40697. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40698. */
  40699. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40700. /**
  40701. * Gets the name of the behavior.
  40702. */
  40703. readonly name: string;
  40704. private _mode;
  40705. private _radiusScale;
  40706. private _positionScale;
  40707. private _defaultElevation;
  40708. private _elevationReturnTime;
  40709. private _elevationReturnWaitTime;
  40710. private _zoomStopsAnimation;
  40711. private _framingTime;
  40712. /**
  40713. * The easing function used by animations
  40714. */
  40715. static EasingFunction: ExponentialEase;
  40716. /**
  40717. * The easing mode used by animations
  40718. */
  40719. static EasingMode: number;
  40720. /**
  40721. * Sets the current mode used by the behavior
  40722. */
  40723. /**
  40724. * Gets current mode used by the behavior.
  40725. */
  40726. mode: number;
  40727. /**
  40728. * Sets the scale applied to the radius (1 by default)
  40729. */
  40730. /**
  40731. * Gets the scale applied to the radius
  40732. */
  40733. radiusScale: number;
  40734. /**
  40735. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40736. */
  40737. /**
  40738. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40739. */
  40740. positionScale: number;
  40741. /**
  40742. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40743. * behaviour is triggered, in radians.
  40744. */
  40745. /**
  40746. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40747. * behaviour is triggered, in radians.
  40748. */
  40749. defaultElevation: number;
  40750. /**
  40751. * Sets the time (in milliseconds) taken to return to the default beta position.
  40752. * Negative value indicates camera should not return to default.
  40753. */
  40754. /**
  40755. * Gets the time (in milliseconds) taken to return to the default beta position.
  40756. * Negative value indicates camera should not return to default.
  40757. */
  40758. elevationReturnTime: number;
  40759. /**
  40760. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40761. */
  40762. /**
  40763. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40764. */
  40765. elevationReturnWaitTime: number;
  40766. /**
  40767. * Sets the flag that indicates if user zooming should stop animation.
  40768. */
  40769. /**
  40770. * Gets the flag that indicates if user zooming should stop animation.
  40771. */
  40772. zoomStopsAnimation: boolean;
  40773. /**
  40774. * Sets the transition time when framing the mesh, in milliseconds
  40775. */
  40776. /**
  40777. * Gets the transition time when framing the mesh, in milliseconds
  40778. */
  40779. framingTime: number;
  40780. /**
  40781. * Define if the behavior should automatically change the configured
  40782. * camera limits and sensibilities.
  40783. */
  40784. autoCorrectCameraLimitsAndSensibility: boolean;
  40785. private _onPrePointerObservableObserver;
  40786. private _onAfterCheckInputsObserver;
  40787. private _onMeshTargetChangedObserver;
  40788. private _attachedCamera;
  40789. private _isPointerDown;
  40790. private _lastInteractionTime;
  40791. /**
  40792. * Initializes the behavior.
  40793. */
  40794. init(): void;
  40795. /**
  40796. * Attaches the behavior to its arc rotate camera.
  40797. * @param camera Defines the camera to attach the behavior to
  40798. */
  40799. attach(camera: ArcRotateCamera): void;
  40800. /**
  40801. * Detaches the behavior from its current arc rotate camera.
  40802. */
  40803. detach(): void;
  40804. private _animatables;
  40805. private _betaIsAnimating;
  40806. private _betaTransition;
  40807. private _radiusTransition;
  40808. private _vectorTransition;
  40809. /**
  40810. * Targets the given mesh and updates zoom level accordingly.
  40811. * @param mesh The mesh to target.
  40812. * @param radius Optional. If a cached radius position already exists, overrides default.
  40813. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40814. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40815. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40816. */
  40817. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40818. /**
  40819. * Targets the given mesh with its children and updates zoom level accordingly.
  40820. * @param mesh The mesh to target.
  40821. * @param radius Optional. If a cached radius position already exists, overrides default.
  40822. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40823. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40824. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40825. */
  40826. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40827. /**
  40828. * Targets the given meshes with their children and updates zoom level accordingly.
  40829. * @param meshes The mesh to target.
  40830. * @param radius Optional. If a cached radius position already exists, overrides default.
  40831. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40832. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40833. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40834. */
  40835. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40836. /**
  40837. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40838. * @param minimumWorld Determines the smaller position of the bounding box extend
  40839. * @param maximumWorld Determines the bigger position of the bounding box extend
  40840. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40841. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40842. */
  40843. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40844. /**
  40845. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40846. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40847. * frustum width.
  40848. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40849. * to fully enclose the mesh in the viewing frustum.
  40850. */
  40851. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40852. /**
  40853. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40854. * is automatically returned to its default position (expected to be above ground plane).
  40855. */
  40856. private _maintainCameraAboveGround;
  40857. /**
  40858. * Returns the frustum slope based on the canvas ratio and camera FOV
  40859. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40860. */
  40861. private _getFrustumSlope;
  40862. /**
  40863. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40864. */
  40865. private _clearAnimationLocks;
  40866. /**
  40867. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40868. */
  40869. private _applyUserInteraction;
  40870. /**
  40871. * Stops and removes all animations that have been applied to the camera
  40872. */
  40873. stopAllAnimations(): void;
  40874. /**
  40875. * Gets a value indicating if the user is moving the camera
  40876. */
  40877. readonly isUserIsMoving: boolean;
  40878. /**
  40879. * The camera can move all the way towards the mesh.
  40880. */
  40881. static IgnoreBoundsSizeMode: number;
  40882. /**
  40883. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40884. */
  40885. static FitFrustumSidesMode: number;
  40886. }
  40887. }
  40888. declare module BABYLON {
  40889. /**
  40890. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40891. */
  40892. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40893. private ui;
  40894. /**
  40895. * The name of the behavior
  40896. */
  40897. name: string;
  40898. /**
  40899. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40900. */
  40901. distanceAwayFromFace: number;
  40902. /**
  40903. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40904. */
  40905. distanceAwayFromBottomOfFace: number;
  40906. private _faceVectors;
  40907. private _target;
  40908. private _scene;
  40909. private _onRenderObserver;
  40910. private _tmpMatrix;
  40911. private _tmpVector;
  40912. /**
  40913. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40914. * @param ui The transform node that should be attched to the mesh
  40915. */
  40916. constructor(ui: BABYLON.TransformNode);
  40917. /**
  40918. * Initializes the behavior
  40919. */
  40920. init(): void;
  40921. private _closestFace;
  40922. private _zeroVector;
  40923. private _lookAtTmpMatrix;
  40924. private _lookAtToRef;
  40925. /**
  40926. * Attaches the AttachToBoxBehavior to the passed in mesh
  40927. * @param target The mesh that the specified node will be attached to
  40928. */
  40929. attach(target: BABYLON.Mesh): void;
  40930. /**
  40931. * Detaches the behavior from the mesh
  40932. */
  40933. detach(): void;
  40934. }
  40935. }
  40936. declare module BABYLON {
  40937. /**
  40938. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40939. */
  40940. class FadeInOutBehavior implements Behavior<Mesh> {
  40941. /**
  40942. * Time in milliseconds to delay before fading in (Default: 0)
  40943. */
  40944. delay: number;
  40945. /**
  40946. * Time in milliseconds for the mesh to fade in (Default: 300)
  40947. */
  40948. fadeInTime: number;
  40949. private _millisecondsPerFrame;
  40950. private _hovered;
  40951. private _hoverValue;
  40952. private _ownerNode;
  40953. /**
  40954. * Instatiates the FadeInOutBehavior
  40955. */
  40956. constructor();
  40957. /**
  40958. * The name of the behavior
  40959. */
  40960. readonly name: string;
  40961. /**
  40962. * Initializes the behavior
  40963. */
  40964. init(): void;
  40965. /**
  40966. * Attaches the fade behavior on the passed in mesh
  40967. * @param ownerNode The mesh that will be faded in/out once attached
  40968. */
  40969. attach(ownerNode: Mesh): void;
  40970. /**
  40971. * Detaches the behavior from the mesh
  40972. */
  40973. detach(): void;
  40974. /**
  40975. * Triggers the mesh to begin fading in or out
  40976. * @param value if the object should fade in or out (true to fade in)
  40977. */
  40978. fadeIn(value: boolean): void;
  40979. private _update;
  40980. private _setAllVisibility;
  40981. }
  40982. }
  40983. declare module BABYLON {
  40984. /**
  40985. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40986. */
  40987. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40988. private _dragBehaviorA;
  40989. private _dragBehaviorB;
  40990. private _startDistance;
  40991. private _initialScale;
  40992. private _targetScale;
  40993. private _ownerNode;
  40994. private _sceneRenderObserver;
  40995. /**
  40996. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40997. */
  40998. constructor();
  40999. /**
  41000. * The name of the behavior
  41001. */
  41002. readonly name: string;
  41003. /**
  41004. * Initializes the behavior
  41005. */
  41006. init(): void;
  41007. private _getCurrentDistance;
  41008. /**
  41009. * Attaches the scale behavior the passed in mesh
  41010. * @param ownerNode The mesh that will be scaled around once attached
  41011. */
  41012. attach(ownerNode: Mesh): void;
  41013. /**
  41014. * Detaches the behavior from the mesh
  41015. */
  41016. detach(): void;
  41017. }
  41018. }
  41019. declare module BABYLON {
  41020. /**
  41021. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  41022. */
  41023. class PointerDragBehavior implements Behavior<AbstractMesh> {
  41024. private static _AnyMouseID;
  41025. private _attachedNode;
  41026. private _dragPlane;
  41027. private _scene;
  41028. private _pointerObserver;
  41029. private _beforeRenderObserver;
  41030. private static _planeScene;
  41031. /**
  41032. * 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)
  41033. */
  41034. maxDragAngle: number;
  41035. /**
  41036. * @hidden
  41037. */
  41038. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  41039. /**
  41040. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41041. */
  41042. currentDraggingPointerID: number;
  41043. /**
  41044. * The last position where the pointer hit the drag plane in world space
  41045. */
  41046. lastDragPosition: Vector3;
  41047. /**
  41048. * If the behavior is currently in a dragging state
  41049. */
  41050. dragging: boolean;
  41051. /**
  41052. * 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)
  41053. */
  41054. dragDeltaRatio: number;
  41055. /**
  41056. * If the drag plane orientation should be updated during the dragging (Default: true)
  41057. */
  41058. updateDragPlane: boolean;
  41059. private _debugMode;
  41060. private _moving;
  41061. /**
  41062. * Fires each time the attached mesh is dragged with the pointer
  41063. * * delta between last drag position and current drag position in world space
  41064. * * dragDistance along the drag axis
  41065. * * dragPlaneNormal normal of the current drag plane used during the drag
  41066. * * dragPlanePoint in world space where the drag intersects the drag plane
  41067. */
  41068. onDragObservable: Observable<{
  41069. delta: Vector3;
  41070. dragPlanePoint: Vector3;
  41071. dragPlaneNormal: Vector3;
  41072. dragDistance: number;
  41073. pointerId: number;
  41074. }>;
  41075. /**
  41076. * Fires each time a drag begins (eg. mouse down on mesh)
  41077. */
  41078. onDragStartObservable: Observable<{
  41079. dragPlanePoint: Vector3;
  41080. pointerId: number;
  41081. }>;
  41082. /**
  41083. * Fires each time a drag ends (eg. mouse release after drag)
  41084. */
  41085. onDragEndObservable: Observable<{
  41086. dragPlanePoint: Vector3;
  41087. pointerId: number;
  41088. }>;
  41089. /**
  41090. * If the attached mesh should be moved when dragged
  41091. */
  41092. moveAttached: boolean;
  41093. /**
  41094. * If the drag behavior will react to drag events (Default: true)
  41095. */
  41096. enabled: boolean;
  41097. /**
  41098. * If camera controls should be detached during the drag
  41099. */
  41100. detachCameraControls: boolean;
  41101. /**
  41102. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41103. */
  41104. useObjectOrienationForDragging: boolean;
  41105. private _options;
  41106. /**
  41107. * Creates a pointer drag behavior that can be attached to a mesh
  41108. * @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)
  41109. */
  41110. constructor(options?: {
  41111. dragAxis?: Vector3;
  41112. dragPlaneNormal?: Vector3;
  41113. });
  41114. /**
  41115. * The name of the behavior
  41116. */
  41117. readonly name: string;
  41118. /**
  41119. * Initializes the behavior
  41120. */
  41121. init(): void;
  41122. private _tmpVector;
  41123. private _alternatePickedPoint;
  41124. private _worldDragAxis;
  41125. private _targetPosition;
  41126. private _attachedElement;
  41127. /**
  41128. * Attaches the drag behavior the passed in mesh
  41129. * @param ownerNode The mesh that will be dragged around once attached
  41130. */
  41131. attach(ownerNode: AbstractMesh): void;
  41132. /**
  41133. * Force relase the drag action by code.
  41134. */
  41135. releaseDrag(): void;
  41136. private _startDragRay;
  41137. private _lastPointerRay;
  41138. /**
  41139. * Simulates the start of a pointer drag event on the behavior
  41140. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41141. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41142. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41143. */
  41144. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41145. private _startDrag;
  41146. private _dragDelta;
  41147. private _moveDrag;
  41148. private _pickWithRayOnDragPlane;
  41149. private _pointA;
  41150. private _pointB;
  41151. private _pointC;
  41152. private _lineA;
  41153. private _lineB;
  41154. private _localAxis;
  41155. private _lookAt;
  41156. private _updateDragPlanePosition;
  41157. /**
  41158. * Detaches the behavior from the mesh
  41159. */
  41160. detach(): void;
  41161. }
  41162. }
  41163. declare module BABYLON {
  41164. /**
  41165. * 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
  41166. */
  41167. class SixDofDragBehavior implements Behavior<Mesh> {
  41168. private static _virtualScene;
  41169. private _ownerNode;
  41170. private _sceneRenderObserver;
  41171. private _scene;
  41172. private _targetPosition;
  41173. private _virtualOriginMesh;
  41174. private _virtualDragMesh;
  41175. private _pointerObserver;
  41176. private _moving;
  41177. private _startingOrientation;
  41178. /**
  41179. * 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)
  41180. */
  41181. private zDragFactor;
  41182. /**
  41183. * If the behavior is currently in a dragging state
  41184. */
  41185. dragging: boolean;
  41186. /**
  41187. * 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)
  41188. */
  41189. dragDeltaRatio: number;
  41190. /**
  41191. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41192. */
  41193. currentDraggingPointerID: number;
  41194. /**
  41195. * If camera controls should be detached during the drag
  41196. */
  41197. detachCameraControls: boolean;
  41198. /**
  41199. * Fires each time a drag starts
  41200. */
  41201. onDragStartObservable: Observable<{}>;
  41202. /**
  41203. * Fires each time a drag ends (eg. mouse release after drag)
  41204. */
  41205. onDragEndObservable: Observable<{}>;
  41206. /**
  41207. * 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
  41208. */
  41209. constructor();
  41210. /**
  41211. * The name of the behavior
  41212. */
  41213. readonly name: string;
  41214. /**
  41215. * Initializes the behavior
  41216. */
  41217. init(): void;
  41218. /**
  41219. * Attaches the scale behavior the passed in mesh
  41220. * @param ownerNode The mesh that will be scaled around once attached
  41221. */
  41222. attach(ownerNode: Mesh): void;
  41223. /**
  41224. * Detaches the behavior from the mesh
  41225. */
  41226. detach(): void;
  41227. }
  41228. }
  41229. declare module BABYLON {
  41230. /**
  41231. * Contains an array of blocks representing the octree
  41232. */
  41233. interface IOctreeContainer<T> {
  41234. /**
  41235. * Blocks within the octree
  41236. */
  41237. blocks: Array<OctreeBlock<T>>;
  41238. }
  41239. /**
  41240. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41241. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41242. */
  41243. class Octree<T> {
  41244. /** 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.) */
  41245. maxDepth: number;
  41246. /**
  41247. * Blocks within the octree containing objects
  41248. */
  41249. blocks: Array<OctreeBlock<T>>;
  41250. /**
  41251. * Content stored in the octree
  41252. */
  41253. dynamicContent: T[];
  41254. private _maxBlockCapacity;
  41255. private _selectionContent;
  41256. private _creationFunc;
  41257. /**
  41258. * Creates a octree
  41259. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41260. * @param creationFunc function to be used to instatiate the octree
  41261. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41262. * @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.)
  41263. */
  41264. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41265. /** 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.) */
  41266. maxDepth?: number);
  41267. /**
  41268. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41269. * @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);
  41270. * @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);
  41271. * @param entries meshes to be added to the octree blocks
  41272. */
  41273. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41274. /**
  41275. * Adds a mesh to the octree
  41276. * @param entry Mesh to add to the octree
  41277. */
  41278. addMesh(entry: T): void;
  41279. /**
  41280. * Selects an array of meshes within the frustum
  41281. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41282. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41283. * @returns array of meshes within the frustum
  41284. */
  41285. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41286. /**
  41287. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41288. * @param sphereCenter defines the bounding sphere center
  41289. * @param sphereRadius defines the bounding sphere radius
  41290. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41291. * @returns an array of objects that intersect the sphere
  41292. */
  41293. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41294. /**
  41295. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41296. * @param ray defines the ray to test with
  41297. * @returns array of intersected objects
  41298. */
  41299. intersectsRay(ray: Ray): SmartArray<T>;
  41300. /**
  41301. * @hidden
  41302. */
  41303. 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;
  41304. /**
  41305. * Adds a mesh into the octree block if it intersects the block
  41306. */
  41307. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41308. /**
  41309. * Adds a submesh into the octree block if it intersects the block
  41310. */
  41311. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41312. }
  41313. }
  41314. declare module BABYLON {
  41315. /**
  41316. * Class used to store a cell in an octree
  41317. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41318. */
  41319. class OctreeBlock<T> {
  41320. /**
  41321. * Gets the content of the current block
  41322. */
  41323. entries: T[];
  41324. /**
  41325. * Gets the list of block children
  41326. */
  41327. blocks: Array<OctreeBlock<T>>;
  41328. private _depth;
  41329. private _maxDepth;
  41330. private _capacity;
  41331. private _minPoint;
  41332. private _maxPoint;
  41333. private _boundingVectors;
  41334. private _creationFunc;
  41335. /**
  41336. * Creates a new block
  41337. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41338. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41339. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41340. * @param depth defines the current depth of this block in the octree
  41341. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41342. * @param creationFunc defines a callback to call when an element is added to the block
  41343. */
  41344. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41345. /**
  41346. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41347. */
  41348. readonly capacity: number;
  41349. /**
  41350. * Gets the minimum vector (in world space) of the block's bounding box
  41351. */
  41352. readonly minPoint: Vector3;
  41353. /**
  41354. * Gets the maximum vector (in world space) of the block's bounding box
  41355. */
  41356. readonly maxPoint: Vector3;
  41357. /**
  41358. * Add a new element to this block
  41359. * @param entry defines the element to add
  41360. */
  41361. addEntry(entry: T): void;
  41362. /**
  41363. * Add an array of elements to this block
  41364. * @param entries defines the array of elements to add
  41365. */
  41366. addEntries(entries: T[]): void;
  41367. /**
  41368. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41369. * @param frustumPlanes defines the frustum planes to test
  41370. * @param selection defines the array to store current content if selection is positive
  41371. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41372. */
  41373. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41374. /**
  41375. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41376. * @param sphereCenter defines the bounding sphere center
  41377. * @param sphereRadius defines the bounding sphere radius
  41378. * @param selection defines the array to store current content if selection is positive
  41379. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41380. */
  41381. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41382. /**
  41383. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41384. * @param ray defines the ray to test with
  41385. * @param selection defines the array to store current content if selection is positive
  41386. */
  41387. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41388. /**
  41389. * Subdivide the content into child blocks (this block will then be empty)
  41390. */
  41391. createInnerBlocks(): void;
  41392. }
  41393. }
  41394. declare module BABYLON {
  41395. interface Scene {
  41396. /**
  41397. * @hidden
  41398. * Backing Filed
  41399. */
  41400. _selectionOctree: Octree<AbstractMesh>;
  41401. /**
  41402. * Gets the octree used to boost mesh selection (picking)
  41403. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41404. */
  41405. selectionOctree: Octree<AbstractMesh>;
  41406. /**
  41407. * Creates or updates the octree used to boost selection (picking)
  41408. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41409. * @param maxCapacity defines the maximum capacity per leaf
  41410. * @param maxDepth defines the maximum depth of the octree
  41411. * @returns an octree of AbstractMesh
  41412. */
  41413. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41414. }
  41415. interface AbstractMesh {
  41416. /**
  41417. * @hidden
  41418. * Backing Field
  41419. */
  41420. _submeshesOctree: Octree<SubMesh>;
  41421. /**
  41422. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41423. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41424. * @param maxCapacity defines the maximum size of each block (64 by default)
  41425. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41426. * @returns the new octree
  41427. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41429. */
  41430. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41431. }
  41432. /**
  41433. * Defines the octree scene component responsible to manage any octrees
  41434. * in a given scene.
  41435. */
  41436. class OctreeSceneComponent {
  41437. /**
  41438. * The component name helpfull to identify the component in the list of scene components.
  41439. */
  41440. readonly name: string;
  41441. /**
  41442. * The scene the component belongs to.
  41443. */
  41444. scene: Scene;
  41445. /**
  41446. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41447. */
  41448. readonly checksIsEnabled: boolean;
  41449. /**
  41450. * Creates a new instance of the component for the given scene
  41451. * @param scene Defines the scene to register the component in
  41452. */
  41453. constructor(scene: Scene);
  41454. /**
  41455. * Registers the component in a given scene
  41456. */
  41457. register(): void;
  41458. /**
  41459. * Return the list of active meshes
  41460. * @returns the list of active meshes
  41461. */
  41462. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41463. /**
  41464. * Return the list of active sub meshes
  41465. * @param mesh The mesh to get the candidates sub meshes from
  41466. * @returns the list of active sub meshes
  41467. */
  41468. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41469. private _tempRay;
  41470. /**
  41471. * Return the list of sub meshes intersecting with a given local ray
  41472. * @param mesh defines the mesh to find the submesh for
  41473. * @param localRay defines the ray in local space
  41474. * @returns the list of intersecting sub meshes
  41475. */
  41476. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41477. /**
  41478. * Return the list of sub meshes colliding with a collider
  41479. * @param mesh defines the mesh to find the submesh for
  41480. * @param collider defines the collider to evaluate the collision against
  41481. * @returns the list of colliding sub meshes
  41482. */
  41483. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41484. /**
  41485. * Rebuilds the elements related to this component in case of
  41486. * context lost for instance.
  41487. */
  41488. rebuild(): void;
  41489. /**
  41490. * Disposes the component and the associated ressources.
  41491. */
  41492. dispose(): void;
  41493. }
  41494. }
  41495. declare module BABYLON {
  41496. /**
  41497. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41498. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41499. */
  41500. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41501. /**
  41502. * Creates a new AnaglyphArcRotateCamera
  41503. * @param name defines camera name
  41504. * @param alpha defines alpha angle (in radians)
  41505. * @param beta defines beta angle (in radians)
  41506. * @param radius defines radius
  41507. * @param target defines camera target
  41508. * @param interaxialDistance defines distance between each color axis
  41509. * @param scene defines the hosting scene
  41510. */
  41511. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41512. /**
  41513. * Gets camera class name
  41514. * @returns AnaglyphArcRotateCamera
  41515. */
  41516. getClassName(): string;
  41517. }
  41518. }
  41519. declare module BABYLON {
  41520. /**
  41521. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41522. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41523. */
  41524. class AnaglyphFreeCamera extends FreeCamera {
  41525. /**
  41526. * Creates a new AnaglyphFreeCamera
  41527. * @param name defines camera name
  41528. * @param position defines initial position
  41529. * @param interaxialDistance defines distance between each color axis
  41530. * @param scene defines the hosting scene
  41531. */
  41532. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41533. /**
  41534. * Gets camera class name
  41535. * @returns AnaglyphFreeCamera
  41536. */
  41537. getClassName(): string;
  41538. }
  41539. }
  41540. declare module BABYLON {
  41541. /**
  41542. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41543. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41544. */
  41545. class AnaglyphGamepadCamera extends GamepadCamera {
  41546. /**
  41547. * Creates a new AnaglyphGamepadCamera
  41548. * @param name defines camera name
  41549. * @param position defines initial position
  41550. * @param interaxialDistance defines distance between each color axis
  41551. * @param scene defines the hosting scene
  41552. */
  41553. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41554. /**
  41555. * Gets camera class name
  41556. * @returns AnaglyphGamepadCamera
  41557. */
  41558. getClassName(): string;
  41559. }
  41560. }
  41561. declare module BABYLON {
  41562. /**
  41563. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41564. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41565. */
  41566. class AnaglyphUniversalCamera extends UniversalCamera {
  41567. /**
  41568. * Creates a new AnaglyphUniversalCamera
  41569. * @param name defines camera name
  41570. * @param position defines initial position
  41571. * @param interaxialDistance defines distance between each color axis
  41572. * @param scene defines the hosting scene
  41573. */
  41574. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41575. /**
  41576. * Gets camera class name
  41577. * @returns AnaglyphUniversalCamera
  41578. */
  41579. getClassName(): string;
  41580. }
  41581. }
  41582. declare module BABYLON {
  41583. /**
  41584. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41585. * @see http://doc.babylonjs.com/features/cameras
  41586. */
  41587. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41588. /**
  41589. * Creates a new StereoscopicArcRotateCamera
  41590. * @param name defines camera name
  41591. * @param alpha defines alpha angle (in radians)
  41592. * @param beta defines beta angle (in radians)
  41593. * @param radius defines radius
  41594. * @param target defines camera target
  41595. * @param interaxialDistance defines distance between each color axis
  41596. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41597. * @param scene defines the hosting scene
  41598. */
  41599. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41600. /**
  41601. * Gets camera class name
  41602. * @returns StereoscopicArcRotateCamera
  41603. */
  41604. getClassName(): string;
  41605. }
  41606. }
  41607. declare module BABYLON {
  41608. /**
  41609. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41610. * @see http://doc.babylonjs.com/features/cameras
  41611. */
  41612. class StereoscopicFreeCamera extends FreeCamera {
  41613. /**
  41614. * Creates a new StereoscopicFreeCamera
  41615. * @param name defines camera name
  41616. * @param position defines initial position
  41617. * @param interaxialDistance defines distance between each color axis
  41618. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41619. * @param scene defines the hosting scene
  41620. */
  41621. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41622. /**
  41623. * Gets camera class name
  41624. * @returns StereoscopicFreeCamera
  41625. */
  41626. getClassName(): string;
  41627. }
  41628. }
  41629. declare module BABYLON {
  41630. /**
  41631. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41632. * @see http://doc.babylonjs.com/features/cameras
  41633. */
  41634. class StereoscopicGamepadCamera extends GamepadCamera {
  41635. /**
  41636. * Creates a new StereoscopicGamepadCamera
  41637. * @param name defines camera name
  41638. * @param position defines initial position
  41639. * @param interaxialDistance defines distance between each color axis
  41640. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41641. * @param scene defines the hosting scene
  41642. */
  41643. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41644. /**
  41645. * Gets camera class name
  41646. * @returns StereoscopicGamepadCamera
  41647. */
  41648. getClassName(): string;
  41649. }
  41650. }
  41651. declare module BABYLON {
  41652. /**
  41653. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41654. * @see http://doc.babylonjs.com/features/cameras
  41655. */
  41656. class StereoscopicUniversalCamera extends UniversalCamera {
  41657. /**
  41658. * Creates a new StereoscopicUniversalCamera
  41659. * @param name defines camera name
  41660. * @param position defines initial position
  41661. * @param interaxialDistance defines distance between each color axis
  41662. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41663. * @param scene defines the hosting scene
  41664. */
  41665. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41666. /**
  41667. * Gets camera class name
  41668. * @returns StereoscopicUniversalCamera
  41669. */
  41670. getClassName(): string;
  41671. }
  41672. }
  41673. declare module BABYLON {
  41674. /**
  41675. * Manage the gamepad inputs to control an arc rotate camera.
  41676. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41677. */
  41678. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41679. /**
  41680. * Defines the camera the input is attached to.
  41681. */
  41682. camera: ArcRotateCamera;
  41683. /**
  41684. * Defines the gamepad the input is gathering event from.
  41685. */
  41686. gamepad: Nullable<Gamepad>;
  41687. /**
  41688. * Defines the gamepad rotation sensiblity.
  41689. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41690. */
  41691. gamepadRotationSensibility: number;
  41692. /**
  41693. * Defines the gamepad move sensiblity.
  41694. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41695. */
  41696. gamepadMoveSensibility: number;
  41697. private _onGamepadConnectedObserver;
  41698. private _onGamepadDisconnectedObserver;
  41699. /**
  41700. * Attach the input controls to a specific dom element to get the input from.
  41701. * @param element Defines the element the controls should be listened from
  41702. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41703. */
  41704. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41705. /**
  41706. * Detach the current controls from the specified dom element.
  41707. * @param element Defines the element to stop listening the inputs from
  41708. */
  41709. detachControl(element: Nullable<HTMLElement>): void;
  41710. /**
  41711. * Update the current camera state depending on the inputs that have been used this frame.
  41712. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41713. */
  41714. checkInputs(): void;
  41715. /**
  41716. * Gets the class name of the current intput.
  41717. * @returns the class name
  41718. */
  41719. getClassName(): string;
  41720. /**
  41721. * Get the friendly name associated with the input class.
  41722. * @returns the input friendly name
  41723. */
  41724. getSimpleName(): string;
  41725. }
  41726. }
  41727. declare module BABYLON {
  41728. /**
  41729. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41730. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41731. */
  41732. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41733. /**
  41734. * Defines the camera the input is attached to.
  41735. */
  41736. camera: ArcRotateCamera;
  41737. /**
  41738. * Defines the list of key codes associated with the up action (increase alpha)
  41739. */
  41740. keysUp: number[];
  41741. /**
  41742. * Defines the list of key codes associated with the down action (decrease alpha)
  41743. */
  41744. keysDown: number[];
  41745. /**
  41746. * Defines the list of key codes associated with the left action (increase beta)
  41747. */
  41748. keysLeft: number[];
  41749. /**
  41750. * Defines the list of key codes associated with the right action (decrease beta)
  41751. */
  41752. keysRight: number[];
  41753. /**
  41754. * Defines the list of key codes associated with the reset action.
  41755. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41756. */
  41757. keysReset: number[];
  41758. /**
  41759. * Defines the panning sensibility of the inputs.
  41760. * (How fast is the camera paning)
  41761. */
  41762. panningSensibility: number;
  41763. /**
  41764. * Defines the zooming sensibility of the inputs.
  41765. * (How fast is the camera zooming)
  41766. */
  41767. zoomingSensibility: number;
  41768. /**
  41769. * Defines wether maintaining the alt key down switch the movement mode from
  41770. * orientation to zoom.
  41771. */
  41772. useAltToZoom: boolean;
  41773. /**
  41774. * Rotation speed of the camera
  41775. */
  41776. angularSpeed: number;
  41777. private _keys;
  41778. private _ctrlPressed;
  41779. private _altPressed;
  41780. private _onCanvasBlurObserver;
  41781. private _onKeyboardObserver;
  41782. private _engine;
  41783. private _scene;
  41784. /**
  41785. * Attach the input controls to a specific dom element to get the input from.
  41786. * @param element Defines the element the controls should be listened from
  41787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41788. */
  41789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41790. /**
  41791. * Detach the current controls from the specified dom element.
  41792. * @param element Defines the element to stop listening the inputs from
  41793. */
  41794. detachControl(element: Nullable<HTMLElement>): void;
  41795. /**
  41796. * Update the current camera state depending on the inputs that have been used this frame.
  41797. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41798. */
  41799. checkInputs(): void;
  41800. /**
  41801. * Gets the class name of the current intput.
  41802. * @returns the class name
  41803. */
  41804. getClassName(): string;
  41805. /**
  41806. * Get the friendly name associated with the input class.
  41807. * @returns the input friendly name
  41808. */
  41809. getSimpleName(): string;
  41810. }
  41811. }
  41812. declare module BABYLON {
  41813. /**
  41814. * Manage the mouse wheel inputs to control an arc rotate camera.
  41815. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41816. */
  41817. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41818. /**
  41819. * Defines the camera the input is attached to.
  41820. */
  41821. camera: ArcRotateCamera;
  41822. /**
  41823. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41824. */
  41825. wheelPrecision: number;
  41826. /**
  41827. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41828. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41829. */
  41830. wheelDeltaPercentage: number;
  41831. private _wheel;
  41832. private _observer;
  41833. /**
  41834. * Attach the input controls to a specific dom element to get the input from.
  41835. * @param element Defines the element the controls should be listened from
  41836. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41837. */
  41838. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41839. /**
  41840. * Detach the current controls from the specified dom element.
  41841. * @param element Defines the element to stop listening the inputs from
  41842. */
  41843. detachControl(element: Nullable<HTMLElement>): void;
  41844. /**
  41845. * Gets the class name of the current intput.
  41846. * @returns the class name
  41847. */
  41848. getClassName(): string;
  41849. /**
  41850. * Get the friendly name associated with the input class.
  41851. * @returns the input friendly name
  41852. */
  41853. getSimpleName(): string;
  41854. }
  41855. }
  41856. declare module BABYLON {
  41857. /**
  41858. * Manage the pointers inputs to control an arc rotate camera.
  41859. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41860. */
  41861. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41862. /**
  41863. * Defines the camera the input is attached to.
  41864. */
  41865. camera: ArcRotateCamera;
  41866. /**
  41867. * Defines the buttons associated with the input to handle camera move.
  41868. */
  41869. buttons: number[];
  41870. /**
  41871. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41872. */
  41873. angularSensibilityX: number;
  41874. /**
  41875. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41876. */
  41877. angularSensibilityY: number;
  41878. /**
  41879. * Defines the pointer pinch precision or how fast is the camera zooming.
  41880. */
  41881. pinchPrecision: number;
  41882. /**
  41883. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41884. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41885. */
  41886. pinchDeltaPercentage: number;
  41887. /**
  41888. * Defines the pointer panning sensibility or how fast is the camera moving.
  41889. */
  41890. panningSensibility: number;
  41891. /**
  41892. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41893. */
  41894. multiTouchPanning: boolean;
  41895. /**
  41896. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41897. */
  41898. multiTouchPanAndZoom: boolean;
  41899. /**
  41900. * Revers pinch action direction.
  41901. */
  41902. pinchInwards: boolean;
  41903. private _isPanClick;
  41904. private _pointerInput;
  41905. private _observer;
  41906. private _onMouseMove;
  41907. private _onGestureStart;
  41908. private _onGesture;
  41909. private _MSGestureHandler;
  41910. private _onLostFocus;
  41911. private _onContextMenu;
  41912. /**
  41913. * Attach the input controls to a specific dom element to get the input from.
  41914. * @param element Defines the element the controls should be listened from
  41915. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41916. */
  41917. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41918. /**
  41919. * Detach the current controls from the specified dom element.
  41920. * @param element Defines the element to stop listening the inputs from
  41921. */
  41922. detachControl(element: Nullable<HTMLElement>): void;
  41923. /**
  41924. * Gets the class name of the current intput.
  41925. * @returns the class name
  41926. */
  41927. getClassName(): string;
  41928. /**
  41929. * Get the friendly name associated with the input class.
  41930. * @returns the input friendly name
  41931. */
  41932. getSimpleName(): string;
  41933. }
  41934. }
  41935. declare module BABYLON {
  41936. /**
  41937. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41939. */
  41940. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41941. /**
  41942. * Defines the camera the input is attached to.
  41943. */
  41944. camera: ArcRotateCamera;
  41945. /**
  41946. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41947. */
  41948. alphaCorrection: number;
  41949. /**
  41950. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41951. */
  41952. gammaCorrection: number;
  41953. private _alpha;
  41954. private _gamma;
  41955. private _dirty;
  41956. private _deviceOrientationHandler;
  41957. /**
  41958. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41959. */
  41960. constructor();
  41961. /**
  41962. * Attach the input controls to a specific dom element to get the input from.
  41963. * @param element Defines the element the controls should be listened from
  41964. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41965. */
  41966. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41967. /** @hidden */
  41968. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41969. /**
  41970. * Update the current camera state depending on the inputs that have been used this frame.
  41971. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41972. */
  41973. checkInputs(): void;
  41974. /**
  41975. * Detach the current controls from the specified dom element.
  41976. * @param element Defines the element to stop listening the inputs from
  41977. */
  41978. detachControl(element: Nullable<HTMLElement>): void;
  41979. /**
  41980. * Gets the class name of the current intput.
  41981. * @returns the class name
  41982. */
  41983. getClassName(): string;
  41984. /**
  41985. * Get the friendly name associated with the input class.
  41986. * @returns the input friendly name
  41987. */
  41988. getSimpleName(): string;
  41989. }
  41990. }
  41991. declare module BABYLON {
  41992. /**
  41993. * Listen to keyboard events to control the camera.
  41994. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41995. */
  41996. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41997. /**
  41998. * Defines the camera the input is attached to.
  41999. */
  42000. camera: FlyCamera;
  42001. /**
  42002. * The list of keyboard keys used to control the forward move of the camera.
  42003. */
  42004. keysForward: number[];
  42005. /**
  42006. * The list of keyboard keys used to control the backward move of the camera.
  42007. */
  42008. keysBackward: number[];
  42009. /**
  42010. * The list of keyboard keys used to control the forward move of the camera.
  42011. */
  42012. keysUp: number[];
  42013. /**
  42014. * The list of keyboard keys used to control the backward move of the camera.
  42015. */
  42016. keysDown: number[];
  42017. /**
  42018. * The list of keyboard keys used to control the right strafe move of the camera.
  42019. */
  42020. keysRight: number[];
  42021. /**
  42022. * The list of keyboard keys used to control the left strafe move of the camera.
  42023. */
  42024. keysLeft: number[];
  42025. private _keys;
  42026. private _onCanvasBlurObserver;
  42027. private _onKeyboardObserver;
  42028. private _engine;
  42029. private _scene;
  42030. /**
  42031. * Attach the input controls to a specific dom element to get the input from.
  42032. * @param element Defines the element the controls should be listened from
  42033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42034. */
  42035. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42036. /**
  42037. * Detach the current controls from the specified dom element.
  42038. * @param element Defines the element to stop listening the inputs from
  42039. */
  42040. detachControl(element: Nullable<HTMLElement>): void;
  42041. /**
  42042. * Gets the class name of the current intput.
  42043. * @returns the class name
  42044. */
  42045. getClassName(): string;
  42046. /** @hidden */
  42047. _onLostFocus(e: FocusEvent): void;
  42048. /**
  42049. * Get the friendly name associated with the input class.
  42050. * @returns the input friendly name
  42051. */
  42052. getSimpleName(): string;
  42053. /**
  42054. * Update the current camera state depending on the inputs that have been used this frame.
  42055. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42056. */
  42057. checkInputs(): void;
  42058. }
  42059. }
  42060. declare module BABYLON {
  42061. /**
  42062. * Listen to mouse events to control the camera.
  42063. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42064. */
  42065. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42066. /**
  42067. * Defines the camera the input is attached to.
  42068. */
  42069. camera: FlyCamera;
  42070. /**
  42071. * Defines if touch is enabled. (Default is true.)
  42072. */
  42073. touchEnabled: boolean;
  42074. /**
  42075. * Defines the buttons associated with the input to handle camera rotation.
  42076. */
  42077. buttons: number[];
  42078. /**
  42079. * Assign buttons for Yaw control.
  42080. */
  42081. buttonsYaw: number[];
  42082. /**
  42083. * Assign buttons for Pitch control.
  42084. */
  42085. buttonsPitch: number[];
  42086. /**
  42087. * Assign buttons for Roll control.
  42088. */
  42089. buttonsRoll: number[];
  42090. /**
  42091. * Detect if any button is being pressed while mouse is moved.
  42092. * -1 = Mouse locked.
  42093. * 0 = Left button.
  42094. * 1 = Middle Button.
  42095. * 2 = Right Button.
  42096. */
  42097. activeButton: number;
  42098. /**
  42099. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42100. * Higher values reduce its sensitivity.
  42101. */
  42102. angularSensibility: number;
  42103. private _mousemoveCallback;
  42104. private _observer;
  42105. private _rollObserver;
  42106. private previousPosition;
  42107. private noPreventDefault;
  42108. private element;
  42109. /**
  42110. * Listen to mouse events to control the camera.
  42111. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42112. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42113. */
  42114. constructor(touchEnabled?: boolean);
  42115. /**
  42116. * Attach the mouse control to the HTML DOM element.
  42117. * @param element Defines the element that listens to the input events.
  42118. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  42119. */
  42120. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42121. /**
  42122. * Detach the current controls from the specified dom element.
  42123. * @param element Defines the element to stop listening the inputs from
  42124. */
  42125. detachControl(element: Nullable<HTMLElement>): void;
  42126. /**
  42127. * Gets the class name of the current input.
  42128. * @returns the class name.
  42129. */
  42130. getClassName(): string;
  42131. /**
  42132. * Get the friendly name associated with the input class.
  42133. * @returns the input's friendly name.
  42134. */
  42135. getSimpleName(): string;
  42136. private _pointerInput;
  42137. private _onMouseMove;
  42138. /**
  42139. * Rotate camera by mouse offset.
  42140. */
  42141. private rotateCamera;
  42142. }
  42143. }
  42144. declare module BABYLON {
  42145. /**
  42146. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42147. * Screen rotation is taken into account.
  42148. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42149. */
  42150. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42151. private _camera;
  42152. private _screenOrientationAngle;
  42153. private _constantTranform;
  42154. private _screenQuaternion;
  42155. private _alpha;
  42156. private _beta;
  42157. private _gamma;
  42158. /**
  42159. * Instantiates a new input
  42160. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42161. */
  42162. constructor();
  42163. /**
  42164. * Define the camera controlled by the input.
  42165. */
  42166. camera: FreeCamera;
  42167. /**
  42168. * Attach the input controls to a specific dom element to get the input from.
  42169. * @param element Defines the element the controls should be listened from
  42170. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42171. */
  42172. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42173. private _orientationChanged;
  42174. private _deviceOrientation;
  42175. /**
  42176. * Detach the current controls from the specified dom element.
  42177. * @param element Defines the element to stop listening the inputs from
  42178. */
  42179. detachControl(element: Nullable<HTMLElement>): void;
  42180. /**
  42181. * Update the current camera state depending on the inputs that have been used this frame.
  42182. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42183. */
  42184. checkInputs(): void;
  42185. /**
  42186. * Gets the class name of the current intput.
  42187. * @returns the class name
  42188. */
  42189. getClassName(): string;
  42190. /**
  42191. * Get the friendly name associated with the input class.
  42192. * @returns the input friendly name
  42193. */
  42194. getSimpleName(): string;
  42195. }
  42196. }
  42197. declare module BABYLON {
  42198. /**
  42199. * Manage the gamepad inputs to control a free camera.
  42200. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42201. */
  42202. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42203. /**
  42204. * Define the camera the input is attached to.
  42205. */
  42206. camera: FreeCamera;
  42207. /**
  42208. * Define the Gamepad controlling the input
  42209. */
  42210. gamepad: Nullable<Gamepad>;
  42211. /**
  42212. * Defines the gamepad rotation sensiblity.
  42213. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42214. */
  42215. gamepadAngularSensibility: number;
  42216. /**
  42217. * Defines the gamepad move sensiblity.
  42218. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42219. */
  42220. gamepadMoveSensibility: number;
  42221. private _onGamepadConnectedObserver;
  42222. private _onGamepadDisconnectedObserver;
  42223. private _cameraTransform;
  42224. private _deltaTransform;
  42225. private _vector3;
  42226. private _vector2;
  42227. /**
  42228. * Attach the input controls to a specific dom element to get the input from.
  42229. * @param element Defines the element the controls should be listened from
  42230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42231. */
  42232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42233. /**
  42234. * Detach the current controls from the specified dom element.
  42235. * @param element Defines the element to stop listening the inputs from
  42236. */
  42237. detachControl(element: Nullable<HTMLElement>): void;
  42238. /**
  42239. * Update the current camera state depending on the inputs that have been used this frame.
  42240. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42241. */
  42242. checkInputs(): void;
  42243. /**
  42244. * Gets the class name of the current intput.
  42245. * @returns the class name
  42246. */
  42247. getClassName(): string;
  42248. /**
  42249. * Get the friendly name associated with the input class.
  42250. * @returns the input friendly name
  42251. */
  42252. getSimpleName(): string;
  42253. }
  42254. }
  42255. declare module BABYLON {
  42256. /**
  42257. * Manage the keyboard inputs to control the movement of a free camera.
  42258. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42259. */
  42260. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  42261. /**
  42262. * Defines the camera the input is attached to.
  42263. */
  42264. camera: FreeCamera;
  42265. /**
  42266. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  42267. */
  42268. keysUp: number[];
  42269. /**
  42270. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  42271. */
  42272. keysDown: number[];
  42273. /**
  42274. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  42275. */
  42276. keysLeft: number[];
  42277. /**
  42278. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  42279. */
  42280. keysRight: number[];
  42281. private _keys;
  42282. private _onCanvasBlurObserver;
  42283. private _onKeyboardObserver;
  42284. private _engine;
  42285. private _scene;
  42286. /**
  42287. * Attach the input controls to a specific dom element to get the input from.
  42288. * @param element Defines the element the controls should be listened from
  42289. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42290. */
  42291. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42292. /**
  42293. * Detach the current controls from the specified dom element.
  42294. * @param element Defines the element to stop listening the inputs from
  42295. */
  42296. detachControl(element: Nullable<HTMLElement>): void;
  42297. /**
  42298. * Update the current camera state depending on the inputs that have been used this frame.
  42299. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42300. */
  42301. checkInputs(): void;
  42302. /**
  42303. * Gets the class name of the current intput.
  42304. * @returns the class name
  42305. */
  42306. getClassName(): string;
  42307. /** @hidden */
  42308. _onLostFocus(e: FocusEvent): void;
  42309. /**
  42310. * Get the friendly name associated with the input class.
  42311. * @returns the input friendly name
  42312. */
  42313. getSimpleName(): string;
  42314. }
  42315. }
  42316. declare module BABYLON {
  42317. /**
  42318. * Manage the mouse inputs to control the movement of a free camera.
  42319. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42320. */
  42321. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  42322. /**
  42323. * Define if touch is enabled in the mouse input
  42324. */
  42325. touchEnabled: boolean;
  42326. /**
  42327. * Defines the camera the input is attached to.
  42328. */
  42329. camera: FreeCamera;
  42330. /**
  42331. * Defines the buttons associated with the input to handle camera move.
  42332. */
  42333. buttons: number[];
  42334. /**
  42335. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  42336. */
  42337. angularSensibility: number;
  42338. private _pointerInput;
  42339. private _onMouseMove;
  42340. private _observer;
  42341. private previousPosition;
  42342. /**
  42343. * Manage the mouse inputs to control the movement of a free camera.
  42344. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42345. * @param touchEnabled Defines if touch is enabled or not
  42346. */
  42347. constructor(
  42348. /**
  42349. * Define if touch is enabled in the mouse input
  42350. */
  42351. touchEnabled?: boolean);
  42352. /**
  42353. * Attach the input controls to a specific dom element to get the input from.
  42354. * @param element Defines the element the controls should be listened from
  42355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42356. */
  42357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42358. /**
  42359. * Detach the current controls from the specified dom element.
  42360. * @param element Defines the element to stop listening the inputs from
  42361. */
  42362. detachControl(element: Nullable<HTMLElement>): void;
  42363. /**
  42364. * Gets the class name of the current intput.
  42365. * @returns the class name
  42366. */
  42367. getClassName(): string;
  42368. /**
  42369. * Get the friendly name associated with the input class.
  42370. * @returns the input friendly name
  42371. */
  42372. getSimpleName(): string;
  42373. }
  42374. }
  42375. declare module BABYLON {
  42376. /**
  42377. * Manage the touch inputs to control the movement of a free camera.
  42378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42379. */
  42380. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  42381. /**
  42382. * Defines the camera the input is attached to.
  42383. */
  42384. camera: FreeCamera;
  42385. /**
  42386. * Defines the touch sensibility for rotation.
  42387. * The higher the faster.
  42388. */
  42389. touchAngularSensibility: number;
  42390. /**
  42391. * Defines the touch sensibility for move.
  42392. * The higher the faster.
  42393. */
  42394. touchMoveSensibility: number;
  42395. private _offsetX;
  42396. private _offsetY;
  42397. private _pointerPressed;
  42398. private _pointerInput;
  42399. private _observer;
  42400. private _onLostFocus;
  42401. /**
  42402. * Attach the input controls to a specific dom element to get the input from.
  42403. * @param element Defines the element the controls should be listened from
  42404. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42405. */
  42406. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42407. /**
  42408. * Detach the current controls from the specified dom element.
  42409. * @param element Defines the element to stop listening the inputs from
  42410. */
  42411. detachControl(element: Nullable<HTMLElement>): void;
  42412. /**
  42413. * Update the current camera state depending on the inputs that have been used this frame.
  42414. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42415. */
  42416. checkInputs(): void;
  42417. /**
  42418. * Gets the class name of the current intput.
  42419. * @returns the class name
  42420. */
  42421. getClassName(): string;
  42422. /**
  42423. * Get the friendly name associated with the input class.
  42424. * @returns the input friendly name
  42425. */
  42426. getSimpleName(): string;
  42427. }
  42428. }
  42429. declare module BABYLON {
  42430. /**
  42431. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42432. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42433. */
  42434. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42435. /**
  42436. * Defines the camera the input is attached to.
  42437. */
  42438. camera: FreeCamera;
  42439. private _leftjoystick;
  42440. private _rightjoystick;
  42441. /**
  42442. * Gets the left stick of the virtual joystick.
  42443. * @returns The virtual Joystick
  42444. */
  42445. getLeftJoystick(): VirtualJoystick;
  42446. /**
  42447. * Gets the right stick of the virtual joystick.
  42448. * @returns The virtual Joystick
  42449. */
  42450. getRightJoystick(): VirtualJoystick;
  42451. /**
  42452. * Update the current camera state depending on the inputs that have been used this frame.
  42453. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42454. */
  42455. checkInputs(): void;
  42456. /**
  42457. * Attach the input controls to a specific dom element to get the input from.
  42458. * @param element Defines the element the controls should be listened from
  42459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42460. */
  42461. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42462. /**
  42463. * Detach the current controls from the specified dom element.
  42464. * @param element Defines the element to stop listening the inputs from
  42465. */
  42466. detachControl(element: Nullable<HTMLElement>): void;
  42467. /**
  42468. * Gets the class name of the current intput.
  42469. * @returns the class name
  42470. */
  42471. getClassName(): string;
  42472. /**
  42473. * Get the friendly name associated with the input class.
  42474. * @returns the input friendly name
  42475. */
  42476. getSimpleName(): string;
  42477. }
  42478. }
  42479. declare module BABYLON {
  42480. /**
  42481. * This represents all the required metrics to create a VR camera.
  42482. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42483. */
  42484. class VRCameraMetrics {
  42485. /**
  42486. * Define the horizontal resolution off the screen.
  42487. */
  42488. hResolution: number;
  42489. /**
  42490. * Define the vertical resolution off the screen.
  42491. */
  42492. vResolution: number;
  42493. /**
  42494. * Define the horizontal screen size.
  42495. */
  42496. hScreenSize: number;
  42497. /**
  42498. * Define the vertical screen size.
  42499. */
  42500. vScreenSize: number;
  42501. /**
  42502. * Define the vertical screen center position.
  42503. */
  42504. vScreenCenter: number;
  42505. /**
  42506. * Define the distance of the eyes to the screen.
  42507. */
  42508. eyeToScreenDistance: number;
  42509. /**
  42510. * Define the distance between both lenses
  42511. */
  42512. lensSeparationDistance: number;
  42513. /**
  42514. * Define the distance between both viewer's eyes.
  42515. */
  42516. interpupillaryDistance: number;
  42517. /**
  42518. * Define the distortion factor of the VR postprocess.
  42519. * Please, touch with care.
  42520. */
  42521. distortionK: number[];
  42522. /**
  42523. * Define the chromatic aberration correction factors for the VR post process.
  42524. */
  42525. chromaAbCorrection: number[];
  42526. /**
  42527. * Define the scale factor of the post process.
  42528. * The smaller the better but the slower.
  42529. */
  42530. postProcessScaleFactor: number;
  42531. /**
  42532. * Define an offset for the lens center.
  42533. */
  42534. lensCenterOffset: number;
  42535. /**
  42536. * Define if the current vr camera should compensate the distortion of the lense or not.
  42537. */
  42538. compensateDistortion: boolean;
  42539. /**
  42540. * Gets the rendering aspect ratio based on the provided resolutions.
  42541. */
  42542. readonly aspectRatio: number;
  42543. /**
  42544. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42545. */
  42546. readonly aspectRatioFov: number;
  42547. /**
  42548. * @hidden
  42549. */
  42550. readonly leftHMatrix: Matrix;
  42551. /**
  42552. * @hidden
  42553. */
  42554. readonly rightHMatrix: Matrix;
  42555. /**
  42556. * @hidden
  42557. */
  42558. readonly leftPreViewMatrix: Matrix;
  42559. /**
  42560. * @hidden
  42561. */
  42562. readonly rightPreViewMatrix: Matrix;
  42563. /**
  42564. * Get the default VRMetrics based on the most generic setup.
  42565. * @returns the default vr metrics
  42566. */
  42567. static GetDefault(): VRCameraMetrics;
  42568. }
  42569. }
  42570. declare module BABYLON {
  42571. /**
  42572. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42573. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42574. */
  42575. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42576. /**
  42577. * Creates a new VRDeviceOrientationArcRotateCamera
  42578. * @param name defines camera name
  42579. * @param alpha defines the camera rotation along the logitudinal axis
  42580. * @param beta defines the camera rotation along the latitudinal axis
  42581. * @param radius defines the camera distance from its target
  42582. * @param target defines the camera target
  42583. * @param scene defines the scene the camera belongs to
  42584. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42585. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42586. */
  42587. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42588. /**
  42589. * Gets camera class name
  42590. * @returns VRDeviceOrientationArcRotateCamera
  42591. */
  42592. getClassName(): string;
  42593. }
  42594. }
  42595. declare module BABYLON {
  42596. /**
  42597. * Camera used to simulate VR rendering (based on FreeCamera)
  42598. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42599. */
  42600. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42601. /**
  42602. * Creates a new VRDeviceOrientationFreeCamera
  42603. * @param name defines camera name
  42604. * @param position defines the start position of the camera
  42605. * @param scene defines the scene the camera belongs to
  42606. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42607. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42608. */
  42609. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42610. /**
  42611. * Gets camera class name
  42612. * @returns VRDeviceOrientationFreeCamera
  42613. */
  42614. getClassName(): string;
  42615. }
  42616. }
  42617. declare module BABYLON {
  42618. /**
  42619. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42620. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42621. */
  42622. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42623. /**
  42624. * Creates a new VRDeviceOrientationGamepadCamera
  42625. * @param name defines camera name
  42626. * @param position defines the start position of the camera
  42627. * @param scene defines the scene the camera belongs to
  42628. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42629. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42630. */
  42631. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42632. /**
  42633. * Gets camera class name
  42634. * @returns VRDeviceOrientationGamepadCamera
  42635. */
  42636. getClassName(): string;
  42637. }
  42638. }
  42639. declare module BABYLON {
  42640. /**
  42641. * Options to modify the vr teleportation behavior.
  42642. */
  42643. interface VRTeleportationOptions {
  42644. /**
  42645. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42646. */
  42647. floorMeshName?: string;
  42648. /**
  42649. * A list of meshes to be used as the teleportation floor. (default: empty)
  42650. */
  42651. floorMeshes?: Mesh[];
  42652. }
  42653. /**
  42654. * Options to modify the vr experience helper's behavior.
  42655. */
  42656. interface VRExperienceHelperOptions extends WebVROptions {
  42657. /**
  42658. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42659. */
  42660. createDeviceOrientationCamera?: boolean;
  42661. /**
  42662. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42663. */
  42664. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42665. /**
  42666. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42667. */
  42668. laserToggle?: boolean;
  42669. /**
  42670. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42671. */
  42672. floorMeshes?: Mesh[];
  42673. }
  42674. /**
  42675. * Helps to quickly add VR support to an existing scene.
  42676. * See http://doc.babylonjs.com/how_to/webvr_helper
  42677. */
  42678. class VRExperienceHelper {
  42679. /** Options to modify the vr experience helper's behavior. */
  42680. webVROptions: VRExperienceHelperOptions;
  42681. private _scene;
  42682. private _position;
  42683. private _btnVR;
  42684. private _btnVRDisplayed;
  42685. private _webVRsupported;
  42686. private _webVRready;
  42687. private _webVRrequesting;
  42688. private _webVRpresenting;
  42689. private _hasEnteredVR;
  42690. private _fullscreenVRpresenting;
  42691. private _canvas;
  42692. private _webVRCamera;
  42693. private _vrDeviceOrientationCamera;
  42694. private _deviceOrientationCamera;
  42695. private _existingCamera;
  42696. private _onKeyDown;
  42697. private _onVrDisplayPresentChange;
  42698. private _onVRDisplayChanged;
  42699. private _onVRRequestPresentStart;
  42700. private _onVRRequestPresentComplete;
  42701. /**
  42702. * Observable raised when entering VR.
  42703. */
  42704. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42705. /**
  42706. * Observable raised when exiting VR.
  42707. */
  42708. onExitingVRObservable: Observable<VRExperienceHelper>;
  42709. /**
  42710. * Observable raised when controller mesh is loaded.
  42711. */
  42712. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42713. /** Return this.onEnteringVRObservable
  42714. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42715. */
  42716. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42717. /** Return this.onExitingVRObservable
  42718. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42719. */
  42720. readonly onExitingVR: Observable<VRExperienceHelper>;
  42721. /** Return this.onControllerMeshLoadedObservable
  42722. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42723. */
  42724. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42725. private _rayLength;
  42726. private _useCustomVRButton;
  42727. private _teleportationRequested;
  42728. private _teleportActive;
  42729. private _floorMeshName;
  42730. private _floorMeshesCollection;
  42731. private _rotationAllowed;
  42732. private _teleportBackwardsVector;
  42733. private _teleportationTarget;
  42734. private _isDefaultTeleportationTarget;
  42735. private _postProcessMove;
  42736. private _teleportationFillColor;
  42737. private _teleportationBorderColor;
  42738. private _rotationAngle;
  42739. private _haloCenter;
  42740. private _cameraGazer;
  42741. private _padSensibilityUp;
  42742. private _padSensibilityDown;
  42743. private _leftController;
  42744. private _rightController;
  42745. /**
  42746. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42747. */
  42748. onNewMeshSelected: Observable<AbstractMesh>;
  42749. /**
  42750. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42751. */
  42752. onNewMeshPicked: Observable<PickingInfo>;
  42753. private _circleEase;
  42754. /**
  42755. * Observable raised before camera teleportation
  42756. */
  42757. onBeforeCameraTeleport: Observable<Vector3>;
  42758. /**
  42759. * Observable raised after camera teleportation
  42760. */
  42761. onAfterCameraTeleport: Observable<Vector3>;
  42762. /**
  42763. * Observable raised when current selected mesh gets unselected
  42764. */
  42765. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42766. private _raySelectionPredicate;
  42767. /**
  42768. * To be optionaly changed by user to define custom ray selection
  42769. */
  42770. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42771. /**
  42772. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42773. */
  42774. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42775. /**
  42776. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42777. */
  42778. teleportationEnabled: boolean;
  42779. private _defaultHeight;
  42780. private _teleportationInitialized;
  42781. private _interactionsEnabled;
  42782. private _interactionsRequested;
  42783. private _displayGaze;
  42784. private _displayLaserPointer;
  42785. /**
  42786. * The mesh used to display where the user is going to teleport.
  42787. */
  42788. /**
  42789. * Sets the mesh to be used to display where the user is going to teleport.
  42790. */
  42791. teleportationTarget: Mesh;
  42792. /**
  42793. * 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
  42794. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42795. * See http://doc.babylonjs.com/resources/baking_transformations
  42796. */
  42797. gazeTrackerMesh: Mesh;
  42798. /**
  42799. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42800. */
  42801. updateGazeTrackerScale: boolean;
  42802. /**
  42803. * The gaze tracking mesh corresponding to the left controller
  42804. */
  42805. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42806. /**
  42807. * The gaze tracking mesh corresponding to the right controller
  42808. */
  42809. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42810. /**
  42811. * If the ray of the gaze should be displayed.
  42812. */
  42813. /**
  42814. * Sets if the ray of the gaze should be displayed.
  42815. */
  42816. displayGaze: boolean;
  42817. /**
  42818. * If the ray of the LaserPointer should be displayed.
  42819. */
  42820. /**
  42821. * Sets if the ray of the LaserPointer should be displayed.
  42822. */
  42823. displayLaserPointer: boolean;
  42824. /**
  42825. * The deviceOrientationCamera used as the camera when not in VR.
  42826. */
  42827. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42828. /**
  42829. * Based on the current WebVR support, returns the current VR camera used.
  42830. */
  42831. readonly currentVRCamera: Nullable<Camera>;
  42832. /**
  42833. * The webVRCamera which is used when in VR.
  42834. */
  42835. readonly webVRCamera: WebVRFreeCamera;
  42836. /**
  42837. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42838. */
  42839. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42840. private readonly _teleportationRequestInitiated;
  42841. /**
  42842. * Instantiates a VRExperienceHelper.
  42843. * Helps to quickly add VR support to an existing scene.
  42844. * @param scene The scene the VRExperienceHelper belongs to.
  42845. * @param webVROptions Options to modify the vr experience helper's behavior.
  42846. */
  42847. constructor(scene: Scene,
  42848. /** Options to modify the vr experience helper's behavior. */
  42849. webVROptions?: VRExperienceHelperOptions);
  42850. private _onDefaultMeshLoaded;
  42851. private _onResize;
  42852. private _onFullscreenChange;
  42853. /**
  42854. * Gets a value indicating if we are currently in VR mode.
  42855. */
  42856. readonly isInVRMode: boolean;
  42857. private onVrDisplayPresentChange;
  42858. private onVRDisplayChanged;
  42859. private moveButtonToBottomRight;
  42860. private displayVRButton;
  42861. private updateButtonVisibility;
  42862. private _cachedAngularSensibility;
  42863. /**
  42864. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42865. * Otherwise, will use the fullscreen API.
  42866. */
  42867. enterVR(): void;
  42868. /**
  42869. * Attempt to exit VR, or fullscreen.
  42870. */
  42871. exitVR(): void;
  42872. /**
  42873. * The position of the vr experience helper.
  42874. */
  42875. /**
  42876. * Sets the position of the vr experience helper.
  42877. */
  42878. position: Vector3;
  42879. /**
  42880. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42881. */
  42882. enableInteractions(): void;
  42883. private readonly _noControllerIsActive;
  42884. private beforeRender;
  42885. private _isTeleportationFloor;
  42886. /**
  42887. * Adds a floor mesh to be used for teleportation.
  42888. * @param floorMesh the mesh to be used for teleportation.
  42889. */
  42890. addFloorMesh(floorMesh: Mesh): void;
  42891. /**
  42892. * Removes a floor mesh from being used for teleportation.
  42893. * @param floorMesh the mesh to be removed.
  42894. */
  42895. removeFloorMesh(floorMesh: Mesh): void;
  42896. /**
  42897. * Enables interactions and teleportation using the VR controllers and gaze.
  42898. * @param vrTeleportationOptions options to modify teleportation behavior.
  42899. */
  42900. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42901. private _onNewGamepadConnected;
  42902. private _tryEnableInteractionOnController;
  42903. private _onNewGamepadDisconnected;
  42904. private _enableInteractionOnController;
  42905. private _checkTeleportWithRay;
  42906. private _checkRotate;
  42907. private _checkTeleportBackwards;
  42908. private _enableTeleportationOnController;
  42909. private _createTeleportationCircles;
  42910. private _displayTeleportationTarget;
  42911. private _hideTeleportationTarget;
  42912. private _rotateCamera;
  42913. private _moveTeleportationSelectorTo;
  42914. private _workingVector;
  42915. private _workingQuaternion;
  42916. private _workingMatrix;
  42917. /**
  42918. * Teleports the users feet to the desired location
  42919. * @param location The location where the user's feet should be placed
  42920. */
  42921. teleportCamera(location: Vector3): void;
  42922. private _convertNormalToDirectionOfRay;
  42923. private _castRayAndSelectObject;
  42924. private _notifySelectedMeshUnselected;
  42925. /**
  42926. * Sets the color of the laser ray from the vr controllers.
  42927. * @param color new color for the ray.
  42928. */
  42929. changeLaserColor(color: Color3): void;
  42930. /**
  42931. * Sets the color of the ray from the vr headsets gaze.
  42932. * @param color new color for the ray.
  42933. */
  42934. changeGazeColor(color: Color3): void;
  42935. /**
  42936. * Exits VR and disposes of the vr experience helper
  42937. */
  42938. dispose(): void;
  42939. /**
  42940. * Gets the name of the VRExperienceHelper class
  42941. * @returns "VRExperienceHelper"
  42942. */
  42943. getClassName(): string;
  42944. }
  42945. }
  42946. declare module BABYLON {
  42947. /**
  42948. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  42949. * IMPORTANT!! The data is right-hand data.
  42950. * @export
  42951. * @interface DevicePose
  42952. */
  42953. interface DevicePose {
  42954. /**
  42955. * The position of the device, values in array are [x,y,z].
  42956. */
  42957. readonly position: Nullable<Float32Array>;
  42958. /**
  42959. * The linearVelocity of the device, values in array are [x,y,z].
  42960. */
  42961. readonly linearVelocity: Nullable<Float32Array>;
  42962. /**
  42963. * The linearAcceleration of the device, values in array are [x,y,z].
  42964. */
  42965. readonly linearAcceleration: Nullable<Float32Array>;
  42966. /**
  42967. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  42968. */
  42969. readonly orientation: Nullable<Float32Array>;
  42970. /**
  42971. * The angularVelocity of the device, values in array are [x,y,z].
  42972. */
  42973. readonly angularVelocity: Nullable<Float32Array>;
  42974. /**
  42975. * The angularAcceleration of the device, values in array are [x,y,z].
  42976. */
  42977. readonly angularAcceleration: Nullable<Float32Array>;
  42978. }
  42979. /**
  42980. * Interface representing a pose controlled object in Babylon.
  42981. * A pose controlled object has both regular pose values as well as pose values
  42982. * from an external device such as a VR head mounted display
  42983. */
  42984. interface PoseControlled {
  42985. /**
  42986. * The position of the object in babylon space.
  42987. */
  42988. position: Vector3;
  42989. /**
  42990. * The rotation quaternion of the object in babylon space.
  42991. */
  42992. rotationQuaternion: Quaternion;
  42993. /**
  42994. * The position of the device in babylon space.
  42995. */
  42996. devicePosition?: Vector3;
  42997. /**
  42998. * The rotation quaternion of the device in babylon space.
  42999. */
  43000. deviceRotationQuaternion: Quaternion;
  43001. /**
  43002. * The raw pose coming from the device.
  43003. */
  43004. rawPose: Nullable<DevicePose>;
  43005. /**
  43006. * The scale of the device to be used when translating from device space to babylon space.
  43007. */
  43008. deviceScaleFactor: number;
  43009. /**
  43010. * Updates the poseControlled values based on the input device pose.
  43011. * @param poseData the pose data to update the object with
  43012. */
  43013. updateFromDevice(poseData: DevicePose): void;
  43014. }
  43015. /**
  43016. * Set of options to customize the webVRCamera
  43017. */
  43018. interface WebVROptions {
  43019. /**
  43020. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  43021. */
  43022. trackPosition?: boolean;
  43023. /**
  43024. * Sets the scale of the vrDevice in babylon space. (default: 1)
  43025. */
  43026. positionScale?: number;
  43027. /**
  43028. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  43029. */
  43030. displayName?: string;
  43031. /**
  43032. * Should the native controller meshes be initialized. (default: true)
  43033. */
  43034. controllerMeshes?: boolean;
  43035. /**
  43036. * Creating a default HemiLight only on controllers. (default: true)
  43037. */
  43038. defaultLightingOnControllers?: boolean;
  43039. /**
  43040. * If you don't want to use the default VR button of the helper. (default: false)
  43041. */
  43042. useCustomVRButton?: boolean;
  43043. /**
  43044. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  43045. */
  43046. customVRButton?: HTMLButtonElement;
  43047. /**
  43048. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  43049. */
  43050. rayLength?: number;
  43051. /**
  43052. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  43053. */
  43054. defaultHeight?: number;
  43055. }
  43056. /**
  43057. * This represents a WebVR camera.
  43058. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  43059. * @example http://doc.babylonjs.com/how_to/webvr_camera
  43060. */
  43061. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  43062. private webVROptions;
  43063. /**
  43064. * @hidden
  43065. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  43066. */
  43067. _vrDevice: any;
  43068. /**
  43069. * The rawPose of the vrDevice.
  43070. */
  43071. rawPose: Nullable<DevicePose>;
  43072. private _onVREnabled;
  43073. private _specsVersion;
  43074. private _attached;
  43075. private _frameData;
  43076. protected _descendants: Array<Node>;
  43077. private _deviceRoomPosition;
  43078. /** @hidden */
  43079. _deviceRoomRotationQuaternion: Quaternion;
  43080. private _standingMatrix;
  43081. /**
  43082. * Represents device position in babylon space.
  43083. */
  43084. devicePosition: Vector3;
  43085. /**
  43086. * Represents device rotation in babylon space.
  43087. */
  43088. deviceRotationQuaternion: Quaternion;
  43089. /**
  43090. * The scale of the device to be used when translating from device space to babylon space.
  43091. */
  43092. deviceScaleFactor: number;
  43093. private _deviceToWorld;
  43094. private _worldToDevice;
  43095. /**
  43096. * References to the webVR controllers for the vrDevice.
  43097. */
  43098. controllers: Array<WebVRController>;
  43099. /**
  43100. * Emits an event when a controller is attached.
  43101. */
  43102. onControllersAttachedObservable: Observable<WebVRController[]>;
  43103. /**
  43104. * Emits an event when a controller's mesh has been loaded;
  43105. */
  43106. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43107. /**
  43108. * Emits an event when the HMD's pose has been updated.
  43109. */
  43110. onPoseUpdatedFromDeviceObservable: Observable<any>;
  43111. private _poseSet;
  43112. /**
  43113. * If the rig cameras be used as parent instead of this camera.
  43114. */
  43115. rigParenting: boolean;
  43116. private _lightOnControllers;
  43117. private _defaultHeight?;
  43118. /**
  43119. * Instantiates a WebVRFreeCamera.
  43120. * @param name The name of the WebVRFreeCamera
  43121. * @param position The starting anchor position for the camera
  43122. * @param scene The scene the camera belongs to
  43123. * @param webVROptions a set of customizable options for the webVRCamera
  43124. */
  43125. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  43126. /**
  43127. * Gets the device distance from the ground in meters.
  43128. * @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.
  43129. */
  43130. deviceDistanceToRoomGround(): number;
  43131. /**
  43132. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  43133. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  43134. */
  43135. useStandingMatrix(callback?: (bool: boolean) => void): void;
  43136. /**
  43137. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  43138. * @returns A promise with a boolean set to if the standing matrix is supported.
  43139. */
  43140. useStandingMatrixAsync(): Promise<boolean>;
  43141. /**
  43142. * Disposes the camera
  43143. */
  43144. dispose(): void;
  43145. /**
  43146. * Gets a vrController by name.
  43147. * @param name The name of the controller to retreive
  43148. * @returns the controller matching the name specified or null if not found
  43149. */
  43150. getControllerByName(name: string): Nullable<WebVRController>;
  43151. private _leftController;
  43152. /**
  43153. * The controller corrisponding to the users left hand.
  43154. */
  43155. readonly leftController: Nullable<WebVRController>;
  43156. private _rightController;
  43157. /**
  43158. * The controller corrisponding to the users right hand.
  43159. */
  43160. readonly rightController: Nullable<WebVRController>;
  43161. /**
  43162. * Casts a ray forward from the vrCamera's gaze.
  43163. * @param length Length of the ray (default: 100)
  43164. * @returns the ray corrisponding to the gaze
  43165. */
  43166. getForwardRay(length?: number): Ray;
  43167. /**
  43168. * @hidden
  43169. * Updates the camera based on device's frame data
  43170. */
  43171. _checkInputs(): void;
  43172. /**
  43173. * Updates the poseControlled values based on the input device pose.
  43174. * @param poseData Pose coming from the device
  43175. */
  43176. updateFromDevice(poseData: DevicePose): void;
  43177. private _htmlElementAttached;
  43178. private _detachIfAttached;
  43179. /**
  43180. * WebVR's attach control will start broadcasting frames to the device.
  43181. * Note that in certain browsers (chrome for example) this function must be called
  43182. * within a user-interaction callback. Example:
  43183. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  43184. *
  43185. * @param element html element to attach the vrDevice to
  43186. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  43187. */
  43188. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43189. /**
  43190. * Detaches the camera from the html element and disables VR
  43191. *
  43192. * @param element html element to detach from
  43193. */
  43194. detachControl(element: HTMLElement): void;
  43195. /**
  43196. * @returns the name of this class
  43197. */
  43198. getClassName(): string;
  43199. /**
  43200. * Calls resetPose on the vrDisplay
  43201. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  43202. */
  43203. resetToCurrentRotation(): void;
  43204. /**
  43205. * @hidden
  43206. * Updates the rig cameras (left and right eye)
  43207. */
  43208. _updateRigCameras(): void;
  43209. private _workingVector;
  43210. private _oneVector;
  43211. private _workingMatrix;
  43212. private updateCacheCalled;
  43213. private _correctPositionIfNotTrackPosition;
  43214. /**
  43215. * @hidden
  43216. * Updates the cached values of the camera
  43217. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  43218. */
  43219. _updateCache(ignoreParentClass?: boolean): void;
  43220. /**
  43221. * @hidden
  43222. * Get current device position in babylon world
  43223. */
  43224. _computeDevicePosition(): void;
  43225. /**
  43226. * Updates the current device position and rotation in the babylon world
  43227. */
  43228. update(): void;
  43229. /**
  43230. * @hidden
  43231. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  43232. * @returns an identity matrix
  43233. */
  43234. _getViewMatrix(): Matrix;
  43235. private _tmpMatrix;
  43236. /**
  43237. * This function is called by the two RIG cameras.
  43238. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  43239. */
  43240. protected _getWebVRViewMatrix(): Matrix;
  43241. protected _getWebVRProjectionMatrix(): Matrix;
  43242. private _onGamepadConnectedObserver;
  43243. private _onGamepadDisconnectedObserver;
  43244. private _updateCacheWhenTrackingDisabledObserver;
  43245. /**
  43246. * Initializes the controllers and their meshes
  43247. */
  43248. initControllers(): void;
  43249. }
  43250. }
  43251. declare module BABYLON {
  43252. /**
  43253. * WebXR Camera which holds the views for the xrSession
  43254. * @see https://doc.babylonjs.com/how_to/webxr
  43255. */
  43256. class WebXRCamera extends FreeCamera {
  43257. private static _TmpMatrix;
  43258. /**
  43259. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43260. * @param name the name of the camera
  43261. * @param scene the scene to add the camera to
  43262. */
  43263. constructor(name: string, scene: BABYLON.Scene);
  43264. private _updateNumberOfRigCameras;
  43265. /** @hidden */
  43266. _updateForDualEyeDebugging(pupilDistance?: number): void;
  43267. /**
  43268. * Updates the cameras position from the current pose information of the XR session
  43269. * @param xrSessionManager the session containing pose information
  43270. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43271. */
  43272. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43273. }
  43274. }
  43275. declare module BABYLON {
  43276. /**
  43277. * Button which can be used to enter a different mode of XR
  43278. */
  43279. class WebXREnterExitUIButton {
  43280. /** button element */
  43281. element: HTMLElement;
  43282. /** XR initialization options for the button */
  43283. initializationOptions: XRSessionCreationOptions;
  43284. /**
  43285. * Creates a WebXREnterExitUIButton
  43286. * @param element button element
  43287. * @param initializationOptions XR initialization options for the button
  43288. */
  43289. constructor(
  43290. /** button element */
  43291. element: HTMLElement,
  43292. /** XR initialization options for the button */
  43293. initializationOptions: XRSessionCreationOptions);
  43294. /**
  43295. * Overwritable function which can be used to update the button's visuals when the state changes
  43296. * @param activeButton the current active button in the UI
  43297. */
  43298. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43299. }
  43300. /**
  43301. * Options to create the webXR UI
  43302. */
  43303. class WebXREnterExitUIOptions {
  43304. /**
  43305. * Context to enter xr with
  43306. */
  43307. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  43308. /**
  43309. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43310. */
  43311. customButtons?: Array<WebXREnterExitUIButton>;
  43312. }
  43313. /**
  43314. * UI to allow the user to enter/exit XR mode
  43315. */
  43316. class WebXREnterExitUI implements IDisposable {
  43317. private scene;
  43318. private _overlay;
  43319. private _buttons;
  43320. private _activeButton;
  43321. /**
  43322. * Fired every time the active button is changed.
  43323. *
  43324. * When xr is entered via a button that launches xr that button will be the callback parameter
  43325. *
  43326. * When exiting xr the callback parameter will be null)
  43327. */
  43328. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43329. /**
  43330. * Creates UI to allow the user to enter/exit XR mode
  43331. * @param scene the scene to add the ui to
  43332. * @param helper the xr experience helper to enter/exit xr with
  43333. * @param options options to configure the UI
  43334. * @returns the created ui
  43335. */
  43336. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43337. private constructor();
  43338. private _updateButtons;
  43339. /**
  43340. * Disposes of the object
  43341. */
  43342. dispose(): void;
  43343. }
  43344. }
  43345. declare module BABYLON {
  43346. /**
  43347. * States of the webXR experience
  43348. */
  43349. enum WebXRState {
  43350. /**
  43351. * Transitioning to being in XR mode
  43352. */
  43353. ENTERING_XR = 0,
  43354. /**
  43355. * Transitioning to non XR mode
  43356. */
  43357. EXITING_XR = 1,
  43358. /**
  43359. * In XR mode and presenting
  43360. */
  43361. IN_XR = 2,
  43362. /**
  43363. * Not entered XR mode
  43364. */
  43365. NOT_IN_XR = 3
  43366. }
  43367. /**
  43368. * Helper class used to enable XR
  43369. * @see https://doc.babylonjs.com/how_to/webxr
  43370. */
  43371. class WebXRExperienceHelper implements IDisposable {
  43372. private scene;
  43373. /**
  43374. * 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
  43375. */
  43376. container: AbstractMesh;
  43377. /**
  43378. * Camera used to render xr content
  43379. */
  43380. camera: WebXRCamera;
  43381. /**
  43382. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43383. */
  43384. state: WebXRState;
  43385. private _setState;
  43386. private static _TmpVector;
  43387. /**
  43388. * Fires when the state of the experience helper has changed
  43389. */
  43390. onStateChangedObservable: Observable<WebXRState>;
  43391. /** @hidden */
  43392. _sessionManager: WebXRSessionManager;
  43393. private _nonVRCamera;
  43394. private _originalSceneAutoClear;
  43395. private _supported;
  43396. /**
  43397. * Creates the experience helper
  43398. * @param scene the scene to attach the experience helper to
  43399. * @returns a promise for the experience helper
  43400. */
  43401. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  43402. /**
  43403. * Creates a WebXRExperienceHelper
  43404. * @param scene The scene the helper should be created in
  43405. */
  43406. private constructor();
  43407. /**
  43408. * Exits XR mode and returns the scene to its original state
  43409. * @returns promise that resolves after xr mode has exited
  43410. */
  43411. exitXRAsync(): Promise<void>;
  43412. /**
  43413. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43414. * @param sessionCreationOptions options for the XR session
  43415. * @param frameOfReference frame of reference of the XR session
  43416. * @returns promise that resolves after xr mode has entered
  43417. */
  43418. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  43419. /**
  43420. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43421. * @param ray ray to cast into the environment
  43422. * @returns Promise which resolves with a collision point in the environment if it exists
  43423. */
  43424. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43425. /**
  43426. * Updates the global position of the camera by moving the camera's container
  43427. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43428. * @param position The desired global position of the camera
  43429. */
  43430. setPositionOfCameraUsingContainer(position: Vector3): void;
  43431. /**
  43432. * Rotates the xr camera by rotating the camera's container around the camera's position
  43433. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43434. * @param rotation the desired quaternion rotation to apply to the camera
  43435. */
  43436. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43437. /**
  43438. * Checks if the creation options are supported by the xr session
  43439. * @param options creation options
  43440. * @returns true if supported
  43441. */
  43442. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43443. /**
  43444. * Disposes of the experience helper
  43445. */
  43446. dispose(): void;
  43447. }
  43448. }
  43449. declare module BABYLON {
  43450. /**
  43451. * Represents an XR input
  43452. */
  43453. class WebXRController {
  43454. /**
  43455. * 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
  43456. */
  43457. grip?: BABYLON.AbstractMesh;
  43458. /**
  43459. * Pointer which can be used to select objects or attach a visible laser to
  43460. */
  43461. pointer: BABYLON.AbstractMesh;
  43462. /**
  43463. * Creates the controller
  43464. * @see https://doc.babylonjs.com/how_to/webxr
  43465. * @param scene the scene which the controller should be associated to
  43466. */
  43467. constructor(scene: BABYLON.Scene);
  43468. /**
  43469. * Disposes of the object
  43470. */
  43471. dispose(): void;
  43472. }
  43473. /**
  43474. * XR input used to track XR inputs such as controllers/rays
  43475. */
  43476. class WebXRInput implements IDisposable {
  43477. private helper;
  43478. /**
  43479. * XR controllers being tracked
  43480. */
  43481. controllers: Array<WebXRController>;
  43482. private _tmpMatrix;
  43483. private _frameObserver;
  43484. /**
  43485. * Initializes the WebXRInput
  43486. * @param helper experience helper which the input should be created for
  43487. */
  43488. constructor(helper: WebXRExperienceHelper);
  43489. /**
  43490. * Disposes of the object
  43491. */
  43492. dispose(): void;
  43493. }
  43494. }
  43495. declare module BABYLON {
  43496. /**
  43497. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43498. */
  43499. class WebXRManagedOutputCanvas implements IDisposable {
  43500. private _canvas;
  43501. /**
  43502. * xrpresent context of the canvas which can be used to display/mirror xr content
  43503. */
  43504. canvasContext: Nullable<WebGLRenderingContext>;
  43505. /**
  43506. * Initializes the canvas to be added/removed upon entering/exiting xr
  43507. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43508. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43509. */
  43510. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43511. /**
  43512. * Disposes of the object
  43513. */
  43514. dispose(): void;
  43515. private _setManagedOutputCanvas;
  43516. private _addCanvas;
  43517. private _removeCanvas;
  43518. }
  43519. }
  43520. declare module BABYLON {
  43521. /**
  43522. * Manages an XRSession
  43523. * @see https://doc.babylonjs.com/how_to/webxr
  43524. */
  43525. class WebXRSessionManager implements IDisposable {
  43526. private scene;
  43527. /**
  43528. * Fires every time a new xrFrame arrives which can be used to update the camera
  43529. */
  43530. onXRFrameObservable: Observable<any>;
  43531. /**
  43532. * Fires when the xr session is ended either by the device or manually done
  43533. */
  43534. onXRSessionEnded: Observable<any>;
  43535. /** @hidden */
  43536. _xrSession: XRSession;
  43537. /** @hidden */
  43538. _frameOfReference: XRFrameOfReference;
  43539. /** @hidden */
  43540. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  43541. /** @hidden */
  43542. _currentXRFrame: Nullable<XRFrame>;
  43543. private _xrNavigator;
  43544. private _xrDevice;
  43545. private _tmpMatrix;
  43546. /**
  43547. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43548. * @param scene The scene which the session should be created for
  43549. */
  43550. constructor(scene: BABYLON.Scene);
  43551. /**
  43552. * Initializes the manager
  43553. * After initialization enterXR can be called to start an XR session
  43554. * @returns Promise which resolves after it is initialized
  43555. */
  43556. initializeAsync(): Promise<void>;
  43557. /**
  43558. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  43559. * @param sessionCreationOptions xr options to create the session with
  43560. * @param frameOfReferenceType option to configure how the xr pose is expressed
  43561. * @returns Promise which resolves after it enters XR
  43562. */
  43563. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  43564. /**
  43565. * Stops the xrSession and restores the renderloop
  43566. * @returns Promise which resolves after it exits XR
  43567. */
  43568. exitXRAsync(): Promise<void>;
  43569. /**
  43570. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43571. * @param ray ray to cast into the environment
  43572. * @returns Promise which resolves with a collision point in the environment if it exists
  43573. */
  43574. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43575. /**
  43576. * Checks if a session would be supported for the creation options specified
  43577. * @param options creation options to check if they are supported
  43578. * @returns true if supported
  43579. */
  43580. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43581. /**
  43582. * @hidden
  43583. * Converts the render layer of xrSession to a render target
  43584. * @param session session to create render target for
  43585. * @param scene scene the new render target should be created for
  43586. */
  43587. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  43588. /**
  43589. * Disposes of the session manager
  43590. */
  43591. dispose(): void;
  43592. }
  43593. }
  43594. declare module BABYLON {
  43595. /** @hidden */
  43596. class _OcclusionDataStorage {
  43597. /** @hidden */
  43598. occlusionInternalRetryCounter: number;
  43599. /** @hidden */
  43600. isOcclusionQueryInProgress: boolean;
  43601. /** @hidden */
  43602. isOccluded: boolean;
  43603. /** @hidden */
  43604. occlusionRetryCount: number;
  43605. /** @hidden */
  43606. occlusionType: number;
  43607. /** @hidden */
  43608. occlusionQueryAlgorithmType: number;
  43609. }
  43610. interface Engine {
  43611. /**
  43612. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43613. * @return the new query
  43614. */
  43615. createQuery(): WebGLQuery;
  43616. /**
  43617. * Delete and release a webGL query
  43618. * @param query defines the query to delete
  43619. * @return the current engine
  43620. */
  43621. deleteQuery(query: WebGLQuery): Engine;
  43622. /**
  43623. * Check if a given query has resolved and got its value
  43624. * @param query defines the query to check
  43625. * @returns true if the query got its value
  43626. */
  43627. isQueryResultAvailable(query: WebGLQuery): boolean;
  43628. /**
  43629. * Gets the value of a given query
  43630. * @param query defines the query to check
  43631. * @returns the value of the query
  43632. */
  43633. getQueryResult(query: WebGLQuery): number;
  43634. /**
  43635. * Initiates an occlusion query
  43636. * @param algorithmType defines the algorithm to use
  43637. * @param query defines the query to use
  43638. * @returns the current engine
  43639. * @see http://doc.babylonjs.com/features/occlusionquery
  43640. */
  43641. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43642. /**
  43643. * Ends an occlusion query
  43644. * @see http://doc.babylonjs.com/features/occlusionquery
  43645. * @param algorithmType defines the algorithm to use
  43646. * @returns the current engine
  43647. */
  43648. endOcclusionQuery(algorithmType: number): Engine;
  43649. /**
  43650. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43651. * Please note that only one query can be issued at a time
  43652. * @returns a time token used to track the time span
  43653. */
  43654. startTimeQuery(): Nullable<_TimeToken>;
  43655. /**
  43656. * Ends a time query
  43657. * @param token defines the token used to measure the time span
  43658. * @returns the time spent (in ns)
  43659. */
  43660. endTimeQuery(token: _TimeToken): int;
  43661. /** @hidden */
  43662. _currentNonTimestampToken: Nullable<_TimeToken>;
  43663. /** @hidden */
  43664. _createTimeQuery(): WebGLQuery;
  43665. /** @hidden */
  43666. _deleteTimeQuery(query: WebGLQuery): void;
  43667. /** @hidden */
  43668. _getGlAlgorithmType(algorithmType: number): number;
  43669. /** @hidden */
  43670. _getTimeQueryResult(query: WebGLQuery): any;
  43671. /** @hidden */
  43672. _getTimeQueryAvailability(query: WebGLQuery): any;
  43673. }
  43674. interface AbstractMesh {
  43675. /**
  43676. * Backing filed
  43677. * @hidden
  43678. */
  43679. __occlusionDataStorage: _OcclusionDataStorage;
  43680. /**
  43681. * Access property
  43682. * @hidden
  43683. */
  43684. _occlusionDataStorage: _OcclusionDataStorage;
  43685. /**
  43686. * 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.
  43687. * The default value is -1 which means don't break the query and wait till the result
  43688. * @see http://doc.babylonjs.com/features/occlusionquery
  43689. */
  43690. occlusionRetryCount: number;
  43691. /**
  43692. * 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:
  43693. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43694. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43695. * * 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.
  43696. * @see http://doc.babylonjs.com/features/occlusionquery
  43697. */
  43698. occlusionType: number;
  43699. /**
  43700. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43701. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43702. * * 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.
  43703. * @see http://doc.babylonjs.com/features/occlusionquery
  43704. */
  43705. occlusionQueryAlgorithmType: number;
  43706. /**
  43707. * 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
  43708. * @see http://doc.babylonjs.com/features/occlusionquery
  43709. */
  43710. isOccluded: boolean;
  43711. /**
  43712. * Flag to check the progress status of the query
  43713. * @see http://doc.babylonjs.com/features/occlusionquery
  43714. */
  43715. isOcclusionQueryInProgress: boolean;
  43716. }
  43717. }
  43718. declare module BABYLON {
  43719. interface Engine {
  43720. /**
  43721. * Creates a webGL transform feedback object
  43722. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43723. * @returns the webGL transform feedback object
  43724. */
  43725. createTransformFeedback(): WebGLTransformFeedback;
  43726. /**
  43727. * Delete a webGL transform feedback object
  43728. * @param value defines the webGL transform feedback object to delete
  43729. */
  43730. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43731. /**
  43732. * Bind a webGL transform feedback object to the webgl context
  43733. * @param value defines the webGL transform feedback object to bind
  43734. */
  43735. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43736. /**
  43737. * Begins a transform feedback operation
  43738. * @param usePoints defines if points or triangles must be used
  43739. */
  43740. beginTransformFeedback(usePoints: boolean): void;
  43741. /**
  43742. * Ends a transform feedback operation
  43743. */
  43744. endTransformFeedback(): void;
  43745. /**
  43746. * Specify the varyings to use with transform feedback
  43747. * @param program defines the associated webGL program
  43748. * @param value defines the list of strings representing the varying names
  43749. */
  43750. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43751. /**
  43752. * Bind a webGL buffer for a transform feedback operation
  43753. * @param value defines the webGL buffer to bind
  43754. */
  43755. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43756. }
  43757. }
  43758. declare module BABYLON {
  43759. /**
  43760. * Google Daydream controller
  43761. */
  43762. class DaydreamController extends WebVRController {
  43763. /**
  43764. * Base Url for the controller model.
  43765. */
  43766. static MODEL_BASE_URL: string;
  43767. /**
  43768. * File name for the controller model.
  43769. */
  43770. static MODEL_FILENAME: string;
  43771. /**
  43772. * Gamepad Id prefix used to identify Daydream Controller.
  43773. */
  43774. static readonly GAMEPAD_ID_PREFIX: string;
  43775. /**
  43776. * Creates a new DaydreamController from a gamepad
  43777. * @param vrGamepad the gamepad that the controller should be created from
  43778. */
  43779. constructor(vrGamepad: any);
  43780. /**
  43781. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43782. * @param scene scene in which to add meshes
  43783. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43784. */
  43785. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43786. /**
  43787. * Called once for each button that changed state since the last frame
  43788. * @param buttonIdx Which button index changed
  43789. * @param state New state of the button
  43790. * @param changes Which properties on the state changed since last frame
  43791. */
  43792. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43793. }
  43794. }
  43795. declare module BABYLON {
  43796. /**
  43797. * Gear VR Controller
  43798. */
  43799. class GearVRController extends WebVRController {
  43800. /**
  43801. * Base Url for the controller model.
  43802. */
  43803. static MODEL_BASE_URL: string;
  43804. /**
  43805. * File name for the controller model.
  43806. */
  43807. static MODEL_FILENAME: string;
  43808. /**
  43809. * Gamepad Id prefix used to identify this controller.
  43810. */
  43811. static readonly GAMEPAD_ID_PREFIX: string;
  43812. private readonly _buttonIndexToObservableNameMap;
  43813. /**
  43814. * Creates a new GearVRController from a gamepad
  43815. * @param vrGamepad the gamepad that the controller should be created from
  43816. */
  43817. constructor(vrGamepad: any);
  43818. /**
  43819. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43820. * @param scene scene in which to add meshes
  43821. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43822. */
  43823. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43824. /**
  43825. * Called once for each button that changed state since the last frame
  43826. * @param buttonIdx Which button index changed
  43827. * @param state New state of the button
  43828. * @param changes Which properties on the state changed since last frame
  43829. */
  43830. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43831. }
  43832. }
  43833. declare module BABYLON {
  43834. /**
  43835. * Generic Controller
  43836. */
  43837. class GenericController extends WebVRController {
  43838. /**
  43839. * Base Url for the controller model.
  43840. */
  43841. static readonly MODEL_BASE_URL: string;
  43842. /**
  43843. * File name for the controller model.
  43844. */
  43845. static readonly MODEL_FILENAME: string;
  43846. /**
  43847. * Creates a new GenericController from a gamepad
  43848. * @param vrGamepad the gamepad that the controller should be created from
  43849. */
  43850. constructor(vrGamepad: any);
  43851. /**
  43852. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43853. * @param scene scene in which to add meshes
  43854. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43855. */
  43856. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43857. /**
  43858. * Called once for each button that changed state since the last frame
  43859. * @param buttonIdx Which button index changed
  43860. * @param state New state of the button
  43861. * @param changes Which properties on the state changed since last frame
  43862. */
  43863. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43864. }
  43865. }
  43866. declare module BABYLON {
  43867. /**
  43868. * Oculus Touch Controller
  43869. */
  43870. class OculusTouchController extends WebVRController {
  43871. /**
  43872. * Base Url for the controller model.
  43873. */
  43874. static MODEL_BASE_URL: string;
  43875. /**
  43876. * File name for the left controller model.
  43877. */
  43878. static MODEL_LEFT_FILENAME: string;
  43879. /**
  43880. * File name for the right controller model.
  43881. */
  43882. static MODEL_RIGHT_FILENAME: string;
  43883. /**
  43884. * Fired when the secondary trigger on this controller is modified
  43885. */
  43886. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43887. /**
  43888. * Fired when the thumb rest on this controller is modified
  43889. */
  43890. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43891. /**
  43892. * Creates a new OculusTouchController from a gamepad
  43893. * @param vrGamepad the gamepad that the controller should be created from
  43894. */
  43895. constructor(vrGamepad: any);
  43896. /**
  43897. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43898. * @param scene scene in which to add meshes
  43899. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43900. */
  43901. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43902. /**
  43903. * Fired when the A button on this controller is modified
  43904. */
  43905. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43906. /**
  43907. * Fired when the B button on this controller is modified
  43908. */
  43909. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43910. /**
  43911. * Fired when the X button on this controller is modified
  43912. */
  43913. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43914. /**
  43915. * Fired when the Y button on this controller is modified
  43916. */
  43917. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43918. /**
  43919. * Called once for each button that changed state since the last frame
  43920. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43921. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43922. * 2) secondary trigger (same)
  43923. * 3) A (right) X (left), touch, pressed = value
  43924. * 4) B / Y
  43925. * 5) thumb rest
  43926. * @param buttonIdx Which button index changed
  43927. * @param state New state of the button
  43928. * @param changes Which properties on the state changed since last frame
  43929. */
  43930. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43931. }
  43932. }
  43933. declare module BABYLON {
  43934. /**
  43935. * Defines the types of pose enabled controllers that are supported
  43936. */
  43937. enum PoseEnabledControllerType {
  43938. /**
  43939. * HTC Vive
  43940. */
  43941. VIVE = 0,
  43942. /**
  43943. * Oculus Rift
  43944. */
  43945. OCULUS = 1,
  43946. /**
  43947. * Windows mixed reality
  43948. */
  43949. WINDOWS = 2,
  43950. /**
  43951. * Samsung gear VR
  43952. */
  43953. GEAR_VR = 3,
  43954. /**
  43955. * Google Daydream
  43956. */
  43957. DAYDREAM = 4,
  43958. /**
  43959. * Generic
  43960. */
  43961. GENERIC = 5
  43962. }
  43963. /**
  43964. * Defines the MutableGamepadButton interface for the state of a gamepad button
  43965. */
  43966. interface MutableGamepadButton {
  43967. /**
  43968. * Value of the button/trigger
  43969. */
  43970. value: number;
  43971. /**
  43972. * If the button/trigger is currently touched
  43973. */
  43974. touched: boolean;
  43975. /**
  43976. * If the button/trigger is currently pressed
  43977. */
  43978. pressed: boolean;
  43979. }
  43980. /**
  43981. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  43982. * @hidden
  43983. */
  43984. interface ExtendedGamepadButton extends GamepadButton {
  43985. /**
  43986. * If the button/trigger is currently pressed
  43987. */
  43988. readonly pressed: boolean;
  43989. /**
  43990. * If the button/trigger is currently touched
  43991. */
  43992. readonly touched: boolean;
  43993. /**
  43994. * Value of the button/trigger
  43995. */
  43996. readonly value: number;
  43997. }
  43998. /**
  43999. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44000. */
  44001. class PoseEnabledControllerHelper {
  44002. /**
  44003. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44004. * @param vrGamepad the gamepad to initialized
  44005. * @returns a vr controller of the type the gamepad identified as
  44006. */
  44007. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  44008. }
  44009. /**
  44010. * Defines the PoseEnabledController object that contains state of a vr capable controller
  44011. */
  44012. class PoseEnabledController extends Gamepad implements PoseControlled {
  44013. private _deviceRoomPosition;
  44014. private _deviceRoomRotationQuaternion;
  44015. /**
  44016. * The device position in babylon space
  44017. */
  44018. devicePosition: Vector3;
  44019. /**
  44020. * The device rotation in babylon space
  44021. */
  44022. deviceRotationQuaternion: Quaternion;
  44023. /**
  44024. * The scale factor of the device in babylon space
  44025. */
  44026. deviceScaleFactor: number;
  44027. /**
  44028. * (Likely devicePosition should be used instead) The device position in its room space
  44029. */
  44030. position: Vector3;
  44031. /**
  44032. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  44033. */
  44034. rotationQuaternion: Quaternion;
  44035. /**
  44036. * The type of controller (Eg. Windows mixed reality)
  44037. */
  44038. controllerType: PoseEnabledControllerType;
  44039. protected _calculatedPosition: Vector3;
  44040. private _calculatedRotation;
  44041. /**
  44042. * The raw pose from the device
  44043. */
  44044. rawPose: DevicePose;
  44045. private _trackPosition;
  44046. private _maxRotationDistFromHeadset;
  44047. private _draggedRoomRotation;
  44048. /**
  44049. * @hidden
  44050. */
  44051. _disableTrackPosition(fixedPosition: Vector3): void;
  44052. /**
  44053. * Internal, the mesh attached to the controller
  44054. * @hidden
  44055. */
  44056. _mesh: Nullable<AbstractMesh>;
  44057. private _poseControlledCamera;
  44058. private _leftHandSystemQuaternion;
  44059. /**
  44060. * Internal, matrix used to convert room space to babylon space
  44061. * @hidden
  44062. */
  44063. _deviceToWorld: Matrix;
  44064. /**
  44065. * Node to be used when casting a ray from the controller
  44066. * @hidden
  44067. */
  44068. _pointingPoseNode: Nullable<TransformNode>;
  44069. /**
  44070. * Name of the child mesh that can be used to cast a ray from the controller
  44071. */
  44072. static readonly POINTING_POSE: string;
  44073. /**
  44074. * Creates a new PoseEnabledController from a gamepad
  44075. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  44076. */
  44077. constructor(browserGamepad: any);
  44078. private _workingMatrix;
  44079. /**
  44080. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  44081. */
  44082. update(): void;
  44083. /**
  44084. * Updates only the pose device and mesh without doing any button event checking
  44085. */
  44086. protected _updatePoseAndMesh(): void;
  44087. /**
  44088. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  44089. * @param poseData raw pose fromthe device
  44090. */
  44091. updateFromDevice(poseData: DevicePose): void;
  44092. /**
  44093. * @hidden
  44094. */
  44095. _meshAttachedObservable: Observable<AbstractMesh>;
  44096. /**
  44097. * Attaches a mesh to the controller
  44098. * @param mesh the mesh to be attached
  44099. */
  44100. attachToMesh(mesh: AbstractMesh): void;
  44101. /**
  44102. * Attaches the controllers mesh to a camera
  44103. * @param camera the camera the mesh should be attached to
  44104. */
  44105. attachToPoseControlledCamera(camera: TargetCamera): void;
  44106. /**
  44107. * Disposes of the controller
  44108. */
  44109. dispose(): void;
  44110. /**
  44111. * The mesh that is attached to the controller
  44112. */
  44113. readonly mesh: Nullable<AbstractMesh>;
  44114. /**
  44115. * Gets the ray of the controller in the direction the controller is pointing
  44116. * @param length the length the resulting ray should be
  44117. * @returns a ray in the direction the controller is pointing
  44118. */
  44119. getForwardRay(length?: number): Ray;
  44120. }
  44121. }
  44122. declare module BABYLON {
  44123. /**
  44124. * Vive Controller
  44125. */
  44126. class ViveController extends WebVRController {
  44127. /**
  44128. * Base Url for the controller model.
  44129. */
  44130. static MODEL_BASE_URL: string;
  44131. /**
  44132. * File name for the controller model.
  44133. */
  44134. static MODEL_FILENAME: string;
  44135. /**
  44136. * Creates a new ViveController from a gamepad
  44137. * @param vrGamepad the gamepad that the controller should be created from
  44138. */
  44139. constructor(vrGamepad: any);
  44140. /**
  44141. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44142. * @param scene scene in which to add meshes
  44143. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44144. */
  44145. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44146. /**
  44147. * Fired when the left button on this controller is modified
  44148. */
  44149. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44150. /**
  44151. * Fired when the right button on this controller is modified
  44152. */
  44153. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44154. /**
  44155. * Fired when the menu button on this controller is modified
  44156. */
  44157. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44158. /**
  44159. * Called once for each button that changed state since the last frame
  44160. * Vive mapping:
  44161. * 0: touchpad
  44162. * 1: trigger
  44163. * 2: left AND right buttons
  44164. * 3: menu button
  44165. * @param buttonIdx Which button index changed
  44166. * @param state New state of the button
  44167. * @param changes Which properties on the state changed since last frame
  44168. */
  44169. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44170. }
  44171. }
  44172. declare module BABYLON {
  44173. /**
  44174. * Defines the WebVRController object that represents controllers tracked in 3D space
  44175. */
  44176. abstract class WebVRController extends PoseEnabledController {
  44177. /**
  44178. * Internal, the default controller model for the controller
  44179. */
  44180. protected _defaultModel: AbstractMesh;
  44181. /**
  44182. * Fired when the trigger state has changed
  44183. */
  44184. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44185. /**
  44186. * Fired when the main button state has changed
  44187. */
  44188. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44189. /**
  44190. * Fired when the secondary button state has changed
  44191. */
  44192. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44193. /**
  44194. * Fired when the pad state has changed
  44195. */
  44196. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  44197. /**
  44198. * Fired when controllers stick values have changed
  44199. */
  44200. onPadValuesChangedObservable: Observable<StickValues>;
  44201. /**
  44202. * Array of button availible on the controller
  44203. */
  44204. protected _buttons: Array<MutableGamepadButton>;
  44205. private _onButtonStateChange;
  44206. /**
  44207. * Fired when a controller button's state has changed
  44208. * @param callback the callback containing the button that was modified
  44209. */
  44210. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  44211. /**
  44212. * X and Y axis corrisponding to the controllers joystick
  44213. */
  44214. pad: StickValues;
  44215. /**
  44216. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  44217. */
  44218. hand: string;
  44219. /**
  44220. * The default controller model for the controller
  44221. */
  44222. readonly defaultModel: AbstractMesh;
  44223. /**
  44224. * Creates a new WebVRController from a gamepad
  44225. * @param vrGamepad the gamepad that the WebVRController should be created from
  44226. */
  44227. constructor(vrGamepad: any);
  44228. /**
  44229. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  44230. */
  44231. update(): void;
  44232. /**
  44233. * Function to be called when a button is modified
  44234. */
  44235. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44236. /**
  44237. * Loads a mesh and attaches it to the controller
  44238. * @param scene the scene the mesh should be added to
  44239. * @param meshLoaded callback for when the mesh has been loaded
  44240. */
  44241. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44242. private _setButtonValue;
  44243. private _changes;
  44244. private _checkChanges;
  44245. /**
  44246. * Disposes of th webVRCOntroller
  44247. */
  44248. dispose(): void;
  44249. }
  44250. }
  44251. declare module BABYLON {
  44252. /**
  44253. * Defines the WindowsMotionController object that the state of the windows motion controller
  44254. */
  44255. class WindowsMotionController extends WebVRController {
  44256. /**
  44257. * The base url used to load the left and right controller models
  44258. */
  44259. static MODEL_BASE_URL: string;
  44260. /**
  44261. * The name of the left controller model file
  44262. */
  44263. static MODEL_LEFT_FILENAME: string;
  44264. /**
  44265. * The name of the right controller model file
  44266. */
  44267. static MODEL_RIGHT_FILENAME: string;
  44268. /**
  44269. * The controller name prefix for this controller type
  44270. */
  44271. static readonly GAMEPAD_ID_PREFIX: string;
  44272. /**
  44273. * The controller id pattern for this controller type
  44274. */
  44275. private static readonly GAMEPAD_ID_PATTERN;
  44276. private _loadedMeshInfo;
  44277. private readonly _mapping;
  44278. /**
  44279. * Fired when the trackpad on this controller is clicked
  44280. */
  44281. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44282. /**
  44283. * Fired when the trackpad on this controller is modified
  44284. */
  44285. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44286. /**
  44287. * The current x and y values of this controller's trackpad
  44288. */
  44289. trackpad: StickValues;
  44290. /**
  44291. * Creates a new WindowsMotionController from a gamepad
  44292. * @param vrGamepad the gamepad that the controller should be created from
  44293. */
  44294. constructor(vrGamepad: any);
  44295. /**
  44296. * Fired when the trigger on this controller is modified
  44297. */
  44298. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44299. /**
  44300. * Fired when the menu button on this controller is modified
  44301. */
  44302. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44303. /**
  44304. * Fired when the grip button on this controller is modified
  44305. */
  44306. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44307. /**
  44308. * Fired when the thumbstick button on this controller is modified
  44309. */
  44310. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44311. /**
  44312. * Fired when the touchpad button on this controller is modified
  44313. */
  44314. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44315. /**
  44316. * Fired when the touchpad values on this controller are modified
  44317. */
  44318. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44319. private _updateTrackpad;
  44320. /**
  44321. * Called once per frame by the engine.
  44322. */
  44323. update(): void;
  44324. /**
  44325. * Called once for each button that changed state since the last frame
  44326. * @param buttonIdx Which button index changed
  44327. * @param state New state of the button
  44328. * @param changes Which properties on the state changed since last frame
  44329. */
  44330. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44331. /**
  44332. * Moves the buttons on the controller mesh based on their current state
  44333. * @param buttonName the name of the button to move
  44334. * @param buttonValue the value of the button which determines the buttons new position
  44335. */
  44336. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44337. /**
  44338. * Moves the axis on the controller mesh based on its current state
  44339. * @param axis the index of the axis
  44340. * @param axisValue the value of the axis which determines the meshes new position
  44341. * @hidden
  44342. */
  44343. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44344. /**
  44345. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44346. * @param scene scene in which to add meshes
  44347. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44348. */
  44349. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44350. /**
  44351. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44352. * can be transformed by button presses and axes values, based on this._mapping.
  44353. *
  44354. * @param scene scene in which the meshes exist
  44355. * @param meshes list of meshes that make up the controller model to process
  44356. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44357. */
  44358. private processModel;
  44359. private createMeshInfo;
  44360. /**
  44361. * Gets the ray of the controller in the direction the controller is pointing
  44362. * @param length the length the resulting ray should be
  44363. * @returns a ray in the direction the controller is pointing
  44364. */
  44365. getForwardRay(length?: number): Ray;
  44366. /**
  44367. * Disposes of the controller
  44368. */
  44369. dispose(): void;
  44370. }
  44371. }
  44372. declare module BABYLON {
  44373. /**
  44374. * Interface to implement to create a shadow generator compatible with BJS.
  44375. */
  44376. interface IShadowGenerator {
  44377. /**
  44378. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44379. * @returns The render target texture if present otherwise, null
  44380. */
  44381. getShadowMap(): Nullable<RenderTargetTexture>;
  44382. /**
  44383. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44384. * @returns The render target texture if the shadow map is present otherwise, null
  44385. */
  44386. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44387. /**
  44388. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44389. * @param subMesh The submesh we want to render in the shadow map
  44390. * @param useInstances Defines wether will draw in the map using instances
  44391. * @returns true if ready otherwise, false
  44392. */
  44393. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44394. /**
  44395. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44396. * @param defines Defines of the material we want to update
  44397. * @param lightIndex Index of the light in the enabled light list of the material
  44398. */
  44399. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  44400. /**
  44401. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44402. * defined in the generator but impacting the effect).
  44403. * It implies the unifroms available on the materials are the standard BJS ones.
  44404. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44405. * @param effect The effect we are binfing the information for
  44406. */
  44407. bindShadowLight(lightIndex: string, effect: Effect): void;
  44408. /**
  44409. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44410. * (eq to shadow prjection matrix * light transform matrix)
  44411. * @returns The transform matrix used to create the shadow map
  44412. */
  44413. getTransformMatrix(): Matrix;
  44414. /**
  44415. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44416. * Cube and 2D textures for instance.
  44417. */
  44418. recreateShadowMap(): void;
  44419. /**
  44420. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44421. * @param onCompiled Callback triggered at the and of the effects compilation
  44422. * @param options Sets of optional options forcing the compilation with different modes
  44423. */
  44424. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44425. useInstances: boolean;
  44426. }>): void;
  44427. /**
  44428. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44429. * @param options Sets of optional options forcing the compilation with different modes
  44430. * @returns A promise that resolves when the compilation completes
  44431. */
  44432. forceCompilationAsync(options?: Partial<{
  44433. useInstances: boolean;
  44434. }>): Promise<void>;
  44435. /**
  44436. * Serializes the shadow generator setup to a json object.
  44437. * @returns The serialized JSON object
  44438. */
  44439. serialize(): any;
  44440. /**
  44441. * Disposes the Shadow map and related Textures and effects.
  44442. */
  44443. dispose(): void;
  44444. }
  44445. /**
  44446. * Default implementation IShadowGenerator.
  44447. * This is the main object responsible of generating shadows in the framework.
  44448. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44449. */
  44450. class ShadowGenerator implements IShadowGenerator {
  44451. /**
  44452. * Shadow generator mode None: no filtering applied.
  44453. */
  44454. static readonly FILTER_NONE: number;
  44455. /**
  44456. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44457. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44458. */
  44459. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  44460. /**
  44461. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44462. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44463. */
  44464. static readonly FILTER_POISSONSAMPLING: number;
  44465. /**
  44466. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44467. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44468. */
  44469. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  44470. /**
  44471. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44472. * edge artifacts on steep falloff.
  44473. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44474. */
  44475. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  44476. /**
  44477. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44478. * edge artifacts on steep falloff.
  44479. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44480. */
  44481. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  44482. /**
  44483. * Shadow generator mode PCF: Percentage Closer Filtering
  44484. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44485. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44486. */
  44487. static readonly FILTER_PCF: number;
  44488. /**
  44489. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44490. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44491. * Contact Hardening
  44492. */
  44493. static readonly FILTER_PCSS: number;
  44494. /**
  44495. * Reserved for PCF and PCSS
  44496. * Highest Quality.
  44497. *
  44498. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44499. *
  44500. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44501. */
  44502. static readonly QUALITY_HIGH: number;
  44503. /**
  44504. * Reserved for PCF and PCSS
  44505. * Good tradeoff for quality/perf cross devices
  44506. *
  44507. * Execute PCF on a 3*3 kernel.
  44508. *
  44509. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44510. */
  44511. static readonly QUALITY_MEDIUM: number;
  44512. /**
  44513. * Reserved for PCF and PCSS
  44514. * The lowest quality but the fastest.
  44515. *
  44516. * Execute PCF on a 1*1 kernel.
  44517. *
  44518. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44519. */
  44520. static readonly QUALITY_LOW: number;
  44521. private _bias;
  44522. /**
  44523. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44524. */
  44525. /**
  44526. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44527. */
  44528. bias: number;
  44529. private _normalBias;
  44530. /**
  44531. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44532. */
  44533. /**
  44534. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44535. */
  44536. normalBias: number;
  44537. private _blurBoxOffset;
  44538. /**
  44539. * Gets the blur box offset: offset applied during the blur pass.
  44540. * Only useful if useKernelBlur = false
  44541. */
  44542. /**
  44543. * Sets the blur box offset: offset applied during the blur pass.
  44544. * Only useful if useKernelBlur = false
  44545. */
  44546. blurBoxOffset: number;
  44547. private _blurScale;
  44548. /**
  44549. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44550. * 2 means half of the size.
  44551. */
  44552. /**
  44553. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44554. * 2 means half of the size.
  44555. */
  44556. blurScale: number;
  44557. private _blurKernel;
  44558. /**
  44559. * Gets the blur kernel: kernel size of the blur pass.
  44560. * Only useful if useKernelBlur = true
  44561. */
  44562. /**
  44563. * Sets the blur kernel: kernel size of the blur pass.
  44564. * Only useful if useKernelBlur = true
  44565. */
  44566. blurKernel: number;
  44567. private _useKernelBlur;
  44568. /**
  44569. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44570. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44571. */
  44572. /**
  44573. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44574. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44575. */
  44576. useKernelBlur: boolean;
  44577. private _depthScale;
  44578. /**
  44579. * Gets the depth scale used in ESM mode.
  44580. */
  44581. /**
  44582. * Sets the depth scale used in ESM mode.
  44583. * This can override the scale stored on the light.
  44584. */
  44585. depthScale: number;
  44586. private _filter;
  44587. /**
  44588. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44589. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44590. */
  44591. /**
  44592. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44593. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44594. */
  44595. filter: number;
  44596. /**
  44597. * Gets if the current filter is set to Poisson Sampling.
  44598. */
  44599. /**
  44600. * Sets the current filter to Poisson Sampling.
  44601. */
  44602. usePoissonSampling: boolean;
  44603. /**
  44604. * Gets if the current filter is set to ESM.
  44605. */
  44606. /**
  44607. * Sets the current filter is to ESM.
  44608. */
  44609. useExponentialShadowMap: boolean;
  44610. /**
  44611. * Gets if the current filter is set to filtered ESM.
  44612. */
  44613. /**
  44614. * Gets if the current filter is set to filtered ESM.
  44615. */
  44616. useBlurExponentialShadowMap: boolean;
  44617. /**
  44618. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44619. * exponential to prevent steep falloff artifacts).
  44620. */
  44621. /**
  44622. * Sets the current filter to "close ESM" (using the inverse of the
  44623. * exponential to prevent steep falloff artifacts).
  44624. */
  44625. useCloseExponentialShadowMap: boolean;
  44626. /**
  44627. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44628. * exponential to prevent steep falloff artifacts).
  44629. */
  44630. /**
  44631. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44632. * exponential to prevent steep falloff artifacts).
  44633. */
  44634. useBlurCloseExponentialShadowMap: boolean;
  44635. /**
  44636. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44637. */
  44638. /**
  44639. * Sets the current filter to "PCF" (percentage closer filtering).
  44640. */
  44641. usePercentageCloserFiltering: boolean;
  44642. private _filteringQuality;
  44643. /**
  44644. * Gets the PCF or PCSS Quality.
  44645. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44646. */
  44647. /**
  44648. * Sets the PCF or PCSS Quality.
  44649. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44650. */
  44651. filteringQuality: number;
  44652. /**
  44653. * Gets if the current filter is set to "PCSS" (contact hardening).
  44654. */
  44655. /**
  44656. * Sets the current filter to "PCSS" (contact hardening).
  44657. */
  44658. useContactHardeningShadow: boolean;
  44659. private _contactHardeningLightSizeUVRatio;
  44660. /**
  44661. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44662. * Using a ratio helps keeping shape stability independently of the map size.
  44663. *
  44664. * It does not account for the light projection as it was having too much
  44665. * instability during the light setup or during light position changes.
  44666. *
  44667. * Only valid if useContactHardeningShadow is true.
  44668. */
  44669. /**
  44670. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44671. * Using a ratio helps keeping shape stability independently of the map size.
  44672. *
  44673. * It does not account for the light projection as it was having too much
  44674. * instability during the light setup or during light position changes.
  44675. *
  44676. * Only valid if useContactHardeningShadow is true.
  44677. */
  44678. contactHardeningLightSizeUVRatio: number;
  44679. private _darkness;
  44680. /**
  44681. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44682. * 0 means strongest and 1 would means no shadow.
  44683. * @returns the darkness.
  44684. */
  44685. getDarkness(): number;
  44686. /**
  44687. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44688. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44689. * @returns the shadow generator allowing fluent coding.
  44690. */
  44691. setDarkness(darkness: number): ShadowGenerator;
  44692. private _transparencyShadow;
  44693. /**
  44694. * Sets the ability to have transparent shadow (boolean).
  44695. * @param transparent True if transparent else False
  44696. * @returns the shadow generator allowing fluent coding
  44697. */
  44698. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44699. private _shadowMap;
  44700. private _shadowMap2;
  44701. /**
  44702. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44703. * @returns The render target texture if present otherwise, null
  44704. */
  44705. getShadowMap(): Nullable<RenderTargetTexture>;
  44706. /**
  44707. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44708. * @returns The render target texture if the shadow map is present otherwise, null
  44709. */
  44710. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44711. /**
  44712. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44713. * @param mesh Mesh to add
  44714. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44715. * @returns the Shadow Generator itself
  44716. */
  44717. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44718. /**
  44719. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44720. * @param mesh Mesh to remove
  44721. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44722. * @returns the Shadow Generator itself
  44723. */
  44724. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44725. /**
  44726. * Controls the extent to which the shadows fade out at the edge of the frustum
  44727. * Used only by directionals and spots
  44728. */
  44729. frustumEdgeFalloff: number;
  44730. private _light;
  44731. /**
  44732. * Returns the associated light object.
  44733. * @returns the light generating the shadow
  44734. */
  44735. getLight(): IShadowLight;
  44736. /**
  44737. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44738. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44739. * It might on the other hand introduce peter panning.
  44740. */
  44741. forceBackFacesOnly: boolean;
  44742. private _scene;
  44743. private _lightDirection;
  44744. private _effect;
  44745. private _viewMatrix;
  44746. private _projectionMatrix;
  44747. private _transformMatrix;
  44748. private _cachedPosition;
  44749. private _cachedDirection;
  44750. private _cachedDefines;
  44751. private _currentRenderID;
  44752. private _boxBlurPostprocess;
  44753. private _kernelBlurXPostprocess;
  44754. private _kernelBlurYPostprocess;
  44755. private _blurPostProcesses;
  44756. private _mapSize;
  44757. private _currentFaceIndex;
  44758. private _currentFaceIndexCache;
  44759. private _textureType;
  44760. private _defaultTextureMatrix;
  44761. /**
  44762. * Creates a ShadowGenerator object.
  44763. * A ShadowGenerator is the required tool to use the shadows.
  44764. * Each light casting shadows needs to use its own ShadowGenerator.
  44765. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44766. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44767. * @param light The light object generating the shadows.
  44768. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  44769. */
  44770. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  44771. private _initializeGenerator;
  44772. private _initializeShadowMap;
  44773. private _initializeBlurRTTAndPostProcesses;
  44774. private _renderForShadowMap;
  44775. private _renderSubMeshForShadowMap;
  44776. private _applyFilterValues;
  44777. /**
  44778. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44779. * @param onCompiled Callback triggered at the and of the effects compilation
  44780. * @param options Sets of optional options forcing the compilation with different modes
  44781. */
  44782. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44783. useInstances: boolean;
  44784. }>): void;
  44785. /**
  44786. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44787. * @param options Sets of optional options forcing the compilation with different modes
  44788. * @returns A promise that resolves when the compilation completes
  44789. */
  44790. forceCompilationAsync(options?: Partial<{
  44791. useInstances: boolean;
  44792. }>): Promise<void>;
  44793. /**
  44794. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44795. * @param subMesh The submesh we want to render in the shadow map
  44796. * @param useInstances Defines wether will draw in the map using instances
  44797. * @returns true if ready otherwise, false
  44798. */
  44799. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44800. /**
  44801. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44802. * @param defines Defines of the material we want to update
  44803. * @param lightIndex Index of the light in the enabled light list of the material
  44804. */
  44805. prepareDefines(defines: any, lightIndex: number): void;
  44806. /**
  44807. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44808. * defined in the generator but impacting the effect).
  44809. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44810. * @param effect The effect we are binfing the information for
  44811. */
  44812. bindShadowLight(lightIndex: string, effect: Effect): void;
  44813. /**
  44814. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44815. * (eq to shadow prjection matrix * light transform matrix)
  44816. * @returns The transform matrix used to create the shadow map
  44817. */
  44818. getTransformMatrix(): Matrix;
  44819. /**
  44820. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44821. * Cube and 2D textures for instance.
  44822. */
  44823. recreateShadowMap(): void;
  44824. private _disposeBlurPostProcesses;
  44825. private _disposeRTTandPostProcesses;
  44826. /**
  44827. * Disposes the ShadowGenerator.
  44828. * Returns nothing.
  44829. */
  44830. dispose(): void;
  44831. /**
  44832. * Serializes the shadow generator setup to a json object.
  44833. * @returns The serialized JSON object
  44834. */
  44835. serialize(): any;
  44836. /**
  44837. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44838. * @param parsedShadowGenerator The JSON object to parse
  44839. * @param scene The scene to create the shadow map for
  44840. * @returns The parsed shadow generator
  44841. */
  44842. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44843. }
  44844. }
  44845. declare module BABYLON {
  44846. /**
  44847. * Defines the shadow generator component responsible to manage any shadow generators
  44848. * in a given scene.
  44849. */
  44850. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44851. /**
  44852. * The component name helpfull to identify the component in the list of scene components.
  44853. */
  44854. readonly name: string;
  44855. /**
  44856. * The scene the component belongs to.
  44857. */
  44858. scene: Scene;
  44859. /**
  44860. * Creates a new instance of the component for the given scene
  44861. * @param scene Defines the scene to register the component in
  44862. */
  44863. constructor(scene: Scene);
  44864. /**
  44865. * Registers the component in a given scene
  44866. */
  44867. register(): void;
  44868. /**
  44869. * Rebuilds the elements related to this component in case of
  44870. * context lost for instance.
  44871. */
  44872. rebuild(): void;
  44873. /**
  44874. * Serializes the component data to the specified json object
  44875. * @param serializationObject The object to serialize to
  44876. */
  44877. serialize(serializationObject: any): void;
  44878. /**
  44879. * Adds all the element from the container to the scene
  44880. * @param container the container holding the elements
  44881. */
  44882. addFromContainer(container: AbstractScene): void;
  44883. /**
  44884. * Removes all the elements in the container from the scene
  44885. * @param container contains the elements to remove
  44886. */
  44887. removeFromContainer(container: AbstractScene): void;
  44888. /**
  44889. * Rebuilds the elements related to this component in case of
  44890. * context lost for instance.
  44891. */
  44892. dispose(): void;
  44893. private _gatherRenderTargets;
  44894. }
  44895. }
  44896. declare module BABYLON {
  44897. }
  44898. declare module BABYLON {
  44899. /**
  44900. * Background material used to create an efficient environement around your scene.
  44901. */
  44902. class BackgroundMaterial extends PushMaterial {
  44903. /**
  44904. * Standard reflectance value at parallel view angle.
  44905. */
  44906. static StandardReflectance0: number;
  44907. /**
  44908. * Standard reflectance value at grazing angle.
  44909. */
  44910. static StandardReflectance90: number;
  44911. protected _primaryColor: Color3;
  44912. /**
  44913. * Key light Color (multiply against the environement texture)
  44914. */
  44915. primaryColor: Color3;
  44916. protected __perceptualColor: Nullable<Color3>;
  44917. /**
  44918. * Experimental Internal Use Only.
  44919. *
  44920. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44921. * This acts as a helper to set the primary color to a more "human friendly" value.
  44922. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44923. * output color as close as possible from the chosen value.
  44924. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44925. * part of lighting setup.)
  44926. */
  44927. _perceptualColor: Nullable<Color3>;
  44928. protected _primaryColorShadowLevel: float;
  44929. /**
  44930. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44931. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44932. */
  44933. primaryColorShadowLevel: float;
  44934. protected _primaryColorHighlightLevel: float;
  44935. /**
  44936. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44937. * The primary color is used at the level chosen to define what the white area would look.
  44938. */
  44939. primaryColorHighlightLevel: float;
  44940. protected _reflectionTexture: Nullable<BaseTexture>;
  44941. /**
  44942. * Reflection Texture used in the material.
  44943. * Should be author in a specific way for the best result (refer to the documentation).
  44944. */
  44945. reflectionTexture: Nullable<BaseTexture>;
  44946. protected _reflectionBlur: float;
  44947. /**
  44948. * Reflection Texture level of blur.
  44949. *
  44950. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44951. * texture twice.
  44952. */
  44953. reflectionBlur: float;
  44954. protected _diffuseTexture: Nullable<BaseTexture>;
  44955. /**
  44956. * Diffuse Texture used in the material.
  44957. * Should be author in a specific way for the best result (refer to the documentation).
  44958. */
  44959. diffuseTexture: Nullable<BaseTexture>;
  44960. protected _shadowLights: Nullable<IShadowLight[]>;
  44961. /**
  44962. * Specify the list of lights casting shadow on the material.
  44963. * All scene shadow lights will be included if null.
  44964. */
  44965. shadowLights: Nullable<IShadowLight[]>;
  44966. protected _shadowLevel: float;
  44967. /**
  44968. * Helps adjusting the shadow to a softer level if required.
  44969. * 0 means black shadows and 1 means no shadows.
  44970. */
  44971. shadowLevel: float;
  44972. protected _sceneCenter: Vector3;
  44973. /**
  44974. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44975. * It is usually zero but might be interesting to modify according to your setup.
  44976. */
  44977. sceneCenter: Vector3;
  44978. protected _opacityFresnel: boolean;
  44979. /**
  44980. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44981. * This helps ensuring a nice transition when the camera goes under the ground.
  44982. */
  44983. opacityFresnel: boolean;
  44984. protected _reflectionFresnel: boolean;
  44985. /**
  44986. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44987. * This helps adding a mirror texture on the ground.
  44988. */
  44989. reflectionFresnel: boolean;
  44990. protected _reflectionFalloffDistance: number;
  44991. /**
  44992. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44993. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44994. */
  44995. reflectionFalloffDistance: number;
  44996. protected _reflectionAmount: number;
  44997. /**
  44998. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44999. */
  45000. reflectionAmount: number;
  45001. protected _reflectionReflectance0: number;
  45002. /**
  45003. * This specifies the weight of the reflection at grazing angle.
  45004. */
  45005. reflectionReflectance0: number;
  45006. protected _reflectionReflectance90: number;
  45007. /**
  45008. * This specifies the weight of the reflection at a perpendicular point of view.
  45009. */
  45010. reflectionReflectance90: number;
  45011. /**
  45012. * Sets the reflection reflectance fresnel values according to the default standard
  45013. * empirically know to work well :-)
  45014. */
  45015. reflectionStandardFresnelWeight: number;
  45016. protected _useRGBColor: boolean;
  45017. /**
  45018. * Helps to directly use the maps channels instead of their level.
  45019. */
  45020. useRGBColor: boolean;
  45021. protected _enableNoise: boolean;
  45022. /**
  45023. * This helps reducing the banding effect that could occur on the background.
  45024. */
  45025. enableNoise: boolean;
  45026. /**
  45027. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45028. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45029. * Recommended to be keep at 1.0 except for special cases.
  45030. */
  45031. fovMultiplier: number;
  45032. private _fovMultiplier;
  45033. /**
  45034. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45035. */
  45036. useEquirectangularFOV: boolean;
  45037. private _maxSimultaneousLights;
  45038. /**
  45039. * Number of Simultaneous lights allowed on the material.
  45040. */
  45041. maxSimultaneousLights: int;
  45042. /**
  45043. * Default configuration related to image processing available in the Background Material.
  45044. */
  45045. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45046. /**
  45047. * Keep track of the image processing observer to allow dispose and replace.
  45048. */
  45049. private _imageProcessingObserver;
  45050. /**
  45051. * Attaches a new image processing configuration to the PBR Material.
  45052. * @param configuration (if null the scene configuration will be use)
  45053. */
  45054. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45055. /**
  45056. * Gets the image processing configuration used either in this material.
  45057. */
  45058. /**
  45059. * Sets the Default image processing configuration used either in the this material.
  45060. *
  45061. * If sets to null, the scene one is in use.
  45062. */
  45063. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45064. /**
  45065. * Gets wether the color curves effect is enabled.
  45066. */
  45067. /**
  45068. * Sets wether the color curves effect is enabled.
  45069. */
  45070. cameraColorCurvesEnabled: boolean;
  45071. /**
  45072. * Gets wether the color grading effect is enabled.
  45073. */
  45074. /**
  45075. * Gets wether the color grading effect is enabled.
  45076. */
  45077. cameraColorGradingEnabled: boolean;
  45078. /**
  45079. * Gets wether tonemapping is enabled or not.
  45080. */
  45081. /**
  45082. * Sets wether tonemapping is enabled or not
  45083. */
  45084. cameraToneMappingEnabled: boolean;
  45085. /**
  45086. * The camera exposure used on this material.
  45087. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45088. * This corresponds to a photographic exposure.
  45089. */
  45090. /**
  45091. * The camera exposure used on this material.
  45092. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45093. * This corresponds to a photographic exposure.
  45094. */
  45095. cameraExposure: float;
  45096. /**
  45097. * Gets The camera contrast used on this material.
  45098. */
  45099. /**
  45100. * Sets The camera contrast used on this material.
  45101. */
  45102. cameraContrast: float;
  45103. /**
  45104. * Gets the Color Grading 2D Lookup Texture.
  45105. */
  45106. /**
  45107. * Sets the Color Grading 2D Lookup Texture.
  45108. */
  45109. cameraColorGradingTexture: Nullable<BaseTexture>;
  45110. /**
  45111. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45112. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45113. * 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;
  45114. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45115. */
  45116. /**
  45117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45119. * 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;
  45120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45121. */
  45122. cameraColorCurves: Nullable<ColorCurves>;
  45123. /**
  45124. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45125. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45126. */
  45127. switchToBGR: boolean;
  45128. private _renderTargets;
  45129. private _reflectionControls;
  45130. private _white;
  45131. private _primaryShadowColor;
  45132. private _primaryHighlightColor;
  45133. /**
  45134. * Instantiates a Background Material in the given scene
  45135. * @param name The friendly name of the material
  45136. * @param scene The scene to add the material to
  45137. */
  45138. constructor(name: string, scene: Scene);
  45139. /**
  45140. * Gets a boolean indicating that current material needs to register RTT
  45141. */
  45142. readonly hasRenderTargetTextures: boolean;
  45143. /**
  45144. * The entire material has been created in order to prevent overdraw.
  45145. * @returns false
  45146. */
  45147. needAlphaTesting(): boolean;
  45148. /**
  45149. * The entire material has been created in order to prevent overdraw.
  45150. * @returns true if blending is enable
  45151. */
  45152. needAlphaBlending(): boolean;
  45153. /**
  45154. * Checks wether the material is ready to be rendered for a given mesh.
  45155. * @param mesh The mesh to render
  45156. * @param subMesh The submesh to check against
  45157. * @param useInstances Specify wether or not the material is used with instances
  45158. * @returns true if all the dependencies are ready (Textures, Effects...)
  45159. */
  45160. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45161. /**
  45162. * Compute the primary color according to the chosen perceptual color.
  45163. */
  45164. private _computePrimaryColorFromPerceptualColor;
  45165. /**
  45166. * Compute the highlights and shadow colors according to their chosen levels.
  45167. */
  45168. private _computePrimaryColors;
  45169. /**
  45170. * Build the uniform buffer used in the material.
  45171. */
  45172. buildUniformLayout(): void;
  45173. /**
  45174. * Unbind the material.
  45175. */
  45176. unbind(): void;
  45177. /**
  45178. * Bind only the world matrix to the material.
  45179. * @param world The world matrix to bind.
  45180. */
  45181. bindOnlyWorldMatrix(world: Matrix): void;
  45182. /**
  45183. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45184. * @param world The world matrix to bind.
  45185. * @param subMesh The submesh to bind for.
  45186. */
  45187. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45188. /**
  45189. * Dispose the material.
  45190. * @param forceDisposeEffect Force disposal of the associated effect.
  45191. * @param forceDisposeTextures Force disposal of the associated textures.
  45192. */
  45193. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45194. /**
  45195. * Clones the material.
  45196. * @param name The cloned name.
  45197. * @returns The cloned material.
  45198. */
  45199. clone(name: string): BackgroundMaterial;
  45200. /**
  45201. * Serializes the current material to its JSON representation.
  45202. * @returns The JSON representation.
  45203. */
  45204. serialize(): any;
  45205. /**
  45206. * Gets the class name of the material
  45207. * @returns "BackgroundMaterial"
  45208. */
  45209. getClassName(): string;
  45210. /**
  45211. * Parse a JSON input to create back a background material.
  45212. * @param source The JSON data to parse
  45213. * @param scene The scene to create the parsed material in
  45214. * @param rootUrl The root url of the assets the material depends upon
  45215. * @returns the instantiated BackgroundMaterial.
  45216. */
  45217. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45218. }
  45219. }
  45220. declare module BABYLON {
  45221. /**
  45222. * The Physically based material base class of BJS.
  45223. *
  45224. * This offers the main features of a standard PBR material.
  45225. * For more information, please refer to the documentation :
  45226. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45227. */
  45228. abstract class PBRBaseMaterial extends PushMaterial {
  45229. /**
  45230. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45231. */
  45232. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45233. /**
  45234. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45235. * to enhance interoperability with other engines.
  45236. */
  45237. static readonly LIGHTFALLOFF_GLTF: number;
  45238. /**
  45239. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45240. * to enhance interoperability with other materials.
  45241. */
  45242. static readonly LIGHTFALLOFF_STANDARD: number;
  45243. /**
  45244. * Intensity of the direct lights e.g. the four lights available in your scene.
  45245. * This impacts both the direct diffuse and specular highlights.
  45246. */
  45247. protected _directIntensity: number;
  45248. /**
  45249. * Intensity of the emissive part of the material.
  45250. * This helps controlling the emissive effect without modifying the emissive color.
  45251. */
  45252. protected _emissiveIntensity: number;
  45253. /**
  45254. * Intensity of the environment e.g. how much the environment will light the object
  45255. * either through harmonics for rough material or through the refelction for shiny ones.
  45256. */
  45257. protected _environmentIntensity: number;
  45258. /**
  45259. * This is a special control allowing the reduction of the specular highlights coming from the
  45260. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45261. */
  45262. protected _specularIntensity: number;
  45263. /**
  45264. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45265. */
  45266. private _lightingInfos;
  45267. /**
  45268. * Debug Control allowing disabling the bump map on this material.
  45269. */
  45270. protected _disableBumpMap: boolean;
  45271. /**
  45272. * AKA Diffuse Texture in standard nomenclature.
  45273. */
  45274. protected _albedoTexture: BaseTexture;
  45275. /**
  45276. * AKA Occlusion Texture in other nomenclature.
  45277. */
  45278. protected _ambientTexture: BaseTexture;
  45279. /**
  45280. * AKA Occlusion Texture Intensity in other nomenclature.
  45281. */
  45282. protected _ambientTextureStrength: number;
  45283. /**
  45284. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45285. * 1 means it completely occludes it
  45286. * 0 mean it has no impact
  45287. */
  45288. protected _ambientTextureImpactOnAnalyticalLights: number;
  45289. /**
  45290. * Stores the alpha values in a texture.
  45291. */
  45292. protected _opacityTexture: BaseTexture;
  45293. /**
  45294. * Stores the reflection values in a texture.
  45295. */
  45296. protected _reflectionTexture: BaseTexture;
  45297. /**
  45298. * Stores the refraction values in a texture.
  45299. */
  45300. protected _refractionTexture: BaseTexture;
  45301. /**
  45302. * Stores the emissive values in a texture.
  45303. */
  45304. protected _emissiveTexture: BaseTexture;
  45305. /**
  45306. * AKA Specular texture in other nomenclature.
  45307. */
  45308. protected _reflectivityTexture: BaseTexture;
  45309. /**
  45310. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45311. */
  45312. protected _metallicTexture: BaseTexture;
  45313. /**
  45314. * Specifies the metallic scalar of the metallic/roughness workflow.
  45315. * Can also be used to scale the metalness values of the metallic texture.
  45316. */
  45317. protected _metallic: Nullable<number>;
  45318. /**
  45319. * Specifies the roughness scalar of the metallic/roughness workflow.
  45320. * Can also be used to scale the roughness values of the metallic texture.
  45321. */
  45322. protected _roughness: Nullable<number>;
  45323. /**
  45324. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45325. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45326. */
  45327. protected _microSurfaceTexture: BaseTexture;
  45328. /**
  45329. * Stores surface normal data used to displace a mesh in a texture.
  45330. */
  45331. protected _bumpTexture: BaseTexture;
  45332. /**
  45333. * Stores the pre-calculated light information of a mesh in a texture.
  45334. */
  45335. protected _lightmapTexture: BaseTexture;
  45336. /**
  45337. * The color of a material in ambient lighting.
  45338. */
  45339. protected _ambientColor: Color3;
  45340. /**
  45341. * AKA Diffuse Color in other nomenclature.
  45342. */
  45343. protected _albedoColor: Color3;
  45344. /**
  45345. * AKA Specular Color in other nomenclature.
  45346. */
  45347. protected _reflectivityColor: Color3;
  45348. /**
  45349. * The color applied when light is reflected from a material.
  45350. */
  45351. protected _reflectionColor: Color3;
  45352. /**
  45353. * The color applied when light is emitted from a material.
  45354. */
  45355. protected _emissiveColor: Color3;
  45356. /**
  45357. * AKA Glossiness in other nomenclature.
  45358. */
  45359. protected _microSurface: number;
  45360. /**
  45361. * source material index of refraction (IOR)' / 'destination material IOR.
  45362. */
  45363. protected _indexOfRefraction: number;
  45364. /**
  45365. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45366. */
  45367. protected _invertRefractionY: boolean;
  45368. /**
  45369. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45370. * Materials half opaque for instance using refraction could benefit from this control.
  45371. */
  45372. protected _linkRefractionWithTransparency: boolean;
  45373. /**
  45374. * Specifies that the material will use the light map as a show map.
  45375. */
  45376. protected _useLightmapAsShadowmap: boolean;
  45377. /**
  45378. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45379. * makes the reflect vector face the model (under horizon).
  45380. */
  45381. protected _useHorizonOcclusion: boolean;
  45382. /**
  45383. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45384. * too much the area relying on ambient texture to define their ambient occlusion.
  45385. */
  45386. protected _useRadianceOcclusion: boolean;
  45387. /**
  45388. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45389. */
  45390. protected _useAlphaFromAlbedoTexture: boolean;
  45391. /**
  45392. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45393. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45394. */
  45395. protected _useSpecularOverAlpha: boolean;
  45396. /**
  45397. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45398. */
  45399. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45400. /**
  45401. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45402. */
  45403. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45404. /**
  45405. * Specifies if the metallic texture contains the roughness information in its green channel.
  45406. */
  45407. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45408. /**
  45409. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45410. */
  45411. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45412. /**
  45413. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45414. */
  45415. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45416. /**
  45417. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45418. */
  45419. protected _useAmbientInGrayScale: boolean;
  45420. /**
  45421. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45422. * The material will try to infer what glossiness each pixel should be.
  45423. */
  45424. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45425. /**
  45426. * Defines the falloff type used in this material.
  45427. * It by default is Physical.
  45428. */
  45429. protected _lightFalloff: number;
  45430. /**
  45431. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45432. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45433. */
  45434. protected _useRadianceOverAlpha: boolean;
  45435. /**
  45436. * Allows using an object space normal map (instead of tangent space).
  45437. */
  45438. protected _useObjectSpaceNormalMap: boolean;
  45439. /**
  45440. * Allows using the bump map in parallax mode.
  45441. */
  45442. protected _useParallax: boolean;
  45443. /**
  45444. * Allows using the bump map in parallax occlusion mode.
  45445. */
  45446. protected _useParallaxOcclusion: boolean;
  45447. /**
  45448. * Controls the scale bias of the parallax mode.
  45449. */
  45450. protected _parallaxScaleBias: number;
  45451. /**
  45452. * If sets to true, disables all the lights affecting the material.
  45453. */
  45454. protected _disableLighting: boolean;
  45455. /**
  45456. * Number of Simultaneous lights allowed on the material.
  45457. */
  45458. protected _maxSimultaneousLights: number;
  45459. /**
  45460. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45461. */
  45462. protected _invertNormalMapX: boolean;
  45463. /**
  45464. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45465. */
  45466. protected _invertNormalMapY: boolean;
  45467. /**
  45468. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45469. */
  45470. protected _twoSidedLighting: boolean;
  45471. /**
  45472. * Defines the alpha limits in alpha test mode.
  45473. */
  45474. protected _alphaCutOff: number;
  45475. /**
  45476. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45477. */
  45478. protected _forceAlphaTest: boolean;
  45479. /**
  45480. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45481. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45482. */
  45483. protected _useAlphaFresnel: boolean;
  45484. /**
  45485. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45486. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45487. */
  45488. protected _useLinearAlphaFresnel: boolean;
  45489. /**
  45490. * The transparency mode of the material.
  45491. */
  45492. protected _transparencyMode: Nullable<number>;
  45493. /**
  45494. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45495. * from cos thetav and roughness:
  45496. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45497. */
  45498. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45499. /**
  45500. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45501. */
  45502. protected _forceIrradianceInFragment: boolean;
  45503. /**
  45504. * Force normal to face away from face.
  45505. */
  45506. protected _forceNormalForward: boolean;
  45507. /**
  45508. * Enables specular anti aliasing in the PBR shader.
  45509. * It will both interacts on the Geometry for analytical and IBL lighting.
  45510. * It also prefilter the roughness map based on the bump values.
  45511. */
  45512. protected _enableSpecularAntiAliasing: boolean;
  45513. /**
  45514. * Default configuration related to image processing available in the PBR Material.
  45515. */
  45516. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45517. /**
  45518. * Keep track of the image processing observer to allow dispose and replace.
  45519. */
  45520. private _imageProcessingObserver;
  45521. /**
  45522. * Attaches a new image processing configuration to the PBR Material.
  45523. * @param configuration
  45524. */
  45525. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45526. /**
  45527. * Stores the available render targets.
  45528. */
  45529. private _renderTargets;
  45530. /**
  45531. * Sets the global ambient color for the material used in lighting calculations.
  45532. */
  45533. private _globalAmbientColor;
  45534. /**
  45535. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45536. */
  45537. private _useLogarithmicDepth;
  45538. /**
  45539. * If set to true, no lighting calculations will be applied.
  45540. */
  45541. private _unlit;
  45542. /**
  45543. * Instantiates a new PBRMaterial instance.
  45544. *
  45545. * @param name The material name
  45546. * @param scene The scene the material will be use in.
  45547. */
  45548. constructor(name: string, scene: Scene);
  45549. /**
  45550. * Gets a boolean indicating that current material needs to register RTT
  45551. */
  45552. readonly hasRenderTargetTextures: boolean;
  45553. /**
  45554. * Gets the name of the material class.
  45555. */
  45556. getClassName(): string;
  45557. /**
  45558. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45559. */
  45560. /**
  45561. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45562. */
  45563. useLogarithmicDepth: boolean;
  45564. /**
  45565. * Gets the current transparency mode.
  45566. */
  45567. /**
  45568. * Sets the transparency mode of the material.
  45569. *
  45570. * | Value | Type | Description |
  45571. * | ----- | ----------------------------------- | ----------- |
  45572. * | 0 | OPAQUE | |
  45573. * | 1 | ALPHATEST | |
  45574. * | 2 | ALPHABLEND | |
  45575. * | 3 | ALPHATESTANDBLEND | |
  45576. *
  45577. */
  45578. transparencyMode: Nullable<number>;
  45579. /**
  45580. * Returns true if alpha blending should be disabled.
  45581. */
  45582. private readonly _disableAlphaBlending;
  45583. /**
  45584. * Specifies whether or not this material should be rendered in alpha blend mode.
  45585. */
  45586. needAlphaBlending(): boolean;
  45587. /**
  45588. * Specifies if the mesh will require alpha blending.
  45589. * @param mesh - BJS mesh.
  45590. */
  45591. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45592. /**
  45593. * Specifies whether or not this material should be rendered in alpha test mode.
  45594. */
  45595. needAlphaTesting(): boolean;
  45596. /**
  45597. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45598. */
  45599. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45600. /**
  45601. * Gets the texture used for the alpha test.
  45602. */
  45603. getAlphaTestTexture(): BaseTexture;
  45604. /**
  45605. * Stores the reflectivity values based on metallic roughness workflow.
  45606. */
  45607. private static _scaledReflectivity;
  45608. /**
  45609. * Specifies that the submesh is ready to be used.
  45610. * @param mesh - BJS mesh.
  45611. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45612. * @param useInstances - Specifies that instances should be used.
  45613. * @returns - boolean indicating that the submesh is ready or not.
  45614. */
  45615. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45616. /**
  45617. * Specifies if the material uses metallic roughness workflow.
  45618. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45619. */
  45620. isMetallicWorkflow(): boolean;
  45621. private _prepareEffect;
  45622. private _prepareDefines;
  45623. /**
  45624. * Force shader compilation
  45625. */
  45626. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45627. clipPlane: boolean;
  45628. }>): void;
  45629. /**
  45630. * Initializes the uniform buffer layout for the shader.
  45631. */
  45632. buildUniformLayout(): void;
  45633. /**
  45634. * Unbinds the textures.
  45635. */
  45636. unbind(): void;
  45637. /**
  45638. * Binds the submesh data.
  45639. * @param world - The world matrix.
  45640. * @param mesh - The BJS mesh.
  45641. * @param subMesh - A submesh of the BJS mesh.
  45642. */
  45643. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45644. /**
  45645. * Returns the animatable textures.
  45646. * @returns - Array of animatable textures.
  45647. */
  45648. getAnimatables(): IAnimatable[];
  45649. /**
  45650. * Returns the texture used for reflections.
  45651. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45652. */
  45653. private _getReflectionTexture;
  45654. /**
  45655. * Returns the texture used for refraction or null if none is used.
  45656. * @returns - Refection texture if present. If no refraction texture and refraction
  45657. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45658. */
  45659. private _getRefractionTexture;
  45660. /**
  45661. * Disposes the resources of the material.
  45662. * @param forceDisposeEffect - Forces the disposal of effects.
  45663. * @param forceDisposeTextures - Forces the disposal of all textures.
  45664. */
  45665. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45666. }
  45667. }
  45668. declare module BABYLON {
  45669. /**
  45670. * The Physically based simple base material of BJS.
  45671. *
  45672. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45673. * It is used as the base class for both the specGloss and metalRough conventions.
  45674. */
  45675. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45676. /**
  45677. * Number of Simultaneous lights allowed on the material.
  45678. */
  45679. maxSimultaneousLights: number;
  45680. /**
  45681. * If sets to true, disables all the lights affecting the material.
  45682. */
  45683. disableLighting: boolean;
  45684. /**
  45685. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45686. */
  45687. environmentTexture: BaseTexture;
  45688. /**
  45689. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45690. */
  45691. invertNormalMapX: boolean;
  45692. /**
  45693. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45694. */
  45695. invertNormalMapY: boolean;
  45696. /**
  45697. * Normal map used in the model.
  45698. */
  45699. normalTexture: BaseTexture;
  45700. /**
  45701. * Emissivie color used to self-illuminate the model.
  45702. */
  45703. emissiveColor: Color3;
  45704. /**
  45705. * Emissivie texture used to self-illuminate the model.
  45706. */
  45707. emissiveTexture: BaseTexture;
  45708. /**
  45709. * Occlusion Channel Strenght.
  45710. */
  45711. occlusionStrength: number;
  45712. /**
  45713. * Occlusion Texture of the material (adding extra occlusion effects).
  45714. */
  45715. occlusionTexture: BaseTexture;
  45716. /**
  45717. * Defines the alpha limits in alpha test mode.
  45718. */
  45719. alphaCutOff: number;
  45720. /**
  45721. * Gets the current double sided mode.
  45722. */
  45723. /**
  45724. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45725. */
  45726. doubleSided: boolean;
  45727. /**
  45728. * Stores the pre-calculated light information of a mesh in a texture.
  45729. */
  45730. lightmapTexture: BaseTexture;
  45731. /**
  45732. * If true, the light map contains occlusion information instead of lighting info.
  45733. */
  45734. useLightmapAsShadowmap: boolean;
  45735. /**
  45736. * Return the active textures of the material.
  45737. */
  45738. getActiveTextures(): BaseTexture[];
  45739. hasTexture(texture: BaseTexture): boolean;
  45740. /**
  45741. * Instantiates a new PBRMaterial instance.
  45742. *
  45743. * @param name The material name
  45744. * @param scene The scene the material will be use in.
  45745. */
  45746. constructor(name: string, scene: Scene);
  45747. getClassName(): string;
  45748. }
  45749. }
  45750. declare module BABYLON {
  45751. /**
  45752. * The Physically based material of BJS.
  45753. *
  45754. * This offers the main features of a standard PBR material.
  45755. * For more information, please refer to the documentation :
  45756. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45757. */
  45758. class PBRMaterial extends PBRBaseMaterial {
  45759. /**
  45760. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45761. */
  45762. static readonly PBRMATERIAL_OPAQUE: number;
  45763. /**
  45764. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45765. */
  45766. static readonly PBRMATERIAL_ALPHATEST: number;
  45767. /**
  45768. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45769. */
  45770. static readonly PBRMATERIAL_ALPHABLEND: number;
  45771. /**
  45772. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45773. * They are also discarded below the alpha cutoff threshold to improve performances.
  45774. */
  45775. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45776. /**
  45777. * Defines the default value of how much AO map is occluding the analytical lights
  45778. * (point spot...).
  45779. */
  45780. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45781. /**
  45782. * Intensity of the direct lights e.g. the four lights available in your scene.
  45783. * This impacts both the direct diffuse and specular highlights.
  45784. */
  45785. directIntensity: number;
  45786. /**
  45787. * Intensity of the emissive part of the material.
  45788. * This helps controlling the emissive effect without modifying the emissive color.
  45789. */
  45790. emissiveIntensity: number;
  45791. /**
  45792. * Intensity of the environment e.g. how much the environment will light the object
  45793. * either through harmonics for rough material or through the refelction for shiny ones.
  45794. */
  45795. environmentIntensity: number;
  45796. /**
  45797. * This is a special control allowing the reduction of the specular highlights coming from the
  45798. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45799. */
  45800. specularIntensity: number;
  45801. /**
  45802. * Debug Control allowing disabling the bump map on this material.
  45803. */
  45804. disableBumpMap: boolean;
  45805. /**
  45806. * AKA Diffuse Texture in standard nomenclature.
  45807. */
  45808. albedoTexture: BaseTexture;
  45809. /**
  45810. * AKA Occlusion Texture in other nomenclature.
  45811. */
  45812. ambientTexture: BaseTexture;
  45813. /**
  45814. * AKA Occlusion Texture Intensity in other nomenclature.
  45815. */
  45816. ambientTextureStrength: number;
  45817. /**
  45818. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45819. * 1 means it completely occludes it
  45820. * 0 mean it has no impact
  45821. */
  45822. ambientTextureImpactOnAnalyticalLights: number;
  45823. /**
  45824. * Stores the alpha values in a texture.
  45825. */
  45826. opacityTexture: BaseTexture;
  45827. /**
  45828. * Stores the reflection values in a texture.
  45829. */
  45830. reflectionTexture: Nullable<BaseTexture>;
  45831. /**
  45832. * Stores the emissive values in a texture.
  45833. */
  45834. emissiveTexture: BaseTexture;
  45835. /**
  45836. * AKA Specular texture in other nomenclature.
  45837. */
  45838. reflectivityTexture: BaseTexture;
  45839. /**
  45840. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45841. */
  45842. metallicTexture: BaseTexture;
  45843. /**
  45844. * Specifies the metallic scalar of the metallic/roughness workflow.
  45845. * Can also be used to scale the metalness values of the metallic texture.
  45846. */
  45847. metallic: Nullable<number>;
  45848. /**
  45849. * Specifies the roughness scalar of the metallic/roughness workflow.
  45850. * Can also be used to scale the roughness values of the metallic texture.
  45851. */
  45852. roughness: Nullable<number>;
  45853. /**
  45854. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45855. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45856. */
  45857. microSurfaceTexture: BaseTexture;
  45858. /**
  45859. * Stores surface normal data used to displace a mesh in a texture.
  45860. */
  45861. bumpTexture: BaseTexture;
  45862. /**
  45863. * Stores the pre-calculated light information of a mesh in a texture.
  45864. */
  45865. lightmapTexture: BaseTexture;
  45866. /**
  45867. * Stores the refracted light information in a texture.
  45868. */
  45869. refractionTexture: BaseTexture;
  45870. /**
  45871. * The color of a material in ambient lighting.
  45872. */
  45873. ambientColor: Color3;
  45874. /**
  45875. * AKA Diffuse Color in other nomenclature.
  45876. */
  45877. albedoColor: Color3;
  45878. /**
  45879. * AKA Specular Color in other nomenclature.
  45880. */
  45881. reflectivityColor: Color3;
  45882. /**
  45883. * The color reflected from the material.
  45884. */
  45885. reflectionColor: Color3;
  45886. /**
  45887. * The color emitted from the material.
  45888. */
  45889. emissiveColor: Color3;
  45890. /**
  45891. * AKA Glossiness in other nomenclature.
  45892. */
  45893. microSurface: number;
  45894. /**
  45895. * source material index of refraction (IOR)' / 'destination material IOR.
  45896. */
  45897. indexOfRefraction: number;
  45898. /**
  45899. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45900. */
  45901. invertRefractionY: boolean;
  45902. /**
  45903. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45904. * Materials half opaque for instance using refraction could benefit from this control.
  45905. */
  45906. linkRefractionWithTransparency: boolean;
  45907. /**
  45908. * If true, the light map contains occlusion information instead of lighting info.
  45909. */
  45910. useLightmapAsShadowmap: boolean;
  45911. /**
  45912. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45913. */
  45914. useAlphaFromAlbedoTexture: boolean;
  45915. /**
  45916. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45917. */
  45918. forceAlphaTest: boolean;
  45919. /**
  45920. * Defines the alpha limits in alpha test mode.
  45921. */
  45922. alphaCutOff: number;
  45923. /**
  45924. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45925. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45926. */
  45927. useSpecularOverAlpha: boolean;
  45928. /**
  45929. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45930. */
  45931. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45932. /**
  45933. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45934. */
  45935. useRoughnessFromMetallicTextureAlpha: boolean;
  45936. /**
  45937. * Specifies if the metallic texture contains the roughness information in its green channel.
  45938. */
  45939. useRoughnessFromMetallicTextureGreen: boolean;
  45940. /**
  45941. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45942. */
  45943. useMetallnessFromMetallicTextureBlue: boolean;
  45944. /**
  45945. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45946. */
  45947. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45948. /**
  45949. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45950. */
  45951. useAmbientInGrayScale: boolean;
  45952. /**
  45953. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45954. * The material will try to infer what glossiness each pixel should be.
  45955. */
  45956. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45957. /**
  45958. * BJS is using an harcoded light falloff based on a manually sets up range.
  45959. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45960. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45961. */
  45962. /**
  45963. * BJS is using an harcoded light falloff based on a manually sets up range.
  45964. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45965. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45966. */
  45967. usePhysicalLightFalloff: boolean;
  45968. /**
  45969. * In order to support the falloff compatibility with gltf, a special mode has been added
  45970. * to reproduce the gltf light falloff.
  45971. */
  45972. /**
  45973. * In order to support the falloff compatibility with gltf, a special mode has been added
  45974. * to reproduce the gltf light falloff.
  45975. */
  45976. useGLTFLightFalloff: boolean;
  45977. /**
  45978. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45979. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45980. */
  45981. useRadianceOverAlpha: boolean;
  45982. /**
  45983. * Allows using an object space normal map (instead of tangent space).
  45984. */
  45985. useObjectSpaceNormalMap: boolean;
  45986. /**
  45987. * Allows using the bump map in parallax mode.
  45988. */
  45989. useParallax: boolean;
  45990. /**
  45991. * Allows using the bump map in parallax occlusion mode.
  45992. */
  45993. useParallaxOcclusion: boolean;
  45994. /**
  45995. * Controls the scale bias of the parallax mode.
  45996. */
  45997. parallaxScaleBias: number;
  45998. /**
  45999. * If sets to true, disables all the lights affecting the material.
  46000. */
  46001. disableLighting: boolean;
  46002. /**
  46003. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46004. */
  46005. forceIrradianceInFragment: boolean;
  46006. /**
  46007. * Number of Simultaneous lights allowed on the material.
  46008. */
  46009. maxSimultaneousLights: number;
  46010. /**
  46011. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46012. */
  46013. invertNormalMapX: boolean;
  46014. /**
  46015. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46016. */
  46017. invertNormalMapY: boolean;
  46018. /**
  46019. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46020. */
  46021. twoSidedLighting: boolean;
  46022. /**
  46023. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46024. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46025. */
  46026. useAlphaFresnel: boolean;
  46027. /**
  46028. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46029. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46030. */
  46031. useLinearAlphaFresnel: boolean;
  46032. /**
  46033. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46034. * And/Or occlude the blended part.
  46035. */
  46036. environmentBRDFTexture: Nullable<BaseTexture>;
  46037. /**
  46038. * Force normal to face away from face.
  46039. */
  46040. forceNormalForward: boolean;
  46041. /**
  46042. * Enables specular anti aliasing in the PBR shader.
  46043. * It will both interacts on the Geometry for analytical and IBL lighting.
  46044. * It also prefilter the roughness map based on the bump values.
  46045. */
  46046. enableSpecularAntiAliasing: boolean;
  46047. /**
  46048. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46049. * makes the reflect vector face the model (under horizon).
  46050. */
  46051. useHorizonOcclusion: boolean;
  46052. /**
  46053. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46054. * too much the area relying on ambient texture to define their ambient occlusion.
  46055. */
  46056. useRadianceOcclusion: boolean;
  46057. /**
  46058. * If set to true, no lighting calculations will be applied.
  46059. */
  46060. unlit: boolean;
  46061. /**
  46062. * Gets the image processing configuration used either in this material.
  46063. */
  46064. /**
  46065. * Sets the Default image processing configuration used either in the this material.
  46066. *
  46067. * If sets to null, the scene one is in use.
  46068. */
  46069. imageProcessingConfiguration: ImageProcessingConfiguration;
  46070. /**
  46071. * Gets wether the color curves effect is enabled.
  46072. */
  46073. /**
  46074. * Sets wether the color curves effect is enabled.
  46075. */
  46076. cameraColorCurvesEnabled: boolean;
  46077. /**
  46078. * Gets wether the color grading effect is enabled.
  46079. */
  46080. /**
  46081. * Gets wether the color grading effect is enabled.
  46082. */
  46083. cameraColorGradingEnabled: boolean;
  46084. /**
  46085. * Gets wether tonemapping is enabled or not.
  46086. */
  46087. /**
  46088. * Sets wether tonemapping is enabled or not
  46089. */
  46090. cameraToneMappingEnabled: boolean;
  46091. /**
  46092. * The camera exposure used on this material.
  46093. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46094. * This corresponds to a photographic exposure.
  46095. */
  46096. /**
  46097. * The camera exposure used on this material.
  46098. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46099. * This corresponds to a photographic exposure.
  46100. */
  46101. cameraExposure: number;
  46102. /**
  46103. * Gets The camera contrast used on this material.
  46104. */
  46105. /**
  46106. * Sets The camera contrast used on this material.
  46107. */
  46108. cameraContrast: number;
  46109. /**
  46110. * Gets the Color Grading 2D Lookup Texture.
  46111. */
  46112. /**
  46113. * Sets the Color Grading 2D Lookup Texture.
  46114. */
  46115. cameraColorGradingTexture: Nullable<BaseTexture>;
  46116. /**
  46117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46119. * 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;
  46120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46121. */
  46122. /**
  46123. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46124. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46125. * 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;
  46126. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46127. */
  46128. cameraColorCurves: Nullable<ColorCurves>;
  46129. /**
  46130. * Instantiates a new PBRMaterial instance.
  46131. *
  46132. * @param name The material name
  46133. * @param scene The scene the material will be use in.
  46134. */
  46135. constructor(name: string, scene: Scene);
  46136. /**
  46137. * Returns the name of this material class.
  46138. */
  46139. getClassName(): string;
  46140. /**
  46141. * Returns an array of the actively used textures.
  46142. * @returns - Array of BaseTextures
  46143. */
  46144. getActiveTextures(): BaseTexture[];
  46145. /**
  46146. * Checks to see if a texture is used in the material.
  46147. * @param texture - Base texture to use.
  46148. * @returns - Boolean specifying if a texture is used in the material.
  46149. */
  46150. hasTexture(texture: BaseTexture): boolean;
  46151. /**
  46152. * Makes a duplicate of the current material.
  46153. * @param name - name to use for the new material.
  46154. */
  46155. clone(name: string): PBRMaterial;
  46156. /**
  46157. * Serializes this PBR Material.
  46158. * @returns - An object with the serialized material.
  46159. */
  46160. serialize(): any;
  46161. /**
  46162. * Parses a PBR Material from a serialized object.
  46163. * @param source - Serialized object.
  46164. * @param scene - BJS scene instance.
  46165. * @param rootUrl - url for the scene object
  46166. * @returns - PBRMaterial
  46167. */
  46168. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46169. }
  46170. }
  46171. declare module BABYLON {
  46172. /**
  46173. * The PBR material of BJS following the metal roughness convention.
  46174. *
  46175. * This fits to the PBR convention in the GLTF definition:
  46176. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  46177. */
  46178. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  46179. /**
  46180. * The base color has two different interpretations depending on the value of metalness.
  46181. * When the material is a metal, the base color is the specific measured reflectance value
  46182. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  46183. * of the material.
  46184. */
  46185. baseColor: Color3;
  46186. /**
  46187. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  46188. * well as opacity information in the alpha channel.
  46189. */
  46190. baseTexture: BaseTexture;
  46191. /**
  46192. * Specifies the metallic scalar value of the material.
  46193. * Can also be used to scale the metalness values of the metallic texture.
  46194. */
  46195. metallic: number;
  46196. /**
  46197. * Specifies the roughness scalar value of the material.
  46198. * Can also be used to scale the roughness values of the metallic texture.
  46199. */
  46200. roughness: number;
  46201. /**
  46202. * Texture containing both the metallic value in the B channel and the
  46203. * roughness value in the G channel to keep better precision.
  46204. */
  46205. metallicRoughnessTexture: BaseTexture;
  46206. /**
  46207. * Instantiates a new PBRMetalRoughnessMaterial instance.
  46208. *
  46209. * @param name The material name
  46210. * @param scene The scene the material will be use in.
  46211. */
  46212. constructor(name: string, scene: Scene);
  46213. /**
  46214. * Return the currrent class name of the material.
  46215. */
  46216. getClassName(): string;
  46217. /**
  46218. * Return the active textures of the material.
  46219. */
  46220. getActiveTextures(): BaseTexture[];
  46221. /**
  46222. * Checks to see if a texture is used in the material.
  46223. * @param texture - Base texture to use.
  46224. * @returns - Boolean specifying if a texture is used in the material.
  46225. */
  46226. hasTexture(texture: BaseTexture): boolean;
  46227. /**
  46228. * Makes a duplicate of the current material.
  46229. * @param name - name to use for the new material.
  46230. */
  46231. clone(name: string): PBRMetallicRoughnessMaterial;
  46232. /**
  46233. * Serialize the material to a parsable JSON object.
  46234. */
  46235. serialize(): any;
  46236. /**
  46237. * Parses a JSON object correponding to the serialize function.
  46238. */
  46239. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46240. }
  46241. }
  46242. declare module BABYLON {
  46243. /**
  46244. * The PBR material of BJS following the specular glossiness convention.
  46245. *
  46246. * This fits to the PBR convention in the GLTF definition:
  46247. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46248. */
  46249. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46250. /**
  46251. * Specifies the diffuse color of the material.
  46252. */
  46253. diffuseColor: Color3;
  46254. /**
  46255. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46256. * channel.
  46257. */
  46258. diffuseTexture: BaseTexture;
  46259. /**
  46260. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46261. */
  46262. specularColor: Color3;
  46263. /**
  46264. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46265. */
  46266. glossiness: number;
  46267. /**
  46268. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46269. */
  46270. specularGlossinessTexture: BaseTexture;
  46271. /**
  46272. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46273. *
  46274. * @param name The material name
  46275. * @param scene The scene the material will be use in.
  46276. */
  46277. constructor(name: string, scene: Scene);
  46278. /**
  46279. * Return the currrent class name of the material.
  46280. */
  46281. getClassName(): string;
  46282. /**
  46283. * Return the active textures of the material.
  46284. */
  46285. getActiveTextures(): BaseTexture[];
  46286. /**
  46287. * Checks to see if a texture is used in the material.
  46288. * @param texture - Base texture to use.
  46289. * @returns - Boolean specifying if a texture is used in the material.
  46290. */
  46291. hasTexture(texture: BaseTexture): boolean;
  46292. /**
  46293. * Makes a duplicate of the current material.
  46294. * @param name - name to use for the new material.
  46295. */
  46296. clone(name: string): PBRSpecularGlossinessMaterial;
  46297. /**
  46298. * Serialize the material to a parsable JSON object.
  46299. */
  46300. serialize(): any;
  46301. /**
  46302. * Parses a JSON object correponding to the serialize function.
  46303. */
  46304. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46305. }
  46306. }
  46307. declare module BABYLON {
  46308. /**
  46309. * Base class of all the textures in babylon.
  46310. * It groups all the common properties the materials, post process, lights... might need
  46311. * in order to make a correct use of the texture.
  46312. */
  46313. class BaseTexture {
  46314. /**
  46315. * Default anisotropic filtering level for the application.
  46316. * It is set to 4 as a good tradeoff between perf and quality.
  46317. */
  46318. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  46319. /**
  46320. * Gets or sets the unique id of the texture
  46321. */
  46322. uniqueId: number;
  46323. /**
  46324. * Define the name of the texture.
  46325. */
  46326. name: string;
  46327. /**
  46328. * Gets or sets an object used to store user defined information.
  46329. */
  46330. metadata: any;
  46331. /**
  46332. * For internal use only. Please do not use.
  46333. */
  46334. reservedDataStore: any;
  46335. private _hasAlpha;
  46336. /**
  46337. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  46338. */
  46339. hasAlpha: boolean;
  46340. /**
  46341. * Defines if the alpha value should be determined via the rgb values.
  46342. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  46343. */
  46344. getAlphaFromRGB: boolean;
  46345. /**
  46346. * Intensity or strength of the texture.
  46347. * It is commonly used by materials to fine tune the intensity of the texture
  46348. */
  46349. level: number;
  46350. /**
  46351. * Define the UV chanel to use starting from 0 and defaulting to 0.
  46352. * This is part of the texture as textures usually maps to one uv set.
  46353. */
  46354. coordinatesIndex: number;
  46355. private _coordinatesMode;
  46356. /**
  46357. * How a texture is mapped.
  46358. *
  46359. * | Value | Type | Description |
  46360. * | ----- | ----------------------------------- | ----------- |
  46361. * | 0 | EXPLICIT_MODE | |
  46362. * | 1 | SPHERICAL_MODE | |
  46363. * | 2 | PLANAR_MODE | |
  46364. * | 3 | CUBIC_MODE | |
  46365. * | 4 | PROJECTION_MODE | |
  46366. * | 5 | SKYBOX_MODE | |
  46367. * | 6 | INVCUBIC_MODE | |
  46368. * | 7 | EQUIRECTANGULAR_MODE | |
  46369. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  46370. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  46371. */
  46372. coordinatesMode: number;
  46373. /**
  46374. * | Value | Type | Description |
  46375. * | ----- | ------------------ | ----------- |
  46376. * | 0 | CLAMP_ADDRESSMODE | |
  46377. * | 1 | WRAP_ADDRESSMODE | |
  46378. * | 2 | MIRROR_ADDRESSMODE | |
  46379. */
  46380. wrapU: number;
  46381. /**
  46382. * | Value | Type | Description |
  46383. * | ----- | ------------------ | ----------- |
  46384. * | 0 | CLAMP_ADDRESSMODE | |
  46385. * | 1 | WRAP_ADDRESSMODE | |
  46386. * | 2 | MIRROR_ADDRESSMODE | |
  46387. */
  46388. wrapV: number;
  46389. /**
  46390. * | Value | Type | Description |
  46391. * | ----- | ------------------ | ----------- |
  46392. * | 0 | CLAMP_ADDRESSMODE | |
  46393. * | 1 | WRAP_ADDRESSMODE | |
  46394. * | 2 | MIRROR_ADDRESSMODE | |
  46395. */
  46396. wrapR: number;
  46397. /**
  46398. * With compliant hardware and browser (supporting anisotropic filtering)
  46399. * this defines the level of anisotropic filtering in the texture.
  46400. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  46401. */
  46402. anisotropicFilteringLevel: number;
  46403. /**
  46404. * Define if the texture is a cube texture or if false a 2d texture.
  46405. */
  46406. isCube: boolean;
  46407. /**
  46408. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  46409. */
  46410. is3D: boolean;
  46411. /**
  46412. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  46413. * HDR texture are usually stored in linear space.
  46414. * This only impacts the PBR and Background materials
  46415. */
  46416. gammaSpace: boolean;
  46417. /**
  46418. * Gets whether or not the texture contains RGBD data.
  46419. */
  46420. readonly isRGBD: boolean;
  46421. /**
  46422. * Is Z inverted in the texture (useful in a cube texture).
  46423. */
  46424. invertZ: boolean;
  46425. /**
  46426. * Are mip maps generated for this texture or not.
  46427. */
  46428. readonly noMipmap: boolean;
  46429. /**
  46430. * @hidden
  46431. */
  46432. lodLevelInAlpha: boolean;
  46433. /**
  46434. * With prefiltered texture, defined the offset used during the prefiltering steps.
  46435. */
  46436. lodGenerationOffset: number;
  46437. /**
  46438. * With prefiltered texture, defined the scale used during the prefiltering steps.
  46439. */
  46440. lodGenerationScale: number;
  46441. /**
  46442. * Define if the texture is a render target.
  46443. */
  46444. isRenderTarget: boolean;
  46445. /**
  46446. * Define the unique id of the texture in the scene.
  46447. */
  46448. readonly uid: string;
  46449. /**
  46450. * Return a string representation of the texture.
  46451. * @returns the texture as a string
  46452. */
  46453. toString(): string;
  46454. /**
  46455. * Get the class name of the texture.
  46456. * @returns "BaseTexture"
  46457. */
  46458. getClassName(): string;
  46459. /**
  46460. * Define the list of animation attached to the texture.
  46461. */
  46462. animations: Animation[];
  46463. /**
  46464. * An event triggered when the texture is disposed.
  46465. */
  46466. onDisposeObservable: Observable<BaseTexture>;
  46467. private _onDisposeObserver;
  46468. /**
  46469. * Callback triggered when the texture has been disposed.
  46470. * Kept for back compatibility, you can use the onDisposeObservable instead.
  46471. */
  46472. onDispose: () => void;
  46473. /**
  46474. * Define the current state of the loading sequence when in delayed load mode.
  46475. */
  46476. delayLoadState: number;
  46477. private _scene;
  46478. /** @hidden */
  46479. _samplingMode: number;
  46480. /** @hidden */
  46481. _texture: Nullable<InternalTexture>;
  46482. private _uid;
  46483. /**
  46484. * Define if the texture is preventinga material to render or not.
  46485. * If not and the texture is not ready, the engine will use a default black texture instead.
  46486. */
  46487. readonly isBlocking: boolean;
  46488. /**
  46489. * Instantiates a new BaseTexture.
  46490. * Base class of all the textures in babylon.
  46491. * It groups all the common properties the materials, post process, lights... might need
  46492. * in order to make a correct use of the texture.
  46493. * @param scene Define the scene the texture blongs to
  46494. */
  46495. constructor(scene: Nullable<Scene>);
  46496. /**
  46497. * Get the scene the texture belongs to.
  46498. * @returns the scene or null if undefined
  46499. */
  46500. getScene(): Nullable<Scene>;
  46501. /**
  46502. * Get the texture transform matrix used to offset tile the texture for istance.
  46503. * @returns the transformation matrix
  46504. */
  46505. getTextureMatrix(): Matrix;
  46506. /**
  46507. * Get the texture reflection matrix used to rotate/transform the reflection.
  46508. * @returns the reflection matrix
  46509. */
  46510. getReflectionTextureMatrix(): Matrix;
  46511. /**
  46512. * Get the underlying lower level texture from Babylon.
  46513. * @returns the insternal texture
  46514. */
  46515. getInternalTexture(): Nullable<InternalTexture>;
  46516. /**
  46517. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  46518. * @returns true if ready or not blocking
  46519. */
  46520. isReadyOrNotBlocking(): boolean;
  46521. /**
  46522. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  46523. * @returns true if fully ready
  46524. */
  46525. isReady(): boolean;
  46526. private _cachedSize;
  46527. /**
  46528. * Get the size of the texture.
  46529. * @returns the texture size.
  46530. */
  46531. getSize(): ISize;
  46532. /**
  46533. * Get the base size of the texture.
  46534. * It can be different from the size if the texture has been resized for POT for instance
  46535. * @returns the base size
  46536. */
  46537. getBaseSize(): ISize;
  46538. /**
  46539. * Update the sampling mode of the texture.
  46540. * Default is Trilinear mode.
  46541. *
  46542. * | Value | Type | Description |
  46543. * | ----- | ------------------ | ----------- |
  46544. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  46545. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  46546. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  46547. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  46548. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  46549. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  46550. * | 7 | NEAREST_LINEAR | |
  46551. * | 8 | NEAREST_NEAREST | |
  46552. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  46553. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  46554. * | 11 | LINEAR_LINEAR | |
  46555. * | 12 | LINEAR_NEAREST | |
  46556. *
  46557. * > _mag_: magnification filter (close to the viewer)
  46558. * > _min_: minification filter (far from the viewer)
  46559. * > _mip_: filter used between mip map levels
  46560. *@param samplingMode Define the new sampling mode of the texture
  46561. */
  46562. updateSamplingMode(samplingMode: number): void;
  46563. /**
  46564. * Scales the texture if is `canRescale()`
  46565. * @param ratio the resize factor we want to use to rescale
  46566. */
  46567. scale(ratio: number): void;
  46568. /**
  46569. * Get if the texture can rescale.
  46570. */
  46571. readonly canRescale: boolean;
  46572. /** @hidden */
  46573. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  46574. /** @hidden */
  46575. _rebuild(): void;
  46576. /**
  46577. * Triggers the load sequence in delayed load mode.
  46578. */
  46579. delayLoad(): void;
  46580. /**
  46581. * Clones the texture.
  46582. * @returns the cloned texture
  46583. */
  46584. clone(): Nullable<BaseTexture>;
  46585. /**
  46586. * Get the texture underlying type (INT, FLOAT...)
  46587. */
  46588. readonly textureType: number;
  46589. /**
  46590. * Get the texture underlying format (RGB, RGBA...)
  46591. */
  46592. readonly textureFormat: number;
  46593. /**
  46594. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46595. * This will returns an RGBA array buffer containing either in values (0-255) or
  46596. * float values (0-1) depending of the underlying buffer type.
  46597. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46598. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46599. * @param buffer defines a user defined buffer to fill with data (can be null)
  46600. * @returns The Array buffer containing the pixels data.
  46601. */
  46602. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46603. /**
  46604. * Release and destroy the underlying lower level texture aka internalTexture.
  46605. */
  46606. releaseInternalTexture(): void;
  46607. /**
  46608. * Get the polynomial representation of the texture data.
  46609. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46610. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46611. */
  46612. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46613. /** @hidden */
  46614. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46615. /** @hidden */
  46616. readonly _lodTextureMid: Nullable<BaseTexture>;
  46617. /** @hidden */
  46618. readonly _lodTextureLow: Nullable<BaseTexture>;
  46619. /**
  46620. * Dispose the texture and release its associated resources.
  46621. */
  46622. dispose(): void;
  46623. /**
  46624. * Serialize the texture into a JSON representation that can be parsed later on.
  46625. * @returns the JSON representation of the texture
  46626. */
  46627. serialize(): any;
  46628. /**
  46629. * Helper function to be called back once a list of texture contains only ready textures.
  46630. * @param textures Define the list of textures to wait for
  46631. * @param callback Define the callback triggered once the entire list will be ready
  46632. */
  46633. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46634. }
  46635. }
  46636. declare module BABYLON {
  46637. /**
  46638. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46639. * It can help converting any input color in a desired output one. This can then be used to create effects
  46640. * from sepia, black and white to sixties or futuristic rendering...
  46641. *
  46642. * The only supported format is currently 3dl.
  46643. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46644. */
  46645. class ColorGradingTexture extends BaseTexture {
  46646. /**
  46647. * The current texture matrix. (will always be identity in color grading texture)
  46648. */
  46649. private _textureMatrix;
  46650. /**
  46651. * The texture URL.
  46652. */
  46653. url: string;
  46654. /**
  46655. * Empty line regex stored for GC.
  46656. */
  46657. private static _noneEmptyLineRegex;
  46658. private _engine;
  46659. /**
  46660. * Instantiates a ColorGradingTexture from the following parameters.
  46661. *
  46662. * @param url The location of the color gradind data (currently only supporting 3dl)
  46663. * @param scene The scene the texture will be used in
  46664. */
  46665. constructor(url: string, scene: Scene);
  46666. /**
  46667. * Returns the texture matrix used in most of the material.
  46668. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46669. */
  46670. getTextureMatrix(): Matrix;
  46671. /**
  46672. * Occurs when the file being loaded is a .3dl LUT file.
  46673. */
  46674. private load3dlTexture;
  46675. /**
  46676. * Starts the loading process of the texture.
  46677. */
  46678. private loadTexture;
  46679. /**
  46680. * Clones the color gradind texture.
  46681. */
  46682. clone(): ColorGradingTexture;
  46683. /**
  46684. * Called during delayed load for textures.
  46685. */
  46686. delayLoad(): void;
  46687. /**
  46688. * Parses a color grading texture serialized by Babylon.
  46689. * @param parsedTexture The texture information being parsedTexture
  46690. * @param scene The scene to load the texture in
  46691. * @param rootUrl The root url of the data assets to load
  46692. * @return A color gradind texture
  46693. */
  46694. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46695. /**
  46696. * Serializes the LUT texture to json format.
  46697. */
  46698. serialize(): any;
  46699. }
  46700. }
  46701. declare module BABYLON {
  46702. /**
  46703. * Class for creating a cube texture
  46704. */
  46705. class CubeTexture extends BaseTexture {
  46706. private _delayedOnLoad;
  46707. /**
  46708. * The url of the texture
  46709. */
  46710. url: string;
  46711. /**
  46712. * Gets or sets the center of the bounding box associated with the cube texture.
  46713. * It must define where the camera used to render the texture was set
  46714. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46715. */
  46716. boundingBoxPosition: Vector3;
  46717. private _boundingBoxSize;
  46718. /**
  46719. * Gets or sets the size of the bounding box associated with the cube texture
  46720. * When defined, the cubemap will switch to local mode
  46721. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46722. * @example https://www.babylonjs-playground.com/#RNASML
  46723. */
  46724. /**
  46725. * Returns the bounding box size
  46726. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46727. */
  46728. boundingBoxSize: Vector3;
  46729. protected _rotationY: number;
  46730. /**
  46731. * Sets texture matrix rotation angle around Y axis in radians.
  46732. */
  46733. /**
  46734. * Gets texture matrix rotation angle around Y axis radians.
  46735. */
  46736. rotationY: number;
  46737. /**
  46738. * Are mip maps generated for this texture or not.
  46739. */
  46740. readonly noMipmap: boolean;
  46741. private _noMipmap;
  46742. private _files;
  46743. private _extensions;
  46744. private _textureMatrix;
  46745. private _format;
  46746. private _createPolynomials;
  46747. /** @hidden */
  46748. _prefiltered: boolean;
  46749. /**
  46750. * Creates a cube texture from an array of image urls
  46751. * @param files defines an array of image urls
  46752. * @param scene defines the hosting scene
  46753. * @param noMipmap specifies if mip maps are not used
  46754. * @returns a cube texture
  46755. */
  46756. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46757. /**
  46758. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46759. * @param url defines the url of the prefiltered texture
  46760. * @param scene defines the scene the texture is attached to
  46761. * @param forcedExtension defines the extension of the file if different from the url
  46762. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46763. * @return the prefiltered texture
  46764. */
  46765. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46766. /**
  46767. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46768. * as prefiltered data.
  46769. * @param rootUrl defines the url of the texture or the root name of the six images
  46770. * @param scene defines the scene the texture is attached to
  46771. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46772. * @param noMipmap defines if mipmaps should be created or not
  46773. * @param files defines the six files to load for the different faces
  46774. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46775. * @param onError defines a callback triggered in case of error during load
  46776. * @param format defines the internal format to use for the texture once loaded
  46777. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46778. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46779. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46780. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46781. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46782. * @return the cube texture
  46783. */
  46784. 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);
  46785. /**
  46786. * Get the current class name of the texture useful for serialization or dynamic coding.
  46787. * @returns "CubeTexture"
  46788. */
  46789. getClassName(): string;
  46790. /**
  46791. * Update the url (and optional buffer) of this texture if url was null during construction.
  46792. * @param url the url of the texture
  46793. * @param forcedExtension defines the extension to use
  46794. * @param onLoad callback called when the texture is loaded (defaults to null)
  46795. */
  46796. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  46797. /**
  46798. * Delays loading of the cube texture
  46799. * @param forcedExtension defines the extension to use
  46800. */
  46801. delayLoad(forcedExtension?: string): void;
  46802. /**
  46803. * Returns the reflection texture matrix
  46804. * @returns the reflection texture matrix
  46805. */
  46806. getReflectionTextureMatrix(): Matrix;
  46807. /**
  46808. * Sets the reflection texture matrix
  46809. * @param value Reflection texture matrix
  46810. */
  46811. setReflectionTextureMatrix(value: Matrix): void;
  46812. /**
  46813. * Parses text to create a cube texture
  46814. * @param parsedTexture define the serialized text to read from
  46815. * @param scene defines the hosting scene
  46816. * @param rootUrl defines the root url of the cube texture
  46817. * @returns a cube texture
  46818. */
  46819. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46820. /**
  46821. * Makes a clone, or deep copy, of the cube texture
  46822. * @returns a new cube texture
  46823. */
  46824. clone(): CubeTexture;
  46825. }
  46826. }
  46827. declare module BABYLON {
  46828. /**
  46829. * A class extending Texture allowing drawing on a texture
  46830. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46831. */
  46832. class DynamicTexture extends Texture {
  46833. private _generateMipMaps;
  46834. private _canvas;
  46835. private _context;
  46836. private _engine;
  46837. /**
  46838. * Creates a DynamicTexture
  46839. * @param name defines the name of the texture
  46840. * @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
  46841. * @param scene defines the scene where you want the texture
  46842. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46843. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46844. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46845. */
  46846. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46847. /**
  46848. * Get the current class name of the texture useful for serialization or dynamic coding.
  46849. * @returns "DynamicTexture"
  46850. */
  46851. getClassName(): string;
  46852. /**
  46853. * Gets the current state of canRescale
  46854. */
  46855. readonly canRescale: boolean;
  46856. private _recreate;
  46857. /**
  46858. * Scales the texture
  46859. * @param ratio the scale factor to apply to both width and height
  46860. */
  46861. scale(ratio: number): void;
  46862. /**
  46863. * Resizes the texture
  46864. * @param width the new width
  46865. * @param height the new height
  46866. */
  46867. scaleTo(width: number, height: number): void;
  46868. /**
  46869. * Gets the context of the canvas used by the texture
  46870. * @returns the canvas context of the dynamic texture
  46871. */
  46872. getContext(): CanvasRenderingContext2D;
  46873. /**
  46874. * Clears the texture
  46875. */
  46876. clear(): void;
  46877. /**
  46878. * Updates the texture
  46879. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46880. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46881. */
  46882. update(invertY?: boolean, premulAlpha?: boolean): void;
  46883. /**
  46884. * Draws text onto the texture
  46885. * @param text defines the text to be drawn
  46886. * @param x defines the placement of the text from the left
  46887. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46888. * @param font defines the font to be used with font-style, font-size, font-name
  46889. * @param color defines the color used for the text
  46890. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46891. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46892. * @param update defines whether texture is immediately update (default is true)
  46893. */
  46894. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  46895. /**
  46896. * Clones the texture
  46897. * @returns the clone of the texture.
  46898. */
  46899. clone(): DynamicTexture;
  46900. /**
  46901. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46902. * @returns a serialized dynamic texture object
  46903. */
  46904. serialize(): any;
  46905. /** @hidden */
  46906. _rebuild(): void;
  46907. }
  46908. }
  46909. declare module BABYLON {
  46910. /**
  46911. * This represents a texture coming from an HDR input.
  46912. *
  46913. * The only supported format is currently panorama picture stored in RGBE format.
  46914. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46915. */
  46916. class HDRCubeTexture extends BaseTexture {
  46917. private static _facesMapping;
  46918. private _generateHarmonics;
  46919. private _noMipmap;
  46920. private _textureMatrix;
  46921. private _size;
  46922. private _onLoad;
  46923. private _onError;
  46924. /**
  46925. * The texture URL.
  46926. */
  46927. url: string;
  46928. /**
  46929. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46930. */
  46931. coordinatesMode: number;
  46932. protected _isBlocking: boolean;
  46933. /**
  46934. * Sets wether or not the texture is blocking during loading.
  46935. */
  46936. /**
  46937. * Gets wether or not the texture is blocking during loading.
  46938. */
  46939. isBlocking: boolean;
  46940. protected _rotationY: number;
  46941. /**
  46942. * Sets texture matrix rotation angle around Y axis in radians.
  46943. */
  46944. /**
  46945. * Gets texture matrix rotation angle around Y axis radians.
  46946. */
  46947. rotationY: number;
  46948. /**
  46949. * Gets or sets the center of the bounding box associated with the cube texture
  46950. * It must define where the camera used to render the texture was set
  46951. */
  46952. boundingBoxPosition: Vector3;
  46953. private _boundingBoxSize;
  46954. /**
  46955. * Gets or sets the size of the bounding box associated with the cube texture
  46956. * When defined, the cubemap will switch to local mode
  46957. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46958. * @example https://www.babylonjs-playground.com/#RNASML
  46959. */
  46960. boundingBoxSize: Vector3;
  46961. /**
  46962. * Instantiates an HDRTexture from the following parameters.
  46963. *
  46964. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46965. * @param scene The scene the texture will be used in
  46966. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46967. * @param noMipmap Forces to not generate the mipmap if true
  46968. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46969. * @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)
  46970. * @param reserved Reserved flag for internal use.
  46971. */
  46972. 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>);
  46973. /**
  46974. * Get the current class name of the texture useful for serialization or dynamic coding.
  46975. * @returns "HDRCubeTexture"
  46976. */
  46977. getClassName(): string;
  46978. /**
  46979. * Occurs when the file is raw .hdr file.
  46980. */
  46981. private loadTexture;
  46982. clone(): HDRCubeTexture;
  46983. delayLoad(): void;
  46984. /**
  46985. * Get the texture reflection matrix used to rotate/transform the reflection.
  46986. * @returns the reflection matrix
  46987. */
  46988. getReflectionTextureMatrix(): Matrix;
  46989. /**
  46990. * Set the texture reflection matrix used to rotate/transform the reflection.
  46991. * @param value Define the reflection matrix to set
  46992. */
  46993. setReflectionTextureMatrix(value: Matrix): void;
  46994. /**
  46995. * Parses a JSON representation of an HDR Texture in order to create the texture
  46996. * @param parsedTexture Define the JSON representation
  46997. * @param scene Define the scene the texture should be created in
  46998. * @param rootUrl Define the root url in case we need to load relative dependencies
  46999. * @returns the newly created texture after parsing
  47000. */
  47001. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47002. serialize(): any;
  47003. }
  47004. }
  47005. declare module BABYLON {
  47006. /**
  47007. * Class used to store data associated with WebGL texture data for the engine
  47008. * This class should not be used directly
  47009. */
  47010. class InternalTexture implements IInternalTextureTracker {
  47011. /**
  47012. * The source of the texture data is unknown
  47013. */
  47014. static DATASOURCE_UNKNOWN: number;
  47015. /**
  47016. * Texture data comes from an URL
  47017. */
  47018. static DATASOURCE_URL: number;
  47019. /**
  47020. * Texture data is only used for temporary storage
  47021. */
  47022. static DATASOURCE_TEMP: number;
  47023. /**
  47024. * Texture data comes from raw data (ArrayBuffer)
  47025. */
  47026. static DATASOURCE_RAW: number;
  47027. /**
  47028. * Texture content is dynamic (video or dynamic texture)
  47029. */
  47030. static DATASOURCE_DYNAMIC: number;
  47031. /**
  47032. * Texture content is generated by rendering to it
  47033. */
  47034. static DATASOURCE_RENDERTARGET: number;
  47035. /**
  47036. * Texture content is part of a multi render target process
  47037. */
  47038. static DATASOURCE_MULTIRENDERTARGET: number;
  47039. /**
  47040. * Texture data comes from a cube data file
  47041. */
  47042. static DATASOURCE_CUBE: number;
  47043. /**
  47044. * Texture data comes from a raw cube data
  47045. */
  47046. static DATASOURCE_CUBERAW: number;
  47047. /**
  47048. * Texture data come from a prefiltered cube data file
  47049. */
  47050. static DATASOURCE_CUBEPREFILTERED: number;
  47051. /**
  47052. * Texture content is raw 3D data
  47053. */
  47054. static DATASOURCE_RAW3D: number;
  47055. /**
  47056. * Texture content is a depth texture
  47057. */
  47058. static DATASOURCE_DEPTHTEXTURE: number;
  47059. /**
  47060. * Texture data comes from a raw cube data encoded with RGBD
  47061. */
  47062. static DATASOURCE_CUBERAW_RGBD: number;
  47063. /**
  47064. * Defines if the texture is ready
  47065. */
  47066. isReady: boolean;
  47067. /**
  47068. * Defines if the texture is a cube texture
  47069. */
  47070. isCube: boolean;
  47071. /**
  47072. * Defines if the texture contains 3D data
  47073. */
  47074. is3D: boolean;
  47075. /**
  47076. * Gets the URL used to load this texture
  47077. */
  47078. url: string;
  47079. /**
  47080. * Gets the sampling mode of the texture
  47081. */
  47082. samplingMode: number;
  47083. /**
  47084. * Gets a boolean indicating if the texture needs mipmaps generation
  47085. */
  47086. generateMipMaps: boolean;
  47087. /**
  47088. * Gets the number of samples used by the texture (WebGL2+ only)
  47089. */
  47090. samples: number;
  47091. /**
  47092. * Gets the type of the texture (int, float...)
  47093. */
  47094. type: number;
  47095. /**
  47096. * Gets the format of the texture (RGB, RGBA...)
  47097. */
  47098. format: number;
  47099. /**
  47100. * Observable called when the texture is loaded
  47101. */
  47102. onLoadedObservable: Observable<InternalTexture>;
  47103. /**
  47104. * Gets the width of the texture
  47105. */
  47106. width: number;
  47107. /**
  47108. * Gets the height of the texture
  47109. */
  47110. height: number;
  47111. /**
  47112. * Gets the depth of the texture
  47113. */
  47114. depth: number;
  47115. /**
  47116. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  47117. */
  47118. baseWidth: number;
  47119. /**
  47120. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  47121. */
  47122. baseHeight: number;
  47123. /**
  47124. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  47125. */
  47126. baseDepth: number;
  47127. /**
  47128. * Gets a boolean indicating if the texture is inverted on Y axis
  47129. */
  47130. invertY: boolean;
  47131. /**
  47132. * Gets or set the previous tracker in the list
  47133. */
  47134. previous: Nullable<IInternalTextureTracker>;
  47135. /**
  47136. * Gets or set the next tracker in the list
  47137. */
  47138. next: Nullable<IInternalTextureTracker>;
  47139. /** @hidden */
  47140. _initialSlot: number;
  47141. /** @hidden */
  47142. _designatedSlot: number;
  47143. /** @hidden */
  47144. _dataSource: number;
  47145. /** @hidden */
  47146. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47147. /** @hidden */
  47148. _bufferView: Nullable<ArrayBufferView>;
  47149. /** @hidden */
  47150. _bufferViewArray: Nullable<ArrayBufferView[]>;
  47151. /** @hidden */
  47152. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  47153. /** @hidden */
  47154. _size: number;
  47155. /** @hidden */
  47156. _extension: string;
  47157. /** @hidden */
  47158. _files: Nullable<string[]>;
  47159. /** @hidden */
  47160. _workingCanvas: HTMLCanvasElement;
  47161. /** @hidden */
  47162. _workingContext: CanvasRenderingContext2D;
  47163. /** @hidden */
  47164. _framebuffer: Nullable<WebGLFramebuffer>;
  47165. /** @hidden */
  47166. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  47167. /** @hidden */
  47168. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  47169. /** @hidden */
  47170. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  47171. /** @hidden */
  47172. _attachments: Nullable<number[]>;
  47173. /** @hidden */
  47174. _cachedCoordinatesMode: Nullable<number>;
  47175. /** @hidden */
  47176. _cachedWrapU: Nullable<number>;
  47177. /** @hidden */
  47178. _cachedWrapV: Nullable<number>;
  47179. /** @hidden */
  47180. _cachedWrapR: Nullable<number>;
  47181. /** @hidden */
  47182. _cachedAnisotropicFilteringLevel: Nullable<number>;
  47183. /** @hidden */
  47184. _isDisabled: boolean;
  47185. /** @hidden */
  47186. _compression: Nullable<string>;
  47187. /** @hidden */
  47188. _generateStencilBuffer: boolean;
  47189. /** @hidden */
  47190. _generateDepthBuffer: boolean;
  47191. /** @hidden */
  47192. _comparisonFunction: number;
  47193. /** @hidden */
  47194. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  47195. /** @hidden */
  47196. _lodGenerationScale: number;
  47197. /** @hidden */
  47198. _lodGenerationOffset: number;
  47199. /** @hidden */
  47200. _lodTextureHigh: BaseTexture;
  47201. /** @hidden */
  47202. _lodTextureMid: BaseTexture;
  47203. /** @hidden */
  47204. _lodTextureLow: BaseTexture;
  47205. /** @hidden */
  47206. _isRGBD: boolean;
  47207. /** @hidden */
  47208. _webGLTexture: Nullable<WebGLTexture>;
  47209. /** @hidden */
  47210. _references: number;
  47211. private _engine;
  47212. /**
  47213. * Gets the Engine the texture belongs to.
  47214. * @returns The babylon engine
  47215. */
  47216. getEngine(): Engine;
  47217. /**
  47218. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  47219. */
  47220. readonly dataSource: number;
  47221. /**
  47222. * Creates a new InternalTexture
  47223. * @param engine defines the engine to use
  47224. * @param dataSource defines the type of data that will be used
  47225. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47226. */
  47227. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  47228. /**
  47229. * Increments the number of references (ie. the number of Texture that point to it)
  47230. */
  47231. incrementReferences(): void;
  47232. /**
  47233. * Change the size of the texture (not the size of the content)
  47234. * @param width defines the new width
  47235. * @param height defines the new height
  47236. * @param depth defines the new depth (1 by default)
  47237. */
  47238. updateSize(width: int, height: int, depth?: int): void;
  47239. /** @hidden */
  47240. _rebuild(): void;
  47241. /** @hidden */
  47242. _swapAndDie(target: InternalTexture): void;
  47243. /**
  47244. * Dispose the current allocated resources
  47245. */
  47246. dispose(): void;
  47247. }
  47248. }
  47249. declare module BABYLON {
  47250. /**
  47251. * This represents the required contract to create a new type of texture loader.
  47252. */
  47253. interface IInternalTextureLoader {
  47254. /**
  47255. * Defines wether the loader supports cascade loading the different faces.
  47256. */
  47257. supportCascades: boolean;
  47258. /**
  47259. * This returns if the loader support the current file information.
  47260. * @param extension defines the file extension of the file being loaded
  47261. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47262. * @param fallback defines the fallback internal texture if any
  47263. * @param isBase64 defines whether the texture is encoded as a base64
  47264. * @param isBuffer defines whether the texture data are stored as a buffer
  47265. * @returns true if the loader can load the specified file
  47266. */
  47267. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47268. /**
  47269. * Transform the url before loading if required.
  47270. * @param rootUrl the url of the texture
  47271. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47272. * @returns the transformed texture
  47273. */
  47274. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47275. /**
  47276. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47277. * @param rootUrl the url of the texture
  47278. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47279. * @returns the fallback texture
  47280. */
  47281. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47282. /**
  47283. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47284. * @param data contains the texture data
  47285. * @param texture defines the BabylonJS internal texture
  47286. * @param createPolynomials will be true if polynomials have been requested
  47287. * @param onLoad defines the callback to trigger once the texture is ready
  47288. * @param onError defines the callback to trigger in case of error
  47289. */
  47290. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47291. /**
  47292. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47293. * @param data contains the texture data
  47294. * @param texture defines the BabylonJS internal texture
  47295. * @param callback defines the method to call once ready to upload
  47296. */
  47297. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  47298. }
  47299. }
  47300. declare module BABYLON {
  47301. /**
  47302. * Internal interface used to track InternalTexture already bound to the GL context
  47303. */
  47304. interface IInternalTextureTracker {
  47305. /**
  47306. * Gets or set the previous tracker in the list
  47307. */
  47308. previous: Nullable<IInternalTextureTracker>;
  47309. /**
  47310. * Gets or set the next tracker in the list
  47311. */
  47312. next: Nullable<IInternalTextureTracker>;
  47313. }
  47314. /**
  47315. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  47316. */
  47317. class DummyInternalTextureTracker {
  47318. /**
  47319. * Gets or set the previous tracker in the list
  47320. */
  47321. previous: Nullable<IInternalTextureTracker>;
  47322. /**
  47323. * Gets or set the next tracker in the list
  47324. */
  47325. next: Nullable<IInternalTextureTracker>;
  47326. }
  47327. }
  47328. declare module BABYLON {
  47329. /**
  47330. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47331. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47332. * You can then easily use it as a reflectionTexture on a flat surface.
  47333. * In case the surface is not a plane, please consider relying on reflection probes.
  47334. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47335. */
  47336. class MirrorTexture extends RenderTargetTexture {
  47337. private scene;
  47338. /**
  47339. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  47340. * 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.
  47341. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47342. */
  47343. mirrorPlane: Plane;
  47344. /**
  47345. * Define the blur ratio used to blur the reflection if needed.
  47346. */
  47347. blurRatio: number;
  47348. /**
  47349. * Define the adaptive blur kernel used to blur the reflection if needed.
  47350. * This will autocompute the closest best match for the `blurKernel`
  47351. */
  47352. adaptiveBlurKernel: number;
  47353. /**
  47354. * Define the blur kernel used to blur the reflection if needed.
  47355. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47356. */
  47357. blurKernel: number;
  47358. /**
  47359. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  47360. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47361. */
  47362. blurKernelX: number;
  47363. /**
  47364. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  47365. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47366. */
  47367. blurKernelY: number;
  47368. private _autoComputeBlurKernel;
  47369. protected _onRatioRescale(): void;
  47370. private _updateGammaSpace;
  47371. private _imageProcessingConfigChangeObserver;
  47372. private _transformMatrix;
  47373. private _mirrorMatrix;
  47374. private _savedViewMatrix;
  47375. private _blurX;
  47376. private _blurY;
  47377. private _adaptiveBlurKernel;
  47378. private _blurKernelX;
  47379. private _blurKernelY;
  47380. private _blurRatio;
  47381. /**
  47382. * Instantiates a Mirror Texture.
  47383. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47384. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47385. * You can then easily use it as a reflectionTexture on a flat surface.
  47386. * In case the surface is not a plane, please consider relying on reflection probes.
  47387. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47388. * @param name
  47389. * @param size
  47390. * @param scene
  47391. * @param generateMipMaps
  47392. * @param type
  47393. * @param samplingMode
  47394. * @param generateDepthBuffer
  47395. */
  47396. constructor(name: string, size: number | {
  47397. width: number;
  47398. height: number;
  47399. } | {
  47400. ratio: number;
  47401. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  47402. private _preparePostProcesses;
  47403. /**
  47404. * Clone the mirror texture.
  47405. * @returns the cloned texture
  47406. */
  47407. clone(): MirrorTexture;
  47408. /**
  47409. * Serialize the texture to a JSON representation you could use in Parse later on
  47410. * @returns the serialized JSON representation
  47411. */
  47412. serialize(): any;
  47413. /**
  47414. * Dispose the texture and release its associated resources.
  47415. */
  47416. dispose(): void;
  47417. }
  47418. }
  47419. declare module BABYLON {
  47420. /**
  47421. * Creation options of the multi render target texture.
  47422. */
  47423. interface IMultiRenderTargetOptions {
  47424. /**
  47425. * Define if the texture needs to create mip maps after render.
  47426. */
  47427. generateMipMaps?: boolean;
  47428. /**
  47429. * Define the types of all the draw buffers we want to create
  47430. */
  47431. types?: number[];
  47432. /**
  47433. * Define the sampling modes of all the draw buffers we want to create
  47434. */
  47435. samplingModes?: number[];
  47436. /**
  47437. * Define if a depth buffer is required
  47438. */
  47439. generateDepthBuffer?: boolean;
  47440. /**
  47441. * Define if a stencil buffer is required
  47442. */
  47443. generateStencilBuffer?: boolean;
  47444. /**
  47445. * Define if a depth texture is required instead of a depth buffer
  47446. */
  47447. generateDepthTexture?: boolean;
  47448. /**
  47449. * Define the number of desired draw buffers
  47450. */
  47451. textureCount?: number;
  47452. /**
  47453. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47454. */
  47455. doNotChangeAspectRatio?: boolean;
  47456. /**
  47457. * Define the default type of the buffers we are creating
  47458. */
  47459. defaultType?: number;
  47460. }
  47461. /**
  47462. * A multi render target, like a render target provides the ability to render to a texture.
  47463. * Unlike the render target, it can render to several draw buffers in one draw.
  47464. * This is specially interesting in deferred rendering or for any effects requiring more than
  47465. * just one color from a single pass.
  47466. */
  47467. class MultiRenderTarget extends RenderTargetTexture {
  47468. private _internalTextures;
  47469. private _textures;
  47470. private _multiRenderTargetOptions;
  47471. /**
  47472. * Get if draw buffers are currently supported by the used hardware and browser.
  47473. */
  47474. readonly isSupported: boolean;
  47475. /**
  47476. * Get the list of textures generated by the multi render target.
  47477. */
  47478. readonly textures: Texture[];
  47479. /**
  47480. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47481. */
  47482. readonly depthTexture: Texture;
  47483. /**
  47484. * Set the wrapping mode on U of all the textures we are rendering to.
  47485. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47486. */
  47487. wrapU: number;
  47488. /**
  47489. * Set the wrapping mode on V of all the textures we are rendering to.
  47490. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47491. */
  47492. wrapV: number;
  47493. /**
  47494. * Instantiate a new multi render target texture.
  47495. * A multi render target, like a render target provides the ability to render to a texture.
  47496. * Unlike the render target, it can render to several draw buffers in one draw.
  47497. * This is specially interesting in deferred rendering or for any effects requiring more than
  47498. * just one color from a single pass.
  47499. * @param name Define the name of the texture
  47500. * @param size Define the size of the buffers to render to
  47501. * @param count Define the number of target we are rendering into
  47502. * @param scene Define the scene the texture belongs to
  47503. * @param options Define the options used to create the multi render target
  47504. */
  47505. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47506. /** @hidden */
  47507. _rebuild(): void;
  47508. private _createInternalTextures;
  47509. private _createTextures;
  47510. /**
  47511. * Define the number of samples used if MSAA is enabled.
  47512. */
  47513. samples: number;
  47514. /**
  47515. * Resize all the textures in the multi render target.
  47516. * Be carrefull as it will recreate all the data in the new texture.
  47517. * @param size Define the new size
  47518. */
  47519. resize(size: any): void;
  47520. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47521. /**
  47522. * Dispose the render targets and their associated resources
  47523. */
  47524. dispose(): void;
  47525. /**
  47526. * Release all the underlying texture used as draw buffers.
  47527. */
  47528. releaseInternalTextures(): void;
  47529. }
  47530. }
  47531. declare module BABYLON {
  47532. /**
  47533. * Raw cube texture where the raw buffers are passed in
  47534. */
  47535. class RawCubeTexture extends CubeTexture {
  47536. /**
  47537. * Creates a cube texture where the raw buffers are passed in.
  47538. * @param scene defines the scene the texture is attached to
  47539. * @param data defines the array of data to use to create each face
  47540. * @param size defines the size of the textures
  47541. * @param format defines the format of the data
  47542. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  47543. * @param generateMipMaps defines if the engine should generate the mip levels
  47544. * @param invertY defines if data must be stored with Y axis inverted
  47545. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  47546. * @param compression defines the compression used (null by default)
  47547. */
  47548. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47549. /**
  47550. * Updates the raw cube texture.
  47551. * @param data defines the data to store
  47552. * @param format defines the data format
  47553. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47554. * @param invertY defines if data must be stored with Y axis inverted
  47555. * @param compression defines the compression used (null by default)
  47556. * @param level defines which level of the texture to update
  47557. */
  47558. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47559. /**
  47560. * Updates a raw cube texture with RGBD encoded data.
  47561. * @param data defines the array of data [mipmap][face] to use to create each face
  47562. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47563. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47564. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47565. * @returns a promsie that resolves when the operation is complete
  47566. */
  47567. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47568. /**
  47569. * Clones the raw cube texture.
  47570. * @return a new cube texture
  47571. */
  47572. clone(): CubeTexture;
  47573. /** @hidden */
  47574. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47575. }
  47576. }
  47577. declare module BABYLON {
  47578. /**
  47579. * Raw texture can help creating a texture directly from an array of data.
  47580. * This can be super useful if you either get the data from an uncompressed source or
  47581. * if you wish to create your texture pixel by pixel.
  47582. */
  47583. class RawTexture extends Texture {
  47584. /**
  47585. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47586. */
  47587. format: number;
  47588. private _engine;
  47589. /**
  47590. * Instantiates a new RawTexture.
  47591. * Raw texture can help creating a texture directly from an array of data.
  47592. * This can be super useful if you either get the data from an uncompressed source or
  47593. * if you wish to create your texture pixel by pixel.
  47594. * @param data define the array of data to use to create the texture
  47595. * @param width define the width of the texture
  47596. * @param height define the height of the texture
  47597. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47598. * @param scene define the scene the texture belongs to
  47599. * @param generateMipMaps define whether mip maps should be generated or not
  47600. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47601. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47602. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47603. */
  47604. constructor(data: ArrayBufferView, width: number, height: number,
  47605. /**
  47606. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47607. */
  47608. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  47609. /**
  47610. * Updates the texture underlying data.
  47611. * @param data Define the new data of the texture
  47612. */
  47613. update(data: ArrayBufferView): void;
  47614. /**
  47615. * Creates a luminance texture from some data.
  47616. * @param data Define the texture data
  47617. * @param width Define the width of the texture
  47618. * @param height Define the height of the texture
  47619. * @param scene Define the scene the texture belongs to
  47620. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47621. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47622. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47623. * @returns the luminance texture
  47624. */
  47625. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47626. /**
  47627. * Creates a luminance alpha texture from some data.
  47628. * @param data Define the texture data
  47629. * @param width Define the width of the texture
  47630. * @param height Define the height of the texture
  47631. * @param scene Define the scene the texture belongs to
  47632. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47633. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47634. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47635. * @returns the luminance alpha texture
  47636. */
  47637. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47638. /**
  47639. * Creates an alpha texture from some data.
  47640. * @param data Define the texture data
  47641. * @param width Define the width of the texture
  47642. * @param height Define the height of the texture
  47643. * @param scene Define the scene the texture belongs to
  47644. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47645. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47646. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47647. * @returns the alpha texture
  47648. */
  47649. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47650. /**
  47651. * Creates a RGB texture from some data.
  47652. * @param data Define the texture data
  47653. * @param width Define the width of the texture
  47654. * @param height Define the height of the texture
  47655. * @param scene Define the scene the texture belongs to
  47656. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47657. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47658. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47659. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47660. * @returns the RGB alpha texture
  47661. */
  47662. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47663. /**
  47664. * Creates a RGBA texture from some data.
  47665. * @param data Define the texture data
  47666. * @param width Define the width of the texture
  47667. * @param height Define the height of the texture
  47668. * @param scene Define the scene the texture belongs to
  47669. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47670. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47671. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47672. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47673. * @returns the RGBA texture
  47674. */
  47675. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47676. /**
  47677. * Creates a R texture from some data.
  47678. * @param data Define the texture data
  47679. * @param width Define the width of the texture
  47680. * @param height Define the height of the texture
  47681. * @param scene Define the scene the texture belongs to
  47682. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47683. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47684. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47685. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47686. * @returns the R texture
  47687. */
  47688. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47689. }
  47690. }
  47691. declare module BABYLON {
  47692. /**
  47693. * Class used to store 3D textures containing user data
  47694. */
  47695. class RawTexture3D extends Texture {
  47696. /** Gets or sets the texture format to use */
  47697. format: number;
  47698. private _engine;
  47699. /**
  47700. * Create a new RawTexture3D
  47701. * @param data defines the data of the texture
  47702. * @param width defines the width of the texture
  47703. * @param height defines the height of the texture
  47704. * @param depth defines the depth of the texture
  47705. * @param format defines the texture format to use
  47706. * @param scene defines the hosting scene
  47707. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47708. * @param invertY defines if texture must be stored with Y axis inverted
  47709. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47710. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47711. */
  47712. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47713. /** Gets or sets the texture format to use */
  47714. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47715. /**
  47716. * Update the texture with new data
  47717. * @param data defines the data to store in the texture
  47718. */
  47719. update(data: ArrayBufferView): void;
  47720. }
  47721. }
  47722. declare module BABYLON {
  47723. /**
  47724. * Creates a refraction texture used by refraction channel of the standard material.
  47725. * It is like a mirror but to see through a material.
  47726. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47727. */
  47728. class RefractionTexture extends RenderTargetTexture {
  47729. /**
  47730. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47731. * 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.
  47732. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47733. */
  47734. refractionPlane: Plane;
  47735. /**
  47736. * Define how deep under the surface we should see.
  47737. */
  47738. depth: number;
  47739. /**
  47740. * Creates a refraction texture used by refraction channel of the standard material.
  47741. * It is like a mirror but to see through a material.
  47742. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47743. * @param name Define the texture name
  47744. * @param size Define the size of the underlying texture
  47745. * @param scene Define the scene the refraction belongs to
  47746. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47747. */
  47748. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47749. /**
  47750. * Clone the refraction texture.
  47751. * @returns the cloned texture
  47752. */
  47753. clone(): RefractionTexture;
  47754. /**
  47755. * Serialize the texture to a JSON representation you could use in Parse later on
  47756. * @returns the serialized JSON representation
  47757. */
  47758. serialize(): any;
  47759. }
  47760. }
  47761. declare module BABYLON {
  47762. /**
  47763. * This Helps creating a texture that will be created from a camera in your scene.
  47764. * It is basically a dynamic texture that could be used to create special effects for instance.
  47765. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47766. */
  47767. class RenderTargetTexture extends Texture {
  47768. isCube: boolean;
  47769. /**
  47770. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47771. */
  47772. static readonly REFRESHRATE_RENDER_ONCE: number;
  47773. /**
  47774. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47775. */
  47776. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47777. /**
  47778. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47779. * the central point of your effect and can save a lot of performances.
  47780. */
  47781. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47782. /**
  47783. * Use this predicate to dynamically define the list of mesh you want to render.
  47784. * If set, the renderList property will be overwritten.
  47785. */
  47786. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47787. private _renderList;
  47788. /**
  47789. * Use this list to define the list of mesh you want to render.
  47790. */
  47791. renderList: Nullable<Array<AbstractMesh>>;
  47792. private _hookArray;
  47793. /**
  47794. * Define if particles should be rendered in your texture.
  47795. */
  47796. renderParticles: boolean;
  47797. /**
  47798. * Define if sprites should be rendered in your texture.
  47799. */
  47800. renderSprites: boolean;
  47801. /**
  47802. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47803. */
  47804. coordinatesMode: number;
  47805. /**
  47806. * Define the camera used to render the texture.
  47807. */
  47808. activeCamera: Nullable<Camera>;
  47809. /**
  47810. * Override the render function of the texture with your own one.
  47811. */
  47812. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47813. /**
  47814. * Define if camera post processes should be use while rendering the texture.
  47815. */
  47816. useCameraPostProcesses: boolean;
  47817. /**
  47818. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47819. */
  47820. ignoreCameraViewport: boolean;
  47821. private _postProcessManager;
  47822. private _postProcesses;
  47823. private _resizeObserver;
  47824. /**
  47825. * An event triggered when the texture is unbind.
  47826. */
  47827. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47828. /**
  47829. * An event triggered when the texture is unbind.
  47830. */
  47831. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47832. private _onAfterUnbindObserver;
  47833. /**
  47834. * Set a after unbind callback in the texture.
  47835. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47836. */
  47837. onAfterUnbind: () => void;
  47838. /**
  47839. * An event triggered before rendering the texture
  47840. */
  47841. onBeforeRenderObservable: Observable<number>;
  47842. private _onBeforeRenderObserver;
  47843. /**
  47844. * Set a before render callback in the texture.
  47845. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47846. */
  47847. onBeforeRender: (faceIndex: number) => void;
  47848. /**
  47849. * An event triggered after rendering the texture
  47850. */
  47851. onAfterRenderObservable: Observable<number>;
  47852. private _onAfterRenderObserver;
  47853. /**
  47854. * Set a after render callback in the texture.
  47855. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47856. */
  47857. onAfterRender: (faceIndex: number) => void;
  47858. /**
  47859. * An event triggered after the texture clear
  47860. */
  47861. onClearObservable: Observable<Engine>;
  47862. private _onClearObserver;
  47863. /**
  47864. * Set a clear callback in the texture.
  47865. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47866. */
  47867. onClear: (Engine: Engine) => void;
  47868. /**
  47869. * Define the clear color of the Render Target if it should be different from the scene.
  47870. */
  47871. clearColor: Color4;
  47872. protected _size: number | {
  47873. width: number;
  47874. height: number;
  47875. };
  47876. protected _initialSizeParameter: number | {
  47877. width: number;
  47878. height: number;
  47879. } | {
  47880. ratio: number;
  47881. };
  47882. protected _sizeRatio: Nullable<number>;
  47883. /** @hidden */
  47884. _generateMipMaps: boolean;
  47885. protected _renderingManager: RenderingManager;
  47886. /** @hidden */
  47887. _waitingRenderList: string[];
  47888. protected _doNotChangeAspectRatio: boolean;
  47889. protected _currentRefreshId: number;
  47890. protected _refreshRate: number;
  47891. protected _textureMatrix: Matrix;
  47892. protected _samples: number;
  47893. protected _renderTargetOptions: RenderTargetCreationOptions;
  47894. /**
  47895. * Gets render target creation options that were used.
  47896. */
  47897. readonly renderTargetOptions: RenderTargetCreationOptions;
  47898. protected _engine: Engine;
  47899. protected _onRatioRescale(): void;
  47900. /**
  47901. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  47902. * It must define where the camera used to render the texture is set
  47903. */
  47904. boundingBoxPosition: Vector3;
  47905. private _boundingBoxSize;
  47906. /**
  47907. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  47908. * When defined, the cubemap will switch to local mode
  47909. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47910. * @example https://www.babylonjs-playground.com/#RNASML
  47911. */
  47912. boundingBoxSize: Vector3;
  47913. /**
  47914. * In case the RTT has been created with a depth texture, get the associated
  47915. * depth texture.
  47916. * Otherwise, return null.
  47917. */
  47918. depthStencilTexture: Nullable<InternalTexture>;
  47919. /**
  47920. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  47921. * or used a shadow, depth texture...
  47922. * @param name The friendly name of the texture
  47923. * @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)
  47924. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  47925. * @param generateMipMaps True if mip maps need to be generated after render.
  47926. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  47927. * @param type The type of the buffer in the RTT (int, half float, float...)
  47928. * @param isCube True if a cube texture needs to be created
  47929. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  47930. * @param generateDepthBuffer True to generate a depth buffer
  47931. * @param generateStencilBuffer True to generate a stencil buffer
  47932. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  47933. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  47934. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47935. */
  47936. constructor(name: string, size: number | {
  47937. width: number;
  47938. height: number;
  47939. } | {
  47940. ratio: number;
  47941. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  47942. /**
  47943. * Creates a depth stencil texture.
  47944. * This is only available in WebGL 2 or with the depth texture extension available.
  47945. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  47946. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  47947. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  47948. */
  47949. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  47950. private _processSizeParameter;
  47951. /**
  47952. * Define the number of samples to use in case of MSAA.
  47953. * It defaults to one meaning no MSAA has been enabled.
  47954. */
  47955. samples: number;
  47956. /**
  47957. * Resets the refresh counter of the texture and start bak from scratch.
  47958. * Could be useful to regenerate the texture if it is setup to render only once.
  47959. */
  47960. resetRefreshCounter(): void;
  47961. /**
  47962. * Define the refresh rate of the texture or the rendering frequency.
  47963. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  47964. */
  47965. refreshRate: number;
  47966. /**
  47967. * Adds a post process to the render target rendering passes.
  47968. * @param postProcess define the post process to add
  47969. */
  47970. addPostProcess(postProcess: PostProcess): void;
  47971. /**
  47972. * Clear all the post processes attached to the render target
  47973. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  47974. */
  47975. clearPostProcesses(dispose?: boolean): void;
  47976. /**
  47977. * Remove one of the post process from the list of attached post processes to the texture
  47978. * @param postProcess define the post process to remove from the list
  47979. */
  47980. removePostProcess(postProcess: PostProcess): void;
  47981. /** @hidden */
  47982. _shouldRender(): boolean;
  47983. /**
  47984. * Gets the actual render size of the texture.
  47985. * @returns the width of the render size
  47986. */
  47987. getRenderSize(): number;
  47988. /**
  47989. * Gets the actual render width of the texture.
  47990. * @returns the width of the render size
  47991. */
  47992. getRenderWidth(): number;
  47993. /**
  47994. * Gets the actual render height of the texture.
  47995. * @returns the height of the render size
  47996. */
  47997. getRenderHeight(): number;
  47998. /**
  47999. * Get if the texture can be rescaled or not.
  48000. */
  48001. readonly canRescale: boolean;
  48002. /**
  48003. * Resize the texture using a ratio.
  48004. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  48005. */
  48006. scale(ratio: number): void;
  48007. /**
  48008. * Get the texture reflection matrix used to rotate/transform the reflection.
  48009. * @returns the reflection matrix
  48010. */
  48011. getReflectionTextureMatrix(): Matrix;
  48012. /**
  48013. * Resize the texture to a new desired size.
  48014. * Be carrefull as it will recreate all the data in the new texture.
  48015. * @param size Define the new size. It can be:
  48016. * - a number for squared texture,
  48017. * - an object containing { width: number, height: number }
  48018. * - or an object containing a ratio { ratio: number }
  48019. */
  48020. resize(size: number | {
  48021. width: number;
  48022. height: number;
  48023. } | {
  48024. ratio: number;
  48025. }): void;
  48026. /**
  48027. * Renders all the objects from the render list into the texture.
  48028. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  48029. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  48030. */
  48031. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  48032. private _bestReflectionRenderTargetDimension;
  48033. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48034. private renderToTarget;
  48035. /**
  48036. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48037. * This allowed control for front to back rendering or reversly depending of the special needs.
  48038. *
  48039. * @param renderingGroupId The rendering group id corresponding to its index
  48040. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48041. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48042. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48043. */
  48044. 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;
  48045. /**
  48046. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48047. *
  48048. * @param renderingGroupId The rendering group id corresponding to its index
  48049. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48050. */
  48051. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48052. /**
  48053. * Clones the texture.
  48054. * @returns the cloned texture
  48055. */
  48056. clone(): RenderTargetTexture;
  48057. /**
  48058. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48059. * @returns The JSON representation of the texture
  48060. */
  48061. serialize(): any;
  48062. /**
  48063. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  48064. */
  48065. disposeFramebufferObjects(): void;
  48066. /**
  48067. * Dispose the texture and release its associated resources.
  48068. */
  48069. dispose(): void;
  48070. /** @hidden */
  48071. _rebuild(): void;
  48072. /**
  48073. * Clear the info related to rendering groups preventing retention point in material dispose.
  48074. */
  48075. freeRenderingGroups(): void;
  48076. }
  48077. }
  48078. declare module BABYLON {
  48079. /**
  48080. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48081. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48082. */
  48083. class Texture extends BaseTexture {
  48084. /** nearest is mag = nearest and min = nearest and mip = linear */
  48085. static readonly NEAREST_SAMPLINGMODE: number;
  48086. /** nearest is mag = nearest and min = nearest and mip = linear */
  48087. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  48088. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48089. static readonly BILINEAR_SAMPLINGMODE: number;
  48090. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48091. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  48092. /** Trilinear is mag = linear and min = linear and mip = linear */
  48093. static readonly TRILINEAR_SAMPLINGMODE: number;
  48094. /** Trilinear is mag = linear and min = linear and mip = linear */
  48095. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  48096. /** mag = nearest and min = nearest and mip = nearest */
  48097. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  48098. /** mag = nearest and min = linear and mip = nearest */
  48099. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  48100. /** mag = nearest and min = linear and mip = linear */
  48101. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  48102. /** mag = nearest and min = linear and mip = none */
  48103. static readonly NEAREST_LINEAR: number;
  48104. /** mag = nearest and min = nearest and mip = none */
  48105. static readonly NEAREST_NEAREST: number;
  48106. /** mag = linear and min = nearest and mip = nearest */
  48107. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  48108. /** mag = linear and min = nearest and mip = linear */
  48109. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  48110. /** mag = linear and min = linear and mip = none */
  48111. static readonly LINEAR_LINEAR: number;
  48112. /** mag = linear and min = nearest and mip = none */
  48113. static readonly LINEAR_NEAREST: number;
  48114. /** Explicit coordinates mode */
  48115. static readonly EXPLICIT_MODE: number;
  48116. /** Spherical coordinates mode */
  48117. static readonly SPHERICAL_MODE: number;
  48118. /** Planar coordinates mode */
  48119. static readonly PLANAR_MODE: number;
  48120. /** Cubic coordinates mode */
  48121. static readonly CUBIC_MODE: number;
  48122. /** Projection coordinates mode */
  48123. static readonly PROJECTION_MODE: number;
  48124. /** Inverse Cubic coordinates mode */
  48125. static readonly SKYBOX_MODE: number;
  48126. /** Inverse Cubic coordinates mode */
  48127. static readonly INVCUBIC_MODE: number;
  48128. /** Equirectangular coordinates mode */
  48129. static readonly EQUIRECTANGULAR_MODE: number;
  48130. /** Equirectangular Fixed coordinates mode */
  48131. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  48132. /** Equirectangular Fixed Mirrored coordinates mode */
  48133. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  48134. /** Texture is not repeating outside of 0..1 UVs */
  48135. static readonly CLAMP_ADDRESSMODE: number;
  48136. /** Texture is repeating outside of 0..1 UVs */
  48137. static readonly WRAP_ADDRESSMODE: number;
  48138. /** Texture is repeating and mirrored */
  48139. static readonly MIRROR_ADDRESSMODE: number;
  48140. /**
  48141. * 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
  48142. */
  48143. static UseSerializedUrlIfAny: boolean;
  48144. /**
  48145. * Define the url of the texture.
  48146. */
  48147. url: Nullable<string>;
  48148. /**
  48149. * Define an offset on the texture to offset the u coordinates of the UVs
  48150. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48151. */
  48152. uOffset: number;
  48153. /**
  48154. * Define an offset on the texture to offset the v coordinates of the UVs
  48155. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48156. */
  48157. vOffset: number;
  48158. /**
  48159. * Define an offset on the texture to scale the u coordinates of the UVs
  48160. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48161. */
  48162. uScale: number;
  48163. /**
  48164. * Define an offset on the texture to scale the v coordinates of the UVs
  48165. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48166. */
  48167. vScale: number;
  48168. /**
  48169. * Define an offset on the texture to rotate around the u coordinates of the UVs
  48170. * @see http://doc.babylonjs.com/how_to/more_materials
  48171. */
  48172. uAng: number;
  48173. /**
  48174. * Define an offset on the texture to rotate around the v coordinates of the UVs
  48175. * @see http://doc.babylonjs.com/how_to/more_materials
  48176. */
  48177. vAng: number;
  48178. /**
  48179. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  48180. * @see http://doc.babylonjs.com/how_to/more_materials
  48181. */
  48182. wAng: number;
  48183. /**
  48184. * Defines the center of rotation (U)
  48185. */
  48186. uRotationCenter: number;
  48187. /**
  48188. * Defines the center of rotation (V)
  48189. */
  48190. vRotationCenter: number;
  48191. /**
  48192. * Defines the center of rotation (W)
  48193. */
  48194. wRotationCenter: number;
  48195. /**
  48196. * Are mip maps generated for this texture or not.
  48197. */
  48198. readonly noMipmap: boolean;
  48199. private _noMipmap;
  48200. /** @hidden */
  48201. _invertY: boolean;
  48202. private _rowGenerationMatrix;
  48203. private _cachedTextureMatrix;
  48204. private _projectionModeMatrix;
  48205. private _t0;
  48206. private _t1;
  48207. private _t2;
  48208. private _cachedUOffset;
  48209. private _cachedVOffset;
  48210. private _cachedUScale;
  48211. private _cachedVScale;
  48212. private _cachedUAng;
  48213. private _cachedVAng;
  48214. private _cachedWAng;
  48215. private _cachedProjectionMatrixId;
  48216. private _cachedCoordinatesMode;
  48217. /** @hidden */
  48218. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  48219. private _deleteBuffer;
  48220. protected _format: Nullable<number>;
  48221. private _delayedOnLoad;
  48222. private _delayedOnError;
  48223. /**
  48224. * Observable triggered once the texture has been loaded.
  48225. */
  48226. onLoadObservable: Observable<Texture>;
  48227. protected _isBlocking: boolean;
  48228. /**
  48229. * Is the texture preventing material to render while loading.
  48230. * If false, a default texture will be used instead of the loading one during the preparation step.
  48231. */
  48232. isBlocking: boolean;
  48233. /**
  48234. * Get the current sampling mode associated with the texture.
  48235. */
  48236. readonly samplingMode: number;
  48237. /**
  48238. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  48239. */
  48240. readonly invertY: boolean;
  48241. /**
  48242. * Instantiates a new texture.
  48243. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48244. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48245. * @param url define the url of the picture to load as a texture
  48246. * @param scene define the scene the texture will belong to
  48247. * @param noMipmap define if the texture will require mip maps or not
  48248. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48249. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48250. * @param onLoad define a callback triggered when the texture has been loaded
  48251. * @param onError define a callback triggered when an error occurred during the loading session
  48252. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48253. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48254. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48255. */
  48256. 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);
  48257. /**
  48258. * Update the url (and optional buffer) of this texture if url was null during construction.
  48259. * @param url the url of the texture
  48260. * @param buffer the buffer of the texture (defaults to null)
  48261. * @param onLoad callback called when the texture is loaded (defaults to null)
  48262. */
  48263. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  48264. /**
  48265. * Finish the loading sequence of a texture flagged as delayed load.
  48266. * @hidden
  48267. */
  48268. delayLoad(): void;
  48269. private _prepareRowForTextureGeneration;
  48270. /**
  48271. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  48272. * @returns the transform matrix of the texture.
  48273. */
  48274. getTextureMatrix(): Matrix;
  48275. /**
  48276. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  48277. * @returns The reflection texture transform
  48278. */
  48279. getReflectionTextureMatrix(): Matrix;
  48280. /**
  48281. * Clones the texture.
  48282. * @returns the cloned texture
  48283. */
  48284. clone(): Texture;
  48285. /**
  48286. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48287. * @returns The JSON representation of the texture
  48288. */
  48289. serialize(): any;
  48290. /**
  48291. * Get the current class name of the texture useful for serialization or dynamic coding.
  48292. * @returns "Texture"
  48293. */
  48294. getClassName(): string;
  48295. /**
  48296. * Dispose the texture and release its associated resources.
  48297. */
  48298. dispose(): void;
  48299. /**
  48300. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  48301. * @param parsedTexture Define the JSON representation of the texture
  48302. * @param scene Define the scene the parsed texture should be instantiated in
  48303. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48304. * @returns The parsed texture if successful
  48305. */
  48306. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  48307. /**
  48308. * Creates a texture from its base 64 representation.
  48309. * @param data Define the base64 payload without the data: prefix
  48310. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48311. * @param scene Define the scene the texture should belong to
  48312. * @param noMipmap Forces the texture to not create mip map information if true
  48313. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48314. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48315. * @param onLoad define a callback triggered when the texture has been loaded
  48316. * @param onError define a callback triggered when an error occurred during the loading session
  48317. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48318. * @returns the created texture
  48319. */
  48320. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  48321. /**
  48322. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  48323. * @param data Define the base64 payload without the data: prefix
  48324. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48325. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48326. * @param scene Define the scene the texture should belong to
  48327. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48328. * @param noMipmap Forces the texture to not create mip map information if true
  48329. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48330. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48331. * @param onLoad define a callback triggered when the texture has been loaded
  48332. * @param onError define a callback triggered when an error occurred during the loading session
  48333. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48334. * @returns the created texture
  48335. */
  48336. 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;
  48337. }
  48338. }
  48339. declare module BABYLON {
  48340. /**
  48341. * Settings for finer control over video usage
  48342. */
  48343. interface VideoTextureSettings {
  48344. /**
  48345. * Applies `autoplay` to video, if specified
  48346. */
  48347. autoPlay?: boolean;
  48348. /**
  48349. * Applies `loop` to video, if specified
  48350. */
  48351. loop?: boolean;
  48352. /**
  48353. * Automatically updates internal texture from video at every frame in the render loop
  48354. */
  48355. autoUpdateTexture: boolean;
  48356. /**
  48357. * Image src displayed during the video loading or until the user interacts with the video.
  48358. */
  48359. poster?: string;
  48360. }
  48361. /**
  48362. * If you want to display a video in your scene, this is the special texture for that.
  48363. * This special texture works similar to other textures, with the exception of a few parameters.
  48364. * @see https://doc.babylonjs.com/how_to/video_texture
  48365. */
  48366. class VideoTexture extends Texture {
  48367. /**
  48368. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  48369. */
  48370. readonly autoUpdateTexture: boolean;
  48371. /**
  48372. * The video instance used by the texture internally
  48373. */
  48374. readonly video: HTMLVideoElement;
  48375. private _onUserActionRequestedObservable;
  48376. /**
  48377. * Event triggerd when a dom action is required by the user to play the video.
  48378. * This happens due to recent changes in browser policies preventing video to auto start.
  48379. */
  48380. readonly onUserActionRequestedObservable: Observable<Texture>;
  48381. private _generateMipMaps;
  48382. private _engine;
  48383. private _stillImageCaptured;
  48384. private _displayingPosterTexture;
  48385. private _settings;
  48386. private _createInternalTextureOnEvent;
  48387. /**
  48388. * Creates a video texture.
  48389. * If you want to display a video in your scene, this is the special texture for that.
  48390. * This special texture works similar to other textures, with the exception of a few parameters.
  48391. * @see https://doc.babylonjs.com/how_to/video_texture
  48392. * @param name optional name, will detect from video source, if not defined
  48393. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  48394. * @param scene is obviously the current scene.
  48395. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  48396. * @param invertY is false by default but can be used to invert video on Y axis
  48397. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  48398. * @param settings allows finer control over video usage
  48399. */
  48400. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  48401. private _getName;
  48402. private _getVideo;
  48403. private _createInternalTexture;
  48404. private reset;
  48405. /**
  48406. * @hidden Internal method to initiate `update`.
  48407. */
  48408. _rebuild(): void;
  48409. /**
  48410. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  48411. */
  48412. update(): void;
  48413. /**
  48414. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  48415. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  48416. */
  48417. updateTexture(isVisible: boolean): void;
  48418. protected _updateInternalTexture: (e?: Event | undefined) => void;
  48419. /**
  48420. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  48421. * @param url New url.
  48422. */
  48423. updateURL(url: string): void;
  48424. /**
  48425. * Dispose the texture and release its associated resources.
  48426. */
  48427. dispose(): void;
  48428. /**
  48429. * Creates a video texture straight from your WebCam video feed.
  48430. * @param scene Define the scene the texture should be created in
  48431. * @param onReady Define a callback to triggered once the texture will be ready
  48432. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  48433. */
  48434. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  48435. minWidth: number;
  48436. maxWidth: number;
  48437. minHeight: number;
  48438. maxHeight: number;
  48439. deviceId: string;
  48440. }): void;
  48441. }
  48442. }
  48443. declare var DracoDecoderModule: any;
  48444. declare var WebAssembly: any;
  48445. declare module BABYLON {
  48446. /**
  48447. * Configuration for Draco compression
  48448. */
  48449. interface IDracoCompressionConfiguration {
  48450. /**
  48451. * Configuration for the decoder.
  48452. */
  48453. decoder?: {
  48454. /**
  48455. * The url to the WebAssembly module.
  48456. */
  48457. wasmUrl?: string;
  48458. /**
  48459. * The url to the WebAssembly binary.
  48460. */
  48461. wasmBinaryUrl?: string;
  48462. /**
  48463. * The url to the fallback JavaScript module.
  48464. */
  48465. fallbackUrl?: string;
  48466. };
  48467. }
  48468. /**
  48469. * Draco compression (https://google.github.io/draco/)
  48470. *
  48471. * This class wraps the Draco module.
  48472. *
  48473. * **Encoder**
  48474. *
  48475. * The encoder is not currently implemented.
  48476. *
  48477. * **Decoder**
  48478. *
  48479. * 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.
  48480. *
  48481. * To update the configuration, use the following code:
  48482. * ```javascript
  48483. * BABYLON.DracoCompression.Configuration = {
  48484. * decoder: {
  48485. * wasmUrl: "<url to the WebAssembly library>",
  48486. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48487. * fallbackUrl: "<url to the fallback JavaScript library>",
  48488. * }
  48489. * };
  48490. * ```
  48491. *
  48492. * 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.
  48493. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48494. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48495. *
  48496. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48497. * ```javascript
  48498. * var dracoCompression = new BABYLON.DracoCompression();
  48499. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48500. * [BABYLON.VertexBuffer.PositionKind]: 0
  48501. * });
  48502. * ```
  48503. *
  48504. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48505. */
  48506. class DracoCompression implements IDisposable {
  48507. private static _DecoderModulePromise;
  48508. /**
  48509. * The configuration. Defaults to the following urls:
  48510. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48511. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48512. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48513. */
  48514. static Configuration: IDracoCompressionConfiguration;
  48515. /**
  48516. * Returns true if the decoder is available.
  48517. */
  48518. static readonly DecoderAvailable: boolean;
  48519. /**
  48520. * Constructor
  48521. */
  48522. constructor();
  48523. /**
  48524. * Stop all async operations and release resources.
  48525. */
  48526. dispose(): void;
  48527. /**
  48528. * Decode Draco compressed mesh data to vertex data.
  48529. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48530. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48531. * @returns A promise that resolves with the decoded vertex data
  48532. */
  48533. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48534. [kind: string]: number;
  48535. }): Promise<VertexData>;
  48536. private static _GetDecoderModule;
  48537. private static _LoadScriptAsync;
  48538. private static _LoadFileAsync;
  48539. }
  48540. }
  48541. declare module BABYLON {
  48542. /**
  48543. * Particle emitter emitting particles from the inside of a box.
  48544. * It emits the particles randomly between 2 given directions.
  48545. */
  48546. class BoxParticleEmitter implements IParticleEmitterType {
  48547. /**
  48548. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48549. */
  48550. direction1: Vector3;
  48551. /**
  48552. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48553. */
  48554. direction2: Vector3;
  48555. /**
  48556. * 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.
  48557. */
  48558. minEmitBox: Vector3;
  48559. /**
  48560. * 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.
  48561. */
  48562. maxEmitBox: Vector3;
  48563. /**
  48564. * Creates a new instance BoxParticleEmitter
  48565. */
  48566. constructor();
  48567. /**
  48568. * Called by the particle System when the direction is computed for the created particle.
  48569. * @param worldMatrix is the world matrix of the particle system
  48570. * @param directionToUpdate is the direction vector to update with the result
  48571. * @param particle is the particle we are computed the direction for
  48572. */
  48573. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48574. /**
  48575. * Called by the particle System when the position is computed for the created particle.
  48576. * @param worldMatrix is the world matrix of the particle system
  48577. * @param positionToUpdate is the position vector to update with the result
  48578. * @param particle is the particle we are computed the position for
  48579. */
  48580. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48581. /**
  48582. * Clones the current emitter and returns a copy of it
  48583. * @returns the new emitter
  48584. */
  48585. clone(): BoxParticleEmitter;
  48586. /**
  48587. * Called by the GPUParticleSystem to setup the update shader
  48588. * @param effect defines the update shader
  48589. */
  48590. applyToShader(effect: Effect): void;
  48591. /**
  48592. * Returns a string to use to update the GPU particles update shader
  48593. * @returns a string containng the defines string
  48594. */
  48595. getEffectDefines(): string;
  48596. /**
  48597. * Returns the string "BoxParticleEmitter"
  48598. * @returns a string containing the class name
  48599. */
  48600. getClassName(): string;
  48601. /**
  48602. * Serializes the particle system to a JSON object.
  48603. * @returns the JSON object
  48604. */
  48605. serialize(): any;
  48606. /**
  48607. * Parse properties from a JSON object
  48608. * @param serializationObject defines the JSON object
  48609. */
  48610. parse(serializationObject: any): void;
  48611. }
  48612. }
  48613. declare module BABYLON {
  48614. /**
  48615. * Particle emitter emitting particles from the inside of a cone.
  48616. * It emits the particles alongside the cone volume from the base to the particle.
  48617. * The emission direction might be randomized.
  48618. */
  48619. class ConeParticleEmitter implements IParticleEmitterType {
  48620. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48621. directionRandomizer: number;
  48622. private _radius;
  48623. private _angle;
  48624. private _height;
  48625. /**
  48626. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  48627. */
  48628. radiusRange: number;
  48629. /**
  48630. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  48631. */
  48632. heightRange: number;
  48633. /**
  48634. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  48635. */
  48636. emitFromSpawnPointOnly: boolean;
  48637. /**
  48638. * Gets or sets the radius of the emission cone
  48639. */
  48640. radius: number;
  48641. /**
  48642. * Gets or sets the angle of the emission cone
  48643. */
  48644. angle: number;
  48645. private _buildHeight;
  48646. /**
  48647. * Creates a new instance ConeParticleEmitter
  48648. * @param radius the radius of the emission cone (1 by default)
  48649. * @param angles the cone base angle (PI by default)
  48650. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  48651. */
  48652. constructor(radius?: number, angle?: number,
  48653. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48654. directionRandomizer?: number);
  48655. /**
  48656. * Called by the particle System when the direction is computed for the created particle.
  48657. * @param worldMatrix is the world matrix of the particle system
  48658. * @param directionToUpdate is the direction vector to update with the result
  48659. * @param particle is the particle we are computed the direction for
  48660. */
  48661. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48662. /**
  48663. * Called by the particle System when the position is computed for the created particle.
  48664. * @param worldMatrix is the world matrix of the particle system
  48665. * @param positionToUpdate is the position vector to update with the result
  48666. * @param particle is the particle we are computed the position for
  48667. */
  48668. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48669. /**
  48670. * Clones the current emitter and returns a copy of it
  48671. * @returns the new emitter
  48672. */
  48673. clone(): ConeParticleEmitter;
  48674. /**
  48675. * Called by the GPUParticleSystem to setup the update shader
  48676. * @param effect defines the update shader
  48677. */
  48678. applyToShader(effect: Effect): void;
  48679. /**
  48680. * Returns a string to use to update the GPU particles update shader
  48681. * @returns a string containng the defines string
  48682. */
  48683. getEffectDefines(): string;
  48684. /**
  48685. * Returns the string "ConeParticleEmitter"
  48686. * @returns a string containing the class name
  48687. */
  48688. getClassName(): string;
  48689. /**
  48690. * Serializes the particle system to a JSON object.
  48691. * @returns the JSON object
  48692. */
  48693. serialize(): any;
  48694. /**
  48695. * Parse properties from a JSON object
  48696. * @param serializationObject defines the JSON object
  48697. */
  48698. parse(serializationObject: any): void;
  48699. }
  48700. }
  48701. declare module BABYLON {
  48702. /**
  48703. * Particle emitter emitting particles from the inside of a cylinder.
  48704. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  48705. */
  48706. class CylinderParticleEmitter implements IParticleEmitterType {
  48707. /**
  48708. * The radius of the emission cylinder.
  48709. */
  48710. radius: number;
  48711. /**
  48712. * The height of the emission cylinder.
  48713. */
  48714. height: number;
  48715. /**
  48716. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48717. */
  48718. radiusRange: number;
  48719. /**
  48720. * How much to randomize the particle direction [0-1].
  48721. */
  48722. directionRandomizer: number;
  48723. /**
  48724. * Creates a new instance CylinderParticleEmitter
  48725. * @param radius the radius of the emission cylinder (1 by default)
  48726. * @param height the height of the emission cylinder (1 by default)
  48727. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48728. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48729. */
  48730. constructor(
  48731. /**
  48732. * The radius of the emission cylinder.
  48733. */
  48734. radius?: number,
  48735. /**
  48736. * The height of the emission cylinder.
  48737. */
  48738. height?: number,
  48739. /**
  48740. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48741. */
  48742. radiusRange?: number,
  48743. /**
  48744. * How much to randomize the particle direction [0-1].
  48745. */
  48746. directionRandomizer?: number);
  48747. /**
  48748. * Called by the particle System when the direction is computed for the created particle.
  48749. * @param worldMatrix is the world matrix of the particle system
  48750. * @param directionToUpdate is the direction vector to update with the result
  48751. * @param particle is the particle we are computed the direction for
  48752. */
  48753. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48754. /**
  48755. * Called by the particle System when the position is computed for the created particle.
  48756. * @param worldMatrix is the world matrix of the particle system
  48757. * @param positionToUpdate is the position vector to update with the result
  48758. * @param particle is the particle we are computed the position for
  48759. */
  48760. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48761. /**
  48762. * Clones the current emitter and returns a copy of it
  48763. * @returns the new emitter
  48764. */
  48765. clone(): CylinderParticleEmitter;
  48766. /**
  48767. * Called by the GPUParticleSystem to setup the update shader
  48768. * @param effect defines the update shader
  48769. */
  48770. applyToShader(effect: Effect): void;
  48771. /**
  48772. * Returns a string to use to update the GPU particles update shader
  48773. * @returns a string containng the defines string
  48774. */
  48775. getEffectDefines(): string;
  48776. /**
  48777. * Returns the string "CylinderParticleEmitter"
  48778. * @returns a string containing the class name
  48779. */
  48780. getClassName(): string;
  48781. /**
  48782. * Serializes the particle system to a JSON object.
  48783. * @returns the JSON object
  48784. */
  48785. serialize(): any;
  48786. /**
  48787. * Parse properties from a JSON object
  48788. * @param serializationObject defines the JSON object
  48789. */
  48790. parse(serializationObject: any): void;
  48791. }
  48792. /**
  48793. * Particle emitter emitting particles from the inside of a cylinder.
  48794. * It emits the particles randomly between two vectors.
  48795. */
  48796. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  48797. /**
  48798. * The min limit of the emission direction.
  48799. */
  48800. direction1: Vector3;
  48801. /**
  48802. * The max limit of the emission direction.
  48803. */
  48804. direction2: Vector3;
  48805. /**
  48806. * Creates a new instance CylinderDirectedParticleEmitter
  48807. * @param radius the radius of the emission cylinder (1 by default)
  48808. * @param height the height of the emission cylinder (1 by default)
  48809. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48810. * @param direction1 the min limit of the emission direction (up vector by default)
  48811. * @param direction2 the max limit of the emission direction (up vector by default)
  48812. */
  48813. constructor(radius?: number, height?: number, radiusRange?: number,
  48814. /**
  48815. * The min limit of the emission direction.
  48816. */
  48817. direction1?: Vector3,
  48818. /**
  48819. * The max limit of the emission direction.
  48820. */
  48821. direction2?: Vector3);
  48822. /**
  48823. * Called by the particle System when the direction is computed for the created particle.
  48824. * @param worldMatrix is the world matrix of the particle system
  48825. * @param directionToUpdate is the direction vector to update with the result
  48826. * @param particle is the particle we are computed the direction for
  48827. */
  48828. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48829. /**
  48830. * Clones the current emitter and returns a copy of it
  48831. * @returns the new emitter
  48832. */
  48833. clone(): CylinderDirectedParticleEmitter;
  48834. /**
  48835. * Called by the GPUParticleSystem to setup the update shader
  48836. * @param effect defines the update shader
  48837. */
  48838. applyToShader(effect: Effect): void;
  48839. /**
  48840. * Returns a string to use to update the GPU particles update shader
  48841. * @returns a string containng the defines string
  48842. */
  48843. getEffectDefines(): string;
  48844. /**
  48845. * Returns the string "CylinderDirectedParticleEmitter"
  48846. * @returns a string containing the class name
  48847. */
  48848. getClassName(): string;
  48849. /**
  48850. * Serializes the particle system to a JSON object.
  48851. * @returns the JSON object
  48852. */
  48853. serialize(): any;
  48854. /**
  48855. * Parse properties from a JSON object
  48856. * @param serializationObject defines the JSON object
  48857. */
  48858. parse(serializationObject: any): void;
  48859. }
  48860. }
  48861. declare module BABYLON {
  48862. /**
  48863. * Particle emitter emitting particles from the inside of a hemisphere.
  48864. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  48865. */
  48866. class HemisphericParticleEmitter implements IParticleEmitterType {
  48867. /**
  48868. * The radius of the emission hemisphere.
  48869. */
  48870. radius: number;
  48871. /**
  48872. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48873. */
  48874. radiusRange: number;
  48875. /**
  48876. * How much to randomize the particle direction [0-1].
  48877. */
  48878. directionRandomizer: number;
  48879. /**
  48880. * Creates a new instance HemisphericParticleEmitter
  48881. * @param radius the radius of the emission hemisphere (1 by default)
  48882. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48883. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48884. */
  48885. constructor(
  48886. /**
  48887. * The radius of the emission hemisphere.
  48888. */
  48889. radius?: number,
  48890. /**
  48891. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48892. */
  48893. radiusRange?: number,
  48894. /**
  48895. * How much to randomize the particle direction [0-1].
  48896. */
  48897. directionRandomizer?: number);
  48898. /**
  48899. * Called by the particle System when the direction is computed for the created particle.
  48900. * @param worldMatrix is the world matrix of the particle system
  48901. * @param directionToUpdate is the direction vector to update with the result
  48902. * @param particle is the particle we are computed the direction for
  48903. */
  48904. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48905. /**
  48906. * Called by the particle System when the position is computed for the created particle.
  48907. * @param worldMatrix is the world matrix of the particle system
  48908. * @param positionToUpdate is the position vector to update with the result
  48909. * @param particle is the particle we are computed the position for
  48910. */
  48911. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48912. /**
  48913. * Clones the current emitter and returns a copy of it
  48914. * @returns the new emitter
  48915. */
  48916. clone(): HemisphericParticleEmitter;
  48917. /**
  48918. * Called by the GPUParticleSystem to setup the update shader
  48919. * @param effect defines the update shader
  48920. */
  48921. applyToShader(effect: Effect): void;
  48922. /**
  48923. * Returns a string to use to update the GPU particles update shader
  48924. * @returns a string containng the defines string
  48925. */
  48926. getEffectDefines(): string;
  48927. /**
  48928. * Returns the string "HemisphericParticleEmitter"
  48929. * @returns a string containing the class name
  48930. */
  48931. getClassName(): string;
  48932. /**
  48933. * Serializes the particle system to a JSON object.
  48934. * @returns the JSON object
  48935. */
  48936. serialize(): any;
  48937. /**
  48938. * Parse properties from a JSON object
  48939. * @param serializationObject defines the JSON object
  48940. */
  48941. parse(serializationObject: any): void;
  48942. }
  48943. }
  48944. declare module BABYLON {
  48945. /**
  48946. * Particle emitter represents a volume emitting particles.
  48947. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  48948. */
  48949. interface IParticleEmitterType {
  48950. /**
  48951. * Called by the particle System when the direction is computed for the created particle.
  48952. * @param worldMatrix is the world matrix of the particle system
  48953. * @param directionToUpdate is the direction vector to update with the result
  48954. * @param particle is the particle we are computed the direction for
  48955. */
  48956. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48957. /**
  48958. * Called by the particle System when the position is computed for the created particle.
  48959. * @param worldMatrix is the world matrix of the particle system
  48960. * @param positionToUpdate is the position vector to update with the result
  48961. * @param particle is the particle we are computed the position for
  48962. */
  48963. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48964. /**
  48965. * Clones the current emitter and returns a copy of it
  48966. * @returns the new emitter
  48967. */
  48968. clone(): IParticleEmitterType;
  48969. /**
  48970. * Called by the GPUParticleSystem to setup the update shader
  48971. * @param effect defines the update shader
  48972. */
  48973. applyToShader(effect: Effect): void;
  48974. /**
  48975. * Returns a string to use to update the GPU particles update shader
  48976. * @returns the effect defines string
  48977. */
  48978. getEffectDefines(): string;
  48979. /**
  48980. * Returns a string representing the class name
  48981. * @returns a string containing the class name
  48982. */
  48983. getClassName(): string;
  48984. /**
  48985. * Serializes the particle system to a JSON object.
  48986. * @returns the JSON object
  48987. */
  48988. serialize(): any;
  48989. /**
  48990. * Parse properties from a JSON object
  48991. * @param serializationObject defines the JSON object
  48992. */
  48993. parse(serializationObject: any): void;
  48994. }
  48995. }
  48996. declare module BABYLON {
  48997. /**
  48998. * Particle emitter emitting particles from a point.
  48999. * It emits the particles randomly between 2 given directions.
  49000. */
  49001. class PointParticleEmitter implements IParticleEmitterType {
  49002. /**
  49003. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49004. */
  49005. direction1: Vector3;
  49006. /**
  49007. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49008. */
  49009. direction2: Vector3;
  49010. /**
  49011. * Creates a new instance PointParticleEmitter
  49012. */
  49013. constructor();
  49014. /**
  49015. * Called by the particle System when the direction is computed for the created particle.
  49016. * @param worldMatrix is the world matrix of the particle system
  49017. * @param directionToUpdate is the direction vector to update with the result
  49018. * @param particle is the particle we are computed the direction for
  49019. */
  49020. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49021. /**
  49022. * Called by the particle System when the position is computed for the created particle.
  49023. * @param worldMatrix is the world matrix of the particle system
  49024. * @param positionToUpdate is the position vector to update with the result
  49025. * @param particle is the particle we are computed the position for
  49026. */
  49027. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49028. /**
  49029. * Clones the current emitter and returns a copy of it
  49030. * @returns the new emitter
  49031. */
  49032. clone(): PointParticleEmitter;
  49033. /**
  49034. * Called by the GPUParticleSystem to setup the update shader
  49035. * @param effect defines the update shader
  49036. */
  49037. applyToShader(effect: Effect): void;
  49038. /**
  49039. * Returns a string to use to update the GPU particles update shader
  49040. * @returns a string containng the defines string
  49041. */
  49042. getEffectDefines(): string;
  49043. /**
  49044. * Returns the string "PointParticleEmitter"
  49045. * @returns a string containing the class name
  49046. */
  49047. getClassName(): string;
  49048. /**
  49049. * Serializes the particle system to a JSON object.
  49050. * @returns the JSON object
  49051. */
  49052. serialize(): any;
  49053. /**
  49054. * Parse properties from a JSON object
  49055. * @param serializationObject defines the JSON object
  49056. */
  49057. parse(serializationObject: any): void;
  49058. }
  49059. }
  49060. declare module BABYLON {
  49061. /**
  49062. * Particle emitter emitting particles from the inside of a sphere.
  49063. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  49064. */
  49065. class SphereParticleEmitter implements IParticleEmitterType {
  49066. /**
  49067. * The radius of the emission sphere.
  49068. */
  49069. radius: number;
  49070. /**
  49071. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49072. */
  49073. radiusRange: number;
  49074. /**
  49075. * How much to randomize the particle direction [0-1].
  49076. */
  49077. directionRandomizer: number;
  49078. /**
  49079. * Creates a new instance SphereParticleEmitter
  49080. * @param radius the radius of the emission sphere (1 by default)
  49081. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49082. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49083. */
  49084. constructor(
  49085. /**
  49086. * The radius of the emission sphere.
  49087. */
  49088. radius?: number,
  49089. /**
  49090. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49091. */
  49092. radiusRange?: number,
  49093. /**
  49094. * How much to randomize the particle direction [0-1].
  49095. */
  49096. directionRandomizer?: number);
  49097. /**
  49098. * Called by the particle System when the direction is computed for the created particle.
  49099. * @param worldMatrix is the world matrix of the particle system
  49100. * @param directionToUpdate is the direction vector to update with the result
  49101. * @param particle is the particle we are computed the direction for
  49102. */
  49103. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49104. /**
  49105. * Called by the particle System when the position is computed for the created particle.
  49106. * @param worldMatrix is the world matrix of the particle system
  49107. * @param positionToUpdate is the position vector to update with the result
  49108. * @param particle is the particle we are computed the position for
  49109. */
  49110. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49111. /**
  49112. * Clones the current emitter and returns a copy of it
  49113. * @returns the new emitter
  49114. */
  49115. clone(): SphereParticleEmitter;
  49116. /**
  49117. * Called by the GPUParticleSystem to setup the update shader
  49118. * @param effect defines the update shader
  49119. */
  49120. applyToShader(effect: Effect): void;
  49121. /**
  49122. * Returns a string to use to update the GPU particles update shader
  49123. * @returns a string containng the defines string
  49124. */
  49125. getEffectDefines(): string;
  49126. /**
  49127. * Returns the string "SphereParticleEmitter"
  49128. * @returns a string containing the class name
  49129. */
  49130. getClassName(): string;
  49131. /**
  49132. * Serializes the particle system to a JSON object.
  49133. * @returns the JSON object
  49134. */
  49135. serialize(): any;
  49136. /**
  49137. * Parse properties from a JSON object
  49138. * @param serializationObject defines the JSON object
  49139. */
  49140. parse(serializationObject: any): void;
  49141. }
  49142. /**
  49143. * Particle emitter emitting particles from the inside of a sphere.
  49144. * It emits the particles randomly between two vectors.
  49145. */
  49146. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  49147. /**
  49148. * The min limit of the emission direction.
  49149. */
  49150. direction1: Vector3;
  49151. /**
  49152. * The max limit of the emission direction.
  49153. */
  49154. direction2: Vector3;
  49155. /**
  49156. * Creates a new instance SphereDirectedParticleEmitter
  49157. * @param radius the radius of the emission sphere (1 by default)
  49158. * @param direction1 the min limit of the emission direction (up vector by default)
  49159. * @param direction2 the max limit of the emission direction (up vector by default)
  49160. */
  49161. constructor(radius?: number,
  49162. /**
  49163. * The min limit of the emission direction.
  49164. */
  49165. direction1?: Vector3,
  49166. /**
  49167. * The max limit of the emission direction.
  49168. */
  49169. direction2?: Vector3);
  49170. /**
  49171. * Called by the particle System when the direction is computed for the created particle.
  49172. * @param worldMatrix is the world matrix of the particle system
  49173. * @param directionToUpdate is the direction vector to update with the result
  49174. * @param particle is the particle we are computed the direction for
  49175. */
  49176. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49177. /**
  49178. * Clones the current emitter and returns a copy of it
  49179. * @returns the new emitter
  49180. */
  49181. clone(): SphereDirectedParticleEmitter;
  49182. /**
  49183. * Called by the GPUParticleSystem to setup the update shader
  49184. * @param effect defines the update shader
  49185. */
  49186. applyToShader(effect: Effect): void;
  49187. /**
  49188. * Returns a string to use to update the GPU particles update shader
  49189. * @returns a string containng the defines string
  49190. */
  49191. getEffectDefines(): string;
  49192. /**
  49193. * Returns the string "SphereDirectedParticleEmitter"
  49194. * @returns a string containing the class name
  49195. */
  49196. getClassName(): string;
  49197. /**
  49198. * Serializes the particle system to a JSON object.
  49199. * @returns the JSON object
  49200. */
  49201. serialize(): any;
  49202. /**
  49203. * Parse properties from a JSON object
  49204. * @param serializationObject defines the JSON object
  49205. */
  49206. parse(serializationObject: any): void;
  49207. }
  49208. }
  49209. declare module BABYLON {
  49210. /** @hidden */
  49211. class CannonJSPlugin implements IPhysicsEnginePlugin {
  49212. private _useDeltaForWorldStep;
  49213. world: any;
  49214. name: string;
  49215. private _physicsMaterials;
  49216. private _fixedTimeStep;
  49217. BJSCANNON: any;
  49218. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  49219. setGravity(gravity: Vector3): void;
  49220. setTimeStep(timeStep: number): void;
  49221. getTimeStep(): number;
  49222. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49223. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49224. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49225. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49226. private _processChildMeshes;
  49227. removePhysicsBody(impostor: PhysicsImpostor): void;
  49228. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49229. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49230. private _addMaterial;
  49231. private _checkWithEpsilon;
  49232. private _createShape;
  49233. private _createHeightmap;
  49234. private _minus90X;
  49235. private _plus90X;
  49236. private _tmpPosition;
  49237. private _tmpDeltaPosition;
  49238. private _tmpUnityRotation;
  49239. private _updatePhysicsBodyTransformation;
  49240. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49241. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49242. isSupported(): boolean;
  49243. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49244. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49245. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49246. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49247. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49248. getBodyMass(impostor: PhysicsImpostor): number;
  49249. getBodyFriction(impostor: PhysicsImpostor): number;
  49250. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49251. getBodyRestitution(impostor: PhysicsImpostor): number;
  49252. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49253. sleepBody(impostor: PhysicsImpostor): void;
  49254. wakeUpBody(impostor: PhysicsImpostor): void;
  49255. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49256. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49257. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49258. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49259. getRadius(impostor: PhysicsImpostor): number;
  49260. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49261. dispose(): void;
  49262. private _extendNamespace;
  49263. }
  49264. }
  49265. declare module BABYLON {
  49266. /** @hidden */
  49267. class OimoJSPlugin implements IPhysicsEnginePlugin {
  49268. world: any;
  49269. name: string;
  49270. BJSOIMO: any;
  49271. constructor(iterations?: number);
  49272. setGravity(gravity: Vector3): void;
  49273. setTimeStep(timeStep: number): void;
  49274. getTimeStep(): number;
  49275. private _tmpImpostorsArray;
  49276. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49277. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49278. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49279. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49280. private _tmpPositionVector;
  49281. removePhysicsBody(impostor: PhysicsImpostor): void;
  49282. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49283. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49284. isSupported(): boolean;
  49285. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49286. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49287. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49288. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49289. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49290. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49291. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49292. getBodyMass(impostor: PhysicsImpostor): number;
  49293. getBodyFriction(impostor: PhysicsImpostor): number;
  49294. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49295. getBodyRestitution(impostor: PhysicsImpostor): number;
  49296. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49297. sleepBody(impostor: PhysicsImpostor): void;
  49298. wakeUpBody(impostor: PhysicsImpostor): void;
  49299. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49300. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  49301. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49302. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49303. getRadius(impostor: PhysicsImpostor): number;
  49304. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49305. dispose(): void;
  49306. }
  49307. }
  49308. declare module BABYLON {
  49309. /**
  49310. * This represents a set of one or more post processes in Babylon.
  49311. * A post process can be used to apply a shader to a texture after it is rendered.
  49312. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49313. */
  49314. class PostProcessRenderEffect {
  49315. private _postProcesses;
  49316. private _getPostProcesses;
  49317. private _singleInstance;
  49318. private _cameras;
  49319. private _indicesForCamera;
  49320. /**
  49321. * Name of the effect
  49322. * @hidden
  49323. */
  49324. _name: string;
  49325. /**
  49326. * Instantiates a post process render effect.
  49327. * A post process can be used to apply a shader to a texture after it is rendered.
  49328. * @param engine The engine the effect is tied to
  49329. * @param name The name of the effect
  49330. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49331. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49332. */
  49333. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49334. /**
  49335. * Checks if all the post processes in the effect are supported.
  49336. */
  49337. readonly isSupported: boolean;
  49338. /**
  49339. * Updates the current state of the effect
  49340. * @hidden
  49341. */
  49342. _update(): void;
  49343. /**
  49344. * Attaches the effect on cameras
  49345. * @param cameras The camera to attach to.
  49346. * @hidden
  49347. */
  49348. _attachCameras(cameras: Camera): void;
  49349. /**
  49350. * Attaches the effect on cameras
  49351. * @param cameras The camera to attach to.
  49352. * @hidden
  49353. */
  49354. _attachCameras(cameras: Camera[]): void;
  49355. /**
  49356. * Detatches the effect on cameras
  49357. * @param cameras The camera to detatch from.
  49358. * @hidden
  49359. */
  49360. _detachCameras(cameras: Camera): void;
  49361. /**
  49362. * Detatches the effect on cameras
  49363. * @param cameras The camera to detatch from.
  49364. * @hidden
  49365. */
  49366. _detachCameras(cameras: Camera[]): void;
  49367. /**
  49368. * Enables the effect on given cameras
  49369. * @param cameras The camera to enable.
  49370. * @hidden
  49371. */
  49372. _enable(cameras: Camera): void;
  49373. /**
  49374. * Enables the effect on given cameras
  49375. * @param cameras The camera to enable.
  49376. * @hidden
  49377. */
  49378. _enable(cameras: Nullable<Camera[]>): void;
  49379. /**
  49380. * Disables the effect on the given cameras
  49381. * @param cameras The camera to disable.
  49382. * @hidden
  49383. */
  49384. _disable(cameras: Camera): void;
  49385. /**
  49386. * Disables the effect on the given cameras
  49387. * @param cameras The camera to disable.
  49388. * @hidden
  49389. */
  49390. _disable(cameras: Nullable<Camera[]>): void;
  49391. /**
  49392. * Gets a list of the post processes contained in the effect.
  49393. * @param camera The camera to get the post processes on.
  49394. * @returns The list of the post processes in the effect.
  49395. */
  49396. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49397. }
  49398. }
  49399. declare module BABYLON {
  49400. /**
  49401. * PostProcessRenderPipeline
  49402. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49403. */
  49404. class PostProcessRenderPipeline {
  49405. private engine;
  49406. private _renderEffects;
  49407. private _renderEffectsForIsolatedPass;
  49408. /**
  49409. * @hidden
  49410. */
  49411. protected _cameras: Camera[];
  49412. /** @hidden */
  49413. _name: string;
  49414. /**
  49415. * Initializes a PostProcessRenderPipeline
  49416. * @param engine engine to add the pipeline to
  49417. * @param name name of the pipeline
  49418. */
  49419. constructor(engine: Engine, name: string);
  49420. /**
  49421. * "PostProcessRenderPipeline"
  49422. * @returns "PostProcessRenderPipeline"
  49423. */
  49424. getClassName(): string;
  49425. /**
  49426. * If all the render effects in the pipeline are support
  49427. */
  49428. readonly isSupported: boolean;
  49429. /**
  49430. * Adds an effect to the pipeline
  49431. * @param renderEffect the effect to add
  49432. */
  49433. addEffect(renderEffect: PostProcessRenderEffect): void;
  49434. /** @hidden */
  49435. _rebuild(): void;
  49436. /** @hidden */
  49437. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49438. /** @hidden */
  49439. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49440. /** @hidden */
  49441. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49442. /** @hidden */
  49443. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49444. /** @hidden */
  49445. _attachCameras(cameras: Camera, unique: boolean): void;
  49446. /** @hidden */
  49447. _attachCameras(cameras: Camera[], unique: boolean): void;
  49448. /** @hidden */
  49449. _detachCameras(cameras: Camera): void;
  49450. /** @hidden */
  49451. _detachCameras(cameras: Nullable<Camera[]>): void;
  49452. /** @hidden */
  49453. _update(): void;
  49454. /** @hidden */
  49455. _reset(): void;
  49456. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49457. /**
  49458. * Disposes of the pipeline
  49459. */
  49460. dispose(): void;
  49461. }
  49462. }
  49463. declare module BABYLON {
  49464. /**
  49465. * PostProcessRenderPipelineManager class
  49466. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49467. */
  49468. class PostProcessRenderPipelineManager {
  49469. private _renderPipelines;
  49470. /**
  49471. * Initializes a PostProcessRenderPipelineManager
  49472. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49473. */
  49474. constructor();
  49475. /**
  49476. * Adds a pipeline to the manager
  49477. * @param renderPipeline The pipeline to add
  49478. */
  49479. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  49480. /**
  49481. * Attaches a camera to the pipeline
  49482. * @param renderPipelineName The name of the pipeline to attach to
  49483. * @param cameras the camera to attach
  49484. * @param unique if the camera can be attached multiple times to the pipeline
  49485. */
  49486. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  49487. /**
  49488. * Detaches a camera from the pipeline
  49489. * @param renderPipelineName The name of the pipeline to detach from
  49490. * @param cameras the camera to detach
  49491. */
  49492. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  49493. /**
  49494. * Enables an effect by name on a pipeline
  49495. * @param renderPipelineName the name of the pipeline to enable the effect in
  49496. * @param renderEffectName the name of the effect to enable
  49497. * @param cameras the cameras that the effect should be enabled on
  49498. */
  49499. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49500. /**
  49501. * Disables an effect by name on a pipeline
  49502. * @param renderPipelineName the name of the pipeline to disable the effect in
  49503. * @param renderEffectName the name of the effect to disable
  49504. * @param cameras the cameras that the effect should be disabled on
  49505. */
  49506. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49507. /**
  49508. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  49509. */
  49510. update(): void;
  49511. /** @hidden */
  49512. _rebuild(): void;
  49513. /**
  49514. * Disposes of the manager and pipelines
  49515. */
  49516. dispose(): void;
  49517. }
  49518. }
  49519. declare module BABYLON {
  49520. interface Scene {
  49521. /** @hidden (Backing field) */
  49522. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49523. /**
  49524. * Gets the postprocess render pipeline manager
  49525. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49526. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49527. */
  49528. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49529. }
  49530. /**
  49531. * Defines the Render Pipeline scene component responsible to rendering pipelines
  49532. */
  49533. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  49534. /**
  49535. * The component name helpfull to identify the component in the list of scene components.
  49536. */
  49537. readonly name: string;
  49538. /**
  49539. * The scene the component belongs to.
  49540. */
  49541. scene: Scene;
  49542. /**
  49543. * Creates a new instance of the component for the given scene
  49544. * @param scene Defines the scene to register the component in
  49545. */
  49546. constructor(scene: Scene);
  49547. /**
  49548. * Registers the component in a given scene
  49549. */
  49550. register(): void;
  49551. /**
  49552. * Rebuilds the elements related to this component in case of
  49553. * context lost for instance.
  49554. */
  49555. rebuild(): void;
  49556. /**
  49557. * Disposes the component and the associated ressources
  49558. */
  49559. dispose(): void;
  49560. private _gatherRenderTargets;
  49561. }
  49562. }
  49563. declare module BABYLON {
  49564. /**
  49565. * Helper class dealing with the extraction of spherical polynomial dataArray
  49566. * from a cube map.
  49567. */
  49568. class CubeMapToSphericalPolynomialTools {
  49569. private static FileFaces;
  49570. /**
  49571. * Converts a texture to the according Spherical Polynomial data.
  49572. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49573. *
  49574. * @param texture The texture to extract the information from.
  49575. * @return The Spherical Polynomial data.
  49576. */
  49577. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49578. /**
  49579. * Converts a cubemap to the according Spherical Polynomial data.
  49580. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49581. *
  49582. * @param cubeInfo The Cube map to extract the information from.
  49583. * @return The Spherical Polynomial data.
  49584. */
  49585. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49586. }
  49587. }
  49588. declare module BABYLON {
  49589. /**
  49590. * Header information of HDR texture files.
  49591. */
  49592. interface HDRInfo {
  49593. /**
  49594. * The height of the texture in pixels.
  49595. */
  49596. height: number;
  49597. /**
  49598. * The width of the texture in pixels.
  49599. */
  49600. width: number;
  49601. /**
  49602. * The index of the beginning of the data in the binary file.
  49603. */
  49604. dataPosition: number;
  49605. }
  49606. /**
  49607. * This groups tools to convert HDR texture to native colors array.
  49608. */
  49609. class HDRTools {
  49610. private static Ldexp;
  49611. private static Rgbe2float;
  49612. private static readStringLine;
  49613. /**
  49614. * Reads header information from an RGBE texture stored in a native array.
  49615. * More information on this format are available here:
  49616. * https://en.wikipedia.org/wiki/RGBE_image_format
  49617. *
  49618. * @param uint8array The binary file stored in native array.
  49619. * @return The header information.
  49620. */
  49621. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49622. /**
  49623. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49624. * This RGBE texture needs to store the information as a panorama.
  49625. *
  49626. * More information on this format are available here:
  49627. * https://en.wikipedia.org/wiki/RGBE_image_format
  49628. *
  49629. * @param buffer The binary file stored in an array buffer.
  49630. * @param size The expected size of the extracted cubemap.
  49631. * @return The Cube Map information.
  49632. */
  49633. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49634. /**
  49635. * Returns the pixels data extracted from an RGBE texture.
  49636. * This pixels will be stored left to right up to down in the R G B order in one array.
  49637. *
  49638. * More information on this format are available here:
  49639. * https://en.wikipedia.org/wiki/RGBE_image_format
  49640. *
  49641. * @param uint8array The binary file stored in an array buffer.
  49642. * @param hdrInfo The header information of the file.
  49643. * @return The pixels data in RGB right to left up to down order.
  49644. */
  49645. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49646. private static RGBE_ReadPixels_RLE;
  49647. }
  49648. }
  49649. declare module BABYLON {
  49650. /**
  49651. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49652. */
  49653. interface CubeMapInfo {
  49654. /**
  49655. * The pixel array for the front face.
  49656. * This is stored in format, left to right, up to down format.
  49657. */
  49658. front: Nullable<ArrayBufferView>;
  49659. /**
  49660. * The pixel array for the back face.
  49661. * This is stored in format, left to right, up to down format.
  49662. */
  49663. back: Nullable<ArrayBufferView>;
  49664. /**
  49665. * The pixel array for the left face.
  49666. * This is stored in format, left to right, up to down format.
  49667. */
  49668. left: Nullable<ArrayBufferView>;
  49669. /**
  49670. * The pixel array for the right face.
  49671. * This is stored in format, left to right, up to down format.
  49672. */
  49673. right: Nullable<ArrayBufferView>;
  49674. /**
  49675. * The pixel array for the up face.
  49676. * This is stored in format, left to right, up to down format.
  49677. */
  49678. up: Nullable<ArrayBufferView>;
  49679. /**
  49680. * The pixel array for the down face.
  49681. * This is stored in format, left to right, up to down format.
  49682. */
  49683. down: Nullable<ArrayBufferView>;
  49684. /**
  49685. * The size of the cubemap stored.
  49686. *
  49687. * Each faces will be size * size pixels.
  49688. */
  49689. size: number;
  49690. /**
  49691. * The format of the texture.
  49692. *
  49693. * RGBA, RGB.
  49694. */
  49695. format: number;
  49696. /**
  49697. * The type of the texture data.
  49698. *
  49699. * UNSIGNED_INT, FLOAT.
  49700. */
  49701. type: number;
  49702. /**
  49703. * Specifies whether the texture is in gamma space.
  49704. */
  49705. gammaSpace: boolean;
  49706. }
  49707. /**
  49708. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49709. */
  49710. class PanoramaToCubeMapTools {
  49711. private static FACE_FRONT;
  49712. private static FACE_BACK;
  49713. private static FACE_RIGHT;
  49714. private static FACE_LEFT;
  49715. private static FACE_DOWN;
  49716. private static FACE_UP;
  49717. /**
  49718. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49719. *
  49720. * @param float32Array The source data.
  49721. * @param inputWidth The width of the input panorama.
  49722. * @param inputHeight The height of the input panorama.
  49723. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49724. * @return The cubemap data
  49725. */
  49726. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49727. private static CreateCubemapTexture;
  49728. private static CalcProjectionSpherical;
  49729. }
  49730. }
  49731. declare module BABYLON {
  49732. }
  49733. declare module BABYLON {
  49734. }
  49735. declare module BABYLON {
  49736. }
  49737. declare module BABYLON {
  49738. }
  49739. declare module BABYLON {
  49740. /**
  49741. * 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.
  49742. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49743. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49744. */
  49745. class CustomProceduralTexture extends ProceduralTexture {
  49746. private _animate;
  49747. private _time;
  49748. private _config;
  49749. private _texturePath;
  49750. /**
  49751. * Instantiates a new Custom Procedural Texture.
  49752. * 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.
  49753. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49754. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49755. * @param name Define the name of the texture
  49756. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49757. * @param size Define the size of the texture to create
  49758. * @param scene Define the scene the texture belongs to
  49759. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49760. * @param generateMipMaps Define if the texture should creates mip maps or not
  49761. */
  49762. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49763. private _loadJson;
  49764. /**
  49765. * Is the texture ready to be used ? (rendered at least once)
  49766. * @returns true if ready, otherwise, false.
  49767. */
  49768. isReady(): boolean;
  49769. /**
  49770. * Render the texture to its associated render target.
  49771. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49772. */
  49773. render(useCameraPostProcess?: boolean): void;
  49774. /**
  49775. * Update the list of dependant textures samplers in the shader.
  49776. */
  49777. updateTextures(): void;
  49778. /**
  49779. * Update the uniform values of the procedural texture in the shader.
  49780. */
  49781. updateShaderUniforms(): void;
  49782. /**
  49783. * Define if the texture animates or not.
  49784. */
  49785. animate: boolean;
  49786. }
  49787. }
  49788. declare module BABYLON {
  49789. /**
  49790. * Class used to generate noise procedural textures
  49791. */
  49792. class NoiseProceduralTexture extends ProceduralTexture {
  49793. private _time;
  49794. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49795. brightness: number;
  49796. /** Defines the number of octaves to process */
  49797. octaves: number;
  49798. /** Defines the level of persistence (0.8 by default) */
  49799. persistence: number;
  49800. /** Gets or sets animation speed factor (default is 1) */
  49801. animationSpeedFactor: number;
  49802. /**
  49803. * Creates a new NoiseProceduralTexture
  49804. * @param name defines the name fo the texture
  49805. * @param size defines the size of the texture (default is 256)
  49806. * @param scene defines the hosting scene
  49807. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49808. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49809. */
  49810. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49811. private _updateShaderUniforms;
  49812. protected _getDefines(): string;
  49813. /** Generate the current state of the procedural texture */
  49814. render(useCameraPostProcess?: boolean): void;
  49815. /**
  49816. * Serializes this noise procedural texture
  49817. * @returns a serialized noise procedural texture object
  49818. */
  49819. serialize(): any;
  49820. /**
  49821. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49822. * @param parsedTexture defines parsed texture data
  49823. * @param scene defines the current scene
  49824. * @param rootUrl defines the root URL containing noise procedural texture information
  49825. * @returns a parsed NoiseProceduralTexture
  49826. */
  49827. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  49828. }
  49829. }
  49830. declare module BABYLON {
  49831. /**
  49832. * 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.
  49833. * This is the base class of any Procedural texture and contains most of the shareable code.
  49834. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49835. */
  49836. class ProceduralTexture extends Texture {
  49837. isCube: boolean;
  49838. /**
  49839. * Define if the texture is enabled or not (disabled texture will not render)
  49840. */
  49841. isEnabled: boolean;
  49842. /**
  49843. * Define if the texture must be cleared before rendering (default is true)
  49844. */
  49845. autoClear: boolean;
  49846. /**
  49847. * Callback called when the texture is generated
  49848. */
  49849. onGenerated: () => void;
  49850. /**
  49851. * Event raised when the texture is generated
  49852. */
  49853. onGeneratedObservable: Observable<ProceduralTexture>;
  49854. /** @hidden */
  49855. _generateMipMaps: boolean;
  49856. /** @hidden **/
  49857. _effect: Effect;
  49858. /** @hidden */
  49859. _textures: {
  49860. [key: string]: Texture;
  49861. };
  49862. private _size;
  49863. private _currentRefreshId;
  49864. private _refreshRate;
  49865. private _vertexBuffers;
  49866. private _indexBuffer;
  49867. private _uniforms;
  49868. private _samplers;
  49869. private _fragment;
  49870. private _floats;
  49871. private _ints;
  49872. private _floatsArrays;
  49873. private _colors3;
  49874. private _colors4;
  49875. private _vectors2;
  49876. private _vectors3;
  49877. private _matrices;
  49878. private _fallbackTexture;
  49879. private _fallbackTextureUsed;
  49880. private _engine;
  49881. private _cachedDefines;
  49882. private _contentUpdateId;
  49883. private _contentData;
  49884. /**
  49885. * Instantiates a new procedural texture.
  49886. * 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.
  49887. * This is the base class of any Procedural texture and contains most of the shareable code.
  49888. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49889. * @param name Define the name of the texture
  49890. * @param size Define the size of the texture to create
  49891. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  49892. * @param scene Define the scene the texture belongs to
  49893. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49894. * @param generateMipMaps Define if the texture should creates mip maps or not
  49895. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  49896. */
  49897. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  49898. /**
  49899. * The effect that is created when initializing the post process.
  49900. * @returns The created effect corrisponding the the postprocess.
  49901. */
  49902. getEffect(): Effect;
  49903. /**
  49904. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  49905. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  49906. */
  49907. getContent(): Nullable<ArrayBufferView>;
  49908. private _createIndexBuffer;
  49909. /** @hidden */
  49910. _rebuild(): void;
  49911. /**
  49912. * Resets the texture in order to recreate its associated resources.
  49913. * This can be called in case of context loss
  49914. */
  49915. reset(): void;
  49916. protected _getDefines(): string;
  49917. /**
  49918. * Is the texture ready to be used ? (rendered at least once)
  49919. * @returns true if ready, otherwise, false.
  49920. */
  49921. isReady(): boolean;
  49922. /**
  49923. * Resets the refresh counter of the texture and start bak from scratch.
  49924. * Could be useful to regenerate the texture if it is setup to render only once.
  49925. */
  49926. resetRefreshCounter(): void;
  49927. /**
  49928. * Set the fragment shader to use in order to render the texture.
  49929. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  49930. */
  49931. setFragment(fragment: any): void;
  49932. /**
  49933. * Define the refresh rate of the texture or the rendering frequency.
  49934. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  49935. */
  49936. refreshRate: number;
  49937. /** @hidden */
  49938. _shouldRender(): boolean;
  49939. /**
  49940. * Get the size the texture is rendering at.
  49941. * @returns the size (texture is always squared)
  49942. */
  49943. getRenderSize(): number;
  49944. /**
  49945. * Resize the texture to new value.
  49946. * @param size Define the new size the texture should have
  49947. * @param generateMipMaps Define whether the new texture should create mip maps
  49948. */
  49949. resize(size: number, generateMipMaps: boolean): void;
  49950. private _checkUniform;
  49951. /**
  49952. * Set a texture in the shader program used to render.
  49953. * @param name Define the name of the uniform samplers as defined in the shader
  49954. * @param texture Define the texture to bind to this sampler
  49955. * @return the texture itself allowing "fluent" like uniform updates
  49956. */
  49957. setTexture(name: string, texture: Texture): ProceduralTexture;
  49958. /**
  49959. * Set a float in the shader.
  49960. * @param name Define the name of the uniform as defined in the shader
  49961. * @param value Define the value to give to the uniform
  49962. * @return the texture itself allowing "fluent" like uniform updates
  49963. */
  49964. setFloat(name: string, value: number): ProceduralTexture;
  49965. /**
  49966. * Set a int in the shader.
  49967. * @param name Define the name of the uniform as defined in the shader
  49968. * @param value Define the value to give to the uniform
  49969. * @return the texture itself allowing "fluent" like uniform updates
  49970. */
  49971. setInt(name: string, value: number): ProceduralTexture;
  49972. /**
  49973. * Set an array of floats in the shader.
  49974. * @param name Define the name of the uniform as defined in the shader
  49975. * @param value Define the value to give to the uniform
  49976. * @return the texture itself allowing "fluent" like uniform updates
  49977. */
  49978. setFloats(name: string, value: number[]): ProceduralTexture;
  49979. /**
  49980. * Set a vec3 in the shader from a Color3.
  49981. * @param name Define the name of the uniform as defined in the shader
  49982. * @param value Define the value to give to the uniform
  49983. * @return the texture itself allowing "fluent" like uniform updates
  49984. */
  49985. setColor3(name: string, value: Color3): ProceduralTexture;
  49986. /**
  49987. * Set a vec4 in the shader from a Color4.
  49988. * @param name Define the name of the uniform as defined in the shader
  49989. * @param value Define the value to give to the uniform
  49990. * @return the texture itself allowing "fluent" like uniform updates
  49991. */
  49992. setColor4(name: string, value: Color4): ProceduralTexture;
  49993. /**
  49994. * Set a vec2 in the shader from a Vector2.
  49995. * @param name Define the name of the uniform as defined in the shader
  49996. * @param value Define the value to give to the uniform
  49997. * @return the texture itself allowing "fluent" like uniform updates
  49998. */
  49999. setVector2(name: string, value: Vector2): ProceduralTexture;
  50000. /**
  50001. * Set a vec3 in the shader from a Vector3.
  50002. * @param name Define the name of the uniform as defined in the shader
  50003. * @param value Define the value to give to the uniform
  50004. * @return the texture itself allowing "fluent" like uniform updates
  50005. */
  50006. setVector3(name: string, value: Vector3): ProceduralTexture;
  50007. /**
  50008. * Set a mat4 in the shader from a MAtrix.
  50009. * @param name Define the name of the uniform as defined in the shader
  50010. * @param value Define the value to give to the uniform
  50011. * @return the texture itself allowing "fluent" like uniform updates
  50012. */
  50013. setMatrix(name: string, value: Matrix): ProceduralTexture;
  50014. /**
  50015. * Render the texture to its associated render target.
  50016. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50017. */
  50018. render(useCameraPostProcess?: boolean): void;
  50019. /**
  50020. * Clone the texture.
  50021. * @returns the cloned texture
  50022. */
  50023. clone(): ProceduralTexture;
  50024. /**
  50025. * Dispose the texture and release its asoociated resources.
  50026. */
  50027. dispose(): void;
  50028. }
  50029. }
  50030. declare module BABYLON {
  50031. interface AbstractScene {
  50032. /**
  50033. * The list of procedural textures added to the scene
  50034. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50035. */
  50036. proceduralTextures: Array<ProceduralTexture>;
  50037. }
  50038. /**
  50039. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  50040. * in a given scene.
  50041. */
  50042. class ProceduralTextureSceneComponent implements ISceneComponent {
  50043. /**
  50044. * The component name helpfull to identify the component in the list of scene components.
  50045. */
  50046. readonly name: string;
  50047. /**
  50048. * The scene the component belongs to.
  50049. */
  50050. scene: Scene;
  50051. /**
  50052. * Creates a new instance of the component for the given scene
  50053. * @param scene Defines the scene to register the component in
  50054. */
  50055. constructor(scene: Scene);
  50056. /**
  50057. * Registers the component in a given scene
  50058. */
  50059. register(): void;
  50060. /**
  50061. * Rebuilds the elements related to this component in case of
  50062. * context lost for instance.
  50063. */
  50064. rebuild(): void;
  50065. /**
  50066. * Disposes the component and the associated ressources.
  50067. */
  50068. dispose(): void;
  50069. private _beforeClear;
  50070. }
  50071. }
  50072. declare module BABYLON {
  50073. /**
  50074. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  50075. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50076. */
  50077. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50078. private _scene;
  50079. private _camerasToBeAttached;
  50080. /**
  50081. * ID of the sharpen post process,
  50082. */
  50083. private readonly SharpenPostProcessId;
  50084. /**
  50085. * @ignore
  50086. * ID of the image processing post process;
  50087. */
  50088. readonly ImageProcessingPostProcessId: string;
  50089. /**
  50090. * @ignore
  50091. * ID of the Fast Approximate Anti-Aliasing post process;
  50092. */
  50093. readonly FxaaPostProcessId: string;
  50094. /**
  50095. * ID of the chromatic aberration post process,
  50096. */
  50097. private readonly ChromaticAberrationPostProcessId;
  50098. /**
  50099. * ID of the grain post process
  50100. */
  50101. private readonly GrainPostProcessId;
  50102. /**
  50103. * Sharpen post process which will apply a sharpen convolution to enhance edges
  50104. */
  50105. sharpen: SharpenPostProcess;
  50106. private _sharpenEffect;
  50107. private bloom;
  50108. /**
  50109. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  50110. */
  50111. depthOfField: DepthOfFieldEffect;
  50112. /**
  50113. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50114. */
  50115. fxaa: FxaaPostProcess;
  50116. /**
  50117. * Image post processing pass used to perform operations such as tone mapping or color grading.
  50118. */
  50119. imageProcessing: ImageProcessingPostProcess;
  50120. /**
  50121. * Chromatic aberration post process which will shift rgb colors in the image
  50122. */
  50123. chromaticAberration: ChromaticAberrationPostProcess;
  50124. private _chromaticAberrationEffect;
  50125. /**
  50126. * Grain post process which add noise to the image
  50127. */
  50128. grain: GrainPostProcess;
  50129. private _grainEffect;
  50130. /**
  50131. * Glow post process which adds a glow to emmisive areas of the image
  50132. */
  50133. private _glowLayer;
  50134. /**
  50135. * Animations which can be used to tweak settings over a period of time
  50136. */
  50137. animations: Animation[];
  50138. private _imageProcessingConfigurationObserver;
  50139. private _sharpenEnabled;
  50140. private _bloomEnabled;
  50141. private _depthOfFieldEnabled;
  50142. private _depthOfFieldBlurLevel;
  50143. private _fxaaEnabled;
  50144. private _imageProcessingEnabled;
  50145. private _defaultPipelineTextureType;
  50146. private _bloomScale;
  50147. private _chromaticAberrationEnabled;
  50148. private _grainEnabled;
  50149. private _buildAllowed;
  50150. /**
  50151. * Enable or disable the sharpen process from the pipeline
  50152. */
  50153. sharpenEnabled: boolean;
  50154. private _resizeObserver;
  50155. private _hardwareScaleLevel;
  50156. private _bloomKernel;
  50157. /**
  50158. * Specifies the size of the bloom blur kernel, relative to the final output size
  50159. */
  50160. bloomKernel: number;
  50161. /**
  50162. * Specifies the weight of the bloom in the final rendering
  50163. */
  50164. private _bloomWeight;
  50165. /**
  50166. * Specifies the luma threshold for the area that will be blurred by the bloom
  50167. */
  50168. private _bloomThreshold;
  50169. private _hdr;
  50170. /**
  50171. * The strength of the bloom.
  50172. */
  50173. bloomWeight: number;
  50174. /**
  50175. * The strength of the bloom.
  50176. */
  50177. bloomThreshold: number;
  50178. /**
  50179. * The scale of the bloom, lower value will provide better performance.
  50180. */
  50181. bloomScale: number;
  50182. /**
  50183. * Enable or disable the bloom from the pipeline
  50184. */
  50185. bloomEnabled: boolean;
  50186. private _rebuildBloom;
  50187. /**
  50188. * If the depth of field is enabled.
  50189. */
  50190. depthOfFieldEnabled: boolean;
  50191. /**
  50192. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50193. */
  50194. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50195. /**
  50196. * If the anti aliasing is enabled.
  50197. */
  50198. fxaaEnabled: boolean;
  50199. private _samples;
  50200. /**
  50201. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50202. */
  50203. samples: number;
  50204. /**
  50205. * If image processing is enabled.
  50206. */
  50207. imageProcessingEnabled: boolean;
  50208. /**
  50209. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50210. */
  50211. glowLayerEnabled: boolean;
  50212. /**
  50213. * Enable or disable the chromaticAberration process from the pipeline
  50214. */
  50215. chromaticAberrationEnabled: boolean;
  50216. /**
  50217. * Enable or disable the grain process from the pipeline
  50218. */
  50219. grainEnabled: boolean;
  50220. /**
  50221. * @constructor
  50222. * @param name - The rendering pipeline name (default: "")
  50223. * @param hdr - If high dynamic range textures should be used (default: true)
  50224. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50225. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50226. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50227. */
  50228. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50229. /**
  50230. * Force the compilation of the entire pipeline.
  50231. */
  50232. prepare(): void;
  50233. private _hasCleared;
  50234. private _prevPostProcess;
  50235. private _prevPrevPostProcess;
  50236. private _setAutoClearAndTextureSharing;
  50237. private _depthOfFieldSceneObserver;
  50238. private _buildPipeline;
  50239. private _disposePostProcesses;
  50240. /**
  50241. * Adds a camera to the pipeline
  50242. * @param camera the camera to be added
  50243. */
  50244. addCamera(camera: Camera): void;
  50245. /**
  50246. * Removes a camera from the pipeline
  50247. * @param camera the camera to remove
  50248. */
  50249. removeCamera(camera: Camera): void;
  50250. /**
  50251. * Dispose of the pipeline and stop all post processes
  50252. */
  50253. dispose(): void;
  50254. /**
  50255. * Serialize the rendering pipeline (Used when exporting)
  50256. * @returns the serialized object
  50257. */
  50258. serialize(): any;
  50259. /**
  50260. * Parse the serialized pipeline
  50261. * @param source Source pipeline.
  50262. * @param scene The scene to load the pipeline to.
  50263. * @param rootUrl The URL of the serialized pipeline.
  50264. * @returns An instantiated pipeline from the serialized object.
  50265. */
  50266. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50267. }
  50268. }
  50269. declare module BABYLON {
  50270. /**
  50271. * BABYLON.JS Chromatic Aberration GLSL Shader
  50272. * Author: Olivier Guyot
  50273. * Separates very slightly R, G and B colors on the edges of the screen
  50274. * Inspired by Francois Tarlier & Martins Upitis
  50275. */
  50276. class LensRenderingPipeline extends PostProcessRenderPipeline {
  50277. /**
  50278. * @ignore
  50279. * The chromatic aberration PostProcess id in the pipeline
  50280. */
  50281. LensChromaticAberrationEffect: string;
  50282. /**
  50283. * @ignore
  50284. * The highlights enhancing PostProcess id in the pipeline
  50285. */
  50286. HighlightsEnhancingEffect: string;
  50287. /**
  50288. * @ignore
  50289. * The depth-of-field PostProcess id in the pipeline
  50290. */
  50291. LensDepthOfFieldEffect: string;
  50292. private _scene;
  50293. private _depthTexture;
  50294. private _grainTexture;
  50295. private _chromaticAberrationPostProcess;
  50296. private _highlightsPostProcess;
  50297. private _depthOfFieldPostProcess;
  50298. private _edgeBlur;
  50299. private _grainAmount;
  50300. private _chromaticAberration;
  50301. private _distortion;
  50302. private _highlightsGain;
  50303. private _highlightsThreshold;
  50304. private _dofDistance;
  50305. private _dofAperture;
  50306. private _dofDarken;
  50307. private _dofPentagon;
  50308. private _blurNoise;
  50309. /**
  50310. * @constructor
  50311. *
  50312. * Effect parameters are as follow:
  50313. * {
  50314. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50315. * edge_blur: number; // from 0 to x (1 for realism)
  50316. * distortion: number; // from 0 to x (1 for realism)
  50317. * grain_amount: number; // from 0 to 1
  50318. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50319. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50320. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50321. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50322. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50323. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50324. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50325. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50326. * }
  50327. * Note: if an effect parameter is unset, effect is disabled
  50328. *
  50329. * @param name The rendering pipeline name
  50330. * @param parameters - An object containing all parameters (see above)
  50331. * @param scene The scene linked to this pipeline
  50332. * @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)
  50333. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50334. */
  50335. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50336. /**
  50337. * Sets the amount of blur at the edges
  50338. * @param amount blur amount
  50339. */
  50340. setEdgeBlur(amount: number): void;
  50341. /**
  50342. * Sets edge blur to 0
  50343. */
  50344. disableEdgeBlur(): void;
  50345. /**
  50346. * Sets the amout of grain
  50347. * @param amount Amount of grain
  50348. */
  50349. setGrainAmount(amount: number): void;
  50350. /**
  50351. * Set grain amount to 0
  50352. */
  50353. disableGrain(): void;
  50354. /**
  50355. * Sets the chromatic aberration amount
  50356. * @param amount amount of chromatic aberration
  50357. */
  50358. setChromaticAberration(amount: number): void;
  50359. /**
  50360. * Sets chromatic aberration amount to 0
  50361. */
  50362. disableChromaticAberration(): void;
  50363. /**
  50364. * Sets the EdgeDistortion amount
  50365. * @param amount amount of EdgeDistortion
  50366. */
  50367. setEdgeDistortion(amount: number): void;
  50368. /**
  50369. * Sets edge distortion to 0
  50370. */
  50371. disableEdgeDistortion(): void;
  50372. /**
  50373. * Sets the FocusDistance amount
  50374. * @param amount amount of FocusDistance
  50375. */
  50376. setFocusDistance(amount: number): void;
  50377. /**
  50378. * Disables depth of field
  50379. */
  50380. disableDepthOfField(): void;
  50381. /**
  50382. * Sets the Aperture amount
  50383. * @param amount amount of Aperture
  50384. */
  50385. setAperture(amount: number): void;
  50386. /**
  50387. * Sets the DarkenOutOfFocus amount
  50388. * @param amount amount of DarkenOutOfFocus
  50389. */
  50390. setDarkenOutOfFocus(amount: number): void;
  50391. /**
  50392. * Creates a pentagon bokeh effect
  50393. */
  50394. enablePentagonBokeh(): void;
  50395. /**
  50396. * Disables the pentagon bokeh effect
  50397. */
  50398. disablePentagonBokeh(): void;
  50399. /**
  50400. * Enables noise blur
  50401. */
  50402. enableNoiseBlur(): void;
  50403. /**
  50404. * Disables noise blur
  50405. */
  50406. disableNoiseBlur(): void;
  50407. /**
  50408. * Sets the HighlightsGain amount
  50409. * @param amount amount of HighlightsGain
  50410. */
  50411. setHighlightsGain(amount: number): void;
  50412. /**
  50413. * Sets the HighlightsThreshold amount
  50414. * @param amount amount of HighlightsThreshold
  50415. */
  50416. setHighlightsThreshold(amount: number): void;
  50417. /**
  50418. * Disables highlights
  50419. */
  50420. disableHighlights(): void;
  50421. /**
  50422. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50423. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50424. */
  50425. dispose(disableDepthRender?: boolean): void;
  50426. private _createChromaticAberrationPostProcess;
  50427. private _createHighlightsPostProcess;
  50428. private _createDepthOfFieldPostProcess;
  50429. private _createGrainTexture;
  50430. }
  50431. }
  50432. declare module BABYLON {
  50433. /**
  50434. * Render pipeline to produce ssao effect
  50435. */
  50436. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50437. /**
  50438. * @ignore
  50439. * The PassPostProcess id in the pipeline that contains the original scene color
  50440. */
  50441. SSAOOriginalSceneColorEffect: string;
  50442. /**
  50443. * @ignore
  50444. * The SSAO PostProcess id in the pipeline
  50445. */
  50446. SSAORenderEffect: string;
  50447. /**
  50448. * @ignore
  50449. * The horizontal blur PostProcess id in the pipeline
  50450. */
  50451. SSAOBlurHRenderEffect: string;
  50452. /**
  50453. * @ignore
  50454. * The vertical blur PostProcess id in the pipeline
  50455. */
  50456. SSAOBlurVRenderEffect: string;
  50457. /**
  50458. * @ignore
  50459. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50460. */
  50461. SSAOCombineRenderEffect: string;
  50462. /**
  50463. * The output strength of the SSAO post-process. Default value is 1.0.
  50464. */
  50465. totalStrength: number;
  50466. /**
  50467. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50468. */
  50469. maxZ: number;
  50470. /**
  50471. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50472. */
  50473. minZAspect: number;
  50474. private _samples;
  50475. /**
  50476. * Number of samples used for the SSAO calculations. Default value is 8
  50477. */
  50478. samples: number;
  50479. private _textureSamples;
  50480. /**
  50481. * Number of samples to use for antialiasing
  50482. */
  50483. textureSamples: number;
  50484. /**
  50485. * Ratio object used for SSAO ratio and blur ratio
  50486. */
  50487. private _ratio;
  50488. /**
  50489. * Dynamically generated sphere sampler.
  50490. */
  50491. private _sampleSphere;
  50492. /**
  50493. * Blur filter offsets
  50494. */
  50495. private _samplerOffsets;
  50496. private _expensiveBlur;
  50497. /**
  50498. * If bilateral blur should be used
  50499. */
  50500. expensiveBlur: boolean;
  50501. /**
  50502. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50503. */
  50504. radius: number;
  50505. /**
  50506. * The base color of the SSAO post-process
  50507. * The final result is "base + ssao" between [0, 1]
  50508. */
  50509. base: number;
  50510. /**
  50511. * Support test.
  50512. */
  50513. static readonly IsSupported: boolean;
  50514. private _scene;
  50515. private _depthTexture;
  50516. private _normalTexture;
  50517. private _randomTexture;
  50518. private _originalColorPostProcess;
  50519. private _ssaoPostProcess;
  50520. private _blurHPostProcess;
  50521. private _blurVPostProcess;
  50522. private _ssaoCombinePostProcess;
  50523. private _firstUpdate;
  50524. /**
  50525. * @constructor
  50526. * @param name The rendering pipeline name
  50527. * @param scene The scene linked to this pipeline
  50528. * @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 }
  50529. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50530. */
  50531. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50532. /**
  50533. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50534. */
  50535. dispose(disableGeometryBufferRenderer?: boolean): void;
  50536. private _createBlurPostProcess;
  50537. /** @hidden */
  50538. _rebuild(): void;
  50539. private _bits;
  50540. private _radicalInverse_VdC;
  50541. private _hammersley;
  50542. private _hemisphereSample_uniform;
  50543. private _generateHemisphere;
  50544. private _createSSAOPostProcess;
  50545. private _createSSAOCombinePostProcess;
  50546. private _createRandomTexture;
  50547. /**
  50548. * Serialize the rendering pipeline (Used when exporting)
  50549. * @returns the serialized object
  50550. */
  50551. serialize(): any;
  50552. /**
  50553. * Parse the serialized pipeline
  50554. * @param source Source pipeline.
  50555. * @param scene The scene to load the pipeline to.
  50556. * @param rootUrl The URL of the serialized pipeline.
  50557. * @returns An instantiated pipeline from the serialized object.
  50558. */
  50559. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50560. }
  50561. }
  50562. declare module BABYLON {
  50563. /**
  50564. * Render pipeline to produce ssao effect
  50565. */
  50566. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50567. /**
  50568. * @ignore
  50569. * The PassPostProcess id in the pipeline that contains the original scene color
  50570. */
  50571. SSAOOriginalSceneColorEffect: string;
  50572. /**
  50573. * @ignore
  50574. * The SSAO PostProcess id in the pipeline
  50575. */
  50576. SSAORenderEffect: string;
  50577. /**
  50578. * @ignore
  50579. * The horizontal blur PostProcess id in the pipeline
  50580. */
  50581. SSAOBlurHRenderEffect: string;
  50582. /**
  50583. * @ignore
  50584. * The vertical blur PostProcess id in the pipeline
  50585. */
  50586. SSAOBlurVRenderEffect: string;
  50587. /**
  50588. * @ignore
  50589. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50590. */
  50591. SSAOCombineRenderEffect: string;
  50592. /**
  50593. * The output strength of the SSAO post-process. Default value is 1.0.
  50594. */
  50595. totalStrength: number;
  50596. /**
  50597. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50598. */
  50599. radius: number;
  50600. /**
  50601. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50602. * Must not be equal to fallOff and superior to fallOff.
  50603. * Default value is 0.975
  50604. */
  50605. area: number;
  50606. /**
  50607. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50608. * Must not be equal to area and inferior to area.
  50609. * Default value is 0.0
  50610. */
  50611. fallOff: number;
  50612. /**
  50613. * The base color of the SSAO post-process
  50614. * The final result is "base + ssao" between [0, 1]
  50615. */
  50616. base: number;
  50617. private _scene;
  50618. private _depthTexture;
  50619. private _randomTexture;
  50620. private _originalColorPostProcess;
  50621. private _ssaoPostProcess;
  50622. private _blurHPostProcess;
  50623. private _blurVPostProcess;
  50624. private _ssaoCombinePostProcess;
  50625. private _firstUpdate;
  50626. /**
  50627. * @constructor
  50628. * @param name - The rendering pipeline name
  50629. * @param scene - The scene linked to this pipeline
  50630. * @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 }
  50631. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50632. */
  50633. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50634. /**
  50635. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50636. */
  50637. dispose(disableDepthRender?: boolean): void;
  50638. private _createBlurPostProcess;
  50639. /** @hidden */
  50640. _rebuild(): void;
  50641. private _createSSAOPostProcess;
  50642. private _createSSAOCombinePostProcess;
  50643. private _createRandomTexture;
  50644. }
  50645. }
  50646. declare module BABYLON {
  50647. /**
  50648. * Standard rendering pipeline
  50649. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50650. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50651. */
  50652. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50653. /**
  50654. * Public members
  50655. */
  50656. /**
  50657. * Post-process which contains the original scene color before the pipeline applies all the effects
  50658. */
  50659. originalPostProcess: Nullable<PostProcess>;
  50660. /**
  50661. * Post-process used to down scale an image x4
  50662. */
  50663. downSampleX4PostProcess: Nullable<PostProcess>;
  50664. /**
  50665. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50666. */
  50667. brightPassPostProcess: Nullable<PostProcess>;
  50668. /**
  50669. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50670. */
  50671. blurHPostProcesses: PostProcess[];
  50672. /**
  50673. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50674. */
  50675. blurVPostProcesses: PostProcess[];
  50676. /**
  50677. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50678. */
  50679. textureAdderPostProcess: Nullable<PostProcess>;
  50680. /**
  50681. * Post-process used to create volumetric lighting effect
  50682. */
  50683. volumetricLightPostProcess: Nullable<PostProcess>;
  50684. /**
  50685. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50686. */
  50687. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50688. /**
  50689. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50690. */
  50691. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50692. /**
  50693. * Post-process used to merge the volumetric light effect and the real scene color
  50694. */
  50695. volumetricLightMergePostProces: Nullable<PostProcess>;
  50696. /**
  50697. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50698. */
  50699. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50700. /**
  50701. * Base post-process used to calculate the average luminance of the final image for HDR
  50702. */
  50703. luminancePostProcess: Nullable<PostProcess>;
  50704. /**
  50705. * Post-processes used to create down sample post-processes in order to get
  50706. * the average luminance of the final image for HDR
  50707. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50708. */
  50709. luminanceDownSamplePostProcesses: PostProcess[];
  50710. /**
  50711. * Post-process used to create a HDR effect (light adaptation)
  50712. */
  50713. hdrPostProcess: Nullable<PostProcess>;
  50714. /**
  50715. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  50716. */
  50717. textureAdderFinalPostProcess: Nullable<PostProcess>;
  50718. /**
  50719. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  50720. */
  50721. lensFlareFinalPostProcess: Nullable<PostProcess>;
  50722. /**
  50723. * Post-process used to merge the final HDR post-process and the real scene color
  50724. */
  50725. hdrFinalPostProcess: Nullable<PostProcess>;
  50726. /**
  50727. * Post-process used to create a lens flare effect
  50728. */
  50729. lensFlarePostProcess: Nullable<PostProcess>;
  50730. /**
  50731. * Post-process that merges the result of the lens flare post-process and the real scene color
  50732. */
  50733. lensFlareComposePostProcess: Nullable<PostProcess>;
  50734. /**
  50735. * Post-process used to create a motion blur effect
  50736. */
  50737. motionBlurPostProcess: Nullable<PostProcess>;
  50738. /**
  50739. * Post-process used to create a depth of field effect
  50740. */
  50741. depthOfFieldPostProcess: Nullable<PostProcess>;
  50742. /**
  50743. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50744. */
  50745. fxaaPostProcess: Nullable<FxaaPostProcess>;
  50746. /**
  50747. * Represents the brightness threshold in order to configure the illuminated surfaces
  50748. */
  50749. brightThreshold: number;
  50750. /**
  50751. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  50752. */
  50753. blurWidth: number;
  50754. /**
  50755. * Sets if the blur for highlighted surfaces must be only horizontal
  50756. */
  50757. horizontalBlur: boolean;
  50758. /**
  50759. * Sets the overall exposure used by the pipeline
  50760. */
  50761. exposure: number;
  50762. /**
  50763. * Texture used typically to simulate "dirty" on camera lens
  50764. */
  50765. lensTexture: Nullable<Texture>;
  50766. /**
  50767. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  50768. */
  50769. volumetricLightCoefficient: number;
  50770. /**
  50771. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  50772. */
  50773. volumetricLightPower: number;
  50774. /**
  50775. * Used the set the blur intensity to smooth the volumetric lights
  50776. */
  50777. volumetricLightBlurScale: number;
  50778. /**
  50779. * Light (spot or directional) used to generate the volumetric lights rays
  50780. * The source light must have a shadow generate so the pipeline can get its
  50781. * depth map
  50782. */
  50783. sourceLight: Nullable<SpotLight | DirectionalLight>;
  50784. /**
  50785. * For eye adaptation, represents the minimum luminance the eye can see
  50786. */
  50787. hdrMinimumLuminance: number;
  50788. /**
  50789. * For eye adaptation, represents the decrease luminance speed
  50790. */
  50791. hdrDecreaseRate: number;
  50792. /**
  50793. * For eye adaptation, represents the increase luminance speed
  50794. */
  50795. hdrIncreaseRate: number;
  50796. /**
  50797. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  50798. */
  50799. lensColorTexture: Nullable<Texture>;
  50800. /**
  50801. * The overall strengh for the lens flare effect
  50802. */
  50803. lensFlareStrength: number;
  50804. /**
  50805. * Dispersion coefficient for lens flare ghosts
  50806. */
  50807. lensFlareGhostDispersal: number;
  50808. /**
  50809. * Main lens flare halo width
  50810. */
  50811. lensFlareHaloWidth: number;
  50812. /**
  50813. * Based on the lens distortion effect, defines how much the lens flare result
  50814. * is distorted
  50815. */
  50816. lensFlareDistortionStrength: number;
  50817. /**
  50818. * Lens star texture must be used to simulate rays on the flares and is available
  50819. * in the documentation
  50820. */
  50821. lensStarTexture: Nullable<Texture>;
  50822. /**
  50823. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  50824. * flare effect by taking account of the dirt texture
  50825. */
  50826. lensFlareDirtTexture: Nullable<Texture>;
  50827. /**
  50828. * Represents the focal length for the depth of field effect
  50829. */
  50830. depthOfFieldDistance: number;
  50831. /**
  50832. * Represents the blur intensity for the blurred part of the depth of field effect
  50833. */
  50834. depthOfFieldBlurWidth: number;
  50835. /**
  50836. * For motion blur, defines how much the image is blurred by the movement
  50837. */
  50838. motionStrength: number;
  50839. /**
  50840. * List of animations for the pipeline (IAnimatable implementation)
  50841. */
  50842. animations: Animation[];
  50843. /**
  50844. * Private members
  50845. */
  50846. private _scene;
  50847. private _currentDepthOfFieldSource;
  50848. private _basePostProcess;
  50849. private _hdrCurrentLuminance;
  50850. private _floatTextureType;
  50851. private _ratio;
  50852. private _bloomEnabled;
  50853. private _depthOfFieldEnabled;
  50854. private _vlsEnabled;
  50855. private _lensFlareEnabled;
  50856. private _hdrEnabled;
  50857. private _motionBlurEnabled;
  50858. private _fxaaEnabled;
  50859. private _motionBlurSamples;
  50860. private _volumetricLightStepsCount;
  50861. private _samples;
  50862. /**
  50863. * @ignore
  50864. * Specifies if the bloom pipeline is enabled
  50865. */
  50866. BloomEnabled: boolean;
  50867. /**
  50868. * @ignore
  50869. * Specifies if the depth of field pipeline is enabed
  50870. */
  50871. DepthOfFieldEnabled: boolean;
  50872. /**
  50873. * @ignore
  50874. * Specifies if the lens flare pipeline is enabed
  50875. */
  50876. LensFlareEnabled: boolean;
  50877. /**
  50878. * @ignore
  50879. * Specifies if the HDR pipeline is enabled
  50880. */
  50881. HDREnabled: boolean;
  50882. /**
  50883. * @ignore
  50884. * Specifies if the volumetric lights scattering effect is enabled
  50885. */
  50886. VLSEnabled: boolean;
  50887. /**
  50888. * @ignore
  50889. * Specifies if the motion blur effect is enabled
  50890. */
  50891. MotionBlurEnabled: boolean;
  50892. /**
  50893. * Specifies if anti-aliasing is enabled
  50894. */
  50895. fxaaEnabled: boolean;
  50896. /**
  50897. * Specifies the number of steps used to calculate the volumetric lights
  50898. * Typically in interval [50, 200]
  50899. */
  50900. volumetricLightStepsCount: number;
  50901. /**
  50902. * Specifies the number of samples used for the motion blur effect
  50903. * Typically in interval [16, 64]
  50904. */
  50905. motionBlurSamples: number;
  50906. /**
  50907. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50908. */
  50909. samples: number;
  50910. /**
  50911. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50912. * @constructor
  50913. * @param name The rendering pipeline name
  50914. * @param scene The scene linked to this pipeline
  50915. * @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)
  50916. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  50917. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50918. */
  50919. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  50920. private _buildPipeline;
  50921. private _createDownSampleX4PostProcess;
  50922. private _createBrightPassPostProcess;
  50923. private _createBlurPostProcesses;
  50924. private _createTextureAdderPostProcess;
  50925. private _createVolumetricLightPostProcess;
  50926. private _createLuminancePostProcesses;
  50927. private _createHdrPostProcess;
  50928. private _createLensFlarePostProcess;
  50929. private _createDepthOfFieldPostProcess;
  50930. private _createMotionBlurPostProcess;
  50931. private _getDepthTexture;
  50932. private _disposePostProcesses;
  50933. /**
  50934. * Dispose of the pipeline and stop all post processes
  50935. */
  50936. dispose(): void;
  50937. /**
  50938. * Serialize the rendering pipeline (Used when exporting)
  50939. * @returns the serialized object
  50940. */
  50941. serialize(): any;
  50942. /**
  50943. * Parse the serialized pipeline
  50944. * @param source Source pipeline.
  50945. * @param scene The scene to load the pipeline to.
  50946. * @param rootUrl The URL of the serialized pipeline.
  50947. * @returns An instantiated pipeline from the serialized object.
  50948. */
  50949. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  50950. /**
  50951. * Luminance steps
  50952. */
  50953. static LuminanceSteps: number;
  50954. }
  50955. }