babylon.d.ts 2.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673
  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 uniqueId
  711. * It will improve performance when the number of geometries becomes important.
  712. */
  713. useGeometryUniqueIdsMap?: 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 geometriesByUniqueId;
  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. * @param onAnimationLoop defines the callback to call when an animation loops
  1778. * @returns the animatable object created for this animation
  1779. */
  1780. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  1781. /**
  1782. * Will start the animation sequence of a given target
  1783. * @param target defines the target
  1784. * @param from defines from which frame should animation start
  1785. * @param to defines until which frame should animation run.
  1786. * @param loop defines if the animation loops
  1787. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1788. * @param onAnimationEnd defines the function to be executed when the animation ends
  1789. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1790. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1791. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  1792. * @param onAnimationLoop defines the callback to call when an animation loops
  1793. * @returns the animatable object created for this animation
  1794. */
  1795. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  1796. /**
  1797. * Will start the animation sequence of a given target and its hierarchy
  1798. * @param target defines the target
  1799. * @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.
  1800. * @param from defines from which frame should animation start
  1801. * @param to defines until which frame should animation run.
  1802. * @param loop defines if the animation loops
  1803. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1804. * @param onAnimationEnd defines the function to be executed when the animation ends
  1805. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1806. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1807. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1808. * @param onAnimationLoop defines the callback to call when an animation loops
  1809. * @returns the list of created animatables
  1810. */
  1811. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  1812. /**
  1813. * Begin a new animation on a given node
  1814. * @param target defines the target where the animation will take place
  1815. * @param animations defines the list of animations to start
  1816. * @param from defines the initial value
  1817. * @param to defines the final value
  1818. * @param loop defines if you want animation to loop (off by default)
  1819. * @param speedRatio defines the speed ratio to apply to all animations
  1820. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1821. * @param onAnimationLoop defines the callback to call when an animation loops
  1822. * @returns the list of created animatables
  1823. */
  1824. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  1825. /**
  1826. * Begin a new animation on a given node and its hierarchy
  1827. * @param target defines the root node where the animation will take place
  1828. * @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.
  1829. * @param animations defines the list of animations to start
  1830. * @param from defines the initial value
  1831. * @param to defines the final value
  1832. * @param loop defines if you want animation to loop (off by default)
  1833. * @param speedRatio defines the speed ratio to apply to all animations
  1834. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1835. * @param onAnimationLoop defines the callback to call when an animation loops
  1836. * @returns the list of animatables created for all nodes
  1837. */
  1838. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  1839. /**
  1840. * Gets the animatable associated with a specific target
  1841. * @param target defines the target of the animatable
  1842. * @returns the required animatable if found
  1843. */
  1844. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1845. /**
  1846. * Gets all animatables associated with a given target
  1847. * @param target defines the target to look animatables for
  1848. * @returns an array of Animatables
  1849. */
  1850. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1851. /**
  1852. * Gets all animatable attached to the scene
  1853. */
  1854. readonly animatables: Animatable[];
  1855. /**
  1856. * Will stop the animation of the given target
  1857. * @param target - the target
  1858. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1859. * @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)
  1860. */
  1861. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1862. /**
  1863. * Stops and removes all animations that have been applied to the scene
  1864. */
  1865. stopAllAnimations(): void;
  1866. private _animate;
  1867. /** @hidden */
  1868. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1869. private _processLateAnimationBindingsForMatrices;
  1870. private _processLateAnimationBindingsForQuaternions;
  1871. private _processLateAnimationBindings;
  1872. /** @hidden */
  1873. _switchToAlternateCameraConfiguration(active: boolean): void;
  1874. /**
  1875. * Gets the current view matrix
  1876. * @returns a Matrix
  1877. */
  1878. getViewMatrix(): Matrix;
  1879. /**
  1880. * Gets the current projection matrix
  1881. * @returns a Matrix
  1882. */
  1883. getProjectionMatrix(): Matrix;
  1884. /**
  1885. * Gets the current transform matrix
  1886. * @returns a Matrix made of View * Projection
  1887. */
  1888. getTransformMatrix(): Matrix;
  1889. /**
  1890. * Sets the current transform matrix
  1891. * @param view defines the View matrix to use
  1892. * @param projection defines the Projection matrix to use
  1893. */
  1894. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1895. /** @hidden */
  1896. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1897. /**
  1898. * Gets the uniform buffer used to store scene data
  1899. * @returns a UniformBuffer
  1900. */
  1901. getSceneUniformBuffer(): UniformBuffer;
  1902. /**
  1903. * Gets an unique (relatively to the current scene) Id
  1904. * @returns an unique number for the scene
  1905. */
  1906. getUniqueId(): number;
  1907. /**
  1908. * Add a mesh to the list of scene's meshes
  1909. * @param newMesh defines the mesh to add
  1910. * @param recursive if all child meshes should also be added to the scene
  1911. */
  1912. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1913. /**
  1914. * Remove a mesh for the list of scene's meshes
  1915. * @param toRemove defines the mesh to remove
  1916. * @param recursive if all child meshes should also be removed from the scene
  1917. * @returns the index where the mesh was in the mesh list
  1918. */
  1919. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1920. /**
  1921. * Add a transform node to the list of scene's transform nodes
  1922. * @param newTransformNode defines the transform node to add
  1923. */
  1924. addTransformNode(newTransformNode: TransformNode): void;
  1925. /**
  1926. * Remove a transform node for the list of scene's transform nodes
  1927. * @param toRemove defines the transform node to remove
  1928. * @returns the index where the transform node was in the transform node list
  1929. */
  1930. removeTransformNode(toRemove: TransformNode): number;
  1931. /**
  1932. * Remove a skeleton for the list of scene's skeletons
  1933. * @param toRemove defines the skeleton to remove
  1934. * @returns the index where the skeleton was in the skeleton list
  1935. */
  1936. removeSkeleton(toRemove: Skeleton): number;
  1937. /**
  1938. * Remove a morph target for the list of scene's morph targets
  1939. * @param toRemove defines the morph target to remove
  1940. * @returns the index where the morph target was in the morph target list
  1941. */
  1942. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1943. /**
  1944. * Remove a light for the list of scene's lights
  1945. * @param toRemove defines the light to remove
  1946. * @returns the index where the light was in the light list
  1947. */
  1948. removeLight(toRemove: Light): number;
  1949. /**
  1950. * Remove a camera for the list of scene's cameras
  1951. * @param toRemove defines the camera to remove
  1952. * @returns the index where the camera was in the camera list
  1953. */
  1954. removeCamera(toRemove: Camera): number;
  1955. /**
  1956. * Remove a particle system for the list of scene's particle systems
  1957. * @param toRemove defines the particle system to remove
  1958. * @returns the index where the particle system was in the particle system list
  1959. */
  1960. removeParticleSystem(toRemove: IParticleSystem): number;
  1961. /**
  1962. * Remove a animation for the list of scene's animations
  1963. * @param toRemove defines the animation to remove
  1964. * @returns the index where the animation was in the animation list
  1965. */
  1966. removeAnimation(toRemove: Animation): number;
  1967. /**
  1968. * Removes the given animation group from this scene.
  1969. * @param toRemove The animation group to remove
  1970. * @returns The index of the removed animation group
  1971. */
  1972. removeAnimationGroup(toRemove: AnimationGroup): number;
  1973. /**
  1974. * Removes the given multi-material from this scene.
  1975. * @param toRemove The multi-material to remove
  1976. * @returns The index of the removed multi-material
  1977. */
  1978. removeMultiMaterial(toRemove: MultiMaterial): number;
  1979. /**
  1980. * Removes the given material from this scene.
  1981. * @param toRemove The material to remove
  1982. * @returns The index of the removed material
  1983. */
  1984. removeMaterial(toRemove: Material): number;
  1985. /**
  1986. * Removes the given action manager from this scene.
  1987. * @param toRemove The action manager to remove
  1988. * @returns The index of the removed action manager
  1989. */
  1990. removeActionManager(toRemove: ActionManager): number;
  1991. /**
  1992. * Removes the given texture from this scene.
  1993. * @param toRemove The texture to remove
  1994. * @returns The index of the removed texture
  1995. */
  1996. removeTexture(toRemove: BaseTexture): number;
  1997. /**
  1998. * Adds the given light to this scene
  1999. * @param newLight The light to add
  2000. */
  2001. addLight(newLight: Light): void;
  2002. /**
  2003. * Sorts the list list based on light priorities
  2004. */
  2005. sortLightsByPriority(): void;
  2006. /**
  2007. * Adds the given camera to this scene
  2008. * @param newCamera The camera to add
  2009. */
  2010. addCamera(newCamera: Camera): void;
  2011. /**
  2012. * Adds the given skeleton to this scene
  2013. * @param newSkeleton The skeleton to add
  2014. */
  2015. addSkeleton(newSkeleton: Skeleton): void;
  2016. /**
  2017. * Adds the given particle system to this scene
  2018. * @param newParticleSystem The particle system to add
  2019. */
  2020. addParticleSystem(newParticleSystem: IParticleSystem): void;
  2021. /**
  2022. * Adds the given animation to this scene
  2023. * @param newAnimation The animation to add
  2024. */
  2025. addAnimation(newAnimation: Animation): void;
  2026. /**
  2027. * Adds the given animation group to this scene.
  2028. * @param newAnimationGroup The animation group to add
  2029. */
  2030. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  2031. /**
  2032. * Adds the given multi-material to this scene
  2033. * @param newMultiMaterial The multi-material to add
  2034. */
  2035. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  2036. /**
  2037. * Adds the given material to this scene
  2038. * @param newMaterial The material to add
  2039. */
  2040. addMaterial(newMaterial: Material): void;
  2041. /**
  2042. * Adds the given morph target to this scene
  2043. * @param newMorphTargetManager The morph target to add
  2044. */
  2045. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  2046. /**
  2047. * Adds the given geometry to this scene
  2048. * @param newGeometry The geometry to add
  2049. */
  2050. addGeometry(newGeometry: Geometry): void;
  2051. /**
  2052. * Adds the given action manager to this scene
  2053. * @param newActionManager The action manager to add
  2054. */
  2055. addActionManager(newActionManager: ActionManager): void;
  2056. /**
  2057. * Adds the given texture to this scene.
  2058. * @param newTexture The texture to add
  2059. */
  2060. addTexture(newTexture: BaseTexture): void;
  2061. /**
  2062. * Switch active camera
  2063. * @param newCamera defines the new active camera
  2064. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2065. */
  2066. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2067. /**
  2068. * sets the active camera of the scene using its ID
  2069. * @param id defines the camera's ID
  2070. * @return the new active camera or null if none found.
  2071. */
  2072. setActiveCameraByID(id: string): Nullable<Camera>;
  2073. /**
  2074. * sets the active camera of the scene using its name
  2075. * @param name defines the camera's name
  2076. * @returns the new active camera or null if none found.
  2077. */
  2078. setActiveCameraByName(name: string): Nullable<Camera>;
  2079. /**
  2080. * get an animation group using its name
  2081. * @param name defines the material's name
  2082. * @return the animation group or null if none found.
  2083. */
  2084. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2085. /**
  2086. * get a material using its id
  2087. * @param id defines the material's ID
  2088. * @return the material or null if none found.
  2089. */
  2090. getMaterialByID(id: string): Nullable<Material>;
  2091. /**
  2092. * Gets a material using its name
  2093. * @param name defines the material's name
  2094. * @return the material or null if none found.
  2095. */
  2096. getMaterialByName(name: string): Nullable<Material>;
  2097. /**
  2098. * Gets a camera using its id
  2099. * @param id defines the id to look for
  2100. * @returns the camera or null if not found
  2101. */
  2102. getCameraByID(id: string): Nullable<Camera>;
  2103. /**
  2104. * Gets a camera using its unique id
  2105. * @param uniqueId defines the unique id to look for
  2106. * @returns the camera or null if not found
  2107. */
  2108. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2109. /**
  2110. * Gets a camera using its name
  2111. * @param name defines the camera's name
  2112. * @return the camera or null if none found.
  2113. */
  2114. getCameraByName(name: string): Nullable<Camera>;
  2115. /**
  2116. * Gets a bone using its id
  2117. * @param id defines the bone's id
  2118. * @return the bone or null if not found
  2119. */
  2120. getBoneByID(id: string): Nullable<Bone>;
  2121. /**
  2122. * Gets a bone using its id
  2123. * @param name defines the bone's name
  2124. * @return the bone or null if not found
  2125. */
  2126. getBoneByName(name: string): Nullable<Bone>;
  2127. /**
  2128. * Gets a light node using its name
  2129. * @param name defines the the light's name
  2130. * @return the light or null if none found.
  2131. */
  2132. getLightByName(name: string): Nullable<Light>;
  2133. /**
  2134. * Gets a light node using its id
  2135. * @param id defines the light's id
  2136. * @return the light or null if none found.
  2137. */
  2138. getLightByID(id: string): Nullable<Light>;
  2139. /**
  2140. * Gets a light node using its scene-generated unique ID
  2141. * @param uniqueId defines the light's unique id
  2142. * @return the light or null if none found.
  2143. */
  2144. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2145. /**
  2146. * Gets a particle system by id
  2147. * @param id defines the particle system id
  2148. * @return the corresponding system or null if none found
  2149. */
  2150. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2151. /**
  2152. * Gets a geometry using its ID
  2153. * @param id defines the geometry's id
  2154. * @return the geometry or null if none found.
  2155. */
  2156. getGeometryByID(id: string): Nullable<Geometry>;
  2157. private _getGeometryByUniqueID;
  2158. /**
  2159. * Add a new geometry to this scene
  2160. * @param geometry defines the geometry to be added to the scene.
  2161. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2162. * @return a boolean defining if the geometry was added or not
  2163. */
  2164. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2165. /**
  2166. * Removes an existing geometry
  2167. * @param geometry defines the geometry to be removed from the scene
  2168. * @return a boolean defining if the geometry was removed or not
  2169. */
  2170. removeGeometry(geometry: Geometry): boolean;
  2171. /**
  2172. * Gets the list of geometries attached to the scene
  2173. * @returns an array of Geometry
  2174. */
  2175. getGeometries(): Geometry[];
  2176. /**
  2177. * Gets the first added mesh found of a given ID
  2178. * @param id defines the id to search for
  2179. * @return the mesh found or null if not found at all
  2180. */
  2181. getMeshByID(id: string): Nullable<AbstractMesh>;
  2182. /**
  2183. * Gets a list of meshes using their id
  2184. * @param id defines the id to search for
  2185. * @returns a list of meshes
  2186. */
  2187. getMeshesByID(id: string): Array<AbstractMesh>;
  2188. /**
  2189. * Gets the first added transform node found of a given ID
  2190. * @param id defines the id to search for
  2191. * @return the found transform node or null if not found at all.
  2192. */
  2193. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2194. /**
  2195. * Gets a list of transform nodes using their id
  2196. * @param id defines the id to search for
  2197. * @returns a list of transform nodes
  2198. */
  2199. getTransformNodesByID(id: string): Array<TransformNode>;
  2200. /**
  2201. * Gets a mesh with its auto-generated unique id
  2202. * @param uniqueId defines the unique id to search for
  2203. * @return the found mesh or null if not found at all.
  2204. */
  2205. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2206. /**
  2207. * Gets a the last added mesh using a given id
  2208. * @param id defines the id to search for
  2209. * @return the found mesh or null if not found at all.
  2210. */
  2211. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2212. /**
  2213. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2214. * @param id defines the id to search for
  2215. * @return the found node or null if not found at all
  2216. */
  2217. getLastEntryByID(id: string): Nullable<Node>;
  2218. /**
  2219. * Gets a node (Mesh, Camera, Light) using a given id
  2220. * @param id defines the id to search for
  2221. * @return the found node or null if not found at all
  2222. */
  2223. getNodeByID(id: string): Nullable<Node>;
  2224. /**
  2225. * Gets a node (Mesh, Camera, Light) using a given name
  2226. * @param name defines the name to search for
  2227. * @return the found node or null if not found at all.
  2228. */
  2229. getNodeByName(name: string): Nullable<Node>;
  2230. /**
  2231. * Gets a mesh using a given name
  2232. * @param name defines the name to search for
  2233. * @return the found mesh or null if not found at all.
  2234. */
  2235. getMeshByName(name: string): Nullable<AbstractMesh>;
  2236. /**
  2237. * Gets a transform node using a given name
  2238. * @param name defines the name to search for
  2239. * @return the found transform node or null if not found at all.
  2240. */
  2241. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2242. /**
  2243. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2244. * @param id defines the id to search for
  2245. * @return the found skeleton or null if not found at all.
  2246. */
  2247. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2248. /**
  2249. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2250. * @param id defines the id to search for
  2251. * @return the found skeleton or null if not found at all.
  2252. */
  2253. getSkeletonById(id: string): Nullable<Skeleton>;
  2254. /**
  2255. * Gets a skeleton using a given name
  2256. * @param name defines the name to search for
  2257. * @return the found skeleton or null if not found at all.
  2258. */
  2259. getSkeletonByName(name: string): Nullable<Skeleton>;
  2260. /**
  2261. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2262. * @param id defines the id to search for
  2263. * @return the found morph target manager or null if not found at all.
  2264. */
  2265. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2266. /**
  2267. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  2268. * @param id defines the id to search for
  2269. * @return the found morph target or null if not found at all.
  2270. */
  2271. getMorphTargetById(id: string): Nullable<MorphTarget>;
  2272. /**
  2273. * Gets a boolean indicating if the given mesh is active
  2274. * @param mesh defines the mesh to look for
  2275. * @returns true if the mesh is in the active list
  2276. */
  2277. isActiveMesh(mesh: AbstractMesh): boolean;
  2278. /**
  2279. * Return a unique id as a string which can serve as an identifier for the scene
  2280. */
  2281. readonly uid: string;
  2282. /**
  2283. * Add an externaly attached data from its key.
  2284. * This method call will fail and return false, if such key already exists.
  2285. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2286. * @param key the unique key that identifies the data
  2287. * @param data the data object to associate to the key for this Engine instance
  2288. * @return true if no such key were already present and the data was added successfully, false otherwise
  2289. */
  2290. addExternalData<T>(key: string, data: T): boolean;
  2291. /**
  2292. * Get an externaly attached data from its key
  2293. * @param key the unique key that identifies the data
  2294. * @return the associated data, if present (can be null), or undefined if not present
  2295. */
  2296. getExternalData<T>(key: string): Nullable<T>;
  2297. /**
  2298. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2299. * @param key the unique key that identifies the data
  2300. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2301. * @return the associated data, can be null if the factory returned null.
  2302. */
  2303. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2304. /**
  2305. * Remove an externaly attached data from the Engine instance
  2306. * @param key the unique key that identifies the data
  2307. * @return true if the data was successfully removed, false if it doesn't exist
  2308. */
  2309. removeExternalData(key: string): boolean;
  2310. private _evaluateSubMesh;
  2311. /**
  2312. * Clear the processed materials smart array preventing retention point in material dispose.
  2313. */
  2314. freeProcessedMaterials(): void;
  2315. private _preventFreeActiveMeshesAndRenderingGroups;
  2316. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2317. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2318. * when disposing several meshes in a row or a hierarchy of meshes.
  2319. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2320. */
  2321. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2322. /**
  2323. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2324. */
  2325. freeActiveMeshes(): void;
  2326. /**
  2327. * Clear the info related to rendering groups preventing retention points during dispose.
  2328. */
  2329. freeRenderingGroups(): void;
  2330. /** @hidden */
  2331. _isInIntermediateRendering(): boolean;
  2332. /**
  2333. * Lambda returning the list of potentially active meshes.
  2334. */
  2335. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2336. /**
  2337. * Lambda returning the list of potentially active sub meshes.
  2338. */
  2339. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2340. /**
  2341. * Lambda returning the list of potentially intersecting sub meshes.
  2342. */
  2343. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2344. /**
  2345. * Lambda returning the list of potentially colliding sub meshes.
  2346. */
  2347. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2348. private _activeMeshesFrozen;
  2349. /**
  2350. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2351. * @returns the current scene
  2352. */
  2353. freezeActiveMeshes(): Scene;
  2354. /**
  2355. * Use this function to restart evaluating active meshes on every frame
  2356. * @returns the current scene
  2357. */
  2358. unfreezeActiveMeshes(): Scene;
  2359. private _evaluateActiveMeshes;
  2360. private _activeMesh;
  2361. /**
  2362. * Update the transform matrix to update from the current active camera
  2363. * @param force defines a boolean used to force the update even if cache is up to date
  2364. */
  2365. updateTransformMatrix(force?: boolean): void;
  2366. /**
  2367. * 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)
  2368. * @param alternateCamera defines the camera to use
  2369. */
  2370. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2371. /** @hidden */
  2372. _allowPostProcessClearColor: boolean;
  2373. private _renderForCamera;
  2374. private _processSubCameras;
  2375. private _checkIntersections;
  2376. /** @hidden */
  2377. _advancePhysicsEngineStep(step: number): void;
  2378. /**
  2379. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2380. */
  2381. getDeterministicFrameTime: () => number;
  2382. /**
  2383. * Render the scene
  2384. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2385. */
  2386. render(updateCameras?: boolean): void;
  2387. /**
  2388. * Freeze all materials
  2389. * A frozen material will not be updatable but should be faster to render
  2390. */
  2391. freezeMaterials(): void;
  2392. /**
  2393. * Unfreeze all materials
  2394. * A frozen material will not be updatable but should be faster to render
  2395. */
  2396. unfreezeMaterials(): void;
  2397. /**
  2398. * Releases all held ressources
  2399. */
  2400. dispose(): void;
  2401. /**
  2402. * Gets if the scene is already disposed
  2403. */
  2404. readonly isDisposed: boolean;
  2405. /**
  2406. * Call this function to reduce memory footprint of the scene.
  2407. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2408. */
  2409. clearCachedVertexData(): void;
  2410. /**
  2411. * This function will remove the local cached buffer data from texture.
  2412. * It will save memory but will prevent the texture from being rebuilt
  2413. */
  2414. cleanCachedTextureBuffer(): void;
  2415. /**
  2416. * Get the world extend vectors with an optional filter
  2417. *
  2418. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2419. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2420. */
  2421. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2422. min: Vector3;
  2423. max: Vector3;
  2424. };
  2425. /**
  2426. * Creates a ray that can be used to pick in the scene
  2427. * @param x defines the x coordinate of the origin (on-screen)
  2428. * @param y defines the y coordinate of the origin (on-screen)
  2429. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2430. * @param camera defines the camera to use for the picking
  2431. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2432. * @returns a Ray
  2433. */
  2434. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2435. /**
  2436. * Creates a ray that can be used to pick in the scene
  2437. * @param x defines the x coordinate of the origin (on-screen)
  2438. * @param y defines the y coordinate of the origin (on-screen)
  2439. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2440. * @param result defines the ray where to store the picking ray
  2441. * @param camera defines the camera to use for the picking
  2442. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2443. * @returns the current scene
  2444. */
  2445. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2446. /**
  2447. * Creates a ray that can be used to pick in the scene
  2448. * @param x defines the x coordinate of the origin (on-screen)
  2449. * @param y defines the y coordinate of the origin (on-screen)
  2450. * @param camera defines the camera to use for the picking
  2451. * @returns a Ray
  2452. */
  2453. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2454. /**
  2455. * Creates a ray that can be used to pick in the scene
  2456. * @param x defines the x coordinate of the origin (on-screen)
  2457. * @param y defines the y coordinate of the origin (on-screen)
  2458. * @param result defines the ray where to store the picking ray
  2459. * @param camera defines the camera to use for the picking
  2460. * @returns the current scene
  2461. */
  2462. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2463. private _internalPick;
  2464. private _internalMultiPick;
  2465. private _tempPickingRay;
  2466. /** Launch a ray to try to pick a mesh in the scene
  2467. * @param x position on screen
  2468. * @param y position on screen
  2469. * @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
  2470. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2471. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2472. * @returns a PickingInfo
  2473. */
  2474. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2475. private _cachedRayForTransform;
  2476. /** Use the given ray to pick a mesh in the scene
  2477. * @param ray The ray to use to pick meshes
  2478. * @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
  2479. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2480. * @returns a PickingInfo
  2481. */
  2482. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2483. /**
  2484. * Launch a ray to try to pick a mesh in the scene
  2485. * @param x X position on screen
  2486. * @param y Y position on screen
  2487. * @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
  2488. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2489. * @returns an array of PickingInfo
  2490. */
  2491. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2492. /**
  2493. * Launch a ray to try to pick a mesh in the scene
  2494. * @param ray Ray to use
  2495. * @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
  2496. * @returns an array of PickingInfo
  2497. */
  2498. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2499. /**
  2500. * Force the value of meshUnderPointer
  2501. * @param mesh defines the mesh to use
  2502. */
  2503. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2504. /**
  2505. * Gets the mesh under the pointer
  2506. * @returns a Mesh or null if no mesh is under the pointer
  2507. */
  2508. getPointerOverMesh(): Nullable<AbstractMesh>;
  2509. /** @hidden */
  2510. _rebuildGeometries(): void;
  2511. /** @hidden */
  2512. _rebuildTextures(): void;
  2513. private _getByTags;
  2514. /**
  2515. * Get a list of meshes by tags
  2516. * @param tagsQuery defines the tags query to use
  2517. * @param forEach defines a predicate used to filter results
  2518. * @returns an array of Mesh
  2519. */
  2520. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2521. /**
  2522. * Get a list of cameras by tags
  2523. * @param tagsQuery defines the tags query to use
  2524. * @param forEach defines a predicate used to filter results
  2525. * @returns an array of Camera
  2526. */
  2527. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2528. /**
  2529. * Get a list of lights by tags
  2530. * @param tagsQuery defines the tags query to use
  2531. * @param forEach defines a predicate used to filter results
  2532. * @returns an array of Light
  2533. */
  2534. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2535. /**
  2536. * Get a list of materials by tags
  2537. * @param tagsQuery defines the tags query to use
  2538. * @param forEach defines a predicate used to filter results
  2539. * @returns an array of Material
  2540. */
  2541. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2542. /**
  2543. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2544. * This allowed control for front to back rendering or reversly depending of the special needs.
  2545. *
  2546. * @param renderingGroupId The rendering group id corresponding to its index
  2547. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2548. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2549. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2550. */
  2551. 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;
  2552. /**
  2553. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2554. *
  2555. * @param renderingGroupId The rendering group id corresponding to its index
  2556. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2557. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2558. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2559. */
  2560. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2561. /**
  2562. * Gets the current auto clear configuration for one rendering group of the rendering
  2563. * manager.
  2564. * @param index the rendering group index to get the information for
  2565. * @returns The auto clear setup for the requested rendering group
  2566. */
  2567. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2568. private _blockMaterialDirtyMechanism;
  2569. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2570. blockMaterialDirtyMechanism: boolean;
  2571. /**
  2572. * Will flag all materials as dirty to trigger new shader compilation
  2573. * @param flag defines the flag used to specify which material part must be marked as dirty
  2574. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2575. */
  2576. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2577. /** @hidden */
  2578. _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;
  2579. /** @hidden */
  2580. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2581. }
  2582. }
  2583. declare module BABYLON {
  2584. /**
  2585. * Groups all the scene component constants in one place to ease maintenance.
  2586. * @hidden
  2587. */
  2588. class SceneComponentConstants {
  2589. static readonly NAME_EFFECTLAYER: string;
  2590. static readonly NAME_LAYER: string;
  2591. static readonly NAME_LENSFLARESYSTEM: string;
  2592. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2593. static readonly NAME_PARTICLESYSTEM: string;
  2594. static readonly NAME_GAMEPAD: string;
  2595. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2596. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2597. static readonly NAME_DEPTHRENDERER: string;
  2598. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2599. static readonly NAME_SPRITE: string;
  2600. static readonly NAME_OUTLINERENDERER: string;
  2601. static readonly NAME_PROCEDURALTEXTURE: string;
  2602. static readonly NAME_SHADOWGENERATOR: string;
  2603. static readonly NAME_OCTREE: string;
  2604. static readonly NAME_PHYSICSENGINE: string;
  2605. static readonly NAME_AUDIO: string;
  2606. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2607. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2608. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2609. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2610. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2611. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2612. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2613. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  2614. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2615. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2616. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2617. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2618. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2619. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2620. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2621. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  2622. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2623. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2624. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2625. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2626. static readonly STEP_AFTERRENDER_AUDIO: number;
  2627. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2628. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2629. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2630. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2631. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2632. static readonly STEP_POINTERMOVE_SPRITE: number;
  2633. static readonly STEP_POINTERDOWN_SPRITE: number;
  2634. static readonly STEP_POINTERUP_SPRITE: number;
  2635. }
  2636. /**
  2637. * This represents a scene component.
  2638. *
  2639. * This is used to decouple the dependency the scene is having on the different workloads like
  2640. * layers, post processes...
  2641. */
  2642. interface ISceneComponent {
  2643. /**
  2644. * The name of the component. Each component must have a unique name.
  2645. */
  2646. name: string;
  2647. /**
  2648. * The scene the component belongs to.
  2649. */
  2650. scene: Scene;
  2651. /**
  2652. * Register the component to one instance of a scene.
  2653. */
  2654. register(): void;
  2655. /**
  2656. * Rebuilds the elements related to this component in case of
  2657. * context lost for instance.
  2658. */
  2659. rebuild(): void;
  2660. /**
  2661. * Disposes the component and the associated ressources.
  2662. */
  2663. dispose(): void;
  2664. }
  2665. /**
  2666. * This represents a SERIALIZABLE scene component.
  2667. *
  2668. * This extends Scene Component to add Serialization methods on top.
  2669. */
  2670. interface ISceneSerializableComponent extends ISceneComponent {
  2671. /**
  2672. * Adds all the element from the container to the scene
  2673. * @param container the container holding the elements
  2674. */
  2675. addFromContainer(container: AbstractScene): void;
  2676. /**
  2677. * Removes all the elements in the container from the scene
  2678. * @param container contains the elements to remove
  2679. */
  2680. removeFromContainer(container: AbstractScene): void;
  2681. /**
  2682. * Serializes the component data to the specified json object
  2683. * @param serializationObject The object to serialize to
  2684. */
  2685. serialize(serializationObject: any): void;
  2686. }
  2687. /**
  2688. * Strong typing of a Mesh related stage step action
  2689. */
  2690. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2691. /**
  2692. * Strong typing of a Evaluate Sub Mesh related stage step action
  2693. */
  2694. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2695. /**
  2696. * Strong typing of a Active Mesh related stage step action
  2697. */
  2698. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2699. /**
  2700. * Strong typing of a Camera related stage step action
  2701. */
  2702. type CameraStageAction = (camera: Camera) => void;
  2703. /**
  2704. * Strong typing of a Render Target related stage step action
  2705. */
  2706. type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  2707. /**
  2708. * Strong typing of a RenderingGroup related stage step action
  2709. */
  2710. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2711. /**
  2712. * Strong typing of a Mesh Render related stage step action
  2713. */
  2714. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2715. /**
  2716. * Strong typing of a simple stage step action
  2717. */
  2718. type SimpleStageAction = () => void;
  2719. /**
  2720. * Strong typing of a render target action.
  2721. */
  2722. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2723. /**
  2724. * Strong typing of a pointer move action.
  2725. */
  2726. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2727. /**
  2728. * Strong typing of a pointer up/down action.
  2729. */
  2730. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2731. /**
  2732. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2733. * @hidden
  2734. */
  2735. class Stage<T extends Function> extends Array<{
  2736. index: number;
  2737. component: ISceneComponent;
  2738. action: T;
  2739. }> {
  2740. /**
  2741. * Hide ctor from the rest of the world.
  2742. * @param items The items to add.
  2743. */
  2744. private constructor();
  2745. /**
  2746. * Creates a new Stage.
  2747. * @returns A new instance of a Stage
  2748. */
  2749. static Create<T extends Function>(): Stage<T>;
  2750. /**
  2751. * Registers a step in an ordered way in the targeted stage.
  2752. * @param index Defines the position to register the step in
  2753. * @param component Defines the component attached to the step
  2754. * @param action Defines the action to launch during the step
  2755. */
  2756. registerStep(index: number, component: ISceneComponent, action: T): void;
  2757. /**
  2758. * Clears all the steps from the stage.
  2759. */
  2760. clear(): void;
  2761. }
  2762. }
  2763. declare module BABYLON {
  2764. /** Alias type for value that can be null */
  2765. type Nullable<T> = T | null;
  2766. /**
  2767. * Alias type for number that are floats
  2768. * @ignorenaming
  2769. */
  2770. type float = number;
  2771. /**
  2772. * Alias type for number that are doubles.
  2773. * @ignorenaming
  2774. */
  2775. type double = number;
  2776. /**
  2777. * Alias type for number that are integer
  2778. * @ignorenaming
  2779. */
  2780. type int = number;
  2781. /** Alias type for number array or Float32Array */
  2782. type FloatArray = number[] | Float32Array;
  2783. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2784. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2785. /**
  2786. * Alias for types that can be used by a Buffer or VertexBuffer.
  2787. */
  2788. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2789. /**
  2790. * Alias type for primitive types
  2791. * @ignorenaming
  2792. */
  2793. type Primitive = undefined | null | boolean | string | number | Function;
  2794. /**
  2795. * Type modifier to make all the properties of an object Readonly
  2796. */
  2797. type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  2798. /**
  2799. * Type modifier to make all the properties of an object Readonly recursively
  2800. */
  2801. type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  2802. /** @hidden */
  2803. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  2804. }
  2805. /** @hidden */
  2806. /** @hidden */
  2807. type DeepImmutableObject<T> = {
  2808. readonly [K in keyof T]: DeepImmutable<T[K]>;
  2809. };
  2810. }
  2811. declare module BABYLON {
  2812. /**
  2813. * The action to be carried out following a trigger
  2814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2815. */
  2816. class Action {
  2817. /** the trigger, with or without parameters, for the action */
  2818. triggerOptions: any;
  2819. /**
  2820. * Trigger for the action
  2821. */
  2822. trigger: number;
  2823. /**
  2824. * Internal only - manager for action
  2825. * @hidden
  2826. */
  2827. _actionManager: ActionManager;
  2828. private _nextActiveAction;
  2829. private _child;
  2830. private _condition?;
  2831. private _triggerParameter;
  2832. /**
  2833. * An event triggered prior to action being executed.
  2834. */
  2835. onBeforeExecuteObservable: Observable<Action>;
  2836. /**
  2837. * Creates a new Action
  2838. * @param triggerOptions the trigger, with or without parameters, for the action
  2839. * @param condition an optional determinant of action
  2840. */
  2841. constructor(
  2842. /** the trigger, with or without parameters, for the action */
  2843. triggerOptions: any, condition?: Condition);
  2844. /**
  2845. * Internal only
  2846. * @hidden
  2847. */
  2848. _prepare(): void;
  2849. /**
  2850. * Gets the trigger parameters
  2851. * @returns the trigger parameters
  2852. */
  2853. getTriggerParameter(): any;
  2854. /**
  2855. * Internal only - executes current action event
  2856. * @hidden
  2857. */
  2858. _executeCurrent(evt?: ActionEvent): void;
  2859. /**
  2860. * Execute placeholder for child classes
  2861. * @param evt optional action event
  2862. */
  2863. execute(evt?: ActionEvent): void;
  2864. /**
  2865. * Skips to next active action
  2866. */
  2867. skipToNextActiveAction(): void;
  2868. /**
  2869. * Adds action to chain of actions, may be a DoNothingAction
  2870. * @param action defines the next action to execute
  2871. * @returns The action passed in
  2872. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2873. */
  2874. then(action: Action): Action;
  2875. /**
  2876. * Internal only
  2877. * @hidden
  2878. */
  2879. _getProperty(propertyPath: string): string;
  2880. /**
  2881. * Internal only
  2882. * @hidden
  2883. */
  2884. _getEffectiveTarget(target: any, propertyPath: string): any;
  2885. /**
  2886. * Serialize placeholder for child classes
  2887. * @param parent of child
  2888. * @returns the serialized object
  2889. */
  2890. serialize(parent: any): any;
  2891. /**
  2892. * Internal only called by serialize
  2893. * @hidden
  2894. */
  2895. protected _serialize(serializedAction: any, parent?: any): any;
  2896. /**
  2897. * Internal only
  2898. * @hidden
  2899. */
  2900. static _SerializeValueAsString: (value: any) => string;
  2901. /**
  2902. * Internal only
  2903. * @hidden
  2904. */
  2905. static _GetTargetProperty: (target: Scene | Node) => {
  2906. name: string;
  2907. targetType: string;
  2908. value: string;
  2909. };
  2910. }
  2911. }
  2912. declare module BABYLON {
  2913. /**
  2914. * ActionEvent is the event being sent when an action is triggered.
  2915. */
  2916. class ActionEvent {
  2917. /** The mesh or sprite that triggered the action */
  2918. source: any;
  2919. /** The X mouse cursor position at the time of the event */
  2920. pointerX: number;
  2921. /** The Y mouse cursor position at the time of the event */
  2922. pointerY: number;
  2923. /** The mesh that is currently pointed at (can be null) */
  2924. meshUnderPointer: Nullable<AbstractMesh>;
  2925. /** the original (browser) event that triggered the ActionEvent */
  2926. sourceEvent?: any;
  2927. /** additional data for the event */
  2928. additionalData?: any;
  2929. /**
  2930. * Creates a new ActionEvent
  2931. * @param source The mesh or sprite that triggered the action
  2932. * @param pointerX The X mouse cursor position at the time of the event
  2933. * @param pointerY The Y mouse cursor position at the time of the event
  2934. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2935. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2936. * @param additionalData additional data for the event
  2937. */
  2938. constructor(
  2939. /** The mesh or sprite that triggered the action */
  2940. source: any,
  2941. /** The X mouse cursor position at the time of the event */
  2942. pointerX: number,
  2943. /** The Y mouse cursor position at the time of the event */
  2944. pointerY: number,
  2945. /** The mesh that is currently pointed at (can be null) */
  2946. meshUnderPointer: Nullable<AbstractMesh>,
  2947. /** the original (browser) event that triggered the ActionEvent */
  2948. sourceEvent?: any,
  2949. /** additional data for the event */
  2950. additionalData?: any);
  2951. /**
  2952. * Helper function to auto-create an ActionEvent from a source mesh.
  2953. * @param source The source mesh that triggered the event
  2954. * @param evt The original (browser) event
  2955. * @param additionalData additional data for the event
  2956. * @returns the new ActionEvent
  2957. */
  2958. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2959. /**
  2960. * Helper function to auto-create an ActionEvent from a source sprite
  2961. * @param source The source sprite that triggered the event
  2962. * @param scene Scene associated with the sprite
  2963. * @param evt The original (browser) event
  2964. * @param additionalData additional data for the event
  2965. * @returns the new ActionEvent
  2966. */
  2967. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2968. /**
  2969. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2970. * @param scene the scene where the event occurred
  2971. * @param evt The original (browser) event
  2972. * @returns the new ActionEvent
  2973. */
  2974. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2975. /**
  2976. * Helper function to auto-create an ActionEvent from a primitive
  2977. * @param prim defines the target primitive
  2978. * @param pointerPos defines the pointer position
  2979. * @param evt The original (browser) event
  2980. * @param additionalData additional data for the event
  2981. * @returns the new ActionEvent
  2982. */
  2983. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2984. }
  2985. /**
  2986. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2987. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2989. */
  2990. class ActionManager {
  2991. /**
  2992. * Nothing
  2993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2994. */
  2995. static readonly NothingTrigger: number;
  2996. /**
  2997. * On pick
  2998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2999. */
  3000. static readonly OnPickTrigger: number;
  3001. /**
  3002. * On left pick
  3003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3004. */
  3005. static readonly OnLeftPickTrigger: number;
  3006. /**
  3007. * On right pick
  3008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3009. */
  3010. static readonly OnRightPickTrigger: number;
  3011. /**
  3012. * On center pick
  3013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3014. */
  3015. static readonly OnCenterPickTrigger: number;
  3016. /**
  3017. * On pick down
  3018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3019. */
  3020. static readonly OnPickDownTrigger: number;
  3021. /**
  3022. * On double pick
  3023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3024. */
  3025. static readonly OnDoublePickTrigger: number;
  3026. /**
  3027. * On pick up
  3028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3029. */
  3030. static readonly OnPickUpTrigger: number;
  3031. /**
  3032. * On pick out.
  3033. * This trigger will only be raised if you also declared a OnPickDown
  3034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3035. */
  3036. static readonly OnPickOutTrigger: number;
  3037. /**
  3038. * On long press
  3039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3040. */
  3041. static readonly OnLongPressTrigger: number;
  3042. /**
  3043. * On pointer over
  3044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3045. */
  3046. static readonly OnPointerOverTrigger: number;
  3047. /**
  3048. * On pointer out
  3049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3050. */
  3051. static readonly OnPointerOutTrigger: number;
  3052. /**
  3053. * On every frame
  3054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3055. */
  3056. static readonly OnEveryFrameTrigger: number;
  3057. /**
  3058. * On intersection enter
  3059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3060. */
  3061. static readonly OnIntersectionEnterTrigger: number;
  3062. /**
  3063. * On intersection exit
  3064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3065. */
  3066. static readonly OnIntersectionExitTrigger: number;
  3067. /**
  3068. * On key down
  3069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3070. */
  3071. static readonly OnKeyDownTrigger: number;
  3072. /**
  3073. * On key up
  3074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3075. */
  3076. static readonly OnKeyUpTrigger: number;
  3077. /** Gets the list of active triggers */
  3078. static Triggers: {
  3079. [key: string]: number;
  3080. };
  3081. /** Gets the list of actions */
  3082. actions: Action[];
  3083. /** Gets the cursor to use when hovering items */
  3084. hoverCursor: string;
  3085. private _scene;
  3086. /**
  3087. * Creates a new action manager
  3088. * @param scene defines the hosting scene
  3089. */
  3090. constructor(scene: Scene);
  3091. /**
  3092. * Releases all associated resources
  3093. */
  3094. dispose(): void;
  3095. /**
  3096. * Gets hosting scene
  3097. * @returns the hosting scene
  3098. */
  3099. getScene(): Scene;
  3100. /**
  3101. * Does this action manager handles actions of any of the given triggers
  3102. * @param triggers defines the triggers to be tested
  3103. * @return a boolean indicating whether one (or more) of the triggers is handled
  3104. */
  3105. hasSpecificTriggers(triggers: number[]): boolean;
  3106. /**
  3107. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3108. * speed.
  3109. * @param triggerA defines the trigger to be tested
  3110. * @param triggerB defines the trigger to be tested
  3111. * @return a boolean indicating whether one (or more) of the triggers is handled
  3112. */
  3113. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3114. /**
  3115. * Does this action manager handles actions of a given trigger
  3116. * @param trigger defines the trigger to be tested
  3117. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3118. * @return whether the trigger is handled
  3119. */
  3120. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3121. /**
  3122. * Does this action manager has pointer triggers
  3123. */
  3124. readonly hasPointerTriggers: boolean;
  3125. /**
  3126. * Does this action manager has pick triggers
  3127. */
  3128. readonly hasPickTriggers: boolean;
  3129. /**
  3130. * Does exist one action manager with at least one trigger
  3131. **/
  3132. static readonly HasTriggers: boolean;
  3133. /**
  3134. * Does exist one action manager with at least one pick trigger
  3135. **/
  3136. static readonly HasPickTriggers: boolean;
  3137. /**
  3138. * Does exist one action manager that handles actions of a given trigger
  3139. * @param trigger defines the trigger to be tested
  3140. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3141. **/
  3142. static HasSpecificTrigger(trigger: number): boolean;
  3143. /**
  3144. * Registers an action to this action manager
  3145. * @param action defines the action to be registered
  3146. * @return the action amended (prepared) after registration
  3147. */
  3148. registerAction(action: Action): Nullable<Action>;
  3149. /**
  3150. * Unregisters an action to this action manager
  3151. * @param action defines the action to be unregistered
  3152. * @return a boolean indicating whether the action has been unregistered
  3153. */
  3154. unregisterAction(action: Action): Boolean;
  3155. /**
  3156. * Process a specific trigger
  3157. * @param trigger defines the trigger to process
  3158. * @param evt defines the event details to be processed
  3159. */
  3160. processTrigger(trigger: number, evt?: ActionEvent): void;
  3161. /** @hidden */
  3162. _getEffectiveTarget(target: any, propertyPath: string): any;
  3163. /** @hidden */
  3164. _getProperty(propertyPath: string): string;
  3165. /**
  3166. * Serialize this manager to a JSON object
  3167. * @param name defines the property name to store this manager
  3168. * @returns a JSON representation of this manager
  3169. */
  3170. serialize(name: string): any;
  3171. /**
  3172. * Creates a new ActionManager from a JSON data
  3173. * @param parsedActions defines the JSON data to read from
  3174. * @param object defines the hosting mesh
  3175. * @param scene defines the hosting scene
  3176. */
  3177. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3178. /**
  3179. * Get a trigger name by index
  3180. * @param trigger defines the trigger index
  3181. * @returns a trigger name
  3182. */
  3183. static GetTriggerName(trigger: number): string;
  3184. }
  3185. }
  3186. declare module BABYLON {
  3187. /**
  3188. * A Condition applied to an Action
  3189. */
  3190. class Condition {
  3191. /**
  3192. * Internal only - manager for action
  3193. * @hidden
  3194. */
  3195. _actionManager: ActionManager;
  3196. /**
  3197. * Internal only
  3198. * @hidden
  3199. */
  3200. _evaluationId: number;
  3201. /**
  3202. * Internal only
  3203. * @hidden
  3204. */
  3205. _currentResult: boolean;
  3206. /**
  3207. * Creates a new Condition
  3208. * @param actionManager the manager of the action the condition is applied to
  3209. */
  3210. constructor(actionManager: ActionManager);
  3211. /**
  3212. * Check if the current condition is valid
  3213. * @returns a boolean
  3214. */
  3215. isValid(): boolean;
  3216. /**
  3217. * Internal only
  3218. * @hidden
  3219. */
  3220. _getProperty(propertyPath: string): string;
  3221. /**
  3222. * Internal only
  3223. * @hidden
  3224. */
  3225. _getEffectiveTarget(target: any, propertyPath: string): any;
  3226. /**
  3227. * Serialize placeholder for child classes
  3228. * @returns the serialized object
  3229. */
  3230. serialize(): any;
  3231. /**
  3232. * Internal only
  3233. * @hidden
  3234. */
  3235. protected _serialize(serializedCondition: any): any;
  3236. }
  3237. /**
  3238. * Defines specific conditional operators as extensions of Condition
  3239. */
  3240. class ValueCondition extends Condition {
  3241. /** path to specify the property of the target the conditional operator uses */
  3242. propertyPath: string;
  3243. /** the value compared by the conditional operator against the current value of the property */
  3244. value: any;
  3245. /** the conditional operator, default ValueCondition.IsEqual */
  3246. operator: number;
  3247. /**
  3248. * Internal only
  3249. * @hidden
  3250. */
  3251. private static _IsEqual;
  3252. /**
  3253. * Internal only
  3254. * @hidden
  3255. */
  3256. private static _IsDifferent;
  3257. /**
  3258. * Internal only
  3259. * @hidden
  3260. */
  3261. private static _IsGreater;
  3262. /**
  3263. * Internal only
  3264. * @hidden
  3265. */
  3266. private static _IsLesser;
  3267. /**
  3268. * returns the number for IsEqual
  3269. */
  3270. static readonly IsEqual: number;
  3271. /**
  3272. * Returns the number for IsDifferent
  3273. */
  3274. static readonly IsDifferent: number;
  3275. /**
  3276. * Returns the number for IsGreater
  3277. */
  3278. static readonly IsGreater: number;
  3279. /**
  3280. * Returns the number for IsLesser
  3281. */
  3282. static readonly IsLesser: number;
  3283. /**
  3284. * Internal only The action manager for the condition
  3285. * @hidden
  3286. */
  3287. _actionManager: ActionManager;
  3288. /**
  3289. * Internal only
  3290. * @hidden
  3291. */
  3292. private _target;
  3293. /**
  3294. * Internal only
  3295. * @hidden
  3296. */
  3297. private _effectiveTarget;
  3298. /**
  3299. * Internal only
  3300. * @hidden
  3301. */
  3302. private _property;
  3303. /**
  3304. * Creates a new ValueCondition
  3305. * @param actionManager manager for the action the condition applies to
  3306. * @param target for the action
  3307. * @param propertyPath path to specify the property of the target the conditional operator uses
  3308. * @param value the value compared by the conditional operator against the current value of the property
  3309. * @param operator the conditional operator, default ValueCondition.IsEqual
  3310. */
  3311. constructor(actionManager: ActionManager, target: any,
  3312. /** path to specify the property of the target the conditional operator uses */
  3313. propertyPath: string,
  3314. /** the value compared by the conditional operator against the current value of the property */
  3315. value: any,
  3316. /** the conditional operator, default ValueCondition.IsEqual */
  3317. operator?: number);
  3318. /**
  3319. * Compares the given value with the property value for the specified conditional operator
  3320. * @returns the result of the comparison
  3321. */
  3322. isValid(): boolean;
  3323. /**
  3324. * Serialize the ValueCondition into a JSON compatible object
  3325. * @returns serialization object
  3326. */
  3327. serialize(): any;
  3328. /**
  3329. * Gets the name of the conditional operator for the ValueCondition
  3330. * @param operator the conditional operator
  3331. * @returns the name
  3332. */
  3333. static GetOperatorName(operator: number): string;
  3334. }
  3335. /**
  3336. * Defines a predicate condition as an extension of Condition
  3337. */
  3338. class PredicateCondition extends Condition {
  3339. /** defines the predicate function used to validate the condition */
  3340. predicate: () => boolean;
  3341. /**
  3342. * Internal only - manager for action
  3343. * @hidden
  3344. */
  3345. _actionManager: ActionManager;
  3346. /**
  3347. * Creates a new PredicateCondition
  3348. * @param actionManager manager for the action the condition applies to
  3349. * @param predicate defines the predicate function used to validate the condition
  3350. */
  3351. constructor(actionManager: ActionManager,
  3352. /** defines the predicate function used to validate the condition */
  3353. predicate: () => boolean);
  3354. /**
  3355. * @returns the validity of the predicate condition
  3356. */
  3357. isValid(): boolean;
  3358. }
  3359. /**
  3360. * Defines a state condition as an extension of Condition
  3361. */
  3362. class StateCondition extends Condition {
  3363. /** Value to compare with target state */
  3364. value: string;
  3365. /**
  3366. * Internal only - manager for action
  3367. * @hidden
  3368. */
  3369. _actionManager: ActionManager;
  3370. /**
  3371. * Internal only
  3372. * @hidden
  3373. */
  3374. private _target;
  3375. /**
  3376. * Creates a new StateCondition
  3377. * @param actionManager manager for the action the condition applies to
  3378. * @param target of the condition
  3379. * @param value to compare with target state
  3380. */
  3381. constructor(actionManager: ActionManager, target: any,
  3382. /** Value to compare with target state */
  3383. value: string);
  3384. /**
  3385. * Gets a boolean indicating if the current condition is met
  3386. * @returns the validity of the state
  3387. */
  3388. isValid(): boolean;
  3389. /**
  3390. * Serialize the StateCondition into a JSON compatible object
  3391. * @returns serialization object
  3392. */
  3393. serialize(): any;
  3394. }
  3395. }
  3396. declare module BABYLON {
  3397. /**
  3398. * This defines an action responsible to toggle a boolean once triggered.
  3399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3400. */
  3401. class SwitchBooleanAction extends Action {
  3402. /**
  3403. * The path to the boolean property in the target object
  3404. */
  3405. propertyPath: string;
  3406. private _target;
  3407. private _effectiveTarget;
  3408. private _property;
  3409. /**
  3410. * Instantiate the action
  3411. * @param triggerOptions defines the trigger options
  3412. * @param target defines the object containing the boolean
  3413. * @param propertyPath defines the path to the boolean property in the target object
  3414. * @param condition defines the trigger related conditions
  3415. */
  3416. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3417. /** @hidden */
  3418. _prepare(): void;
  3419. /**
  3420. * Execute the action toggle the boolean value.
  3421. */
  3422. execute(): void;
  3423. /**
  3424. * Serializes the actions and its related information.
  3425. * @param parent defines the object to serialize in
  3426. * @returns the serialized object
  3427. */
  3428. serialize(parent: any): any;
  3429. }
  3430. /**
  3431. * This defines an action responsible to set a the state field of the target
  3432. * to a desired value once triggered.
  3433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3434. */
  3435. class SetStateAction extends Action {
  3436. /**
  3437. * The value to store in the state field.
  3438. */
  3439. value: string;
  3440. private _target;
  3441. /**
  3442. * Instantiate the action
  3443. * @param triggerOptions defines the trigger options
  3444. * @param target defines the object containing the state property
  3445. * @param value defines the value to store in the state field
  3446. * @param condition defines the trigger related conditions
  3447. */
  3448. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3449. /**
  3450. * Execute the action and store the value on the target state property.
  3451. */
  3452. execute(): void;
  3453. /**
  3454. * Serializes the actions and its related information.
  3455. * @param parent defines the object to serialize in
  3456. * @returns the serialized object
  3457. */
  3458. serialize(parent: any): any;
  3459. }
  3460. /**
  3461. * This defines an action responsible to set a property of the target
  3462. * to a desired value once triggered.
  3463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3464. */
  3465. class SetValueAction extends Action {
  3466. /**
  3467. * The path of the property to set in the target.
  3468. */
  3469. propertyPath: string;
  3470. /**
  3471. * The value to set in the property
  3472. */
  3473. value: any;
  3474. private _target;
  3475. private _effectiveTarget;
  3476. private _property;
  3477. /**
  3478. * Instantiate the action
  3479. * @param triggerOptions defines the trigger options
  3480. * @param target defines the object containing the property
  3481. * @param propertyPath defines the path of the property to set in the target
  3482. * @param value defines the value to set in the property
  3483. * @param condition defines the trigger related conditions
  3484. */
  3485. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3486. /** @hidden */
  3487. _prepare(): void;
  3488. /**
  3489. * Execute the action and set the targetted property to the desired value.
  3490. */
  3491. execute(): void;
  3492. /**
  3493. * Serializes the actions and its related information.
  3494. * @param parent defines the object to serialize in
  3495. * @returns the serialized object
  3496. */
  3497. serialize(parent: any): any;
  3498. }
  3499. /**
  3500. * This defines an action responsible to increment the target value
  3501. * to a desired value once triggered.
  3502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3503. */
  3504. class IncrementValueAction extends Action {
  3505. /**
  3506. * The path of the property to increment in the target.
  3507. */
  3508. propertyPath: string;
  3509. /**
  3510. * The value we should increment the property by.
  3511. */
  3512. value: any;
  3513. private _target;
  3514. private _effectiveTarget;
  3515. private _property;
  3516. /**
  3517. * Instantiate the action
  3518. * @param triggerOptions defines the trigger options
  3519. * @param target defines the object containing the property
  3520. * @param propertyPath defines the path of the property to increment in the target
  3521. * @param value defines the value value we should increment the property by
  3522. * @param condition defines the trigger related conditions
  3523. */
  3524. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3525. /** @hidden */
  3526. _prepare(): void;
  3527. /**
  3528. * Execute the action and increment the target of the value amount.
  3529. */
  3530. execute(): void;
  3531. /**
  3532. * Serializes the actions and its related information.
  3533. * @param parent defines the object to serialize in
  3534. * @returns the serialized object
  3535. */
  3536. serialize(parent: any): any;
  3537. }
  3538. /**
  3539. * This defines an action responsible to start an animation once triggered.
  3540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3541. */
  3542. class PlayAnimationAction extends Action {
  3543. /**
  3544. * Where the animation should start (animation frame)
  3545. */
  3546. from: number;
  3547. /**
  3548. * Where the animation should stop (animation frame)
  3549. */
  3550. to: number;
  3551. /**
  3552. * Define if the animation should loop or stop after the first play.
  3553. */
  3554. loop?: boolean;
  3555. private _target;
  3556. /**
  3557. * Instantiate the action
  3558. * @param triggerOptions defines the trigger options
  3559. * @param target defines the target animation or animation name
  3560. * @param from defines from where the animation should start (animation frame)
  3561. * @param end defines where the animation should stop (animation frame)
  3562. * @param loop defines if the animation should loop or stop after the first play
  3563. * @param condition defines the trigger related conditions
  3564. */
  3565. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3566. /** @hidden */
  3567. _prepare(): void;
  3568. /**
  3569. * Execute the action and play the animation.
  3570. */
  3571. execute(): void;
  3572. /**
  3573. * Serializes the actions and its related information.
  3574. * @param parent defines the object to serialize in
  3575. * @returns the serialized object
  3576. */
  3577. serialize(parent: any): any;
  3578. }
  3579. /**
  3580. * This defines an action responsible to stop an animation once triggered.
  3581. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3582. */
  3583. class StopAnimationAction extends Action {
  3584. private _target;
  3585. /**
  3586. * Instantiate the action
  3587. * @param triggerOptions defines the trigger options
  3588. * @param target defines the target animation or animation name
  3589. * @param condition defines the trigger related conditions
  3590. */
  3591. constructor(triggerOptions: any, target: any, condition?: Condition);
  3592. /** @hidden */
  3593. _prepare(): void;
  3594. /**
  3595. * Execute the action and stop the animation.
  3596. */
  3597. execute(): void;
  3598. /**
  3599. * Serializes the actions and its related information.
  3600. * @param parent defines the object to serialize in
  3601. * @returns the serialized object
  3602. */
  3603. serialize(parent: any): any;
  3604. }
  3605. /**
  3606. * This defines an action responsible that does nothing once triggered.
  3607. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3608. */
  3609. class DoNothingAction extends Action {
  3610. /**
  3611. * Instantiate the action
  3612. * @param triggerOptions defines the trigger options
  3613. * @param condition defines the trigger related conditions
  3614. */
  3615. constructor(triggerOptions?: any, condition?: Condition);
  3616. /**
  3617. * Execute the action and do nothing.
  3618. */
  3619. execute(): void;
  3620. /**
  3621. * Serializes the actions and its related information.
  3622. * @param parent defines the object to serialize in
  3623. * @returns the serialized object
  3624. */
  3625. serialize(parent: any): any;
  3626. }
  3627. /**
  3628. * This defines an action responsible to trigger several actions once triggered.
  3629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3630. */
  3631. class CombineAction extends Action {
  3632. /**
  3633. * The list of aggregated animations to run.
  3634. */
  3635. children: Action[];
  3636. /**
  3637. * Instantiate the action
  3638. * @param triggerOptions defines the trigger options
  3639. * @param children defines the list of aggregated animations to run
  3640. * @param condition defines the trigger related conditions
  3641. */
  3642. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3643. /** @hidden */
  3644. _prepare(): void;
  3645. /**
  3646. * Execute the action and executes all the aggregated actions.
  3647. */
  3648. execute(evt: ActionEvent): void;
  3649. /**
  3650. * Serializes the actions and its related information.
  3651. * @param parent defines the object to serialize in
  3652. * @returns the serialized object
  3653. */
  3654. serialize(parent: any): any;
  3655. }
  3656. /**
  3657. * This defines an action responsible to run code (external event) once triggered.
  3658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3659. */
  3660. class ExecuteCodeAction extends Action {
  3661. /**
  3662. * The callback function to run.
  3663. */
  3664. func: (evt: ActionEvent) => void;
  3665. /**
  3666. * Instantiate the action
  3667. * @param triggerOptions defines the trigger options
  3668. * @param func defines the callback function to run
  3669. * @param condition defines the trigger related conditions
  3670. */
  3671. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3672. /**
  3673. * Execute the action and run the attached code.
  3674. */
  3675. execute(evt: ActionEvent): void;
  3676. }
  3677. /**
  3678. * This defines an action responsible to set the parent property of the target once triggered.
  3679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3680. */
  3681. class SetParentAction extends Action {
  3682. private _parent;
  3683. private _target;
  3684. /**
  3685. * Instantiate the action
  3686. * @param triggerOptions defines the trigger options
  3687. * @param target defines the target containing the parent property
  3688. * @param parent defines from where the animation should start (animation frame)
  3689. * @param condition defines the trigger related conditions
  3690. */
  3691. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3692. /** @hidden */
  3693. _prepare(): void;
  3694. /**
  3695. * Execute the action and set the parent property.
  3696. */
  3697. execute(): void;
  3698. /**
  3699. * Serializes the actions and its related information.
  3700. * @param parent defines the object to serialize in
  3701. * @returns the serialized object
  3702. */
  3703. serialize(parent: any): any;
  3704. }
  3705. }
  3706. declare module BABYLON {
  3707. /**
  3708. * This defines an action helpful to play a defined sound on a triggered action.
  3709. */
  3710. class PlaySoundAction extends Action {
  3711. private _sound;
  3712. /**
  3713. * Instantiate the action
  3714. * @param triggerOptions defines the trigger options
  3715. * @param sound defines the sound to play
  3716. * @param condition defines the trigger related conditions
  3717. */
  3718. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3719. /** @hidden */
  3720. _prepare(): void;
  3721. /**
  3722. * Execute the action and play the sound.
  3723. */
  3724. execute(): void;
  3725. /**
  3726. * Serializes the actions and its related information.
  3727. * @param parent defines the object to serialize in
  3728. * @returns the serialized object
  3729. */
  3730. serialize(parent: any): any;
  3731. }
  3732. /**
  3733. * This defines an action helpful to stop a defined sound on a triggered action.
  3734. */
  3735. class StopSoundAction extends Action {
  3736. private _sound;
  3737. /**
  3738. * Instantiate the action
  3739. * @param triggerOptions defines the trigger options
  3740. * @param sound defines the sound to stop
  3741. * @param condition defines the trigger related conditions
  3742. */
  3743. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3744. /** @hidden */
  3745. _prepare(): void;
  3746. /**
  3747. * Execute the action and stop the sound.
  3748. */
  3749. execute(): void;
  3750. /**
  3751. * Serializes the actions and its related information.
  3752. * @param parent defines the object to serialize in
  3753. * @returns the serialized object
  3754. */
  3755. serialize(parent: any): any;
  3756. }
  3757. }
  3758. declare module BABYLON {
  3759. /**
  3760. * This defines an action responsible to change the value of a property
  3761. * by interpolating between its current value and the newly set one once triggered.
  3762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3763. */
  3764. class InterpolateValueAction extends Action {
  3765. /**
  3766. * Defines the path of the property where the value should be interpolated
  3767. */
  3768. propertyPath: string;
  3769. /**
  3770. * Defines the target value at the end of the interpolation.
  3771. */
  3772. value: any;
  3773. /**
  3774. * Defines the time it will take for the property to interpolate to the value.
  3775. */
  3776. duration: number;
  3777. /**
  3778. * Defines if the other scene animations should be stopped when the action has been triggered
  3779. */
  3780. stopOtherAnimations?: boolean;
  3781. /**
  3782. * Defines a callback raised once the interpolation animation has been done.
  3783. */
  3784. onInterpolationDone?: () => void;
  3785. /**
  3786. * Observable triggered once the interpolation animation has been done.
  3787. */
  3788. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3789. private _target;
  3790. private _effectiveTarget;
  3791. private _property;
  3792. /**
  3793. * Instantiate the action
  3794. * @param triggerOptions defines the trigger options
  3795. * @param target defines the object containing the value to interpolate
  3796. * @param propertyPath defines the path to the property in the target object
  3797. * @param value defines the target value at the end of the interpolation
  3798. * @param duration deines the time it will take for the property to interpolate to the value.
  3799. * @param condition defines the trigger related conditions
  3800. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3801. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3802. */
  3803. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3804. /** @hidden */
  3805. _prepare(): void;
  3806. /**
  3807. * Execute the action starts the value interpolation.
  3808. */
  3809. execute(): void;
  3810. /**
  3811. * Serializes the actions and its related information.
  3812. * @param parent defines the object to serialize in
  3813. * @returns the serialized object
  3814. */
  3815. serialize(parent: any): any;
  3816. }
  3817. }
  3818. declare module BABYLON {
  3819. /**
  3820. * Class used to work with sound analyzer using fast fourier transform (FFT)
  3821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3822. */
  3823. class Analyser {
  3824. /**
  3825. * Gets or sets the smoothing
  3826. * @ignorenaming
  3827. */
  3828. SMOOTHING: number;
  3829. /**
  3830. * Gets or sets the FFT table size
  3831. * @ignorenaming
  3832. */
  3833. FFT_SIZE: number;
  3834. /**
  3835. * Gets or sets the bar graph amplitude
  3836. * @ignorenaming
  3837. */
  3838. BARGRAPHAMPLITUDE: number;
  3839. /**
  3840. * Gets or sets the position of the debug canvas
  3841. * @ignorenaming
  3842. */
  3843. DEBUGCANVASPOS: {
  3844. x: number;
  3845. y: number;
  3846. };
  3847. /**
  3848. * Gets or sets the debug canvas size
  3849. * @ignorenaming
  3850. */
  3851. DEBUGCANVASSIZE: {
  3852. width: number;
  3853. height: number;
  3854. };
  3855. private _byteFreqs;
  3856. private _byteTime;
  3857. private _floatFreqs;
  3858. private _webAudioAnalyser;
  3859. private _debugCanvas;
  3860. private _debugCanvasContext;
  3861. private _scene;
  3862. private _registerFunc;
  3863. private _audioEngine;
  3864. /**
  3865. * Creates a new analyser
  3866. * @param scene defines hosting scene
  3867. */
  3868. constructor(scene: Scene);
  3869. /**
  3870. * Get the number of data values you will have to play with for the visualization
  3871. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  3872. * @returns a number
  3873. */
  3874. getFrequencyBinCount(): number;
  3875. /**
  3876. * Gets the current frequency data as a byte array
  3877. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3878. * @returns a Uint8Array
  3879. */
  3880. getByteFrequencyData(): Uint8Array;
  3881. /**
  3882. * Gets the current waveform as a byte array
  3883. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  3884. * @returns a Uint8Array
  3885. */
  3886. getByteTimeDomainData(): Uint8Array;
  3887. /**
  3888. * Gets the current frequency data as a float array
  3889. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3890. * @returns a Float32Array
  3891. */
  3892. getFloatFrequencyData(): Float32Array;
  3893. /**
  3894. * Renders the debug canvas
  3895. */
  3896. drawDebugCanvas(): void;
  3897. /**
  3898. * Stops rendering the debug canvas and removes it
  3899. */
  3900. stopDebugCanvas(): void;
  3901. /**
  3902. * Connects two audio nodes
  3903. * @param inputAudioNode defines first node to connect
  3904. * @param outputAudioNode defines second node to connect
  3905. */
  3906. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  3907. /**
  3908. * Releases all associated resources
  3909. */
  3910. dispose(): void;
  3911. }
  3912. }
  3913. declare module BABYLON {
  3914. /**
  3915. * This represents an audio engine and it is responsible
  3916. * to play, synchronize and analyse sounds throughout the application.
  3917. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3918. */
  3919. interface IAudioEngine extends IDisposable {
  3920. /**
  3921. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  3922. */
  3923. readonly canUseWebAudio: boolean;
  3924. /**
  3925. * Gets the current AudioContext if available.
  3926. */
  3927. readonly audioContext: Nullable<AudioContext>;
  3928. /**
  3929. * The master gain node defines the global audio volume of your audio engine.
  3930. */
  3931. readonly masterGain: GainNode;
  3932. /**
  3933. * Gets whether or not mp3 are supported by your browser.
  3934. */
  3935. readonly isMP3supported: boolean;
  3936. /**
  3937. * Gets whether or not ogg are supported by your browser.
  3938. */
  3939. readonly isOGGsupported: boolean;
  3940. /**
  3941. * Defines if Babylon should emit a warning if WebAudio is not supported.
  3942. * @ignoreNaming
  3943. */
  3944. WarnedWebAudioUnsupported: boolean;
  3945. /**
  3946. * Defines if the audio engine relies on a custom unlocked button.
  3947. * In this case, the embedded button will not be displayed.
  3948. */
  3949. useCustomUnlockedButton: boolean;
  3950. /**
  3951. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  3952. */
  3953. readonly unlocked: boolean;
  3954. /**
  3955. * Event raised when audio has been unlocked on the browser.
  3956. */
  3957. onAudioUnlockedObservable: Observable<AudioEngine>;
  3958. /**
  3959. * Event raised when audio has been locked on the browser.
  3960. */
  3961. onAudioLockedObservable: Observable<AudioEngine>;
  3962. /**
  3963. * Flags the audio engine in Locked state.
  3964. * This happens due to new browser policies preventing audio to autoplay.
  3965. */
  3966. lock(): void;
  3967. /**
  3968. * Unlocks the audio engine once a user action has been done on the dom.
  3969. * This is helpful to resume play once browser policies have been satisfied.
  3970. */
  3971. unlock(): void;
  3972. }
  3973. /**
  3974. * This represents the default audio engine used in babylon.
  3975. * It is responsible to play, synchronize and analyse sounds throughout the application.
  3976. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3977. */
  3978. class AudioEngine implements IAudioEngine {
  3979. private _audioContext;
  3980. private _audioContextInitialized;
  3981. private _muteButton;
  3982. private _hostElement;
  3983. /**
  3984. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  3985. */
  3986. canUseWebAudio: boolean;
  3987. /**
  3988. * The master gain node defines the global audio volume of your audio engine.
  3989. */
  3990. masterGain: GainNode;
  3991. /**
  3992. * Defines if Babylon should emit a warning if WebAudio is not supported.
  3993. * @ignoreNaming
  3994. */
  3995. WarnedWebAudioUnsupported: boolean;
  3996. /**
  3997. * Gets whether or not mp3 are supported by your browser.
  3998. */
  3999. isMP3supported: boolean;
  4000. /**
  4001. * Gets whether or not ogg are supported by your browser.
  4002. */
  4003. isOGGsupported: boolean;
  4004. /**
  4005. * Gets whether audio has been unlocked on the device.
  4006. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  4007. * a user interaction has happened.
  4008. */
  4009. unlocked: boolean;
  4010. /**
  4011. * Defines if the audio engine relies on a custom unlocked button.
  4012. * In this case, the embedded button will not be displayed.
  4013. */
  4014. useCustomUnlockedButton: boolean;
  4015. /**
  4016. * Event raised when audio has been unlocked on the browser.
  4017. */
  4018. onAudioUnlockedObservable: Observable<AudioEngine>;
  4019. /**
  4020. * Event raised when audio has been locked on the browser.
  4021. */
  4022. onAudioLockedObservable: Observable<AudioEngine>;
  4023. /**
  4024. * Gets the current AudioContext if available.
  4025. */
  4026. readonly audioContext: Nullable<AudioContext>;
  4027. private _connectedAnalyser;
  4028. /**
  4029. * Instantiates a new audio engine.
  4030. *
  4031. * There should be only one per page as some browsers restrict the number
  4032. * of audio contexts you can create.
  4033. * @param hostElement defines the host element where to display the mute icon if necessary
  4034. */
  4035. constructor(hostElement?: Nullable<HTMLElement>);
  4036. /**
  4037. * Flags the audio engine in Locked state.
  4038. * This happens due to new browser policies preventing audio to autoplay.
  4039. */
  4040. lock(): void;
  4041. /**
  4042. * Unlocks the audio engine once a user action has been done on the dom.
  4043. * This is helpful to resume play once browser policies have been satisfied.
  4044. */
  4045. unlock(): void;
  4046. private _resumeAudioContext;
  4047. private _initializeAudioContext;
  4048. private _tryToRun;
  4049. private _triggerRunningState;
  4050. private _triggerSuspendedState;
  4051. private _displayMuteButton;
  4052. private _moveButtonToTopLeft;
  4053. private _onResize;
  4054. private _hideMuteButton;
  4055. /**
  4056. * Destroy and release the resources associated with the audio ccontext.
  4057. */
  4058. dispose(): void;
  4059. /**
  4060. * Gets the global volume sets on the master gain.
  4061. * @returns the global volume if set or -1 otherwise
  4062. */
  4063. getGlobalVolume(): number;
  4064. /**
  4065. * Sets the global volume of your experience (sets on the master gain).
  4066. * @param newVolume Defines the new global volume of the application
  4067. */
  4068. setGlobalVolume(newVolume: number): void;
  4069. /**
  4070. * Connect the audio engine to an audio analyser allowing some amazing
  4071. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  4072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  4073. * @param analyser The analyser to connect to the engine
  4074. */
  4075. connectToAnalyser(analyser: Analyser): void;
  4076. }
  4077. }
  4078. declare module BABYLON {
  4079. interface AbstractScene {
  4080. /**
  4081. * The list of sounds used in the scene.
  4082. */
  4083. sounds: Nullable<Array<Sound>>;
  4084. }
  4085. interface Scene {
  4086. /**
  4087. * @hidden
  4088. * Backing field
  4089. */
  4090. _mainSoundTrack: SoundTrack;
  4091. /**
  4092. * The main sound track played by the scene.
  4093. * It cotains your primary collection of sounds.
  4094. */
  4095. mainSoundTrack: SoundTrack;
  4096. /**
  4097. * The list of sound tracks added to the scene
  4098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4099. */
  4100. soundTracks: Nullable<Array<SoundTrack>>;
  4101. /**
  4102. * Gets a sound using a given name
  4103. * @param name defines the name to search for
  4104. * @return the found sound or null if not found at all.
  4105. */
  4106. getSoundByName(name: string): Nullable<Sound>;
  4107. /**
  4108. * Gets or sets if audio support is enabled
  4109. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4110. */
  4111. audioEnabled: boolean;
  4112. /**
  4113. * Gets or sets if audio will be output to headphones
  4114. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4115. */
  4116. headphone: boolean;
  4117. }
  4118. /**
  4119. * Defines the sound scene component responsible to manage any sounds
  4120. * in a given scene.
  4121. */
  4122. class AudioSceneComponent implements ISceneSerializableComponent {
  4123. /**
  4124. * The component name helpfull to identify the component in the list of scene components.
  4125. */
  4126. readonly name: string;
  4127. /**
  4128. * The scene the component belongs to.
  4129. */
  4130. scene: Scene;
  4131. private _audioEnabled;
  4132. /**
  4133. * Gets whether audio is enabled or not.
  4134. * Please use related enable/disable method to switch state.
  4135. */
  4136. readonly audioEnabled: boolean;
  4137. private _headphone;
  4138. /**
  4139. * Gets whether audio is outputing to headphone or not.
  4140. * Please use the according Switch methods to change output.
  4141. */
  4142. readonly headphone: boolean;
  4143. /**
  4144. * Creates a new instance of the component for the given scene
  4145. * @param scene Defines the scene to register the component in
  4146. */
  4147. constructor(scene: Scene);
  4148. /**
  4149. * Registers the component in a given scene
  4150. */
  4151. register(): void;
  4152. /**
  4153. * Rebuilds the elements related to this component in case of
  4154. * context lost for instance.
  4155. */
  4156. rebuild(): void;
  4157. /**
  4158. * Serializes the component data to the specified json object
  4159. * @param serializationObject The object to serialize to
  4160. */
  4161. serialize(serializationObject: any): void;
  4162. /**
  4163. * Adds all the element from the container to the scene
  4164. * @param container the container holding the elements
  4165. */
  4166. addFromContainer(container: AbstractScene): void;
  4167. /**
  4168. * Removes all the elements in the container from the scene
  4169. * @param container contains the elements to remove
  4170. */
  4171. removeFromContainer(container: AbstractScene): void;
  4172. /**
  4173. * Disposes the component and the associated ressources.
  4174. */
  4175. dispose(): void;
  4176. /**
  4177. * Disables audio in the associated scene.
  4178. */
  4179. disableAudio(): void;
  4180. /**
  4181. * Enables audio in the associated scene.
  4182. */
  4183. enableAudio(): void;
  4184. /**
  4185. * Switch audio to headphone output.
  4186. */
  4187. switchAudioModeForHeadphones(): void;
  4188. /**
  4189. * Switch audio to normal speakers.
  4190. */
  4191. switchAudioModeForNormalSpeakers(): void;
  4192. private _afterRender;
  4193. }
  4194. }
  4195. declare module BABYLON {
  4196. /**
  4197. * Defines a sound that can be played in the application.
  4198. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  4199. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4200. */
  4201. class Sound {
  4202. /**
  4203. * The name of the sound in the scene.
  4204. */
  4205. name: string;
  4206. /**
  4207. * Does the sound autoplay once loaded.
  4208. */
  4209. autoplay: boolean;
  4210. /**
  4211. * Does the sound loop after it finishes playing once.
  4212. */
  4213. loop: boolean;
  4214. /**
  4215. * Does the sound use a custom attenuation curve to simulate the falloff
  4216. * happening when the source gets further away from the camera.
  4217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  4218. */
  4219. useCustomAttenuation: boolean;
  4220. /**
  4221. * The sound track id this sound belongs to.
  4222. */
  4223. soundTrackId: number;
  4224. /**
  4225. * Is this sound currently played.
  4226. */
  4227. isPlaying: boolean;
  4228. /**
  4229. * Is this sound currently paused.
  4230. */
  4231. isPaused: boolean;
  4232. /**
  4233. * Does this sound enables spatial sound.
  4234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4235. */
  4236. spatialSound: boolean;
  4237. /**
  4238. * Define the reference distance the sound should be heard perfectly.
  4239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4240. */
  4241. refDistance: number;
  4242. /**
  4243. * Define the roll off factor of spatial sounds.
  4244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4245. */
  4246. rolloffFactor: number;
  4247. /**
  4248. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  4249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4250. */
  4251. maxDistance: number;
  4252. /**
  4253. * Define the distance attenuation model the sound will follow.
  4254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4255. */
  4256. distanceModel: string;
  4257. /**
  4258. * @hidden
  4259. * Back Compat
  4260. **/
  4261. onended: () => any;
  4262. /**
  4263. * Observable event when the current playing sound finishes.
  4264. */
  4265. onEndedObservable: Observable<Sound>;
  4266. private _panningModel;
  4267. private _playbackRate;
  4268. private _streaming;
  4269. private _startTime;
  4270. private _startOffset;
  4271. private _position;
  4272. /** @hidden */
  4273. _positionInEmitterSpace: boolean;
  4274. private _localDirection;
  4275. private _volume;
  4276. private _isReadyToPlay;
  4277. private _isDirectional;
  4278. private _readyToPlayCallback;
  4279. private _audioBuffer;
  4280. private _soundSource;
  4281. private _streamingSource;
  4282. private _soundPanner;
  4283. private _soundGain;
  4284. private _inputAudioNode;
  4285. private _outputAudioNode;
  4286. private _coneInnerAngle;
  4287. private _coneOuterAngle;
  4288. private _coneOuterGain;
  4289. private _scene;
  4290. private _connectedTransformNode;
  4291. private _customAttenuationFunction;
  4292. private _registerFunc;
  4293. private _isOutputConnected;
  4294. private _htmlAudioElement;
  4295. private _urlType;
  4296. /**
  4297. * Create a sound and attach it to a scene
  4298. * @param name Name of your sound
  4299. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4300. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4301. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4302. */
  4303. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4304. /**
  4305. * Release the sound and its associated resources
  4306. */
  4307. dispose(): void;
  4308. /**
  4309. * Gets if the sounds is ready to be played or not.
  4310. * @returns true if ready, otherwise false
  4311. */
  4312. isReady(): boolean;
  4313. private _soundLoaded;
  4314. /**
  4315. * Sets the data of the sound from an audiobuffer
  4316. * @param audioBuffer The audioBuffer containing the data
  4317. */
  4318. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4319. /**
  4320. * Updates the current sounds options such as maxdistance, loop...
  4321. * @param options A JSON object containing values named as the object properties
  4322. */
  4323. updateOptions(options: any): void;
  4324. private _createSpatialParameters;
  4325. private _updateSpatialParameters;
  4326. /**
  4327. * Switch the panning model to HRTF:
  4328. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  4329. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4330. */
  4331. switchPanningModelToHRTF(): void;
  4332. /**
  4333. * Switch the panning model to Equal Power:
  4334. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  4335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4336. */
  4337. switchPanningModelToEqualPower(): void;
  4338. private _switchPanningModel;
  4339. /**
  4340. * Connect this sound to a sound track audio node like gain...
  4341. * @param soundTrackAudioNode the sound track audio node to connect to
  4342. */
  4343. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4344. /**
  4345. * Transform this sound into a directional source
  4346. * @param coneInnerAngle Size of the inner cone in degree
  4347. * @param coneOuterAngle Size of the outer cone in degree
  4348. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4349. */
  4350. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4351. /**
  4352. * Gets or sets the inner angle for the directional cone.
  4353. */
  4354. /**
  4355. * Gets or sets the inner angle for the directional cone.
  4356. */
  4357. directionalConeInnerAngle: number;
  4358. /**
  4359. * Gets or sets the outer angle for the directional cone.
  4360. */
  4361. /**
  4362. * Gets or sets the outer angle for the directional cone.
  4363. */
  4364. directionalConeOuterAngle: number;
  4365. /**
  4366. * Sets the position of the emitter if spatial sound is enabled
  4367. * @param newPosition Defines the new posisiton
  4368. */
  4369. setPosition(newPosition: Vector3): void;
  4370. /**
  4371. * Sets the local direction of the emitter if spatial sound is enabled
  4372. * @param newLocalDirection Defines the new local direction
  4373. */
  4374. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4375. private _updateDirection;
  4376. /** @hidden */
  4377. updateDistanceFromListener(): void;
  4378. /**
  4379. * Sets a new custom attenuation function for the sound.
  4380. * @param callback Defines the function used for the attenuation
  4381. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  4382. */
  4383. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4384. /**
  4385. * Play the sound
  4386. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4387. * @param offset (optional) Start the sound setting it at a specific time
  4388. */
  4389. play(time?: number, offset?: number): void;
  4390. private _onended;
  4391. /**
  4392. * Stop the sound
  4393. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4394. */
  4395. stop(time?: number): void;
  4396. /**
  4397. * Put the sound in pause
  4398. */
  4399. pause(): void;
  4400. /**
  4401. * Sets a dedicated volume for this sounds
  4402. * @param newVolume Define the new volume of the sound
  4403. * @param time Define in how long the sound should be at this value
  4404. */
  4405. setVolume(newVolume: number, time?: number): void;
  4406. /**
  4407. * Set the sound play back rate
  4408. * @param newPlaybackRate Define the playback rate the sound should be played at
  4409. */
  4410. setPlaybackRate(newPlaybackRate: number): void;
  4411. /**
  4412. * Gets the volume of the sound.
  4413. * @returns the volume of the sound
  4414. */
  4415. getVolume(): number;
  4416. /**
  4417. * Attach the sound to a dedicated mesh
  4418. * @param transformNode The transform node to connect the sound with
  4419. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  4420. */
  4421. attachToMesh(transformNode: TransformNode): void;
  4422. /**
  4423. * Detach the sound from the previously attached mesh
  4424. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  4425. */
  4426. detachFromMesh(): void;
  4427. private _onRegisterAfterWorldMatrixUpdate;
  4428. /**
  4429. * Clone the current sound in the scene.
  4430. * @returns the new sound clone
  4431. */
  4432. clone(): Nullable<Sound>;
  4433. /**
  4434. * Gets the current underlying audio buffer containing the data
  4435. * @returns the audio buffer
  4436. */
  4437. getAudioBuffer(): Nullable<AudioBuffer>;
  4438. /**
  4439. * Serializes the Sound in a JSON representation
  4440. * @returns the JSON representation of the sound
  4441. */
  4442. serialize(): any;
  4443. /**
  4444. * Parse a JSON representation of a sound to innstantiate in a given scene
  4445. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  4446. * @param scene Define the scene the new parsed sound should be created in
  4447. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  4448. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  4449. * @returns the newly parsed sound
  4450. */
  4451. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4452. }
  4453. }
  4454. declare module BABYLON {
  4455. /**
  4456. * Options allowed during the creation of a sound track.
  4457. */
  4458. interface ISoundTrackOptions {
  4459. /**
  4460. * The volume the sound track should take during creation
  4461. */
  4462. volume?: number;
  4463. /**
  4464. * Define if the sound track is the main sound track of the scene
  4465. */
  4466. mainTrack?: boolean;
  4467. }
  4468. /**
  4469. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  4470. * It will be also used in a future release to apply effects on a specific track.
  4471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  4472. */
  4473. class SoundTrack {
  4474. /**
  4475. * The unique identifier of the sound track in the scene.
  4476. */
  4477. id: number;
  4478. /**
  4479. * The list of sounds included in the sound track.
  4480. */
  4481. soundCollection: Array<Sound>;
  4482. private _outputAudioNode;
  4483. private _scene;
  4484. private _isMainTrack;
  4485. private _connectedAnalyser;
  4486. private _options;
  4487. private _isInitialized;
  4488. /**
  4489. * Creates a new sound track.
  4490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  4491. * @param scene Define the scene the sound track belongs to
  4492. * @param options
  4493. */
  4494. constructor(scene: Scene, options?: ISoundTrackOptions);
  4495. private _initializeSoundTrackAudioGraph;
  4496. /**
  4497. * Release the sound track and its associated resources
  4498. */
  4499. dispose(): void;
  4500. /**
  4501. * Adds a sound to this sound track
  4502. * @param sound define the cound to add
  4503. * @ignoreNaming
  4504. */
  4505. AddSound(sound: Sound): void;
  4506. /**
  4507. * Removes a sound to this sound track
  4508. * @param sound define the cound to remove
  4509. * @ignoreNaming
  4510. */
  4511. RemoveSound(sound: Sound): void;
  4512. /**
  4513. * Set a global volume for the full sound track.
  4514. * @param newVolume Define the new volume of the sound track
  4515. */
  4516. setVolume(newVolume: number): void;
  4517. /**
  4518. * Switch the panning model to HRTF:
  4519. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  4520. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4521. */
  4522. switchPanningModelToHRTF(): void;
  4523. /**
  4524. * Switch the panning model to Equal Power:
  4525. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  4526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4527. */
  4528. switchPanningModelToEqualPower(): void;
  4529. /**
  4530. * Connect the sound track to an audio analyser allowing some amazing
  4531. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  4532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  4533. * @param analyser The analyser to connect to the engine
  4534. */
  4535. connectToAnalyser(analyser: Analyser): void;
  4536. }
  4537. }
  4538. declare module BABYLON {
  4539. /**
  4540. * Wraps one or more Sound objects and selects one with random weight for playback.
  4541. */
  4542. class WeightedSound {
  4543. /** When true a Sound will be selected and played when the current playing Sound completes. */
  4544. loop: boolean;
  4545. private _coneInnerAngle;
  4546. private _coneOuterAngle;
  4547. private _volume;
  4548. /** A Sound is currently playing. */
  4549. isPlaying: boolean;
  4550. /** A Sound is currently paused. */
  4551. isPaused: boolean;
  4552. private _sounds;
  4553. private _weights;
  4554. private _currentIndex?;
  4555. /**
  4556. * Creates a new WeightedSound from the list of sounds given.
  4557. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  4558. * @param sounds Array of Sounds that will be selected from.
  4559. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  4560. */
  4561. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  4562. /**
  4563. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  4564. */
  4565. /**
  4566. * The size of cone in degress for a directional sound in which there will be no attenuation.
  4567. */
  4568. directionalConeInnerAngle: number;
  4569. /**
  4570. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4571. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4572. */
  4573. /**
  4574. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4575. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4576. */
  4577. directionalConeOuterAngle: number;
  4578. /**
  4579. * Playback volume.
  4580. */
  4581. /**
  4582. * Playback volume.
  4583. */
  4584. volume: number;
  4585. private _onended;
  4586. /**
  4587. * Suspend playback
  4588. */
  4589. pause(): void;
  4590. /**
  4591. * Stop playback
  4592. */
  4593. stop(): void;
  4594. /**
  4595. * Start playback.
  4596. * @param startOffset Position the clip head at a specific time in seconds.
  4597. */
  4598. play(startOffset?: number): void;
  4599. }
  4600. }
  4601. declare module BABYLON {
  4602. /**
  4603. * Class used to store an actual running animation
  4604. */
  4605. class Animatable {
  4606. /** defines the target object */
  4607. target: any;
  4608. /** defines the starting frame number (default is 0) */
  4609. fromFrame: number;
  4610. /** defines the ending frame number (default is 100) */
  4611. toFrame: number;
  4612. /** defines if the animation must loop (default is false) */
  4613. loopAnimation: boolean;
  4614. /** defines a callback to call when animation ends if it is not looping */
  4615. onAnimationEnd?: (() => void) | null | undefined;
  4616. /** defines a callback to call when animation loops */
  4617. onAnimationLoop?: (() => void) | null | undefined;
  4618. private _localDelayOffset;
  4619. private _pausedDelay;
  4620. private _runtimeAnimations;
  4621. private _paused;
  4622. private _scene;
  4623. private _speedRatio;
  4624. private _weight;
  4625. private _syncRoot;
  4626. /**
  4627. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  4628. * This will only apply for non looping animation (default is true)
  4629. */
  4630. disposeOnEnd: boolean;
  4631. /**
  4632. * Gets a boolean indicating if the animation has started
  4633. */
  4634. animationStarted: boolean;
  4635. /**
  4636. * Observer raised when the animation ends
  4637. */
  4638. onAnimationEndObservable: Observable<Animatable>;
  4639. /**
  4640. * Observer raised when the animation loops
  4641. */
  4642. onAnimationLoopObservable: Observable<Animatable>;
  4643. /**
  4644. * Gets the root Animatable used to synchronize and normalize animations
  4645. */
  4646. readonly syncRoot: Animatable;
  4647. /**
  4648. * Gets the current frame of the first RuntimeAnimation
  4649. * Used to synchronize Animatables
  4650. */
  4651. readonly masterFrame: number;
  4652. /**
  4653. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  4654. */
  4655. weight: number;
  4656. /**
  4657. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  4658. */
  4659. speedRatio: number;
  4660. /**
  4661. * Creates a new Animatable
  4662. * @param scene defines the hosting scene
  4663. * @param target defines the target object
  4664. * @param fromFrame defines the starting frame number (default is 0)
  4665. * @param toFrame defines the ending frame number (default is 100)
  4666. * @param loopAnimation defines if the animation must loop (default is false)
  4667. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  4668. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  4669. * @param animations defines a group of animation to add to the new Animatable
  4670. * @param onAnimationLoop defines a callback to call when animation loops
  4671. */
  4672. constructor(scene: Scene,
  4673. /** defines the target object */
  4674. target: any,
  4675. /** defines the starting frame number (default is 0) */
  4676. fromFrame?: number,
  4677. /** defines the ending frame number (default is 100) */
  4678. toFrame?: number,
  4679. /** defines if the animation must loop (default is false) */
  4680. loopAnimation?: boolean, speedRatio?: number,
  4681. /** defines a callback to call when animation ends if it is not looping */
  4682. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  4683. /** defines a callback to call when animation loops */
  4684. onAnimationLoop?: (() => void) | null | undefined);
  4685. /**
  4686. * Synchronize and normalize current Animatable with a source Animatable
  4687. * This is useful when using animation weights and when animations are not of the same length
  4688. * @param root defines the root Animatable to synchronize with
  4689. * @returns the current Animatable
  4690. */
  4691. syncWith(root: Animatable): Animatable;
  4692. /**
  4693. * Gets the list of runtime animations
  4694. * @returns an array of RuntimeAnimation
  4695. */
  4696. getAnimations(): RuntimeAnimation[];
  4697. /**
  4698. * Adds more animations to the current animatable
  4699. * @param target defines the target of the animations
  4700. * @param animations defines the new animations to add
  4701. */
  4702. appendAnimations(target: any, animations: Animation[]): void;
  4703. /**
  4704. * Gets the source animation for a specific property
  4705. * @param property defines the propertyu to look for
  4706. * @returns null or the source animation for the given property
  4707. */
  4708. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  4709. /**
  4710. * Gets the runtime animation for a specific property
  4711. * @param property defines the propertyu to look for
  4712. * @returns null or the runtime animation for the given property
  4713. */
  4714. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  4715. /**
  4716. * Resets the animatable to its original state
  4717. */
  4718. reset(): void;
  4719. /**
  4720. * Allows the animatable to blend with current running animations
  4721. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  4722. * @param blendingSpeed defines the blending speed to use
  4723. */
  4724. enableBlending(blendingSpeed: number): void;
  4725. /**
  4726. * Disable animation blending
  4727. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  4728. */
  4729. disableBlending(): void;
  4730. /**
  4731. * Jump directly to a given frame
  4732. * @param frame defines the frame to jump to
  4733. */
  4734. goToFrame(frame: number): void;
  4735. /**
  4736. * Pause the animation
  4737. */
  4738. pause(): void;
  4739. /**
  4740. * Restart the animation
  4741. */
  4742. restart(): void;
  4743. private _raiseOnAnimationEnd;
  4744. /**
  4745. * Stop and delete the current animation
  4746. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  4747. * @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)
  4748. */
  4749. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  4750. /**
  4751. * Wait asynchronously for the animation to end
  4752. * @returns a promise which will be fullfilled when the animation ends
  4753. */
  4754. waitAsync(): Promise<Animatable>;
  4755. /** @hidden */
  4756. _animate(delay: number): boolean;
  4757. }
  4758. }
  4759. declare module BABYLON {
  4760. /**
  4761. * Represents the range of an animation
  4762. */
  4763. class AnimationRange {
  4764. /**The name of the animation range**/
  4765. name: string;
  4766. /**The starting frame of the animation */
  4767. from: number;
  4768. /**The ending frame of the animation*/
  4769. to: number;
  4770. /**
  4771. * Initializes the range of an animation
  4772. * @param name The name of the animation range
  4773. * @param from The starting frame of the animation
  4774. * @param to The ending frame of the animation
  4775. */
  4776. constructor(
  4777. /**The name of the animation range**/
  4778. name: string,
  4779. /**The starting frame of the animation */
  4780. from: number,
  4781. /**The ending frame of the animation*/
  4782. to: number);
  4783. /**
  4784. * Makes a copy of the animation range
  4785. * @returns A copy of the animation range
  4786. */
  4787. clone(): AnimationRange;
  4788. }
  4789. /**
  4790. * Composed of a frame, and an action function
  4791. */
  4792. class AnimationEvent {
  4793. /** The frame for which the event is triggered **/
  4794. frame: number;
  4795. /** The event to perform when triggered **/
  4796. action: (currentFrame: number) => void;
  4797. /** Specifies if the event should be triggered only once**/
  4798. onlyOnce?: boolean | undefined;
  4799. /**
  4800. * Specifies if the animation event is done
  4801. */
  4802. isDone: boolean;
  4803. /**
  4804. * Initializes the animation event
  4805. * @param frame The frame for which the event is triggered
  4806. * @param action The event to perform when triggered
  4807. * @param onlyOnce Specifies if the event should be triggered only once
  4808. */
  4809. constructor(
  4810. /** The frame for which the event is triggered **/
  4811. frame: number,
  4812. /** The event to perform when triggered **/
  4813. action: (currentFrame: number) => void,
  4814. /** Specifies if the event should be triggered only once**/
  4815. onlyOnce?: boolean | undefined);
  4816. /** @hidden */
  4817. _clone(): AnimationEvent;
  4818. }
  4819. /**
  4820. * A cursor which tracks a point on a path
  4821. */
  4822. class PathCursor {
  4823. private path;
  4824. /**
  4825. * Stores path cursor callbacks for when an onchange event is triggered
  4826. */
  4827. private _onchange;
  4828. /**
  4829. * The value of the path cursor
  4830. */
  4831. value: number;
  4832. /**
  4833. * The animation array of the path cursor
  4834. */
  4835. animations: Animation[];
  4836. /**
  4837. * Initializes the path cursor
  4838. * @param path The path to track
  4839. */
  4840. constructor(path: Path2);
  4841. /**
  4842. * Gets the cursor point on the path
  4843. * @returns A point on the path cursor at the cursor location
  4844. */
  4845. getPoint(): Vector3;
  4846. /**
  4847. * Moves the cursor ahead by the step amount
  4848. * @param step The amount to move the cursor forward
  4849. * @returns This path cursor
  4850. */
  4851. moveAhead(step?: number): PathCursor;
  4852. /**
  4853. * Moves the cursor behind by the step amount
  4854. * @param step The amount to move the cursor back
  4855. * @returns This path cursor
  4856. */
  4857. moveBack(step?: number): PathCursor;
  4858. /**
  4859. * Moves the cursor by the step amount
  4860. * If the step amount is greater than one, an exception is thrown
  4861. * @param step The amount to move the cursor
  4862. * @returns This path cursor
  4863. */
  4864. move(step: number): PathCursor;
  4865. /**
  4866. * Ensures that the value is limited between zero and one
  4867. * @returns This path cursor
  4868. */
  4869. private ensureLimits;
  4870. /**
  4871. * Runs onchange callbacks on change (used by the animation engine)
  4872. * @returns This path cursor
  4873. */
  4874. private raiseOnChange;
  4875. /**
  4876. * Executes a function on change
  4877. * @param f A path cursor onchange callback
  4878. * @returns This path cursor
  4879. */
  4880. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4881. }
  4882. /**
  4883. * Defines an interface which represents an animation key frame
  4884. */
  4885. interface IAnimationKey {
  4886. /**
  4887. * Frame of the key frame
  4888. */
  4889. frame: number;
  4890. /**
  4891. * Value at the specifies key frame
  4892. */
  4893. value: any;
  4894. /**
  4895. * The input tangent for the cubic hermite spline
  4896. */
  4897. inTangent?: any;
  4898. /**
  4899. * The output tangent for the cubic hermite spline
  4900. */
  4901. outTangent?: any;
  4902. /**
  4903. * The animation interpolation type
  4904. */
  4905. interpolation?: AnimationKeyInterpolation;
  4906. }
  4907. /**
  4908. * Enum for the animation key frame interpolation type
  4909. */
  4910. enum AnimationKeyInterpolation {
  4911. /**
  4912. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4913. */
  4914. STEP = 1
  4915. }
  4916. /**
  4917. * Class used to store any kind of animation
  4918. */
  4919. class Animation {
  4920. /**Name of the animation */
  4921. name: string;
  4922. /**Property to animate */
  4923. targetProperty: string;
  4924. /**The frames per second of the animation */
  4925. framePerSecond: number;
  4926. /**The data type of the animation */
  4927. dataType: number;
  4928. /**The loop mode of the animation */
  4929. loopMode?: number | undefined;
  4930. /**Specifies if blending should be enabled */
  4931. enableBlending?: boolean | undefined;
  4932. /**
  4933. * Use matrix interpolation instead of using direct key value when animating matrices
  4934. */
  4935. static AllowMatricesInterpolation: boolean;
  4936. /**
  4937. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4938. */
  4939. static AllowMatrixDecomposeForInterpolation: boolean;
  4940. /**
  4941. * Stores the key frames of the animation
  4942. */
  4943. private _keys;
  4944. /**
  4945. * Stores the easing function of the animation
  4946. */
  4947. private _easingFunction;
  4948. /**
  4949. * @hidden Internal use only
  4950. */
  4951. _runtimeAnimations: RuntimeAnimation[];
  4952. /**
  4953. * The set of event that will be linked to this animation
  4954. */
  4955. private _events;
  4956. /**
  4957. * Stores an array of target property paths
  4958. */
  4959. targetPropertyPath: string[];
  4960. /**
  4961. * Stores the blending speed of the animation
  4962. */
  4963. blendingSpeed: number;
  4964. /**
  4965. * Stores the animation ranges for the animation
  4966. */
  4967. private _ranges;
  4968. /**
  4969. * @hidden Internal use
  4970. */
  4971. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4972. /**
  4973. * Sets up an animation
  4974. * @param property The property to animate
  4975. * @param animationType The animation type to apply
  4976. * @param framePerSecond The frames per second of the animation
  4977. * @param easingFunction The easing function used in the animation
  4978. * @returns The created animation
  4979. */
  4980. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4981. /**
  4982. * Create and start an animation on a node
  4983. * @param name defines the name of the global animation that will be run on all nodes
  4984. * @param node defines the root node where the animation will take place
  4985. * @param targetProperty defines property to animate
  4986. * @param framePerSecond defines the number of frame per second yo use
  4987. * @param totalFrame defines the number of frames in total
  4988. * @param from defines the initial value
  4989. * @param to defines the final value
  4990. * @param loopMode defines which loop mode you want to use (off by default)
  4991. * @param easingFunction defines the easing function to use (linear by default)
  4992. * @param onAnimationEnd defines the callback to call when animation end
  4993. * @returns the animatable created for this animation
  4994. */
  4995. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4996. /**
  4997. * Create and start an animation on a node and its descendants
  4998. * @param name defines the name of the global animation that will be run on all nodes
  4999. * @param node defines the root node where the animation will take place
  5000. * @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
  5001. * @param targetProperty defines property to animate
  5002. * @param framePerSecond defines the number of frame per second to use
  5003. * @param totalFrame defines the number of frames in total
  5004. * @param from defines the initial value
  5005. * @param to defines the final value
  5006. * @param loopMode defines which loop mode you want to use (off by default)
  5007. * @param easingFunction defines the easing function to use (linear by default)
  5008. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  5009. * @returns the list of animatables created for all nodes
  5010. * @example https://www.babylonjs-playground.com/#MH0VLI
  5011. */
  5012. 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[]>;
  5013. /**
  5014. * Creates a new animation, merges it with the existing animations and starts it
  5015. * @param name Name of the animation
  5016. * @param node Node which contains the scene that begins the animations
  5017. * @param targetProperty Specifies which property to animate
  5018. * @param framePerSecond The frames per second of the animation
  5019. * @param totalFrame The total number of frames
  5020. * @param from The frame at the beginning of the animation
  5021. * @param to The frame at the end of the animation
  5022. * @param loopMode Specifies the loop mode of the animation
  5023. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  5024. * @param onAnimationEnd Callback to run once the animation is complete
  5025. * @returns Nullable animation
  5026. */
  5027. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  5028. /**
  5029. * Transition property of an host to the target Value
  5030. * @param property The property to transition
  5031. * @param targetValue The target Value of the property
  5032. * @param host The object where the property to animate belongs
  5033. * @param scene Scene used to run the animation
  5034. * @param frameRate Framerate (in frame/s) to use
  5035. * @param transition The transition type we want to use
  5036. * @param duration The duration of the animation, in milliseconds
  5037. * @param onAnimationEnd Callback trigger at the end of the animation
  5038. * @returns Nullable animation
  5039. */
  5040. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  5041. /**
  5042. * Return the array of runtime animations currently using this animation
  5043. */
  5044. readonly runtimeAnimations: RuntimeAnimation[];
  5045. /**
  5046. * Specifies if any of the runtime animations are currently running
  5047. */
  5048. readonly hasRunningRuntimeAnimations: boolean;
  5049. /**
  5050. * Initializes the animation
  5051. * @param name Name of the animation
  5052. * @param targetProperty Property to animate
  5053. * @param framePerSecond The frames per second of the animation
  5054. * @param dataType The data type of the animation
  5055. * @param loopMode The loop mode of the animation
  5056. * @param enableBlendings Specifies if blending should be enabled
  5057. */
  5058. constructor(
  5059. /**Name of the animation */
  5060. name: string,
  5061. /**Property to animate */
  5062. targetProperty: string,
  5063. /**The frames per second of the animation */
  5064. framePerSecond: number,
  5065. /**The data type of the animation */
  5066. dataType: number,
  5067. /**The loop mode of the animation */
  5068. loopMode?: number | undefined,
  5069. /**Specifies if blending should be enabled */
  5070. enableBlending?: boolean | undefined);
  5071. /**
  5072. * Converts the animation to a string
  5073. * @param fullDetails support for multiple levels of logging within scene loading
  5074. * @returns String form of the animation
  5075. */
  5076. toString(fullDetails?: boolean): string;
  5077. /**
  5078. * Add an event to this animation
  5079. * @param event Event to add
  5080. */
  5081. addEvent(event: AnimationEvent): void;
  5082. /**
  5083. * Remove all events found at the given frame
  5084. * @param frame The frame to remove events from
  5085. */
  5086. removeEvents(frame: number): void;
  5087. /**
  5088. * Retrieves all the events from the animation
  5089. * @returns Events from the animation
  5090. */
  5091. getEvents(): AnimationEvent[];
  5092. /**
  5093. * Creates an animation range
  5094. * @param name Name of the animation range
  5095. * @param from Starting frame of the animation range
  5096. * @param to Ending frame of the animation
  5097. */
  5098. createRange(name: string, from: number, to: number): void;
  5099. /**
  5100. * Deletes an animation range by name
  5101. * @param name Name of the animation range to delete
  5102. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  5103. */
  5104. deleteRange(name: string, deleteFrames?: boolean): void;
  5105. /**
  5106. * Gets the animation range by name, or null if not defined
  5107. * @param name Name of the animation range
  5108. * @returns Nullable animation range
  5109. */
  5110. getRange(name: string): Nullable<AnimationRange>;
  5111. /**
  5112. * Gets the key frames from the animation
  5113. * @returns The key frames of the animation
  5114. */
  5115. getKeys(): Array<IAnimationKey>;
  5116. /**
  5117. * Gets the highest frame rate of the animation
  5118. * @returns Highest frame rate of the animation
  5119. */
  5120. getHighestFrame(): number;
  5121. /**
  5122. * Gets the easing function of the animation
  5123. * @returns Easing function of the animation
  5124. */
  5125. getEasingFunction(): IEasingFunction;
  5126. /**
  5127. * Sets the easing function of the animation
  5128. * @param easingFunction A custom mathematical formula for animation
  5129. */
  5130. setEasingFunction(easingFunction: EasingFunction): void;
  5131. /**
  5132. * Interpolates a scalar linearly
  5133. * @param startValue Start value of the animation curve
  5134. * @param endValue End value of the animation curve
  5135. * @param gradient Scalar amount to interpolate
  5136. * @returns Interpolated scalar value
  5137. */
  5138. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  5139. /**
  5140. * Interpolates a scalar cubically
  5141. * @param startValue Start value of the animation curve
  5142. * @param outTangent End tangent of the animation
  5143. * @param endValue End value of the animation curve
  5144. * @param inTangent Start tangent of the animation curve
  5145. * @param gradient Scalar amount to interpolate
  5146. * @returns Interpolated scalar value
  5147. */
  5148. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  5149. /**
  5150. * Interpolates a quaternion using a spherical linear interpolation
  5151. * @param startValue Start value of the animation curve
  5152. * @param endValue End value of the animation curve
  5153. * @param gradient Scalar amount to interpolate
  5154. * @returns Interpolated quaternion value
  5155. */
  5156. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  5157. /**
  5158. * Interpolates a quaternion cubically
  5159. * @param startValue Start value of the animation curve
  5160. * @param outTangent End tangent of the animation curve
  5161. * @param endValue End value of the animation curve
  5162. * @param inTangent Start tangent of the animation curve
  5163. * @param gradient Scalar amount to interpolate
  5164. * @returns Interpolated quaternion value
  5165. */
  5166. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  5167. /**
  5168. * Interpolates a Vector3 linearl
  5169. * @param startValue Start value of the animation curve
  5170. * @param endValue End value of the animation curve
  5171. * @param gradient Scalar amount to interpolate
  5172. * @returns Interpolated scalar value
  5173. */
  5174. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  5175. /**
  5176. * Interpolates a Vector3 cubically
  5177. * @param startValue Start value of the animation curve
  5178. * @param outTangent End tangent of the animation
  5179. * @param endValue End value of the animation curve
  5180. * @param inTangent Start tangent of the animation curve
  5181. * @param gradient Scalar amount to interpolate
  5182. * @returns InterpolatedVector3 value
  5183. */
  5184. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  5185. /**
  5186. * Interpolates a Vector2 linearly
  5187. * @param startValue Start value of the animation curve
  5188. * @param endValue End value of the animation curve
  5189. * @param gradient Scalar amount to interpolate
  5190. * @returns Interpolated Vector2 value
  5191. */
  5192. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  5193. /**
  5194. * Interpolates a Vector2 cubically
  5195. * @param startValue Start value of the animation curve
  5196. * @param outTangent End tangent of the animation
  5197. * @param endValue End value of the animation curve
  5198. * @param inTangent Start tangent of the animation curve
  5199. * @param gradient Scalar amount to interpolate
  5200. * @returns Interpolated Vector2 value
  5201. */
  5202. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  5203. /**
  5204. * Interpolates a size linearly
  5205. * @param startValue Start value of the animation curve
  5206. * @param endValue End value of the animation curve
  5207. * @param gradient Scalar amount to interpolate
  5208. * @returns Interpolated Size value
  5209. */
  5210. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  5211. /**
  5212. * Interpolates a Color3 linearly
  5213. * @param startValue Start value of the animation curve
  5214. * @param endValue End value of the animation curve
  5215. * @param gradient Scalar amount to interpolate
  5216. * @returns Interpolated Color3 value
  5217. */
  5218. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  5219. /**
  5220. * @hidden Internal use only
  5221. */
  5222. _getKeyValue(value: any): any;
  5223. /**
  5224. * @hidden Internal use only
  5225. */
  5226. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  5227. /**
  5228. * Defines the function to use to interpolate matrices
  5229. * @param startValue defines the start matrix
  5230. * @param endValue defines the end matrix
  5231. * @param gradient defines the gradient between both matrices
  5232. * @param result defines an optional target matrix where to store the interpolation
  5233. * @returns the interpolated matrix
  5234. */
  5235. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  5236. /**
  5237. * Makes a copy of the animation
  5238. * @returns Cloned animation
  5239. */
  5240. clone(): Animation;
  5241. /**
  5242. * Sets the key frames of the animation
  5243. * @param values The animation key frames to set
  5244. */
  5245. setKeys(values: Array<IAnimationKey>): void;
  5246. /**
  5247. * Serializes the animation to an object
  5248. * @returns Serialized object
  5249. */
  5250. serialize(): any;
  5251. /**
  5252. * Float animation type
  5253. */
  5254. private static _ANIMATIONTYPE_FLOAT;
  5255. /**
  5256. * Vector3 animation type
  5257. */
  5258. private static _ANIMATIONTYPE_VECTOR3;
  5259. /**
  5260. * Quaternion animation type
  5261. */
  5262. private static _ANIMATIONTYPE_QUATERNION;
  5263. /**
  5264. * Matrix animation type
  5265. */
  5266. private static _ANIMATIONTYPE_MATRIX;
  5267. /**
  5268. * Color3 animation type
  5269. */
  5270. private static _ANIMATIONTYPE_COLOR3;
  5271. /**
  5272. * Vector2 animation type
  5273. */
  5274. private static _ANIMATIONTYPE_VECTOR2;
  5275. /**
  5276. * Size animation type
  5277. */
  5278. private static _ANIMATIONTYPE_SIZE;
  5279. /**
  5280. * Relative Loop Mode
  5281. */
  5282. private static _ANIMATIONLOOPMODE_RELATIVE;
  5283. /**
  5284. * Cycle Loop Mode
  5285. */
  5286. private static _ANIMATIONLOOPMODE_CYCLE;
  5287. /**
  5288. * Constant Loop Mode
  5289. */
  5290. private static _ANIMATIONLOOPMODE_CONSTANT;
  5291. /**
  5292. * Get the float animation type
  5293. */
  5294. static readonly ANIMATIONTYPE_FLOAT: number;
  5295. /**
  5296. * Get the Vector3 animation type
  5297. */
  5298. static readonly ANIMATIONTYPE_VECTOR3: number;
  5299. /**
  5300. * Get the Vector2 animation type
  5301. */
  5302. static readonly ANIMATIONTYPE_VECTOR2: number;
  5303. /**
  5304. * Get the Size animation type
  5305. */
  5306. static readonly ANIMATIONTYPE_SIZE: number;
  5307. /**
  5308. * Get the Quaternion animation type
  5309. */
  5310. static readonly ANIMATIONTYPE_QUATERNION: number;
  5311. /**
  5312. * Get the Matrix animation type
  5313. */
  5314. static readonly ANIMATIONTYPE_MATRIX: number;
  5315. /**
  5316. * Get the Color3 animation type
  5317. */
  5318. static readonly ANIMATIONTYPE_COLOR3: number;
  5319. /**
  5320. * Get the Relative Loop Mode
  5321. */
  5322. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  5323. /**
  5324. * Get the Cycle Loop Mode
  5325. */
  5326. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  5327. /**
  5328. * Get the Constant Loop Mode
  5329. */
  5330. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  5331. /** @hidden */
  5332. static _UniversalLerp(left: any, right: any, amount: number): any;
  5333. /**
  5334. * Parses an animation object and creates an animation
  5335. * @param parsedAnimation Parsed animation object
  5336. * @returns Animation object
  5337. */
  5338. static Parse(parsedAnimation: any): Animation;
  5339. /**
  5340. * Appends the serialized animations from the source animations
  5341. * @param source Source containing the animations
  5342. * @param destination Target to store the animations
  5343. */
  5344. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  5345. }
  5346. }
  5347. declare module BABYLON {
  5348. /**
  5349. * This class defines the direct association between an animation and a target
  5350. */
  5351. class TargetedAnimation {
  5352. /**
  5353. * Animation to perform
  5354. */
  5355. animation: Animation;
  5356. /**
  5357. * Target to animate
  5358. */
  5359. target: any;
  5360. }
  5361. /**
  5362. * Use this class to create coordinated animations on multiple targets
  5363. */
  5364. class AnimationGroup implements IDisposable {
  5365. /** The name of the animation group */
  5366. name: string;
  5367. private _scene;
  5368. private _targetedAnimations;
  5369. private _animatables;
  5370. private _from;
  5371. private _to;
  5372. private _isStarted;
  5373. private _isPaused;
  5374. private _speedRatio;
  5375. /**
  5376. * Gets or sets the unique id of the node
  5377. */
  5378. uniqueId: number;
  5379. /**
  5380. * This observable will notify when one animation have ended
  5381. */
  5382. onAnimationEndObservable: Observable<TargetedAnimation>;
  5383. /**
  5384. * Observer raised when one animation loops
  5385. */
  5386. onAnimationLoopObservable: Observable<TargetedAnimation>;
  5387. /**
  5388. * This observable will notify when all animations have ended.
  5389. */
  5390. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  5391. /**
  5392. * This observable will notify when all animations have paused.
  5393. */
  5394. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  5395. /**
  5396. * This observable will notify when all animations are playing.
  5397. */
  5398. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  5399. /**
  5400. * Gets the first frame
  5401. */
  5402. readonly from: number;
  5403. /**
  5404. * Gets the last frame
  5405. */
  5406. readonly to: number;
  5407. /**
  5408. * Define if the animations are started
  5409. */
  5410. readonly isStarted: boolean;
  5411. /**
  5412. * Gets a value indicating that the current group is playing
  5413. */
  5414. readonly isPlaying: boolean;
  5415. /**
  5416. * Gets or sets the speed ratio to use for all animations
  5417. */
  5418. /**
  5419. * Gets or sets the speed ratio to use for all animations
  5420. */
  5421. speedRatio: number;
  5422. /**
  5423. * Gets the targeted animations for this animation group
  5424. */
  5425. readonly targetedAnimations: Array<TargetedAnimation>;
  5426. /**
  5427. * returning the list of animatables controlled by this animation group.
  5428. */
  5429. readonly animatables: Array<Animatable>;
  5430. /**
  5431. * Instantiates a new Animation Group.
  5432. * This helps managing several animations at once.
  5433. * @see http://doc.babylonjs.com/how_to/group
  5434. * @param name Defines the name of the group
  5435. * @param scene Defines the scene the group belongs to
  5436. */
  5437. constructor(
  5438. /** The name of the animation group */
  5439. name: string, scene?: Nullable<Scene>);
  5440. /**
  5441. * Add an animation (with its target) in the group
  5442. * @param animation defines the animation we want to add
  5443. * @param target defines the target of the animation
  5444. * @returns the TargetedAnimation object
  5445. */
  5446. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  5447. /**
  5448. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  5449. * It can add constant keys at begin or end
  5450. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  5451. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  5452. * @returns the animation group
  5453. */
  5454. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  5455. /**
  5456. * Start all animations on given targets
  5457. * @param loop defines if animations must loop
  5458. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  5459. * @param from defines the from key (optional)
  5460. * @param to defines the to key (optional)
  5461. * @returns the current animation group
  5462. */
  5463. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  5464. /**
  5465. * Pause all animations
  5466. * @returns the animation group
  5467. */
  5468. pause(): AnimationGroup;
  5469. /**
  5470. * Play all animations to initial state
  5471. * This function will start() the animations if they were not started or will restart() them if they were paused
  5472. * @param loop defines if animations must loop
  5473. * @returns the animation group
  5474. */
  5475. play(loop?: boolean): AnimationGroup;
  5476. /**
  5477. * Reset all animations to initial state
  5478. * @returns the animation group
  5479. */
  5480. reset(): AnimationGroup;
  5481. /**
  5482. * Restart animations from key 0
  5483. * @returns the animation group
  5484. */
  5485. restart(): AnimationGroup;
  5486. /**
  5487. * Stop all animations
  5488. * @returns the animation group
  5489. */
  5490. stop(): AnimationGroup;
  5491. /**
  5492. * Set animation weight for all animatables
  5493. * @param weight defines the weight to use
  5494. * @return the animationGroup
  5495. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  5496. */
  5497. setWeightForAllAnimatables(weight: number): AnimationGroup;
  5498. /**
  5499. * Synchronize and normalize all animatables with a source animatable
  5500. * @param root defines the root animatable to synchronize with
  5501. * @return the animationGroup
  5502. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  5503. */
  5504. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  5505. /**
  5506. * Goes to a specific frame in this animation group
  5507. * @param frame the frame number to go to
  5508. * @return the animationGroup
  5509. */
  5510. goToFrame(frame: number): AnimationGroup;
  5511. /**
  5512. * Dispose all associated resources
  5513. */
  5514. dispose(): void;
  5515. private _checkAnimationGroupEnded;
  5516. /**
  5517. * Returns a new AnimationGroup object parsed from the source provided.
  5518. * @param parsedAnimationGroup defines the source
  5519. * @param scene defines the scene that will receive the animationGroup
  5520. * @returns a new AnimationGroup
  5521. */
  5522. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  5523. /**
  5524. * Returns the string "AnimationGroup"
  5525. * @returns "AnimationGroup"
  5526. */
  5527. getClassName(): string;
  5528. /**
  5529. * Creates a detailled string about the object
  5530. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  5531. * @returns a string representing the object
  5532. */
  5533. toString(fullDetails?: boolean): string;
  5534. }
  5535. }
  5536. declare module BABYLON {
  5537. /**
  5538. * Class used to override all child animations of a given target
  5539. */
  5540. class AnimationPropertiesOverride {
  5541. /**
  5542. * Gets or sets a value indicating if animation blending must be used
  5543. */
  5544. enableBlending: boolean;
  5545. /**
  5546. * Gets or sets the blending speed to use when enableBlending is true
  5547. */
  5548. blendingSpeed: number;
  5549. /**
  5550. * Gets or sets the default loop mode to use
  5551. */
  5552. loopMode: number;
  5553. }
  5554. }
  5555. declare module BABYLON {
  5556. /**
  5557. * This represents the main contract an easing function should follow.
  5558. * Easing functions are used throughout the animation system.
  5559. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5560. */
  5561. interface IEasingFunction {
  5562. /**
  5563. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5564. * of the easing function.
  5565. * The link below provides some of the most common examples of easing functions.
  5566. * @see https://easings.net/
  5567. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5568. * @returns the corresponding value on the curve defined by the easing function
  5569. */
  5570. ease(gradient: number): number;
  5571. }
  5572. /**
  5573. * Base class used for every default easing function.
  5574. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5575. */
  5576. class EasingFunction implements IEasingFunction {
  5577. /**
  5578. * Interpolation follows the mathematical formula associated with the easing function.
  5579. */
  5580. static readonly EASINGMODE_EASEIN: number;
  5581. /**
  5582. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5583. */
  5584. static readonly EASINGMODE_EASEOUT: number;
  5585. /**
  5586. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5587. */
  5588. static readonly EASINGMODE_EASEINOUT: number;
  5589. private _easingMode;
  5590. /**
  5591. * Sets the easing mode of the current function.
  5592. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5593. */
  5594. setEasingMode(easingMode: number): void;
  5595. /**
  5596. * Gets the current easing mode.
  5597. * @returns the easing mode
  5598. */
  5599. getEasingMode(): number;
  5600. /**
  5601. * @hidden
  5602. */
  5603. easeInCore(gradient: number): number;
  5604. /**
  5605. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5606. * of the easing function.
  5607. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5608. * @returns the corresponding value on the curve defined by the easing function
  5609. */
  5610. ease(gradient: number): number;
  5611. }
  5612. /**
  5613. * Easing function with a circle shape (see link below).
  5614. * @see https://easings.net/#easeInCirc
  5615. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5616. */
  5617. class CircleEase extends EasingFunction implements IEasingFunction {
  5618. /** @hidden */
  5619. easeInCore(gradient: number): number;
  5620. }
  5621. /**
  5622. * Easing function with a ease back shape (see link below).
  5623. * @see https://easings.net/#easeInBack
  5624. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5625. */
  5626. class BackEase extends EasingFunction implements IEasingFunction {
  5627. /** Defines the amplitude of the function */
  5628. amplitude: number;
  5629. /**
  5630. * Instantiates a back ease easing
  5631. * @see https://easings.net/#easeInBack
  5632. * @param amplitude Defines the amplitude of the function
  5633. */
  5634. constructor(
  5635. /** Defines the amplitude of the function */
  5636. amplitude?: number);
  5637. /** @hidden */
  5638. easeInCore(gradient: number): number;
  5639. }
  5640. /**
  5641. * Easing function with a bouncing shape (see link below).
  5642. * @see https://easings.net/#easeInBounce
  5643. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5644. */
  5645. class BounceEase extends EasingFunction implements IEasingFunction {
  5646. /** Defines the number of bounces */
  5647. bounces: number;
  5648. /** Defines the amplitude of the bounce */
  5649. bounciness: number;
  5650. /**
  5651. * Instantiates a bounce easing
  5652. * @see https://easings.net/#easeInBounce
  5653. * @param bounces Defines the number of bounces
  5654. * @param bounciness Defines the amplitude of the bounce
  5655. */
  5656. constructor(
  5657. /** Defines the number of bounces */
  5658. bounces?: number,
  5659. /** Defines the amplitude of the bounce */
  5660. bounciness?: number);
  5661. /** @hidden */
  5662. easeInCore(gradient: number): number;
  5663. }
  5664. /**
  5665. * Easing function with a power of 3 shape (see link below).
  5666. * @see https://easings.net/#easeInCubic
  5667. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5668. */
  5669. class CubicEase extends EasingFunction implements IEasingFunction {
  5670. /** @hidden */
  5671. easeInCore(gradient: number): number;
  5672. }
  5673. /**
  5674. * Easing function with an elastic shape (see link below).
  5675. * @see https://easings.net/#easeInElastic
  5676. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5677. */
  5678. class ElasticEase extends EasingFunction implements IEasingFunction {
  5679. /** Defines the number of oscillations*/
  5680. oscillations: number;
  5681. /** Defines the amplitude of the oscillations*/
  5682. springiness: number;
  5683. /**
  5684. * Instantiates an elastic easing function
  5685. * @see https://easings.net/#easeInElastic
  5686. * @param oscillations Defines the number of oscillations
  5687. * @param springiness Defines the amplitude of the oscillations
  5688. */
  5689. constructor(
  5690. /** Defines the number of oscillations*/
  5691. oscillations?: number,
  5692. /** Defines the amplitude of the oscillations*/
  5693. springiness?: number);
  5694. /** @hidden */
  5695. easeInCore(gradient: number): number;
  5696. }
  5697. /**
  5698. * Easing function with an exponential shape (see link below).
  5699. * @see https://easings.net/#easeInExpo
  5700. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5701. */
  5702. class ExponentialEase extends EasingFunction implements IEasingFunction {
  5703. /** Defines the exponent of the function */
  5704. exponent: number;
  5705. /**
  5706. * Instantiates an exponential easing function
  5707. * @see https://easings.net/#easeInExpo
  5708. * @param exponent Defines the exponent of the function
  5709. */
  5710. constructor(
  5711. /** Defines the exponent of the function */
  5712. exponent?: number);
  5713. /** @hidden */
  5714. easeInCore(gradient: number): number;
  5715. }
  5716. /**
  5717. * Easing function with a power shape (see link below).
  5718. * @see https://easings.net/#easeInQuad
  5719. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5720. */
  5721. class PowerEase extends EasingFunction implements IEasingFunction {
  5722. /** Defines the power of the function */
  5723. power: number;
  5724. /**
  5725. * Instantiates an power base easing function
  5726. * @see https://easings.net/#easeInQuad
  5727. * @param power Defines the power of the function
  5728. */
  5729. constructor(
  5730. /** Defines the power of the function */
  5731. power?: number);
  5732. /** @hidden */
  5733. easeInCore(gradient: number): number;
  5734. }
  5735. /**
  5736. * Easing function with a power of 2 shape (see link below).
  5737. * @see https://easings.net/#easeInQuad
  5738. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5739. */
  5740. class QuadraticEase extends EasingFunction implements IEasingFunction {
  5741. /** @hidden */
  5742. easeInCore(gradient: number): number;
  5743. }
  5744. /**
  5745. * Easing function with a power of 4 shape (see link below).
  5746. * @see https://easings.net/#easeInQuart
  5747. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5748. */
  5749. class QuarticEase extends EasingFunction implements IEasingFunction {
  5750. /** @hidden */
  5751. easeInCore(gradient: number): number;
  5752. }
  5753. /**
  5754. * Easing function with a power of 5 shape (see link below).
  5755. * @see https://easings.net/#easeInQuint
  5756. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5757. */
  5758. class QuinticEase extends EasingFunction implements IEasingFunction {
  5759. /** @hidden */
  5760. easeInCore(gradient: number): number;
  5761. }
  5762. /**
  5763. * Easing function with a sin shape (see link below).
  5764. * @see https://easings.net/#easeInSine
  5765. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5766. */
  5767. class SineEase extends EasingFunction implements IEasingFunction {
  5768. /** @hidden */
  5769. easeInCore(gradient: number): number;
  5770. }
  5771. /**
  5772. * Easing function with a bezier shape (see link below).
  5773. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5774. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5775. */
  5776. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5777. /** Defines the x component of the start tangent in the bezier curve */
  5778. x1: number;
  5779. /** Defines the y component of the start tangent in the bezier curve */
  5780. y1: number;
  5781. /** Defines the x component of the end tangent in the bezier curve */
  5782. x2: number;
  5783. /** Defines the y component of the end tangent in the bezier curve */
  5784. y2: number;
  5785. /**
  5786. * Instantiates a bezier function
  5787. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5788. * @param x1 Defines the x component of the start tangent in the bezier curve
  5789. * @param y1 Defines the y component of the start tangent in the bezier curve
  5790. * @param x2 Defines the x component of the end tangent in the bezier curve
  5791. * @param y2 Defines the y component of the end tangent in the bezier curve
  5792. */
  5793. constructor(
  5794. /** Defines the x component of the start tangent in the bezier curve */
  5795. x1?: number,
  5796. /** Defines the y component of the start tangent in the bezier curve */
  5797. y1?: number,
  5798. /** Defines the x component of the end tangent in the bezier curve */
  5799. x2?: number,
  5800. /** Defines the y component of the end tangent in the bezier curve */
  5801. y2?: number);
  5802. /** @hidden */
  5803. easeInCore(gradient: number): number;
  5804. }
  5805. }
  5806. declare module BABYLON {
  5807. /**
  5808. * Defines a runtime animation
  5809. */
  5810. class RuntimeAnimation {
  5811. private _events;
  5812. /**
  5813. * The current frame of the runtime animation
  5814. */
  5815. private _currentFrame;
  5816. /**
  5817. * The animation used by the runtime animation
  5818. */
  5819. private _animation;
  5820. /**
  5821. * The target of the runtime animation
  5822. */
  5823. private _target;
  5824. /**
  5825. * The initiating animatable
  5826. */
  5827. private _host;
  5828. /**
  5829. * The original value of the runtime animation
  5830. */
  5831. private _originalValue;
  5832. /**
  5833. * The original blend value of the runtime animation
  5834. */
  5835. private _originalBlendValue;
  5836. /**
  5837. * The offsets cache of the runtime animation
  5838. */
  5839. private _offsetsCache;
  5840. /**
  5841. * The high limits cache of the runtime animation
  5842. */
  5843. private _highLimitsCache;
  5844. /**
  5845. * Specifies if the runtime animation has been stopped
  5846. */
  5847. private _stopped;
  5848. /**
  5849. * The blending factor of the runtime animation
  5850. */
  5851. private _blendingFactor;
  5852. /**
  5853. * The BabylonJS scene
  5854. */
  5855. private _scene;
  5856. /**
  5857. * The current value of the runtime animation
  5858. */
  5859. private _currentValue;
  5860. /** @hidden */
  5861. _workValue: any;
  5862. /**
  5863. * The active target of the runtime animation
  5864. */
  5865. private _activeTarget;
  5866. /**
  5867. * The target path of the runtime animation
  5868. */
  5869. private _targetPath;
  5870. /**
  5871. * The weight of the runtime animation
  5872. */
  5873. private _weight;
  5874. /**
  5875. * The ratio offset of the runtime animation
  5876. */
  5877. private _ratioOffset;
  5878. /**
  5879. * The previous delay of the runtime animation
  5880. */
  5881. private _previousDelay;
  5882. /**
  5883. * The previous ratio of the runtime animation
  5884. */
  5885. private _previousRatio;
  5886. /**
  5887. * Gets the current frame of the runtime animation
  5888. */
  5889. readonly currentFrame: number;
  5890. /**
  5891. * Gets the weight of the runtime animation
  5892. */
  5893. readonly weight: number;
  5894. /**
  5895. * Gets the current value of the runtime animation
  5896. */
  5897. readonly currentValue: any;
  5898. /**
  5899. * Gets the target path of the runtime animation
  5900. */
  5901. readonly targetPath: string;
  5902. /**
  5903. * Gets the actual target of the runtime animation
  5904. */
  5905. readonly target: any;
  5906. /**
  5907. * Create a new RuntimeAnimation object
  5908. * @param target defines the target of the animation
  5909. * @param animation defines the source animation object
  5910. * @param scene defines the hosting scene
  5911. * @param host defines the initiating Animatable
  5912. */
  5913. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5914. /**
  5915. * Gets the animation from the runtime animation
  5916. */
  5917. readonly animation: Animation;
  5918. /**
  5919. * Resets the runtime animation to the beginning
  5920. * @param restoreOriginal defines whether to restore the target property to the original value
  5921. */
  5922. reset(restoreOriginal?: boolean): void;
  5923. /**
  5924. * Specifies if the runtime animation is stopped
  5925. * @returns Boolean specifying if the runtime animation is stopped
  5926. */
  5927. isStopped(): boolean;
  5928. /**
  5929. * Disposes of the runtime animation
  5930. */
  5931. dispose(): void;
  5932. /**
  5933. * Interpolates the animation from the current frame
  5934. * @param currentFrame The frame to interpolate the animation to
  5935. * @param repeatCount The number of times that the animation should loop
  5936. * @param loopMode The type of looping mode to use
  5937. * @param offsetValue Animation offset value
  5938. * @param highLimitValue The high limit value
  5939. * @returns The interpolated value
  5940. */
  5941. private _interpolate;
  5942. /**
  5943. * Apply the interpolated value to the target
  5944. * @param currentValue defines the value computed by the animation
  5945. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5946. */
  5947. setValue(currentValue: any, weight?: number): void;
  5948. private _setValue;
  5949. /**
  5950. * Gets the loop pmode of the runtime animation
  5951. * @returns Loop Mode
  5952. */
  5953. private _getCorrectLoopMode;
  5954. /**
  5955. * Move the current animation to a given frame
  5956. * @param frame defines the frame to move to
  5957. */
  5958. goToFrame(frame: number): void;
  5959. /**
  5960. * @hidden Internal use only
  5961. */
  5962. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5963. /**
  5964. * Execute the current animation
  5965. * @param delay defines the delay to add to the current frame
  5966. * @param from defines the lower bound of the animation range
  5967. * @param to defines the upper bound of the animation range
  5968. * @param loop defines if the current animation must loop
  5969. * @param speedRatio defines the current speed ratio
  5970. * @param weight defines the weight of the animation (default is -1 so no weight)
  5971. * @param onLoop optional callback called when animation loops
  5972. * @returns a boolean indicating if the animation is running
  5973. */
  5974. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  5975. }
  5976. }
  5977. declare module BABYLON {
  5978. /**
  5979. * Interface used to define a behavior
  5980. */
  5981. interface Behavior<T> {
  5982. /** gets or sets behavior's name */
  5983. name: string;
  5984. /**
  5985. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5986. */
  5987. init(): void;
  5988. /**
  5989. * Called when the behavior is attached to a target
  5990. * @param target defines the target where the behavior is attached to
  5991. */
  5992. attach(target: T): void;
  5993. /**
  5994. * Called when the behavior is detached from its target
  5995. */
  5996. detach(): void;
  5997. }
  5998. /**
  5999. * Interface implemented by classes supporting behaviors
  6000. */
  6001. interface IBehaviorAware<T> {
  6002. /**
  6003. * Attach a behavior
  6004. * @param behavior defines the behavior to attach
  6005. * @returns the current host
  6006. */
  6007. addBehavior(behavior: Behavior<T>): T;
  6008. /**
  6009. * Remove a behavior from the current object
  6010. * @param behavior defines the behavior to detach
  6011. * @returns the current host
  6012. */
  6013. removeBehavior(behavior: Behavior<T>): T;
  6014. /**
  6015. * Gets a behavior using its name to search
  6016. * @param name defines the name to search
  6017. * @returns the behavior or null if not found
  6018. */
  6019. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6020. }
  6021. }
  6022. declare module BABYLON {
  6023. /**
  6024. * Class used to store bone information
  6025. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6026. */
  6027. class Bone extends Node {
  6028. /**
  6029. * defines the bone name
  6030. */
  6031. name: string;
  6032. private static _tmpVecs;
  6033. private static _tmpQuat;
  6034. private static _tmpMats;
  6035. /**
  6036. * Gets the list of child bones
  6037. */
  6038. children: Bone[];
  6039. /** Gets the animations associated with this bone */
  6040. animations: Animation[];
  6041. /**
  6042. * Gets or sets bone length
  6043. */
  6044. length: number;
  6045. /**
  6046. * @hidden Internal only
  6047. * Set this value to map this bone to a different index in the transform matrices
  6048. * Set this value to -1 to exclude the bone from the transform matrices
  6049. */
  6050. _index: Nullable<number>;
  6051. private _skeleton;
  6052. private _localMatrix;
  6053. private _restPose;
  6054. private _baseMatrix;
  6055. private _absoluteTransform;
  6056. private _invertedAbsoluteTransform;
  6057. private _parent;
  6058. private _scalingDeterminant;
  6059. private _worldTransform;
  6060. private _localScaling;
  6061. private _localRotation;
  6062. private _localPosition;
  6063. private _needToDecompose;
  6064. private _needToCompose;
  6065. /** @hidden */
  6066. _linkedTransformNode: Nullable<TransformNode>;
  6067. /** @hidden */
  6068. /** @hidden */
  6069. _matrix: Matrix;
  6070. /**
  6071. * Create a new bone
  6072. * @param name defines the bone name
  6073. * @param skeleton defines the parent skeleton
  6074. * @param parentBone defines the parent (can be null if the bone is the root)
  6075. * @param localMatrix defines the local matrix
  6076. * @param restPose defines the rest pose matrix
  6077. * @param baseMatrix defines the base matrix
  6078. * @param index defines index of the bone in the hiearchy
  6079. */
  6080. constructor(
  6081. /**
  6082. * defines the bone name
  6083. */
  6084. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  6085. /**
  6086. * Gets the parent skeleton
  6087. * @returns a skeleton
  6088. */
  6089. getSkeleton(): Skeleton;
  6090. /**
  6091. * Gets parent bone
  6092. * @returns a bone or null if the bone is the root of the bone hierarchy
  6093. */
  6094. getParent(): Nullable<Bone>;
  6095. /**
  6096. * Sets the parent bone
  6097. * @param parent defines the parent (can be null if the bone is the root)
  6098. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6099. */
  6100. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  6101. /**
  6102. * Gets the local matrix
  6103. * @returns a matrix
  6104. */
  6105. getLocalMatrix(): Matrix;
  6106. /**
  6107. * Gets the base matrix (initial matrix which remains unchanged)
  6108. * @returns a matrix
  6109. */
  6110. getBaseMatrix(): Matrix;
  6111. /**
  6112. * Gets the rest pose matrix
  6113. * @returns a matrix
  6114. */
  6115. getRestPose(): Matrix;
  6116. /**
  6117. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  6118. */
  6119. getWorldMatrix(): Matrix;
  6120. /**
  6121. * Sets the local matrix to rest pose matrix
  6122. */
  6123. returnToRest(): void;
  6124. /**
  6125. * Gets the inverse of the absolute transform matrix.
  6126. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6127. * @returns a matrix
  6128. */
  6129. getInvertedAbsoluteTransform(): Matrix;
  6130. /**
  6131. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6132. * @returns a matrix
  6133. */
  6134. getAbsoluteTransform(): Matrix;
  6135. /**
  6136. * Links with the given transform node.
  6137. * The local matrix of this bone is copied from the transform node every frame.
  6138. * @param transformNode defines the transform node to link to
  6139. */
  6140. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  6141. /** Gets or sets current position (in local space) */
  6142. position: Vector3;
  6143. /** Gets or sets current rotation (in local space) */
  6144. rotation: Vector3;
  6145. /** Gets or sets current rotation quaternion (in local space) */
  6146. rotationQuaternion: Quaternion;
  6147. /** Gets or sets current scaling (in local space) */
  6148. scaling: Vector3;
  6149. /**
  6150. * Gets the animation properties override
  6151. */
  6152. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6153. private _decompose;
  6154. private _compose;
  6155. /**
  6156. * Update the base and local matrices
  6157. * @param matrix defines the new base or local matrix
  6158. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6159. * @param updateLocalMatrix defines if the local matrix should be updated
  6160. */
  6161. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6162. /** @hidden */
  6163. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6164. /**
  6165. * Flag the bone as dirty (Forcing it to update everything)
  6166. */
  6167. markAsDirty(): void;
  6168. private _markAsDirtyAndCompose;
  6169. private _markAsDirtyAndDecompose;
  6170. /**
  6171. * Copy an animation range from another bone
  6172. * @param source defines the source bone
  6173. * @param rangeName defines the range name to copy
  6174. * @param frameOffset defines the frame offset
  6175. * @param rescaleAsRequired defines if rescaling must be applied if required
  6176. * @param skelDimensionsRatio defines the scaling ratio
  6177. * @returns true if operation was successful
  6178. */
  6179. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6180. /**
  6181. * Translate the bone in local or world space
  6182. * @param vec The amount to translate the bone
  6183. * @param space The space that the translation is in
  6184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6185. */
  6186. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6187. /**
  6188. * Set the postion of the bone in local or world space
  6189. * @param position The position to set the bone
  6190. * @param space The space that the position is in
  6191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6192. */
  6193. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6194. /**
  6195. * Set the absolute position of the bone (world space)
  6196. * @param position The position to set the bone
  6197. * @param mesh The mesh that this bone is attached to
  6198. */
  6199. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6200. /**
  6201. * Scale the bone on the x, y and z axes (in local space)
  6202. * @param x The amount to scale the bone on the x axis
  6203. * @param y The amount to scale the bone on the y axis
  6204. * @param z The amount to scale the bone on the z axis
  6205. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6206. */
  6207. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6208. /**
  6209. * Set the bone scaling in local space
  6210. * @param scale defines the scaling vector
  6211. */
  6212. setScale(scale: Vector3): void;
  6213. /**
  6214. * Gets the current scaling in local space
  6215. * @returns the current scaling vector
  6216. */
  6217. getScale(): Vector3;
  6218. /**
  6219. * Gets the current scaling in local space and stores it in a target vector
  6220. * @param result defines the target vector
  6221. */
  6222. getScaleToRef(result: Vector3): void;
  6223. /**
  6224. * Set the yaw, pitch, and roll of the bone in local or world space
  6225. * @param yaw The rotation of the bone on the y axis
  6226. * @param pitch The rotation of the bone on the x axis
  6227. * @param roll The rotation of the bone on the z axis
  6228. * @param space The space that the axes of rotation are in
  6229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6230. */
  6231. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6232. /**
  6233. * Add a rotation to the bone on an axis in local or world space
  6234. * @param axis The axis to rotate the bone on
  6235. * @param amount The amount to rotate the bone
  6236. * @param space The space that the axis is in
  6237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6238. */
  6239. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6240. /**
  6241. * Set the rotation of the bone to a particular axis angle in local or world space
  6242. * @param axis The axis to rotate the bone on
  6243. * @param angle The angle that the bone should be rotated to
  6244. * @param space The space that the axis is in
  6245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6246. */
  6247. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6248. /**
  6249. * Set the euler rotation of the bone in local of world space
  6250. * @param rotation The euler rotation that the bone should be set to
  6251. * @param space The space that the rotation is in
  6252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6253. */
  6254. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6255. /**
  6256. * Set the quaternion rotation of the bone in local of world space
  6257. * @param quat The quaternion rotation that the bone should be set to
  6258. * @param space The space that the rotation is in
  6259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6260. */
  6261. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6262. /**
  6263. * Set the rotation matrix of the bone in local of world space
  6264. * @param rotMat The rotation matrix that the bone should be set to
  6265. * @param space The space that the rotation is in
  6266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6267. */
  6268. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6269. private _rotateWithMatrix;
  6270. private _getNegativeRotationToRef;
  6271. /**
  6272. * Get the position of the bone in local or world space
  6273. * @param space The space that the returned position is in
  6274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6275. * @returns The position of the bone
  6276. */
  6277. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6278. /**
  6279. * Copy the position of the bone to a vector3 in local or world space
  6280. * @param space The space that the returned position is in
  6281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6282. * @param result The vector3 to copy the position to
  6283. */
  6284. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6285. /**
  6286. * Get the absolute position of the bone (world space)
  6287. * @param mesh The mesh that this bone is attached to
  6288. * @returns The absolute position of the bone
  6289. */
  6290. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6291. /**
  6292. * Copy the absolute position of the bone (world space) to the result param
  6293. * @param mesh The mesh that this bone is attached to
  6294. * @param result The vector3 to copy the absolute position to
  6295. */
  6296. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6297. /**
  6298. * Compute the absolute transforms of this bone and its children
  6299. */
  6300. computeAbsoluteTransforms(): void;
  6301. /**
  6302. * Get the world direction from an axis that is in the local space of the bone
  6303. * @param localAxis The local direction that is used to compute the world direction
  6304. * @param mesh The mesh that this bone is attached to
  6305. * @returns The world direction
  6306. */
  6307. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6308. /**
  6309. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6310. * @param localAxis The local direction that is used to compute the world direction
  6311. * @param mesh The mesh that this bone is attached to
  6312. * @param result The vector3 that the world direction will be copied to
  6313. */
  6314. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6315. /**
  6316. * Get the euler rotation of the bone in local or world space
  6317. * @param space The space that the rotation should be in
  6318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6319. * @returns The euler rotation
  6320. */
  6321. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6322. /**
  6323. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6324. * @param space The space that the rotation should be in
  6325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6326. * @param result The vector3 that the rotation should be copied to
  6327. */
  6328. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6329. /**
  6330. * Get the quaternion rotation of the bone in either local or world space
  6331. * @param space The space that the rotation should be in
  6332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6333. * @returns The quaternion rotation
  6334. */
  6335. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6336. /**
  6337. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6338. * @param space The space that the rotation should be in
  6339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6340. * @param result The quaternion that the rotation should be copied to
  6341. */
  6342. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6343. /**
  6344. * Get the rotation matrix of the bone in local or world space
  6345. * @param space The space that the rotation should be in
  6346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6347. * @returns The rotation matrix
  6348. */
  6349. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6350. /**
  6351. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6352. * @param space The space that the rotation should be in
  6353. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6354. * @param result The quaternion that the rotation should be copied to
  6355. */
  6356. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6357. /**
  6358. * Get the world position of a point that is in the local space of the bone
  6359. * @param position The local position
  6360. * @param mesh The mesh that this bone is attached to
  6361. * @returns The world position
  6362. */
  6363. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6364. /**
  6365. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6366. * @param position The local position
  6367. * @param mesh The mesh that this bone is attached to
  6368. * @param result The vector3 that the world position should be copied to
  6369. */
  6370. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6371. /**
  6372. * Get the local position of a point that is in world space
  6373. * @param position The world position
  6374. * @param mesh The mesh that this bone is attached to
  6375. * @returns The local position
  6376. */
  6377. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6378. /**
  6379. * Get the local position of a point that is in world space and copy it to the result param
  6380. * @param position The world position
  6381. * @param mesh The mesh that this bone is attached to
  6382. * @param result The vector3 that the local position should be copied to
  6383. */
  6384. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6385. }
  6386. }
  6387. declare module BABYLON {
  6388. /**
  6389. * Class used to apply inverse kinematics to bones
  6390. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6391. */
  6392. class BoneIKController {
  6393. private static _tmpVecs;
  6394. private static _tmpQuat;
  6395. private static _tmpMats;
  6396. /**
  6397. * Gets or sets the target mesh
  6398. */
  6399. targetMesh: AbstractMesh;
  6400. /** Gets or sets the mesh used as pole */
  6401. poleTargetMesh: AbstractMesh;
  6402. /**
  6403. * Gets or sets the bone used as pole
  6404. */
  6405. poleTargetBone: Nullable<Bone>;
  6406. /**
  6407. * Gets or sets the target position
  6408. */
  6409. targetPosition: Vector3;
  6410. /**
  6411. * Gets or sets the pole target position
  6412. */
  6413. poleTargetPosition: Vector3;
  6414. /**
  6415. * Gets or sets the pole target local offset
  6416. */
  6417. poleTargetLocalOffset: Vector3;
  6418. /**
  6419. * Gets or sets the pole angle
  6420. */
  6421. poleAngle: number;
  6422. /**
  6423. * Gets or sets the mesh associated with the controller
  6424. */
  6425. mesh: AbstractMesh;
  6426. /**
  6427. * 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)
  6428. */
  6429. slerpAmount: number;
  6430. private _bone1Quat;
  6431. private _bone1Mat;
  6432. private _bone2Ang;
  6433. private _bone1;
  6434. private _bone2;
  6435. private _bone1Length;
  6436. private _bone2Length;
  6437. private _maxAngle;
  6438. private _maxReach;
  6439. private _rightHandedSystem;
  6440. private _bendAxis;
  6441. private _slerping;
  6442. private _adjustRoll;
  6443. /**
  6444. * Gets or sets maximum allowed angle
  6445. */
  6446. maxAngle: number;
  6447. /**
  6448. * Creates a new BoneIKController
  6449. * @param mesh defines the mesh to control
  6450. * @param bone defines the bone to control
  6451. * @param options defines options to set up the controller
  6452. */
  6453. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6454. targetMesh?: AbstractMesh;
  6455. poleTargetMesh?: AbstractMesh;
  6456. poleTargetBone?: Bone;
  6457. poleTargetLocalOffset?: Vector3;
  6458. poleAngle?: number;
  6459. bendAxis?: Vector3;
  6460. maxAngle?: number;
  6461. slerpAmount?: number;
  6462. });
  6463. private _setMaxAngle;
  6464. /**
  6465. * Force the controller to update the bones
  6466. */
  6467. update(): void;
  6468. }
  6469. }
  6470. declare module BABYLON {
  6471. /**
  6472. * Class used to make a bone look toward a point in space
  6473. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6474. */
  6475. class BoneLookController {
  6476. private static _tmpVecs;
  6477. private static _tmpQuat;
  6478. private static _tmpMats;
  6479. /**
  6480. * The target Vector3 that the bone will look at
  6481. */
  6482. target: Vector3;
  6483. /**
  6484. * The mesh that the bone is attached to
  6485. */
  6486. mesh: AbstractMesh;
  6487. /**
  6488. * The bone that will be looking to the target
  6489. */
  6490. bone: Bone;
  6491. /**
  6492. * The up axis of the coordinate system that is used when the bone is rotated
  6493. */
  6494. upAxis: Vector3;
  6495. /**
  6496. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6497. */
  6498. upAxisSpace: Space;
  6499. /**
  6500. * Used to make an adjustment to the yaw of the bone
  6501. */
  6502. adjustYaw: number;
  6503. /**
  6504. * Used to make an adjustment to the pitch of the bone
  6505. */
  6506. adjustPitch: number;
  6507. /**
  6508. * Used to make an adjustment to the roll of the bone
  6509. */
  6510. adjustRoll: number;
  6511. /**
  6512. * 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)
  6513. */
  6514. slerpAmount: number;
  6515. private _minYaw;
  6516. private _maxYaw;
  6517. private _minPitch;
  6518. private _maxPitch;
  6519. private _minYawSin;
  6520. private _minYawCos;
  6521. private _maxYawSin;
  6522. private _maxYawCos;
  6523. private _midYawConstraint;
  6524. private _minPitchTan;
  6525. private _maxPitchTan;
  6526. private _boneQuat;
  6527. private _slerping;
  6528. private _transformYawPitch;
  6529. private _transformYawPitchInv;
  6530. private _firstFrameSkipped;
  6531. private _yawRange;
  6532. private _fowardAxis;
  6533. /**
  6534. * Gets or sets the minimum yaw angle that the bone can look to
  6535. */
  6536. minYaw: number;
  6537. /**
  6538. * Gets or sets the maximum yaw angle that the bone can look to
  6539. */
  6540. maxYaw: number;
  6541. /**
  6542. * Gets or sets the minimum pitch angle that the bone can look to
  6543. */
  6544. minPitch: number;
  6545. /**
  6546. * Gets or sets the maximum pitch angle that the bone can look to
  6547. */
  6548. maxPitch: number;
  6549. /**
  6550. * Create a BoneLookController
  6551. * @param mesh the mesh that the bone belongs to
  6552. * @param bone the bone that will be looking to the target
  6553. * @param target the target Vector3 to look at
  6554. * @param settings optional settings:
  6555. * * maxYaw: the maximum angle the bone will yaw to
  6556. * * minYaw: the minimum angle the bone will yaw to
  6557. * * maxPitch: the maximum angle the bone will pitch to
  6558. * * minPitch: the minimum angle the bone will yaw to
  6559. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6560. * * upAxis: the up axis of the coordinate system
  6561. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6562. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6563. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6564. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6565. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6566. * * adjustRoll: used to make an adjustment to the roll of the bone
  6567. **/
  6568. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6569. maxYaw?: number;
  6570. minYaw?: number;
  6571. maxPitch?: number;
  6572. minPitch?: number;
  6573. slerpAmount?: number;
  6574. upAxis?: Vector3;
  6575. upAxisSpace?: Space;
  6576. yawAxis?: Vector3;
  6577. pitchAxis?: Vector3;
  6578. adjustYaw?: number;
  6579. adjustPitch?: number;
  6580. adjustRoll?: number;
  6581. });
  6582. /**
  6583. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6584. */
  6585. update(): void;
  6586. private _getAngleDiff;
  6587. private _getAngleBetween;
  6588. private _isAngleBetween;
  6589. }
  6590. }
  6591. declare module BABYLON {
  6592. /**
  6593. * Class used to handle skinning animations
  6594. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6595. */
  6596. class Skeleton implements IAnimatable {
  6597. /** defines the skeleton name */
  6598. name: string;
  6599. /** defines the skeleton Id */
  6600. id: string;
  6601. /**
  6602. * Defines the list of child bones
  6603. */
  6604. bones: Bone[];
  6605. /**
  6606. * Defines an estimate of the dimension of the skeleton at rest
  6607. */
  6608. dimensionsAtRest: Vector3;
  6609. /**
  6610. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6611. */
  6612. needInitialSkinMatrix: boolean;
  6613. /**
  6614. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  6615. */
  6616. overrideMesh: Nullable<AbstractMesh>;
  6617. /**
  6618. * Gets the list of animations attached to this skeleton
  6619. */
  6620. animations: Array<Animation>;
  6621. private _scene;
  6622. private _isDirty;
  6623. private _transformMatrices;
  6624. private _transformMatrixTexture;
  6625. private _meshesWithPoseMatrix;
  6626. private _animatables;
  6627. private _identity;
  6628. private _synchronizedWithMesh;
  6629. private _ranges;
  6630. private _lastAbsoluteTransformsUpdateId;
  6631. private _canUseTextureForBones;
  6632. /** @hidden */
  6633. _numBonesWithLinkedTransformNode: number;
  6634. /**
  6635. * Specifies if the skeleton should be serialized
  6636. */
  6637. doNotSerialize: boolean;
  6638. /**
  6639. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  6640. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  6641. */
  6642. useTextureToStoreBoneMatrices: boolean;
  6643. private _animationPropertiesOverride;
  6644. /**
  6645. * Gets or sets the animation properties override
  6646. */
  6647. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6648. /**
  6649. * An observable triggered before computing the skeleton's matrices
  6650. */
  6651. onBeforeComputeObservable: Observable<Skeleton>;
  6652. /**
  6653. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  6654. */
  6655. readonly isUsingTextureForMatrices: boolean;
  6656. /**
  6657. * Creates a new skeleton
  6658. * @param name defines the skeleton name
  6659. * @param id defines the skeleton Id
  6660. * @param scene defines the hosting scene
  6661. */
  6662. constructor(
  6663. /** defines the skeleton name */
  6664. name: string,
  6665. /** defines the skeleton Id */
  6666. id: string, scene: Scene);
  6667. /**
  6668. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6669. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6670. * @returns a Float32Array containing matrices data
  6671. */
  6672. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6673. /**
  6674. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  6675. * @returns a raw texture containing the data
  6676. */
  6677. getTransformMatrixTexture(): Nullable<RawTexture>;
  6678. /**
  6679. * Gets the current hosting scene
  6680. * @returns a scene object
  6681. */
  6682. getScene(): Scene;
  6683. /**
  6684. * Gets a string representing the current skeleton data
  6685. * @param fullDetails defines a boolean indicating if we want a verbose version
  6686. * @returns a string representing the current skeleton data
  6687. */
  6688. toString(fullDetails?: boolean): string;
  6689. /**
  6690. * Get bone's index searching by name
  6691. * @param name defines bone's name to search for
  6692. * @return the indice of the bone. Returns -1 if not found
  6693. */
  6694. getBoneIndexByName(name: string): number;
  6695. /**
  6696. * Creater a new animation range
  6697. * @param name defines the name of the range
  6698. * @param from defines the start key
  6699. * @param to defines the end key
  6700. */
  6701. createAnimationRange(name: string, from: number, to: number): void;
  6702. /**
  6703. * Delete a specific animation range
  6704. * @param name defines the name of the range
  6705. * @param deleteFrames defines if frames must be removed as well
  6706. */
  6707. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6708. /**
  6709. * Gets a specific animation range
  6710. * @param name defines the name of the range to look for
  6711. * @returns the requested animation range or null if not found
  6712. */
  6713. getAnimationRange(name: string): Nullable<AnimationRange>;
  6714. /**
  6715. * Gets the list of all animation ranges defined on this skeleton
  6716. * @returns an array
  6717. */
  6718. getAnimationRanges(): Nullable<AnimationRange>[];
  6719. /**
  6720. * Copy animation range from a source skeleton.
  6721. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6722. * @param source defines the source skeleton
  6723. * @param name defines the name of the range to copy
  6724. * @param rescaleAsRequired defines if rescaling must be applied if required
  6725. * @returns true if operation was successful
  6726. */
  6727. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6728. /**
  6729. * Forces the skeleton to go to rest pose
  6730. */
  6731. returnToRest(): void;
  6732. private _getHighestAnimationFrame;
  6733. /**
  6734. * Begin a specific animation range
  6735. * @param name defines the name of the range to start
  6736. * @param loop defines if looping must be turned on (false by default)
  6737. * @param speedRatio defines the speed ratio to apply (1 by default)
  6738. * @param onAnimationEnd defines a callback which will be called when animation will end
  6739. * @returns a new animatable
  6740. */
  6741. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6742. /** @hidden */
  6743. _markAsDirty(): void;
  6744. /** @hidden */
  6745. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6746. /** @hidden */
  6747. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6748. private _computeTransformMatrices;
  6749. /**
  6750. * Build all resources required to render a skeleton
  6751. */
  6752. prepare(): void;
  6753. /**
  6754. * Gets the list of animatables currently running for this skeleton
  6755. * @returns an array of animatables
  6756. */
  6757. getAnimatables(): IAnimatable[];
  6758. /**
  6759. * Clone the current skeleton
  6760. * @param name defines the name of the new skeleton
  6761. * @param id defines the id of the enw skeleton
  6762. * @returns the new skeleton
  6763. */
  6764. clone(name: string, id: string): Skeleton;
  6765. /**
  6766. * Enable animation blending for this skeleton
  6767. * @param blendingSpeed defines the blending speed to apply
  6768. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6769. */
  6770. enableBlending(blendingSpeed?: number): void;
  6771. /**
  6772. * Releases all resources associated with the current skeleton
  6773. */
  6774. dispose(): void;
  6775. /**
  6776. * Serialize the skeleton in a JSON object
  6777. * @returns a JSON object
  6778. */
  6779. serialize(): any;
  6780. /**
  6781. * Creates a new skeleton from serialized data
  6782. * @param parsedSkeleton defines the serialized data
  6783. * @param scene defines the hosting scene
  6784. * @returns a new skeleton
  6785. */
  6786. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6787. /**
  6788. * Compute all node absolute transforms
  6789. * @param forceUpdate defines if computation must be done even if cache is up to date
  6790. */
  6791. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6792. /**
  6793. * Gets the root pose matrix
  6794. * @returns a matrix
  6795. */
  6796. getPoseMatrix(): Nullable<Matrix>;
  6797. /**
  6798. * Sorts bones per internal index
  6799. */
  6800. sortBones(): void;
  6801. private _sortBones;
  6802. }
  6803. }
  6804. declare module BABYLON {
  6805. /** @hidden */
  6806. class Collider {
  6807. /** Define if a collision was found */
  6808. collisionFound: boolean;
  6809. /**
  6810. * Define last intersection point in local space
  6811. */
  6812. intersectionPoint: Vector3;
  6813. /**
  6814. * Define last collided mesh
  6815. */
  6816. collidedMesh: Nullable<AbstractMesh>;
  6817. private _collisionPoint;
  6818. private _planeIntersectionPoint;
  6819. private _tempVector;
  6820. private _tempVector2;
  6821. private _tempVector3;
  6822. private _tempVector4;
  6823. private _edge;
  6824. private _baseToVertex;
  6825. private _destinationPoint;
  6826. private _slidePlaneNormal;
  6827. private _displacementVector;
  6828. /** @hidden */
  6829. _radius: Vector3;
  6830. /** @hidden */
  6831. _retry: number;
  6832. private _velocity;
  6833. private _basePoint;
  6834. private _epsilon;
  6835. /** @hidden */
  6836. _velocityWorldLength: number;
  6837. /** @hidden */
  6838. _basePointWorld: Vector3;
  6839. private _velocityWorld;
  6840. private _normalizedVelocity;
  6841. /** @hidden */
  6842. _initialVelocity: Vector3;
  6843. /** @hidden */
  6844. _initialPosition: Vector3;
  6845. private _nearestDistance;
  6846. private _collisionMask;
  6847. collisionMask: number;
  6848. /**
  6849. * Gets the plane normal used to compute the sliding response (in local space)
  6850. */
  6851. readonly slidePlaneNormal: Vector3;
  6852. /** @hidden */
  6853. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6854. /** @hidden */
  6855. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6856. /** @hidden */
  6857. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6858. /** @hidden */
  6859. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6860. /** @hidden */
  6861. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6862. /** @hidden */
  6863. _getResponse(pos: Vector3, vel: Vector3): void;
  6864. }
  6865. }
  6866. declare module BABYLON {
  6867. /** @hidden */
  6868. var CollisionWorker: string;
  6869. /** @hidden */
  6870. interface ICollisionCoordinator {
  6871. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6872. init(scene: Scene): void;
  6873. destroy(): void;
  6874. onMeshAdded(mesh: AbstractMesh): void;
  6875. onMeshUpdated(mesh: AbstractMesh): void;
  6876. onMeshRemoved(mesh: AbstractMesh): void;
  6877. onGeometryAdded(geometry: Geometry): void;
  6878. onGeometryUpdated(geometry: Geometry): void;
  6879. onGeometryDeleted(geometry: Geometry): void;
  6880. }
  6881. /** @hidden */
  6882. interface SerializedMesh {
  6883. id: string;
  6884. name: string;
  6885. uniqueId: number;
  6886. geometryId: Nullable<string>;
  6887. sphereCenter: Array<number>;
  6888. sphereRadius: number;
  6889. boxMinimum: Array<number>;
  6890. boxMaximum: Array<number>;
  6891. worldMatrixFromCache: any;
  6892. subMeshes: Array<SerializedSubMesh>;
  6893. checkCollisions: boolean;
  6894. }
  6895. /** @hidden */
  6896. interface SerializedSubMesh {
  6897. position: number;
  6898. verticesStart: number;
  6899. verticesCount: number;
  6900. indexStart: number;
  6901. indexCount: number;
  6902. hasMaterial: boolean;
  6903. sphereCenter: Array<number>;
  6904. sphereRadius: number;
  6905. boxMinimum: Array<number>;
  6906. boxMaximum: Array<number>;
  6907. }
  6908. /**
  6909. * Interface describing the value associated with a geometry.
  6910. * @hidden
  6911. */
  6912. interface SerializedGeometry {
  6913. /**
  6914. * Defines the unique ID of the geometry
  6915. */
  6916. id: string;
  6917. /**
  6918. * Defines the array containing the positions
  6919. */
  6920. positions: Float32Array;
  6921. /**
  6922. * Defines the array containing the indices
  6923. */
  6924. indices: Uint32Array;
  6925. /**
  6926. * Defines the array containing the normals
  6927. */
  6928. normals: Float32Array;
  6929. }
  6930. /** @hidden */
  6931. interface BabylonMessage {
  6932. taskType: WorkerTaskType;
  6933. payload: InitPayload | CollidePayload | UpdatePayload;
  6934. }
  6935. /** @hidden */
  6936. interface SerializedColliderToWorker {
  6937. position: Array<number>;
  6938. velocity: Array<number>;
  6939. radius: Array<number>;
  6940. }
  6941. /** Defines supported task for worker process */
  6942. enum WorkerTaskType {
  6943. /** Initialization */
  6944. INIT = 0,
  6945. /** Update of geometry */
  6946. UPDATE = 1,
  6947. /** Evaluate collision */
  6948. COLLIDE = 2
  6949. }
  6950. /** @hidden */
  6951. interface WorkerReply {
  6952. error: WorkerReplyType;
  6953. taskType: WorkerTaskType;
  6954. payload?: any;
  6955. }
  6956. /** @hidden */
  6957. interface CollisionReplyPayload {
  6958. newPosition: Array<number>;
  6959. collisionId: number;
  6960. collidedMeshUniqueId: number;
  6961. }
  6962. /** @hidden */
  6963. interface InitPayload {
  6964. }
  6965. /** @hidden */
  6966. interface CollidePayload {
  6967. collisionId: number;
  6968. collider: SerializedColliderToWorker;
  6969. maximumRetry: number;
  6970. excludedMeshUniqueId: Nullable<number>;
  6971. }
  6972. /** @hidden */
  6973. interface UpdatePayload {
  6974. updatedMeshes: {
  6975. [n: number]: SerializedMesh;
  6976. };
  6977. updatedGeometries: {
  6978. [s: string]: SerializedGeometry;
  6979. };
  6980. removedMeshes: Array<number>;
  6981. removedGeometries: Array<string>;
  6982. }
  6983. /** Defines kind of replies returned by worker */
  6984. enum WorkerReplyType {
  6985. /** Success */
  6986. SUCCESS = 0,
  6987. /** Unkown error */
  6988. UNKNOWN_ERROR = 1
  6989. }
  6990. /** @hidden */
  6991. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6992. private _scene;
  6993. private _scaledPosition;
  6994. private _scaledVelocity;
  6995. private _collisionsCallbackArray;
  6996. private _init;
  6997. private _runningUpdated;
  6998. private _worker;
  6999. private _addUpdateMeshesList;
  7000. private _addUpdateGeometriesList;
  7001. private _toRemoveMeshesArray;
  7002. private _toRemoveGeometryArray;
  7003. constructor();
  7004. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  7005. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  7006. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  7007. init(scene: Scene): void;
  7008. destroy(): void;
  7009. onMeshAdded(mesh: AbstractMesh): void;
  7010. onMeshUpdated: (transformNode: TransformNode) => void;
  7011. onMeshRemoved(mesh: AbstractMesh): void;
  7012. onGeometryAdded(geometry: Geometry): void;
  7013. onGeometryUpdated: (geometry: Geometry) => void;
  7014. onGeometryDeleted(geometry: Geometry): void;
  7015. private _afterRender;
  7016. private _onMessageFromWorker;
  7017. }
  7018. /** @hidden */
  7019. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  7020. private _scene;
  7021. private _scaledPosition;
  7022. private _scaledVelocity;
  7023. private _finalPosition;
  7024. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  7025. init(scene: Scene): void;
  7026. destroy(): void;
  7027. onMeshAdded(mesh: AbstractMesh): void;
  7028. onMeshUpdated(mesh: AbstractMesh): void;
  7029. onMeshRemoved(mesh: AbstractMesh): void;
  7030. onGeometryAdded(geometry: Geometry): void;
  7031. onGeometryUpdated(geometry: Geometry): void;
  7032. onGeometryDeleted(geometry: Geometry): void;
  7033. private _collideWithWorld;
  7034. }
  7035. }
  7036. declare function importScripts(...urls: string[]): void;
  7037. declare const safePostMessage: any;
  7038. declare module BABYLON {
  7039. /** @hidden */
  7040. var WorkerIncluded: boolean;
  7041. /** @hidden */
  7042. class CollisionCache {
  7043. private _meshes;
  7044. private _geometries;
  7045. getMeshes(): {
  7046. [n: number]: SerializedMesh;
  7047. };
  7048. getGeometries(): {
  7049. [s: number]: SerializedGeometry;
  7050. };
  7051. getMesh(id: any): SerializedMesh;
  7052. addMesh(mesh: SerializedMesh): void;
  7053. removeMesh(uniqueId: number): void;
  7054. getGeometry(id: string): SerializedGeometry;
  7055. addGeometry(geometry: SerializedGeometry): void;
  7056. removeGeometry(id: string): void;
  7057. }
  7058. /** @hidden */
  7059. class CollideWorker {
  7060. collider: Collider;
  7061. private _collisionCache;
  7062. private finalPosition;
  7063. private collisionsScalingMatrix;
  7064. private collisionTranformationMatrix;
  7065. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  7066. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  7067. private checkCollision;
  7068. private processCollisionsForSubMeshes;
  7069. private collideForSubMesh;
  7070. private checkSubmeshCollision;
  7071. }
  7072. /** @hidden */
  7073. interface ICollisionDetector {
  7074. onInit(payload: InitPayload): void;
  7075. onUpdate(payload: UpdatePayload): void;
  7076. onCollision(payload: CollidePayload): void;
  7077. }
  7078. /** @hidden */
  7079. class CollisionDetectorTransferable implements ICollisionDetector {
  7080. private _collisionCache;
  7081. onInit(payload: InitPayload): void;
  7082. onUpdate(payload: UpdatePayload): void;
  7083. onCollision(payload: CollidePayload): void;
  7084. }
  7085. }
  7086. declare module BABYLON {
  7087. /**
  7088. * @hidden
  7089. */
  7090. class IntersectionInfo {
  7091. bu: Nullable<number>;
  7092. bv: Nullable<number>;
  7093. distance: number;
  7094. faceId: number;
  7095. subMeshId: number;
  7096. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7097. }
  7098. /**
  7099. * Information about the result of picking within a scene
  7100. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  7101. */
  7102. class PickingInfo {
  7103. /**
  7104. * If the pick collided with an object
  7105. */
  7106. hit: boolean;
  7107. /**
  7108. * Distance away where the pick collided
  7109. */
  7110. distance: number;
  7111. /**
  7112. * The location of pick collision
  7113. */
  7114. pickedPoint: Nullable<Vector3>;
  7115. /**
  7116. * The mesh corresponding the the pick collision
  7117. */
  7118. pickedMesh: Nullable<AbstractMesh>;
  7119. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  7120. bu: number;
  7121. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  7122. bv: number;
  7123. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  7124. faceId: number;
  7125. /** Id of the the submesh that was picked */
  7126. subMeshId: number;
  7127. /** If a sprite was picked, this will be the sprite the pick collided with */
  7128. pickedSprite: Nullable<Sprite>;
  7129. /**
  7130. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  7131. */
  7132. originMesh: Nullable<AbstractMesh>;
  7133. /**
  7134. * The ray that was used to perform the picking.
  7135. */
  7136. ray: Nullable<Ray>;
  7137. /**
  7138. * Gets the normal correspodning to the face the pick collided with
  7139. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  7140. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  7141. * @returns The normal correspodning to the face the pick collided with
  7142. */
  7143. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  7144. /**
  7145. * Gets the texture coordinates of where the pick occured
  7146. * @returns the vector containing the coordnates of the texture
  7147. */
  7148. getTextureCoordinates(): Nullable<Vector2>;
  7149. }
  7150. }
  7151. declare module BABYLON {
  7152. /**
  7153. * Class used to store bounding box information
  7154. */
  7155. class BoundingBox implements ICullable {
  7156. /**
  7157. * Gets the 8 vectors representing the bounding box in local space
  7158. */
  7159. readonly vectors: Vector3[];
  7160. /**
  7161. * Gets the center of the bounding box in local space
  7162. */
  7163. readonly center: Vector3;
  7164. /**
  7165. * Gets the center of the bounding box in world space
  7166. */
  7167. readonly centerWorld: Vector3;
  7168. /**
  7169. * Gets the extend size in local space
  7170. */
  7171. readonly extendSize: Vector3;
  7172. /**
  7173. * Gets the extend size in world space
  7174. */
  7175. readonly extendSizeWorld: Vector3;
  7176. /**
  7177. * Gets the OBB (object bounding box) directions
  7178. */
  7179. readonly directions: Vector3[];
  7180. /**
  7181. * Gets the 8 vectors representing the bounding box in world space
  7182. */
  7183. readonly vectorsWorld: Vector3[];
  7184. /**
  7185. * Gets the minimum vector in world space
  7186. */
  7187. readonly minimumWorld: Vector3;
  7188. /**
  7189. * Gets the maximum vector in world space
  7190. */
  7191. readonly maximumWorld: Vector3;
  7192. /**
  7193. * Gets the minimum vector in local space
  7194. */
  7195. readonly minimum: Vector3;
  7196. /**
  7197. * Gets the maximum vector in local space
  7198. */
  7199. readonly maximum: Vector3;
  7200. private _worldMatrix;
  7201. private static readonly TmpVector3;
  7202. /**
  7203. * @hidden
  7204. */
  7205. _tag: number;
  7206. /**
  7207. * Creates a new bounding box
  7208. * @param min defines the minimum vector (in local space)
  7209. * @param max defines the maximum vector (in local space)
  7210. * @param worldMatrix defines the new world matrix
  7211. */
  7212. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7213. /**
  7214. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7215. * @param min defines the new minimum vector (in local space)
  7216. * @param max defines the new maximum vector (in local space)
  7217. * @param worldMatrix defines the new world matrix
  7218. */
  7219. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7220. /**
  7221. * Scale the current bounding box by applying a scale factor
  7222. * @param factor defines the scale factor to apply
  7223. * @returns the current bounding box
  7224. */
  7225. scale(factor: number): BoundingBox;
  7226. /**
  7227. * Gets the world matrix of the bounding box
  7228. * @returns a matrix
  7229. */
  7230. getWorldMatrix(): DeepImmutable<Matrix>;
  7231. /** @hidden */
  7232. _update(world: DeepImmutable<Matrix>): void;
  7233. /**
  7234. * Tests if the bounding box is intersecting the frustum planes
  7235. * @param frustumPlanes defines the frustum planes to test
  7236. * @returns true if there is an intersection
  7237. */
  7238. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7239. /**
  7240. * Tests if the bounding box is entirely inside the frustum planes
  7241. * @param frustumPlanes defines the frustum planes to test
  7242. * @returns true if there is an inclusion
  7243. */
  7244. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7245. /**
  7246. * Tests if a point is inside the bounding box
  7247. * @param point defines the point to test
  7248. * @returns true if the point is inside the bounding box
  7249. */
  7250. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7251. /**
  7252. * Tests if the bounding box intersects with a bounding sphere
  7253. * @param sphere defines the sphere to test
  7254. * @returns true if there is an intersection
  7255. */
  7256. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7257. /**
  7258. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7259. * @param min defines the min vector to use
  7260. * @param max defines the max vector to use
  7261. * @returns true if there is an intersection
  7262. */
  7263. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7264. /**
  7265. * Tests if two bounding boxes are intersections
  7266. * @param box0 defines the first box to test
  7267. * @param box1 defines the second box to test
  7268. * @returns true if there is an intersection
  7269. */
  7270. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7271. /**
  7272. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7273. * @param minPoint defines the minimum vector of the bounding box
  7274. * @param maxPoint defines the maximum vector of the bounding box
  7275. * @param sphereCenter defines the sphere center
  7276. * @param sphereRadius defines the sphere radius
  7277. * @returns true if there is an intersection
  7278. */
  7279. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7280. /**
  7281. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7282. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7283. * @param frustumPlanes defines the frustum planes to test
  7284. * @return true if there is an inclusion
  7285. */
  7286. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7287. /**
  7288. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7289. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7290. * @param frustumPlanes defines the frustum planes to test
  7291. * @return true if there is an intersection
  7292. */
  7293. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7294. }
  7295. }
  7296. declare module BABYLON {
  7297. /**
  7298. * Interface for cullable objects
  7299. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7300. */
  7301. interface ICullable {
  7302. /**
  7303. * Checks if the object or part of the object is in the frustum
  7304. * @param frustumPlanes Camera near/planes
  7305. * @returns true if the object is in frustum otherwise false
  7306. */
  7307. isInFrustum(frustumPlanes: Plane[]): boolean;
  7308. /**
  7309. * Checks if a cullable object (mesh...) is in the camera frustum
  7310. * Unlike isInFrustum this cheks the full bounding box
  7311. * @param frustumPlanes Camera near/planes
  7312. * @returns true if the object is in frustum otherwise false
  7313. */
  7314. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7315. }
  7316. /**
  7317. * Info for a bounding data of a mesh
  7318. */
  7319. class BoundingInfo implements ICullable {
  7320. /**
  7321. * Bounding box for the mesh
  7322. */
  7323. readonly boundingBox: BoundingBox;
  7324. /**
  7325. * Bounding sphere for the mesh
  7326. */
  7327. readonly boundingSphere: BoundingSphere;
  7328. private _isLocked;
  7329. private static readonly TmpVector3;
  7330. /**
  7331. * Constructs bounding info
  7332. * @param minimum min vector of the bounding box/sphere
  7333. * @param maximum max vector of the bounding box/sphere
  7334. * @param worldMatrix defines the new world matrix
  7335. */
  7336. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7337. /**
  7338. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7339. * @param min defines the new minimum vector (in local space)
  7340. * @param max defines the new maximum vector (in local space)
  7341. * @param worldMatrix defines the new world matrix
  7342. */
  7343. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7344. /**
  7345. * min vector of the bounding box/sphere
  7346. */
  7347. readonly minimum: Vector3;
  7348. /**
  7349. * max vector of the bounding box/sphere
  7350. */
  7351. readonly maximum: Vector3;
  7352. /**
  7353. * If the info is locked and won't be updated to avoid perf overhead
  7354. */
  7355. isLocked: boolean;
  7356. /**
  7357. * Updates the bounding sphere and box
  7358. * @param world world matrix to be used to update
  7359. */
  7360. update(world: DeepImmutable<Matrix>): void;
  7361. /**
  7362. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7363. * @param center New center of the bounding info
  7364. * @param extend New extend of the bounding info
  7365. * @returns the current bounding info
  7366. */
  7367. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7368. /**
  7369. * Scale the current bounding info by applying a scale factor
  7370. * @param factor defines the scale factor to apply
  7371. * @returns the current bounding info
  7372. */
  7373. scale(factor: number): BoundingInfo;
  7374. /**
  7375. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7376. * @param frustumPlanes defines the frustum to test
  7377. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7378. * @returns true if the bounding info is in the frustum planes
  7379. */
  7380. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7381. /**
  7382. * Gets the world distance between the min and max points of the bounding box
  7383. */
  7384. readonly diagonalLength: number;
  7385. /**
  7386. * Checks if a cullable object (mesh...) is in the camera frustum
  7387. * Unlike isInFrustum this cheks the full bounding box
  7388. * @param frustumPlanes Camera near/planes
  7389. * @returns true if the object is in frustum otherwise false
  7390. */
  7391. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7392. /** @hidden */
  7393. _checkCollision(collider: Collider): boolean;
  7394. /**
  7395. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7396. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7397. * @param point the point to check intersection with
  7398. * @returns if the point intersects
  7399. */
  7400. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7401. /**
  7402. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7403. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7404. * @param boundingInfo the bounding info to check intersection with
  7405. * @param precise if the intersection should be done using OBB
  7406. * @returns if the bounding info intersects
  7407. */
  7408. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7409. }
  7410. }
  7411. declare module BABYLON {
  7412. /**
  7413. * Class used to store bounding sphere information
  7414. */
  7415. class BoundingSphere {
  7416. /**
  7417. * Gets the center of the bounding sphere in local space
  7418. */
  7419. readonly center: Vector3;
  7420. /**
  7421. * Radius of the bounding sphere in local space
  7422. */
  7423. radius: number;
  7424. /**
  7425. * Gets the center of the bounding sphere in world space
  7426. */
  7427. readonly centerWorld: Vector3;
  7428. /**
  7429. * Radius of the bounding sphere in world space
  7430. */
  7431. radiusWorld: number;
  7432. /**
  7433. * Gets the minimum vector in local space
  7434. */
  7435. readonly minimum: Vector3;
  7436. /**
  7437. * Gets the maximum vector in local space
  7438. */
  7439. readonly maximum: Vector3;
  7440. private _worldMatrix;
  7441. private static readonly TmpVector3;
  7442. /**
  7443. * Creates a new bounding sphere
  7444. * @param min defines the minimum vector (in local space)
  7445. * @param max defines the maximum vector (in local space)
  7446. * @param worldMatrix defines the new world matrix
  7447. */
  7448. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7449. /**
  7450. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7451. * @param min defines the new minimum vector (in local space)
  7452. * @param max defines the new maximum vector (in local space)
  7453. * @param worldMatrix defines the new world matrix
  7454. */
  7455. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7456. /**
  7457. * Scale the current bounding sphere by applying a scale factor
  7458. * @param factor defines the scale factor to apply
  7459. * @returns the current bounding box
  7460. */
  7461. scale(factor: number): BoundingSphere;
  7462. /**
  7463. * Gets the world matrix of the bounding box
  7464. * @returns a matrix
  7465. */
  7466. getWorldMatrix(): DeepImmutable<Matrix>;
  7467. /** @hidden */
  7468. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7469. /**
  7470. * Tests if the bounding sphere is intersecting the frustum planes
  7471. * @param frustumPlanes defines the frustum planes to test
  7472. * @returns true if there is an intersection
  7473. */
  7474. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7475. /**
  7476. * Tests if the bounding sphere center is in between the frustum planes.
  7477. * Used for optimistic fast inclusion.
  7478. * @param frustumPlanes defines the frustum planes to test
  7479. * @returns true if the sphere center is in between the frustum planes
  7480. */
  7481. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7482. /**
  7483. * Tests if a point is inside the bounding sphere
  7484. * @param point defines the point to test
  7485. * @returns true if the point is inside the bounding sphere
  7486. */
  7487. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7488. /**
  7489. * Checks if two sphere intersct
  7490. * @param sphere0 sphere 0
  7491. * @param sphere1 sphere 1
  7492. * @returns true if the speres intersect
  7493. */
  7494. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7495. }
  7496. }
  7497. declare module BABYLON {
  7498. /**
  7499. * Class representing a ray with position and direction
  7500. */
  7501. class Ray {
  7502. /** origin point */
  7503. origin: Vector3;
  7504. /** direction */
  7505. direction: Vector3;
  7506. /** length of the ray */
  7507. length: number;
  7508. private static readonly TmpVector3;
  7509. private _tmpRay;
  7510. /**
  7511. * Creates a new ray
  7512. * @param origin origin point
  7513. * @param direction direction
  7514. * @param length length of the ray
  7515. */
  7516. constructor(
  7517. /** origin point */
  7518. origin: Vector3,
  7519. /** direction */
  7520. direction: Vector3,
  7521. /** length of the ray */
  7522. length?: number);
  7523. /**
  7524. * Checks if the ray intersects a box
  7525. * @param minimum bound of the box
  7526. * @param maximum bound of the box
  7527. * @param intersectionTreshold extra extend to be added to the box in all direction
  7528. * @returns if the box was hit
  7529. */
  7530. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  7531. /**
  7532. * Checks if the ray intersects a box
  7533. * @param box the bounding box to check
  7534. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  7535. * @returns if the box was hit
  7536. */
  7537. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  7538. /**
  7539. * If the ray hits a sphere
  7540. * @param sphere the bounding sphere to check
  7541. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  7542. * @returns true if it hits the sphere
  7543. */
  7544. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  7545. /**
  7546. * If the ray hits a triange
  7547. * @param vertex0 triangle vertex
  7548. * @param vertex1 triangle vertex
  7549. * @param vertex2 triangle vertex
  7550. * @returns intersection information if hit
  7551. */
  7552. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  7553. /**
  7554. * Checks if ray intersects a plane
  7555. * @param plane the plane to check
  7556. * @returns the distance away it was hit
  7557. */
  7558. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  7559. /**
  7560. * Checks if ray intersects a mesh
  7561. * @param mesh the mesh to check
  7562. * @param fastCheck if only the bounding box should checked
  7563. * @returns picking info of the intersecton
  7564. */
  7565. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  7566. /**
  7567. * Checks if ray intersects a mesh
  7568. * @param meshes the meshes to check
  7569. * @param fastCheck if only the bounding box should checked
  7570. * @param results array to store result in
  7571. * @returns Array of picking infos
  7572. */
  7573. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  7574. private _comparePickingInfo;
  7575. private static smallnum;
  7576. private static rayl;
  7577. /**
  7578. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  7579. * @param sega the first point of the segment to test the intersection against
  7580. * @param segb the second point of the segment to test the intersection against
  7581. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  7582. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  7583. */
  7584. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  7585. /**
  7586. * Update the ray from viewport position
  7587. * @param x position
  7588. * @param y y position
  7589. * @param viewportWidth viewport width
  7590. * @param viewportHeight viewport height
  7591. * @param world world matrix
  7592. * @param view view matrix
  7593. * @param projection projection matrix
  7594. * @returns this ray updated
  7595. */
  7596. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7597. /**
  7598. * Creates a ray with origin and direction of 0,0,0
  7599. * @returns the new ray
  7600. */
  7601. static Zero(): Ray;
  7602. /**
  7603. * Creates a new ray from screen space and viewport
  7604. * @param x position
  7605. * @param y y position
  7606. * @param viewportWidth viewport width
  7607. * @param viewportHeight viewport height
  7608. * @param world world matrix
  7609. * @param view view matrix
  7610. * @param projection projection matrix
  7611. * @returns new ray
  7612. */
  7613. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7614. /**
  7615. * 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
  7616. * transformed to the given world matrix.
  7617. * @param origin The origin point
  7618. * @param end The end point
  7619. * @param world a matrix to transform the ray to. Default is the identity matrix.
  7620. * @returns the new ray
  7621. */
  7622. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  7623. /**
  7624. * Transforms a ray by a matrix
  7625. * @param ray ray to transform
  7626. * @param matrix matrix to apply
  7627. * @returns the resulting new ray
  7628. */
  7629. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  7630. /**
  7631. * Transforms a ray by a matrix
  7632. * @param ray ray to transform
  7633. * @param matrix matrix to apply
  7634. * @param result ray to store result in
  7635. */
  7636. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  7637. }
  7638. }
  7639. /**
  7640. * Module Debug contains the (visual) components to debug a scene correctly
  7641. */
  7642. declare module BABYLON.Debug {
  7643. /**
  7644. * The Axes viewer will show 3 axes in a specific point in space
  7645. */
  7646. class AxesViewer {
  7647. private _xAxis;
  7648. private _yAxis;
  7649. private _zAxis;
  7650. private _scaleLinesFactor;
  7651. private _instanced;
  7652. /**
  7653. * Gets the hosting scene
  7654. */
  7655. scene: Scene;
  7656. /**
  7657. * Gets or sets a number used to scale line length
  7658. */
  7659. scaleLines: number;
  7660. /** Gets the node hierarchy used to render x-axis */
  7661. readonly xAxis: TransformNode;
  7662. /** Gets the node hierarchy used to render y-axis */
  7663. readonly yAxis: TransformNode;
  7664. /** Gets the node hierarchy used to render z-axis */
  7665. readonly zAxis: TransformNode;
  7666. /**
  7667. * Creates a new AxesViewer
  7668. * @param scene defines the hosting scene
  7669. * @param scaleLines defines a number used to scale line length (1 by default)
  7670. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  7671. * @param xAxis defines the node hierarchy used to render the x-axis
  7672. * @param yAxis defines the node hierarchy used to render the y-axis
  7673. * @param zAxis defines the node hierarchy used to render the z-axis
  7674. */
  7675. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  7676. /**
  7677. * Force the viewer to update
  7678. * @param position defines the position of the viewer
  7679. * @param xaxis defines the x axis of the viewer
  7680. * @param yaxis defines the y axis of the viewer
  7681. * @param zaxis defines the z axis of the viewer
  7682. */
  7683. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  7684. /**
  7685. * Creates an instance of this axes viewer.
  7686. * @returns a new axes viewer with instanced meshes
  7687. */
  7688. createInstance(): AxesViewer;
  7689. /** Releases resources */
  7690. dispose(): void;
  7691. private static _SetRenderingGroupId;
  7692. }
  7693. }
  7694. declare module BABYLON.Debug {
  7695. /**
  7696. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  7697. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  7698. */
  7699. class BoneAxesViewer extends AxesViewer {
  7700. /**
  7701. * Gets or sets the target mesh where to display the axes viewer
  7702. */
  7703. mesh: Nullable<Mesh>;
  7704. /**
  7705. * Gets or sets the target bone where to display the axes viewer
  7706. */
  7707. bone: Nullable<Bone>;
  7708. /** Gets current position */
  7709. pos: Vector3;
  7710. /** Gets direction of X axis */
  7711. xaxis: Vector3;
  7712. /** Gets direction of Y axis */
  7713. yaxis: Vector3;
  7714. /** Gets direction of Z axis */
  7715. zaxis: Vector3;
  7716. /**
  7717. * Creates a new BoneAxesViewer
  7718. * @param scene defines the hosting scene
  7719. * @param bone defines the target bone
  7720. * @param mesh defines the target mesh
  7721. * @param scaleLines defines a scaling factor for line length (1 by default)
  7722. */
  7723. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  7724. /**
  7725. * Force the viewer to update
  7726. */
  7727. update(): void;
  7728. /** Releases resources */
  7729. dispose(): void;
  7730. }
  7731. }
  7732. declare module BABYLON {
  7733. /**
  7734. * Interface used to define scene explorer extensibility option
  7735. */
  7736. interface IExplorerExtensibilityOption {
  7737. /**
  7738. * Define the option label
  7739. */
  7740. label: string;
  7741. /**
  7742. * Defines the action to execute on click
  7743. */
  7744. action: (entity: any) => void;
  7745. }
  7746. /**
  7747. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  7748. */
  7749. interface IExplorerExtensibilityGroup {
  7750. /**
  7751. * Defines a predicate to test if a given type mut be extended
  7752. */
  7753. predicate: (entity: any) => boolean;
  7754. /**
  7755. * Gets the list of options added to a type
  7756. */
  7757. entries: IExplorerExtensibilityOption[];
  7758. }
  7759. /**
  7760. * Interface used to define the options to use to create the Inspector
  7761. */
  7762. interface IInspectorOptions {
  7763. /**
  7764. * Display in overlay mode (default: false)
  7765. */
  7766. overlay?: boolean;
  7767. /**
  7768. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  7769. */
  7770. globalRoot?: HTMLElement;
  7771. /**
  7772. * Display the Scene explorer
  7773. */
  7774. showExplorer?: boolean;
  7775. /**
  7776. * Display the property inspector
  7777. */
  7778. showInspector?: boolean;
  7779. /**
  7780. * Display in embed mode (both panes on the right)
  7781. */
  7782. embedMode?: boolean;
  7783. /**
  7784. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  7785. */
  7786. handleResize?: boolean;
  7787. /**
  7788. * Allow the panes to popup (default: true)
  7789. */
  7790. enablePopup?: boolean;
  7791. /**
  7792. * Allow the panes to be closed by users (default: true)
  7793. */
  7794. enableClose?: boolean;
  7795. /**
  7796. * Optional list of extensibility entries
  7797. */
  7798. explorerExtensibility?: IExplorerExtensibilityGroup[];
  7799. }
  7800. interface Scene {
  7801. /**
  7802. * @hidden
  7803. * Backing field
  7804. */
  7805. _debugLayer: DebugLayer;
  7806. /**
  7807. * Gets the debug layer (aka Inspector) associated with the scene
  7808. * @see http://doc.babylonjs.com/features/playground_debuglayer
  7809. */
  7810. debugLayer: DebugLayer;
  7811. }
  7812. /**
  7813. * The debug layer (aka Inspector) is the go to tool in order to better understand
  7814. * what is happening in your scene
  7815. * @see http://doc.babylonjs.com/features/playground_debuglayer
  7816. */
  7817. class DebugLayer {
  7818. /**
  7819. * Define the url to get the inspector script from.
  7820. * By default it uses the babylonjs CDN.
  7821. * @ignoreNaming
  7822. */
  7823. static InspectorURL: string;
  7824. private _scene;
  7825. private BJSINSPECTOR;
  7826. /**
  7827. * Observable triggered when a property is changed through the inspector.
  7828. */
  7829. onPropertyChangedObservable: Observable<{
  7830. object: any;
  7831. property: string;
  7832. value: any;
  7833. initialValue: any;
  7834. }>;
  7835. /**
  7836. * Instantiates a new debug layer.
  7837. * The debug layer (aka Inspector) is the go to tool in order to better understand
  7838. * what is happening in your scene
  7839. * @see http://doc.babylonjs.com/features/playground_debuglayer
  7840. * @param scene Defines the scene to inspect
  7841. */
  7842. constructor(scene: Scene);
  7843. /** Creates the inspector window. */
  7844. private _createInspector;
  7845. /** Get the inspector from bundle or global */
  7846. private _getGlobalInspector;
  7847. /**
  7848. * Get if the inspector is visible or not.
  7849. * @returns true if visible otherwise, false
  7850. */
  7851. isVisible(): boolean;
  7852. /**
  7853. * Hide the inspector and close its window.
  7854. */
  7855. hide(): void;
  7856. /**
  7857. * Launch the debugLayer.
  7858. * @param config Define the configuration of the inspector
  7859. */
  7860. show(config?: IInspectorOptions): void;
  7861. }
  7862. }
  7863. declare module BABYLON.Debug {
  7864. /**
  7865. * Used to show the physics impostor around the specific mesh
  7866. */
  7867. class PhysicsViewer {
  7868. /** @hidden */
  7869. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  7870. /** @hidden */
  7871. protected _meshes: Array<Nullable<AbstractMesh>>;
  7872. /** @hidden */
  7873. protected _scene: Nullable<Scene>;
  7874. /** @hidden */
  7875. protected _numMeshes: number;
  7876. /** @hidden */
  7877. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  7878. private _renderFunction;
  7879. private _utilityLayer;
  7880. private _debugBoxMesh;
  7881. private _debugSphereMesh;
  7882. private _debugMaterial;
  7883. /**
  7884. * Creates a new PhysicsViewer
  7885. * @param scene defines the hosting scene
  7886. */
  7887. constructor(scene: Scene);
  7888. /** @hidden */
  7889. protected _updateDebugMeshes(): void;
  7890. /**
  7891. * Renders a specified physic impostor
  7892. * @param impostor defines the impostor to render
  7893. * @returns the new debug mesh used to render the impostor
  7894. */
  7895. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  7896. /**
  7897. * Hides a specified physic impostor
  7898. * @param impostor defines the impostor to hide
  7899. */
  7900. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  7901. private _getDebugMaterial;
  7902. private _getDebugBoxMesh;
  7903. private _getDebugSphereMesh;
  7904. private _getDebugMesh;
  7905. /** Releases all resources */
  7906. dispose(): void;
  7907. }
  7908. }
  7909. declare module BABYLON {
  7910. /**
  7911. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  7912. * in order to better appreciate the issue one might have.
  7913. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  7914. */
  7915. class RayHelper {
  7916. /**
  7917. * Defines the ray we are currently tryin to visualize.
  7918. */
  7919. ray: Nullable<Ray>;
  7920. private _renderPoints;
  7921. private _renderLine;
  7922. private _renderFunction;
  7923. private _scene;
  7924. private _updateToMeshFunction;
  7925. private _attachedToMesh;
  7926. private _meshSpaceDirection;
  7927. private _meshSpaceOrigin;
  7928. /**
  7929. * Helper function to create a colored helper in a scene in one line.
  7930. * @param ray Defines the ray we are currently tryin to visualize
  7931. * @param scene Defines the scene the ray is used in
  7932. * @param color Defines the color we want to see the ray in
  7933. * @returns The newly created ray helper.
  7934. */
  7935. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  7936. /**
  7937. * Instantiate a new ray helper.
  7938. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  7939. * in order to better appreciate the issue one might have.
  7940. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  7941. * @param ray Defines the ray we are currently tryin to visualize
  7942. */
  7943. constructor(ray: Ray);
  7944. /**
  7945. * Shows the ray we are willing to debug.
  7946. * @param scene Defines the scene the ray needs to be rendered in
  7947. * @param color Defines the color the ray needs to be rendered in
  7948. */
  7949. show(scene: Scene, color?: Color3): void;
  7950. /**
  7951. * Hides the ray we are debugging.
  7952. */
  7953. hide(): void;
  7954. private _render;
  7955. /**
  7956. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  7957. * @param mesh Defines the mesh we want the helper attached to
  7958. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  7959. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  7960. * @param length Defines the length of the ray
  7961. */
  7962. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  7963. /**
  7964. * Detach the ray helper from the mesh it has previously been attached to.
  7965. */
  7966. detachFromMesh(): void;
  7967. private _updateToMesh;
  7968. /**
  7969. * Dispose the helper and release its associated resources.
  7970. */
  7971. dispose(): void;
  7972. }
  7973. }
  7974. declare module BABYLON.Debug {
  7975. /**
  7976. * Class used to render a debug view of a given skeleton
  7977. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  7978. */
  7979. class SkeletonViewer {
  7980. /** defines the skeleton to render */
  7981. skeleton: Skeleton;
  7982. /** defines the mesh attached to the skeleton */
  7983. mesh: AbstractMesh;
  7984. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  7985. autoUpdateBonesMatrices: boolean;
  7986. /** defines the rendering group id to use with the viewer */
  7987. renderingGroupId: number;
  7988. /** Gets or sets the color used to render the skeleton */
  7989. color: Color3;
  7990. private _scene;
  7991. private _debugLines;
  7992. private _debugMesh;
  7993. private _isEnabled;
  7994. private _renderFunction;
  7995. private _utilityLayer;
  7996. /**
  7997. * Returns the mesh used to render the bones
  7998. */
  7999. readonly debugMesh: Nullable<LinesMesh>;
  8000. /**
  8001. * Creates a new SkeletonViewer
  8002. * @param skeleton defines the skeleton to render
  8003. * @param mesh defines the mesh attached to the skeleton
  8004. * @param scene defines the hosting scene
  8005. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  8006. * @param renderingGroupId defines the rendering group id to use with the viewer
  8007. */
  8008. constructor(
  8009. /** defines the skeleton to render */
  8010. skeleton: Skeleton,
  8011. /** defines the mesh attached to the skeleton */
  8012. mesh: AbstractMesh, scene: Scene,
  8013. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  8014. autoUpdateBonesMatrices?: boolean,
  8015. /** defines the rendering group id to use with the viewer */
  8016. renderingGroupId?: number);
  8017. /** Gets or sets a boolean indicating if the viewer is enabled */
  8018. isEnabled: boolean;
  8019. private _getBonePosition;
  8020. private _getLinesForBonesWithLength;
  8021. private _getLinesForBonesNoLength;
  8022. /** Update the viewer to sync with current skeleton state */
  8023. update(): void;
  8024. /** Release associated resources */
  8025. dispose(): void;
  8026. }
  8027. }
  8028. declare module BABYLON {
  8029. /**
  8030. * This represents an orbital type of camera.
  8031. *
  8032. * 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.
  8033. * 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.
  8034. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  8035. */
  8036. class ArcRotateCamera extends TargetCamera {
  8037. /**
  8038. * Defines the rotation angle of the camera along the longitudinal axis.
  8039. */
  8040. alpha: number;
  8041. /**
  8042. * Defines the rotation angle of the camera along the latitudinal axis.
  8043. */
  8044. beta: number;
  8045. /**
  8046. * Defines the radius of the camera from it s target point.
  8047. */
  8048. radius: number;
  8049. protected _target: Vector3;
  8050. protected _targetHost: Nullable<AbstractMesh>;
  8051. /**
  8052. * Defines the target point of the camera.
  8053. * The camera looks towards it form the radius distance.
  8054. */
  8055. target: Vector3;
  8056. /**
  8057. * Current inertia value on the longitudinal axis.
  8058. * The bigger this number the longer it will take for the camera to stop.
  8059. */
  8060. inertialAlphaOffset: number;
  8061. /**
  8062. * Current inertia value on the latitudinal axis.
  8063. * The bigger this number the longer it will take for the camera to stop.
  8064. */
  8065. inertialBetaOffset: number;
  8066. /**
  8067. * Current inertia value on the radius axis.
  8068. * The bigger this number the longer it will take for the camera to stop.
  8069. */
  8070. inertialRadiusOffset: number;
  8071. /**
  8072. * Minimum allowed angle on the longitudinal axis.
  8073. * This can help limiting how the Camera is able to move in the scene.
  8074. */
  8075. lowerAlphaLimit: Nullable<number>;
  8076. /**
  8077. * Maximum allowed angle on the longitudinal axis.
  8078. * This can help limiting how the Camera is able to move in the scene.
  8079. */
  8080. upperAlphaLimit: Nullable<number>;
  8081. /**
  8082. * Minimum allowed angle on the latitudinal axis.
  8083. * This can help limiting how the Camera is able to move in the scene.
  8084. */
  8085. lowerBetaLimit: number;
  8086. /**
  8087. * Maximum allowed angle on the latitudinal axis.
  8088. * This can help limiting how the Camera is able to move in the scene.
  8089. */
  8090. upperBetaLimit: number;
  8091. /**
  8092. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  8093. * This can help limiting how the Camera is able to move in the scene.
  8094. */
  8095. lowerRadiusLimit: Nullable<number>;
  8096. /**
  8097. * Maximum allowed distance of the camera to the target (The camera can not get further).
  8098. * This can help limiting how the Camera is able to move in the scene.
  8099. */
  8100. upperRadiusLimit: Nullable<number>;
  8101. /**
  8102. * Defines the current inertia value used during panning of the camera along the X axis.
  8103. */
  8104. inertialPanningX: number;
  8105. /**
  8106. * Defines the current inertia value used during panning of the camera along the Y axis.
  8107. */
  8108. inertialPanningY: number;
  8109. /**
  8110. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  8111. * Basically if your fingers moves away from more than this distance you will be considered
  8112. * in pinch mode.
  8113. */
  8114. pinchToPanMaxDistance: number;
  8115. /**
  8116. * Defines the maximum distance the camera can pan.
  8117. * This could help keeping the cammera always in your scene.
  8118. */
  8119. panningDistanceLimit: Nullable<number>;
  8120. /**
  8121. * Defines the target of the camera before paning.
  8122. */
  8123. panningOriginTarget: Vector3;
  8124. /**
  8125. * Defines the value of the inertia used during panning.
  8126. * 0 would mean stop inertia and one would mean no decelleration at all.
  8127. */
  8128. panningInertia: number;
  8129. /**
  8130. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  8131. */
  8132. angularSensibilityX: number;
  8133. /**
  8134. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  8135. */
  8136. angularSensibilityY: number;
  8137. /**
  8138. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  8139. */
  8140. pinchPrecision: number;
  8141. /**
  8142. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  8143. * It will be used instead of pinchDeltaPrecision if different from 0.
  8144. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  8145. */
  8146. pinchDeltaPercentage: number;
  8147. /**
  8148. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  8149. */
  8150. panningSensibility: number;
  8151. /**
  8152. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  8153. */
  8154. keysUp: number[];
  8155. /**
  8156. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  8157. */
  8158. keysDown: number[];
  8159. /**
  8160. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  8161. */
  8162. keysLeft: number[];
  8163. /**
  8164. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  8165. */
  8166. keysRight: number[];
  8167. /**
  8168. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  8169. */
  8170. wheelPrecision: number;
  8171. /**
  8172. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  8173. * It will be used instead of pinchDeltaPrecision if different from 0.
  8174. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  8175. */
  8176. wheelDeltaPercentage: number;
  8177. /**
  8178. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  8179. */
  8180. zoomOnFactor: number;
  8181. /**
  8182. * Defines a screen offset for the camera position.
  8183. */
  8184. targetScreenOffset: Vector2;
  8185. /**
  8186. * Allows the camera to be completely reversed.
  8187. * If false the camera can not arrive upside down.
  8188. */
  8189. allowUpsideDown: boolean;
  8190. /**
  8191. * Define if double tap/click is used to restore the previously saved state of the camera.
  8192. */
  8193. useInputToRestoreState: boolean;
  8194. /** @hidden */
  8195. _viewMatrix: Matrix;
  8196. /** @hidden */
  8197. _useCtrlForPanning: boolean;
  8198. /** @hidden */
  8199. _panningMouseButton: number;
  8200. /**
  8201. * Defines the inpute associated to the camera.
  8202. */
  8203. inputs: ArcRotateCameraInputsManager;
  8204. /** @hidden */
  8205. _reset: () => void;
  8206. /**
  8207. * Defines the allowed panning axis.
  8208. */
  8209. panningAxis: Vector3;
  8210. protected _localDirection: Vector3;
  8211. protected _transformedDirection: Vector3;
  8212. private _bouncingBehavior;
  8213. /**
  8214. * Gets the bouncing behavior of the camera if it has been enabled.
  8215. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  8216. */
  8217. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  8218. /**
  8219. * Defines if the bouncing behavior of the camera is enabled on the camera.
  8220. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  8221. */
  8222. useBouncingBehavior: boolean;
  8223. private _framingBehavior;
  8224. /**
  8225. * Gets the framing behavior of the camera if it has been enabled.
  8226. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8227. */
  8228. readonly framingBehavior: Nullable<FramingBehavior>;
  8229. /**
  8230. * Defines if the framing behavior of the camera is enabled on the camera.
  8231. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8232. */
  8233. useFramingBehavior: boolean;
  8234. private _autoRotationBehavior;
  8235. /**
  8236. * Gets the auto rotation behavior of the camera if it has been enabled.
  8237. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  8238. */
  8239. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  8240. /**
  8241. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  8242. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  8243. */
  8244. useAutoRotationBehavior: boolean;
  8245. /**
  8246. * Observable triggered when the mesh target has been changed on the camera.
  8247. */
  8248. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  8249. /**
  8250. * Event raised when the camera is colliding with a mesh.
  8251. */
  8252. onCollide: (collidedMesh: AbstractMesh) => void;
  8253. /**
  8254. * Defines whether the camera should check collision with the objects oh the scene.
  8255. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  8256. */
  8257. checkCollisions: boolean;
  8258. /**
  8259. * Defines the collision radius of the camera.
  8260. * This simulates a sphere around the camera.
  8261. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8262. */
  8263. collisionRadius: Vector3;
  8264. protected _collider: Collider;
  8265. protected _previousPosition: Vector3;
  8266. protected _collisionVelocity: Vector3;
  8267. protected _newPosition: Vector3;
  8268. protected _previousAlpha: number;
  8269. protected _previousBeta: number;
  8270. protected _previousRadius: number;
  8271. protected _collisionTriggered: boolean;
  8272. protected _targetBoundingCenter: Nullable<Vector3>;
  8273. private _computationVector;
  8274. private _tempAxisVector;
  8275. private _tempAxisRotationMatrix;
  8276. /**
  8277. * Instantiates a new ArcRotateCamera in a given scene
  8278. * @param name Defines the name of the camera
  8279. * @param alpha Defines the camera rotation along the logitudinal axis
  8280. * @param beta Defines the camera rotation along the latitudinal axis
  8281. * @param radius Defines the camera distance from its target
  8282. * @param target Defines the camera target
  8283. * @param scene Defines the scene the camera belongs to
  8284. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8285. */
  8286. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8287. /** @hidden */
  8288. _initCache(): void;
  8289. /** @hidden */
  8290. _updateCache(ignoreParentClass?: boolean): void;
  8291. protected _getTargetPosition(): Vector3;
  8292. private _storedAlpha;
  8293. private _storedBeta;
  8294. private _storedRadius;
  8295. private _storedTarget;
  8296. /**
  8297. * Stores the current state of the camera (alpha, beta, radius and target)
  8298. * @returns the camera itself
  8299. */
  8300. storeState(): Camera;
  8301. /**
  8302. * @hidden
  8303. * Restored camera state. You must call storeState() first
  8304. */
  8305. _restoreStateValues(): boolean;
  8306. /** @hidden */
  8307. _isSynchronizedViewMatrix(): boolean;
  8308. /**
  8309. * Attached controls to the current camera.
  8310. * @param element Defines the element the controls should be listened from
  8311. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8312. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  8313. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  8314. */
  8315. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  8316. /**
  8317. * Detach the current controls from the camera.
  8318. * The camera will stop reacting to inputs.
  8319. * @param element Defines the element to stop listening the inputs from
  8320. */
  8321. detachControl(element: HTMLElement): void;
  8322. /** @hidden */
  8323. _checkInputs(): void;
  8324. protected _checkLimits(): void;
  8325. /**
  8326. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  8327. */
  8328. rebuildAnglesAndRadius(): void;
  8329. /**
  8330. * Use a position to define the current camera related information like aplha, beta and radius
  8331. * @param position Defines the position to set the camera at
  8332. */
  8333. setPosition(position: Vector3): void;
  8334. /**
  8335. * Defines the target the camera should look at.
  8336. * This will automatically adapt alpha beta and radius to fit within the new target.
  8337. * @param target Defines the new target as a Vector or a mesh
  8338. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  8339. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  8340. */
  8341. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  8342. /** @hidden */
  8343. _getViewMatrix(): Matrix;
  8344. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  8345. /**
  8346. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  8347. * @param meshes Defines the mesh to zoom on
  8348. * @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)
  8349. */
  8350. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  8351. /**
  8352. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  8353. * The target will be changed but the radius
  8354. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  8355. * @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)
  8356. */
  8357. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  8358. min: Vector3;
  8359. max: Vector3;
  8360. distance: number;
  8361. }, doNotUpdateMaxZ?: boolean): void;
  8362. /**
  8363. * @override
  8364. * Override Camera.createRigCamera
  8365. */
  8366. createRigCamera(name: string, cameraIndex: number): Camera;
  8367. /**
  8368. * @hidden
  8369. * @override
  8370. * Override Camera._updateRigCameras
  8371. */
  8372. _updateRigCameras(): void;
  8373. /**
  8374. * Destroy the camera and release the current resources hold by it.
  8375. */
  8376. dispose(): void;
  8377. /**
  8378. * Gets the current object class name.
  8379. * @return the class name
  8380. */
  8381. getClassName(): string;
  8382. }
  8383. }
  8384. declare module BABYLON {
  8385. /**
  8386. * Default Inputs manager for the ArcRotateCamera.
  8387. * It groups all the default supported inputs for ease of use.
  8388. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8389. */
  8390. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  8391. /**
  8392. * Instantiates a new ArcRotateCameraInputsManager.
  8393. * @param camera Defines the camera the inputs belong to
  8394. */
  8395. constructor(camera: ArcRotateCamera);
  8396. /**
  8397. * Add mouse wheel input support to the input manager.
  8398. * @returns the current input manager
  8399. */
  8400. addMouseWheel(): ArcRotateCameraInputsManager;
  8401. /**
  8402. * Add pointers input support to the input manager.
  8403. * @returns the current input manager
  8404. */
  8405. addPointers(): ArcRotateCameraInputsManager;
  8406. /**
  8407. * Add keyboard input support to the input manager.
  8408. * @returns the current input manager
  8409. */
  8410. addKeyboard(): ArcRotateCameraInputsManager;
  8411. /**
  8412. * Add orientation input support to the input manager.
  8413. * @returns the current input manager
  8414. */
  8415. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  8416. }
  8417. }
  8418. declare module BABYLON {
  8419. /**
  8420. * This is the base class of all the camera used in the application.
  8421. * @see http://doc.babylonjs.com/features/cameras
  8422. */
  8423. class Camera extends Node {
  8424. /**
  8425. * This is the default projection mode used by the cameras.
  8426. * It helps recreating a feeling of perspective and better appreciate depth.
  8427. * This is the best way to simulate real life cameras.
  8428. */
  8429. static readonly PERSPECTIVE_CAMERA: number;
  8430. /**
  8431. * This helps creating camera with an orthographic mode.
  8432. * 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.
  8433. */
  8434. static readonly ORTHOGRAPHIC_CAMERA: number;
  8435. /**
  8436. * This is the default FOV mode for perspective cameras.
  8437. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  8438. */
  8439. static readonly FOVMODE_VERTICAL_FIXED: number;
  8440. /**
  8441. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  8442. */
  8443. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  8444. /**
  8445. * This specifies ther is no need for a camera rig.
  8446. * Basically only one eye is rendered corresponding to the camera.
  8447. */
  8448. static readonly RIG_MODE_NONE: number;
  8449. /**
  8450. * Simulates a camera Rig with one blue eye and one red eye.
  8451. * This can be use with 3d blue and red glasses.
  8452. */
  8453. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  8454. /**
  8455. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  8456. */
  8457. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  8458. /**
  8459. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  8460. */
  8461. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  8462. /**
  8463. * Defines that both eyes of the camera will be rendered over under each other.
  8464. */
  8465. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  8466. /**
  8467. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  8468. */
  8469. static readonly RIG_MODE_VR: number;
  8470. /**
  8471. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  8472. */
  8473. static readonly RIG_MODE_WEBVR: number;
  8474. /**
  8475. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  8476. */
  8477. static readonly RIG_MODE_CUSTOM: number;
  8478. /**
  8479. * Defines if by default attaching controls should prevent the default javascript event to continue.
  8480. */
  8481. static ForceAttachControlToAlwaysPreventDefault: boolean;
  8482. /**
  8483. * @hidden
  8484. * Might be removed once multiview will be a thing
  8485. */
  8486. static UseAlternateWebVRRendering: boolean;
  8487. /**
  8488. * Define the input manager associated with the camera.
  8489. */
  8490. inputs: CameraInputsManager<Camera>;
  8491. /**
  8492. * Define the current local position of the camera in the scene
  8493. */
  8494. position: Vector3;
  8495. /**
  8496. * The vector the camera should consider as up.
  8497. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  8498. */
  8499. upVector: Vector3;
  8500. /**
  8501. * Define the current limit on the left side for an orthographic camera
  8502. * In scene unit
  8503. */
  8504. orthoLeft: Nullable<number>;
  8505. /**
  8506. * Define the current limit on the right side for an orthographic camera
  8507. * In scene unit
  8508. */
  8509. orthoRight: Nullable<number>;
  8510. /**
  8511. * Define the current limit on the bottom side for an orthographic camera
  8512. * In scene unit
  8513. */
  8514. orthoBottom: Nullable<number>;
  8515. /**
  8516. * Define the current limit on the top side for an orthographic camera
  8517. * In scene unit
  8518. */
  8519. orthoTop: Nullable<number>;
  8520. /**
  8521. * Field Of View is set in Radians. (default is 0.8)
  8522. */
  8523. fov: number;
  8524. /**
  8525. * Define the minimum distance the camera can see from.
  8526. * This is important to note that the depth buffer are not infinite and the closer it starts
  8527. * the more your scene might encounter depth fighting issue.
  8528. */
  8529. minZ: number;
  8530. /**
  8531. * Define the maximum distance the camera can see to.
  8532. * This is important to note that the depth buffer are not infinite and the further it end
  8533. * the more your scene might encounter depth fighting issue.
  8534. */
  8535. maxZ: number;
  8536. /**
  8537. * Define the default inertia of the camera.
  8538. * This helps giving a smooth feeling to the camera movement.
  8539. */
  8540. inertia: number;
  8541. /**
  8542. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  8543. */
  8544. mode: number;
  8545. /**
  8546. * Define wether the camera is intermediate.
  8547. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  8548. */
  8549. isIntermediate: boolean;
  8550. /**
  8551. * Define the viewport of the camera.
  8552. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  8553. */
  8554. viewport: Viewport;
  8555. /**
  8556. * Restricts the camera to viewing objects with the same layerMask.
  8557. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  8558. */
  8559. layerMask: number;
  8560. /**
  8561. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  8562. */
  8563. fovMode: number;
  8564. /**
  8565. * Rig mode of the camera.
  8566. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  8567. * This is normally controlled byt the camera themselves as internal use.
  8568. */
  8569. cameraRigMode: number;
  8570. /**
  8571. * Defines the distance between both "eyes" in case of a RIG
  8572. */
  8573. interaxialDistance: number;
  8574. /**
  8575. * Defines if stereoscopic rendering is done side by side or over under.
  8576. */
  8577. isStereoscopicSideBySide: boolean;
  8578. /**
  8579. * 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
  8580. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  8581. * else in the scene.
  8582. */
  8583. customRenderTargets: RenderTargetTexture[];
  8584. /**
  8585. * When set, the camera will render to this render target instead of the default canvas
  8586. */
  8587. outputRenderTarget: Nullable<RenderTargetTexture>;
  8588. /**
  8589. * Observable triggered when the camera view matrix has changed.
  8590. */
  8591. onViewMatrixChangedObservable: Observable<Camera>;
  8592. /**
  8593. * Observable triggered when the camera Projection matrix has changed.
  8594. */
  8595. onProjectionMatrixChangedObservable: Observable<Camera>;
  8596. /**
  8597. * Observable triggered when the inputs have been processed.
  8598. */
  8599. onAfterCheckInputsObservable: Observable<Camera>;
  8600. /**
  8601. * Observable triggered when reset has been called and applied to the camera.
  8602. */
  8603. onRestoreStateObservable: Observable<Camera>;
  8604. /** @hidden */
  8605. _cameraRigParams: any;
  8606. /** @hidden */
  8607. _rigCameras: Camera[];
  8608. /** @hidden */
  8609. _rigPostProcess: Nullable<PostProcess>;
  8610. protected _webvrViewMatrix: Matrix;
  8611. /** @hidden */
  8612. _skipRendering: boolean;
  8613. /** @hidden */
  8614. _alternateCamera: Camera;
  8615. /** @hidden */
  8616. _projectionMatrix: Matrix;
  8617. /** @hidden */
  8618. _postProcesses: Nullable<PostProcess>[];
  8619. /** @hidden */
  8620. _activeMeshes: SmartArray<AbstractMesh>;
  8621. protected _globalPosition: Vector3;
  8622. /** hidden */
  8623. _computedViewMatrix: Matrix;
  8624. private _doNotComputeProjectionMatrix;
  8625. private _transformMatrix;
  8626. private _frustumPlanes;
  8627. private _refreshFrustumPlanes;
  8628. private _storedFov;
  8629. private _stateStored;
  8630. /**
  8631. * Instantiates a new camera object.
  8632. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  8633. * @see http://doc.babylonjs.com/features/cameras
  8634. * @param name Defines the name of the camera in the scene
  8635. * @param position Defines the position of the camera
  8636. * @param scene Defines the scene the camera belongs too
  8637. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  8638. */
  8639. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8640. /**
  8641. * Store current camera state (fov, position, etc..)
  8642. * @returns the camera
  8643. */
  8644. storeState(): Camera;
  8645. /**
  8646. * Restores the camera state values if it has been stored. You must call storeState() first
  8647. */
  8648. protected _restoreStateValues(): boolean;
  8649. /**
  8650. * Restored camera state. You must call storeState() first.
  8651. * @returns true if restored and false otherwise
  8652. */
  8653. restoreState(): boolean;
  8654. /**
  8655. * Gets the class name of the camera.
  8656. * @returns the class name
  8657. */
  8658. getClassName(): string;
  8659. /**
  8660. * Gets a string representation of the camera useful for debug purpose.
  8661. * @param fullDetails Defines that a more verboe level of logging is required
  8662. * @returns the string representation
  8663. */
  8664. toString(fullDetails?: boolean): string;
  8665. /**
  8666. * Gets the current world space position of the camera.
  8667. */
  8668. readonly globalPosition: Vector3;
  8669. /**
  8670. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  8671. * @returns the active meshe list
  8672. */
  8673. getActiveMeshes(): SmartArray<AbstractMesh>;
  8674. /**
  8675. * Check wether a mesh is part of the current active mesh list of the camera
  8676. * @param mesh Defines the mesh to check
  8677. * @returns true if active, false otherwise
  8678. */
  8679. isActiveMesh(mesh: Mesh): boolean;
  8680. /**
  8681. * Is this camera ready to be used/rendered
  8682. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  8683. * @return true if the camera is ready
  8684. */
  8685. isReady(completeCheck?: boolean): boolean;
  8686. /** @hidden */
  8687. _initCache(): void;
  8688. /** @hidden */
  8689. _updateCache(ignoreParentClass?: boolean): void;
  8690. /** @hidden */
  8691. _isSynchronized(): boolean;
  8692. /** @hidden */
  8693. _isSynchronizedViewMatrix(): boolean;
  8694. /** @hidden */
  8695. _isSynchronizedProjectionMatrix(): boolean;
  8696. /**
  8697. * Attach the input controls to a specific dom element to get the input from.
  8698. * @param element Defines the element the controls should be listened from
  8699. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8700. */
  8701. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8702. /**
  8703. * Detach the current controls from the specified dom element.
  8704. * @param element Defines the element to stop listening the inputs from
  8705. */
  8706. detachControl(element: HTMLElement): void;
  8707. /**
  8708. * Update the camera state according to the different inputs gathered during the frame.
  8709. */
  8710. update(): void;
  8711. /** @hidden */
  8712. _checkInputs(): void;
  8713. /** @hidden */
  8714. readonly rigCameras: Camera[];
  8715. /**
  8716. * Gets the post process used by the rig cameras
  8717. */
  8718. readonly rigPostProcess: Nullable<PostProcess>;
  8719. /**
  8720. * Internal, gets the first post proces.
  8721. * @returns the first post process to be run on this camera.
  8722. */
  8723. _getFirstPostProcess(): Nullable<PostProcess>;
  8724. private _cascadePostProcessesToRigCams;
  8725. /**
  8726. * Attach a post process to the camera.
  8727. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8728. * @param postProcess The post process to attach to the camera
  8729. * @param insertAt The position of the post process in case several of them are in use in the scene
  8730. * @returns the position the post process has been inserted at
  8731. */
  8732. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  8733. /**
  8734. * Detach a post process to the camera.
  8735. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8736. * @param postProcess The post process to detach from the camera
  8737. */
  8738. detachPostProcess(postProcess: PostProcess): void;
  8739. /**
  8740. * Gets the current world matrix of the camera
  8741. */
  8742. getWorldMatrix(): Matrix;
  8743. /** @hidden */
  8744. protected _getViewMatrix(): Matrix;
  8745. /**
  8746. * Gets the current view matrix of the camera.
  8747. * @param force forces the camera to recompute the matrix without looking at the cached state
  8748. * @returns the view matrix
  8749. */
  8750. getViewMatrix(force?: boolean): Matrix;
  8751. /**
  8752. * Freeze the projection matrix.
  8753. * It will prevent the cache check of the camera projection compute and can speed up perf
  8754. * if no parameter of the camera are meant to change
  8755. * @param projection Defines manually a projection if necessary
  8756. */
  8757. freezeProjectionMatrix(projection?: Matrix): void;
  8758. /**
  8759. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  8760. */
  8761. unfreezeProjectionMatrix(): void;
  8762. /**
  8763. * Gets the current projection matrix of the camera.
  8764. * @param force forces the camera to recompute the matrix without looking at the cached state
  8765. * @returns the projection matrix
  8766. */
  8767. getProjectionMatrix(force?: boolean): Matrix;
  8768. /**
  8769. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  8770. * @returns a Matrix
  8771. */
  8772. getTransformationMatrix(): Matrix;
  8773. private _updateFrustumPlanes;
  8774. /**
  8775. * Checks if a cullable object (mesh...) is in the camera frustum
  8776. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  8777. * @param target The object to check
  8778. * @returns true if the object is in frustum otherwise false
  8779. */
  8780. isInFrustum(target: ICullable): boolean;
  8781. /**
  8782. * Checks if a cullable object (mesh...) is in the camera frustum
  8783. * Unlike isInFrustum this cheks the full bounding box
  8784. * @param target The object to check
  8785. * @returns true if the object is in frustum otherwise false
  8786. */
  8787. isCompletelyInFrustum(target: ICullable): boolean;
  8788. /**
  8789. * Gets a ray in the forward direction from the camera.
  8790. * @param length Defines the length of the ray to create
  8791. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  8792. * @param origin Defines the start point of the ray which defaults to the camera position
  8793. * @returns the forward ray
  8794. */
  8795. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  8796. /**
  8797. * Releases resources associated with this node.
  8798. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8799. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8800. */
  8801. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8802. /**
  8803. * Gets the left camera of a rig setup in case of Rigged Camera
  8804. */
  8805. readonly leftCamera: Nullable<FreeCamera>;
  8806. /**
  8807. * Gets the right camera of a rig setup in case of Rigged Camera
  8808. */
  8809. readonly rightCamera: Nullable<FreeCamera>;
  8810. /**
  8811. * Gets the left camera target of a rig setup in case of Rigged Camera
  8812. * @returns the target position
  8813. */
  8814. getLeftTarget(): Nullable<Vector3>;
  8815. /**
  8816. * Gets the right camera target of a rig setup in case of Rigged Camera
  8817. * @returns the target position
  8818. */
  8819. getRightTarget(): Nullable<Vector3>;
  8820. /**
  8821. * @hidden
  8822. */
  8823. setCameraRigMode(mode: number, rigParams: any): void;
  8824. private _getVRProjectionMatrix;
  8825. protected _updateCameraRotationMatrix(): void;
  8826. protected _updateWebVRCameraRotationMatrix(): void;
  8827. /**
  8828. * This function MUST be overwritten by the different WebVR cameras available.
  8829. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8830. */
  8831. protected _getWebVRProjectionMatrix(): Matrix;
  8832. /**
  8833. * This function MUST be overwritten by the different WebVR cameras available.
  8834. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8835. */
  8836. protected _getWebVRViewMatrix(): Matrix;
  8837. /** @hidden */
  8838. setCameraRigParameter(name: string, value: any): void;
  8839. /**
  8840. * needs to be overridden by children so sub has required properties to be copied
  8841. * @hidden
  8842. */
  8843. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8844. /**
  8845. * May need to be overridden by children
  8846. * @hidden
  8847. */
  8848. _updateRigCameras(): void;
  8849. /** @hidden */
  8850. _setupInputs(): void;
  8851. /**
  8852. * Serialiaze the camera setup to a json represention
  8853. * @returns the JSON representation
  8854. */
  8855. serialize(): any;
  8856. /**
  8857. * Clones the current camera.
  8858. * @param name The cloned camera name
  8859. * @returns the cloned camera
  8860. */
  8861. clone(name: string): Camera;
  8862. /**
  8863. * Gets the direction of the camera relative to a given local axis.
  8864. * @param localAxis Defines the reference axis to provide a relative direction.
  8865. * @return the direction
  8866. */
  8867. getDirection(localAxis: Vector3): Vector3;
  8868. /**
  8869. * Gets the direction of the camera relative to a given local axis into a passed vector.
  8870. * @param localAxis Defines the reference axis to provide a relative direction.
  8871. * @param result Defines the vector to store the result in
  8872. */
  8873. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  8874. /**
  8875. * Gets a camera constructor for a given camera type
  8876. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  8877. * @param name The name of the camera the result will be able to instantiate
  8878. * @param scene The scene the result will construct the camera in
  8879. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  8880. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  8881. * @returns a factory method to construc the camera
  8882. */
  8883. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8884. /**
  8885. * Compute the world matrix of the camera.
  8886. * @returns the camera workd matrix
  8887. */
  8888. computeWorldMatrix(): Matrix;
  8889. /**
  8890. * Parse a JSON and creates the camera from the parsed information
  8891. * @param parsedCamera The JSON to parse
  8892. * @param scene The scene to instantiate the camera in
  8893. * @returns the newly constructed camera
  8894. */
  8895. static Parse(parsedCamera: any, scene: Scene): Camera;
  8896. }
  8897. }
  8898. declare module BABYLON {
  8899. /**
  8900. * @ignore
  8901. * This is a list of all the different input types that are available in the application.
  8902. * Fo instance: ArcRotateCameraGamepadInput...
  8903. */
  8904. var CameraInputTypes: {};
  8905. /**
  8906. * This is the contract to implement in order to create a new input class.
  8907. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8908. */
  8909. interface ICameraInput<TCamera extends Camera> {
  8910. /**
  8911. * Defines the camera the input is attached to.
  8912. */
  8913. camera: Nullable<TCamera>;
  8914. /**
  8915. * Gets the class name of the current intput.
  8916. * @returns the class name
  8917. */
  8918. getClassName(): string;
  8919. /**
  8920. * Get the friendly name associated with the input class.
  8921. * @returns the input friendly name
  8922. */
  8923. getSimpleName(): string;
  8924. /**
  8925. * Attach the input controls to a specific dom element to get the input from.
  8926. * @param element Defines the element the controls should be listened from
  8927. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8928. */
  8929. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8930. /**
  8931. * Detach the current controls from the specified dom element.
  8932. * @param element Defines the element to stop listening the inputs from
  8933. */
  8934. detachControl(element: Nullable<HTMLElement>): void;
  8935. /**
  8936. * Update the current camera state depending on the inputs that have been used this frame.
  8937. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8938. */
  8939. checkInputs?: () => void;
  8940. }
  8941. /**
  8942. * Represents a map of input types to input instance or input index to input instance.
  8943. */
  8944. interface CameraInputsMap<TCamera extends Camera> {
  8945. /**
  8946. * Accessor to the input by input type.
  8947. */
  8948. [name: string]: ICameraInput<TCamera>;
  8949. /**
  8950. * Accessor to the input by input index.
  8951. */
  8952. [idx: number]: ICameraInput<TCamera>;
  8953. }
  8954. /**
  8955. * This represents the input manager used within a camera.
  8956. * It helps dealing with all the different kind of input attached to a camera.
  8957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8958. */
  8959. class CameraInputsManager<TCamera extends Camera> {
  8960. /**
  8961. * Defines the list of inputs attahed to the camera.
  8962. */
  8963. attached: CameraInputsMap<TCamera>;
  8964. /**
  8965. * Defines the dom element the camera is collecting inputs from.
  8966. * This is null if the controls have not been attached.
  8967. */
  8968. attachedElement: Nullable<HTMLElement>;
  8969. /**
  8970. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8971. */
  8972. noPreventDefault: boolean;
  8973. /**
  8974. * Defined the camera the input manager belongs to.
  8975. */
  8976. camera: TCamera;
  8977. /**
  8978. * Update the current camera state depending on the inputs that have been used this frame.
  8979. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8980. */
  8981. checkInputs: () => void;
  8982. /**
  8983. * Instantiate a new Camera Input Manager.
  8984. * @param camera Defines the camera the input manager blongs to
  8985. */
  8986. constructor(camera: TCamera);
  8987. /**
  8988. * Add an input method to a camera
  8989. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8990. * @param input camera input method
  8991. */
  8992. add(input: ICameraInput<TCamera>): void;
  8993. /**
  8994. * Remove a specific input method from a camera
  8995. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8996. * @param inputToRemove camera input method
  8997. */
  8998. remove(inputToRemove: ICameraInput<TCamera>): void;
  8999. /**
  9000. * Remove a specific input type from a camera
  9001. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9002. * @param inputType the type of the input to remove
  9003. */
  9004. removeByType(inputType: string): void;
  9005. private _addCheckInputs;
  9006. /**
  9007. * Attach the input controls to the currently attached dom element to listen the events from.
  9008. * @param input Defines the input to attach
  9009. */
  9010. attachInput(input: ICameraInput<TCamera>): void;
  9011. /**
  9012. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9013. * @param element Defines the dom element to collect the events from
  9014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9015. */
  9016. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  9017. /**
  9018. * Detach the current manager inputs controls from a specific dom element.
  9019. * @param element Defines the dom element to collect the events from
  9020. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9021. */
  9022. detachElement(element: HTMLElement, disconnect?: boolean): void;
  9023. /**
  9024. * Rebuild the dynamic inputCheck function from the current list of
  9025. * defined inputs in the manager.
  9026. */
  9027. rebuildInputCheck(): void;
  9028. /**
  9029. * Remove all attached input methods from a camera
  9030. */
  9031. clear(): void;
  9032. /**
  9033. * Serialize the current input manager attached to a camera.
  9034. * This ensures than once parsed,
  9035. * the input associated to the camera will be identical to the current ones
  9036. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9037. */
  9038. serialize(serializedCamera: any): void;
  9039. /**
  9040. * Parses an input manager serialized JSON to restore the previous list of inputs
  9041. * and states associated to a camera.
  9042. * @param parsedCamera Defines the JSON to parse
  9043. */
  9044. parse(parsedCamera: any): void;
  9045. }
  9046. }
  9047. declare module BABYLON {
  9048. /**
  9049. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  9050. * being tilted forward or back and left or right.
  9051. */
  9052. class DeviceOrientationCamera extends FreeCamera {
  9053. private _initialQuaternion;
  9054. private _quaternionCache;
  9055. /**
  9056. * Creates a new device orientation camera
  9057. * @param name The name of the camera
  9058. * @param position The start position camera
  9059. * @param scene The scene the camera belongs to
  9060. */
  9061. constructor(name: string, position: Vector3, scene: Scene);
  9062. /**
  9063. * Gets the current instance class name ("DeviceOrientationCamera").
  9064. * This helps avoiding instanceof at run time.
  9065. * @returns the class name
  9066. */
  9067. getClassName(): string;
  9068. /**
  9069. * @hidden
  9070. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  9071. */
  9072. _checkInputs(): void;
  9073. /**
  9074. * Reset the camera to its default orientation on the specified axis only.
  9075. * @param axis The axis to reset
  9076. */
  9077. resetToCurrentRotation(axis?: Axis): void;
  9078. }
  9079. }
  9080. declare module BABYLON {
  9081. /**
  9082. * This is a flying camera, designed for 3D movement and rotation in all directions,
  9083. * such as in a 3D Space Shooter or a Flight Simulator.
  9084. */
  9085. class FlyCamera extends TargetCamera {
  9086. /**
  9087. * Define the collision ellipsoid of the camera.
  9088. * This is helpful for simulating a camera body, like a player's body.
  9089. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  9090. */
  9091. ellipsoid: Vector3;
  9092. /**
  9093. * Define an offset for the position of the ellipsoid around the camera.
  9094. * This can be helpful if the camera is attached away from the player's body center,
  9095. * such as at its head.
  9096. */
  9097. ellipsoidOffset: Vector3;
  9098. /**
  9099. * Enable or disable collisions of the camera with the rest of the scene objects.
  9100. */
  9101. checkCollisions: boolean;
  9102. /**
  9103. * Enable or disable gravity on the camera.
  9104. */
  9105. applyGravity: boolean;
  9106. /**
  9107. * Define the current direction the camera is moving to.
  9108. */
  9109. cameraDirection: Vector3;
  9110. /**
  9111. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  9112. * This overrides and empties cameraRotation.
  9113. */
  9114. rotationQuaternion: BABYLON.Quaternion;
  9115. /**
  9116. * Track Roll to maintain the wanted Rolling when looking around.
  9117. */
  9118. _trackRoll: number;
  9119. /**
  9120. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  9121. */
  9122. rollCorrect: number;
  9123. /**
  9124. * Mimic a banked turn, Rolling the camera when Yawing.
  9125. * It's recommended to use rollCorrect = 10 for faster banking correction.
  9126. */
  9127. bankedTurn: boolean;
  9128. /**
  9129. * Limit in radians for how much Roll banking will add. (Default: 90°)
  9130. */
  9131. bankedTurnLimit: number;
  9132. /**
  9133. * Value of 0 disables the banked Roll.
  9134. * Value of 1 is equal to the Yaw angle in radians.
  9135. */
  9136. bankedTurnMultiplier: number;
  9137. /**
  9138. * The inputs manager loads all the input sources, such as keyboard and mouse.
  9139. */
  9140. inputs: FlyCameraInputsManager;
  9141. /**
  9142. * Gets the input sensibility for mouse input.
  9143. * Higher values reduce sensitivity.
  9144. */
  9145. /**
  9146. * Sets the input sensibility for a mouse input.
  9147. * Higher values reduce sensitivity.
  9148. */
  9149. angularSensibility: number;
  9150. /**
  9151. * Get the keys for camera movement forward.
  9152. */
  9153. /**
  9154. * Set the keys for camera movement forward.
  9155. */
  9156. keysForward: number[];
  9157. /**
  9158. * Get the keys for camera movement backward.
  9159. */
  9160. keysBackward: number[];
  9161. /**
  9162. * Get the keys for camera movement up.
  9163. */
  9164. /**
  9165. * Set the keys for camera movement up.
  9166. */
  9167. keysUp: number[];
  9168. /**
  9169. * Get the keys for camera movement down.
  9170. */
  9171. /**
  9172. * Set the keys for camera movement down.
  9173. */
  9174. keysDown: number[];
  9175. /**
  9176. * Get the keys for camera movement left.
  9177. */
  9178. /**
  9179. * Set the keys for camera movement left.
  9180. */
  9181. keysLeft: number[];
  9182. /**
  9183. * Set the keys for camera movement right.
  9184. */
  9185. /**
  9186. * Set the keys for camera movement right.
  9187. */
  9188. keysRight: number[];
  9189. /**
  9190. * Event raised when the camera collides with a mesh in the scene.
  9191. */
  9192. onCollide: (collidedMesh: AbstractMesh) => void;
  9193. private _collider;
  9194. private _needMoveForGravity;
  9195. private _oldPosition;
  9196. private _diffPosition;
  9197. private _newPosition;
  9198. /** @hidden */
  9199. _localDirection: Vector3;
  9200. /** @hidden */
  9201. _transformedDirection: Vector3;
  9202. /**
  9203. * Instantiates a FlyCamera.
  9204. * This is a flying camera, designed for 3D movement and rotation in all directions,
  9205. * such as in a 3D Space Shooter or a Flight Simulator.
  9206. * @param name Define the name of the camera in the scene.
  9207. * @param position Define the starting position of the camera in the scene.
  9208. * @param scene Define the scene the camera belongs to.
  9209. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  9210. */
  9211. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9212. /**
  9213. * Attach a control to the HTML DOM element.
  9214. * @param element Defines the element that listens to the input events.
  9215. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  9216. */
  9217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9218. /**
  9219. * Detach a control from the HTML DOM element.
  9220. * The camera will stop reacting to that input.
  9221. * @param element Defines the element that listens to the input events.
  9222. */
  9223. detachControl(element: HTMLElement): void;
  9224. private _collisionMask;
  9225. /**
  9226. * Get the mask that the camera ignores in collision events.
  9227. */
  9228. /**
  9229. * Set the mask that the camera ignores in collision events.
  9230. */
  9231. collisionMask: number;
  9232. /** @hidden */
  9233. _collideWithWorld(displacement: Vector3): void;
  9234. /** @hidden */
  9235. private _onCollisionPositionChange;
  9236. /** @hidden */
  9237. _checkInputs(): void;
  9238. /** @hidden */
  9239. _decideIfNeedsToMove(): boolean;
  9240. /** @hidden */
  9241. _updatePosition(): void;
  9242. /**
  9243. * Restore the Roll to its target value at the rate specified.
  9244. * @param rate - Higher means slower restoring.
  9245. * @hidden
  9246. */
  9247. restoreRoll(rate: number): void;
  9248. /**
  9249. * Destroy the camera and release the current resources held by it.
  9250. */
  9251. dispose(): void;
  9252. /**
  9253. * Get the current object class name.
  9254. * @returns the class name.
  9255. */
  9256. getClassName(): string;
  9257. }
  9258. }
  9259. declare module BABYLON {
  9260. /**
  9261. * Default Inputs manager for the FlyCamera.
  9262. * It groups all the default supported inputs for ease of use.
  9263. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9264. */
  9265. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  9266. /**
  9267. * Instantiates a new FlyCameraInputsManager.
  9268. * @param camera Defines the camera the inputs belong to.
  9269. */
  9270. constructor(camera: FlyCamera);
  9271. /**
  9272. * Add keyboard input support to the input manager.
  9273. * @returns the new FlyCameraKeyboardMoveInput().
  9274. */
  9275. addKeyboard(): FlyCameraInputsManager;
  9276. /**
  9277. * Add mouse input support to the input manager.
  9278. * @param touchEnabled Enable touch screen support.
  9279. * @returns the new FlyCameraMouseInput().
  9280. */
  9281. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  9282. }
  9283. }
  9284. declare module BABYLON {
  9285. /**
  9286. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  9287. * an arc rotate version arcFollowCamera are available.
  9288. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  9289. */
  9290. class FollowCamera extends TargetCamera {
  9291. /**
  9292. * Distance the follow camera should follow an object at
  9293. */
  9294. radius: number;
  9295. /**
  9296. * Define a rotation offset between the camera and the object it follows
  9297. */
  9298. rotationOffset: number;
  9299. /**
  9300. * Define a height offset between the camera and the object it follows.
  9301. * It can help following an object from the top (like a car chaing a plane)
  9302. */
  9303. heightOffset: number;
  9304. /**
  9305. * Define how fast the camera can accelerate to follow it s target.
  9306. */
  9307. cameraAcceleration: number;
  9308. /**
  9309. * Define the speed limit of the camera following an object.
  9310. */
  9311. maxCameraSpeed: number;
  9312. /**
  9313. * Define the target of the camera.
  9314. */
  9315. lockedTarget: Nullable<AbstractMesh>;
  9316. /**
  9317. * Instantiates the follow camera.
  9318. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  9319. * @param name Define the name of the camera in the scene
  9320. * @param position Define the position of the camera
  9321. * @param scene Define the scene the camera belong to
  9322. * @param lockedTarget Define the target of the camera
  9323. */
  9324. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  9325. private _follow;
  9326. /** @hidden */
  9327. _checkInputs(): void;
  9328. /**
  9329. * Gets the camera class name.
  9330. * @returns the class name
  9331. */
  9332. getClassName(): string;
  9333. }
  9334. /**
  9335. * Arc Rotate version of the follow camera.
  9336. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  9337. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  9338. */
  9339. class ArcFollowCamera extends TargetCamera {
  9340. /** The longitudinal angle of the camera */
  9341. alpha: number;
  9342. /** The latitudinal angle of the camera */
  9343. beta: number;
  9344. /** The radius of the camera from its target */
  9345. radius: number;
  9346. /** Define the camera target (the messh it should follow) */
  9347. target: Nullable<AbstractMesh>;
  9348. private _cartesianCoordinates;
  9349. /**
  9350. * Instantiates a new ArcFollowCamera
  9351. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  9352. * @param name Define the name of the camera
  9353. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  9354. * @param beta Define the rotation angle of the camera around the elevation axis
  9355. * @param radius Define the radius of the camera from its target point
  9356. * @param target Define the target of the camera
  9357. * @param scene Define the scene the camera belongs to
  9358. */
  9359. constructor(name: string,
  9360. /** The longitudinal angle of the camera */
  9361. alpha: number,
  9362. /** The latitudinal angle of the camera */
  9363. beta: number,
  9364. /** The radius of the camera from its target */
  9365. radius: number,
  9366. /** Define the camera target (the messh it should follow) */
  9367. target: Nullable<AbstractMesh>, scene: Scene);
  9368. private _follow;
  9369. /** @hidden */
  9370. _checkInputs(): void;
  9371. /**
  9372. * Returns the class name of the object.
  9373. * It is mostly used internally for serialization purposes.
  9374. */
  9375. getClassName(): string;
  9376. }
  9377. }
  9378. declare module BABYLON {
  9379. /**
  9380. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  9381. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  9382. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9383. */
  9384. class FreeCamera extends TargetCamera {
  9385. /**
  9386. * Define the collision ellipsoid of the camera.
  9387. * This is helpful to simulate a camera body like the player body around the camera
  9388. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  9389. */
  9390. ellipsoid: Vector3;
  9391. /**
  9392. * Define an offset for the position of the ellipsoid around the camera.
  9393. * This can be helpful to determine the center of the body near the gravity center of the body
  9394. * instead of its head.
  9395. */
  9396. ellipsoidOffset: Vector3;
  9397. /**
  9398. * Enable or disable collisions of the camera with the rest of the scene objects.
  9399. */
  9400. checkCollisions: boolean;
  9401. /**
  9402. * Enable or disable gravity on the camera.
  9403. */
  9404. applyGravity: boolean;
  9405. /**
  9406. * Define the input manager associated to the camera.
  9407. */
  9408. inputs: FreeCameraInputsManager;
  9409. /**
  9410. * Gets the input sensibility for a mouse input. (default is 2000.0)
  9411. * Higher values reduce sensitivity.
  9412. */
  9413. /**
  9414. * Sets the input sensibility for a mouse input. (default is 2000.0)
  9415. * Higher values reduce sensitivity.
  9416. */
  9417. angularSensibility: number;
  9418. /**
  9419. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9420. */
  9421. keysUp: number[];
  9422. /**
  9423. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9424. */
  9425. keysDown: number[];
  9426. /**
  9427. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9428. */
  9429. keysLeft: number[];
  9430. /**
  9431. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9432. */
  9433. keysRight: number[];
  9434. /**
  9435. * Event raised when the camera collide with a mesh in the scene.
  9436. */
  9437. onCollide: (collidedMesh: AbstractMesh) => void;
  9438. private _collider;
  9439. private _needMoveForGravity;
  9440. private _oldPosition;
  9441. private _diffPosition;
  9442. private _newPosition;
  9443. /** @hidden */
  9444. _localDirection: Vector3;
  9445. /** @hidden */
  9446. _transformedDirection: Vector3;
  9447. /**
  9448. * Instantiates a Free Camera.
  9449. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  9450. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  9451. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9452. * @param name Define the name of the camera in the scene
  9453. * @param position Define the start position of the camera in the scene
  9454. * @param scene Define the scene the camera belongs to
  9455. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9456. */
  9457. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9458. /**
  9459. * Attached controls to the current camera.
  9460. * @param element Defines the element the controls should be listened from
  9461. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9462. */
  9463. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9464. /**
  9465. * Detach the current controls from the camera.
  9466. * The camera will stop reacting to inputs.
  9467. * @param element Defines the element to stop listening the inputs from
  9468. */
  9469. detachControl(element: HTMLElement): void;
  9470. private _collisionMask;
  9471. /**
  9472. * Define a collision mask to limit the list of object the camera can collide with
  9473. */
  9474. collisionMask: number;
  9475. /** @hidden */
  9476. _collideWithWorld(displacement: Vector3): void;
  9477. private _onCollisionPositionChange;
  9478. /** @hidden */
  9479. _checkInputs(): void;
  9480. /** @hidden */
  9481. _decideIfNeedsToMove(): boolean;
  9482. /** @hidden */
  9483. _updatePosition(): void;
  9484. /**
  9485. * Destroy the camera and release the current resources hold by it.
  9486. */
  9487. dispose(): void;
  9488. /**
  9489. * Gets the current object class name.
  9490. * @return the class name
  9491. */
  9492. getClassName(): string;
  9493. }
  9494. }
  9495. declare module BABYLON {
  9496. /**
  9497. * Default Inputs manager for the FreeCamera.
  9498. * It groups all the default supported inputs for ease of use.
  9499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9500. */
  9501. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  9502. /**
  9503. * Instantiates a new FreeCameraInputsManager.
  9504. * @param camera Defines the camera the inputs belong to
  9505. */
  9506. constructor(camera: FreeCamera);
  9507. /**
  9508. * Add keyboard input support to the input manager.
  9509. * @returns the current input manager
  9510. */
  9511. addKeyboard(): FreeCameraInputsManager;
  9512. /**
  9513. * Add mouse input support to the input manager.
  9514. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  9515. * @returns the current input manager
  9516. */
  9517. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  9518. /**
  9519. * Add orientation input support to the input manager.
  9520. * @returns the current input manager
  9521. */
  9522. addDeviceOrientation(): FreeCameraInputsManager;
  9523. /**
  9524. * Add touch input support to the input manager.
  9525. * @returns the current input manager
  9526. */
  9527. addTouch(): FreeCameraInputsManager;
  9528. /**
  9529. * Add virtual joystick input support to the input manager.
  9530. * @returns the current input manager
  9531. */
  9532. addVirtualJoystick(): FreeCameraInputsManager;
  9533. }
  9534. }
  9535. declare module BABYLON {
  9536. /**
  9537. * This represents a FPS type of camera. This is only here for back compat purpose.
  9538. * Please use the UniversalCamera instead as both are identical.
  9539. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9540. */
  9541. class GamepadCamera extends UniversalCamera {
  9542. /**
  9543. * Instantiates a new Gamepad Camera
  9544. * This represents a FPS type of camera. This is only here for back compat purpose.
  9545. * Please use the UniversalCamera instead as both are identical.
  9546. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9547. * @param name Define the name of the camera in the scene
  9548. * @param position Define the start position of the camera in the scene
  9549. * @param scene Define the scene the camera belongs to
  9550. */
  9551. constructor(name: string, position: Vector3, scene: Scene);
  9552. /**
  9553. * Gets the current object class name.
  9554. * @return the class name
  9555. */
  9556. getClassName(): string;
  9557. }
  9558. }
  9559. declare module BABYLON {
  9560. /**
  9561. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9562. * This is the base of the follow, arc rotate cameras and Free camera
  9563. * @see http://doc.babylonjs.com/features/cameras
  9564. */
  9565. class TargetCamera extends Camera {
  9566. private static _RigCamTransformMatrix;
  9567. private static _TargetTransformMatrix;
  9568. private static _TargetFocalPoint;
  9569. /**
  9570. * Define the current direction the camera is moving to
  9571. */
  9572. cameraDirection: Vector3;
  9573. /**
  9574. * Define the current rotation the camera is rotating to
  9575. */
  9576. cameraRotation: Vector2;
  9577. /**
  9578. * When set, the up vector of the camera will be updated by the rotation of the camera
  9579. */
  9580. updateUpVectorFromRotation: boolean;
  9581. private _tmpQuaternion;
  9582. /**
  9583. * Define the current rotation of the camera
  9584. */
  9585. rotation: Vector3;
  9586. /**
  9587. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9588. */
  9589. rotationQuaternion: Quaternion;
  9590. /**
  9591. * Define the current speed of the camera
  9592. */
  9593. speed: number;
  9594. /**
  9595. * Add cconstraint to the camera to prevent it to move freely in all directions and
  9596. * around all axis.
  9597. */
  9598. noRotationConstraint: boolean;
  9599. /**
  9600. * Define the current target of the camera as an object or a position.
  9601. */
  9602. lockedTarget: any;
  9603. /** @hidden */
  9604. _currentTarget: Vector3;
  9605. /** @hidden */
  9606. _initialFocalDistance: number;
  9607. /** @hidden */
  9608. _viewMatrix: Matrix;
  9609. /** @hidden */
  9610. _camMatrix: Matrix;
  9611. /** @hidden */
  9612. _cameraTransformMatrix: Matrix;
  9613. /** @hidden */
  9614. _cameraRotationMatrix: Matrix;
  9615. /** @hidden */
  9616. _referencePoint: Vector3;
  9617. /** @hidden */
  9618. _transformedReferencePoint: Vector3;
  9619. protected _globalCurrentTarget: Vector3;
  9620. protected _globalCurrentUpVector: Vector3;
  9621. /** @hidden */
  9622. _reset: () => void;
  9623. private _defaultUp;
  9624. /**
  9625. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  9626. * This is the base of the follow, arc rotate cameras and Free camera
  9627. * @see http://doc.babylonjs.com/features/cameras
  9628. * @param name Defines the name of the camera in the scene
  9629. * @param position Defines the start position of the camera in the scene
  9630. * @param scene Defines the scene the camera belongs to
  9631. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9632. */
  9633. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9634. /**
  9635. * Gets the position in front of the camera at a given distance.
  9636. * @param distance The distance from the camera we want the position to be
  9637. * @returns the position
  9638. */
  9639. getFrontPosition(distance: number): Vector3;
  9640. /** @hidden */
  9641. _getLockedTargetPosition(): Nullable<Vector3>;
  9642. private _storedPosition;
  9643. private _storedRotation;
  9644. private _storedRotationQuaternion;
  9645. /**
  9646. * Store current camera state of the camera (fov, position, rotation, etc..)
  9647. * @returns the camera
  9648. */
  9649. storeState(): Camera;
  9650. /**
  9651. * Restored camera state. You must call storeState() first
  9652. * @returns whether it was successful or not
  9653. * @hidden
  9654. */
  9655. _restoreStateValues(): boolean;
  9656. /** @hidden */
  9657. _initCache(): void;
  9658. /** @hidden */
  9659. _updateCache(ignoreParentClass?: boolean): void;
  9660. /** @hidden */
  9661. _isSynchronizedViewMatrix(): boolean;
  9662. /** @hidden */
  9663. _computeLocalCameraSpeed(): number;
  9664. /** @hidden */
  9665. setTarget(target: Vector3): void;
  9666. /**
  9667. * Return the current target position of the camera. This value is expressed in local space.
  9668. * @returns the target position
  9669. */
  9670. getTarget(): Vector3;
  9671. /** @hidden */
  9672. _decideIfNeedsToMove(): boolean;
  9673. /** @hidden */
  9674. _updatePosition(): void;
  9675. /** @hidden */
  9676. _checkInputs(): void;
  9677. protected _updateCameraRotationMatrix(): void;
  9678. /**
  9679. * 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)
  9680. * @returns the current camera
  9681. */
  9682. private _rotateUpVectorWithCameraRotationMatrix;
  9683. private _cachedRotationZ;
  9684. private _cachedQuaternionRotationZ;
  9685. /** @hidden */
  9686. _getViewMatrix(): Matrix;
  9687. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9688. /**
  9689. * @hidden
  9690. */
  9691. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9692. /**
  9693. * @hidden
  9694. */
  9695. _updateRigCameras(): void;
  9696. private _getRigCamPositionAndTarget;
  9697. /**
  9698. * Gets the current object class name.
  9699. * @return the class name
  9700. */
  9701. getClassName(): string;
  9702. }
  9703. }
  9704. declare module BABYLON {
  9705. /**
  9706. * This represents a FPS type of camera controlled by touch.
  9707. * This is like a universal camera minus the Gamepad controls.
  9708. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9709. */
  9710. class TouchCamera extends FreeCamera {
  9711. /**
  9712. * Defines the touch sensibility for rotation.
  9713. * The higher the faster.
  9714. */
  9715. touchAngularSensibility: number;
  9716. /**
  9717. * Defines the touch sensibility for move.
  9718. * The higher the faster.
  9719. */
  9720. touchMoveSensibility: number;
  9721. /**
  9722. * Instantiates a new touch camera.
  9723. * This represents a FPS type of camera controlled by touch.
  9724. * This is like a universal camera minus the Gamepad controls.
  9725. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9726. * @param name Define the name of the camera in the scene
  9727. * @param position Define the start position of the camera in the scene
  9728. * @param scene Define the scene the camera belongs to
  9729. */
  9730. constructor(name: string, position: Vector3, scene: Scene);
  9731. /**
  9732. * Gets the current object class name.
  9733. * @return the class name
  9734. */
  9735. getClassName(): string;
  9736. /** @hidden */
  9737. _setupInputs(): void;
  9738. }
  9739. }
  9740. declare module BABYLON {
  9741. /**
  9742. * 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,
  9743. * which still works and will still be found in many Playgrounds.
  9744. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9745. */
  9746. class UniversalCamera extends TouchCamera {
  9747. /**
  9748. * Defines the gamepad rotation sensiblity.
  9749. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  9750. */
  9751. gamepadAngularSensibility: number;
  9752. /**
  9753. * Defines the gamepad move sensiblity.
  9754. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  9755. */
  9756. gamepadMoveSensibility: number;
  9757. /**
  9758. * 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,
  9759. * which still works and will still be found in many Playgrounds.
  9760. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9761. * @param name Define the name of the camera in the scene
  9762. * @param position Define the start position of the camera in the scene
  9763. * @param scene Define the scene the camera belongs to
  9764. */
  9765. constructor(name: string, position: Vector3, scene: Scene);
  9766. /**
  9767. * Gets the current object class name.
  9768. * @return the class name
  9769. */
  9770. getClassName(): string;
  9771. }
  9772. }
  9773. declare module BABYLON {
  9774. /**
  9775. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  9776. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9777. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9778. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9779. */
  9780. class VirtualJoysticksCamera extends FreeCamera {
  9781. /**
  9782. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  9783. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9784. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9785. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9786. * @param name Define the name of the camera in the scene
  9787. * @param position Define the start position of the camera in the scene
  9788. * @param scene Define the scene the camera belongs to
  9789. */
  9790. constructor(name: string, position: Vector3, scene: Scene);
  9791. /**
  9792. * Gets the current object class name.
  9793. * @return the class name
  9794. */
  9795. getClassName(): string;
  9796. }
  9797. }
  9798. interface VRDisplay extends EventTarget {
  9799. /**
  9800. * Dictionary of capabilities describing the VRDisplay.
  9801. */
  9802. readonly capabilities: VRDisplayCapabilities;
  9803. /**
  9804. * z-depth defining the far plane of the eye view frustum
  9805. * enables mapping of values in the render target depth
  9806. * attachment to scene coordinates. Initially set to 10000.0.
  9807. */
  9808. depthFar: number;
  9809. /**
  9810. * z-depth defining the near plane of the eye view frustum
  9811. * enables mapping of values in the render target depth
  9812. * attachment to scene coordinates. Initially set to 0.01.
  9813. */
  9814. depthNear: number;
  9815. /**
  9816. * An identifier for this distinct VRDisplay. Used as an
  9817. * association point in the Gamepad API.
  9818. */
  9819. readonly displayId: number;
  9820. /**
  9821. * A display name, a user-readable name identifying it.
  9822. */
  9823. readonly displayName: string;
  9824. readonly isConnected: boolean;
  9825. readonly isPresenting: boolean;
  9826. /**
  9827. * If this VRDisplay supports room-scale experiences, the optional
  9828. * stage attribute contains details on the room-scale parameters.
  9829. */
  9830. readonly stageParameters: VRStageParameters | null;
  9831. /**
  9832. * Passing the value returned by `requestAnimationFrame` to
  9833. * `cancelAnimationFrame` will unregister the callback.
  9834. * @param handle Define the hanle of the request to cancel
  9835. */
  9836. cancelAnimationFrame(handle: number): void;
  9837. /**
  9838. * Stops presenting to the VRDisplay.
  9839. * @returns a promise to know when it stopped
  9840. */
  9841. exitPresent(): Promise<void>;
  9842. /**
  9843. * Return the current VREyeParameters for the given eye.
  9844. * @param whichEye Define the eye we want the parameter for
  9845. * @returns the eye parameters
  9846. */
  9847. getEyeParameters(whichEye: string): VREyeParameters;
  9848. /**
  9849. * Populates the passed VRFrameData with the information required to render
  9850. * the current frame.
  9851. * @param frameData Define the data structure to populate
  9852. * @returns true if ok otherwise false
  9853. */
  9854. getFrameData(frameData: VRFrameData): boolean;
  9855. /**
  9856. * Get the layers currently being presented.
  9857. * @returns the list of VR layers
  9858. */
  9859. getLayers(): VRLayer[];
  9860. /**
  9861. * Return a VRPose containing the future predicted pose of the VRDisplay
  9862. * when the current frame will be presented. The value returned will not
  9863. * change until JavaScript has returned control to the browser.
  9864. *
  9865. * The VRPose will contain the position, orientation, velocity,
  9866. * and acceleration of each of these properties.
  9867. * @returns the pose object
  9868. */
  9869. getPose(): VRPose;
  9870. /**
  9871. * Return the current instantaneous pose of the VRDisplay, with no
  9872. * prediction applied.
  9873. * @returns the current instantaneous pose
  9874. */
  9875. getImmediatePose(): VRPose;
  9876. /**
  9877. * The callback passed to `requestAnimationFrame` will be called
  9878. * any time a new frame should be rendered. When the VRDisplay is
  9879. * presenting the callback will be called at the native refresh
  9880. * rate of the HMD. When not presenting this function acts
  9881. * identically to how window.requestAnimationFrame acts. Content should
  9882. * make no assumptions of frame rate or vsync behavior as the HMD runs
  9883. * asynchronously from other displays and at differing refresh rates.
  9884. * @param callback Define the eaction to run next frame
  9885. * @returns the request handle it
  9886. */
  9887. requestAnimationFrame(callback: FrameRequestCallback): number;
  9888. /**
  9889. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  9890. * Repeat calls while already presenting will update the VRLayers being displayed.
  9891. * @param layers Define the list of layer to present
  9892. * @returns a promise to know when the request has been fulfilled
  9893. */
  9894. requestPresent(layers: VRLayer[]): Promise<void>;
  9895. /**
  9896. * Reset the pose for this display, treating its current position and
  9897. * orientation as the "origin/zero" values. VRPose.position,
  9898. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9899. * updated when calling resetPose(). This should be called in only
  9900. * sitting-space experiences.
  9901. */
  9902. resetPose(): void;
  9903. /**
  9904. * The VRLayer provided to the VRDisplay will be captured and presented
  9905. * in the HMD. Calling this function has the same effect on the source
  9906. * canvas as any other operation that uses its source image, and canvases
  9907. * created without preserveDrawingBuffer set to true will be cleared.
  9908. * @param pose Define the pose to submit
  9909. */
  9910. submitFrame(pose?: VRPose): void;
  9911. }
  9912. declare var VRDisplay: {
  9913. prototype: VRDisplay;
  9914. new (): VRDisplay;
  9915. };
  9916. interface VRLayer {
  9917. leftBounds?: number[] | Float32Array | null;
  9918. rightBounds?: number[] | Float32Array | null;
  9919. source?: HTMLCanvasElement | null;
  9920. }
  9921. interface VRDisplayCapabilities {
  9922. readonly canPresent: boolean;
  9923. readonly hasExternalDisplay: boolean;
  9924. readonly hasOrientation: boolean;
  9925. readonly hasPosition: boolean;
  9926. readonly maxLayers: number;
  9927. }
  9928. interface VREyeParameters {
  9929. /** @deprecated */
  9930. readonly fieldOfView: VRFieldOfView;
  9931. readonly offset: Float32Array;
  9932. readonly renderHeight: number;
  9933. readonly renderWidth: number;
  9934. }
  9935. interface VRFieldOfView {
  9936. readonly downDegrees: number;
  9937. readonly leftDegrees: number;
  9938. readonly rightDegrees: number;
  9939. readonly upDegrees: number;
  9940. }
  9941. interface VRFrameData {
  9942. readonly leftProjectionMatrix: Float32Array;
  9943. readonly leftViewMatrix: Float32Array;
  9944. readonly pose: VRPose;
  9945. readonly rightProjectionMatrix: Float32Array;
  9946. readonly rightViewMatrix: Float32Array;
  9947. readonly timestamp: number;
  9948. }
  9949. interface VRPose {
  9950. readonly angularAcceleration: Float32Array | null;
  9951. readonly angularVelocity: Float32Array | null;
  9952. readonly linearAcceleration: Float32Array | null;
  9953. readonly linearVelocity: Float32Array | null;
  9954. readonly orientation: Float32Array | null;
  9955. readonly position: Float32Array | null;
  9956. readonly timestamp: number;
  9957. }
  9958. interface VRStageParameters {
  9959. sittingToStandingTransform?: Float32Array;
  9960. sizeX?: number;
  9961. sizeY?: number;
  9962. }
  9963. interface Navigator {
  9964. getVRDisplays(): Promise<VRDisplay[]>;
  9965. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9966. }
  9967. interface Window {
  9968. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9969. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9970. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9971. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9972. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9973. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9974. }
  9975. interface Gamepad {
  9976. readonly displayId: number;
  9977. }
  9978. declare module BABYLON {
  9979. /**
  9980. * Interface for attribute information associated with buffer instanciation
  9981. */
  9982. class InstancingAttributeInfo {
  9983. /**
  9984. * Index/offset of the attribute in the vertex shader
  9985. */
  9986. index: number;
  9987. /**
  9988. * size of the attribute, 1, 2, 3 or 4
  9989. */
  9990. attributeSize: number;
  9991. /**
  9992. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9993. * default is FLOAT
  9994. */
  9995. attribyteType: number;
  9996. /**
  9997. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9998. */
  9999. normalized: boolean;
  10000. /**
  10001. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  10002. */
  10003. offset: number;
  10004. /**
  10005. * Name of the GLSL attribute, for debugging purpose only
  10006. */
  10007. attributeName: string;
  10008. }
  10009. /**
  10010. * Define options used to create a render target texture
  10011. */
  10012. class RenderTargetCreationOptions {
  10013. /**
  10014. * Specifies is mipmaps must be generated
  10015. */
  10016. generateMipMaps?: boolean;
  10017. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  10018. generateDepthBuffer?: boolean;
  10019. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  10020. generateStencilBuffer?: boolean;
  10021. /** Defines texture type (int by default) */
  10022. type?: number;
  10023. /** Defines sampling mode (trilinear by default) */
  10024. samplingMode?: number;
  10025. /** Defines format (RGBA by default) */
  10026. format?: number;
  10027. }
  10028. /**
  10029. * Define options used to create a depth texture
  10030. */
  10031. class DepthTextureCreationOptions {
  10032. /** Specifies whether or not a stencil should be allocated in the texture */
  10033. generateStencil?: boolean;
  10034. /** Specifies whether or not bilinear filtering is enable on the texture */
  10035. bilinearFiltering?: boolean;
  10036. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10037. comparisonFunction?: number;
  10038. /** Specifies if the created texture is a cube texture */
  10039. isCube?: boolean;
  10040. }
  10041. /**
  10042. * Class used to describe the capabilities of the engine relatively to the current browser
  10043. */
  10044. class EngineCapabilities {
  10045. /** Maximum textures units per fragment shader */
  10046. maxTexturesImageUnits: number;
  10047. /** Maximum texture units per vertex shader */
  10048. maxVertexTextureImageUnits: number;
  10049. /** Maximum textures units in the entire pipeline */
  10050. maxCombinedTexturesImageUnits: number;
  10051. /** Maximum texture size */
  10052. maxTextureSize: number;
  10053. /** Maximum cube texture size */
  10054. maxCubemapTextureSize: number;
  10055. /** Maximum render texture size */
  10056. maxRenderTextureSize: number;
  10057. /** Maximum number of vertex attributes */
  10058. maxVertexAttribs: number;
  10059. /** Maximum number of varyings */
  10060. maxVaryingVectors: number;
  10061. /** Maximum number of uniforms per vertex shader */
  10062. maxVertexUniformVectors: number;
  10063. /** Maximum number of uniforms per fragment shader */
  10064. maxFragmentUniformVectors: number;
  10065. /** Defines if standard derivates (dx/dy) are supported */
  10066. standardDerivatives: boolean;
  10067. /** Defines if s3tc texture compression is supported */
  10068. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  10069. /** Defines if pvrtc texture compression is supported */
  10070. pvrtc: any;
  10071. /** Defines if etc1 texture compression is supported */
  10072. etc1: any;
  10073. /** Defines if etc2 texture compression is supported */
  10074. etc2: any;
  10075. /** Defines if astc texture compression is supported */
  10076. astc: any;
  10077. /** Defines if float textures are supported */
  10078. textureFloat: boolean;
  10079. /** Defines if vertex array objects are supported */
  10080. vertexArrayObject: boolean;
  10081. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  10082. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  10083. /** Gets the maximum level of anisotropy supported */
  10084. maxAnisotropy: number;
  10085. /** Defines if instancing is supported */
  10086. instancedArrays: boolean;
  10087. /** Defines if 32 bits indices are supported */
  10088. uintIndices: boolean;
  10089. /** Defines if high precision shaders are supported */
  10090. highPrecisionShaderSupported: boolean;
  10091. /** Defines if depth reading in the fragment shader is supported */
  10092. fragmentDepthSupported: boolean;
  10093. /** Defines if float texture linear filtering is supported*/
  10094. textureFloatLinearFiltering: boolean;
  10095. /** Defines if rendering to float textures is supported */
  10096. textureFloatRender: boolean;
  10097. /** Defines if half float textures are supported*/
  10098. textureHalfFloat: boolean;
  10099. /** Defines if half float texture linear filtering is supported*/
  10100. textureHalfFloatLinearFiltering: boolean;
  10101. /** Defines if rendering to half float textures is supported */
  10102. textureHalfFloatRender: boolean;
  10103. /** Defines if textureLOD shader command is supported */
  10104. textureLOD: boolean;
  10105. /** Defines if draw buffers extension is supported */
  10106. drawBuffersExtension: boolean;
  10107. /** Defines if depth textures are supported */
  10108. depthTextureExtension: boolean;
  10109. /** Defines if float color buffer are supported */
  10110. colorBufferFloat: boolean;
  10111. /** Gets disjoint timer query extension (null if not supported) */
  10112. timerQuery: EXT_disjoint_timer_query;
  10113. /** Defines if timestamp can be used with timer query */
  10114. canUseTimestampForTimerQuery: boolean;
  10115. /** Function used to let the system compiles shaders in background */
  10116. parallelShaderCompile: {
  10117. MAX_SHADER_COMPILER_THREADS_KHR: number;
  10118. maxShaderCompilerThreadsKHR: (thread: number) => void;
  10119. COMPLETION_STATUS_KHR: number;
  10120. };
  10121. }
  10122. /** Interface defining initialization parameters for Engine class */
  10123. interface EngineOptions extends WebGLContextAttributes {
  10124. /**
  10125. * Defines if the engine should no exceed a specified device ratio
  10126. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  10127. */
  10128. limitDeviceRatio?: number;
  10129. /**
  10130. * Defines if webvr should be enabled automatically
  10131. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10132. */
  10133. autoEnableWebVR?: boolean;
  10134. /**
  10135. * Defines if webgl2 should be turned off even if supported
  10136. * @see http://doc.babylonjs.com/features/webgl2
  10137. */
  10138. disableWebGL2Support?: boolean;
  10139. /**
  10140. * Defines if webaudio should be initialized as well
  10141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10142. */
  10143. audioEngine?: boolean;
  10144. /**
  10145. * Defines if animations should run using a deterministic lock step
  10146. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10147. */
  10148. deterministicLockstep?: boolean;
  10149. /** Defines the maximum steps to use with deterministic lock step mode */
  10150. lockstepMaxSteps?: number;
  10151. /**
  10152. * Defines that engine should ignore context lost events
  10153. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  10154. */
  10155. doNotHandleContextLost?: boolean;
  10156. /**
  10157. * Defines that engine should ignore modifying touch action attribute and style
  10158. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  10159. */
  10160. doNotHandleTouchAction?: boolean;
  10161. }
  10162. /**
  10163. * Defines the interface used by display changed events
  10164. */
  10165. interface IDisplayChangedEventArgs {
  10166. /** Gets the vrDisplay object (if any) */
  10167. vrDisplay: Nullable<any>;
  10168. /** Gets a boolean indicating if webVR is supported */
  10169. vrSupported: boolean;
  10170. }
  10171. /**
  10172. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  10173. */
  10174. class Engine {
  10175. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  10176. static ExceptionList: ({
  10177. key: string;
  10178. capture: string;
  10179. captureConstraint: number;
  10180. targets: string[];
  10181. } | {
  10182. key: string;
  10183. capture: null;
  10184. captureConstraint: null;
  10185. targets: string[];
  10186. })[];
  10187. /** Gets the list of created engines */
  10188. static Instances: Engine[];
  10189. /**
  10190. * Gets the latest created engine
  10191. */
  10192. static readonly LastCreatedEngine: Nullable<Engine>;
  10193. /**
  10194. * Gets the latest created scene
  10195. */
  10196. static readonly LastCreatedScene: Nullable<Scene>;
  10197. /**
  10198. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10199. * @param flag defines which part of the materials must be marked as dirty
  10200. * @param predicate defines a predicate used to filter which materials should be affected
  10201. */
  10202. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10203. /**
  10204. * Hidden
  10205. */
  10206. static _TextureLoaders: IInternalTextureLoader[];
  10207. /** Defines that alpha blending is disabled */
  10208. static readonly ALPHA_DISABLE: number;
  10209. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10210. static readonly ALPHA_ADD: number;
  10211. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10212. static readonly ALPHA_COMBINE: number;
  10213. /** Defines that alpha blending to DEST - SRC * DEST */
  10214. static readonly ALPHA_SUBTRACT: number;
  10215. /** Defines that alpha blending to SRC * DEST */
  10216. static readonly ALPHA_MULTIPLY: number;
  10217. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10218. static readonly ALPHA_MAXIMIZED: number;
  10219. /** Defines that alpha blending to SRC + DEST */
  10220. static readonly ALPHA_ONEONE: number;
  10221. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10222. static readonly ALPHA_PREMULTIPLIED: number;
  10223. /**
  10224. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10225. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10226. */
  10227. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10228. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10229. static readonly ALPHA_INTERPOLATE: number;
  10230. /**
  10231. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10232. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10233. */
  10234. static readonly ALPHA_SCREENMODE: number;
  10235. /** Defines that the ressource is not delayed*/
  10236. static readonly DELAYLOADSTATE_NONE: number;
  10237. /** Defines that the ressource was successfully delay loaded */
  10238. static readonly DELAYLOADSTATE_LOADED: number;
  10239. /** Defines that the ressource is currently delay loading */
  10240. static readonly DELAYLOADSTATE_LOADING: number;
  10241. /** Defines that the ressource is delayed and has not started loading */
  10242. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10243. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10244. static readonly NEVER: number;
  10245. /** 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 */
  10246. static readonly ALWAYS: number;
  10247. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10248. static readonly LESS: number;
  10249. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10250. static readonly EQUAL: number;
  10251. /** 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 */
  10252. static readonly LEQUAL: number;
  10253. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10254. static readonly GREATER: number;
  10255. /** 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 */
  10256. static readonly GEQUAL: number;
  10257. /** 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 */
  10258. static readonly NOTEQUAL: number;
  10259. /** Passed to stencilOperation to specify that stencil value must be kept */
  10260. static readonly KEEP: number;
  10261. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10262. static readonly REPLACE: number;
  10263. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10264. static readonly INCR: number;
  10265. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10266. static readonly DECR: number;
  10267. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10268. static readonly INVERT: number;
  10269. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10270. static readonly INCR_WRAP: number;
  10271. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10272. static readonly DECR_WRAP: number;
  10273. /** Texture is not repeating outside of 0..1 UVs */
  10274. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10275. /** Texture is repeating outside of 0..1 UVs */
  10276. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10277. /** Texture is repeating and mirrored */
  10278. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10279. /** ALPHA */
  10280. static readonly TEXTUREFORMAT_ALPHA: number;
  10281. /** LUMINANCE */
  10282. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10283. /** LUMINANCE_ALPHA */
  10284. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10285. /** RGB */
  10286. static readonly TEXTUREFORMAT_RGB: number;
  10287. /** RGBA */
  10288. static readonly TEXTUREFORMAT_RGBA: number;
  10289. /** RED */
  10290. static readonly TEXTUREFORMAT_RED: number;
  10291. /** RED (2nd reference) */
  10292. static readonly TEXTUREFORMAT_R: number;
  10293. /** RG */
  10294. static readonly TEXTUREFORMAT_RG: number;
  10295. /** RED_INTEGER */
  10296. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10297. /** RED_INTEGER (2nd reference) */
  10298. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10299. /** RG_INTEGER */
  10300. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10301. /** RGB_INTEGER */
  10302. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10303. /** RGBA_INTEGER */
  10304. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10305. /** UNSIGNED_BYTE */
  10306. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10307. /** UNSIGNED_BYTE (2nd reference) */
  10308. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10309. /** FLOAT */
  10310. static readonly TEXTURETYPE_FLOAT: number;
  10311. /** HALF_FLOAT */
  10312. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10313. /** BYTE */
  10314. static readonly TEXTURETYPE_BYTE: number;
  10315. /** SHORT */
  10316. static readonly TEXTURETYPE_SHORT: number;
  10317. /** UNSIGNED_SHORT */
  10318. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10319. /** INT */
  10320. static readonly TEXTURETYPE_INT: number;
  10321. /** UNSIGNED_INT */
  10322. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10323. /** UNSIGNED_SHORT_4_4_4_4 */
  10324. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10325. /** UNSIGNED_SHORT_5_5_5_1 */
  10326. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10327. /** UNSIGNED_SHORT_5_6_5 */
  10328. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10329. /** UNSIGNED_INT_2_10_10_10_REV */
  10330. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10331. /** UNSIGNED_INT_24_8 */
  10332. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10333. /** UNSIGNED_INT_10F_11F_11F_REV */
  10334. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10335. /** UNSIGNED_INT_5_9_9_9_REV */
  10336. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10337. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10338. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10339. /** nearest is mag = nearest and min = nearest and mip = linear */
  10340. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10341. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10342. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10343. /** Trilinear is mag = linear and min = linear and mip = linear */
  10344. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10345. /** nearest is mag = nearest and min = nearest and mip = linear */
  10346. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10347. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10348. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10349. /** Trilinear is mag = linear and min = linear and mip = linear */
  10350. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10351. /** mag = nearest and min = nearest and mip = nearest */
  10352. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10353. /** mag = nearest and min = linear and mip = nearest */
  10354. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10355. /** mag = nearest and min = linear and mip = linear */
  10356. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10357. /** mag = nearest and min = linear and mip = none */
  10358. static readonly TEXTURE_NEAREST_LINEAR: number;
  10359. /** mag = nearest and min = nearest and mip = none */
  10360. static readonly TEXTURE_NEAREST_NEAREST: number;
  10361. /** mag = linear and min = nearest and mip = nearest */
  10362. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10363. /** mag = linear and min = nearest and mip = linear */
  10364. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10365. /** mag = linear and min = linear and mip = none */
  10366. static readonly TEXTURE_LINEAR_LINEAR: number;
  10367. /** mag = linear and min = nearest and mip = none */
  10368. static readonly TEXTURE_LINEAR_NEAREST: number;
  10369. /** Explicit coordinates mode */
  10370. static readonly TEXTURE_EXPLICIT_MODE: number;
  10371. /** Spherical coordinates mode */
  10372. static readonly TEXTURE_SPHERICAL_MODE: number;
  10373. /** Planar coordinates mode */
  10374. static readonly TEXTURE_PLANAR_MODE: number;
  10375. /** Cubic coordinates mode */
  10376. static readonly TEXTURE_CUBIC_MODE: number;
  10377. /** Projection coordinates mode */
  10378. static readonly TEXTURE_PROJECTION_MODE: number;
  10379. /** Skybox coordinates mode */
  10380. static readonly TEXTURE_SKYBOX_MODE: number;
  10381. /** Inverse Cubic coordinates mode */
  10382. static readonly TEXTURE_INVCUBIC_MODE: number;
  10383. /** Equirectangular coordinates mode */
  10384. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10385. /** Equirectangular Fixed coordinates mode */
  10386. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10387. /** Equirectangular Fixed Mirrored coordinates mode */
  10388. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10389. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10390. static readonly SCALEMODE_FLOOR: number;
  10391. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10392. static readonly SCALEMODE_NEAREST: number;
  10393. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10394. static readonly SCALEMODE_CEILING: number;
  10395. /**
  10396. * Returns the current version of the framework
  10397. */
  10398. static readonly Version: string;
  10399. /**
  10400. * Returns a string describing the current engine
  10401. */
  10402. readonly description: string;
  10403. /**
  10404. * Gets or sets the epsilon value used by collision engine
  10405. */
  10406. static CollisionsEpsilon: number;
  10407. /**
  10408. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10409. */
  10410. static CodeRepository: string;
  10411. /**
  10412. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10413. */
  10414. static ShadersRepository: string;
  10415. /**
  10416. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10417. */
  10418. forcePOTTextures: boolean;
  10419. /**
  10420. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10421. */
  10422. isFullscreen: boolean;
  10423. /**
  10424. * Gets a boolean indicating if the pointer is currently locked
  10425. */
  10426. isPointerLock: boolean;
  10427. /**
  10428. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10429. */
  10430. cullBackFaces: boolean;
  10431. /**
  10432. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10433. */
  10434. renderEvenInBackground: boolean;
  10435. /**
  10436. * Gets or sets a boolean indicating that cache can be kept between frames
  10437. */
  10438. preventCacheWipeBetweenFrames: boolean;
  10439. /**
  10440. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10441. **/
  10442. enableOfflineSupport: boolean;
  10443. /**
  10444. * 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)
  10445. **/
  10446. disableManifestCheck: boolean;
  10447. /**
  10448. * Gets the list of created scenes
  10449. */
  10450. scenes: Scene[];
  10451. /**
  10452. * Event raised when a new scene is created
  10453. */
  10454. onNewSceneAddedObservable: Observable<Scene>;
  10455. /**
  10456. * Gets the list of created postprocesses
  10457. */
  10458. postProcesses: PostProcess[];
  10459. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10460. validateShaderPrograms: boolean;
  10461. /**
  10462. * Observable event triggered each time the rendering canvas is resized
  10463. */
  10464. onResizeObservable: Observable<Engine>;
  10465. /**
  10466. * Observable event triggered each time the canvas loses focus
  10467. */
  10468. onCanvasBlurObservable: Observable<Engine>;
  10469. /**
  10470. * Observable event triggered each time the canvas gains focus
  10471. */
  10472. onCanvasFocusObservable: Observable<Engine>;
  10473. /**
  10474. * Observable event triggered each time the canvas receives pointerout event
  10475. */
  10476. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10477. /**
  10478. * Observable event triggered before each texture is initialized
  10479. */
  10480. onBeforeTextureInitObservable: Observable<Texture>;
  10481. private _vrDisplay;
  10482. private _vrSupported;
  10483. private _oldSize;
  10484. private _oldHardwareScaleFactor;
  10485. private _vrExclusivePointerMode;
  10486. private _webVRInitPromise;
  10487. /**
  10488. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10489. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10490. */
  10491. readonly isInVRExclusivePointerMode: boolean;
  10492. /**
  10493. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10494. */
  10495. disableUniformBuffers: boolean;
  10496. /** @hidden */
  10497. _uniformBuffers: UniformBuffer[];
  10498. /**
  10499. * Gets a boolean indicating that the engine supports uniform buffers
  10500. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10501. */
  10502. readonly supportsUniformBuffers: boolean;
  10503. /**
  10504. * Observable raised when the engine begins a new frame
  10505. */
  10506. onBeginFrameObservable: Observable<Engine>;
  10507. /**
  10508. * If set, will be used to request the next animation frame for the render loop
  10509. */
  10510. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10511. /**
  10512. * Observable raised when the engine ends the current frame
  10513. */
  10514. onEndFrameObservable: Observable<Engine>;
  10515. /**
  10516. * Observable raised when the engine is about to compile a shader
  10517. */
  10518. onBeforeShaderCompilationObservable: Observable<Engine>;
  10519. /**
  10520. * Observable raised when the engine has jsut compiled a shader
  10521. */
  10522. onAfterShaderCompilationObservable: Observable<Engine>;
  10523. /** @hidden */
  10524. _gl: WebGLRenderingContext;
  10525. private _renderingCanvas;
  10526. private _windowIsBackground;
  10527. private _webGLVersion;
  10528. /**
  10529. * Gets a boolean indicating that only power of 2 textures are supported
  10530. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10531. */
  10532. readonly needPOTTextures: boolean;
  10533. /** @hidden */
  10534. _badOS: boolean;
  10535. /** @hidden */
  10536. _badDesktopOS: boolean;
  10537. /**
  10538. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10539. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10540. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10541. */
  10542. disableTextureBindingOptimization: boolean;
  10543. /**
  10544. * Gets the audio engine
  10545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10546. * @ignorenaming
  10547. */
  10548. static audioEngine: IAudioEngine;
  10549. /**
  10550. * Default AudioEngine factory responsible of creating the Audio Engine.
  10551. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10552. */
  10553. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10554. /**
  10555. * Default offline support factory responsible of creating a tool used to store data locally.
  10556. * By default, this will create a Database object if the workload has been embedded.
  10557. */
  10558. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10559. private _onFocus;
  10560. private _onBlur;
  10561. private _onCanvasPointerOut;
  10562. private _onCanvasBlur;
  10563. private _onCanvasFocus;
  10564. private _onFullscreenChange;
  10565. private _onPointerLockChange;
  10566. private _onVRDisplayPointerRestricted;
  10567. private _onVRDisplayPointerUnrestricted;
  10568. private _onVrDisplayConnect;
  10569. private _onVrDisplayDisconnect;
  10570. private _onVrDisplayPresentChange;
  10571. /**
  10572. * Observable signaled when VR display mode changes
  10573. */
  10574. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10575. /**
  10576. * Observable signaled when VR request present is complete
  10577. */
  10578. onVRRequestPresentComplete: Observable<boolean>;
  10579. /**
  10580. * Observable signaled when VR request present starts
  10581. */
  10582. onVRRequestPresentStart: Observable<Engine>;
  10583. private _hardwareScalingLevel;
  10584. /** @hidden */
  10585. protected _caps: EngineCapabilities;
  10586. private _pointerLockRequested;
  10587. private _isStencilEnable;
  10588. private _colorWrite;
  10589. private _loadingScreen;
  10590. /** @hidden */
  10591. _drawCalls: PerfCounter;
  10592. /** @hidden */
  10593. _textureCollisions: PerfCounter;
  10594. private _glVersion;
  10595. private _glRenderer;
  10596. private _glVendor;
  10597. private _videoTextureSupported;
  10598. private _renderingQueueLaunched;
  10599. private _activeRenderLoops;
  10600. private _deterministicLockstep;
  10601. private _lockstepMaxSteps;
  10602. /**
  10603. * Observable signaled when a context lost event is raised
  10604. */
  10605. onContextLostObservable: Observable<Engine>;
  10606. /**
  10607. * Observable signaled when a context restored event is raised
  10608. */
  10609. onContextRestoredObservable: Observable<Engine>;
  10610. private _onContextLost;
  10611. private _onContextRestored;
  10612. private _contextWasLost;
  10613. private _doNotHandleContextLost;
  10614. /**
  10615. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10616. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10617. */
  10618. doNotHandleContextLost: boolean;
  10619. private _performanceMonitor;
  10620. private _fps;
  10621. private _deltaTime;
  10622. /**
  10623. * Turn this value on if you want to pause FPS computation when in background
  10624. */
  10625. disablePerformanceMonitorInBackground: boolean;
  10626. /**
  10627. * Gets the performance monitor attached to this engine
  10628. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10629. */
  10630. readonly performanceMonitor: PerformanceMonitor;
  10631. /** @hidden */
  10632. protected _depthCullingState: _DepthCullingState;
  10633. /** @hidden */
  10634. protected _stencilState: _StencilState;
  10635. /** @hidden */
  10636. protected _alphaState: _AlphaState;
  10637. /** @hidden */
  10638. protected _alphaMode: number;
  10639. protected _internalTexturesCache: InternalTexture[];
  10640. /** @hidden */
  10641. protected _activeChannel: number;
  10642. private _currentTextureChannel;
  10643. /** @hidden */
  10644. protected _boundTexturesCache: {
  10645. [key: string]: Nullable<InternalTexture>;
  10646. };
  10647. /** @hidden */
  10648. protected _currentEffect: Nullable<Effect>;
  10649. /** @hidden */
  10650. protected _currentProgram: Nullable<WebGLProgram>;
  10651. private _compiledEffects;
  10652. private _vertexAttribArraysEnabled;
  10653. /** @hidden */
  10654. protected _cachedViewport: Nullable<Viewport>;
  10655. private _cachedVertexArrayObject;
  10656. /** @hidden */
  10657. protected _cachedVertexBuffers: any;
  10658. /** @hidden */
  10659. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10660. /** @hidden */
  10661. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10662. /** @hidden */
  10663. protected _currentRenderTarget: Nullable<InternalTexture>;
  10664. private _uintIndicesCurrentlySet;
  10665. private _currentBoundBuffer;
  10666. /** @hidden */
  10667. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10668. private _currentBufferPointers;
  10669. private _currentInstanceLocations;
  10670. private _currentInstanceBuffers;
  10671. private _textureUnits;
  10672. private _firstBoundInternalTextureTracker;
  10673. private _lastBoundInternalTextureTracker;
  10674. private _workingCanvas;
  10675. private _workingContext;
  10676. private _rescalePostProcess;
  10677. private _dummyFramebuffer;
  10678. private _externalData;
  10679. private _bindedRenderFunction;
  10680. private _vaoRecordInProgress;
  10681. private _mustWipeVertexAttributes;
  10682. private _emptyTexture;
  10683. private _emptyCubeTexture;
  10684. private _emptyTexture3D;
  10685. /** @hidden */
  10686. _frameHandler: number;
  10687. private _nextFreeTextureSlots;
  10688. private _maxSimultaneousTextures;
  10689. private _activeRequests;
  10690. private _texturesSupported;
  10691. private _textureFormatInUse;
  10692. /**
  10693. * Gets the list of texture formats supported
  10694. */
  10695. readonly texturesSupported: Array<string>;
  10696. /**
  10697. * Gets the list of texture formats in use
  10698. */
  10699. readonly textureFormatInUse: Nullable<string>;
  10700. /**
  10701. * Gets the current viewport
  10702. */
  10703. readonly currentViewport: Nullable<Viewport>;
  10704. /**
  10705. * Gets the default empty texture
  10706. */
  10707. readonly emptyTexture: InternalTexture;
  10708. /**
  10709. * Gets the default empty 3D texture
  10710. */
  10711. readonly emptyTexture3D: InternalTexture;
  10712. /**
  10713. * Gets the default empty cube texture
  10714. */
  10715. readonly emptyCubeTexture: InternalTexture;
  10716. /**
  10717. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10718. */
  10719. readonly premultipliedAlpha: boolean;
  10720. /**
  10721. * Creates a new engine
  10722. * @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
  10723. * @param antialias defines enable antialiasing (default: false)
  10724. * @param options defines further options to be sent to the getContext() function
  10725. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10726. */
  10727. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10728. private _disableTouchAction;
  10729. private _rebuildInternalTextures;
  10730. private _rebuildEffects;
  10731. /**
  10732. * Gets a boolean indicating if all created effects are ready
  10733. * @returns true if all effects are ready
  10734. */
  10735. areAllEffectsReady(): boolean;
  10736. private _rebuildBuffers;
  10737. private _initGLContext;
  10738. /**
  10739. * Gets version of the current webGL context
  10740. */
  10741. readonly webGLVersion: number;
  10742. /**
  10743. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10744. */
  10745. readonly isStencilEnable: boolean;
  10746. private _prepareWorkingCanvas;
  10747. /**
  10748. * Reset the texture cache to empty state
  10749. */
  10750. resetTextureCache(): void;
  10751. /**
  10752. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10753. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10754. * @returns true if engine is in deterministic lock step mode
  10755. */
  10756. isDeterministicLockStep(): boolean;
  10757. /**
  10758. * Gets the max steps when engine is running in deterministic lock step
  10759. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10760. * @returns the max steps
  10761. */
  10762. getLockstepMaxSteps(): number;
  10763. /**
  10764. * Gets an object containing information about the current webGL context
  10765. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10766. */
  10767. getGlInfo(): {
  10768. vendor: string;
  10769. renderer: string;
  10770. version: string;
  10771. };
  10772. /**
  10773. * Gets current aspect ratio
  10774. * @param camera defines the camera to use to get the aspect ratio
  10775. * @param useScreen defines if screen size must be used (or the current render target if any)
  10776. * @returns a number defining the aspect ratio
  10777. */
  10778. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10779. /**
  10780. * Gets current screen aspect ratio
  10781. * @returns a number defining the aspect ratio
  10782. */
  10783. getScreenAspectRatio(): number;
  10784. /**
  10785. * Gets the current render width
  10786. * @param useScreen defines if screen size must be used (or the current render target if any)
  10787. * @returns a number defining the current render width
  10788. */
  10789. getRenderWidth(useScreen?: boolean): number;
  10790. /**
  10791. * Gets the current render height
  10792. * @param useScreen defines if screen size must be used (or the current render target if any)
  10793. * @returns a number defining the current render height
  10794. */
  10795. getRenderHeight(useScreen?: boolean): number;
  10796. /**
  10797. * Gets the HTML canvas attached with the current webGL context
  10798. * @returns a HTML canvas
  10799. */
  10800. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10801. /**
  10802. * Gets the client rect of the HTML canvas attached with the current webGL context
  10803. * @returns a client rectanglee
  10804. */
  10805. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10806. /**
  10807. * Defines the hardware scaling level.
  10808. * By default the hardware scaling level is computed from the window device ratio.
  10809. * 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.
  10810. * @param level defines the level to use
  10811. */
  10812. setHardwareScalingLevel(level: number): void;
  10813. /**
  10814. * Gets the current hardware scaling level.
  10815. * By default the hardware scaling level is computed from the window device ratio.
  10816. * 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.
  10817. * @returns a number indicating the current hardware scaling level
  10818. */
  10819. getHardwareScalingLevel(): number;
  10820. /**
  10821. * Gets the list of loaded textures
  10822. * @returns an array containing all loaded textures
  10823. */
  10824. getLoadedTexturesCache(): InternalTexture[];
  10825. /**
  10826. * Gets the object containing all engine capabilities
  10827. * @returns the EngineCapabilities object
  10828. */
  10829. getCaps(): EngineCapabilities;
  10830. /**
  10831. * Gets the current depth function
  10832. * @returns a number defining the depth function
  10833. */
  10834. getDepthFunction(): Nullable<number>;
  10835. /**
  10836. * Sets the current depth function
  10837. * @param depthFunc defines the function to use
  10838. */
  10839. setDepthFunction(depthFunc: number): void;
  10840. /**
  10841. * Sets the current depth function to GREATER
  10842. */
  10843. setDepthFunctionToGreater(): void;
  10844. /**
  10845. * Sets the current depth function to GEQUAL
  10846. */
  10847. setDepthFunctionToGreaterOrEqual(): void;
  10848. /**
  10849. * Sets the current depth function to LESS
  10850. */
  10851. setDepthFunctionToLess(): void;
  10852. /**
  10853. * Sets the current depth function to LEQUAL
  10854. */
  10855. setDepthFunctionToLessOrEqual(): void;
  10856. /**
  10857. * Gets a boolean indicating if stencil buffer is enabled
  10858. * @returns the current stencil buffer state
  10859. */
  10860. getStencilBuffer(): boolean;
  10861. /**
  10862. * Enable or disable the stencil buffer
  10863. * @param enable defines if the stencil buffer must be enabled or disabled
  10864. */
  10865. setStencilBuffer(enable: boolean): void;
  10866. /**
  10867. * Gets the current stencil mask
  10868. * @returns a number defining the new stencil mask to use
  10869. */
  10870. getStencilMask(): number;
  10871. /**
  10872. * Sets the current stencil mask
  10873. * @param mask defines the new stencil mask to use
  10874. */
  10875. setStencilMask(mask: number): void;
  10876. /**
  10877. * Gets the current stencil function
  10878. * @returns a number defining the stencil function to use
  10879. */
  10880. getStencilFunction(): number;
  10881. /**
  10882. * Gets the current stencil reference value
  10883. * @returns a number defining the stencil reference value to use
  10884. */
  10885. getStencilFunctionReference(): number;
  10886. /**
  10887. * Gets the current stencil mask
  10888. * @returns a number defining the stencil mask to use
  10889. */
  10890. getStencilFunctionMask(): number;
  10891. /**
  10892. * Sets the current stencil function
  10893. * @param stencilFunc defines the new stencil function to use
  10894. */
  10895. setStencilFunction(stencilFunc: number): void;
  10896. /**
  10897. * Sets the current stencil reference
  10898. * @param reference defines the new stencil reference to use
  10899. */
  10900. setStencilFunctionReference(reference: number): void;
  10901. /**
  10902. * Sets the current stencil mask
  10903. * @param mask defines the new stencil mask to use
  10904. */
  10905. setStencilFunctionMask(mask: number): void;
  10906. /**
  10907. * Gets the current stencil operation when stencil fails
  10908. * @returns a number defining stencil operation to use when stencil fails
  10909. */
  10910. getStencilOperationFail(): number;
  10911. /**
  10912. * Gets the current stencil operation when depth fails
  10913. * @returns a number defining stencil operation to use when depth fails
  10914. */
  10915. getStencilOperationDepthFail(): number;
  10916. /**
  10917. * Gets the current stencil operation when stencil passes
  10918. * @returns a number defining stencil operation to use when stencil passes
  10919. */
  10920. getStencilOperationPass(): number;
  10921. /**
  10922. * Sets the stencil operation to use when stencil fails
  10923. * @param operation defines the stencil operation to use when stencil fails
  10924. */
  10925. setStencilOperationFail(operation: number): void;
  10926. /**
  10927. * Sets the stencil operation to use when depth fails
  10928. * @param operation defines the stencil operation to use when depth fails
  10929. */
  10930. setStencilOperationDepthFail(operation: number): void;
  10931. /**
  10932. * Sets the stencil operation to use when stencil passes
  10933. * @param operation defines the stencil operation to use when stencil passes
  10934. */
  10935. setStencilOperationPass(operation: number): void;
  10936. /**
  10937. * Sets a boolean indicating if the dithering state is enabled or disabled
  10938. * @param value defines the dithering state
  10939. */
  10940. setDitheringState(value: boolean): void;
  10941. /**
  10942. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10943. * @param value defines the rasterizer state
  10944. */
  10945. setRasterizerState(value: boolean): void;
  10946. /**
  10947. * stop executing a render loop function and remove it from the execution array
  10948. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10949. */
  10950. stopRenderLoop(renderFunction?: () => void): void;
  10951. /** @hidden */
  10952. _renderLoop(): void;
  10953. /**
  10954. * Register and execute a render loop. The engine can have more than one render function
  10955. * @param renderFunction defines the function to continuously execute
  10956. */
  10957. runRenderLoop(renderFunction: () => void): void;
  10958. /**
  10959. * Toggle full screen mode
  10960. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10961. */
  10962. switchFullscreen(requestPointerLock: boolean): void;
  10963. /**
  10964. * Clear the current render buffer or the current render target (if any is set up)
  10965. * @param color defines the color to use
  10966. * @param backBuffer defines if the back buffer must be cleared
  10967. * @param depth defines if the depth buffer must be cleared
  10968. * @param stencil defines if the stencil buffer must be cleared
  10969. */
  10970. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10971. /**
  10972. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10973. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10974. * @param y defines the y-coordinate of the corner of the clear rectangle
  10975. * @param width defines the width of the clear rectangle
  10976. * @param height defines the height of the clear rectangle
  10977. * @param clearColor defines the clear color
  10978. */
  10979. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10980. /**
  10981. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  10982. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10983. * @param y defines the y-coordinate of the corner of the clear rectangle
  10984. * @param width defines the width of the clear rectangle
  10985. * @param height defines the height of the clear rectangle
  10986. */
  10987. enableScissor(x: number, y: number, width: number, height: number): void;
  10988. /**
  10989. * Disable previously set scissor test rectangle
  10990. */
  10991. disableScissor(): void;
  10992. private _viewportCached;
  10993. /** @hidden */
  10994. _viewport(x: number, y: number, width: number, height: number): void;
  10995. /**
  10996. * Set the WebGL's viewport
  10997. * @param viewport defines the viewport element to be used
  10998. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10999. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  11000. */
  11001. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  11002. /**
  11003. * Directly set the WebGL Viewport
  11004. * @param x defines the x coordinate of the viewport (in screen space)
  11005. * @param y defines the y coordinate of the viewport (in screen space)
  11006. * @param width defines the width of the viewport (in screen space)
  11007. * @param height defines the height of the viewport (in screen space)
  11008. * @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
  11009. */
  11010. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  11011. /**
  11012. * Begin a new frame
  11013. */
  11014. beginFrame(): void;
  11015. /**
  11016. * Enf the current frame
  11017. */
  11018. endFrame(): void;
  11019. /**
  11020. * Resize the view according to the canvas' size
  11021. */
  11022. resize(): void;
  11023. /**
  11024. * Force a specific size of the canvas
  11025. * @param width defines the new canvas' width
  11026. * @param height defines the new canvas' height
  11027. */
  11028. setSize(width: number, height: number): void;
  11029. /**
  11030. * Gets a boolean indicating if a webVR device was detected
  11031. * @returns true if a webVR device was detected
  11032. */
  11033. isVRDevicePresent(): boolean;
  11034. /**
  11035. * Gets the current webVR device
  11036. * @returns the current webVR device (or null)
  11037. */
  11038. getVRDevice(): any;
  11039. /**
  11040. * Initializes a webVR display and starts listening to display change events
  11041. * The onVRDisplayChangedObservable will be notified upon these changes
  11042. * @returns The onVRDisplayChangedObservable
  11043. */
  11044. initWebVR(): Observable<IDisplayChangedEventArgs>;
  11045. /**
  11046. * Initializes a webVR display and starts listening to display change events
  11047. * The onVRDisplayChangedObservable will be notified upon these changes
  11048. * @returns A promise containing a VRDisplay and if vr is supported
  11049. */
  11050. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  11051. /**
  11052. * Call this function to switch to webVR mode
  11053. * Will do nothing if webVR is not supported or if there is no webVR device
  11054. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11055. */
  11056. enableVR(): void;
  11057. /**
  11058. * Call this function to leave webVR mode
  11059. * Will do nothing if webVR is not supported or if there is no webVR device
  11060. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11061. */
  11062. disableVR(): void;
  11063. private _onVRFullScreenTriggered;
  11064. private _getVRDisplaysAsync;
  11065. /**
  11066. * Binds the frame buffer to the specified texture.
  11067. * @param texture The texture to render to or null for the default canvas
  11068. * @param faceIndex The face of the texture to render to in case of cube texture
  11069. * @param requiredWidth The width of the target to render to
  11070. * @param requiredHeight The height of the target to render to
  11071. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  11072. * @param depthStencilTexture The depth stencil texture to use to render
  11073. * @param lodLevel defines le lod level to bind to the frame buffer
  11074. */
  11075. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  11076. private bindUnboundFramebuffer;
  11077. /**
  11078. * Unbind the current render target texture from the webGL context
  11079. * @param texture defines the render target texture to unbind
  11080. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11081. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11082. */
  11083. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11084. /**
  11085. * Unbind a list of render target textures from the webGL context
  11086. * This is used only when drawBuffer extension or webGL2 are active
  11087. * @param textures defines the render target textures to unbind
  11088. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11089. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11090. */
  11091. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11092. /**
  11093. * Force the mipmap generation for the given render target texture
  11094. * @param texture defines the render target texture to use
  11095. */
  11096. generateMipMapsForCubemap(texture: InternalTexture): void;
  11097. /**
  11098. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  11099. */
  11100. flushFramebuffer(): void;
  11101. /**
  11102. * Unbind the current render target and bind the default framebuffer
  11103. */
  11104. restoreDefaultFramebuffer(): void;
  11105. /**
  11106. * Create an uniform buffer
  11107. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11108. * @param elements defines the content of the uniform buffer
  11109. * @returns the webGL uniform buffer
  11110. */
  11111. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  11112. /**
  11113. * Create a dynamic uniform buffer
  11114. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11115. * @param elements defines the content of the uniform buffer
  11116. * @returns the webGL uniform buffer
  11117. */
  11118. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  11119. /**
  11120. * Update an existing uniform buffer
  11121. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11122. * @param uniformBuffer defines the target uniform buffer
  11123. * @param elements defines the content to update
  11124. * @param offset defines the offset in the uniform buffer where update should start
  11125. * @param count defines the size of the data to update
  11126. */
  11127. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  11128. private _resetVertexBufferBinding;
  11129. /**
  11130. * Creates a vertex buffer
  11131. * @param data the data for the vertex buffer
  11132. * @returns the new WebGL static buffer
  11133. */
  11134. createVertexBuffer(data: DataArray): WebGLBuffer;
  11135. /**
  11136. * Creates a dynamic vertex buffer
  11137. * @param data the data for the dynamic vertex buffer
  11138. * @returns the new WebGL dynamic buffer
  11139. */
  11140. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  11141. /**
  11142. * Update a dynamic index buffer
  11143. * @param indexBuffer defines the target index buffer
  11144. * @param indices defines the data to update
  11145. * @param offset defines the offset in the target index buffer where update should start
  11146. */
  11147. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11148. /**
  11149. * Updates a dynamic vertex buffer.
  11150. * @param vertexBuffer the vertex buffer to update
  11151. * @param data the data used to update the vertex buffer
  11152. * @param byteOffset the byte offset of the data
  11153. * @param byteLength the byte length of the data
  11154. */
  11155. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11156. private _resetIndexBufferBinding;
  11157. /**
  11158. * Creates a new index buffer
  11159. * @param indices defines the content of the index buffer
  11160. * @param updatable defines if the index buffer must be updatable
  11161. * @returns a new webGL buffer
  11162. */
  11163. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  11164. /**
  11165. * Bind a webGL buffer to the webGL context
  11166. * @param buffer defines the buffer to bind
  11167. */
  11168. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  11169. /**
  11170. * Bind an uniform buffer to the current webGL context
  11171. * @param buffer defines the buffer to bind
  11172. */
  11173. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  11174. /**
  11175. * Bind a buffer to the current webGL context at a given location
  11176. * @param buffer defines the buffer to bind
  11177. * @param location defines the index where to bind the buffer
  11178. */
  11179. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  11180. /**
  11181. * Bind a specific block at a given index in a specific shader program
  11182. * @param shaderProgram defines the shader program
  11183. * @param blockName defines the block name
  11184. * @param index defines the index where to bind the block
  11185. */
  11186. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  11187. private bindIndexBuffer;
  11188. private bindBuffer;
  11189. /**
  11190. * update the bound buffer with the given data
  11191. * @param data defines the data to update
  11192. */
  11193. updateArrayBuffer(data: Float32Array): void;
  11194. private _vertexAttribPointer;
  11195. private _bindIndexBufferWithCache;
  11196. private _bindVertexBuffersAttributes;
  11197. /**
  11198. * Records a vertex array object
  11199. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11200. * @param vertexBuffers defines the list of vertex buffers to store
  11201. * @param indexBuffer defines the index buffer to store
  11202. * @param effect defines the effect to store
  11203. * @returns the new vertex array object
  11204. */
  11205. recordVertexArrayObject(vertexBuffers: {
  11206. [key: string]: VertexBuffer;
  11207. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  11208. /**
  11209. * Bind a specific vertex array object
  11210. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11211. * @param vertexArrayObject defines the vertex array object to bind
  11212. * @param indexBuffer defines the index buffer to bind
  11213. */
  11214. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11215. /**
  11216. * Bind webGl buffers directly to the webGL context
  11217. * @param vertexBuffer defines the vertex buffer to bind
  11218. * @param indexBuffer defines the index buffer to bind
  11219. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11220. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11221. * @param effect defines the effect associated with the vertex buffer
  11222. */
  11223. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11224. private _unbindVertexArrayObject;
  11225. /**
  11226. * Bind a list of vertex buffers to the webGL context
  11227. * @param vertexBuffers defines the list of vertex buffers to bind
  11228. * @param indexBuffer defines the index buffer to bind
  11229. * @param effect defines the effect associated with the vertex buffers
  11230. */
  11231. bindBuffers(vertexBuffers: {
  11232. [key: string]: Nullable<VertexBuffer>;
  11233. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11234. /**
  11235. * Unbind all instance attributes
  11236. */
  11237. unbindInstanceAttributes(): void;
  11238. /**
  11239. * Release and free the memory of a vertex array object
  11240. * @param vao defines the vertex array object to delete
  11241. */
  11242. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11243. /** @hidden */
  11244. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11245. /**
  11246. * Creates a webGL buffer to use with instanciation
  11247. * @param capacity defines the size of the buffer
  11248. * @returns the webGL buffer
  11249. */
  11250. createInstancesBuffer(capacity: number): WebGLBuffer;
  11251. /**
  11252. * Delete a webGL buffer used with instanciation
  11253. * @param buffer defines the webGL buffer to delete
  11254. */
  11255. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11256. /**
  11257. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11258. * @param instancesBuffer defines the webGL buffer to update and bind
  11259. * @param data defines the data to store in the buffer
  11260. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11261. */
  11262. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11263. /**
  11264. * Apply all cached states (depth, culling, stencil and alpha)
  11265. */
  11266. applyStates(): void;
  11267. /**
  11268. * Send a draw order
  11269. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11270. * @param indexStart defines the starting index
  11271. * @param indexCount defines the number of index to draw
  11272. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11273. */
  11274. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11275. /**
  11276. * Draw a list of points
  11277. * @param verticesStart defines the index of first vertex to draw
  11278. * @param verticesCount defines the count of vertices to draw
  11279. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11280. */
  11281. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11282. /**
  11283. * Draw a list of unindexed primitives
  11284. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11285. * @param verticesStart defines the index of first vertex to draw
  11286. * @param verticesCount defines the count of vertices to draw
  11287. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11288. */
  11289. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11290. /**
  11291. * Draw a list of indexed primitives
  11292. * @param fillMode defines the primitive to use
  11293. * @param indexStart defines the starting index
  11294. * @param indexCount defines the number of index to draw
  11295. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11296. */
  11297. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11298. /**
  11299. * Draw a list of unindexed primitives
  11300. * @param fillMode defines the primitive to use
  11301. * @param verticesStart defines the index of first vertex to draw
  11302. * @param verticesCount defines the count of vertices to draw
  11303. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11304. */
  11305. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11306. private _drawMode;
  11307. /** @hidden */
  11308. _releaseEffect(effect: Effect): void;
  11309. /** @hidden */
  11310. _deleteProgram(program: WebGLProgram): void;
  11311. /**
  11312. * Create a new effect (used to store vertex/fragment shaders)
  11313. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11314. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11315. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11316. * @param samplers defines an array of string used to represent textures
  11317. * @param defines defines the string containing the defines to use to compile the shaders
  11318. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11319. * @param onCompiled defines a function to call when the effect creation is successful
  11320. * @param onError defines a function to call when the effect creation has failed
  11321. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11322. * @returns the new Effect
  11323. */
  11324. 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;
  11325. private _compileShader;
  11326. private _compileRawShader;
  11327. /**
  11328. * Directly creates a webGL program
  11329. * @param vertexCode defines the vertex shader code to use
  11330. * @param fragmentCode defines the fragment shader code to use
  11331. * @param context defines the webGL context to use (if not set, the current one will be used)
  11332. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11333. * @returns the new webGL program
  11334. */
  11335. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11336. /**
  11337. * Creates a webGL program
  11338. * @param vertexCode defines the vertex shader code to use
  11339. * @param fragmentCode defines the fragment shader code to use
  11340. * @param defines defines the string containing the defines to use to compile the shaders
  11341. * @param context defines the webGL context to use (if not set, the current one will be used)
  11342. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11343. * @returns the new webGL program
  11344. */
  11345. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11346. private _createShaderProgram;
  11347. private _finalizeProgram;
  11348. /** @hidden */
  11349. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11350. /** @hidden */
  11351. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11352. /**
  11353. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11354. * @param shaderProgram defines the webGL program to use
  11355. * @param uniformsNames defines the list of uniform names
  11356. * @returns an array of webGL uniform locations
  11357. */
  11358. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11359. /**
  11360. * Gets the lsit of active attributes for a given webGL program
  11361. * @param shaderProgram defines the webGL program to use
  11362. * @param attributesNames defines the list of attribute names to get
  11363. * @returns an array of indices indicating the offset of each attribute
  11364. */
  11365. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11366. /**
  11367. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11368. * @param effect defines the effect to activate
  11369. */
  11370. enableEffect(effect: Nullable<Effect>): void;
  11371. /**
  11372. * Set the value of an uniform to an array of int32
  11373. * @param uniform defines the webGL uniform location where to store the value
  11374. * @param array defines the array of int32 to store
  11375. */
  11376. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11377. /**
  11378. * Set the value of an uniform to an array of int32 (stored as vec2)
  11379. * @param uniform defines the webGL uniform location where to store the value
  11380. * @param array defines the array of int32 to store
  11381. */
  11382. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11383. /**
  11384. * Set the value of an uniform to an array of int32 (stored as vec3)
  11385. * @param uniform defines the webGL uniform location where to store the value
  11386. * @param array defines the array of int32 to store
  11387. */
  11388. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11389. /**
  11390. * Set the value of an uniform to an array of int32 (stored as vec4)
  11391. * @param uniform defines the webGL uniform location where to store the value
  11392. * @param array defines the array of int32 to store
  11393. */
  11394. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11395. /**
  11396. * Set the value of an uniform to an array of float32
  11397. * @param uniform defines the webGL uniform location where to store the value
  11398. * @param array defines the array of float32 to store
  11399. */
  11400. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11401. /**
  11402. * Set the value of an uniform to an array of float32 (stored as vec2)
  11403. * @param uniform defines the webGL uniform location where to store the value
  11404. * @param array defines the array of float32 to store
  11405. */
  11406. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11407. /**
  11408. * Set the value of an uniform to an array of float32 (stored as vec3)
  11409. * @param uniform defines the webGL uniform location where to store the value
  11410. * @param array defines the array of float32 to store
  11411. */
  11412. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11413. /**
  11414. * Set the value of an uniform to an array of float32 (stored as vec4)
  11415. * @param uniform defines the webGL uniform location where to store the value
  11416. * @param array defines the array of float32 to store
  11417. */
  11418. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11419. /**
  11420. * Set the value of an uniform to an array of number
  11421. * @param uniform defines the webGL uniform location where to store the value
  11422. * @param array defines the array of number to store
  11423. */
  11424. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11425. /**
  11426. * Set the value of an uniform to an array of number (stored as vec2)
  11427. * @param uniform defines the webGL uniform location where to store the value
  11428. * @param array defines the array of number to store
  11429. */
  11430. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11431. /**
  11432. * Set the value of an uniform to an array of number (stored as vec3)
  11433. * @param uniform defines the webGL uniform location where to store the value
  11434. * @param array defines the array of number to store
  11435. */
  11436. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11437. /**
  11438. * Set the value of an uniform to an array of number (stored as vec4)
  11439. * @param uniform defines the webGL uniform location where to store the value
  11440. * @param array defines the array of number to store
  11441. */
  11442. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11443. /**
  11444. * Set the value of an uniform to an array of float32 (stored as matrices)
  11445. * @param uniform defines the webGL uniform location where to store the value
  11446. * @param matrices defines the array of float32 to store
  11447. */
  11448. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11449. /**
  11450. * Set the value of an uniform to a matrix
  11451. * @param uniform defines the webGL uniform location where to store the value
  11452. * @param matrix defines the matrix to store
  11453. */
  11454. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11455. /**
  11456. * Set the value of an uniform to a matrix (3x3)
  11457. * @param uniform defines the webGL uniform location where to store the value
  11458. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11459. */
  11460. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11461. /**
  11462. * Set the value of an uniform to a matrix (2x2)
  11463. * @param uniform defines the webGL uniform location where to store the value
  11464. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11465. */
  11466. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11467. /**
  11468. * Set the value of an uniform to a number (int)
  11469. * @param uniform defines the webGL uniform location where to store the value
  11470. * @param value defines the int number to store
  11471. */
  11472. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11473. /**
  11474. * Set the value of an uniform to a number (float)
  11475. * @param uniform defines the webGL uniform location where to store the value
  11476. * @param value defines the float number to store
  11477. */
  11478. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11479. /**
  11480. * Set the value of an uniform to a vec2
  11481. * @param uniform defines the webGL uniform location where to store the value
  11482. * @param x defines the 1st component of the value
  11483. * @param y defines the 2nd component of the value
  11484. */
  11485. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11486. /**
  11487. * Set the value of an uniform to a vec3
  11488. * @param uniform defines the webGL uniform location where to store the value
  11489. * @param x defines the 1st component of the value
  11490. * @param y defines the 2nd component of the value
  11491. * @param z defines the 3rd component of the value
  11492. */
  11493. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11494. /**
  11495. * Set the value of an uniform to a boolean
  11496. * @param uniform defines the webGL uniform location where to store the value
  11497. * @param bool defines the boolean to store
  11498. */
  11499. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11500. /**
  11501. * Set the value of an uniform to a vec4
  11502. * @param uniform defines the webGL uniform location where to store the value
  11503. * @param x defines the 1st component of the value
  11504. * @param y defines the 2nd component of the value
  11505. * @param z defines the 3rd component of the value
  11506. * @param w defines the 4th component of the value
  11507. */
  11508. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11509. /**
  11510. * Set the value of an uniform to a Color3
  11511. * @param uniform defines the webGL uniform location where to store the value
  11512. * @param color3 defines the color to store
  11513. */
  11514. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11515. /**
  11516. * Set the value of an uniform to a Color3 and an alpha value
  11517. * @param uniform defines the webGL uniform location where to store the value
  11518. * @param color3 defines the color to store
  11519. * @param alpha defines the alpha component to store
  11520. */
  11521. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11522. /**
  11523. * Sets a Color4 on a uniform variable
  11524. * @param uniform defines the uniform location
  11525. * @param color4 defines the value to be set
  11526. */
  11527. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11528. /**
  11529. * Set various states to the webGL context
  11530. * @param culling defines backface culling state
  11531. * @param zOffset defines the value to apply to zOffset (0 by default)
  11532. * @param force defines if states must be applied even if cache is up to date
  11533. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11534. */
  11535. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11536. /**
  11537. * Set the z offset to apply to current rendering
  11538. * @param value defines the offset to apply
  11539. */
  11540. setZOffset(value: number): void;
  11541. /**
  11542. * Gets the current value of the zOffset
  11543. * @returns the current zOffset state
  11544. */
  11545. getZOffset(): number;
  11546. /**
  11547. * Enable or disable depth buffering
  11548. * @param enable defines the state to set
  11549. */
  11550. setDepthBuffer(enable: boolean): void;
  11551. /**
  11552. * Gets a boolean indicating if depth writing is enabled
  11553. * @returns the current depth writing state
  11554. */
  11555. getDepthWrite(): boolean;
  11556. /**
  11557. * Enable or disable depth writing
  11558. * @param enable defines the state to set
  11559. */
  11560. setDepthWrite(enable: boolean): void;
  11561. /**
  11562. * Enable or disable color writing
  11563. * @param enable defines the state to set
  11564. */
  11565. setColorWrite(enable: boolean): void;
  11566. /**
  11567. * Gets a boolean indicating if color writing is enabled
  11568. * @returns the current color writing state
  11569. */
  11570. getColorWrite(): boolean;
  11571. /**
  11572. * Sets alpha constants used by some alpha blending modes
  11573. * @param r defines the red component
  11574. * @param g defines the green component
  11575. * @param b defines the blue component
  11576. * @param a defines the alpha component
  11577. */
  11578. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11579. /**
  11580. * Sets the current alpha mode
  11581. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11582. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11583. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11584. */
  11585. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11586. /**
  11587. * Gets the current alpha mode
  11588. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11589. * @returns the current alpha mode
  11590. */
  11591. getAlphaMode(): number;
  11592. /**
  11593. * Clears the list of texture accessible through engine.
  11594. * This can help preventing texture load conflict due to name collision.
  11595. */
  11596. clearInternalTexturesCache(): void;
  11597. /**
  11598. * Force the entire cache to be cleared
  11599. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11600. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11601. */
  11602. wipeCaches(bruteForce?: boolean): void;
  11603. /**
  11604. * Set the compressed texture format to use, based on the formats you have, and the formats
  11605. * supported by the hardware / browser.
  11606. *
  11607. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11608. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11609. * to API arguments needed to compressed textures. This puts the burden on the container
  11610. * generator to house the arcane code for determining these for current & future formats.
  11611. *
  11612. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11613. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11614. *
  11615. * Note: The result of this call is not taken into account when a texture is base64.
  11616. *
  11617. * @param formatsAvailable defines the list of those format families you have created
  11618. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11619. *
  11620. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11621. * @returns The extension selected.
  11622. */
  11623. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11624. private _getSamplingParameters;
  11625. private _partialLoadImg;
  11626. private _cascadeLoadImgs;
  11627. /** @hidden */
  11628. _createTexture(): WebGLTexture;
  11629. /**
  11630. * Usually called from BABYLON.Texture.ts.
  11631. * Passed information to create a WebGLTexture
  11632. * @param urlArg defines a value which contains one of the following:
  11633. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11634. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11635. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11636. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11637. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  11638. * @param scene needed for loading to the correct scene
  11639. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11640. * @param onLoad optional callback to be called upon successful completion
  11641. * @param onError optional callback to be called upon failure
  11642. * @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
  11643. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11644. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11645. * @param forcedExtension defines the extension to use to pick the right loader
  11646. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  11647. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11648. */
  11649. 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;
  11650. private _rescaleTexture;
  11651. /**
  11652. * Update a raw texture
  11653. * @param texture defines the texture to update
  11654. * @param data defines the data to store in the texture
  11655. * @param format defines the format of the data
  11656. * @param invertY defines if data must be stored with Y axis inverted
  11657. * @param compression defines the compression used (null by default)
  11658. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11659. */
  11660. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11661. /**
  11662. * Creates a raw texture
  11663. * @param data defines the data to store in the texture
  11664. * @param width defines the width of the texture
  11665. * @param height defines the height of the texture
  11666. * @param format defines the format of the data
  11667. * @param generateMipMaps defines if the engine should generate the mip levels
  11668. * @param invertY defines if data must be stored with Y axis inverted
  11669. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11670. * @param compression defines the compression used (null by default)
  11671. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11672. * @returns the raw texture inside an InternalTexture
  11673. */
  11674. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11675. private _unpackFlipYCached;
  11676. /**
  11677. * In case you are sharing the context with other applications, it might
  11678. * be interested to not cache the unpack flip y state to ensure a consistent
  11679. * value would be set.
  11680. */
  11681. enableUnpackFlipYCached: boolean;
  11682. /** @hidden */
  11683. _unpackFlipY(value: boolean): void;
  11684. /** @hidden */
  11685. _getUnpackAlignement(): number;
  11686. /**
  11687. * Creates a dynamic texture
  11688. * @param width defines the width of the texture
  11689. * @param height defines the height of the texture
  11690. * @param generateMipMaps defines if the engine should generate the mip levels
  11691. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11692. * @returns the dynamic texture inside an InternalTexture
  11693. */
  11694. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11695. /**
  11696. * Update the sampling mode of a given texture
  11697. * @param samplingMode defines the required sampling mode
  11698. * @param texture defines the texture to update
  11699. */
  11700. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11701. /**
  11702. * Update the content of a dynamic texture
  11703. * @param texture defines the texture to update
  11704. * @param canvas defines the canvas containing the source
  11705. * @param invertY defines if data must be stored with Y axis inverted
  11706. * @param premulAlpha defines if alpha is stored as premultiplied
  11707. * @param format defines the format of the data
  11708. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11709. */
  11710. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11711. /**
  11712. * Update a video texture
  11713. * @param texture defines the texture to update
  11714. * @param video defines the video element to use
  11715. * @param invertY defines if data must be stored with Y axis inverted
  11716. */
  11717. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11718. /**
  11719. * Updates a depth texture Comparison Mode and Function.
  11720. * If the comparison Function is equal to 0, the mode will be set to none.
  11721. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11722. * @param texture The texture to set the comparison function for
  11723. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11724. */
  11725. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11726. private _setupDepthStencilTexture;
  11727. /**
  11728. * Creates a depth stencil texture.
  11729. * This is only available in WebGL 2 or with the depth texture extension available.
  11730. * @param size The size of face edge in the texture.
  11731. * @param options The options defining the texture.
  11732. * @returns The texture
  11733. */
  11734. createDepthStencilTexture(size: number | {
  11735. width: number;
  11736. height: number;
  11737. }, options: DepthTextureCreationOptions): InternalTexture;
  11738. /**
  11739. * Creates a depth stencil texture.
  11740. * This is only available in WebGL 2 or with the depth texture extension available.
  11741. * @param size The size of face edge in the texture.
  11742. * @param options The options defining the texture.
  11743. * @returns The texture
  11744. */
  11745. private _createDepthStencilTexture;
  11746. /**
  11747. * Creates a depth stencil cube texture.
  11748. * This is only available in WebGL 2.
  11749. * @param size The size of face edge in the cube texture.
  11750. * @param options The options defining the cube texture.
  11751. * @returns The cube texture
  11752. */
  11753. private _createDepthStencilCubeTexture;
  11754. /**
  11755. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11756. * @param renderTarget The render target to set the frame buffer for
  11757. */
  11758. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11759. /**
  11760. * Creates a new render target texture
  11761. * @param size defines the size of the texture
  11762. * @param options defines the options used to create the texture
  11763. * @returns a new render target texture stored in an InternalTexture
  11764. */
  11765. createRenderTargetTexture(size: number | {
  11766. width: number;
  11767. height: number;
  11768. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11769. /**
  11770. * Create a multi render target texture
  11771. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11772. * @param size defines the size of the texture
  11773. * @param options defines the creation options
  11774. * @returns the cube texture as an InternalTexture
  11775. */
  11776. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11777. private _setupFramebufferDepthAttachments;
  11778. /**
  11779. * Updates the sample count of a render target texture
  11780. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11781. * @param texture defines the texture to update
  11782. * @param samples defines the sample count to set
  11783. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11784. */
  11785. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11786. /**
  11787. * Update the sample count for a given multiple render target texture
  11788. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11789. * @param textures defines the textures to update
  11790. * @param samples defines the sample count to set
  11791. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11792. */
  11793. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11794. /** @hidden */
  11795. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11796. /** @hidden */
  11797. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11798. /** @hidden */
  11799. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11800. /** @hidden */
  11801. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11802. /**
  11803. * Creates a new render target cube texture
  11804. * @param size defines the size of the texture
  11805. * @param options defines the options used to create the texture
  11806. * @returns a new render target cube texture stored in an InternalTexture
  11807. */
  11808. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11809. /**
  11810. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11811. * @param rootUrl defines the url where the file to load is located
  11812. * @param scene defines the current scene
  11813. * @param lodScale defines scale to apply to the mip map selection
  11814. * @param lodOffset defines offset to apply to the mip map selection
  11815. * @param onLoad defines an optional callback raised when the texture is loaded
  11816. * @param onError defines an optional callback raised if there is an issue to load the texture
  11817. * @param format defines the format of the data
  11818. * @param forcedExtension defines the extension to use to pick the right loader
  11819. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11820. * @returns the cube texture as an InternalTexture
  11821. */
  11822. 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;
  11823. /**
  11824. * Creates a cube texture
  11825. * @param rootUrl defines the url where the files to load is located
  11826. * @param scene defines the current scene
  11827. * @param files defines the list of files to load (1 per face)
  11828. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11829. * @param onLoad defines an optional callback raised when the texture is loaded
  11830. * @param onError defines an optional callback raised if there is an issue to load the texture
  11831. * @param format defines the format of the data
  11832. * @param forcedExtension defines the extension to use to pick the right loader
  11833. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11834. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11835. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11836. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11837. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  11838. * @returns the cube texture as an InternalTexture
  11839. */
  11840. 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;
  11841. /**
  11842. * @hidden
  11843. */
  11844. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11845. /**
  11846. * Update a raw cube texture
  11847. * @param texture defines the texture to udpdate
  11848. * @param data defines the data to store
  11849. * @param format defines the data format
  11850. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11851. * @param invertY defines if data must be stored with Y axis inverted
  11852. * @param compression defines the compression used (null by default)
  11853. * @param level defines which level of the texture to update
  11854. */
  11855. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11856. /**
  11857. * Creates a new raw cube texture
  11858. * @param data defines the array of data to use to create each face
  11859. * @param size defines the size of the textures
  11860. * @param format defines the format of the data
  11861. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11862. * @param generateMipMaps defines if the engine should generate the mip levels
  11863. * @param invertY defines if data must be stored with Y axis inverted
  11864. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11865. * @param compression defines the compression used (null by default)
  11866. * @returns the cube texture as an InternalTexture
  11867. */
  11868. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11869. /**
  11870. * Creates a new raw cube texture from a specified url
  11871. * @param url defines the url where the data is located
  11872. * @param scene defines the current scene
  11873. * @param size defines the size of the textures
  11874. * @param format defines the format of the data
  11875. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11876. * @param noMipmap defines if the engine should avoid generating the mip levels
  11877. * @param callback defines a callback used to extract texture data from loaded data
  11878. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11879. * @param onLoad defines a callback called when texture is loaded
  11880. * @param onError defines a callback called if there is an error
  11881. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11882. * @param invertY defines if data must be stored with Y axis inverted
  11883. * @returns the cube texture as an InternalTexture
  11884. */
  11885. 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;
  11886. /**
  11887. * Update a raw 3D texture
  11888. * @param texture defines the texture to update
  11889. * @param data defines the data to store
  11890. * @param format defines the data format
  11891. * @param invertY defines if data must be stored with Y axis inverted
  11892. * @param compression defines the used compression (can be null)
  11893. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11894. */
  11895. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11896. /**
  11897. * Creates a new raw 3D texture
  11898. * @param data defines the data used to create the texture
  11899. * @param width defines the width of the texture
  11900. * @param height defines the height of the texture
  11901. * @param depth defines the depth of the texture
  11902. * @param format defines the format of the texture
  11903. * @param generateMipMaps defines if the engine must generate mip levels
  11904. * @param invertY defines if data must be stored with Y axis inverted
  11905. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11906. * @param compression defines the compressed used (can be null)
  11907. * @param textureType defines the compressed used (can be null)
  11908. * @returns a new raw 3D texture (stored in an InternalTexture)
  11909. */
  11910. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11911. private _prepareWebGLTextureContinuation;
  11912. private _prepareWebGLTexture;
  11913. private _convertRGBtoRGBATextureData;
  11914. /** @hidden */
  11915. _releaseFramebufferObjects(texture: InternalTexture): void;
  11916. /** @hidden */
  11917. _releaseTexture(texture: InternalTexture): void;
  11918. private setProgram;
  11919. private _boundUniforms;
  11920. /**
  11921. * Binds an effect to the webGL context
  11922. * @param effect defines the effect to bind
  11923. */
  11924. bindSamplers(effect: Effect): void;
  11925. private _moveBoundTextureOnTop;
  11926. private _getCorrectTextureChannel;
  11927. private _linkTrackers;
  11928. private _removeDesignatedSlot;
  11929. private _activateCurrentTexture;
  11930. /** @hidden */
  11931. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11932. /** @hidden */
  11933. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11934. /**
  11935. * Sets a texture to the webGL context from a postprocess
  11936. * @param channel defines the channel to use
  11937. * @param postProcess defines the source postprocess
  11938. */
  11939. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11940. /**
  11941. * Binds the output of the passed in post process to the texture channel specified
  11942. * @param channel The channel the texture should be bound to
  11943. * @param postProcess The post process which's output should be bound
  11944. */
  11945. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11946. /**
  11947. * Unbind all textures from the webGL context
  11948. */
  11949. unbindAllTextures(): void;
  11950. /**
  11951. * Sets a texture to the according uniform.
  11952. * @param channel The texture channel
  11953. * @param uniform The uniform to set
  11954. * @param texture The texture to apply
  11955. */
  11956. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11957. /**
  11958. * Sets a depth stencil texture from a render target to the according uniform.
  11959. * @param channel The texture channel
  11960. * @param uniform The uniform to set
  11961. * @param texture The render target texture containing the depth stencil texture to apply
  11962. */
  11963. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11964. private _bindSamplerUniformToChannel;
  11965. private _getTextureWrapMode;
  11966. private _setTexture;
  11967. /**
  11968. * Sets an array of texture to the webGL context
  11969. * @param channel defines the channel where the texture array must be set
  11970. * @param uniform defines the associated uniform location
  11971. * @param textures defines the array of textures to bind
  11972. */
  11973. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11974. /** @hidden */
  11975. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11976. private _setTextureParameterFloat;
  11977. private _setTextureParameterInteger;
  11978. /**
  11979. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11980. * @param x defines the x coordinate of the rectangle where pixels must be read
  11981. * @param y defines the y coordinate of the rectangle where pixels must be read
  11982. * @param width defines the width of the rectangle where pixels must be read
  11983. * @param height defines the height of the rectangle where pixels must be read
  11984. * @returns a Uint8Array containing RGBA colors
  11985. */
  11986. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11987. /**
  11988. * Add an externaly attached data from its key.
  11989. * This method call will fail and return false, if such key already exists.
  11990. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11991. * @param key the unique key that identifies the data
  11992. * @param data the data object to associate to the key for this Engine instance
  11993. * @return true if no such key were already present and the data was added successfully, false otherwise
  11994. */
  11995. addExternalData<T>(key: string, data: T): boolean;
  11996. /**
  11997. * Get an externaly attached data from its key
  11998. * @param key the unique key that identifies the data
  11999. * @return the associated data, if present (can be null), or undefined if not present
  12000. */
  12001. getExternalData<T>(key: string): T;
  12002. /**
  12003. * Get an externaly attached data from its key, create it using a factory if it's not already present
  12004. * @param key the unique key that identifies the data
  12005. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  12006. * @return the associated data, can be null if the factory returned null.
  12007. */
  12008. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  12009. /**
  12010. * Remove an externaly attached data from the Engine instance
  12011. * @param key the unique key that identifies the data
  12012. * @return true if the data was successfully removed, false if it doesn't exist
  12013. */
  12014. removeExternalData(key: string): boolean;
  12015. /**
  12016. * Unbind all vertex attributes from the webGL context
  12017. */
  12018. unbindAllAttributes(): void;
  12019. /**
  12020. * 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
  12021. */
  12022. releaseEffects(): void;
  12023. /**
  12024. * Dispose and release all associated resources
  12025. */
  12026. dispose(): void;
  12027. /**
  12028. * Display the loading screen
  12029. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12030. */
  12031. displayLoadingUI(): void;
  12032. /**
  12033. * Hide the loading screen
  12034. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12035. */
  12036. hideLoadingUI(): void;
  12037. /**
  12038. * Gets the current loading screen object
  12039. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12040. */
  12041. /**
  12042. * Sets the current loading screen object
  12043. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12044. */
  12045. loadingScreen: ILoadingScreen;
  12046. /**
  12047. * Sets the current loading screen text
  12048. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12049. */
  12050. loadingUIText: string;
  12051. /**
  12052. * Sets the current loading screen background color
  12053. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12054. */
  12055. loadingUIBackgroundColor: string;
  12056. /**
  12057. * Attach a new callback raised when context lost event is fired
  12058. * @param callback defines the callback to call
  12059. */
  12060. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12061. /**
  12062. * Attach a new callback raised when context restored event is fired
  12063. * @param callback defines the callback to call
  12064. */
  12065. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12066. /**
  12067. * Gets the source code of the vertex shader associated with a specific webGL program
  12068. * @param program defines the program to use
  12069. * @returns a string containing the source code of the vertex shader associated with the program
  12070. */
  12071. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  12072. /**
  12073. * Gets the source code of the fragment shader associated with a specific webGL program
  12074. * @param program defines the program to use
  12075. * @returns a string containing the source code of the fragment shader associated with the program
  12076. */
  12077. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  12078. /**
  12079. * Get the current error code of the webGL context
  12080. * @returns the error code
  12081. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12082. */
  12083. getError(): number;
  12084. /**
  12085. * Gets the current framerate
  12086. * @returns a number representing the framerate
  12087. */
  12088. getFps(): number;
  12089. /**
  12090. * Gets the time spent between current and previous frame
  12091. * @returns a number representing the delta time in ms
  12092. */
  12093. getDeltaTime(): number;
  12094. private _measureFps;
  12095. /** @hidden */
  12096. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  12097. private _canRenderToFloatFramebuffer;
  12098. private _canRenderToHalfFloatFramebuffer;
  12099. private _canRenderToFramebuffer;
  12100. /** @hidden */
  12101. _getWebGLTextureType(type: number): number;
  12102. private _getInternalFormat;
  12103. /** @hidden */
  12104. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  12105. /** @hidden */
  12106. _getRGBAMultiSampleBufferFormat(type: number): number;
  12107. /** @hidden */
  12108. _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;
  12109. /** @hidden */
  12110. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  12111. private _partialLoadFile;
  12112. private _cascadeLoadFiles;
  12113. /**
  12114. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  12115. * @returns true if the engine can be created
  12116. * @ignorenaming
  12117. */
  12118. static isSupported(): boolean;
  12119. }
  12120. }
  12121. declare module BABYLON {
  12122. /**
  12123. * Options to create the null engine
  12124. */
  12125. class NullEngineOptions {
  12126. /**
  12127. * Render width (Default: 512)
  12128. */
  12129. renderWidth: number;
  12130. /**
  12131. * Render height (Default: 256)
  12132. */
  12133. renderHeight: number;
  12134. /**
  12135. * Texture size (Default: 512)
  12136. */
  12137. textureSize: number;
  12138. /**
  12139. * If delta time between frames should be constant
  12140. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12141. */
  12142. deterministicLockstep: boolean;
  12143. /**
  12144. * Maximum about of steps between frames (Default: 4)
  12145. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12146. */
  12147. lockstepMaxSteps: number;
  12148. }
  12149. /**
  12150. * The null engine class provides support for headless version of babylon.js.
  12151. * This can be used in server side scenario or for testing purposes
  12152. */
  12153. class NullEngine extends Engine {
  12154. private _options;
  12155. /**
  12156. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12157. */
  12158. isDeterministicLockStep(): boolean;
  12159. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  12160. getLockstepMaxSteps(): number;
  12161. /**
  12162. * Sets hardware scaling, used to save performance if needed
  12163. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  12164. */
  12165. getHardwareScalingLevel(): number;
  12166. constructor(options?: NullEngineOptions);
  12167. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12168. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  12169. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  12170. getRenderWidth(useScreen?: boolean): number;
  12171. getRenderHeight(useScreen?: boolean): number;
  12172. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  12173. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  12174. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  12175. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  12176. bindSamplers(effect: Effect): void;
  12177. enableEffect(effect: Effect): void;
  12178. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  12179. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  12180. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  12181. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  12182. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  12183. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  12184. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  12185. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  12186. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  12187. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  12188. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  12189. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  12190. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  12191. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  12192. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  12193. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12194. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12195. setFloat(uniform: WebGLUniformLocation, value: number): void;
  12196. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  12197. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  12198. setBool(uniform: WebGLUniformLocation, bool: number): void;
  12199. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  12200. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  12201. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  12202. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12203. bindBuffers(vertexBuffers: {
  12204. [key: string]: VertexBuffer;
  12205. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  12206. wipeCaches(bruteForce?: boolean): void;
  12207. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  12208. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  12209. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  12210. /** @hidden */
  12211. _createTexture(): WebGLTexture;
  12212. /** @hidden */
  12213. _releaseTexture(texture: InternalTexture): void;
  12214. 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;
  12215. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12216. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12217. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12218. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12219. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12220. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12221. areAllEffectsReady(): boolean;
  12222. /**
  12223. * @hidden
  12224. * Get the current error code of the webGL context
  12225. * @returns the error code
  12226. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12227. */
  12228. getError(): number;
  12229. /** @hidden */
  12230. _getUnpackAlignement(): number;
  12231. /** @hidden */
  12232. _unpackFlipY(value: boolean): void;
  12233. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12234. /**
  12235. * Updates a dynamic vertex buffer.
  12236. * @param vertexBuffer the vertex buffer to update
  12237. * @param data the data used to update the vertex buffer
  12238. * @param byteOffset the byte offset of the data (optional)
  12239. * @param byteLength the byte length of the data (optional)
  12240. */
  12241. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12242. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12243. /** @hidden */
  12244. _bindTexture(channel: number, texture: InternalTexture): void;
  12245. /** @hidden */
  12246. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12247. releaseEffects(): void;
  12248. displayLoadingUI(): void;
  12249. hideLoadingUI(): void;
  12250. /** @hidden */
  12251. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12252. /** @hidden */
  12253. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12254. /** @hidden */
  12255. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12256. /** @hidden */
  12257. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12258. }
  12259. }
  12260. interface WebGLRenderingContext {
  12261. readonly RASTERIZER_DISCARD: number;
  12262. readonly DEPTH_COMPONENT24: number;
  12263. readonly TEXTURE_3D: number;
  12264. readonly TEXTURE_2D_ARRAY: number;
  12265. readonly TEXTURE_COMPARE_FUNC: number;
  12266. readonly TEXTURE_COMPARE_MODE: number;
  12267. readonly COMPARE_REF_TO_TEXTURE: number;
  12268. readonly TEXTURE_WRAP_R: number;
  12269. readonly HALF_FLOAT: number;
  12270. readonly RGB8: number;
  12271. readonly RED_INTEGER: number;
  12272. readonly RG_INTEGER: number;
  12273. readonly RGB_INTEGER: number;
  12274. readonly RGBA_INTEGER: number;
  12275. readonly R8_SNORM: number;
  12276. readonly RG8_SNORM: number;
  12277. readonly RGB8_SNORM: number;
  12278. readonly RGBA8_SNORM: number;
  12279. readonly R8I: number;
  12280. readonly RG8I: number;
  12281. readonly RGB8I: number;
  12282. readonly RGBA8I: number;
  12283. readonly R8UI: number;
  12284. readonly RG8UI: number;
  12285. readonly RGB8UI: number;
  12286. readonly RGBA8UI: number;
  12287. readonly R16I: number;
  12288. readonly RG16I: number;
  12289. readonly RGB16I: number;
  12290. readonly RGBA16I: number;
  12291. readonly R16UI: number;
  12292. readonly RG16UI: number;
  12293. readonly RGB16UI: number;
  12294. readonly RGBA16UI: number;
  12295. readonly R32I: number;
  12296. readonly RG32I: number;
  12297. readonly RGB32I: number;
  12298. readonly RGBA32I: number;
  12299. readonly R32UI: number;
  12300. readonly RG32UI: number;
  12301. readonly RGB32UI: number;
  12302. readonly RGBA32UI: number;
  12303. readonly RGB10_A2UI: number;
  12304. readonly R11F_G11F_B10F: number;
  12305. readonly RGB9_E5: number;
  12306. readonly RGB10_A2: number;
  12307. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12308. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12309. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12310. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12311. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12312. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12313. 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;
  12314. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12315. readonly TRANSFORM_FEEDBACK: number;
  12316. readonly INTERLEAVED_ATTRIBS: number;
  12317. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12318. createTransformFeedback(): WebGLTransformFeedback;
  12319. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12320. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12321. beginTransformFeedback(primitiveMode: number): void;
  12322. endTransformFeedback(): void;
  12323. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12324. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12325. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12326. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12327. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12328. }
  12329. interface ImageBitmap {
  12330. readonly width: number;
  12331. readonly height: number;
  12332. close(): void;
  12333. }
  12334. interface WebGLQuery extends WebGLObject {
  12335. }
  12336. declare var WebGLQuery: {
  12337. prototype: WebGLQuery;
  12338. new (): WebGLQuery;
  12339. };
  12340. interface WebGLSampler extends WebGLObject {
  12341. }
  12342. declare var WebGLSampler: {
  12343. prototype: WebGLSampler;
  12344. new (): WebGLSampler;
  12345. };
  12346. interface WebGLSync extends WebGLObject {
  12347. }
  12348. declare var WebGLSync: {
  12349. prototype: WebGLSync;
  12350. new (): WebGLSync;
  12351. };
  12352. interface WebGLTransformFeedback extends WebGLObject {
  12353. }
  12354. declare var WebGLTransformFeedback: {
  12355. prototype: WebGLTransformFeedback;
  12356. new (): WebGLTransformFeedback;
  12357. };
  12358. interface WebGLVertexArrayObject extends WebGLObject {
  12359. }
  12360. declare var WebGLVertexArrayObject: {
  12361. prototype: WebGLVertexArrayObject;
  12362. new (): WebGLVertexArrayObject;
  12363. };
  12364. declare module BABYLON {
  12365. /**
  12366. * Gather the list of clipboard event types as constants.
  12367. */
  12368. class ClipboardEventTypes {
  12369. /**
  12370. * The clipboard event is fired when a copy command is active (pressed).
  12371. */
  12372. static readonly COPY: number;
  12373. /**
  12374. * The clipboard event is fired when a cut command is active (pressed).
  12375. */
  12376. static readonly CUT: number;
  12377. /**
  12378. * The clipboard event is fired when a paste command is active (pressed).
  12379. */
  12380. static readonly PASTE: number;
  12381. }
  12382. /**
  12383. * This class is used to store clipboard related info for the onClipboardObservable event.
  12384. */
  12385. class ClipboardInfo {
  12386. /**
  12387. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12388. */
  12389. type: number;
  12390. /**
  12391. * Defines the related dom event
  12392. */
  12393. event: ClipboardEvent;
  12394. /**
  12395. *Creates an instance of ClipboardInfo.
  12396. * @param {number} type
  12397. * @param {ClipboardEvent} event
  12398. */
  12399. constructor(
  12400. /**
  12401. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12402. */
  12403. type: number,
  12404. /**
  12405. * Defines the related dom event
  12406. */
  12407. event: ClipboardEvent);
  12408. /**
  12409. * Get the clipboard event's type from the keycode.
  12410. * @param keyCode Defines the keyCode for the current keyboard event.
  12411. * @return {number}
  12412. */
  12413. static GetTypeFromCharacter(keyCode: number): number;
  12414. }
  12415. }
  12416. declare module BABYLON {
  12417. /**
  12418. * Gather the list of keyboard event types as constants.
  12419. */
  12420. class KeyboardEventTypes {
  12421. /**
  12422. * The keydown event is fired when a key becomes active (pressed).
  12423. */
  12424. static readonly KEYDOWN: number;
  12425. /**
  12426. * The keyup event is fired when a key has been released.
  12427. */
  12428. static readonly KEYUP: number;
  12429. }
  12430. /**
  12431. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12432. */
  12433. class KeyboardInfo {
  12434. /**
  12435. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12436. */
  12437. type: number;
  12438. /**
  12439. * Defines the related dom event
  12440. */
  12441. event: KeyboardEvent;
  12442. /**
  12443. * Instantiates a new keyboard info.
  12444. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12445. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12446. * @param event Defines the related dom event
  12447. */
  12448. constructor(
  12449. /**
  12450. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12451. */
  12452. type: number,
  12453. /**
  12454. * Defines the related dom event
  12455. */
  12456. event: KeyboardEvent);
  12457. }
  12458. /**
  12459. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12460. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12461. */
  12462. class KeyboardInfoPre extends KeyboardInfo {
  12463. /**
  12464. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12465. */
  12466. type: number;
  12467. /**
  12468. * Defines the related dom event
  12469. */
  12470. event: KeyboardEvent;
  12471. /**
  12472. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12473. */
  12474. skipOnPointerObservable: boolean;
  12475. /**
  12476. * Instantiates a new keyboard pre info.
  12477. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12478. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12479. * @param event Defines the related dom event
  12480. */
  12481. constructor(
  12482. /**
  12483. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12484. */
  12485. type: number,
  12486. /**
  12487. * Defines the related dom event
  12488. */
  12489. event: KeyboardEvent);
  12490. }
  12491. }
  12492. declare module BABYLON {
  12493. /**
  12494. * Gather the list of pointer event types as constants.
  12495. */
  12496. class PointerEventTypes {
  12497. /**
  12498. * 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.
  12499. */
  12500. static readonly POINTERDOWN: number;
  12501. /**
  12502. * The pointerup event is fired when a pointer is no longer active.
  12503. */
  12504. static readonly POINTERUP: number;
  12505. /**
  12506. * The pointermove event is fired when a pointer changes coordinates.
  12507. */
  12508. static readonly POINTERMOVE: number;
  12509. /**
  12510. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12511. */
  12512. static readonly POINTERWHEEL: number;
  12513. /**
  12514. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12515. */
  12516. static readonly POINTERPICK: number;
  12517. /**
  12518. * The pointertap event is fired when a the object has been touched and released without drag.
  12519. */
  12520. static readonly POINTERTAP: number;
  12521. /**
  12522. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12523. */
  12524. static readonly POINTERDOUBLETAP: number;
  12525. }
  12526. /**
  12527. * Base class of pointer info types.
  12528. */
  12529. class PointerInfoBase {
  12530. /**
  12531. * Defines the type of event (BABYLON.PointerEventTypes)
  12532. */
  12533. type: number;
  12534. /**
  12535. * Defines the related dom event
  12536. */
  12537. event: PointerEvent | MouseWheelEvent;
  12538. /**
  12539. * Instantiates the base class of pointers info.
  12540. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12541. * @param event Defines the related dom event
  12542. */
  12543. constructor(
  12544. /**
  12545. * Defines the type of event (BABYLON.PointerEventTypes)
  12546. */
  12547. type: number,
  12548. /**
  12549. * Defines the related dom event
  12550. */
  12551. event: PointerEvent | MouseWheelEvent);
  12552. }
  12553. /**
  12554. * This class is used to store pointer related info for the onPrePointerObservable event.
  12555. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12556. */
  12557. class PointerInfoPre extends PointerInfoBase {
  12558. /**
  12559. * Ray from a pointer if availible (eg. 6dof controller)
  12560. */
  12561. ray: Nullable<Ray>;
  12562. /**
  12563. * Defines the local position of the pointer on the canvas.
  12564. */
  12565. localPosition: Vector2;
  12566. /**
  12567. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12568. */
  12569. skipOnPointerObservable: boolean;
  12570. /**
  12571. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12572. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12573. * @param event Defines the related dom event
  12574. * @param localX Defines the local x coordinates of the pointer when the event occured
  12575. * @param localY Defines the local y coordinates of the pointer when the event occured
  12576. */
  12577. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12578. }
  12579. /**
  12580. * This type contains all the data related to a pointer event in Babylon.js.
  12581. * 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.
  12582. */
  12583. class PointerInfo extends PointerInfoBase {
  12584. /**
  12585. * Defines the picking info associated to the info (if any)\
  12586. */
  12587. pickInfo: Nullable<PickingInfo>;
  12588. /**
  12589. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12590. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12591. * @param event Defines the related dom event
  12592. * @param pickInfo Defines the picking info associated to the info (if any)\
  12593. */
  12594. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12595. /**
  12596. * Defines the picking info associated to the info (if any)\
  12597. */
  12598. pickInfo: Nullable<PickingInfo>);
  12599. }
  12600. }
  12601. declare module BABYLON {
  12602. /**
  12603. * Represents a gamepad control stick position
  12604. */
  12605. class StickValues {
  12606. /**
  12607. * The x component of the control stick
  12608. */
  12609. x: number;
  12610. /**
  12611. * The y component of the control stick
  12612. */
  12613. y: number;
  12614. /**
  12615. * Initializes the gamepad x and y control stick values
  12616. * @param x The x component of the gamepad control stick value
  12617. * @param y The y component of the gamepad control stick value
  12618. */
  12619. constructor(
  12620. /**
  12621. * The x component of the control stick
  12622. */
  12623. x: number,
  12624. /**
  12625. * The y component of the control stick
  12626. */
  12627. y: number);
  12628. }
  12629. /**
  12630. * An interface which manages callbacks for gamepad button changes
  12631. */
  12632. interface GamepadButtonChanges {
  12633. /**
  12634. * Called when a gamepad has been changed
  12635. */
  12636. changed: boolean;
  12637. /**
  12638. * Called when a gamepad press event has been triggered
  12639. */
  12640. pressChanged: boolean;
  12641. /**
  12642. * Called when a touch event has been triggered
  12643. */
  12644. touchChanged: boolean;
  12645. /**
  12646. * Called when a value has changed
  12647. */
  12648. valueChanged: boolean;
  12649. }
  12650. /**
  12651. * Represents a gamepad
  12652. */
  12653. class Gamepad {
  12654. /**
  12655. * The id of the gamepad
  12656. */
  12657. id: string;
  12658. /**
  12659. * The index of the gamepad
  12660. */
  12661. index: number;
  12662. /**
  12663. * The browser gamepad
  12664. */
  12665. browserGamepad: any;
  12666. /**
  12667. * Specifies what type of gamepad this represents
  12668. */
  12669. type: number;
  12670. private _leftStick;
  12671. private _rightStick;
  12672. /** @hidden */
  12673. _isConnected: boolean;
  12674. private _leftStickAxisX;
  12675. private _leftStickAxisY;
  12676. private _rightStickAxisX;
  12677. private _rightStickAxisY;
  12678. /**
  12679. * Triggered when the left control stick has been changed
  12680. */
  12681. private _onleftstickchanged;
  12682. /**
  12683. * Triggered when the right control stick has been changed
  12684. */
  12685. private _onrightstickchanged;
  12686. /**
  12687. * Represents a gamepad controller
  12688. */
  12689. static GAMEPAD: number;
  12690. /**
  12691. * Represents a generic controller
  12692. */
  12693. static GENERIC: number;
  12694. /**
  12695. * Represents an XBox controller
  12696. */
  12697. static XBOX: number;
  12698. /**
  12699. * Represents a pose-enabled controller
  12700. */
  12701. static POSE_ENABLED: number;
  12702. /**
  12703. * Specifies whether the left control stick should be Y-inverted
  12704. */
  12705. protected _invertLeftStickY: boolean;
  12706. /**
  12707. * Specifies if the gamepad has been connected
  12708. */
  12709. readonly isConnected: boolean;
  12710. /**
  12711. * Initializes the gamepad
  12712. * @param id The id of the gamepad
  12713. * @param index The index of the gamepad
  12714. * @param browserGamepad The browser gamepad
  12715. * @param leftStickX The x component of the left joystick
  12716. * @param leftStickY The y component of the left joystick
  12717. * @param rightStickX The x component of the right joystick
  12718. * @param rightStickY The y component of the right joystick
  12719. */
  12720. constructor(
  12721. /**
  12722. * The id of the gamepad
  12723. */
  12724. id: string,
  12725. /**
  12726. * The index of the gamepad
  12727. */
  12728. index: number,
  12729. /**
  12730. * The browser gamepad
  12731. */
  12732. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12733. /**
  12734. * Callback triggered when the left joystick has changed
  12735. * @param callback
  12736. */
  12737. onleftstickchanged(callback: (values: StickValues) => void): void;
  12738. /**
  12739. * Callback triggered when the right joystick has changed
  12740. * @param callback
  12741. */
  12742. onrightstickchanged(callback: (values: StickValues) => void): void;
  12743. /**
  12744. * Gets the left joystick
  12745. */
  12746. /**
  12747. * Sets the left joystick values
  12748. */
  12749. leftStick: StickValues;
  12750. /**
  12751. * Gets the right joystick
  12752. */
  12753. /**
  12754. * Sets the right joystick value
  12755. */
  12756. rightStick: StickValues;
  12757. /**
  12758. * Updates the gamepad joystick positions
  12759. */
  12760. update(): void;
  12761. /**
  12762. * Disposes the gamepad
  12763. */
  12764. dispose(): void;
  12765. }
  12766. /**
  12767. * Represents a generic gamepad
  12768. */
  12769. class GenericPad extends Gamepad {
  12770. private _buttons;
  12771. private _onbuttondown;
  12772. private _onbuttonup;
  12773. /**
  12774. * Observable triggered when a button has been pressed
  12775. */
  12776. onButtonDownObservable: Observable<number>;
  12777. /**
  12778. * Observable triggered when a button has been released
  12779. */
  12780. onButtonUpObservable: Observable<number>;
  12781. /**
  12782. * Callback triggered when a button has been pressed
  12783. * @param callback Called when a button has been pressed
  12784. */
  12785. onbuttondown(callback: (buttonPressed: number) => void): void;
  12786. /**
  12787. * Callback triggered when a button has been released
  12788. * @param callback Called when a button has been released
  12789. */
  12790. onbuttonup(callback: (buttonReleased: number) => void): void;
  12791. /**
  12792. * Initializes the generic gamepad
  12793. * @param id The id of the generic gamepad
  12794. * @param index The index of the generic gamepad
  12795. * @param browserGamepad The browser gamepad
  12796. */
  12797. constructor(id: string, index: number, browserGamepad: any);
  12798. private _setButtonValue;
  12799. /**
  12800. * Updates the generic gamepad
  12801. */
  12802. update(): void;
  12803. /**
  12804. * Disposes the generic gamepad
  12805. */
  12806. dispose(): void;
  12807. }
  12808. }
  12809. declare module BABYLON {
  12810. /**
  12811. * Manager for handling gamepads
  12812. */
  12813. class GamepadManager {
  12814. private _scene?;
  12815. private _babylonGamepads;
  12816. private _oneGamepadConnected;
  12817. /** @hidden */
  12818. _isMonitoring: boolean;
  12819. private _gamepadEventSupported;
  12820. private _gamepadSupport;
  12821. /**
  12822. * observable to be triggered when the gamepad controller has been connected
  12823. */
  12824. onGamepadConnectedObservable: Observable<Gamepad>;
  12825. /**
  12826. * observable to be triggered when the gamepad controller has been disconnected
  12827. */
  12828. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12829. private _onGamepadConnectedEvent;
  12830. private _onGamepadDisconnectedEvent;
  12831. /**
  12832. * Initializes the gamepad manager
  12833. * @param _scene BabylonJS scene
  12834. */
  12835. constructor(_scene?: Scene | undefined);
  12836. /**
  12837. * The gamepads in the game pad manager
  12838. */
  12839. readonly gamepads: Gamepad[];
  12840. /**
  12841. * Get the gamepad controllers based on type
  12842. * @param type The type of gamepad controller
  12843. * @returns Nullable gamepad
  12844. */
  12845. getGamepadByType(type?: number): Nullable<Gamepad>;
  12846. /**
  12847. * Disposes the gamepad manager
  12848. */
  12849. dispose(): void;
  12850. private _addNewGamepad;
  12851. private _startMonitoringGamepads;
  12852. private _stopMonitoringGamepads;
  12853. /** @hidden */
  12854. _checkGamepadsStatus(): void;
  12855. private _updateGamepadObjects;
  12856. }
  12857. }
  12858. declare module BABYLON {
  12859. interface Scene {
  12860. /** @hidden */
  12861. _gamepadManager: Nullable<GamepadManager>;
  12862. /**
  12863. * Gets the gamepad manager associated with the scene
  12864. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12865. */
  12866. gamepadManager: GamepadManager;
  12867. }
  12868. /**
  12869. * Interface representing a free camera inputs manager
  12870. */
  12871. interface FreeCameraInputsManager {
  12872. /**
  12873. * Adds gamepad input support to the FreeCameraInputsManager.
  12874. * @returns the FreeCameraInputsManager
  12875. */
  12876. addGamepad(): FreeCameraInputsManager;
  12877. }
  12878. /**
  12879. * Interface representing an arc rotate camera inputs manager
  12880. */
  12881. interface ArcRotateCameraInputsManager {
  12882. /**
  12883. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12884. * @returns the camera inputs manager
  12885. */
  12886. addGamepad(): ArcRotateCameraInputsManager;
  12887. }
  12888. /**
  12889. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12890. */
  12891. class GamepadSystemSceneComponent implements ISceneComponent {
  12892. /**
  12893. * The component name helpfull to identify the component in the list of scene components.
  12894. */
  12895. readonly name: string;
  12896. /**
  12897. * The scene the component belongs to.
  12898. */
  12899. scene: Scene;
  12900. /**
  12901. * Creates a new instance of the component for the given scene
  12902. * @param scene Defines the scene to register the component in
  12903. */
  12904. constructor(scene: Scene);
  12905. /**
  12906. * Registers the component in a given scene
  12907. */
  12908. register(): void;
  12909. /**
  12910. * Rebuilds the elements related to this component in case of
  12911. * context lost for instance.
  12912. */
  12913. rebuild(): void;
  12914. /**
  12915. * Disposes the component and the associated ressources
  12916. */
  12917. dispose(): void;
  12918. private _beforeCameraUpdate;
  12919. }
  12920. }
  12921. declare module BABYLON {
  12922. /**
  12923. * Defines supported buttons for XBox360 compatible gamepads
  12924. */
  12925. enum Xbox360Button {
  12926. /** A */
  12927. A = 0,
  12928. /** B */
  12929. B = 1,
  12930. /** X */
  12931. X = 2,
  12932. /** Y */
  12933. Y = 3,
  12934. /** Start */
  12935. Start = 4,
  12936. /** Back */
  12937. Back = 5,
  12938. /** Left button */
  12939. LB = 6,
  12940. /** Right button */
  12941. RB = 7,
  12942. /** Left stick */
  12943. LeftStick = 8,
  12944. /** Right stick */
  12945. RightStick = 9
  12946. }
  12947. /** Defines values for XBox360 DPad */
  12948. enum Xbox360Dpad {
  12949. /** Up */
  12950. Up = 0,
  12951. /** Down */
  12952. Down = 1,
  12953. /** Left */
  12954. Left = 2,
  12955. /** Right */
  12956. Right = 3
  12957. }
  12958. /**
  12959. * Defines a XBox360 gamepad
  12960. */
  12961. class Xbox360Pad extends Gamepad {
  12962. private _leftTrigger;
  12963. private _rightTrigger;
  12964. private _onlefttriggerchanged;
  12965. private _onrighttriggerchanged;
  12966. private _onbuttondown;
  12967. private _onbuttonup;
  12968. private _ondpaddown;
  12969. private _ondpadup;
  12970. /** Observable raised when a button is pressed */
  12971. onButtonDownObservable: Observable<Xbox360Button>;
  12972. /** Observable raised when a button is released */
  12973. onButtonUpObservable: Observable<Xbox360Button>;
  12974. /** Observable raised when a pad is pressed */
  12975. onPadDownObservable: Observable<Xbox360Dpad>;
  12976. /** Observable raised when a pad is released */
  12977. onPadUpObservable: Observable<Xbox360Dpad>;
  12978. private _buttonA;
  12979. private _buttonB;
  12980. private _buttonX;
  12981. private _buttonY;
  12982. private _buttonBack;
  12983. private _buttonStart;
  12984. private _buttonLB;
  12985. private _buttonRB;
  12986. private _buttonLeftStick;
  12987. private _buttonRightStick;
  12988. private _dPadUp;
  12989. private _dPadDown;
  12990. private _dPadLeft;
  12991. private _dPadRight;
  12992. private _isXboxOnePad;
  12993. /**
  12994. * Creates a new XBox360 gamepad object
  12995. * @param id defines the id of this gamepad
  12996. * @param index defines its index
  12997. * @param gamepad defines the internal HTML gamepad object
  12998. * @param xboxOne defines if it is a XBox One gamepad
  12999. */
  13000. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  13001. /**
  13002. * Defines the callback to call when left trigger is pressed
  13003. * @param callback defines the callback to use
  13004. */
  13005. onlefttriggerchanged(callback: (value: number) => void): void;
  13006. /**
  13007. * Defines the callback to call when right trigger is pressed
  13008. * @param callback defines the callback to use
  13009. */
  13010. onrighttriggerchanged(callback: (value: number) => void): void;
  13011. /**
  13012. * Gets the left trigger value
  13013. */
  13014. /**
  13015. * Sets the left trigger value
  13016. */
  13017. leftTrigger: number;
  13018. /**
  13019. * Gets the right trigger value
  13020. */
  13021. /**
  13022. * Sets the right trigger value
  13023. */
  13024. rightTrigger: number;
  13025. /**
  13026. * Defines the callback to call when a button is pressed
  13027. * @param callback defines the callback to use
  13028. */
  13029. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  13030. /**
  13031. * Defines the callback to call when a button is released
  13032. * @param callback defines the callback to use
  13033. */
  13034. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  13035. /**
  13036. * Defines the callback to call when a pad is pressed
  13037. * @param callback defines the callback to use
  13038. */
  13039. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  13040. /**
  13041. * Defines the callback to call when a pad is released
  13042. * @param callback defines the callback to use
  13043. */
  13044. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  13045. private _setButtonValue;
  13046. private _setDPadValue;
  13047. /**
  13048. * Gets the value of the `A` button
  13049. */
  13050. /**
  13051. * Sets the value of the `A` button
  13052. */
  13053. buttonA: number;
  13054. /**
  13055. * Gets the value of the `B` button
  13056. */
  13057. /**
  13058. * Sets the value of the `B` button
  13059. */
  13060. buttonB: number;
  13061. /**
  13062. * Gets the value of the `X` button
  13063. */
  13064. /**
  13065. * Sets the value of the `X` button
  13066. */
  13067. buttonX: number;
  13068. /**
  13069. * Gets the value of the `Y` button
  13070. */
  13071. /**
  13072. * Sets the value of the `Y` button
  13073. */
  13074. buttonY: number;
  13075. /**
  13076. * Gets the value of the `Start` button
  13077. */
  13078. /**
  13079. * Sets the value of the `Start` button
  13080. */
  13081. buttonStart: number;
  13082. /**
  13083. * Gets the value of the `Back` button
  13084. */
  13085. /**
  13086. * Sets the value of the `Back` button
  13087. */
  13088. buttonBack: number;
  13089. /**
  13090. * Gets the value of the `Left` button
  13091. */
  13092. /**
  13093. * Sets the value of the `Left` button
  13094. */
  13095. buttonLB: number;
  13096. /**
  13097. * Gets the value of the `Right` button
  13098. */
  13099. /**
  13100. * Sets the value of the `Right` button
  13101. */
  13102. buttonRB: number;
  13103. /**
  13104. * Gets the value of the Left joystick
  13105. */
  13106. /**
  13107. * Sets the value of the Left joystick
  13108. */
  13109. buttonLeftStick: number;
  13110. /**
  13111. * Gets the value of the Right joystick
  13112. */
  13113. /**
  13114. * Sets the value of the Right joystick
  13115. */
  13116. buttonRightStick: number;
  13117. /**
  13118. * Gets the value of D-pad up
  13119. */
  13120. /**
  13121. * Sets the value of D-pad up
  13122. */
  13123. dPadUp: number;
  13124. /**
  13125. * Gets the value of D-pad down
  13126. */
  13127. /**
  13128. * Sets the value of D-pad down
  13129. */
  13130. dPadDown: number;
  13131. /**
  13132. * Gets the value of D-pad left
  13133. */
  13134. /**
  13135. * Sets the value of D-pad left
  13136. */
  13137. dPadLeft: number;
  13138. /**
  13139. * Gets the value of D-pad right
  13140. */
  13141. /**
  13142. * Sets the value of D-pad right
  13143. */
  13144. dPadRight: number;
  13145. /**
  13146. * Force the gamepad to synchronize with device values
  13147. */
  13148. update(): void;
  13149. /**
  13150. * Disposes the gamepad
  13151. */
  13152. dispose(): void;
  13153. }
  13154. }
  13155. declare module BABYLON {
  13156. /**
  13157. * Represents the different options available during the creation of
  13158. * a Environment helper.
  13159. *
  13160. * This can control the default ground, skybox and image processing setup of your scene.
  13161. */
  13162. interface IEnvironmentHelperOptions {
  13163. /**
  13164. * Specifies wether or not to create a ground.
  13165. * True by default.
  13166. */
  13167. createGround: boolean;
  13168. /**
  13169. * Specifies the ground size.
  13170. * 15 by default.
  13171. */
  13172. groundSize: number;
  13173. /**
  13174. * The texture used on the ground for the main color.
  13175. * Comes from the BabylonJS CDN by default.
  13176. *
  13177. * Remarks: Can be either a texture or a url.
  13178. */
  13179. groundTexture: string | BaseTexture;
  13180. /**
  13181. * The color mixed in the ground texture by default.
  13182. * BabylonJS clearColor by default.
  13183. */
  13184. groundColor: Color3;
  13185. /**
  13186. * Specifies the ground opacity.
  13187. * 1 by default.
  13188. */
  13189. groundOpacity: number;
  13190. /**
  13191. * Enables the ground to receive shadows.
  13192. * True by default.
  13193. */
  13194. enableGroundShadow: boolean;
  13195. /**
  13196. * Helps preventing the shadow to be fully black on the ground.
  13197. * 0.5 by default.
  13198. */
  13199. groundShadowLevel: number;
  13200. /**
  13201. * Creates a mirror texture attach to the ground.
  13202. * false by default.
  13203. */
  13204. enableGroundMirror: boolean;
  13205. /**
  13206. * Specifies the ground mirror size ratio.
  13207. * 0.3 by default as the default kernel is 64.
  13208. */
  13209. groundMirrorSizeRatio: number;
  13210. /**
  13211. * Specifies the ground mirror blur kernel size.
  13212. * 64 by default.
  13213. */
  13214. groundMirrorBlurKernel: number;
  13215. /**
  13216. * Specifies the ground mirror visibility amount.
  13217. * 1 by default
  13218. */
  13219. groundMirrorAmount: number;
  13220. /**
  13221. * Specifies the ground mirror reflectance weight.
  13222. * This uses the standard weight of the background material to setup the fresnel effect
  13223. * of the mirror.
  13224. * 1 by default.
  13225. */
  13226. groundMirrorFresnelWeight: number;
  13227. /**
  13228. * Specifies the ground mirror Falloff distance.
  13229. * This can helps reducing the size of the reflection.
  13230. * 0 by Default.
  13231. */
  13232. groundMirrorFallOffDistance: number;
  13233. /**
  13234. * Specifies the ground mirror texture type.
  13235. * Unsigned Int by Default.
  13236. */
  13237. groundMirrorTextureType: number;
  13238. /**
  13239. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13240. * the shown objects.
  13241. */
  13242. groundYBias: number;
  13243. /**
  13244. * Specifies wether or not to create a skybox.
  13245. * True by default.
  13246. */
  13247. createSkybox: boolean;
  13248. /**
  13249. * Specifies the skybox size.
  13250. * 20 by default.
  13251. */
  13252. skyboxSize: number;
  13253. /**
  13254. * The texture used on the skybox for the main color.
  13255. * Comes from the BabylonJS CDN by default.
  13256. *
  13257. * Remarks: Can be either a texture or a url.
  13258. */
  13259. skyboxTexture: string | BaseTexture;
  13260. /**
  13261. * The color mixed in the skybox texture by default.
  13262. * BabylonJS clearColor by default.
  13263. */
  13264. skyboxColor: Color3;
  13265. /**
  13266. * The background rotation around the Y axis of the scene.
  13267. * This helps aligning the key lights of your scene with the background.
  13268. * 0 by default.
  13269. */
  13270. backgroundYRotation: number;
  13271. /**
  13272. * Compute automatically the size of the elements to best fit with the scene.
  13273. */
  13274. sizeAuto: boolean;
  13275. /**
  13276. * Default position of the rootMesh if autoSize is not true.
  13277. */
  13278. rootPosition: Vector3;
  13279. /**
  13280. * Sets up the image processing in the scene.
  13281. * true by default.
  13282. */
  13283. setupImageProcessing: boolean;
  13284. /**
  13285. * The texture used as your environment texture in the scene.
  13286. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13287. *
  13288. * Remarks: Can be either a texture or a url.
  13289. */
  13290. environmentTexture: string | BaseTexture;
  13291. /**
  13292. * The value of the exposure to apply to the scene.
  13293. * 0.6 by default if setupImageProcessing is true.
  13294. */
  13295. cameraExposure: number;
  13296. /**
  13297. * The value of the contrast to apply to the scene.
  13298. * 1.6 by default if setupImageProcessing is true.
  13299. */
  13300. cameraContrast: number;
  13301. /**
  13302. * Specifies wether or not tonemapping should be enabled in the scene.
  13303. * true by default if setupImageProcessing is true.
  13304. */
  13305. toneMappingEnabled: boolean;
  13306. }
  13307. /**
  13308. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13309. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13310. * It also helps with the default setup of your imageProcessing configuration.
  13311. */
  13312. class EnvironmentHelper {
  13313. /**
  13314. * Default ground texture URL.
  13315. */
  13316. private static _groundTextureCDNUrl;
  13317. /**
  13318. * Default skybox texture URL.
  13319. */
  13320. private static _skyboxTextureCDNUrl;
  13321. /**
  13322. * Default environment texture URL.
  13323. */
  13324. private static _environmentTextureCDNUrl;
  13325. /**
  13326. * Creates the default options for the helper.
  13327. */
  13328. private static _getDefaultOptions;
  13329. private _rootMesh;
  13330. /**
  13331. * Gets the root mesh created by the helper.
  13332. */
  13333. readonly rootMesh: Mesh;
  13334. private _skybox;
  13335. /**
  13336. * Gets the skybox created by the helper.
  13337. */
  13338. readonly skybox: Nullable<Mesh>;
  13339. private _skyboxTexture;
  13340. /**
  13341. * Gets the skybox texture created by the helper.
  13342. */
  13343. readonly skyboxTexture: Nullable<BaseTexture>;
  13344. private _skyboxMaterial;
  13345. /**
  13346. * Gets the skybox material created by the helper.
  13347. */
  13348. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13349. private _ground;
  13350. /**
  13351. * Gets the ground mesh created by the helper.
  13352. */
  13353. readonly ground: Nullable<Mesh>;
  13354. private _groundTexture;
  13355. /**
  13356. * Gets the ground texture created by the helper.
  13357. */
  13358. readonly groundTexture: Nullable<BaseTexture>;
  13359. private _groundMirror;
  13360. /**
  13361. * Gets the ground mirror created by the helper.
  13362. */
  13363. readonly groundMirror: Nullable<MirrorTexture>;
  13364. /**
  13365. * Gets the ground mirror render list to helps pushing the meshes
  13366. * you wish in the ground reflection.
  13367. */
  13368. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13369. private _groundMaterial;
  13370. /**
  13371. * Gets the ground material created by the helper.
  13372. */
  13373. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13374. /**
  13375. * Stores the creation options.
  13376. */
  13377. private readonly _scene;
  13378. private _options;
  13379. /**
  13380. * This observable will be notified with any error during the creation of the environment,
  13381. * mainly texture creation errors.
  13382. */
  13383. onErrorObservable: Observable<{
  13384. message?: string;
  13385. exception?: any;
  13386. }>;
  13387. /**
  13388. * constructor
  13389. * @param options
  13390. * @param scene The scene to add the material to
  13391. */
  13392. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13393. /**
  13394. * Updates the background according to the new options
  13395. * @param options
  13396. */
  13397. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13398. /**
  13399. * Sets the primary color of all the available elements.
  13400. * @param color the main color to affect to the ground and the background
  13401. */
  13402. setMainColor(color: Color3): void;
  13403. /**
  13404. * Setup the image processing according to the specified options.
  13405. */
  13406. private _setupImageProcessing;
  13407. /**
  13408. * Setup the environment texture according to the specified options.
  13409. */
  13410. private _setupEnvironmentTexture;
  13411. /**
  13412. * Setup the background according to the specified options.
  13413. */
  13414. private _setupBackground;
  13415. /**
  13416. * Get the scene sizes according to the setup.
  13417. */
  13418. private _getSceneSize;
  13419. /**
  13420. * Setup the ground according to the specified options.
  13421. */
  13422. private _setupGround;
  13423. /**
  13424. * Setup the ground material according to the specified options.
  13425. */
  13426. private _setupGroundMaterial;
  13427. /**
  13428. * Setup the ground diffuse texture according to the specified options.
  13429. */
  13430. private _setupGroundDiffuseTexture;
  13431. /**
  13432. * Setup the ground mirror texture according to the specified options.
  13433. */
  13434. private _setupGroundMirrorTexture;
  13435. /**
  13436. * Setup the ground to receive the mirror texture.
  13437. */
  13438. private _setupMirrorInGroundMaterial;
  13439. /**
  13440. * Setup the skybox according to the specified options.
  13441. */
  13442. private _setupSkybox;
  13443. /**
  13444. * Setup the skybox material according to the specified options.
  13445. */
  13446. private _setupSkyboxMaterial;
  13447. /**
  13448. * Setup the skybox reflection texture according to the specified options.
  13449. */
  13450. private _setupSkyboxReflectionTexture;
  13451. private _errorHandler;
  13452. /**
  13453. * Dispose all the elements created by the Helper.
  13454. */
  13455. dispose(): void;
  13456. }
  13457. }
  13458. declare module BABYLON {
  13459. /**
  13460. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13461. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13462. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13463. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13464. */
  13465. class PhotoDome extends TransformNode {
  13466. private _useDirectMapping;
  13467. /**
  13468. * The texture being displayed on the sphere
  13469. */
  13470. protected _photoTexture: Texture;
  13471. /**
  13472. * Gets or sets the texture being displayed on the sphere
  13473. */
  13474. photoTexture: Texture;
  13475. /**
  13476. * Observable raised when an error occured while loading the 360 image
  13477. */
  13478. onLoadErrorObservable: Observable<string>;
  13479. /**
  13480. * The skybox material
  13481. */
  13482. protected _material: BackgroundMaterial;
  13483. /**
  13484. * The surface used for the skybox
  13485. */
  13486. protected _mesh: Mesh;
  13487. /**
  13488. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13489. * Also see the options.resolution property.
  13490. */
  13491. fovMultiplier: number;
  13492. /**
  13493. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13494. * @param name Element's name, child elements will append suffixes for their own names.
  13495. * @param urlsOfPhoto defines the url of the photo to display
  13496. * @param options defines an object containing optional or exposed sub element properties
  13497. * @param onError defines a callback called when an error occured while loading the texture
  13498. */
  13499. constructor(name: string, urlOfPhoto: string, options: {
  13500. resolution?: number;
  13501. size?: number;
  13502. useDirectMapping?: boolean;
  13503. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13504. /**
  13505. * Releases resources associated with this node.
  13506. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13507. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13508. */
  13509. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13510. }
  13511. }
  13512. declare module BABYLON {
  13513. interface Scene {
  13514. /**
  13515. * Creates a default light for the scene.
  13516. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13517. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13518. */
  13519. createDefaultLight(replace?: boolean): void;
  13520. /**
  13521. * Creates a default camera for the scene.
  13522. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13523. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13524. * @param replace has default false, when true replaces the active camera in the scene
  13525. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13526. */
  13527. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13528. /**
  13529. * Creates a default camera and a default light.
  13530. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13531. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13532. * @param replace has the default false, when true replaces the active camera/light in the scene
  13533. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13534. */
  13535. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13536. /**
  13537. * Creates a new sky box
  13538. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13539. * @param environmentTexture defines the texture to use as environment texture
  13540. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13541. * @param scale defines the overall scale of the skybox
  13542. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13543. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13544. * @returns a new mesh holding the sky box
  13545. */
  13546. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13547. /**
  13548. * Creates a new environment
  13549. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13550. * @param options defines the options you can use to configure the environment
  13551. * @returns the new EnvironmentHelper
  13552. */
  13553. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13554. /**
  13555. * Creates a new VREXperienceHelper
  13556. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13557. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13558. * @returns a new VREXperienceHelper
  13559. */
  13560. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  13561. /**
  13562. * Creates a new XREXperienceHelper
  13563. * @see http://doc.babylonjs.com/how_to/webxr
  13564. * @returns a promise for a new XREXperienceHelper
  13565. */
  13566. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  13567. }
  13568. }
  13569. declare module BABYLON {
  13570. /**
  13571. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  13572. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  13573. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  13574. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13575. */
  13576. class VideoDome extends TransformNode {
  13577. private _useDirectMapping;
  13578. /**
  13579. * The video texture being displayed on the sphere
  13580. */
  13581. protected _videoTexture: VideoTexture;
  13582. /**
  13583. * Gets the video texture being displayed on the sphere
  13584. */
  13585. readonly videoTexture: VideoTexture;
  13586. /**
  13587. * The skybox material
  13588. */
  13589. protected _material: BackgroundMaterial;
  13590. /**
  13591. * The surface used for the skybox
  13592. */
  13593. protected _mesh: Mesh;
  13594. /**
  13595. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13596. * Also see the options.resolution property.
  13597. */
  13598. fovMultiplier: number;
  13599. /**
  13600. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  13601. * @param name Element's name, child elements will append suffixes for their own names.
  13602. * @param urlsOrVideo defines the url(s) or the video element to use
  13603. * @param options An object containing optional or exposed sub element properties
  13604. */
  13605. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  13606. resolution?: number;
  13607. clickToPlay?: boolean;
  13608. autoPlay?: boolean;
  13609. loop?: boolean;
  13610. size?: number;
  13611. poster?: string;
  13612. useDirectMapping?: boolean;
  13613. }, scene: Scene);
  13614. /**
  13615. * Releases resources associated with this node.
  13616. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13617. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13618. */
  13619. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13620. }
  13621. }
  13622. declare module BABYLON {
  13623. /**
  13624. * Single axis drag gizmo
  13625. */
  13626. class AxisDragGizmo extends Gizmo {
  13627. /**
  13628. * Drag behavior responsible for the gizmos dragging interactions
  13629. */
  13630. dragBehavior: PointerDragBehavior;
  13631. private _pointerObserver;
  13632. /**
  13633. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13634. */
  13635. snapDistance: number;
  13636. /**
  13637. * Event that fires each time the gizmo snaps to a new location.
  13638. * * snapDistance is the the change in distance
  13639. */
  13640. onSnapObservable: Observable<{
  13641. snapDistance: number;
  13642. }>;
  13643. /** @hidden */
  13644. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  13645. /** @hidden */
  13646. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  13647. /**
  13648. * Creates an AxisDragGizmo
  13649. * @param gizmoLayer The utility layer the gizmo will be added to
  13650. * @param dragAxis The axis which the gizmo will be able to drag on
  13651. * @param color The color of the gizmo
  13652. */
  13653. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13654. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13655. /**
  13656. * Disposes of the gizmo
  13657. */
  13658. dispose(): void;
  13659. }
  13660. }
  13661. declare module BABYLON {
  13662. /**
  13663. * Single axis scale gizmo
  13664. */
  13665. class AxisScaleGizmo extends Gizmo {
  13666. private _coloredMaterial;
  13667. /**
  13668. * Drag behavior responsible for the gizmos dragging interactions
  13669. */
  13670. dragBehavior: PointerDragBehavior;
  13671. private _pointerObserver;
  13672. /**
  13673. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13674. */
  13675. snapDistance: number;
  13676. /**
  13677. * Event that fires each time the gizmo snaps to a new location.
  13678. * * snapDistance is the the change in distance
  13679. */
  13680. onSnapObservable: Observable<{
  13681. snapDistance: number;
  13682. }>;
  13683. /**
  13684. * If the scaling operation should be done on all axis (default: false)
  13685. */
  13686. uniformScaling: boolean;
  13687. /**
  13688. * Creates an AxisScaleGizmo
  13689. * @param gizmoLayer The utility layer the gizmo will be added to
  13690. * @param dragAxis The axis which the gizmo will be able to scale on
  13691. * @param color The color of the gizmo
  13692. */
  13693. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13694. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13695. /**
  13696. * Disposes of the gizmo
  13697. */
  13698. dispose(): void;
  13699. /**
  13700. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13701. * @param mesh The mesh to replace the default mesh of the gizmo
  13702. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  13703. */
  13704. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  13705. }
  13706. }
  13707. declare module BABYLON {
  13708. /**
  13709. * Bounding box gizmo
  13710. */
  13711. class BoundingBoxGizmo extends Gizmo {
  13712. private _lineBoundingBox;
  13713. private _rotateSpheresParent;
  13714. private _scaleBoxesParent;
  13715. private _boundingDimensions;
  13716. private _renderObserver;
  13717. private _pointerObserver;
  13718. private _scaleDragSpeed;
  13719. private _tmpQuaternion;
  13720. private _tmpVector;
  13721. private _tmpRotationMatrix;
  13722. /**
  13723. * 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)
  13724. */
  13725. ignoreChildren: boolean;
  13726. /**
  13727. * 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)
  13728. */
  13729. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  13730. /**
  13731. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  13732. */
  13733. rotationSphereSize: number;
  13734. /**
  13735. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  13736. */
  13737. scaleBoxSize: number;
  13738. /**
  13739. * 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)
  13740. */
  13741. fixedDragMeshScreenSize: boolean;
  13742. /**
  13743. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13744. */
  13745. fixedDragMeshScreenSizeDistanceFactor: number;
  13746. /**
  13747. * Fired when a rotation sphere or scale box is dragged
  13748. */
  13749. onDragStartObservable: Observable<{}>;
  13750. /**
  13751. * Fired when a scale box is dragged
  13752. */
  13753. onScaleBoxDragObservable: Observable<{}>;
  13754. /**
  13755. * Fired when a scale box drag is ended
  13756. */
  13757. onScaleBoxDragEndObservable: Observable<{}>;
  13758. /**
  13759. * Fired when a rotation sphere is dragged
  13760. */
  13761. onRotationSphereDragObservable: Observable<{}>;
  13762. /**
  13763. * Fired when a rotation sphere drag is ended
  13764. */
  13765. onRotationSphereDragEndObservable: Observable<{}>;
  13766. /**
  13767. * 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)
  13768. */
  13769. scalePivot: Nullable<Vector3>;
  13770. private _anchorMesh;
  13771. private _existingMeshScale;
  13772. private _dragMesh;
  13773. private pointerDragBehavior;
  13774. private static _PivotCached;
  13775. private static _OldPivotPoint;
  13776. private static _PivotTranslation;
  13777. private static _PivotTmpVector;
  13778. /** @hidden */
  13779. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13780. /** @hidden */
  13781. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13782. /**
  13783. * Creates an BoundingBoxGizmo
  13784. * @param gizmoLayer The utility layer the gizmo will be added to
  13785. * @param color The color of the gizmo
  13786. */
  13787. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13788. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13789. private _selectNode;
  13790. /**
  13791. * Updates the bounding box information for the Gizmo
  13792. */
  13793. updateBoundingBox(): void;
  13794. private _updateRotationSpheres;
  13795. private _updateScaleBoxes;
  13796. /**
  13797. * Enables rotation on the specified axis and disables rotation on the others
  13798. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13799. */
  13800. setEnabledRotationAxis(axis: string): void;
  13801. private _updateDummy;
  13802. /**
  13803. * Enables a pointer drag behavior on the bounding box of the gizmo
  13804. */
  13805. enableDragBehavior(): void;
  13806. /**
  13807. * Disposes of the gizmo
  13808. */
  13809. dispose(): void;
  13810. /**
  13811. * 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)
  13812. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13813. * @returns the bounding box mesh with the passed in mesh as a child
  13814. */
  13815. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13816. /**
  13817. * CustomMeshes are not supported by this gizmo
  13818. * @param mesh The mesh to replace the default mesh of the gizmo
  13819. */
  13820. setCustomMesh(mesh: Mesh): void;
  13821. }
  13822. }
  13823. declare module BABYLON {
  13824. /**
  13825. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13826. */
  13827. class Gizmo implements IDisposable {
  13828. /** The utility layer the gizmo will be added to */
  13829. gizmoLayer: UtilityLayerRenderer;
  13830. /**
  13831. * The root mesh of the gizmo
  13832. */
  13833. protected _rootMesh: Mesh;
  13834. private _attachedMesh;
  13835. /**
  13836. * Ratio for the scale of the gizmo (Default: 1)
  13837. */
  13838. scaleRatio: number;
  13839. private _tmpMatrix;
  13840. /**
  13841. * If a custom mesh has been set (Default: false)
  13842. */
  13843. protected _customMeshSet: boolean;
  13844. /**
  13845. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13846. * * When set, interactions will be enabled
  13847. */
  13848. attachedMesh: Nullable<AbstractMesh>;
  13849. /**
  13850. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13851. * @param mesh The mesh to replace the default mesh of the gizmo
  13852. */
  13853. setCustomMesh(mesh: Mesh): void;
  13854. /**
  13855. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13856. */
  13857. updateGizmoRotationToMatchAttachedMesh: boolean;
  13858. /**
  13859. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13860. */
  13861. updateGizmoPositionToMatchAttachedMesh: boolean;
  13862. /**
  13863. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13864. */
  13865. protected _updateScale: boolean;
  13866. protected _interactionsEnabled: boolean;
  13867. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13868. private _beforeRenderObserver;
  13869. /**
  13870. * Creates a gizmo
  13871. * @param gizmoLayer The utility layer the gizmo will be added to
  13872. */
  13873. constructor(
  13874. /** The utility layer the gizmo will be added to */
  13875. gizmoLayer?: UtilityLayerRenderer);
  13876. private _tempVector;
  13877. /**
  13878. * @hidden
  13879. * Updates the gizmo to match the attached mesh's position/rotation
  13880. */
  13881. protected _update(): void;
  13882. /**
  13883. * Disposes of the gizmo
  13884. */
  13885. dispose(): void;
  13886. }
  13887. }
  13888. declare module BABYLON {
  13889. /**
  13890. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13891. */
  13892. class GizmoManager implements IDisposable {
  13893. private scene;
  13894. /**
  13895. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13896. */
  13897. gizmos: {
  13898. positionGizmo: Nullable<PositionGizmo>;
  13899. rotationGizmo: Nullable<RotationGizmo>;
  13900. scaleGizmo: Nullable<ScaleGizmo>;
  13901. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13902. };
  13903. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  13904. clearGizmoOnEmptyPointerEvent: boolean;
  13905. /** Fires an event when the manager is attached to a mesh */
  13906. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  13907. private _gizmosEnabled;
  13908. private _pointerObserver;
  13909. private _attachedMesh;
  13910. private _boundingBoxColor;
  13911. private _defaultUtilityLayer;
  13912. private _defaultKeepDepthUtilityLayer;
  13913. /**
  13914. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13915. */
  13916. boundingBoxDragBehavior: SixDofDragBehavior;
  13917. /**
  13918. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13919. */
  13920. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13921. /**
  13922. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13923. */
  13924. usePointerToAttachGizmos: boolean;
  13925. /**
  13926. * Instatiates a gizmo manager
  13927. * @param scene the scene to overlay the gizmos on top of
  13928. */
  13929. constructor(scene: Scene);
  13930. /**
  13931. * Attaches a set of gizmos to the specified mesh
  13932. * @param mesh The mesh the gizmo's should be attached to
  13933. */
  13934. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13935. /**
  13936. * If the position gizmo is enabled
  13937. */
  13938. positionGizmoEnabled: boolean;
  13939. /**
  13940. * If the rotation gizmo is enabled
  13941. */
  13942. rotationGizmoEnabled: boolean;
  13943. /**
  13944. * If the scale gizmo is enabled
  13945. */
  13946. scaleGizmoEnabled: boolean;
  13947. /**
  13948. * If the boundingBox gizmo is enabled
  13949. */
  13950. boundingBoxGizmoEnabled: boolean;
  13951. /**
  13952. * Disposes of the gizmo manager
  13953. */
  13954. dispose(): void;
  13955. }
  13956. }
  13957. declare module BABYLON {
  13958. /**
  13959. * Single plane rotation gizmo
  13960. */
  13961. class PlaneRotationGizmo extends Gizmo {
  13962. /**
  13963. * Drag behavior responsible for the gizmos dragging interactions
  13964. */
  13965. dragBehavior: PointerDragBehavior;
  13966. private _pointerObserver;
  13967. /**
  13968. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13969. */
  13970. snapDistance: number;
  13971. /**
  13972. * Event that fires each time the gizmo snaps to a new location.
  13973. * * snapDistance is the the change in distance
  13974. */
  13975. onSnapObservable: Observable<{
  13976. snapDistance: number;
  13977. }>;
  13978. /**
  13979. * Creates a PlaneRotationGizmo
  13980. * @param gizmoLayer The utility layer the gizmo will be added to
  13981. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13982. * @param color The color of the gizmo
  13983. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13984. */
  13985. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13986. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13987. /**
  13988. * Disposes of the gizmo
  13989. */
  13990. dispose(): void;
  13991. }
  13992. }
  13993. declare module BABYLON {
  13994. /**
  13995. * Gizmo that enables dragging a mesh along 3 axis
  13996. */
  13997. class PositionGizmo extends Gizmo {
  13998. /**
  13999. * Internal gizmo used for interactions on the x axis
  14000. */
  14001. xGizmo: AxisDragGizmo;
  14002. /**
  14003. * Internal gizmo used for interactions on the y axis
  14004. */
  14005. yGizmo: AxisDragGizmo;
  14006. /**
  14007. * Internal gizmo used for interactions on the z axis
  14008. */
  14009. zGizmo: AxisDragGizmo;
  14010. /** Fires an event when any of it's sub gizmos are dragged */
  14011. onDragStartObservable: Observable<{}>;
  14012. /** Fires an event when any of it's sub gizmos are released from dragging */
  14013. onDragEndObservable: Observable<{}>;
  14014. attachedMesh: Nullable<AbstractMesh>;
  14015. /**
  14016. * Creates a PositionGizmo
  14017. * @param gizmoLayer The utility layer the gizmo will be added to
  14018. */
  14019. constructor(gizmoLayer?: UtilityLayerRenderer);
  14020. updateGizmoRotationToMatchAttachedMesh: boolean;
  14021. /**
  14022. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  14023. */
  14024. snapDistance: number;
  14025. /**
  14026. * Ratio for the scale of the gizmo (Default: 1)
  14027. */
  14028. scaleRatio: number;
  14029. /**
  14030. * Disposes of the gizmo
  14031. */
  14032. dispose(): void;
  14033. /**
  14034. * CustomMeshes are not supported by this gizmo
  14035. * @param mesh The mesh to replace the default mesh of the gizmo
  14036. */
  14037. setCustomMesh(mesh: Mesh): void;
  14038. }
  14039. }
  14040. declare module BABYLON {
  14041. /**
  14042. * Gizmo that enables rotating a mesh along 3 axis
  14043. */
  14044. class RotationGizmo extends Gizmo {
  14045. /**
  14046. * Internal gizmo used for interactions on the x axis
  14047. */
  14048. xGizmo: PlaneRotationGizmo;
  14049. /**
  14050. * Internal gizmo used for interactions on the y axis
  14051. */
  14052. yGizmo: PlaneRotationGizmo;
  14053. /**
  14054. * Internal gizmo used for interactions on the z axis
  14055. */
  14056. zGizmo: PlaneRotationGizmo;
  14057. /** Fires an event when any of it's sub gizmos are dragged */
  14058. onDragStartObservable: Observable<{}>;
  14059. /** Fires an event when any of it's sub gizmos are released from dragging */
  14060. onDragEndObservable: Observable<{}>;
  14061. attachedMesh: Nullable<AbstractMesh>;
  14062. /**
  14063. * Creates a RotationGizmo
  14064. * @param gizmoLayer The utility layer the gizmo will be added to
  14065. * @param tessellation Amount of tessellation to be used when creating rotation circles
  14066. */
  14067. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  14068. updateGizmoRotationToMatchAttachedMesh: boolean;
  14069. /**
  14070. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  14071. */
  14072. snapDistance: number;
  14073. /**
  14074. * Ratio for the scale of the gizmo (Default: 1)
  14075. */
  14076. scaleRatio: number;
  14077. /**
  14078. * Disposes of the gizmo
  14079. */
  14080. dispose(): void;
  14081. /**
  14082. * CustomMeshes are not supported by this gizmo
  14083. * @param mesh The mesh to replace the default mesh of the gizmo
  14084. */
  14085. setCustomMesh(mesh: Mesh): void;
  14086. }
  14087. }
  14088. declare module BABYLON {
  14089. /**
  14090. * Gizmo that enables scaling a mesh along 3 axis
  14091. */
  14092. class ScaleGizmo extends Gizmo {
  14093. /**
  14094. * Internal gizmo used for interactions on the x axis
  14095. */
  14096. xGizmo: AxisScaleGizmo;
  14097. /**
  14098. * Internal gizmo used for interactions on the y axis
  14099. */
  14100. yGizmo: AxisScaleGizmo;
  14101. /**
  14102. * Internal gizmo used for interactions on the z axis
  14103. */
  14104. zGizmo: AxisScaleGizmo;
  14105. /**
  14106. * Internal gizmo used to scale all axis equally
  14107. */
  14108. uniformScaleGizmo: AxisScaleGizmo;
  14109. /** Fires an event when any of it's sub gizmos are dragged */
  14110. onDragStartObservable: Observable<{}>;
  14111. /** Fires an event when any of it's sub gizmos are released from dragging */
  14112. onDragEndObservable: Observable<{}>;
  14113. attachedMesh: Nullable<AbstractMesh>;
  14114. /**
  14115. * Creates a ScaleGizmo
  14116. * @param gizmoLayer The utility layer the gizmo will be added to
  14117. */
  14118. constructor(gizmoLayer?: UtilityLayerRenderer);
  14119. updateGizmoRotationToMatchAttachedMesh: boolean;
  14120. /**
  14121. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  14122. */
  14123. snapDistance: number;
  14124. /**
  14125. * Ratio for the scale of the gizmo (Default: 1)
  14126. */
  14127. scaleRatio: number;
  14128. /**
  14129. * Disposes of the gizmo
  14130. */
  14131. dispose(): void;
  14132. }
  14133. }
  14134. declare module BABYLON {
  14135. /**
  14136. * This class can be used to get instrumentation data from a Babylon engine
  14137. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14138. */
  14139. class EngineInstrumentation implements IDisposable {
  14140. /**
  14141. * Define the instrumented engine.
  14142. */
  14143. engine: Engine;
  14144. private _captureGPUFrameTime;
  14145. private _gpuFrameTimeToken;
  14146. private _gpuFrameTime;
  14147. private _captureShaderCompilationTime;
  14148. private _shaderCompilationTime;
  14149. private _onBeginFrameObserver;
  14150. private _onEndFrameObserver;
  14151. private _onBeforeShaderCompilationObserver;
  14152. private _onAfterShaderCompilationObserver;
  14153. /**
  14154. * Gets the perf counter used for GPU frame time
  14155. */
  14156. readonly gpuFrameTimeCounter: PerfCounter;
  14157. /**
  14158. * Gets the GPU frame time capture status
  14159. */
  14160. /**
  14161. * Enable or disable the GPU frame time capture
  14162. */
  14163. captureGPUFrameTime: boolean;
  14164. /**
  14165. * Gets the perf counter used for shader compilation time
  14166. */
  14167. readonly shaderCompilationTimeCounter: PerfCounter;
  14168. /**
  14169. * Gets the shader compilation time capture status
  14170. */
  14171. /**
  14172. * Enable or disable the shader compilation time capture
  14173. */
  14174. captureShaderCompilationTime: boolean;
  14175. /**
  14176. * Instantiates a new engine instrumentation.
  14177. * This class can be used to get instrumentation data from a Babylon engine
  14178. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14179. * @param engine Defines the engine to instrument
  14180. */
  14181. constructor(
  14182. /**
  14183. * Define the instrumented engine.
  14184. */
  14185. engine: Engine);
  14186. /**
  14187. * Dispose and release associated resources.
  14188. */
  14189. dispose(): void;
  14190. }
  14191. }
  14192. declare module BABYLON {
  14193. /**
  14194. * This class can be used to get instrumentation data from a Babylon engine
  14195. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14196. */
  14197. class SceneInstrumentation implements IDisposable {
  14198. /**
  14199. * Defines the scene to instrument
  14200. */
  14201. scene: Scene;
  14202. private _captureActiveMeshesEvaluationTime;
  14203. private _activeMeshesEvaluationTime;
  14204. private _captureRenderTargetsRenderTime;
  14205. private _renderTargetsRenderTime;
  14206. private _captureFrameTime;
  14207. private _frameTime;
  14208. private _captureRenderTime;
  14209. private _renderTime;
  14210. private _captureInterFrameTime;
  14211. private _interFrameTime;
  14212. private _captureParticlesRenderTime;
  14213. private _particlesRenderTime;
  14214. private _captureSpritesRenderTime;
  14215. private _spritesRenderTime;
  14216. private _capturePhysicsTime;
  14217. private _physicsTime;
  14218. private _captureAnimationsTime;
  14219. private _animationsTime;
  14220. private _captureCameraRenderTime;
  14221. private _cameraRenderTime;
  14222. private _onBeforeActiveMeshesEvaluationObserver;
  14223. private _onAfterActiveMeshesEvaluationObserver;
  14224. private _onBeforeRenderTargetsRenderObserver;
  14225. private _onAfterRenderTargetsRenderObserver;
  14226. private _onAfterRenderObserver;
  14227. private _onBeforeDrawPhaseObserver;
  14228. private _onAfterDrawPhaseObserver;
  14229. private _onBeforeAnimationsObserver;
  14230. private _onBeforeParticlesRenderingObserver;
  14231. private _onAfterParticlesRenderingObserver;
  14232. private _onBeforeSpritesRenderingObserver;
  14233. private _onAfterSpritesRenderingObserver;
  14234. private _onBeforePhysicsObserver;
  14235. private _onAfterPhysicsObserver;
  14236. private _onAfterAnimationsObserver;
  14237. private _onBeforeCameraRenderObserver;
  14238. private _onAfterCameraRenderObserver;
  14239. /**
  14240. * Gets the perf counter used for active meshes evaluation time
  14241. */
  14242. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  14243. /**
  14244. * Gets the active meshes evaluation time capture status
  14245. */
  14246. /**
  14247. * Enable or disable the active meshes evaluation time capture
  14248. */
  14249. captureActiveMeshesEvaluationTime: boolean;
  14250. /**
  14251. * Gets the perf counter used for render targets render time
  14252. */
  14253. readonly renderTargetsRenderTimeCounter: PerfCounter;
  14254. /**
  14255. * Gets the render targets render time capture status
  14256. */
  14257. /**
  14258. * Enable or disable the render targets render time capture
  14259. */
  14260. captureRenderTargetsRenderTime: boolean;
  14261. /**
  14262. * Gets the perf counter used for particles render time
  14263. */
  14264. readonly particlesRenderTimeCounter: PerfCounter;
  14265. /**
  14266. * Gets the particles render time capture status
  14267. */
  14268. /**
  14269. * Enable or disable the particles render time capture
  14270. */
  14271. captureParticlesRenderTime: boolean;
  14272. /**
  14273. * Gets the perf counter used for sprites render time
  14274. */
  14275. readonly spritesRenderTimeCounter: PerfCounter;
  14276. /**
  14277. * Gets the sprites render time capture status
  14278. */
  14279. /**
  14280. * Enable or disable the sprites render time capture
  14281. */
  14282. captureSpritesRenderTime: boolean;
  14283. /**
  14284. * Gets the perf counter used for physics time
  14285. */
  14286. readonly physicsTimeCounter: PerfCounter;
  14287. /**
  14288. * Gets the physics time capture status
  14289. */
  14290. /**
  14291. * Enable or disable the physics time capture
  14292. */
  14293. capturePhysicsTime: boolean;
  14294. /**
  14295. * Gets the perf counter used for animations time
  14296. */
  14297. readonly animationsTimeCounter: PerfCounter;
  14298. /**
  14299. * Gets the animations time capture status
  14300. */
  14301. /**
  14302. * Enable or disable the animations time capture
  14303. */
  14304. captureAnimationsTime: boolean;
  14305. /**
  14306. * Gets the perf counter used for frame time capture
  14307. */
  14308. readonly frameTimeCounter: PerfCounter;
  14309. /**
  14310. * Gets the frame time capture status
  14311. */
  14312. /**
  14313. * Enable or disable the frame time capture
  14314. */
  14315. captureFrameTime: boolean;
  14316. /**
  14317. * Gets the perf counter used for inter-frames time capture
  14318. */
  14319. readonly interFrameTimeCounter: PerfCounter;
  14320. /**
  14321. * Gets the inter-frames time capture status
  14322. */
  14323. /**
  14324. * Enable or disable the inter-frames time capture
  14325. */
  14326. captureInterFrameTime: boolean;
  14327. /**
  14328. * Gets the perf counter used for render time capture
  14329. */
  14330. readonly renderTimeCounter: PerfCounter;
  14331. /**
  14332. * Gets the render time capture status
  14333. */
  14334. /**
  14335. * Enable or disable the render time capture
  14336. */
  14337. captureRenderTime: boolean;
  14338. /**
  14339. * Gets the perf counter used for camera render time capture
  14340. */
  14341. readonly cameraRenderTimeCounter: PerfCounter;
  14342. /**
  14343. * Gets the camera render time capture status
  14344. */
  14345. /**
  14346. * Enable or disable the camera render time capture
  14347. */
  14348. captureCameraRenderTime: boolean;
  14349. /**
  14350. * Gets the perf counter used for draw calls
  14351. */
  14352. readonly drawCallsCounter: PerfCounter;
  14353. /**
  14354. * Gets the perf counter used for texture collisions
  14355. */
  14356. readonly textureCollisionsCounter: PerfCounter;
  14357. /**
  14358. * Instantiates a new scene instrumentation.
  14359. * This class can be used to get instrumentation data from a Babylon engine
  14360. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14361. * @param scene Defines the scene to instrument
  14362. */
  14363. constructor(
  14364. /**
  14365. * Defines the scene to instrument
  14366. */
  14367. scene: Scene);
  14368. /**
  14369. * Dispose and release associated resources.
  14370. */
  14371. dispose(): void;
  14372. }
  14373. }
  14374. declare module BABYLON {
  14375. /**
  14376. * @hidden
  14377. **/
  14378. class _TimeToken {
  14379. _startTimeQuery: Nullable<WebGLQuery>;
  14380. _endTimeQuery: Nullable<WebGLQuery>;
  14381. _timeElapsedQuery: Nullable<WebGLQuery>;
  14382. _timeElapsedQueryEnded: boolean;
  14383. }
  14384. }
  14385. declare module BABYLON {
  14386. /**
  14387. * Effect layer options. This helps customizing the behaviour
  14388. * of the effect layer.
  14389. */
  14390. interface IEffectLayerOptions {
  14391. /**
  14392. * Multiplication factor apply to the canvas size to compute the render target size
  14393. * used to generated the objects (the smaller the faster).
  14394. */
  14395. mainTextureRatio: number;
  14396. /**
  14397. * Enforces a fixed size texture to ensure effect stability across devices.
  14398. */
  14399. mainTextureFixedSize?: number;
  14400. /**
  14401. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14402. */
  14403. alphaBlendingMode: number;
  14404. /**
  14405. * The camera attached to the layer.
  14406. */
  14407. camera: Nullable<Camera>;
  14408. /**
  14409. * The rendering group to draw the layer in.
  14410. */
  14411. renderingGroupId: number;
  14412. }
  14413. /**
  14414. * The effect layer Helps adding post process effect blended with the main pass.
  14415. *
  14416. * This can be for instance use to generate glow or higlight effects on the scene.
  14417. *
  14418. * The effect layer class can not be used directly and is intented to inherited from to be
  14419. * customized per effects.
  14420. */
  14421. abstract class EffectLayer {
  14422. private _vertexBuffers;
  14423. private _indexBuffer;
  14424. private _cachedDefines;
  14425. private _effectLayerMapGenerationEffect;
  14426. private _effectLayerOptions;
  14427. private _mergeEffect;
  14428. protected _scene: Scene;
  14429. protected _engine: Engine;
  14430. protected _maxSize: number;
  14431. protected _mainTextureDesiredSize: ISize;
  14432. protected _mainTexture: RenderTargetTexture;
  14433. protected _shouldRender: boolean;
  14434. protected _postProcesses: PostProcess[];
  14435. protected _textures: BaseTexture[];
  14436. protected _emissiveTextureAndColor: {
  14437. texture: Nullable<BaseTexture>;
  14438. color: Color4;
  14439. };
  14440. /**
  14441. * The name of the layer
  14442. */
  14443. name: string;
  14444. /**
  14445. * The clear color of the texture used to generate the glow map.
  14446. */
  14447. neutralColor: Color4;
  14448. /**
  14449. * Specifies wether the highlight layer is enabled or not.
  14450. */
  14451. isEnabled: boolean;
  14452. /**
  14453. * Gets the camera attached to the layer.
  14454. */
  14455. readonly camera: Nullable<Camera>;
  14456. /**
  14457. * Gets the rendering group id the layer should render in.
  14458. */
  14459. readonly renderingGroupId: number;
  14460. /**
  14461. * An event triggered when the effect layer has been disposed.
  14462. */
  14463. onDisposeObservable: Observable<EffectLayer>;
  14464. /**
  14465. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14466. */
  14467. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14468. /**
  14469. * An event triggered when the generated texture is being merged in the scene.
  14470. */
  14471. onBeforeComposeObservable: Observable<EffectLayer>;
  14472. /**
  14473. * An event triggered when the generated texture has been merged in the scene.
  14474. */
  14475. onAfterComposeObservable: Observable<EffectLayer>;
  14476. /**
  14477. * An event triggered when the efffect layer changes its size.
  14478. */
  14479. onSizeChangedObservable: Observable<EffectLayer>;
  14480. /**
  14481. * Instantiates a new effect Layer and references it in the scene.
  14482. * @param name The name of the layer
  14483. * @param scene The scene to use the layer in
  14484. */
  14485. constructor(
  14486. /** The Friendly of the effect in the scene */
  14487. name: string, scene: Scene);
  14488. /**
  14489. * Get the effect name of the layer.
  14490. * @return The effect name
  14491. */
  14492. abstract getEffectName(): string;
  14493. /**
  14494. * Checks for the readiness of the element composing the layer.
  14495. * @param subMesh the mesh to check for
  14496. * @param useInstances specify wether or not to use instances to render the mesh
  14497. * @return true if ready otherwise, false
  14498. */
  14499. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14500. /**
  14501. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14502. * @returns true if the effect requires stencil during the main canvas render pass.
  14503. */
  14504. abstract needStencil(): boolean;
  14505. /**
  14506. * Create the merge effect. This is the shader use to blit the information back
  14507. * to the main canvas at the end of the scene rendering.
  14508. * @returns The effect containing the shader used to merge the effect on the main canvas
  14509. */
  14510. protected abstract _createMergeEffect(): Effect;
  14511. /**
  14512. * Creates the render target textures and post processes used in the effect layer.
  14513. */
  14514. protected abstract _createTextureAndPostProcesses(): void;
  14515. /**
  14516. * Implementation specific of rendering the generating effect on the main canvas.
  14517. * @param effect The effect used to render through
  14518. */
  14519. protected abstract _internalRender(effect: Effect): void;
  14520. /**
  14521. * Sets the required values for both the emissive texture and and the main color.
  14522. */
  14523. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14524. /**
  14525. * Free any resources and references associated to a mesh.
  14526. * Internal use
  14527. * @param mesh The mesh to free.
  14528. */
  14529. abstract _disposeMesh(mesh: Mesh): void;
  14530. /**
  14531. * Serializes this layer (Glow or Highlight for example)
  14532. * @returns a serialized layer object
  14533. */
  14534. abstract serialize?(): any;
  14535. /**
  14536. * Initializes the effect layer with the required options.
  14537. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14538. */
  14539. protected _init(options: Partial<IEffectLayerOptions>): void;
  14540. /**
  14541. * Generates the index buffer of the full screen quad blending to the main canvas.
  14542. */
  14543. private _generateIndexBuffer;
  14544. /**
  14545. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14546. */
  14547. private _genrateVertexBuffer;
  14548. /**
  14549. * Sets the main texture desired size which is the closest power of two
  14550. * of the engine canvas size.
  14551. */
  14552. private _setMainTextureSize;
  14553. /**
  14554. * Creates the main texture for the effect layer.
  14555. */
  14556. protected _createMainTexture(): void;
  14557. /**
  14558. * Checks for the readiness of the element composing the layer.
  14559. * @param subMesh the mesh to check for
  14560. * @param useInstances specify wether or not to use instances to render the mesh
  14561. * @param emissiveTexture the associated emissive texture used to generate the glow
  14562. * @return true if ready otherwise, false
  14563. */
  14564. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14565. /**
  14566. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14567. */
  14568. render(): void;
  14569. /**
  14570. * Determine if a given mesh will be used in the current effect.
  14571. * @param mesh mesh to test
  14572. * @returns true if the mesh will be used
  14573. */
  14574. hasMesh(mesh: AbstractMesh): boolean;
  14575. /**
  14576. * Returns true if the layer contains information to display, otherwise false.
  14577. * @returns true if the glow layer should be rendered
  14578. */
  14579. shouldRender(): boolean;
  14580. /**
  14581. * Returns true if the mesh should render, otherwise false.
  14582. * @param mesh The mesh to render
  14583. * @returns true if it should render otherwise false
  14584. */
  14585. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14586. /**
  14587. * Returns true if the mesh should render, otherwise false.
  14588. * @param mesh The mesh to render
  14589. * @returns true if it should render otherwise false
  14590. */
  14591. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14592. /**
  14593. * Renders the submesh passed in parameter to the generation map.
  14594. */
  14595. protected _renderSubMesh(subMesh: SubMesh): void;
  14596. /**
  14597. * Rebuild the required buffers.
  14598. * @hidden Internal use only.
  14599. */
  14600. _rebuild(): void;
  14601. /**
  14602. * Dispose only the render target textures and post process.
  14603. */
  14604. private _disposeTextureAndPostProcesses;
  14605. /**
  14606. * Dispose the highlight layer and free resources.
  14607. */
  14608. dispose(): void;
  14609. /**
  14610. * Gets the class name of the effect layer
  14611. * @returns the string with the class name of the effect layer
  14612. */
  14613. getClassName(): string;
  14614. /**
  14615. * Creates an effect layer from parsed effect layer data
  14616. * @param parsedEffectLayer defines effect layer data
  14617. * @param scene defines the current scene
  14618. * @param rootUrl defines the root URL containing the effect layer information
  14619. * @returns a parsed effect Layer
  14620. */
  14621. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14622. }
  14623. }
  14624. declare module BABYLON {
  14625. interface AbstractScene {
  14626. /**
  14627. * The list of effect layers (highlights/glow) added to the scene
  14628. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14629. * @see http://doc.babylonjs.com/how_to/glow_layer
  14630. */
  14631. effectLayers: Array<EffectLayer>;
  14632. /**
  14633. * Removes the given effect layer from this scene.
  14634. * @param toRemove defines the effect layer to remove
  14635. * @returns the index of the removed effect layer
  14636. */
  14637. removeEffectLayer(toRemove: EffectLayer): number;
  14638. /**
  14639. * Adds the given effect layer to this scene
  14640. * @param newEffectLayer defines the effect layer to add
  14641. */
  14642. addEffectLayer(newEffectLayer: EffectLayer): void;
  14643. }
  14644. /**
  14645. * Defines the layer scene component responsible to manage any effect layers
  14646. * in a given scene.
  14647. */
  14648. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14649. /**
  14650. * The component name helpfull to identify the component in the list of scene components.
  14651. */
  14652. readonly name: string;
  14653. /**
  14654. * The scene the component belongs to.
  14655. */
  14656. scene: Scene;
  14657. private _engine;
  14658. private _renderEffects;
  14659. private _needStencil;
  14660. private _previousStencilState;
  14661. /**
  14662. * Creates a new instance of the component for the given scene
  14663. * @param scene Defines the scene to register the component in
  14664. */
  14665. constructor(scene: Scene);
  14666. /**
  14667. * Registers the component in a given scene
  14668. */
  14669. register(): void;
  14670. /**
  14671. * Rebuilds the elements related to this component in case of
  14672. * context lost for instance.
  14673. */
  14674. rebuild(): void;
  14675. /**
  14676. * Serializes the component data to the specified json object
  14677. * @param serializationObject The object to serialize to
  14678. */
  14679. serialize(serializationObject: any): void;
  14680. /**
  14681. * Adds all the element from the container to the scene
  14682. * @param container the container holding the elements
  14683. */
  14684. addFromContainer(container: AbstractScene): void;
  14685. /**
  14686. * Removes all the elements in the container from the scene
  14687. * @param container contains the elements to remove
  14688. */
  14689. removeFromContainer(container: AbstractScene): void;
  14690. /**
  14691. * Disposes the component and the associated ressources.
  14692. */
  14693. dispose(): void;
  14694. private _isReadyForMesh;
  14695. private _renderMainTexture;
  14696. private _setStencil;
  14697. private _setStencilBack;
  14698. private _draw;
  14699. private _drawCamera;
  14700. private _drawRenderingGroup;
  14701. }
  14702. }
  14703. declare module BABYLON {
  14704. interface AbstractScene {
  14705. /**
  14706. * Return a the first highlight layer of the scene with a given name.
  14707. * @param name The name of the highlight layer to look for.
  14708. * @return The highlight layer if found otherwise null.
  14709. */
  14710. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14711. }
  14712. /**
  14713. * Glow layer options. This helps customizing the behaviour
  14714. * of the glow layer.
  14715. */
  14716. interface IGlowLayerOptions {
  14717. /**
  14718. * Multiplication factor apply to the canvas size to compute the render target size
  14719. * used to generated the glowing objects (the smaller the faster).
  14720. */
  14721. mainTextureRatio: number;
  14722. /**
  14723. * Enforces a fixed size texture to ensure resize independant blur.
  14724. */
  14725. mainTextureFixedSize?: number;
  14726. /**
  14727. * How big is the kernel of the blur texture.
  14728. */
  14729. blurKernelSize: number;
  14730. /**
  14731. * The camera attached to the layer.
  14732. */
  14733. camera: Nullable<Camera>;
  14734. /**
  14735. * Enable MSAA by chosing the number of samples.
  14736. */
  14737. mainTextureSamples?: number;
  14738. /**
  14739. * The rendering group to draw the layer in.
  14740. */
  14741. renderingGroupId: number;
  14742. }
  14743. /**
  14744. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14745. *
  14746. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14747. * glowy meshes to your scene.
  14748. *
  14749. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14750. */
  14751. class GlowLayer extends EffectLayer {
  14752. /**
  14753. * Effect Name of the layer.
  14754. */
  14755. static readonly EffectName: string;
  14756. /**
  14757. * The default blur kernel size used for the glow.
  14758. */
  14759. static DefaultBlurKernelSize: number;
  14760. /**
  14761. * The default texture size ratio used for the glow.
  14762. */
  14763. static DefaultTextureRatio: number;
  14764. /**
  14765. * Sets the kernel size of the blur.
  14766. */
  14767. /**
  14768. * Gets the kernel size of the blur.
  14769. */
  14770. blurKernelSize: number;
  14771. /**
  14772. * Sets the glow intensity.
  14773. */
  14774. /**
  14775. * Gets the glow intensity.
  14776. */
  14777. intensity: number;
  14778. private _options;
  14779. private _intensity;
  14780. private _horizontalBlurPostprocess1;
  14781. private _verticalBlurPostprocess1;
  14782. private _horizontalBlurPostprocess2;
  14783. private _verticalBlurPostprocess2;
  14784. private _blurTexture1;
  14785. private _blurTexture2;
  14786. private _postProcesses1;
  14787. private _postProcesses2;
  14788. private _includedOnlyMeshes;
  14789. private _excludedMeshes;
  14790. /**
  14791. * Callback used to let the user override the color selection on a per mesh basis
  14792. */
  14793. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14794. /**
  14795. * Callback used to let the user override the texture selection on a per mesh basis
  14796. */
  14797. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14798. /**
  14799. * Instantiates a new glow Layer and references it to the scene.
  14800. * @param name The name of the layer
  14801. * @param scene The scene to use the layer in
  14802. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14803. */
  14804. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14805. /**
  14806. * Get the effect name of the layer.
  14807. * @return The effect name
  14808. */
  14809. getEffectName(): string;
  14810. /**
  14811. * Create the merge effect. This is the shader use to blit the information back
  14812. * to the main canvas at the end of the scene rendering.
  14813. */
  14814. protected _createMergeEffect(): Effect;
  14815. /**
  14816. * Creates the render target textures and post processes used in the glow layer.
  14817. */
  14818. protected _createTextureAndPostProcesses(): void;
  14819. /**
  14820. * Checks for the readiness of the element composing the layer.
  14821. * @param subMesh the mesh to check for
  14822. * @param useInstances specify wether or not to use instances to render the mesh
  14823. * @param emissiveTexture the associated emissive texture used to generate the glow
  14824. * @return true if ready otherwise, false
  14825. */
  14826. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14827. /**
  14828. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14829. */
  14830. needStencil(): boolean;
  14831. /**
  14832. * Implementation specific of rendering the generating effect on the main canvas.
  14833. * @param effect The effect used to render through
  14834. */
  14835. protected _internalRender(effect: Effect): void;
  14836. /**
  14837. * Sets the required values for both the emissive texture and and the main color.
  14838. */
  14839. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14840. /**
  14841. * Returns true if the mesh should render, otherwise false.
  14842. * @param mesh The mesh to render
  14843. * @returns true if it should render otherwise false
  14844. */
  14845. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14846. /**
  14847. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14848. * @param mesh The mesh to exclude from the glow layer
  14849. */
  14850. addExcludedMesh(mesh: Mesh): void;
  14851. /**
  14852. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14853. * @param mesh The mesh to remove
  14854. */
  14855. removeExcludedMesh(mesh: Mesh): void;
  14856. /**
  14857. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14858. * @param mesh The mesh to include in the glow layer
  14859. */
  14860. addIncludedOnlyMesh(mesh: Mesh): void;
  14861. /**
  14862. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14863. * @param mesh The mesh to remove
  14864. */
  14865. removeIncludedOnlyMesh(mesh: Mesh): void;
  14866. /**
  14867. * Determine if a given mesh will be used in the glow layer
  14868. * @param mesh The mesh to test
  14869. * @returns true if the mesh will be highlighted by the current glow layer
  14870. */
  14871. hasMesh(mesh: AbstractMesh): boolean;
  14872. /**
  14873. * Free any resources and references associated to a mesh.
  14874. * Internal use
  14875. * @param mesh The mesh to free.
  14876. * @hidden
  14877. */
  14878. _disposeMesh(mesh: Mesh): void;
  14879. /**
  14880. * Gets the class name of the effect layer
  14881. * @returns the string with the class name of the effect layer
  14882. */
  14883. getClassName(): string;
  14884. /**
  14885. * Serializes this glow layer
  14886. * @returns a serialized glow layer object
  14887. */
  14888. serialize(): any;
  14889. /**
  14890. * Creates a Glow Layer from parsed glow layer data
  14891. * @param parsedGlowLayer defines glow layer data
  14892. * @param scene defines the current scene
  14893. * @param rootUrl defines the root URL containing the glow layer information
  14894. * @returns a parsed Glow Layer
  14895. */
  14896. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14897. }
  14898. }
  14899. declare module BABYLON {
  14900. interface AbstractScene {
  14901. /**
  14902. * Return a the first highlight layer of the scene with a given name.
  14903. * @param name The name of the highlight layer to look for.
  14904. * @return The highlight layer if found otherwise null.
  14905. */
  14906. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14907. }
  14908. /**
  14909. * Highlight layer options. This helps customizing the behaviour
  14910. * of the highlight layer.
  14911. */
  14912. interface IHighlightLayerOptions {
  14913. /**
  14914. * Multiplication factor apply to the canvas size to compute the render target size
  14915. * used to generated the glowing objects (the smaller the faster).
  14916. */
  14917. mainTextureRatio: number;
  14918. /**
  14919. * Enforces a fixed size texture to ensure resize independant blur.
  14920. */
  14921. mainTextureFixedSize?: number;
  14922. /**
  14923. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14924. * of the picture to blur (the smaller the faster).
  14925. */
  14926. blurTextureSizeRatio: number;
  14927. /**
  14928. * How big in texel of the blur texture is the vertical blur.
  14929. */
  14930. blurVerticalSize: number;
  14931. /**
  14932. * How big in texel of the blur texture is the horizontal blur.
  14933. */
  14934. blurHorizontalSize: number;
  14935. /**
  14936. * Alpha blending mode used to apply the blur. Default is combine.
  14937. */
  14938. alphaBlendingMode: number;
  14939. /**
  14940. * The camera attached to the layer.
  14941. */
  14942. camera: Nullable<Camera>;
  14943. /**
  14944. * Should we display highlight as a solid stroke?
  14945. */
  14946. isStroke?: boolean;
  14947. /**
  14948. * The rendering group to draw the layer in.
  14949. */
  14950. renderingGroupId: number;
  14951. }
  14952. /**
  14953. * The highlight layer Helps adding a glow effect around a mesh.
  14954. *
  14955. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14956. * glowy meshes to your scene.
  14957. *
  14958. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14959. */
  14960. class HighlightLayer extends EffectLayer {
  14961. name: string;
  14962. /**
  14963. * Effect Name of the highlight layer.
  14964. */
  14965. static readonly EffectName: string;
  14966. /**
  14967. * The neutral color used during the preparation of the glow effect.
  14968. * This is black by default as the blend operation is a blend operation.
  14969. */
  14970. static NeutralColor: Color4;
  14971. /**
  14972. * Stencil value used for glowing meshes.
  14973. */
  14974. static GlowingMeshStencilReference: number;
  14975. /**
  14976. * Stencil value used for the other meshes in the scene.
  14977. */
  14978. static NormalMeshStencilReference: number;
  14979. /**
  14980. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14981. */
  14982. innerGlow: boolean;
  14983. /**
  14984. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14985. */
  14986. outerGlow: boolean;
  14987. /**
  14988. * Specifies the horizontal size of the blur.
  14989. */
  14990. /**
  14991. * Gets the horizontal size of the blur.
  14992. */
  14993. blurHorizontalSize: number;
  14994. /**
  14995. * Specifies the vertical size of the blur.
  14996. */
  14997. /**
  14998. * Gets the vertical size of the blur.
  14999. */
  15000. blurVerticalSize: number;
  15001. /**
  15002. * An event triggered when the highlight layer is being blurred.
  15003. */
  15004. onBeforeBlurObservable: Observable<HighlightLayer>;
  15005. /**
  15006. * An event triggered when the highlight layer has been blurred.
  15007. */
  15008. onAfterBlurObservable: Observable<HighlightLayer>;
  15009. private _instanceGlowingMeshStencilReference;
  15010. private _options;
  15011. private _downSamplePostprocess;
  15012. private _horizontalBlurPostprocess;
  15013. private _verticalBlurPostprocess;
  15014. private _blurTexture;
  15015. private _meshes;
  15016. private _excludedMeshes;
  15017. /**
  15018. * Instantiates a new highlight Layer and references it to the scene..
  15019. * @param name The name of the layer
  15020. * @param scene The scene to use the layer in
  15021. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  15022. */
  15023. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  15024. /**
  15025. * Get the effect name of the layer.
  15026. * @return The effect name
  15027. */
  15028. getEffectName(): string;
  15029. /**
  15030. * Create the merge effect. This is the shader use to blit the information back
  15031. * to the main canvas at the end of the scene rendering.
  15032. */
  15033. protected _createMergeEffect(): Effect;
  15034. /**
  15035. * Creates the render target textures and post processes used in the highlight layer.
  15036. */
  15037. protected _createTextureAndPostProcesses(): void;
  15038. /**
  15039. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  15040. */
  15041. needStencil(): boolean;
  15042. /**
  15043. * Checks for the readiness of the element composing the layer.
  15044. * @param subMesh the mesh to check for
  15045. * @param useInstances specify wether or not to use instances to render the mesh
  15046. * @param emissiveTexture the associated emissive texture used to generate the glow
  15047. * @return true if ready otherwise, false
  15048. */
  15049. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  15050. /**
  15051. * Implementation specific of rendering the generating effect on the main canvas.
  15052. * @param effect The effect used to render through
  15053. */
  15054. protected _internalRender(effect: Effect): void;
  15055. /**
  15056. * Returns true if the layer contains information to display, otherwise false.
  15057. */
  15058. shouldRender(): boolean;
  15059. /**
  15060. * Returns true if the mesh should render, otherwise false.
  15061. * @param mesh The mesh to render
  15062. * @returns true if it should render otherwise false
  15063. */
  15064. protected _shouldRenderMesh(mesh: Mesh): boolean;
  15065. /**
  15066. * Sets the required values for both the emissive texture and and the main color.
  15067. */
  15068. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  15069. /**
  15070. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  15071. * @param mesh The mesh to exclude from the highlight layer
  15072. */
  15073. addExcludedMesh(mesh: Mesh): void;
  15074. /**
  15075. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  15076. * @param mesh The mesh to highlight
  15077. */
  15078. removeExcludedMesh(mesh: Mesh): void;
  15079. /**
  15080. * Determine if a given mesh will be highlighted by the current HighlightLayer
  15081. * @param mesh mesh to test
  15082. * @returns true if the mesh will be highlighted by the current HighlightLayer
  15083. */
  15084. hasMesh(mesh: AbstractMesh): boolean;
  15085. /**
  15086. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  15087. * @param mesh The mesh to highlight
  15088. * @param color The color of the highlight
  15089. * @param glowEmissiveOnly Extract the glow from the emissive texture
  15090. */
  15091. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  15092. /**
  15093. * Remove a mesh from the highlight layer in order to make it stop glowing.
  15094. * @param mesh The mesh to highlight
  15095. */
  15096. removeMesh(mesh: Mesh): void;
  15097. /**
  15098. * Force the stencil to the normal expected value for none glowing parts
  15099. */
  15100. private _defaultStencilReference;
  15101. /**
  15102. * Free any resources and references associated to a mesh.
  15103. * Internal use
  15104. * @param mesh The mesh to free.
  15105. * @hidden
  15106. */
  15107. _disposeMesh(mesh: Mesh): void;
  15108. /**
  15109. * Dispose the highlight layer and free resources.
  15110. */
  15111. dispose(): void;
  15112. /**
  15113. * Gets the class name of the effect layer
  15114. * @returns the string with the class name of the effect layer
  15115. */
  15116. getClassName(): string;
  15117. /**
  15118. * Serializes this Highlight layer
  15119. * @returns a serialized Highlight layer object
  15120. */
  15121. serialize(): any;
  15122. /**
  15123. * Creates a Highlight layer from parsed Highlight layer data
  15124. * @param parsedHightlightLayer defines the Highlight layer data
  15125. * @param scene defines the current scene
  15126. * @param rootUrl defines the root URL containing the Highlight layer information
  15127. * @returns a parsed Highlight layer
  15128. */
  15129. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  15130. }
  15131. }
  15132. declare module BABYLON {
  15133. /**
  15134. * This represents a full screen 2d layer.
  15135. * This can be useful to display a picture in the background of your scene for instance.
  15136. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15137. */
  15138. class Layer {
  15139. /**
  15140. * Define the name of the layer.
  15141. */
  15142. name: string;
  15143. /**
  15144. * Define the texture the layer should display.
  15145. */
  15146. texture: Nullable<Texture>;
  15147. /**
  15148. * Is the layer in background or foreground.
  15149. */
  15150. isBackground: boolean;
  15151. /**
  15152. * Define the color of the layer (instead of texture).
  15153. */
  15154. color: Color4;
  15155. /**
  15156. * Define the scale of the layer in order to zoom in out of the texture.
  15157. */
  15158. scale: Vector2;
  15159. /**
  15160. * Define an offset for the layer in order to shift the texture.
  15161. */
  15162. offset: Vector2;
  15163. /**
  15164. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  15165. */
  15166. alphaBlendingMode: number;
  15167. /**
  15168. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  15169. * Alpha test will not mix with the background color in case of transparency.
  15170. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  15171. */
  15172. alphaTest: boolean;
  15173. /**
  15174. * Define a mask to restrict the layer to only some of the scene cameras.
  15175. */
  15176. layerMask: number;
  15177. /**
  15178. * Define the list of render target the layer is visible into.
  15179. */
  15180. renderTargetTextures: RenderTargetTexture[];
  15181. /**
  15182. * Define if the layer is only used in renderTarget or if it also
  15183. * renders in the main frame buffer of the canvas.
  15184. */
  15185. renderOnlyInRenderTargetTextures: boolean;
  15186. private _scene;
  15187. private _vertexBuffers;
  15188. private _indexBuffer;
  15189. private _effect;
  15190. private _alphaTestEffect;
  15191. /**
  15192. * An event triggered when the layer is disposed.
  15193. */
  15194. onDisposeObservable: Observable<Layer>;
  15195. private _onDisposeObserver;
  15196. /**
  15197. * Back compatibility with callback before the onDisposeObservable existed.
  15198. * The set callback will be triggered when the layer has been disposed.
  15199. */
  15200. onDispose: () => void;
  15201. /**
  15202. * An event triggered before rendering the scene
  15203. */
  15204. onBeforeRenderObservable: Observable<Layer>;
  15205. private _onBeforeRenderObserver;
  15206. /**
  15207. * Back compatibility with callback before the onBeforeRenderObservable existed.
  15208. * The set callback will be triggered just before rendering the layer.
  15209. */
  15210. onBeforeRender: () => void;
  15211. /**
  15212. * An event triggered after rendering the scene
  15213. */
  15214. onAfterRenderObservable: Observable<Layer>;
  15215. private _onAfterRenderObserver;
  15216. /**
  15217. * Back compatibility with callback before the onAfterRenderObservable existed.
  15218. * The set callback will be triggered just after rendering the layer.
  15219. */
  15220. onAfterRender: () => void;
  15221. /**
  15222. * Instantiates a new layer.
  15223. * This represents a full screen 2d layer.
  15224. * This can be useful to display a picture in the background of your scene for instance.
  15225. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15226. * @param name Define the name of the layer in the scene
  15227. * @param imgUrl Define the url of the texture to display in the layer
  15228. * @param scene Define the scene the layer belongs to
  15229. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  15230. * @param color Defines a color for the layer
  15231. */
  15232. constructor(
  15233. /**
  15234. * Define the name of the layer.
  15235. */
  15236. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  15237. private _createIndexBuffer;
  15238. /** @hidden */
  15239. _rebuild(): void;
  15240. /**
  15241. * Renders the layer in the scene.
  15242. */
  15243. render(): void;
  15244. /**
  15245. * Disposes and releases the associated ressources.
  15246. */
  15247. dispose(): void;
  15248. }
  15249. }
  15250. declare module BABYLON {
  15251. interface AbstractScene {
  15252. /**
  15253. * The list of layers (background and foreground) of the scene
  15254. */
  15255. layers: Array<Layer>;
  15256. }
  15257. /**
  15258. * Defines the layer scene component responsible to manage any layers
  15259. * in a given scene.
  15260. */
  15261. class LayerSceneComponent implements ISceneComponent {
  15262. /**
  15263. * The component name helpfull to identify the component in the list of scene components.
  15264. */
  15265. readonly name: string;
  15266. /**
  15267. * The scene the component belongs to.
  15268. */
  15269. scene: Scene;
  15270. private _engine;
  15271. /**
  15272. * Creates a new instance of the component for the given scene
  15273. * @param scene Defines the scene to register the component in
  15274. */
  15275. constructor(scene: Scene);
  15276. /**
  15277. * Registers the component in a given scene
  15278. */
  15279. register(): void;
  15280. /**
  15281. * Rebuilds the elements related to this component in case of
  15282. * context lost for instance.
  15283. */
  15284. rebuild(): void;
  15285. /**
  15286. * Disposes the component and the associated ressources.
  15287. */
  15288. dispose(): void;
  15289. private _draw;
  15290. private _drawCameraPredicate;
  15291. private _drawCameraBackground;
  15292. private _drawCameraForeground;
  15293. private _drawRenderTargetPredicate;
  15294. private _drawRenderTargetBackground;
  15295. private _drawRenderTargetForeground;
  15296. }
  15297. }
  15298. declare module BABYLON {
  15299. /**
  15300. * A directional light is defined by a direction (what a surprise!).
  15301. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15302. * 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.
  15303. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15304. */
  15305. class DirectionalLight extends ShadowLight {
  15306. private _shadowFrustumSize;
  15307. /**
  15308. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15309. */
  15310. /**
  15311. * Specifies a fix frustum size for the shadow generation.
  15312. */
  15313. shadowFrustumSize: number;
  15314. private _shadowOrthoScale;
  15315. /**
  15316. * Gets the shadow projection scale against the optimal computed one.
  15317. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15318. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15319. */
  15320. /**
  15321. * Sets the shadow projection scale against the optimal computed one.
  15322. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15323. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15324. */
  15325. shadowOrthoScale: number;
  15326. /**
  15327. * Automatically compute the projection matrix to best fit (including all the casters)
  15328. * on each frame.
  15329. */
  15330. autoUpdateExtends: boolean;
  15331. private _orthoLeft;
  15332. private _orthoRight;
  15333. private _orthoTop;
  15334. private _orthoBottom;
  15335. /**
  15336. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15337. * The directional light is emitted from everywhere in the given direction.
  15338. * It can cast shadows.
  15339. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15340. * @param name The friendly name of the light
  15341. * @param direction The direction of the light
  15342. * @param scene The scene the light belongs to
  15343. */
  15344. constructor(name: string, direction: Vector3, scene: Scene);
  15345. /**
  15346. * Returns the string "DirectionalLight".
  15347. * @return The class name
  15348. */
  15349. getClassName(): string;
  15350. /**
  15351. * Returns the integer 1.
  15352. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15353. */
  15354. getTypeID(): number;
  15355. /**
  15356. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15357. * Returns the DirectionalLight Shadow projection matrix.
  15358. */
  15359. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15360. /**
  15361. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15362. * Returns the DirectionalLight Shadow projection matrix.
  15363. */
  15364. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15365. /**
  15366. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15367. * Returns the DirectionalLight Shadow projection matrix.
  15368. */
  15369. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15370. protected _buildUniformLayout(): void;
  15371. /**
  15372. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15373. * @param effect The effect to update
  15374. * @param lightIndex The index of the light in the effect to update
  15375. * @returns The directional light
  15376. */
  15377. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15378. /**
  15379. * Gets the minZ used for shadow according to both the scene and the light.
  15380. *
  15381. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15382. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15383. * @param activeCamera The camera we are returning the min for
  15384. * @returns the depth min z
  15385. */
  15386. getDepthMinZ(activeCamera: Camera): number;
  15387. /**
  15388. * Gets the maxZ used for shadow according to both the scene and the light.
  15389. *
  15390. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15391. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15392. * @param activeCamera The camera we are returning the max for
  15393. * @returns the depth max z
  15394. */
  15395. getDepthMaxZ(activeCamera: Camera): number;
  15396. /**
  15397. * Prepares the list of defines specific to the light type.
  15398. * @param defines the list of defines
  15399. * @param lightIndex defines the index of the light for the effect
  15400. */
  15401. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15402. }
  15403. }
  15404. declare module BABYLON {
  15405. /**
  15406. * The HemisphericLight simulates the ambient environment light,
  15407. * so the passed direction is the light reflection direction, not the incoming direction.
  15408. */
  15409. class HemisphericLight extends Light {
  15410. /**
  15411. * The groundColor is the light in the opposite direction to the one specified during creation.
  15412. * 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.
  15413. */
  15414. groundColor: Color3;
  15415. /**
  15416. * The light reflection direction, not the incoming direction.
  15417. */
  15418. direction: Vector3;
  15419. /**
  15420. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15421. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15422. * The HemisphericLight can't cast shadows.
  15423. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15424. * @param name The friendly name of the light
  15425. * @param direction The direction of the light reflection
  15426. * @param scene The scene the light belongs to
  15427. */
  15428. constructor(name: string, direction: Vector3, scene: Scene);
  15429. protected _buildUniformLayout(): void;
  15430. /**
  15431. * Returns the string "HemisphericLight".
  15432. * @return The class name
  15433. */
  15434. getClassName(): string;
  15435. /**
  15436. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15437. * Returns the updated direction.
  15438. * @param target The target the direction should point to
  15439. * @return The computed direction
  15440. */
  15441. setDirectionToTarget(target: Vector3): Vector3;
  15442. /**
  15443. * Returns the shadow generator associated to the light.
  15444. * @returns Always null for hemispheric lights because it does not support shadows.
  15445. */
  15446. getShadowGenerator(): Nullable<IShadowGenerator>;
  15447. /**
  15448. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15449. * @param effect The effect to update
  15450. * @param lightIndex The index of the light in the effect to update
  15451. * @returns The hemispheric light
  15452. */
  15453. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15454. /**
  15455. * Computes the world matrix of the node
  15456. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15457. * @param useWasUpdatedFlag defines a reserved property
  15458. * @returns the world matrix
  15459. */
  15460. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15461. /**
  15462. * Returns the integer 3.
  15463. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15464. */
  15465. getTypeID(): number;
  15466. /**
  15467. * Prepares the list of defines specific to the light type.
  15468. * @param defines the list of defines
  15469. * @param lightIndex defines the index of the light for the effect
  15470. */
  15471. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15472. }
  15473. }
  15474. declare module BABYLON {
  15475. /**
  15476. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15477. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15478. * 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.
  15479. */
  15480. abstract class Light extends Node {
  15481. /**
  15482. * Falloff Default: light is falling off following the material specification:
  15483. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15484. */
  15485. static readonly FALLOFF_DEFAULT: number;
  15486. /**
  15487. * Falloff Physical: light is falling off following the inverse squared distance law.
  15488. */
  15489. static readonly FALLOFF_PHYSICAL: number;
  15490. /**
  15491. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15492. * to enhance interoperability with other engines.
  15493. */
  15494. static readonly FALLOFF_GLTF: number;
  15495. /**
  15496. * Falloff Standard: light is falling off like in the standard material
  15497. * to enhance interoperability with other materials.
  15498. */
  15499. static readonly FALLOFF_STANDARD: number;
  15500. /**
  15501. * If every light affecting the material is in this lightmapMode,
  15502. * material.lightmapTexture adds or multiplies
  15503. * (depends on material.useLightmapAsShadowmap)
  15504. * after every other light calculations.
  15505. */
  15506. static readonly LIGHTMAP_DEFAULT: number;
  15507. /**
  15508. * material.lightmapTexture as only diffuse lighting from this light
  15509. * adds only specular lighting from this light
  15510. * adds dynamic shadows
  15511. */
  15512. static readonly LIGHTMAP_SPECULAR: number;
  15513. /**
  15514. * material.lightmapTexture as only lighting
  15515. * no light calculation from this light
  15516. * only adds dynamic shadows from this light
  15517. */
  15518. static readonly LIGHTMAP_SHADOWSONLY: number;
  15519. /**
  15520. * Each light type uses the default quantity according to its type:
  15521. * point/spot lights use luminous intensity
  15522. * directional lights use illuminance
  15523. */
  15524. static readonly INTENSITYMODE_AUTOMATIC: number;
  15525. /**
  15526. * lumen (lm)
  15527. */
  15528. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15529. /**
  15530. * candela (lm/sr)
  15531. */
  15532. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15533. /**
  15534. * lux (lm/m^2)
  15535. */
  15536. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15537. /**
  15538. * nit (cd/m^2)
  15539. */
  15540. static readonly INTENSITYMODE_LUMINANCE: number;
  15541. /**
  15542. * Light type const id of the point light.
  15543. */
  15544. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15545. /**
  15546. * Light type const id of the directional light.
  15547. */
  15548. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15549. /**
  15550. * Light type const id of the spot light.
  15551. */
  15552. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15553. /**
  15554. * Light type const id of the hemispheric light.
  15555. */
  15556. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15557. /**
  15558. * Diffuse gives the basic color to an object.
  15559. */
  15560. diffuse: Color3;
  15561. /**
  15562. * Specular produces a highlight color on an object.
  15563. * Note: This is note affecting PBR materials.
  15564. */
  15565. specular: Color3;
  15566. /**
  15567. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15568. * falling off base on range or angle.
  15569. * This can be set to any values in Light.FALLOFF_x.
  15570. *
  15571. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  15572. * other types of materials.
  15573. */
  15574. falloffType: number;
  15575. /**
  15576. * Strength of the light.
  15577. * Note: By default it is define in the framework own unit.
  15578. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15579. */
  15580. intensity: number;
  15581. private _range;
  15582. protected _inverseSquaredRange: number;
  15583. /**
  15584. * Defines how far from the source the light is impacting in scene units.
  15585. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15586. */
  15587. /**
  15588. * Defines how far from the source the light is impacting in scene units.
  15589. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15590. */
  15591. range: number;
  15592. /**
  15593. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15594. * of light.
  15595. */
  15596. private _photometricScale;
  15597. private _intensityMode;
  15598. /**
  15599. * Gets the photometric scale used to interpret the intensity.
  15600. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15601. */
  15602. /**
  15603. * Sets the photometric scale used to interpret the intensity.
  15604. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15605. */
  15606. intensityMode: number;
  15607. private _radius;
  15608. /**
  15609. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15610. */
  15611. /**
  15612. * sets the light radius used by PBR Materials to simulate soft area lights.
  15613. */
  15614. radius: number;
  15615. private _renderPriority;
  15616. /**
  15617. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15618. * exceeding the number allowed of the materials.
  15619. */
  15620. renderPriority: number;
  15621. private _shadowEnabled;
  15622. /**
  15623. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15624. * the current shadow generator.
  15625. */
  15626. /**
  15627. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15628. * the current shadow generator.
  15629. */
  15630. shadowEnabled: boolean;
  15631. private _includedOnlyMeshes;
  15632. /**
  15633. * Gets the only meshes impacted by this light.
  15634. */
  15635. /**
  15636. * Sets the only meshes impacted by this light.
  15637. */
  15638. includedOnlyMeshes: AbstractMesh[];
  15639. private _excludedMeshes;
  15640. /**
  15641. * Gets the meshes not impacted by this light.
  15642. */
  15643. /**
  15644. * Sets the meshes not impacted by this light.
  15645. */
  15646. excludedMeshes: AbstractMesh[];
  15647. private _excludeWithLayerMask;
  15648. /**
  15649. * Gets the layer id use to find what meshes are not impacted by the light.
  15650. * Inactive if 0
  15651. */
  15652. /**
  15653. * Sets the layer id use to find what meshes are not impacted by the light.
  15654. * Inactive if 0
  15655. */
  15656. excludeWithLayerMask: number;
  15657. private _includeOnlyWithLayerMask;
  15658. /**
  15659. * Gets the layer id use to find what meshes are impacted by the light.
  15660. * Inactive if 0
  15661. */
  15662. /**
  15663. * Sets the layer id use to find what meshes are impacted by the light.
  15664. * Inactive if 0
  15665. */
  15666. includeOnlyWithLayerMask: number;
  15667. private _lightmapMode;
  15668. /**
  15669. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15670. */
  15671. /**
  15672. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15673. */
  15674. lightmapMode: number;
  15675. /**
  15676. * Shadow generator associted to the light.
  15677. * @hidden Internal use only.
  15678. */
  15679. _shadowGenerator: Nullable<IShadowGenerator>;
  15680. /**
  15681. * @hidden Internal use only.
  15682. */
  15683. _excludedMeshesIds: string[];
  15684. /**
  15685. * @hidden Internal use only.
  15686. */
  15687. _includedOnlyMeshesIds: string[];
  15688. /**
  15689. * The current light unifom buffer.
  15690. * @hidden Internal use only.
  15691. */
  15692. _uniformBuffer: UniformBuffer;
  15693. /**
  15694. * Creates a Light object in the scene.
  15695. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15696. * @param name The firendly name of the light
  15697. * @param scene The scene the light belongs too
  15698. */
  15699. constructor(name: string, scene: Scene);
  15700. protected abstract _buildUniformLayout(): void;
  15701. /**
  15702. * Sets the passed Effect "effect" with the Light information.
  15703. * @param effect The effect to update
  15704. * @param lightIndex The index of the light in the effect to update
  15705. * @returns The light
  15706. */
  15707. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15708. /**
  15709. * Returns the string "Light".
  15710. * @returns the class name
  15711. */
  15712. getClassName(): string;
  15713. /**
  15714. * Converts the light information to a readable string for debug purpose.
  15715. * @param fullDetails Supports for multiple levels of logging within scene loading
  15716. * @returns the human readable light info
  15717. */
  15718. toString(fullDetails?: boolean): string;
  15719. /** @hidden */
  15720. protected _syncParentEnabledState(): void;
  15721. /**
  15722. * Set the enabled state of this node.
  15723. * @param value - the new enabled state
  15724. */
  15725. setEnabled(value: boolean): void;
  15726. /**
  15727. * Returns the Light associated shadow generator if any.
  15728. * @return the associated shadow generator.
  15729. */
  15730. getShadowGenerator(): Nullable<IShadowGenerator>;
  15731. /**
  15732. * Returns a Vector3, the absolute light position in the World.
  15733. * @returns the world space position of the light
  15734. */
  15735. getAbsolutePosition(): Vector3;
  15736. /**
  15737. * Specifies if the light will affect the passed mesh.
  15738. * @param mesh The mesh to test against the light
  15739. * @return true the mesh is affected otherwise, false.
  15740. */
  15741. canAffectMesh(mesh: AbstractMesh): boolean;
  15742. /**
  15743. * Sort function to order lights for rendering.
  15744. * @param a First Light object to compare to second.
  15745. * @param b Second Light object to compare first.
  15746. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15747. */
  15748. static CompareLightsPriority(a: Light, b: Light): number;
  15749. /**
  15750. * Releases resources associated with this node.
  15751. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15752. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15753. */
  15754. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15755. /**
  15756. * Returns the light type ID (integer).
  15757. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15758. */
  15759. getTypeID(): number;
  15760. /**
  15761. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15762. * @returns the scaled intensity in intensity mode unit
  15763. */
  15764. getScaledIntensity(): number;
  15765. /**
  15766. * Returns a new Light object, named "name", from the current one.
  15767. * @param name The name of the cloned light
  15768. * @returns the new created light
  15769. */
  15770. clone(name: string): Nullable<Light>;
  15771. /**
  15772. * Serializes the current light into a Serialization object.
  15773. * @returns the serialized object.
  15774. */
  15775. serialize(): any;
  15776. /**
  15777. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15778. * This new light is named "name" and added to the passed scene.
  15779. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15780. * @param name The friendly name of the light
  15781. * @param scene The scene the new light will belong to
  15782. * @returns the constructor function
  15783. */
  15784. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15785. /**
  15786. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15787. * @param parsedLight The JSON representation of the light
  15788. * @param scene The scene to create the parsed light in
  15789. * @returns the created light after parsing
  15790. */
  15791. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15792. private _hookArrayForExcluded;
  15793. private _hookArrayForIncludedOnly;
  15794. private _resyncMeshes;
  15795. /**
  15796. * Forces the meshes to update their light related information in their rendering used effects
  15797. * @hidden Internal Use Only
  15798. */
  15799. _markMeshesAsLightDirty(): void;
  15800. /**
  15801. * Recomputes the cached photometric scale if needed.
  15802. */
  15803. private _computePhotometricScale;
  15804. /**
  15805. * Returns the Photometric Scale according to the light type and intensity mode.
  15806. */
  15807. private _getPhotometricScale;
  15808. /**
  15809. * Reorder the light in the scene according to their defined priority.
  15810. * @hidden Internal Use Only
  15811. */
  15812. _reorderLightsInScene(): void;
  15813. /**
  15814. * Prepares the list of defines specific to the light type.
  15815. * @param defines the list of defines
  15816. * @param lightIndex defines the index of the light for the effect
  15817. */
  15818. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15819. }
  15820. }
  15821. declare module BABYLON {
  15822. /**
  15823. * A point light is a light defined by an unique point in world space.
  15824. * The light is emitted in every direction from this point.
  15825. * A good example of a point light is a standard light bulb.
  15826. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15827. */
  15828. class PointLight extends ShadowLight {
  15829. private _shadowAngle;
  15830. /**
  15831. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15832. * This specifies what angle the shadow will use to be created.
  15833. *
  15834. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15835. */
  15836. /**
  15837. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15838. * This specifies what angle the shadow will use to be created.
  15839. *
  15840. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15841. */
  15842. shadowAngle: number;
  15843. /**
  15844. * Gets the direction if it has been set.
  15845. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15846. */
  15847. /**
  15848. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15849. */
  15850. direction: Vector3;
  15851. /**
  15852. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  15853. * A PointLight emits the light in every direction.
  15854. * It can cast shadows.
  15855. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  15856. * ```javascript
  15857. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  15858. * ```
  15859. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15860. * @param name The light friendly name
  15861. * @param position The position of the point light in the scene
  15862. * @param scene The scene the lights belongs to
  15863. */
  15864. constructor(name: string, position: Vector3, scene: Scene);
  15865. /**
  15866. * Returns the string "PointLight"
  15867. * @returns the class name
  15868. */
  15869. getClassName(): string;
  15870. /**
  15871. * Returns the integer 0.
  15872. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15873. */
  15874. getTypeID(): number;
  15875. /**
  15876. * Specifies wether or not the shadowmap should be a cube texture.
  15877. * @returns true if the shadowmap needs to be a cube texture.
  15878. */
  15879. needCube(): boolean;
  15880. /**
  15881. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  15882. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15883. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15884. */
  15885. getShadowDirection(faceIndex?: number): Vector3;
  15886. /**
  15887. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  15888. * - fov = PI / 2
  15889. * - aspect ratio : 1.0
  15890. * - z-near and far equal to the active camera minZ and maxZ.
  15891. * Returns the PointLight.
  15892. */
  15893. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15894. protected _buildUniformLayout(): void;
  15895. /**
  15896. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  15897. * @param effect The effect to update
  15898. * @param lightIndex The index of the light in the effect to update
  15899. * @returns The point light
  15900. */
  15901. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  15902. /**
  15903. * Prepares the list of defines specific to the light type.
  15904. * @param defines the list of defines
  15905. * @param lightIndex defines the index of the light for the effect
  15906. */
  15907. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15908. }
  15909. }
  15910. declare module BABYLON {
  15911. /**
  15912. * Interface describing all the common properties and methods a shadow light needs to implement.
  15913. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  15914. * as well as binding the different shadow properties to the effects.
  15915. */
  15916. interface IShadowLight extends Light {
  15917. /**
  15918. * The light id in the scene (used in scene.findLighById for instance)
  15919. */
  15920. id: string;
  15921. /**
  15922. * The position the shdow will be casted from.
  15923. */
  15924. position: Vector3;
  15925. /**
  15926. * In 2d mode (needCube being false), the direction used to cast the shadow.
  15927. */
  15928. direction: Vector3;
  15929. /**
  15930. * The transformed position. Position of the light in world space taking parenting in account.
  15931. */
  15932. transformedPosition: Vector3;
  15933. /**
  15934. * The transformed direction. Direction of the light in world space taking parenting in account.
  15935. */
  15936. transformedDirection: Vector3;
  15937. /**
  15938. * The friendly name of the light in the scene.
  15939. */
  15940. name: string;
  15941. /**
  15942. * Defines the shadow projection clipping minimum z value.
  15943. */
  15944. shadowMinZ: number;
  15945. /**
  15946. * Defines the shadow projection clipping maximum z value.
  15947. */
  15948. shadowMaxZ: number;
  15949. /**
  15950. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15951. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15952. */
  15953. computeTransformedInformation(): boolean;
  15954. /**
  15955. * Gets the scene the light belongs to.
  15956. * @returns The scene
  15957. */
  15958. getScene(): Scene;
  15959. /**
  15960. * Callback defining a custom Projection Matrix Builder.
  15961. * This can be used to override the default projection matrix computation.
  15962. */
  15963. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15964. /**
  15965. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15966. * @param matrix The materix to updated with the projection information
  15967. * @param viewMatrix The transform matrix of the light
  15968. * @param renderList The list of mesh to render in the map
  15969. * @returns The current light
  15970. */
  15971. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15972. /**
  15973. * Gets the current depth scale used in ESM.
  15974. * @returns The scale
  15975. */
  15976. getDepthScale(): number;
  15977. /**
  15978. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15979. * @returns true if a cube texture needs to be use
  15980. */
  15981. needCube(): boolean;
  15982. /**
  15983. * Detects if the projection matrix requires to be recomputed this frame.
  15984. * @returns true if it requires to be recomputed otherwise, false.
  15985. */
  15986. needProjectionMatrixCompute(): boolean;
  15987. /**
  15988. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15989. */
  15990. forceProjectionMatrixCompute(): void;
  15991. /**
  15992. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15993. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15994. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15995. */
  15996. getShadowDirection(faceIndex?: number): Vector3;
  15997. /**
  15998. * Gets the minZ used for shadow according to both the scene and the light.
  15999. * @param activeCamera The camera we are returning the min for
  16000. * @returns the depth min z
  16001. */
  16002. getDepthMinZ(activeCamera: Camera): number;
  16003. /**
  16004. * Gets the maxZ used for shadow according to both the scene and the light.
  16005. * @param activeCamera The camera we are returning the max for
  16006. * @returns the depth max z
  16007. */
  16008. getDepthMaxZ(activeCamera: Camera): number;
  16009. }
  16010. /**
  16011. * Base implementation IShadowLight
  16012. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  16013. */
  16014. abstract class ShadowLight extends Light implements IShadowLight {
  16015. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16016. protected _position: Vector3;
  16017. protected _setPosition(value: Vector3): void;
  16018. /**
  16019. * Sets the position the shadow will be casted from. Also use as the light position for both
  16020. * point and spot lights.
  16021. */
  16022. /**
  16023. * Sets the position the shadow will be casted from. Also use as the light position for both
  16024. * point and spot lights.
  16025. */
  16026. position: Vector3;
  16027. protected _direction: Vector3;
  16028. protected _setDirection(value: Vector3): void;
  16029. /**
  16030. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  16031. * Also use as the light direction on spot and directional lights.
  16032. */
  16033. /**
  16034. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  16035. * Also use as the light direction on spot and directional lights.
  16036. */
  16037. direction: Vector3;
  16038. private _shadowMinZ;
  16039. /**
  16040. * Gets the shadow projection clipping minimum z value.
  16041. */
  16042. /**
  16043. * Sets the shadow projection clipping minimum z value.
  16044. */
  16045. shadowMinZ: number;
  16046. private _shadowMaxZ;
  16047. /**
  16048. * Sets the shadow projection clipping maximum z value.
  16049. */
  16050. /**
  16051. * Gets the shadow projection clipping maximum z value.
  16052. */
  16053. shadowMaxZ: number;
  16054. /**
  16055. * Callback defining a custom Projection Matrix Builder.
  16056. * This can be used to override the default projection matrix computation.
  16057. */
  16058. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16059. /**
  16060. * The transformed position. Position of the light in world space taking parenting in account.
  16061. */
  16062. transformedPosition: Vector3;
  16063. /**
  16064. * The transformed direction. Direction of the light in world space taking parenting in account.
  16065. */
  16066. transformedDirection: Vector3;
  16067. private _needProjectionMatrixCompute;
  16068. /**
  16069. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16070. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16071. */
  16072. computeTransformedInformation(): boolean;
  16073. /**
  16074. * Return the depth scale used for the shadow map.
  16075. * @returns the depth scale.
  16076. */
  16077. getDepthScale(): number;
  16078. /**
  16079. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16080. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16081. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16082. */
  16083. getShadowDirection(faceIndex?: number): Vector3;
  16084. /**
  16085. * Returns the ShadowLight absolute position in the World.
  16086. * @returns the position vector in world space
  16087. */
  16088. getAbsolutePosition(): Vector3;
  16089. /**
  16090. * Sets the ShadowLight direction toward the passed target.
  16091. * @param target The point tot target in local space
  16092. * @returns the updated ShadowLight direction
  16093. */
  16094. setDirectionToTarget(target: Vector3): Vector3;
  16095. /**
  16096. * Returns the light rotation in euler definition.
  16097. * @returns the x y z rotation in local space.
  16098. */
  16099. getRotation(): Vector3;
  16100. /**
  16101. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16102. * @returns true if a cube texture needs to be use
  16103. */
  16104. needCube(): boolean;
  16105. /**
  16106. * Detects if the projection matrix requires to be recomputed this frame.
  16107. * @returns true if it requires to be recomputed otherwise, false.
  16108. */
  16109. needProjectionMatrixCompute(): boolean;
  16110. /**
  16111. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16112. */
  16113. forceProjectionMatrixCompute(): void;
  16114. /** @hidden */
  16115. _initCache(): void;
  16116. /** @hidden */
  16117. _isSynchronized(): boolean;
  16118. /**
  16119. * Computes the world matrix of the node
  16120. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16121. * @returns the world matrix
  16122. */
  16123. computeWorldMatrix(force?: boolean): Matrix;
  16124. /**
  16125. * Gets the minZ used for shadow according to both the scene and the light.
  16126. * @param activeCamera The camera we are returning the min for
  16127. * @returns the depth min z
  16128. */
  16129. getDepthMinZ(activeCamera: Camera): number;
  16130. /**
  16131. * Gets the maxZ used for shadow according to both the scene and the light.
  16132. * @param activeCamera The camera we are returning the max for
  16133. * @returns the depth max z
  16134. */
  16135. getDepthMaxZ(activeCamera: Camera): number;
  16136. /**
  16137. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16138. * @param matrix The materix to updated with the projection information
  16139. * @param viewMatrix The transform matrix of the light
  16140. * @param renderList The list of mesh to render in the map
  16141. * @returns The current light
  16142. */
  16143. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16144. }
  16145. }
  16146. declare module BABYLON {
  16147. /**
  16148. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16149. * These values define a cone of light starting from the position, emitting toward the direction.
  16150. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16151. * and the exponent defines the speed of the decay of the light with distance (reach).
  16152. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16153. */
  16154. class SpotLight extends ShadowLight {
  16155. private _angle;
  16156. private _innerAngle;
  16157. private _cosHalfAngle;
  16158. private _lightAngleScale;
  16159. private _lightAngleOffset;
  16160. /**
  16161. * Gets the cone angle of the spot light in Radians.
  16162. */
  16163. /**
  16164. * Sets the cone angle of the spot light in Radians.
  16165. */
  16166. angle: number;
  16167. /**
  16168. * Only used in gltf falloff mode, this defines the angle where
  16169. * the directional falloff will start before cutting at angle which could be seen
  16170. * as outer angle.
  16171. */
  16172. /**
  16173. * Only used in gltf falloff mode, this defines the angle where
  16174. * the directional falloff will start before cutting at angle which could be seen
  16175. * as outer angle.
  16176. */
  16177. innerAngle: number;
  16178. private _shadowAngleScale;
  16179. /**
  16180. * Allows scaling the angle of the light for shadow generation only.
  16181. */
  16182. /**
  16183. * Allows scaling the angle of the light for shadow generation only.
  16184. */
  16185. shadowAngleScale: number;
  16186. /**
  16187. * The light decay speed with the distance from the emission spot.
  16188. */
  16189. exponent: number;
  16190. private _projectionTextureMatrix;
  16191. /**
  16192. * Allows reading the projecton texture
  16193. */
  16194. readonly projectionTextureMatrix: Matrix;
  16195. protected _projectionTextureLightNear: number;
  16196. /**
  16197. * Gets the near clip of the Spotlight for texture projection.
  16198. */
  16199. /**
  16200. * Sets the near clip of the Spotlight for texture projection.
  16201. */
  16202. projectionTextureLightNear: number;
  16203. protected _projectionTextureLightFar: number;
  16204. /**
  16205. * Gets the far clip of the Spotlight for texture projection.
  16206. */
  16207. /**
  16208. * Sets the far clip of the Spotlight for texture projection.
  16209. */
  16210. projectionTextureLightFar: number;
  16211. protected _projectionTextureUpDirection: Vector3;
  16212. /**
  16213. * Gets the Up vector of the Spotlight for texture projection.
  16214. */
  16215. /**
  16216. * Sets the Up vector of the Spotlight for texture projection.
  16217. */
  16218. projectionTextureUpDirection: Vector3;
  16219. private _projectionTexture;
  16220. /**
  16221. * Gets the projection texture of the light.
  16222. */
  16223. /**
  16224. * Sets the projection texture of the light.
  16225. */
  16226. projectionTexture: Nullable<BaseTexture>;
  16227. private _projectionTextureViewLightDirty;
  16228. private _projectionTextureProjectionLightDirty;
  16229. private _projectionTextureDirty;
  16230. private _projectionTextureViewTargetVector;
  16231. private _projectionTextureViewLightMatrix;
  16232. private _projectionTextureProjectionLightMatrix;
  16233. private _projectionTextureScalingMatrix;
  16234. /**
  16235. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16236. * It can cast shadows.
  16237. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16238. * @param name The light friendly name
  16239. * @param position The position of the spot light in the scene
  16240. * @param direction The direction of the light in the scene
  16241. * @param angle The cone angle of the light in Radians
  16242. * @param exponent The light decay speed with the distance from the emission spot
  16243. * @param scene The scene the lights belongs to
  16244. */
  16245. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16246. /**
  16247. * Returns the string "SpotLight".
  16248. * @returns the class name
  16249. */
  16250. getClassName(): string;
  16251. /**
  16252. * Returns the integer 2.
  16253. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16254. */
  16255. getTypeID(): number;
  16256. /**
  16257. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16258. */
  16259. protected _setDirection(value: Vector3): void;
  16260. /**
  16261. * Overrides the position setter to recompute the projection texture view light Matrix.
  16262. */
  16263. protected _setPosition(value: Vector3): void;
  16264. /**
  16265. * 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.
  16266. * Returns the SpotLight.
  16267. */
  16268. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16269. protected _computeProjectionTextureViewLightMatrix(): void;
  16270. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16271. /**
  16272. * Main function for light texture projection matrix computing.
  16273. */
  16274. protected _computeProjectionTextureMatrix(): void;
  16275. protected _buildUniformLayout(): void;
  16276. private _computeAngleValues;
  16277. /**
  16278. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16279. * @param effect The effect to update
  16280. * @param lightIndex The index of the light in the effect to update
  16281. * @returns The spot light
  16282. */
  16283. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16284. /**
  16285. * Disposes the light and the associated resources.
  16286. */
  16287. dispose(): void;
  16288. /**
  16289. * Prepares the list of defines specific to the light type.
  16290. * @param defines the list of defines
  16291. * @param lightIndex defines the index of the light for the effect
  16292. */
  16293. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16294. }
  16295. }
  16296. declare module BABYLON {
  16297. /**
  16298. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  16299. * It controls one of the indiviual texture used in the effect.
  16300. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  16301. */
  16302. class LensFlare {
  16303. /**
  16304. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  16305. */
  16306. size: number;
  16307. /**
  16308. * 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.
  16309. */
  16310. position: number;
  16311. /**
  16312. * Define the lens color.
  16313. */
  16314. color: Color3;
  16315. /**
  16316. * Define the lens texture.
  16317. */
  16318. texture: Nullable<Texture>;
  16319. /**
  16320. * Define the alpha mode to render this particular lens.
  16321. */
  16322. alphaMode: number;
  16323. private _system;
  16324. /**
  16325. * Creates a new Lens Flare.
  16326. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  16327. * It controls one of the indiviual texture used in the effect.
  16328. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  16329. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  16330. * @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.
  16331. * @param color Define the lens color
  16332. * @param imgUrl Define the lens texture url
  16333. * @param system Define the `lensFlareSystem` this flare is part of
  16334. * @returns The newly created Lens Flare
  16335. */
  16336. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  16337. /**
  16338. * Instantiates a new Lens Flare.
  16339. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  16340. * It controls one of the indiviual texture used in the effect.
  16341. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  16342. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  16343. * @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.
  16344. * @param color Define the lens color
  16345. * @param imgUrl Define the lens texture url
  16346. * @param system Define the `lensFlareSystem` this flare is part of
  16347. */
  16348. constructor(
  16349. /**
  16350. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  16351. */
  16352. size: number,
  16353. /**
  16354. * 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.
  16355. */
  16356. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  16357. /**
  16358. * Dispose and release the lens flare with its associated resources.
  16359. */
  16360. dispose(): void;
  16361. }
  16362. }
  16363. declare module BABYLON {
  16364. /**
  16365. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  16366. * It is usually composed of several `BABYLON.lensFlare`.
  16367. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  16368. */
  16369. class LensFlareSystem {
  16370. /**
  16371. * Define the name of the lens flare system
  16372. */
  16373. name: string;
  16374. /**
  16375. * List of lens flares used in this system.
  16376. */
  16377. lensFlares: LensFlare[];
  16378. /**
  16379. * Define a limit from the border the lens flare can be visible.
  16380. */
  16381. borderLimit: number;
  16382. /**
  16383. * Define a viewport border we do not want to see the lens flare in.
  16384. */
  16385. viewportBorder: number;
  16386. /**
  16387. * Define a predicate which could limit the list of meshes able to occlude the effect.
  16388. */
  16389. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  16390. /**
  16391. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  16392. */
  16393. layerMask: number;
  16394. /**
  16395. * Define the id of the lens flare system in the scene.
  16396. * (equal to name by default)
  16397. */
  16398. id: string;
  16399. private _scene;
  16400. private _emitter;
  16401. private _vertexBuffers;
  16402. private _indexBuffer;
  16403. private _effect;
  16404. private _positionX;
  16405. private _positionY;
  16406. private _isEnabled;
  16407. /**
  16408. * Instantiates a lens flare system.
  16409. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  16410. * It is usually composed of several `BABYLON.lensFlare`.
  16411. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  16412. * @param name Define the name of the lens flare system in the scene
  16413. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  16414. * @param scene Define the scene the lens flare system belongs to
  16415. */
  16416. constructor(
  16417. /**
  16418. * Define the name of the lens flare system
  16419. */
  16420. name: string, emitter: any, scene: Scene);
  16421. /**
  16422. * Define if the lens flare system is enabled.
  16423. */
  16424. isEnabled: boolean;
  16425. /**
  16426. * Get the scene the effects belongs to.
  16427. * @returns the scene holding the lens flare system
  16428. */
  16429. getScene(): Scene;
  16430. /**
  16431. * Get the emitter of the lens flare system.
  16432. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  16433. * @returns the emitter of the lens flare system
  16434. */
  16435. getEmitter(): any;
  16436. /**
  16437. * Set the emitter of the lens flare system.
  16438. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  16439. * @param newEmitter Define the new emitter of the system
  16440. */
  16441. setEmitter(newEmitter: any): void;
  16442. /**
  16443. * Get the lens flare system emitter position.
  16444. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  16445. * @returns the position
  16446. */
  16447. getEmitterPosition(): Vector3;
  16448. /**
  16449. * @hidden
  16450. */
  16451. computeEffectivePosition(globalViewport: Viewport): boolean;
  16452. /** @hidden */
  16453. _isVisible(): boolean;
  16454. /**
  16455. * @hidden
  16456. */
  16457. render(): boolean;
  16458. /**
  16459. * Dispose and release the lens flare with its associated resources.
  16460. */
  16461. dispose(): void;
  16462. /**
  16463. * Parse a lens flare system from a JSON repressentation
  16464. * @param parsedLensFlareSystem Define the JSON to parse
  16465. * @param scene Define the scene the parsed system should be instantiated in
  16466. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  16467. * @returns the parsed system
  16468. */
  16469. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  16470. /**
  16471. * Serialize the current Lens Flare System into a JSON representation.
  16472. * @returns the serialized JSON
  16473. */
  16474. serialize(): any;
  16475. }
  16476. }
  16477. declare module BABYLON {
  16478. interface AbstractScene {
  16479. /**
  16480. * The list of lens flare system added to the scene
  16481. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  16482. */
  16483. lensFlareSystems: Array<LensFlareSystem>;
  16484. /**
  16485. * Removes the given lens flare system from this scene.
  16486. * @param toRemove The lens flare system to remove
  16487. * @returns The index of the removed lens flare system
  16488. */
  16489. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  16490. /**
  16491. * Adds the given lens flare system to this scene
  16492. * @param newLensFlareSystem The lens flare system to add
  16493. */
  16494. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  16495. /**
  16496. * Gets a lens flare system using its name
  16497. * @param name defines the name to look for
  16498. * @returns the lens flare system or null if not found
  16499. */
  16500. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  16501. /**
  16502. * Gets a lens flare system using its id
  16503. * @param id defines the id to look for
  16504. * @returns the lens flare system or null if not found
  16505. */
  16506. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  16507. }
  16508. /**
  16509. * Defines the lens flare scene component responsible to manage any lens flares
  16510. * in a given scene.
  16511. */
  16512. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  16513. /**
  16514. * The component name helpfull to identify the component in the list of scene components.
  16515. */
  16516. readonly name: string;
  16517. /**
  16518. * The scene the component belongs to.
  16519. */
  16520. scene: Scene;
  16521. /**
  16522. * Creates a new instance of the component for the given scene
  16523. * @param scene Defines the scene to register the component in
  16524. */
  16525. constructor(scene: Scene);
  16526. /**
  16527. * Registers the component in a given scene
  16528. */
  16529. register(): void;
  16530. /**
  16531. * Rebuilds the elements related to this component in case of
  16532. * context lost for instance.
  16533. */
  16534. rebuild(): void;
  16535. /**
  16536. * Adds all the element from the container to the scene
  16537. * @param container the container holding the elements
  16538. */
  16539. addFromContainer(container: AbstractScene): void;
  16540. /**
  16541. * Removes all the elements in the container from the scene
  16542. * @param container contains the elements to remove
  16543. */
  16544. removeFromContainer(container: AbstractScene): void;
  16545. /**
  16546. * Serializes the component data to the specified json object
  16547. * @param serializationObject The object to serialize to
  16548. */
  16549. serialize(serializationObject: any): void;
  16550. /**
  16551. * Disposes the component and the associated ressources.
  16552. */
  16553. dispose(): void;
  16554. private _draw;
  16555. }
  16556. }
  16557. declare module BABYLON {
  16558. /**
  16559. * Interface used to present a loading screen while loading a scene
  16560. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16561. */
  16562. interface ILoadingScreen {
  16563. /**
  16564. * Function called to display the loading screen
  16565. */
  16566. displayLoadingUI: () => void;
  16567. /**
  16568. * Function called to hide the loading screen
  16569. */
  16570. hideLoadingUI: () => void;
  16571. /**
  16572. * Gets or sets the color to use for the background
  16573. */
  16574. loadingUIBackgroundColor: string;
  16575. /**
  16576. * Gets or sets the text to display while loading
  16577. */
  16578. loadingUIText: string;
  16579. }
  16580. /**
  16581. * Class used for the default loading screen
  16582. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16583. */
  16584. class DefaultLoadingScreen implements ILoadingScreen {
  16585. private _renderingCanvas;
  16586. private _loadingText;
  16587. private _loadingDivBackgroundColor;
  16588. private _loadingDiv;
  16589. private _loadingTextDiv;
  16590. /**
  16591. * Creates a new default loading screen
  16592. * @param _renderingCanvas defines the canvas used to render the scene
  16593. * @param _loadingText defines the default text to display
  16594. * @param _loadingDivBackgroundColor defines the default background color
  16595. */
  16596. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16597. /**
  16598. * Function called to display the loading screen
  16599. */
  16600. displayLoadingUI(): void;
  16601. /**
  16602. * Function called to hide the loading screen
  16603. */
  16604. hideLoadingUI(): void;
  16605. /**
  16606. * Gets or sets the text to display while loading
  16607. */
  16608. loadingUIText: string;
  16609. /**
  16610. * Gets or sets the color to use for the background
  16611. */
  16612. loadingUIBackgroundColor: string;
  16613. private _resizeLoadingUI;
  16614. }
  16615. }
  16616. declare module BABYLON {
  16617. /**
  16618. * Class used to represent data loading progression
  16619. */
  16620. class SceneLoaderProgressEvent {
  16621. /** defines if data length to load can be evaluated */
  16622. readonly lengthComputable: boolean;
  16623. /** defines the loaded data length */
  16624. readonly loaded: number;
  16625. /** defines the data length to load */
  16626. readonly total: number;
  16627. /**
  16628. * Create a new progress event
  16629. * @param lengthComputable defines if data length to load can be evaluated
  16630. * @param loaded defines the loaded data length
  16631. * @param total defines the data length to load
  16632. */
  16633. constructor(
  16634. /** defines if data length to load can be evaluated */
  16635. lengthComputable: boolean,
  16636. /** defines the loaded data length */
  16637. loaded: number,
  16638. /** defines the data length to load */
  16639. total: number);
  16640. /**
  16641. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16642. * @param event defines the source event
  16643. * @returns a new SceneLoaderProgressEvent
  16644. */
  16645. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16646. }
  16647. /**
  16648. * Interface used by SceneLoader plugins to define supported file extensions
  16649. */
  16650. interface ISceneLoaderPluginExtensions {
  16651. /**
  16652. * Defines the list of supported extensions
  16653. */
  16654. [extension: string]: {
  16655. isBinary: boolean;
  16656. };
  16657. }
  16658. /**
  16659. * Interface used by SceneLoader plugin factory
  16660. */
  16661. interface ISceneLoaderPluginFactory {
  16662. /**
  16663. * Defines the name of the factory
  16664. */
  16665. name: string;
  16666. /**
  16667. * Function called to create a new plugin
  16668. * @return the new plugin
  16669. */
  16670. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16671. /**
  16672. * Boolean indicating if the plugin can direct load specific data
  16673. */
  16674. canDirectLoad?: (data: string) => boolean;
  16675. }
  16676. /**
  16677. * Interface used to define a SceneLoader plugin
  16678. */
  16679. interface ISceneLoaderPlugin {
  16680. /**
  16681. * The friendly name of this plugin.
  16682. */
  16683. name: string;
  16684. /**
  16685. * The file extensions supported by this plugin.
  16686. */
  16687. extensions: string | ISceneLoaderPluginExtensions;
  16688. /**
  16689. * Import meshes into a scene.
  16690. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16691. * @param scene The scene to import into
  16692. * @param data The data to import
  16693. * @param rootUrl The root url for scene and resources
  16694. * @param meshes The meshes array to import into
  16695. * @param particleSystems The particle systems array to import into
  16696. * @param skeletons The skeletons array to import into
  16697. * @param onError The callback when import fails
  16698. * @returns True if successful or false otherwise
  16699. */
  16700. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16701. /**
  16702. * Load into a scene.
  16703. * @param scene The scene to load into
  16704. * @param data The data to import
  16705. * @param rootUrl The root url for scene and resources
  16706. * @param onError The callback when import fails
  16707. * @returns true if successful or false otherwise
  16708. */
  16709. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16710. /**
  16711. * The callback that returns true if the data can be directly loaded.
  16712. */
  16713. canDirectLoad?: (data: string) => boolean;
  16714. /**
  16715. * The callback that allows custom handling of the root url based on the response url.
  16716. */
  16717. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16718. /**
  16719. * Load into an asset container.
  16720. * @param scene The scene to load into
  16721. * @param data The data to import
  16722. * @param rootUrl The root url for scene and resources
  16723. * @param onError The callback when import fails
  16724. * @returns The loaded asset container
  16725. */
  16726. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16727. }
  16728. /**
  16729. * Interface used to define an async SceneLoader plugin
  16730. */
  16731. interface ISceneLoaderPluginAsync {
  16732. /**
  16733. * The friendly name of this plugin.
  16734. */
  16735. name: string;
  16736. /**
  16737. * The file extensions supported by this plugin.
  16738. */
  16739. extensions: string | ISceneLoaderPluginExtensions;
  16740. /**
  16741. * Import meshes into a scene.
  16742. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16743. * @param scene The scene to import into
  16744. * @param data The data to import
  16745. * @param rootUrl The root url for scene and resources
  16746. * @param onProgress The callback when the load progresses
  16747. * @param fileName Defines the name of the file to load
  16748. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16749. */
  16750. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16751. meshes: AbstractMesh[];
  16752. particleSystems: IParticleSystem[];
  16753. skeletons: Skeleton[];
  16754. animationGroups: AnimationGroup[];
  16755. }>;
  16756. /**
  16757. * Load into a scene.
  16758. * @param scene The scene to load into
  16759. * @param data The data to import
  16760. * @param rootUrl The root url for scene and resources
  16761. * @param onProgress The callback when the load progresses
  16762. * @param fileName Defines the name of the file to load
  16763. * @returns Nothing
  16764. */
  16765. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16766. /**
  16767. * The callback that returns true if the data can be directly loaded.
  16768. */
  16769. canDirectLoad?: (data: string) => boolean;
  16770. /**
  16771. * The callback that allows custom handling of the root url based on the response url.
  16772. */
  16773. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16774. /**
  16775. * Load into an asset container.
  16776. * @param scene The scene to load into
  16777. * @param data The data to import
  16778. * @param rootUrl The root url for scene and resources
  16779. * @param onProgress The callback when the load progresses
  16780. * @param fileName Defines the name of the file to load
  16781. * @returns The loaded asset container
  16782. */
  16783. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16784. }
  16785. /**
  16786. * Class used to load scene from various file formats using registered plugins
  16787. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16788. */
  16789. class SceneLoader {
  16790. private static _ForceFullSceneLoadingForIncremental;
  16791. private static _ShowLoadingScreen;
  16792. private static _CleanBoneMatrixWeights;
  16793. /**
  16794. * No logging while loading
  16795. */
  16796. static readonly NO_LOGGING: number;
  16797. /**
  16798. * Minimal logging while loading
  16799. */
  16800. static readonly MINIMAL_LOGGING: number;
  16801. /**
  16802. * Summary logging while loading
  16803. */
  16804. static readonly SUMMARY_LOGGING: number;
  16805. /**
  16806. * Detailled logging while loading
  16807. */
  16808. static readonly DETAILED_LOGGING: number;
  16809. private static _loggingLevel;
  16810. /**
  16811. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16812. */
  16813. static ForceFullSceneLoadingForIncremental: boolean;
  16814. /**
  16815. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16816. */
  16817. static ShowLoadingScreen: boolean;
  16818. /**
  16819. * Defines the current logging level (while loading the scene)
  16820. * @ignorenaming
  16821. */
  16822. static loggingLevel: number;
  16823. /**
  16824. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16825. */
  16826. static CleanBoneMatrixWeights: boolean;
  16827. /**
  16828. * Event raised when a plugin is used to load a scene
  16829. */
  16830. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16831. private static _registeredPlugins;
  16832. private static _getDefaultPlugin;
  16833. private static _getPluginForExtension;
  16834. private static _getPluginForDirectLoad;
  16835. private static _getPluginForFilename;
  16836. private static _getDirectLoad;
  16837. private static _loadData;
  16838. private static _getFileInfo;
  16839. /**
  16840. * Gets a plugin that can load the given extension
  16841. * @param extension defines the extension to load
  16842. * @returns a plugin or null if none works
  16843. */
  16844. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16845. /**
  16846. * Gets a boolean indicating that the given extension can be loaded
  16847. * @param extension defines the extension to load
  16848. * @returns true if the extension is supported
  16849. */
  16850. static IsPluginForExtensionAvailable(extension: string): boolean;
  16851. /**
  16852. * Adds a new plugin to the list of registered plugins
  16853. * @param plugin defines the plugin to add
  16854. */
  16855. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16856. /**
  16857. * Import meshes into a scene
  16858. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16859. * @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)
  16860. * @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)
  16861. * @param scene the instance of BABYLON.Scene to append to
  16862. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16863. * @param onProgress a callback with a progress event for each file being loaded
  16864. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16865. * @param pluginExtension the extension used to determine the plugin
  16866. * @returns The loaded plugin
  16867. */
  16868. 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>;
  16869. /**
  16870. * Import meshes into a scene
  16871. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16872. * @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)
  16873. * @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)
  16874. * @param scene the instance of BABYLON.Scene to append to
  16875. * @param onProgress a callback with a progress event for each file being loaded
  16876. * @param pluginExtension the extension used to determine the plugin
  16877. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16878. */
  16879. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16880. meshes: AbstractMesh[];
  16881. particleSystems: IParticleSystem[];
  16882. skeletons: Skeleton[];
  16883. animationGroups: AnimationGroup[];
  16884. }>;
  16885. /**
  16886. * Load a scene
  16887. * @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)
  16888. * @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)
  16889. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16890. * @param onSuccess a callback with the scene when import succeeds
  16891. * @param onProgress a callback with a progress event for each file being loaded
  16892. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16893. * @param pluginExtension the extension used to determine the plugin
  16894. * @returns The loaded plugin
  16895. */
  16896. 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>;
  16897. /**
  16898. * Load a scene
  16899. * @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)
  16900. * @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)
  16901. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16902. * @param onProgress a callback with a progress event for each file being loaded
  16903. * @param pluginExtension the extension used to determine the plugin
  16904. * @returns The loaded scene
  16905. */
  16906. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16907. /**
  16908. * Append a scene
  16909. * @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)
  16910. * @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)
  16911. * @param scene is the instance of BABYLON.Scene to append to
  16912. * @param onSuccess a callback with the scene when import succeeds
  16913. * @param onProgress a callback with a progress event for each file being loaded
  16914. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16915. * @param pluginExtension the extension used to determine the plugin
  16916. * @returns The loaded plugin
  16917. */
  16918. 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>;
  16919. /**
  16920. * Append a scene
  16921. * @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)
  16922. * @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)
  16923. * @param scene is the instance of BABYLON.Scene to append to
  16924. * @param onProgress a callback with a progress event for each file being loaded
  16925. * @param pluginExtension the extension used to determine the plugin
  16926. * @returns The given scene
  16927. */
  16928. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16929. /**
  16930. * Load a scene into an asset container
  16931. * @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)
  16932. * @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)
  16933. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16934. * @param onSuccess a callback with the scene when import succeeds
  16935. * @param onProgress a callback with a progress event for each file being loaded
  16936. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16937. * @param pluginExtension the extension used to determine the plugin
  16938. * @returns The loaded plugin
  16939. */
  16940. 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>;
  16941. /**
  16942. * Load a scene into an asset container
  16943. * @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)
  16944. * @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)
  16945. * @param scene is the instance of BABYLON.Scene to append to
  16946. * @param onProgress a callback with a progress event for each file being loaded
  16947. * @param pluginExtension the extension used to determine the plugin
  16948. * @returns The loaded asset container
  16949. */
  16950. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16951. }
  16952. }
  16953. declare module BABYLON {
  16954. /**
  16955. * Scalar computation library
  16956. */
  16957. class Scalar {
  16958. /**
  16959. * Two pi constants convenient for computation.
  16960. */
  16961. static TwoPi: number;
  16962. /**
  16963. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  16964. * @param a number
  16965. * @param b number
  16966. * @param epsilon (default = 1.401298E-45)
  16967. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  16968. */
  16969. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  16970. /**
  16971. * Returns a string : the upper case translation of the number i to hexadecimal.
  16972. * @param i number
  16973. * @returns the upper case translation of the number i to hexadecimal.
  16974. */
  16975. static ToHex(i: number): string;
  16976. /**
  16977. * Returns -1 if value is negative and +1 is value is positive.
  16978. * @param value the value
  16979. * @returns the value itself if it's equal to zero.
  16980. */
  16981. static Sign(value: number): number;
  16982. /**
  16983. * Returns the value itself if it's between min and max.
  16984. * Returns min if the value is lower than min.
  16985. * Returns max if the value is greater than max.
  16986. * @param value the value to clmap
  16987. * @param min the min value to clamp to (default: 0)
  16988. * @param max the max value to clamp to (default: 1)
  16989. * @returns the clamped value
  16990. */
  16991. static Clamp(value: number, min?: number, max?: number): number;
  16992. /**
  16993. * the log2 of value.
  16994. * @param value the value to compute log2 of
  16995. * @returns the log2 of value.
  16996. */
  16997. static Log2(value: number): number;
  16998. /**
  16999. * Loops the value, so that it is never larger than length and never smaller than 0.
  17000. *
  17001. * This is similar to the modulo operator but it works with floating point numbers.
  17002. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  17003. * With t = 5 and length = 2.5, the result would be 0.0.
  17004. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  17005. * @param value the value
  17006. * @param length the length
  17007. * @returns the looped value
  17008. */
  17009. static Repeat(value: number, length: number): number;
  17010. /**
  17011. * Normalize the value between 0.0 and 1.0 using min and max values
  17012. * @param value value to normalize
  17013. * @param min max to normalize between
  17014. * @param max min to normalize between
  17015. * @returns the normalized value
  17016. */
  17017. static Normalize(value: number, min: number, max: number): number;
  17018. /**
  17019. * Denormalize the value from 0.0 and 1.0 using min and max values
  17020. * @param normalized value to denormalize
  17021. * @param min max to denormalize between
  17022. * @param max min to denormalize between
  17023. * @returns the denormalized value
  17024. */
  17025. static Denormalize(normalized: number, min: number, max: number): number;
  17026. /**
  17027. * Calculates the shortest difference between two given angles given in degrees.
  17028. * @param current current angle in degrees
  17029. * @param target target angle in degrees
  17030. * @returns the delta
  17031. */
  17032. static DeltaAngle(current: number, target: number): number;
  17033. /**
  17034. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  17035. * @param tx value
  17036. * @param length length
  17037. * @returns The returned value will move back and forth between 0 and length
  17038. */
  17039. static PingPong(tx: number, length: number): number;
  17040. /**
  17041. * Interpolates between min and max with smoothing at the limits.
  17042. *
  17043. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  17044. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  17045. * @param from from
  17046. * @param to to
  17047. * @param tx value
  17048. * @returns the smooth stepped value
  17049. */
  17050. static SmoothStep(from: number, to: number, tx: number): number;
  17051. /**
  17052. * Moves a value current towards target.
  17053. *
  17054. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  17055. * Negative values of maxDelta pushes the value away from target.
  17056. * @param current current value
  17057. * @param target target value
  17058. * @param maxDelta max distance to move
  17059. * @returns resulting value
  17060. */
  17061. static MoveTowards(current: number, target: number, maxDelta: number): number;
  17062. /**
  17063. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  17064. *
  17065. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  17066. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  17067. * @param current current value
  17068. * @param target target value
  17069. * @param maxDelta max distance to move
  17070. * @returns resulting angle
  17071. */
  17072. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  17073. /**
  17074. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  17075. * @param start start value
  17076. * @param end target value
  17077. * @param amount amount to lerp between
  17078. * @returns the lerped value
  17079. */
  17080. static Lerp(start: number, end: number, amount: number): number;
  17081. /**
  17082. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  17083. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  17084. * @param start start value
  17085. * @param end target value
  17086. * @param amount amount to lerp between
  17087. * @returns the lerped value
  17088. */
  17089. static LerpAngle(start: number, end: number, amount: number): number;
  17090. /**
  17091. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  17092. * @param a start value
  17093. * @param b target value
  17094. * @param value value between a and b
  17095. * @returns the inverseLerp value
  17096. */
  17097. static InverseLerp(a: number, b: number, value: number): number;
  17098. /**
  17099. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  17100. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  17101. * @param value1 spline value
  17102. * @param tangent1 spline value
  17103. * @param value2 spline value
  17104. * @param tangent2 spline value
  17105. * @param amount input value
  17106. * @returns hermite result
  17107. */
  17108. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  17109. /**
  17110. * Returns a random float number between and min and max values
  17111. * @param min min value of random
  17112. * @param max max value of random
  17113. * @returns random value
  17114. */
  17115. static RandomRange(min: number, max: number): number;
  17116. /**
  17117. * This function returns percentage of a number in a given range.
  17118. *
  17119. * RangeToPercent(40,20,60) will return 0.5 (50%)
  17120. * RangeToPercent(34,0,100) will return 0.34 (34%)
  17121. * @param number to convert to percentage
  17122. * @param min min range
  17123. * @param max max range
  17124. * @returns the percentage
  17125. */
  17126. static RangeToPercent(number: number, min: number, max: number): number;
  17127. /**
  17128. * This function returns number that corresponds to the percentage in a given range.
  17129. *
  17130. * PercentToRange(0.34,0,100) will return 34.
  17131. * @param percent to convert to number
  17132. * @param min min range
  17133. * @param max max range
  17134. * @returns the number
  17135. */
  17136. static PercentToRange(percent: number, min: number, max: number): number;
  17137. /**
  17138. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  17139. * @param angle The angle to normalize in radian.
  17140. * @return The converted angle.
  17141. */
  17142. static NormalizeRadians(angle: number): number;
  17143. }
  17144. }
  17145. declare module BABYLON {
  17146. /**
  17147. * Constant used to convert a value to gamma space
  17148. * @ignorenaming
  17149. */
  17150. const ToGammaSpace: number;
  17151. /**
  17152. * Constant used to convert a value to linear space
  17153. * @ignorenaming
  17154. */
  17155. const ToLinearSpace = 2.2;
  17156. /**
  17157. * Constant used to define the minimal number value in Babylon.js
  17158. * @ignorenaming
  17159. */
  17160. const Epsilon = 0.001;
  17161. /**
  17162. * Class used to hold a RBG color
  17163. */
  17164. class Color3 {
  17165. /**
  17166. * Defines the red component (between 0 and 1, default is 0)
  17167. */
  17168. r: number;
  17169. /**
  17170. * Defines the green component (between 0 and 1, default is 0)
  17171. */
  17172. g: number;
  17173. /**
  17174. * Defines the blue component (between 0 and 1, default is 0)
  17175. */
  17176. b: number;
  17177. /**
  17178. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  17179. * @param r defines the red component (between 0 and 1, default is 0)
  17180. * @param g defines the green component (between 0 and 1, default is 0)
  17181. * @param b defines the blue component (between 0 and 1, default is 0)
  17182. */
  17183. constructor(
  17184. /**
  17185. * Defines the red component (between 0 and 1, default is 0)
  17186. */
  17187. r?: number,
  17188. /**
  17189. * Defines the green component (between 0 and 1, default is 0)
  17190. */
  17191. g?: number,
  17192. /**
  17193. * Defines the blue component (between 0 and 1, default is 0)
  17194. */
  17195. b?: number);
  17196. /**
  17197. * Creates a string with the Color3 current values
  17198. * @returns the string representation of the Color3 object
  17199. */
  17200. toString(): string;
  17201. /**
  17202. * Returns the string "Color3"
  17203. * @returns "Color3"
  17204. */
  17205. getClassName(): string;
  17206. /**
  17207. * Compute the Color3 hash code
  17208. * @returns an unique number that can be used to hash Color3 objects
  17209. */
  17210. getHashCode(): number;
  17211. /**
  17212. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  17213. * @param array defines the array where to store the r,g,b components
  17214. * @param index defines an optional index in the target array to define where to start storing values
  17215. * @returns the current Color3 object
  17216. */
  17217. toArray(array: FloatArray, index?: number): Color3;
  17218. /**
  17219. * Returns a new Color4 object from the current Color3 and the given alpha
  17220. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  17221. * @returns a new Color4 object
  17222. */
  17223. toColor4(alpha?: number): Color4;
  17224. /**
  17225. * Returns a new array populated with 3 numeric elements : red, green and blue values
  17226. * @returns the new array
  17227. */
  17228. asArray(): number[];
  17229. /**
  17230. * Returns the luminance value
  17231. * @returns a float value
  17232. */
  17233. toLuminance(): number;
  17234. /**
  17235. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  17236. * @param otherColor defines the second operand
  17237. * @returns the new Color3 object
  17238. */
  17239. multiply(otherColor: DeepImmutable<Color3>): Color3;
  17240. /**
  17241. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  17242. * @param otherColor defines the second operand
  17243. * @param result defines the Color3 object where to store the result
  17244. * @returns the current Color3
  17245. */
  17246. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  17247. /**
  17248. * Determines equality between Color3 objects
  17249. * @param otherColor defines the second operand
  17250. * @returns true if the rgb values are equal to the given ones
  17251. */
  17252. equals(otherColor: DeepImmutable<Color3>): boolean;
  17253. /**
  17254. * Determines equality between the current Color3 object and a set of r,b,g values
  17255. * @param r defines the red component to check
  17256. * @param g defines the green component to check
  17257. * @param b defines the blue component to check
  17258. * @returns true if the rgb values are equal to the given ones
  17259. */
  17260. equalsFloats(r: number, g: number, b: number): boolean;
  17261. /**
  17262. * Multiplies in place each rgb value by scale
  17263. * @param scale defines the scaling factor
  17264. * @returns the updated Color3
  17265. */
  17266. scale(scale: number): Color3;
  17267. /**
  17268. * Multiplies the rgb values by scale and stores the result into "result"
  17269. * @param scale defines the scaling factor
  17270. * @param result defines the Color3 object where to store the result
  17271. * @returns the unmodified current Color3
  17272. */
  17273. scaleToRef(scale: number, result: Color3): Color3;
  17274. /**
  17275. * Scale the current Color3 values by a factor and add the result to a given Color3
  17276. * @param scale defines the scale factor
  17277. * @param result defines color to store the result into
  17278. * @returns the unmodified current Color3
  17279. */
  17280. scaleAndAddToRef(scale: number, result: Color3): Color3;
  17281. /**
  17282. * Clamps the rgb values by the min and max values and stores the result into "result"
  17283. * @param min defines minimum clamping value (default is 0)
  17284. * @param max defines maximum clamping value (default is 1)
  17285. * @param result defines color to store the result into
  17286. * @returns the original Color3
  17287. */
  17288. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  17289. /**
  17290. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  17291. * @param otherColor defines the second operand
  17292. * @returns the new Color3
  17293. */
  17294. add(otherColor: DeepImmutable<Color3>): Color3;
  17295. /**
  17296. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  17297. * @param otherColor defines the second operand
  17298. * @param result defines Color3 object to store the result into
  17299. * @returns the unmodified current Color3
  17300. */
  17301. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  17302. /**
  17303. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  17304. * @param otherColor defines the second operand
  17305. * @returns the new Color3
  17306. */
  17307. subtract(otherColor: DeepImmutable<Color3>): Color3;
  17308. /**
  17309. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  17310. * @param otherColor defines the second operand
  17311. * @param result defines Color3 object to store the result into
  17312. * @returns the unmodified current Color3
  17313. */
  17314. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  17315. /**
  17316. * Copy the current object
  17317. * @returns a new Color3 copied the current one
  17318. */
  17319. clone(): Color3;
  17320. /**
  17321. * Copies the rgb values from the source in the current Color3
  17322. * @param source defines the source Color3 object
  17323. * @returns the updated Color3 object
  17324. */
  17325. copyFrom(source: DeepImmutable<Color3>): Color3;
  17326. /**
  17327. * Updates the Color3 rgb values from the given floats
  17328. * @param r defines the red component to read from
  17329. * @param g defines the green component to read from
  17330. * @param b defines the blue component to read from
  17331. * @returns the current Color3 object
  17332. */
  17333. copyFromFloats(r: number, g: number, b: number): Color3;
  17334. /**
  17335. * Updates the Color3 rgb values from the given floats
  17336. * @param r defines the red component to read from
  17337. * @param g defines the green component to read from
  17338. * @param b defines the blue component to read from
  17339. * @returns the current Color3 object
  17340. */
  17341. set(r: number, g: number, b: number): Color3;
  17342. /**
  17343. * Compute the Color3 hexadecimal code as a string
  17344. * @returns a string containing the hexadecimal representation of the Color3 object
  17345. */
  17346. toHexString(): string;
  17347. /**
  17348. * Computes a new Color3 converted from the current one to linear space
  17349. * @returns a new Color3 object
  17350. */
  17351. toLinearSpace(): Color3;
  17352. /**
  17353. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  17354. * @param convertedColor defines the Color3 object where to store the linear space version
  17355. * @returns the unmodified Color3
  17356. */
  17357. toLinearSpaceToRef(convertedColor: Color3): Color3;
  17358. /**
  17359. * Computes a new Color3 converted from the current one to gamma space
  17360. * @returns a new Color3 object
  17361. */
  17362. toGammaSpace(): Color3;
  17363. /**
  17364. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  17365. * @param convertedColor defines the Color3 object where to store the gamma space version
  17366. * @returns the unmodified Color3
  17367. */
  17368. toGammaSpaceToRef(convertedColor: Color3): Color3;
  17369. private static _BlackReadOnly;
  17370. /**
  17371. * Creates a new Color3 from the string containing valid hexadecimal values
  17372. * @param hex defines a string containing valid hexadecimal values
  17373. * @returns a new Color3 object
  17374. */
  17375. static FromHexString(hex: string): Color3;
  17376. /**
  17377. * Creates a new Vector3 from the starting index of the given array
  17378. * @param array defines the source array
  17379. * @param offset defines an offset in the source array
  17380. * @returns a new Color3 object
  17381. */
  17382. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  17383. /**
  17384. * Creates a new Color3 from integer values (< 256)
  17385. * @param r defines the red component to read from (value between 0 and 255)
  17386. * @param g defines the green component to read from (value between 0 and 255)
  17387. * @param b defines the blue component to read from (value between 0 and 255)
  17388. * @returns a new Color3 object
  17389. */
  17390. static FromInts(r: number, g: number, b: number): Color3;
  17391. /**
  17392. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  17393. * @param start defines the start Color3 value
  17394. * @param end defines the end Color3 value
  17395. * @param amount defines the gradient value between start and end
  17396. * @returns a new Color3 object
  17397. */
  17398. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  17399. /**
  17400. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  17401. * @param left defines the start value
  17402. * @param right defines the end value
  17403. * @param amount defines the gradient factor
  17404. * @param result defines the Color3 object where to store the result
  17405. */
  17406. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  17407. /**
  17408. * Returns a Color3 value containing a red color
  17409. * @returns a new Color3 object
  17410. */
  17411. static Red(): Color3;
  17412. /**
  17413. * Returns a Color3 value containing a green color
  17414. * @returns a new Color3 object
  17415. */
  17416. static Green(): Color3;
  17417. /**
  17418. * Returns a Color3 value containing a blue color
  17419. * @returns a new Color3 object
  17420. */
  17421. static Blue(): Color3;
  17422. /**
  17423. * Returns a Color3 value containing a black color
  17424. * @returns a new Color3 object
  17425. */
  17426. static Black(): Color3;
  17427. /**
  17428. * Gets a Color3 value containing a black color that must not be updated
  17429. */
  17430. static readonly BlackReadOnly: DeepImmutable<Color3>;
  17431. /**
  17432. * Returns a Color3 value containing a white color
  17433. * @returns a new Color3 object
  17434. */
  17435. static White(): Color3;
  17436. /**
  17437. * Returns a Color3 value containing a purple color
  17438. * @returns a new Color3 object
  17439. */
  17440. static Purple(): Color3;
  17441. /**
  17442. * Returns a Color3 value containing a magenta color
  17443. * @returns a new Color3 object
  17444. */
  17445. static Magenta(): Color3;
  17446. /**
  17447. * Returns a Color3 value containing a yellow color
  17448. * @returns a new Color3 object
  17449. */
  17450. static Yellow(): Color3;
  17451. /**
  17452. * Returns a Color3 value containing a gray color
  17453. * @returns a new Color3 object
  17454. */
  17455. static Gray(): Color3;
  17456. /**
  17457. * Returns a Color3 value containing a teal color
  17458. * @returns a new Color3 object
  17459. */
  17460. static Teal(): Color3;
  17461. /**
  17462. * Returns a Color3 value containing a random color
  17463. * @returns a new Color3 object
  17464. */
  17465. static Random(): Color3;
  17466. }
  17467. /**
  17468. * Class used to hold a RBGA color
  17469. */
  17470. class Color4 {
  17471. /**
  17472. * Defines the red component (between 0 and 1, default is 0)
  17473. */
  17474. r: number;
  17475. /**
  17476. * Defines the green component (between 0 and 1, default is 0)
  17477. */
  17478. g: number;
  17479. /**
  17480. * Defines the blue component (between 0 and 1, default is 0)
  17481. */
  17482. b: number;
  17483. /**
  17484. * Defines the alpha component (between 0 and 1, default is 1)
  17485. */
  17486. a: number;
  17487. /**
  17488. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  17489. * @param r defines the red component (between 0 and 1, default is 0)
  17490. * @param g defines the green component (between 0 and 1, default is 0)
  17491. * @param b defines the blue component (between 0 and 1, default is 0)
  17492. * @param a defines the alpha component (between 0 and 1, default is 1)
  17493. */
  17494. constructor(
  17495. /**
  17496. * Defines the red component (between 0 and 1, default is 0)
  17497. */
  17498. r?: number,
  17499. /**
  17500. * Defines the green component (between 0 and 1, default is 0)
  17501. */
  17502. g?: number,
  17503. /**
  17504. * Defines the blue component (between 0 and 1, default is 0)
  17505. */
  17506. b?: number,
  17507. /**
  17508. * Defines the alpha component (between 0 and 1, default is 1)
  17509. */
  17510. a?: number);
  17511. /**
  17512. * Adds in place the given Color4 values to the current Color4 object
  17513. * @param right defines the second operand
  17514. * @returns the current updated Color4 object
  17515. */
  17516. addInPlace(right: DeepImmutable<Color4>): Color4;
  17517. /**
  17518. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  17519. * @returns the new array
  17520. */
  17521. asArray(): number[];
  17522. /**
  17523. * Stores from the starting index in the given array the Color4 successive values
  17524. * @param array defines the array where to store the r,g,b components
  17525. * @param index defines an optional index in the target array to define where to start storing values
  17526. * @returns the current Color4 object
  17527. */
  17528. toArray(array: number[], index?: number): Color4;
  17529. /**
  17530. * Determines equality between Color4 objects
  17531. * @param otherColor defines the second operand
  17532. * @returns true if the rgba values are equal to the given ones
  17533. */
  17534. equals(otherColor: DeepImmutable<Color4>): boolean;
  17535. /**
  17536. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  17537. * @param right defines the second operand
  17538. * @returns a new Color4 object
  17539. */
  17540. add(right: DeepImmutable<Color4>): Color4;
  17541. /**
  17542. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  17543. * @param right defines the second operand
  17544. * @returns a new Color4 object
  17545. */
  17546. subtract(right: DeepImmutable<Color4>): Color4;
  17547. /**
  17548. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  17549. * @param right defines the second operand
  17550. * @param result defines the Color4 object where to store the result
  17551. * @returns the current Color4 object
  17552. */
  17553. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  17554. /**
  17555. * Creates a new Color4 with the current Color4 values multiplied by scale
  17556. * @param scale defines the scaling factor to apply
  17557. * @returns a new Color4 object
  17558. */
  17559. scale(scale: number): Color4;
  17560. /**
  17561. * Multiplies the current Color4 values by scale and stores the result in "result"
  17562. * @param scale defines the scaling factor to apply
  17563. * @param result defines the Color4 object where to store the result
  17564. * @returns the current unmodified Color4
  17565. */
  17566. scaleToRef(scale: number, result: Color4): Color4;
  17567. /**
  17568. * Scale the current Color4 values by a factor and add the result to a given Color4
  17569. * @param scale defines the scale factor
  17570. * @param result defines the Color4 object where to store the result
  17571. * @returns the unmodified current Color4
  17572. */
  17573. scaleAndAddToRef(scale: number, result: Color4): Color4;
  17574. /**
  17575. * Clamps the rgb values by the min and max values and stores the result into "result"
  17576. * @param min defines minimum clamping value (default is 0)
  17577. * @param max defines maximum clamping value (default is 1)
  17578. * @param result defines color to store the result into.
  17579. * @returns the cuurent Color4
  17580. */
  17581. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  17582. /**
  17583. * Multipy an Color4 value by another and return a new Color4 object
  17584. * @param color defines the Color4 value to multiply by
  17585. * @returns a new Color4 object
  17586. */
  17587. multiply(color: Color4): Color4;
  17588. /**
  17589. * Multipy a Color4 value by another and push the result in a reference value
  17590. * @param color defines the Color4 value to multiply by
  17591. * @param result defines the Color4 to fill the result in
  17592. * @returns the result Color4
  17593. */
  17594. multiplyToRef(color: Color4, result: Color4): Color4;
  17595. /**
  17596. * Creates a string with the Color4 current values
  17597. * @returns the string representation of the Color4 object
  17598. */
  17599. toString(): string;
  17600. /**
  17601. * Returns the string "Color4"
  17602. * @returns "Color4"
  17603. */
  17604. getClassName(): string;
  17605. /**
  17606. * Compute the Color4 hash code
  17607. * @returns an unique number that can be used to hash Color4 objects
  17608. */
  17609. getHashCode(): number;
  17610. /**
  17611. * Creates a new Color4 copied from the current one
  17612. * @returns a new Color4 object
  17613. */
  17614. clone(): Color4;
  17615. /**
  17616. * Copies the given Color4 values into the current one
  17617. * @param source defines the source Color4 object
  17618. * @returns the current updated Color4 object
  17619. */
  17620. copyFrom(source: Color4): Color4;
  17621. /**
  17622. * Copies the given float values into the current one
  17623. * @param r defines the red component to read from
  17624. * @param g defines the green component to read from
  17625. * @param b defines the blue component to read from
  17626. * @param a defines the alpha component to read from
  17627. * @returns the current updated Color4 object
  17628. */
  17629. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  17630. /**
  17631. * Copies the given float values into the current one
  17632. * @param r defines the red component to read from
  17633. * @param g defines the green component to read from
  17634. * @param b defines the blue component to read from
  17635. * @param a defines the alpha component to read from
  17636. * @returns the current updated Color4 object
  17637. */
  17638. set(r: number, g: number, b: number, a: number): Color4;
  17639. /**
  17640. * Compute the Color4 hexadecimal code as a string
  17641. * @returns a string containing the hexadecimal representation of the Color4 object
  17642. */
  17643. toHexString(): string;
  17644. /**
  17645. * Computes a new Color4 converted from the current one to linear space
  17646. * @returns a new Color4 object
  17647. */
  17648. toLinearSpace(): Color4;
  17649. /**
  17650. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  17651. * @param convertedColor defines the Color4 object where to store the linear space version
  17652. * @returns the unmodified Color4
  17653. */
  17654. toLinearSpaceToRef(convertedColor: Color4): Color4;
  17655. /**
  17656. * Computes a new Color4 converted from the current one to gamma space
  17657. * @returns a new Color4 object
  17658. */
  17659. toGammaSpace(): Color4;
  17660. /**
  17661. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  17662. * @param convertedColor defines the Color4 object where to store the gamma space version
  17663. * @returns the unmodified Color4
  17664. */
  17665. toGammaSpaceToRef(convertedColor: Color4): Color4;
  17666. /**
  17667. * Creates a new Color4 from the string containing valid hexadecimal values
  17668. * @param hex defines a string containing valid hexadecimal values
  17669. * @returns a new Color4 object
  17670. */
  17671. static FromHexString(hex: string): Color4;
  17672. /**
  17673. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  17674. * @param left defines the start value
  17675. * @param right defines the end value
  17676. * @param amount defines the gradient factor
  17677. * @returns a new Color4 object
  17678. */
  17679. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  17680. /**
  17681. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  17682. * @param left defines the start value
  17683. * @param right defines the end value
  17684. * @param amount defines the gradient factor
  17685. * @param result defines the Color4 object where to store data
  17686. */
  17687. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  17688. /**
  17689. * Creates a new Color4 from a Color3 and an alpha value
  17690. * @param color3 defines the source Color3 to read from
  17691. * @param alpha defines the alpha component (1.0 by default)
  17692. * @returns a new Color4 object
  17693. */
  17694. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  17695. /**
  17696. * Creates a new Color4 from the starting index element of the given array
  17697. * @param array defines the source array to read from
  17698. * @param offset defines the offset in the source array
  17699. * @returns a new Color4 object
  17700. */
  17701. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  17702. /**
  17703. * Creates a new Color3 from integer values (< 256)
  17704. * @param r defines the red component to read from (value between 0 and 255)
  17705. * @param g defines the green component to read from (value between 0 and 255)
  17706. * @param b defines the blue component to read from (value between 0 and 255)
  17707. * @param a defines the alpha component to read from (value between 0 and 255)
  17708. * @returns a new Color3 object
  17709. */
  17710. static FromInts(r: number, g: number, b: number, a: number): Color4;
  17711. /**
  17712. * Check the content of a given array and convert it to an array containing RGBA data
  17713. * If the original array was already containing count * 4 values then it is returned directly
  17714. * @param colors defines the array to check
  17715. * @param count defines the number of RGBA data to expect
  17716. * @returns an array containing count * 4 values (RGBA)
  17717. */
  17718. static CheckColors4(colors: number[], count: number): number[];
  17719. }
  17720. /**
  17721. * Class representing a vector containing 2 coordinates
  17722. */
  17723. class Vector2 {
  17724. /** defines the first coordinate */
  17725. x: number;
  17726. /** defines the second coordinate */
  17727. y: number;
  17728. /**
  17729. * Creates a new Vector2 from the given x and y coordinates
  17730. * @param x defines the first coordinate
  17731. * @param y defines the second coordinate
  17732. */
  17733. constructor(
  17734. /** defines the first coordinate */
  17735. x?: number,
  17736. /** defines the second coordinate */
  17737. y?: number);
  17738. /**
  17739. * Gets a string with the Vector2 coordinates
  17740. * @returns a string with the Vector2 coordinates
  17741. */
  17742. toString(): string;
  17743. /**
  17744. * Gets class name
  17745. * @returns the string "Vector2"
  17746. */
  17747. getClassName(): string;
  17748. /**
  17749. * Gets current vector hash code
  17750. * @returns the Vector2 hash code as a number
  17751. */
  17752. getHashCode(): number;
  17753. /**
  17754. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  17755. * @param array defines the source array
  17756. * @param index defines the offset in source array
  17757. * @returns the current Vector2
  17758. */
  17759. toArray(array: FloatArray, index?: number): Vector2;
  17760. /**
  17761. * Copy the current vector to an array
  17762. * @returns a new array with 2 elements: the Vector2 coordinates.
  17763. */
  17764. asArray(): number[];
  17765. /**
  17766. * Sets the Vector2 coordinates with the given Vector2 coordinates
  17767. * @param source defines the source Vector2
  17768. * @returns the current updated Vector2
  17769. */
  17770. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  17771. /**
  17772. * Sets the Vector2 coordinates with the given floats
  17773. * @param x defines the first coordinate
  17774. * @param y defines the second coordinate
  17775. * @returns the current updated Vector2
  17776. */
  17777. copyFromFloats(x: number, y: number): Vector2;
  17778. /**
  17779. * Sets the Vector2 coordinates with the given floats
  17780. * @param x defines the first coordinate
  17781. * @param y defines the second coordinate
  17782. * @returns the current updated Vector2
  17783. */
  17784. set(x: number, y: number): Vector2;
  17785. /**
  17786. * Add another vector with the current one
  17787. * @param otherVector defines the other vector
  17788. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  17789. */
  17790. add(otherVector: DeepImmutable<Vector2>): Vector2;
  17791. /**
  17792. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  17793. * @param otherVector defines the other vector
  17794. * @param result defines the target vector
  17795. * @returns the unmodified current Vector2
  17796. */
  17797. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  17798. /**
  17799. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  17800. * @param otherVector defines the other vector
  17801. * @returns the current updated Vector2
  17802. */
  17803. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  17804. /**
  17805. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  17806. * @param otherVector defines the other vector
  17807. * @returns a new Vector2
  17808. */
  17809. addVector3(otherVector: Vector3): Vector2;
  17810. /**
  17811. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  17812. * @param otherVector defines the other vector
  17813. * @returns a new Vector2
  17814. */
  17815. subtract(otherVector: Vector2): Vector2;
  17816. /**
  17817. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  17818. * @param otherVector defines the other vector
  17819. * @param result defines the target vector
  17820. * @returns the unmodified current Vector2
  17821. */
  17822. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  17823. /**
  17824. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  17825. * @param otherVector defines the other vector
  17826. * @returns the current updated Vector2
  17827. */
  17828. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  17829. /**
  17830. * Multiplies in place the current Vector2 coordinates by the given ones
  17831. * @param otherVector defines the other vector
  17832. * @returns the current updated Vector2
  17833. */
  17834. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  17835. /**
  17836. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  17837. * @param otherVector defines the other vector
  17838. * @returns a new Vector2
  17839. */
  17840. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  17841. /**
  17842. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  17843. * @param otherVector defines the other vector
  17844. * @param result defines the target vector
  17845. * @returns the unmodified current Vector2
  17846. */
  17847. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  17848. /**
  17849. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  17850. * @param x defines the first coordinate
  17851. * @param y defines the second coordinate
  17852. * @returns a new Vector2
  17853. */
  17854. multiplyByFloats(x: number, y: number): Vector2;
  17855. /**
  17856. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  17857. * @param otherVector defines the other vector
  17858. * @returns a new Vector2
  17859. */
  17860. divide(otherVector: Vector2): Vector2;
  17861. /**
  17862. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  17863. * @param otherVector defines the other vector
  17864. * @param result defines the target vector
  17865. * @returns the unmodified current Vector2
  17866. */
  17867. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  17868. /**
  17869. * Divides the current Vector2 coordinates by the given ones
  17870. * @param otherVector defines the other vector
  17871. * @returns the current updated Vector2
  17872. */
  17873. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  17874. /**
  17875. * Gets a new Vector2 with current Vector2 negated coordinates
  17876. * @returns a new Vector2
  17877. */
  17878. negate(): Vector2;
  17879. /**
  17880. * Multiply the Vector2 coordinates by scale
  17881. * @param scale defines the scaling factor
  17882. * @returns the current updated Vector2
  17883. */
  17884. scaleInPlace(scale: number): Vector2;
  17885. /**
  17886. * Returns a new Vector2 scaled by "scale" from the current Vector2
  17887. * @param scale defines the scaling factor
  17888. * @returns a new Vector2
  17889. */
  17890. scale(scale: number): Vector2;
  17891. /**
  17892. * Scale the current Vector2 values by a factor to a given Vector2
  17893. * @param scale defines the scale factor
  17894. * @param result defines the Vector2 object where to store the result
  17895. * @returns the unmodified current Vector2
  17896. */
  17897. scaleToRef(scale: number, result: Vector2): Vector2;
  17898. /**
  17899. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  17900. * @param scale defines the scale factor
  17901. * @param result defines the Vector2 object where to store the result
  17902. * @returns the unmodified current Vector2
  17903. */
  17904. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  17905. /**
  17906. * Gets a boolean if two vectors are equals
  17907. * @param otherVector defines the other vector
  17908. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  17909. */
  17910. equals(otherVector: DeepImmutable<Vector2>): boolean;
  17911. /**
  17912. * Gets a boolean if two vectors are equals (using an epsilon value)
  17913. * @param otherVector defines the other vector
  17914. * @param epsilon defines the minimal distance to consider equality
  17915. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  17916. */
  17917. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  17918. /**
  17919. * Gets a new Vector2 from current Vector2 floored values
  17920. * @returns a new Vector2
  17921. */
  17922. floor(): Vector2;
  17923. /**
  17924. * Gets a new Vector2 from current Vector2 floored values
  17925. * @returns a new Vector2
  17926. */
  17927. fract(): Vector2;
  17928. /**
  17929. * Gets the length of the vector
  17930. * @returns the vector length (float)
  17931. */
  17932. length(): number;
  17933. /**
  17934. * Gets the vector squared length
  17935. * @returns the vector squared length (float)
  17936. */
  17937. lengthSquared(): number;
  17938. /**
  17939. * Normalize the vector
  17940. * @returns the current updated Vector2
  17941. */
  17942. normalize(): Vector2;
  17943. /**
  17944. * Gets a new Vector2 copied from the Vector2
  17945. * @returns a new Vector2
  17946. */
  17947. clone(): Vector2;
  17948. /**
  17949. * Gets a new Vector2(0, 0)
  17950. * @returns a new Vector2
  17951. */
  17952. static Zero(): Vector2;
  17953. /**
  17954. * Gets a new Vector2(1, 1)
  17955. * @returns a new Vector2
  17956. */
  17957. static One(): Vector2;
  17958. /**
  17959. * Gets a new Vector2 set from the given index element of the given array
  17960. * @param array defines the data source
  17961. * @param offset defines the offset in the data source
  17962. * @returns a new Vector2
  17963. */
  17964. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  17965. /**
  17966. * Sets "result" from the given index element of the given array
  17967. * @param array defines the data source
  17968. * @param offset defines the offset in the data source
  17969. * @param result defines the target vector
  17970. */
  17971. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  17972. /**
  17973. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  17974. * @param value1 defines 1st point of control
  17975. * @param value2 defines 2nd point of control
  17976. * @param value3 defines 3rd point of control
  17977. * @param value4 defines 4th point of control
  17978. * @param amount defines the interpolation factor
  17979. * @returns a new Vector2
  17980. */
  17981. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  17982. /**
  17983. * 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".
  17984. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  17985. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  17986. * @param value defines the value to clamp
  17987. * @param min defines the lower limit
  17988. * @param max defines the upper limit
  17989. * @returns a new Vector2
  17990. */
  17991. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  17992. /**
  17993. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  17994. * @param value1 defines the 1st control point
  17995. * @param tangent1 defines the outgoing tangent
  17996. * @param value2 defines the 2nd control point
  17997. * @param tangent2 defines the incoming tangent
  17998. * @param amount defines the interpolation factor
  17999. * @returns a new Vector2
  18000. */
  18001. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  18002. /**
  18003. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  18004. * @param start defines the start vector
  18005. * @param end defines the end vector
  18006. * @param amount defines the interpolation factor
  18007. * @returns a new Vector2
  18008. */
  18009. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  18010. /**
  18011. * Gets the dot product of the vector "left" and the vector "right"
  18012. * @param left defines first vector
  18013. * @param right defines second vector
  18014. * @returns the dot product (float)
  18015. */
  18016. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  18017. /**
  18018. * Returns a new Vector2 equal to the normalized given vector
  18019. * @param vector defines the vector to normalize
  18020. * @returns a new Vector2
  18021. */
  18022. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  18023. /**
  18024. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  18025. * @param left defines 1st vector
  18026. * @param right defines 2nd vector
  18027. * @returns a new Vector2
  18028. */
  18029. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  18030. /**
  18031. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  18032. * @param left defines 1st vector
  18033. * @param right defines 2nd vector
  18034. * @returns a new Vector2
  18035. */
  18036. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  18037. /**
  18038. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  18039. * @param vector defines the vector to transform
  18040. * @param transformation defines the matrix to apply
  18041. * @returns a new Vector2
  18042. */
  18043. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  18044. /**
  18045. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  18046. * @param vector defines the vector to transform
  18047. * @param transformation defines the matrix to apply
  18048. * @param result defines the target vector
  18049. */
  18050. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  18051. /**
  18052. * Determines if a given vector is included in a triangle
  18053. * @param p defines the vector to test
  18054. * @param p0 defines 1st triangle point
  18055. * @param p1 defines 2nd triangle point
  18056. * @param p2 defines 3rd triangle point
  18057. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  18058. */
  18059. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  18060. /**
  18061. * Gets the distance between the vectors "value1" and "value2"
  18062. * @param value1 defines first vector
  18063. * @param value2 defines second vector
  18064. * @returns the distance between vectors
  18065. */
  18066. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  18067. /**
  18068. * Returns the squared distance between the vectors "value1" and "value2"
  18069. * @param value1 defines first vector
  18070. * @param value2 defines second vector
  18071. * @returns the squared distance between vectors
  18072. */
  18073. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  18074. /**
  18075. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  18076. * @param value1 defines first vector
  18077. * @param value2 defines second vector
  18078. * @returns a new Vector2
  18079. */
  18080. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  18081. /**
  18082. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  18083. * @param p defines the middle point
  18084. * @param segA defines one point of the segment
  18085. * @param segB defines the other point of the segment
  18086. * @returns the shortest distance
  18087. */
  18088. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  18089. }
  18090. /**
  18091. * Classed used to store (x,y,z) vector representation
  18092. * A Vector3 is the main object used in 3D geometry
  18093. * It can represent etiher the coordinates of a point the space, either a direction
  18094. * Reminder: Babylon.js uses a left handed forward facing system
  18095. */
  18096. class Vector3 {
  18097. /**
  18098. * Defines the first coordinates (on X axis)
  18099. */
  18100. x: number;
  18101. /**
  18102. * Defines the second coordinates (on Y axis)
  18103. */
  18104. y: number;
  18105. /**
  18106. * Defines the third coordinates (on Z axis)
  18107. */
  18108. z: number;
  18109. private static _UpReadOnly;
  18110. /**
  18111. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  18112. * @param x defines the first coordinates (on X axis)
  18113. * @param y defines the second coordinates (on Y axis)
  18114. * @param z defines the third coordinates (on Z axis)
  18115. */
  18116. constructor(
  18117. /**
  18118. * Defines the first coordinates (on X axis)
  18119. */
  18120. x?: number,
  18121. /**
  18122. * Defines the second coordinates (on Y axis)
  18123. */
  18124. y?: number,
  18125. /**
  18126. * Defines the third coordinates (on Z axis)
  18127. */
  18128. z?: number);
  18129. /**
  18130. * Creates a string representation of the Vector3
  18131. * @returns a string with the Vector3 coordinates.
  18132. */
  18133. toString(): string;
  18134. /**
  18135. * Gets the class name
  18136. * @returns the string "Vector3"
  18137. */
  18138. getClassName(): string;
  18139. /**
  18140. * Creates the Vector3 hash code
  18141. * @returns a number which tends to be unique between Vector3 instances
  18142. */
  18143. getHashCode(): number;
  18144. /**
  18145. * Creates an array containing three elements : the coordinates of the Vector3
  18146. * @returns a new array of numbers
  18147. */
  18148. asArray(): number[];
  18149. /**
  18150. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  18151. * @param array defines the destination array
  18152. * @param index defines the offset in the destination array
  18153. * @returns the current Vector3
  18154. */
  18155. toArray(array: FloatArray, index?: number): Vector3;
  18156. /**
  18157. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  18158. * @returns a new Quaternion object, computed from the Vector3 coordinates
  18159. */
  18160. toQuaternion(): Quaternion;
  18161. /**
  18162. * Adds the given vector to the current Vector3
  18163. * @param otherVector defines the second operand
  18164. * @returns the current updated Vector3
  18165. */
  18166. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  18167. /**
  18168. * Adds the given coordinates to the current Vector3
  18169. * @param x defines the x coordinate of the operand
  18170. * @param y defines the y coordinate of the operand
  18171. * @param z defines the z coordinate of the operand
  18172. * @returns the current updated Vector3
  18173. */
  18174. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  18175. /**
  18176. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  18177. * @param otherVector defines the second operand
  18178. * @returns the resulting Vector3
  18179. */
  18180. add(otherVector: DeepImmutable<Vector3>): Vector3;
  18181. /**
  18182. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  18183. * @param otherVector defines the second operand
  18184. * @param result defines the Vector3 object where to store the result
  18185. * @returns the current Vector3
  18186. */
  18187. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  18188. /**
  18189. * Subtract the given vector from the current Vector3
  18190. * @param otherVector defines the second operand
  18191. * @returns the current updated Vector3
  18192. */
  18193. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  18194. /**
  18195. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  18196. * @param otherVector defines the second operand
  18197. * @returns the resulting Vector3
  18198. */
  18199. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  18200. /**
  18201. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  18202. * @param otherVector defines the second operand
  18203. * @param result defines the Vector3 object where to store the result
  18204. * @returns the current Vector3
  18205. */
  18206. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  18207. /**
  18208. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  18209. * @param x defines the x coordinate of the operand
  18210. * @param y defines the y coordinate of the operand
  18211. * @param z defines the z coordinate of the operand
  18212. * @returns the resulting Vector3
  18213. */
  18214. subtractFromFloats(x: number, y: number, z: number): Vector3;
  18215. /**
  18216. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  18217. * @param x defines the x coordinate of the operand
  18218. * @param y defines the y coordinate of the operand
  18219. * @param z defines the z coordinate of the operand
  18220. * @param result defines the Vector3 object where to store the result
  18221. * @returns the current Vector3
  18222. */
  18223. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  18224. /**
  18225. * Gets a new Vector3 set with the current Vector3 negated coordinates
  18226. * @returns a new Vector3
  18227. */
  18228. negate(): Vector3;
  18229. /**
  18230. * Multiplies the Vector3 coordinates by the float "scale"
  18231. * @param scale defines the multiplier factor
  18232. * @returns the current updated Vector3
  18233. */
  18234. scaleInPlace(scale: number): Vector3;
  18235. /**
  18236. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  18237. * @param scale defines the multiplier factor
  18238. * @returns a new Vector3
  18239. */
  18240. scale(scale: number): Vector3;
  18241. /**
  18242. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  18243. * @param scale defines the multiplier factor
  18244. * @param result defines the Vector3 object where to store the result
  18245. * @returns the current Vector3
  18246. */
  18247. scaleToRef(scale: number, result: Vector3): Vector3;
  18248. /**
  18249. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  18250. * @param scale defines the scale factor
  18251. * @param result defines the Vector3 object where to store the result
  18252. * @returns the unmodified current Vector3
  18253. */
  18254. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  18255. /**
  18256. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  18257. * @param otherVector defines the second operand
  18258. * @returns true if both vectors are equals
  18259. */
  18260. equals(otherVector: DeepImmutable<Vector3>): boolean;
  18261. /**
  18262. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  18263. * @param otherVector defines the second operand
  18264. * @param epsilon defines the minimal distance to define values as equals
  18265. * @returns true if both vectors are distant less than epsilon
  18266. */
  18267. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  18268. /**
  18269. * Returns true if the current Vector3 coordinates equals the given floats
  18270. * @param x defines the x coordinate of the operand
  18271. * @param y defines the y coordinate of the operand
  18272. * @param z defines the z coordinate of the operand
  18273. * @returns true if both vectors are equals
  18274. */
  18275. equalsToFloats(x: number, y: number, z: number): boolean;
  18276. /**
  18277. * Multiplies the current Vector3 coordinates by the given ones
  18278. * @param otherVector defines the second operand
  18279. * @returns the current updated Vector3
  18280. */
  18281. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  18282. /**
  18283. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  18284. * @param otherVector defines the second operand
  18285. * @returns the new Vector3
  18286. */
  18287. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  18288. /**
  18289. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  18290. * @param otherVector defines the second operand
  18291. * @param result defines the Vector3 object where to store the result
  18292. * @returns the current Vector3
  18293. */
  18294. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  18295. /**
  18296. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  18297. * @param x defines the x coordinate of the operand
  18298. * @param y defines the y coordinate of the operand
  18299. * @param z defines the z coordinate of the operand
  18300. * @returns the new Vector3
  18301. */
  18302. multiplyByFloats(x: number, y: number, z: number): Vector3;
  18303. /**
  18304. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  18305. * @param otherVector defines the second operand
  18306. * @returns the new Vector3
  18307. */
  18308. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  18309. /**
  18310. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  18311. * @param otherVector defines the second operand
  18312. * @param result defines the Vector3 object where to store the result
  18313. * @returns the current Vector3
  18314. */
  18315. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  18316. /**
  18317. * Divides the current Vector3 coordinates by the given ones.
  18318. * @param otherVector defines the second operand
  18319. * @returns the current updated Vector3
  18320. */
  18321. divideInPlace(otherVector: Vector3): Vector3;
  18322. /**
  18323. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  18324. * @param other defines the second operand
  18325. * @returns the current updated Vector3
  18326. */
  18327. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  18328. /**
  18329. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  18330. * @param other defines the second operand
  18331. * @returns the current updated Vector3
  18332. */
  18333. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  18334. /**
  18335. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  18336. * @param x defines the x coordinate of the operand
  18337. * @param y defines the y coordinate of the operand
  18338. * @param z defines the z coordinate of the operand
  18339. * @returns the current updated Vector3
  18340. */
  18341. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  18342. /**
  18343. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  18344. * @param x defines the x coordinate of the operand
  18345. * @param y defines the y coordinate of the operand
  18346. * @param z defines the z coordinate of the operand
  18347. * @returns the current updated Vector3
  18348. */
  18349. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  18350. /**
  18351. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  18352. */
  18353. readonly isNonUniform: boolean;
  18354. /**
  18355. * Gets a new Vector3 from current Vector3 floored values
  18356. * @returns a new Vector3
  18357. */
  18358. floor(): Vector3;
  18359. /**
  18360. * Gets a new Vector3 from current Vector3 floored values
  18361. * @returns a new Vector3
  18362. */
  18363. fract(): Vector3;
  18364. /**
  18365. * Gets the length of the Vector3
  18366. * @returns the length of the Vecto3
  18367. */
  18368. length(): number;
  18369. /**
  18370. * Gets the squared length of the Vector3
  18371. * @returns squared length of the Vector3
  18372. */
  18373. lengthSquared(): number;
  18374. /**
  18375. * Normalize the current Vector3.
  18376. * Please note that this is an in place operation.
  18377. * @returns the current updated Vector3
  18378. */
  18379. normalize(): Vector3;
  18380. /**
  18381. * Reorders the x y z properties of the vector in place
  18382. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  18383. * @returns the current updated vector
  18384. */
  18385. reorderInPlace(order: string): this;
  18386. /**
  18387. * Rotates the vector around 0,0,0 by a quaternion
  18388. * @param quaternion the rotation quaternion
  18389. * @param result vector to store the result
  18390. * @returns the resulting vector
  18391. */
  18392. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  18393. /**
  18394. * Rotates a vector around a given point
  18395. * @param quaternion the rotation quaternion
  18396. * @param point the point to rotate around
  18397. * @param result vector to store the result
  18398. * @returns the resulting vector
  18399. */
  18400. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  18401. /**
  18402. * Normalize the current Vector3 with the given input length.
  18403. * Please note that this is an in place operation.
  18404. * @param len the length of the vector
  18405. * @returns the current updated Vector3
  18406. */
  18407. normalizeFromLength(len: number): Vector3;
  18408. /**
  18409. * Normalize the current Vector3 to a new vector
  18410. * @returns the new Vector3
  18411. */
  18412. normalizeToNew(): Vector3;
  18413. /**
  18414. * Normalize the current Vector3 to the reference
  18415. * @param reference define the Vector3 to update
  18416. * @returns the updated Vector3
  18417. */
  18418. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  18419. /**
  18420. * Creates a new Vector3 copied from the current Vector3
  18421. * @returns the new Vector3
  18422. */
  18423. clone(): Vector3;
  18424. /**
  18425. * Copies the given vector coordinates to the current Vector3 ones
  18426. * @param source defines the source Vector3
  18427. * @returns the current updated Vector3
  18428. */
  18429. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  18430. /**
  18431. * Copies the given floats to the current Vector3 coordinates
  18432. * @param x defines the x coordinate of the operand
  18433. * @param y defines the y coordinate of the operand
  18434. * @param z defines the z coordinate of the operand
  18435. * @returns the current updated Vector3
  18436. */
  18437. copyFromFloats(x: number, y: number, z: number): Vector3;
  18438. /**
  18439. * Copies the given floats to the current Vector3 coordinates
  18440. * @param x defines the x coordinate of the operand
  18441. * @param y defines the y coordinate of the operand
  18442. * @param z defines the z coordinate of the operand
  18443. * @returns the current updated Vector3
  18444. */
  18445. set(x: number, y: number, z: number): Vector3;
  18446. /**
  18447. * Copies the given float to the current Vector3 coordinates
  18448. * @param v defines the x, y and z coordinates of the operand
  18449. * @returns the current updated Vector3
  18450. */
  18451. setAll(v: number): Vector3;
  18452. /**
  18453. * Get the clip factor between two vectors
  18454. * @param vector0 defines the first operand
  18455. * @param vector1 defines the second operand
  18456. * @param axis defines the axis to use
  18457. * @param size defines the size along the axis
  18458. * @returns the clip factor
  18459. */
  18460. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  18461. /**
  18462. * Get angle between two vectors
  18463. * @param vector0 angle between vector0 and vector1
  18464. * @param vector1 angle between vector0 and vector1
  18465. * @param normal direction of the normal
  18466. * @return the angle between vector0 and vector1
  18467. */
  18468. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  18469. /**
  18470. * Returns a new Vector3 set from the index "offset" of the given array
  18471. * @param array defines the source array
  18472. * @param offset defines the offset in the source array
  18473. * @returns the new Vector3
  18474. */
  18475. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  18476. /**
  18477. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  18478. * This function is deprecated. Use FromArray instead
  18479. * @param array defines the source array
  18480. * @param offset defines the offset in the source array
  18481. * @returns the new Vector3
  18482. */
  18483. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  18484. /**
  18485. * Sets the given vector "result" with the element values from the index "offset" of the given array
  18486. * @param array defines the source array
  18487. * @param offset defines the offset in the source array
  18488. * @param result defines the Vector3 where to store the result
  18489. */
  18490. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  18491. /**
  18492. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  18493. * This function is deprecated. Use FromArrayToRef instead.
  18494. * @param array defines the source array
  18495. * @param offset defines the offset in the source array
  18496. * @param result defines the Vector3 where to store the result
  18497. */
  18498. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  18499. /**
  18500. * Sets the given vector "result" with the given floats.
  18501. * @param x defines the x coordinate of the source
  18502. * @param y defines the y coordinate of the source
  18503. * @param z defines the z coordinate of the source
  18504. * @param result defines the Vector3 where to store the result
  18505. */
  18506. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  18507. /**
  18508. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  18509. * @returns a new empty Vector3
  18510. */
  18511. static Zero(): Vector3;
  18512. /**
  18513. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  18514. * @returns a new unit Vector3
  18515. */
  18516. static One(): Vector3;
  18517. /**
  18518. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  18519. * @returns a new up Vector3
  18520. */
  18521. static Up(): Vector3;
  18522. /**
  18523. * Gets a up Vector3 that must not be updated
  18524. */
  18525. static readonly UpReadOnly: DeepImmutable<Vector3>;
  18526. /**
  18527. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  18528. * @returns a new down Vector3
  18529. */
  18530. static Down(): Vector3;
  18531. /**
  18532. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  18533. * @returns a new forward Vector3
  18534. */
  18535. static Forward(): Vector3;
  18536. /**
  18537. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  18538. * @returns a new forward Vector3
  18539. */
  18540. static Backward(): Vector3;
  18541. /**
  18542. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  18543. * @returns a new right Vector3
  18544. */
  18545. static Right(): Vector3;
  18546. /**
  18547. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  18548. * @returns a new left Vector3
  18549. */
  18550. static Left(): Vector3;
  18551. /**
  18552. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  18553. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  18554. * @param vector defines the Vector3 to transform
  18555. * @param transformation defines the transformation matrix
  18556. * @returns the transformed Vector3
  18557. */
  18558. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  18559. /**
  18560. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  18561. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  18562. * @param vector defines the Vector3 to transform
  18563. * @param transformation defines the transformation matrix
  18564. * @param result defines the Vector3 where to store the result
  18565. */
  18566. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  18567. /**
  18568. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  18569. * This method computes tranformed coordinates only, not transformed direction vectors
  18570. * @param x define the x coordinate of the source vector
  18571. * @param y define the y coordinate of the source vector
  18572. * @param z define the z coordinate of the source vector
  18573. * @param transformation defines the transformation matrix
  18574. * @param result defines the Vector3 where to store the result
  18575. */
  18576. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  18577. /**
  18578. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  18579. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  18580. * @param vector defines the Vector3 to transform
  18581. * @param transformation defines the transformation matrix
  18582. * @returns the new Vector3
  18583. */
  18584. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  18585. /**
  18586. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  18587. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  18588. * @param vector defines the Vector3 to transform
  18589. * @param transformation defines the transformation matrix
  18590. * @param result defines the Vector3 where to store the result
  18591. */
  18592. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  18593. /**
  18594. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  18595. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  18596. * @param x define the x coordinate of the source vector
  18597. * @param y define the y coordinate of the source vector
  18598. * @param z define the z coordinate of the source vector
  18599. * @param transformation defines the transformation matrix
  18600. * @param result defines the Vector3 where to store the result
  18601. */
  18602. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  18603. /**
  18604. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  18605. * @param value1 defines the first control point
  18606. * @param value2 defines the second control point
  18607. * @param value3 defines the third control point
  18608. * @param value4 defines the fourth control point
  18609. * @param amount defines the amount on the spline to use
  18610. * @returns the new Vector3
  18611. */
  18612. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  18613. /**
  18614. * 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"
  18615. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  18616. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  18617. * @param value defines the current value
  18618. * @param min defines the lower range value
  18619. * @param max defines the upper range value
  18620. * @returns the new Vector3
  18621. */
  18622. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  18623. /**
  18624. * 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"
  18625. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  18626. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  18627. * @param value defines the current value
  18628. * @param min defines the lower range value
  18629. * @param max defines the upper range value
  18630. * @param result defines the Vector3 where to store the result
  18631. */
  18632. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  18633. /**
  18634. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  18635. * @param value1 defines the first control point
  18636. * @param tangent1 defines the first tangent vector
  18637. * @param value2 defines the second control point
  18638. * @param tangent2 defines the second tangent vector
  18639. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  18640. * @returns the new Vector3
  18641. */
  18642. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  18643. /**
  18644. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  18645. * @param start defines the start value
  18646. * @param end defines the end value
  18647. * @param amount max defines amount between both (between 0 and 1)
  18648. * @returns the new Vector3
  18649. */
  18650. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  18651. /**
  18652. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  18653. * @param start defines the start value
  18654. * @param end defines the end value
  18655. * @param amount max defines amount between both (between 0 and 1)
  18656. * @param result defines the Vector3 where to store the result
  18657. */
  18658. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  18659. /**
  18660. * Returns the dot product (float) between the vectors "left" and "right"
  18661. * @param left defines the left operand
  18662. * @param right defines the right operand
  18663. * @returns the dot product
  18664. */
  18665. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  18666. /**
  18667. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  18668. * The cross product is then orthogonal to both "left" and "right"
  18669. * @param left defines the left operand
  18670. * @param right defines the right operand
  18671. * @returns the cross product
  18672. */
  18673. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  18674. /**
  18675. * Sets the given vector "result" with the cross product of "left" and "right"
  18676. * The cross product is then orthogonal to both "left" and "right"
  18677. * @param left defines the left operand
  18678. * @param right defines the right operand
  18679. * @param result defines the Vector3 where to store the result
  18680. */
  18681. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  18682. /**
  18683. * Returns a new Vector3 as the normalization of the given vector
  18684. * @param vector defines the Vector3 to normalize
  18685. * @returns the new Vector3
  18686. */
  18687. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  18688. /**
  18689. * Sets the given vector "result" with the normalization of the given first vector
  18690. * @param vector defines the Vector3 to normalize
  18691. * @param result defines the Vector3 where to store the result
  18692. */
  18693. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  18694. /**
  18695. * Project a Vector3 onto screen space
  18696. * @param vector defines the Vector3 to project
  18697. * @param world defines the world matrix to use
  18698. * @param transform defines the transform (view x projection) matrix to use
  18699. * @param viewport defines the screen viewport to use
  18700. * @returns the new Vector3
  18701. */
  18702. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  18703. /** @hidden */
  18704. private static UnprojectFromInvertedMatrixToRef;
  18705. /**
  18706. * Unproject from screen space to object space
  18707. * @param source defines the screen space Vector3 to use
  18708. * @param viewportWidth defines the current width of the viewport
  18709. * @param viewportHeight defines the current height of the viewport
  18710. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18711. * @param transform defines the transform (view x projection) matrix to use
  18712. * @returns the new Vector3
  18713. */
  18714. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  18715. /**
  18716. * Unproject from screen space to object space
  18717. * @param source defines the screen space Vector3 to use
  18718. * @param viewportWidth defines the current width of the viewport
  18719. * @param viewportHeight defines the current height of the viewport
  18720. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18721. * @param view defines the view matrix to use
  18722. * @param projection defines the projection matrix to use
  18723. * @returns the new Vector3
  18724. */
  18725. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  18726. /**
  18727. * Unproject from screen space to object space
  18728. * @param source defines the screen space Vector3 to use
  18729. * @param viewportWidth defines the current width of the viewport
  18730. * @param viewportHeight defines the current height of the viewport
  18731. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18732. * @param view defines the view matrix to use
  18733. * @param projection defines the projection matrix to use
  18734. * @param result defines the Vector3 where to store the result
  18735. */
  18736. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  18737. /**
  18738. * Unproject from screen space to object space
  18739. * @param sourceX defines the screen space x coordinate to use
  18740. * @param sourceY defines the screen space y coordinate to use
  18741. * @param sourceZ defines the screen space z coordinate to use
  18742. * @param viewportWidth defines the current width of the viewport
  18743. * @param viewportHeight defines the current height of the viewport
  18744. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18745. * @param view defines the view matrix to use
  18746. * @param projection defines the projection matrix to use
  18747. * @param result defines the Vector3 where to store the result
  18748. */
  18749. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  18750. /**
  18751. * Unproject a ray from screen space to object space
  18752. * @param sourceX defines the screen space x coordinate to use
  18753. * @param sourceY defines the screen space y coordinate to use
  18754. * @param viewportWidth defines the current width of the viewport
  18755. * @param viewportHeight defines the current height of the viewport
  18756. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18757. * @param view defines the view matrix to use
  18758. * @param projection defines the projection matrix to use
  18759. * @param ray defines the Ray where to store the result
  18760. */
  18761. static UnprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, ray: Ray): void;
  18762. /**
  18763. * Gets the minimal coordinate values between two Vector3
  18764. * @param left defines the first operand
  18765. * @param right defines the second operand
  18766. * @returns the new Vector3
  18767. */
  18768. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  18769. /**
  18770. * Gets the maximal coordinate values between two Vector3
  18771. * @param left defines the first operand
  18772. * @param right defines the second operand
  18773. * @returns the new Vector3
  18774. */
  18775. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  18776. /**
  18777. * Returns the distance between the vectors "value1" and "value2"
  18778. * @param value1 defines the first operand
  18779. * @param value2 defines the second operand
  18780. * @returns the distance
  18781. */
  18782. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  18783. /**
  18784. * Returns the squared distance between the vectors "value1" and "value2"
  18785. * @param value1 defines the first operand
  18786. * @param value2 defines the second operand
  18787. * @returns the squared distance
  18788. */
  18789. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  18790. /**
  18791. * Returns a new Vector3 located at the center between "value1" and "value2"
  18792. * @param value1 defines the first operand
  18793. * @param value2 defines the second operand
  18794. * @returns the new Vector3
  18795. */
  18796. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  18797. /**
  18798. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  18799. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  18800. * to something in order to rotate it from its local system to the given target system
  18801. * Note: axis1, axis2 and axis3 are normalized during this operation
  18802. * @param axis1 defines the first axis
  18803. * @param axis2 defines the second axis
  18804. * @param axis3 defines the third axis
  18805. * @returns a new Vector3
  18806. */
  18807. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  18808. /**
  18809. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  18810. * @param axis1 defines the first axis
  18811. * @param axis2 defines the second axis
  18812. * @param axis3 defines the third axis
  18813. * @param ref defines the Vector3 where to store the result
  18814. */
  18815. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  18816. }
  18817. /**
  18818. * Vector4 class created for EulerAngle class conversion to Quaternion
  18819. */
  18820. class Vector4 {
  18821. /** x value of the vector */
  18822. x: number;
  18823. /** y value of the vector */
  18824. y: number;
  18825. /** z value of the vector */
  18826. z: number;
  18827. /** w value of the vector */
  18828. w: number;
  18829. /**
  18830. * Creates a Vector4 object from the given floats.
  18831. * @param x x value of the vector
  18832. * @param y y value of the vector
  18833. * @param z z value of the vector
  18834. * @param w w value of the vector
  18835. */
  18836. constructor(
  18837. /** x value of the vector */
  18838. x: number,
  18839. /** y value of the vector */
  18840. y: number,
  18841. /** z value of the vector */
  18842. z: number,
  18843. /** w value of the vector */
  18844. w: number);
  18845. /**
  18846. * Returns the string with the Vector4 coordinates.
  18847. * @returns a string containing all the vector values
  18848. */
  18849. toString(): string;
  18850. /**
  18851. * Returns the string "Vector4".
  18852. * @returns "Vector4"
  18853. */
  18854. getClassName(): string;
  18855. /**
  18856. * Returns the Vector4 hash code.
  18857. * @returns a unique hash code
  18858. */
  18859. getHashCode(): number;
  18860. /**
  18861. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  18862. * @returns the resulting array
  18863. */
  18864. asArray(): number[];
  18865. /**
  18866. * Populates the given array from the given index with the Vector4 coordinates.
  18867. * @param array array to populate
  18868. * @param index index of the array to start at (default: 0)
  18869. * @returns the Vector4.
  18870. */
  18871. toArray(array: FloatArray, index?: number): Vector4;
  18872. /**
  18873. * Adds the given vector to the current Vector4.
  18874. * @param otherVector the vector to add
  18875. * @returns the updated Vector4.
  18876. */
  18877. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  18878. /**
  18879. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  18880. * @param otherVector the vector to add
  18881. * @returns the resulting vector
  18882. */
  18883. add(otherVector: DeepImmutable<Vector4>): Vector4;
  18884. /**
  18885. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  18886. * @param otherVector the vector to add
  18887. * @param result the vector to store the result
  18888. * @returns the current Vector4.
  18889. */
  18890. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  18891. /**
  18892. * Subtract in place the given vector from the current Vector4.
  18893. * @param otherVector the vector to subtract
  18894. * @returns the updated Vector4.
  18895. */
  18896. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  18897. /**
  18898. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  18899. * @param otherVector the vector to add
  18900. * @returns the new vector with the result
  18901. */
  18902. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  18903. /**
  18904. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  18905. * @param otherVector the vector to subtract
  18906. * @param result the vector to store the result
  18907. * @returns the current Vector4.
  18908. */
  18909. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  18910. /**
  18911. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  18912. */
  18913. /**
  18914. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  18915. * @param x value to subtract
  18916. * @param y value to subtract
  18917. * @param z value to subtract
  18918. * @param w value to subtract
  18919. * @returns new vector containing the result
  18920. */
  18921. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  18922. /**
  18923. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  18924. * @param x value to subtract
  18925. * @param y value to subtract
  18926. * @param z value to subtract
  18927. * @param w value to subtract
  18928. * @param result the vector to store the result in
  18929. * @returns the current Vector4.
  18930. */
  18931. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  18932. /**
  18933. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  18934. * @returns a new vector with the negated values
  18935. */
  18936. negate(): Vector4;
  18937. /**
  18938. * Multiplies the current Vector4 coordinates by scale (float).
  18939. * @param scale the number to scale with
  18940. * @returns the updated Vector4.
  18941. */
  18942. scaleInPlace(scale: number): Vector4;
  18943. /**
  18944. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  18945. * @param scale the number to scale with
  18946. * @returns a new vector with the result
  18947. */
  18948. scale(scale: number): Vector4;
  18949. /**
  18950. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  18951. * @param scale the number to scale with
  18952. * @param result a vector to store the result in
  18953. * @returns the current Vector4.
  18954. */
  18955. scaleToRef(scale: number, result: Vector4): Vector4;
  18956. /**
  18957. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  18958. * @param scale defines the scale factor
  18959. * @param result defines the Vector4 object where to store the result
  18960. * @returns the unmodified current Vector4
  18961. */
  18962. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  18963. /**
  18964. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  18965. * @param otherVector the vector to compare against
  18966. * @returns true if they are equal
  18967. */
  18968. equals(otherVector: DeepImmutable<Vector4>): boolean;
  18969. /**
  18970. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  18971. * @param otherVector vector to compare against
  18972. * @param epsilon (Default: very small number)
  18973. * @returns true if they are equal
  18974. */
  18975. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  18976. /**
  18977. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  18978. * @param x x value to compare against
  18979. * @param y y value to compare against
  18980. * @param z z value to compare against
  18981. * @param w w value to compare against
  18982. * @returns true if equal
  18983. */
  18984. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  18985. /**
  18986. * Multiplies in place the current Vector4 by the given one.
  18987. * @param otherVector vector to multiple with
  18988. * @returns the updated Vector4.
  18989. */
  18990. multiplyInPlace(otherVector: Vector4): Vector4;
  18991. /**
  18992. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  18993. * @param otherVector vector to multiple with
  18994. * @returns resulting new vector
  18995. */
  18996. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  18997. /**
  18998. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  18999. * @param otherVector vector to multiple with
  19000. * @param result vector to store the result
  19001. * @returns the current Vector4.
  19002. */
  19003. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  19004. /**
  19005. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  19006. * @param x x value multiply with
  19007. * @param y y value multiply with
  19008. * @param z z value multiply with
  19009. * @param w w value multiply with
  19010. * @returns resulting new vector
  19011. */
  19012. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  19013. /**
  19014. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  19015. * @param otherVector vector to devide with
  19016. * @returns resulting new vector
  19017. */
  19018. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  19019. /**
  19020. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  19021. * @param otherVector vector to devide with
  19022. * @param result vector to store the result
  19023. * @returns the current Vector4.
  19024. */
  19025. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  19026. /**
  19027. * Divides the current Vector3 coordinates by the given ones.
  19028. * @param otherVector vector to devide with
  19029. * @returns the updated Vector3.
  19030. */
  19031. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  19032. /**
  19033. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  19034. * @param other defines the second operand
  19035. * @returns the current updated Vector4
  19036. */
  19037. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  19038. /**
  19039. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  19040. * @param other defines the second operand
  19041. * @returns the current updated Vector4
  19042. */
  19043. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  19044. /**
  19045. * Gets a new Vector4 from current Vector4 floored values
  19046. * @returns a new Vector4
  19047. */
  19048. floor(): Vector4;
  19049. /**
  19050. * Gets a new Vector4 from current Vector3 floored values
  19051. * @returns a new Vector4
  19052. */
  19053. fract(): Vector4;
  19054. /**
  19055. * Returns the Vector4 length (float).
  19056. * @returns the length
  19057. */
  19058. length(): number;
  19059. /**
  19060. * Returns the Vector4 squared length (float).
  19061. * @returns the length squared
  19062. */
  19063. lengthSquared(): number;
  19064. /**
  19065. * Normalizes in place the Vector4.
  19066. * @returns the updated Vector4.
  19067. */
  19068. normalize(): Vector4;
  19069. /**
  19070. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  19071. * @returns this converted to a new vector3
  19072. */
  19073. toVector3(): Vector3;
  19074. /**
  19075. * Returns a new Vector4 copied from the current one.
  19076. * @returns the new cloned vector
  19077. */
  19078. clone(): Vector4;
  19079. /**
  19080. * Updates the current Vector4 with the given one coordinates.
  19081. * @param source the source vector to copy from
  19082. * @returns the updated Vector4.
  19083. */
  19084. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  19085. /**
  19086. * Updates the current Vector4 coordinates with the given floats.
  19087. * @param x float to copy from
  19088. * @param y float to copy from
  19089. * @param z float to copy from
  19090. * @param w float to copy from
  19091. * @returns the updated Vector4.
  19092. */
  19093. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  19094. /**
  19095. * Updates the current Vector4 coordinates with the given floats.
  19096. * @param x float to set from
  19097. * @param y float to set from
  19098. * @param z float to set from
  19099. * @param w float to set from
  19100. * @returns the updated Vector4.
  19101. */
  19102. set(x: number, y: number, z: number, w: number): Vector4;
  19103. /**
  19104. * Copies the given float to the current Vector3 coordinates
  19105. * @param v defines the x, y, z and w coordinates of the operand
  19106. * @returns the current updated Vector3
  19107. */
  19108. setAll(v: number): Vector4;
  19109. /**
  19110. * Returns a new Vector4 set from the starting index of the given array.
  19111. * @param array the array to pull values from
  19112. * @param offset the offset into the array to start at
  19113. * @returns the new vector
  19114. */
  19115. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  19116. /**
  19117. * Updates the given vector "result" from the starting index of the given array.
  19118. * @param array the array to pull values from
  19119. * @param offset the offset into the array to start at
  19120. * @param result the vector to store the result in
  19121. */
  19122. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  19123. /**
  19124. * Updates the given vector "result" from the starting index of the given Float32Array.
  19125. * @param array the array to pull values from
  19126. * @param offset the offset into the array to start at
  19127. * @param result the vector to store the result in
  19128. */
  19129. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  19130. /**
  19131. * Updates the given vector "result" coordinates from the given floats.
  19132. * @param x float to set from
  19133. * @param y float to set from
  19134. * @param z float to set from
  19135. * @param w float to set from
  19136. * @param result the vector to the floats in
  19137. */
  19138. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  19139. /**
  19140. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  19141. * @returns the new vector
  19142. */
  19143. static Zero(): Vector4;
  19144. /**
  19145. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  19146. * @returns the new vector
  19147. */
  19148. static One(): Vector4;
  19149. /**
  19150. * Returns a new normalized Vector4 from the given one.
  19151. * @param vector the vector to normalize
  19152. * @returns the vector
  19153. */
  19154. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  19155. /**
  19156. * Updates the given vector "result" from the normalization of the given one.
  19157. * @param vector the vector to normalize
  19158. * @param result the vector to store the result in
  19159. */
  19160. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  19161. /**
  19162. * Returns a vector with the minimum values from the left and right vectors
  19163. * @param left left vector to minimize
  19164. * @param right right vector to minimize
  19165. * @returns a new vector with the minimum of the left and right vector values
  19166. */
  19167. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  19168. /**
  19169. * Returns a vector with the maximum values from the left and right vectors
  19170. * @param left left vector to maximize
  19171. * @param right right vector to maximize
  19172. * @returns a new vector with the maximum of the left and right vector values
  19173. */
  19174. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  19175. /**
  19176. * Returns the distance (float) between the vectors "value1" and "value2".
  19177. * @param value1 value to calulate the distance between
  19178. * @param value2 value to calulate the distance between
  19179. * @return the distance between the two vectors
  19180. */
  19181. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  19182. /**
  19183. * Returns the squared distance (float) between the vectors "value1" and "value2".
  19184. * @param value1 value to calulate the distance between
  19185. * @param value2 value to calulate the distance between
  19186. * @return the distance between the two vectors squared
  19187. */
  19188. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  19189. /**
  19190. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  19191. * @param value1 value to calulate the center between
  19192. * @param value2 value to calulate the center between
  19193. * @return the center between the two vectors
  19194. */
  19195. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  19196. /**
  19197. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  19198. * This methods computes transformed normalized direction vectors only.
  19199. * @param vector the vector to transform
  19200. * @param transformation the transformation matrix to apply
  19201. * @returns the new vector
  19202. */
  19203. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  19204. /**
  19205. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  19206. * This methods computes transformed normalized direction vectors only.
  19207. * @param vector the vector to transform
  19208. * @param transformation the transformation matrix to apply
  19209. * @param result the vector to store the result in
  19210. */
  19211. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  19212. /**
  19213. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  19214. * This methods computes transformed normalized direction vectors only.
  19215. * @param x value to transform
  19216. * @param y value to transform
  19217. * @param z value to transform
  19218. * @param w value to transform
  19219. * @param transformation the transformation matrix to apply
  19220. * @param result the vector to store the results in
  19221. */
  19222. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  19223. /**
  19224. * Creates a new Vector4 from a Vector3
  19225. * @param source defines the source data
  19226. * @param w defines the 4th component (default is 0)
  19227. * @returns a new Vector4
  19228. */
  19229. static FromVector3(source: Vector3, w?: number): Vector4;
  19230. }
  19231. /**
  19232. * Interface for the size containing width and height
  19233. */
  19234. interface ISize {
  19235. /**
  19236. * Width
  19237. */
  19238. width: number;
  19239. /**
  19240. * Heighht
  19241. */
  19242. height: number;
  19243. }
  19244. /**
  19245. * Size containing widht and height
  19246. */
  19247. class Size implements ISize {
  19248. /**
  19249. * Width
  19250. */
  19251. width: number;
  19252. /**
  19253. * Height
  19254. */
  19255. height: number;
  19256. /**
  19257. * Creates a Size object from the given width and height (floats).
  19258. * @param width width of the new size
  19259. * @param height height of the new size
  19260. */
  19261. constructor(width: number, height: number);
  19262. /**
  19263. * Returns a string with the Size width and height
  19264. * @returns a string with the Size width and height
  19265. */
  19266. toString(): string;
  19267. /**
  19268. * "Size"
  19269. * @returns the string "Size"
  19270. */
  19271. getClassName(): string;
  19272. /**
  19273. * Returns the Size hash code.
  19274. * @returns a hash code for a unique width and height
  19275. */
  19276. getHashCode(): number;
  19277. /**
  19278. * Updates the current size from the given one.
  19279. * @param src the given size
  19280. */
  19281. copyFrom(src: Size): void;
  19282. /**
  19283. * Updates in place the current Size from the given floats.
  19284. * @param width width of the new size
  19285. * @param height height of the new size
  19286. * @returns the updated Size.
  19287. */
  19288. copyFromFloats(width: number, height: number): Size;
  19289. /**
  19290. * Updates in place the current Size from the given floats.
  19291. * @param width width to set
  19292. * @param height height to set
  19293. * @returns the updated Size.
  19294. */
  19295. set(width: number, height: number): Size;
  19296. /**
  19297. * Multiplies the width and height by numbers
  19298. * @param w factor to multiple the width by
  19299. * @param h factor to multiple the height by
  19300. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  19301. */
  19302. multiplyByFloats(w: number, h: number): Size;
  19303. /**
  19304. * Clones the size
  19305. * @returns a new Size copied from the given one.
  19306. */
  19307. clone(): Size;
  19308. /**
  19309. * True if the current Size and the given one width and height are strictly equal.
  19310. * @param other the other size to compare against
  19311. * @returns True if the current Size and the given one width and height are strictly equal.
  19312. */
  19313. equals(other: Size): boolean;
  19314. /**
  19315. * The surface of the Size : width * height (float).
  19316. */
  19317. readonly surface: number;
  19318. /**
  19319. * Create a new size of zero
  19320. * @returns a new Size set to (0.0, 0.0)
  19321. */
  19322. static Zero(): Size;
  19323. /**
  19324. * Sums the width and height of two sizes
  19325. * @param otherSize size to add to this size
  19326. * @returns a new Size set as the addition result of the current Size and the given one.
  19327. */
  19328. add(otherSize: Size): Size;
  19329. /**
  19330. * Subtracts the width and height of two
  19331. * @param otherSize size to subtract to this size
  19332. * @returns a new Size set as the subtraction result of the given one from the current Size.
  19333. */
  19334. subtract(otherSize: Size): Size;
  19335. /**
  19336. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  19337. * @param start starting size to lerp between
  19338. * @param end end size to lerp between
  19339. * @param amount amount to lerp between the start and end values
  19340. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  19341. */
  19342. static Lerp(start: Size, end: Size, amount: number): Size;
  19343. }
  19344. /**
  19345. * Class used to store quaternion data
  19346. * @see https://en.wikipedia.org/wiki/Quaternion
  19347. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  19348. */
  19349. class Quaternion {
  19350. /** defines the first component (0 by default) */
  19351. x: number;
  19352. /** defines the second component (0 by default) */
  19353. y: number;
  19354. /** defines the third component (0 by default) */
  19355. z: number;
  19356. /** defines the fourth component (1.0 by default) */
  19357. w: number;
  19358. /**
  19359. * Creates a new Quaternion from the given floats
  19360. * @param x defines the first component (0 by default)
  19361. * @param y defines the second component (0 by default)
  19362. * @param z defines the third component (0 by default)
  19363. * @param w defines the fourth component (1.0 by default)
  19364. */
  19365. constructor(
  19366. /** defines the first component (0 by default) */
  19367. x?: number,
  19368. /** defines the second component (0 by default) */
  19369. y?: number,
  19370. /** defines the third component (0 by default) */
  19371. z?: number,
  19372. /** defines the fourth component (1.0 by default) */
  19373. w?: number);
  19374. /**
  19375. * Gets a string representation for the current quaternion
  19376. * @returns a string with the Quaternion coordinates
  19377. */
  19378. toString(): string;
  19379. /**
  19380. * Gets the class name of the quaternion
  19381. * @returns the string "Quaternion"
  19382. */
  19383. getClassName(): string;
  19384. /**
  19385. * Gets a hash code for this quaternion
  19386. * @returns the quaternion hash code
  19387. */
  19388. getHashCode(): number;
  19389. /**
  19390. * Copy the quaternion to an array
  19391. * @returns a new array populated with 4 elements from the quaternion coordinates
  19392. */
  19393. asArray(): number[];
  19394. /**
  19395. * Check if two quaternions are equals
  19396. * @param otherQuaternion defines the second operand
  19397. * @return true if the current quaternion and the given one coordinates are strictly equals
  19398. */
  19399. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  19400. /**
  19401. * Clone the current quaternion
  19402. * @returns a new quaternion copied from the current one
  19403. */
  19404. clone(): Quaternion;
  19405. /**
  19406. * Copy a quaternion to the current one
  19407. * @param other defines the other quaternion
  19408. * @returns the updated current quaternion
  19409. */
  19410. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  19411. /**
  19412. * Updates the current quaternion with the given float coordinates
  19413. * @param x defines the x coordinate
  19414. * @param y defines the y coordinate
  19415. * @param z defines the z coordinate
  19416. * @param w defines the w coordinate
  19417. * @returns the updated current quaternion
  19418. */
  19419. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  19420. /**
  19421. * Updates the current quaternion from the given float coordinates
  19422. * @param x defines the x coordinate
  19423. * @param y defines the y coordinate
  19424. * @param z defines the z coordinate
  19425. * @param w defines the w coordinate
  19426. * @returns the updated current quaternion
  19427. */
  19428. set(x: number, y: number, z: number, w: number): Quaternion;
  19429. /**
  19430. * Adds two quaternions
  19431. * @param other defines the second operand
  19432. * @returns a new quaternion as the addition result of the given one and the current quaternion
  19433. */
  19434. add(other: DeepImmutable<Quaternion>): Quaternion;
  19435. /**
  19436. * Add a quaternion to the current one
  19437. * @param other defines the quaternion to add
  19438. * @returns the current quaternion
  19439. */
  19440. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  19441. /**
  19442. * Subtract two quaternions
  19443. * @param other defines the second operand
  19444. * @returns a new quaternion as the subtraction result of the given one from the current one
  19445. */
  19446. subtract(other: Quaternion): Quaternion;
  19447. /**
  19448. * Multiplies the current quaternion by a scale factor
  19449. * @param value defines the scale factor
  19450. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  19451. */
  19452. scale(value: number): Quaternion;
  19453. /**
  19454. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  19455. * @param scale defines the scale factor
  19456. * @param result defines the Quaternion object where to store the result
  19457. * @returns the unmodified current quaternion
  19458. */
  19459. scaleToRef(scale: number, result: Quaternion): Quaternion;
  19460. /**
  19461. * Multiplies in place the current quaternion by a scale factor
  19462. * @param value defines the scale factor
  19463. * @returns the current modified quaternion
  19464. */
  19465. scaleInPlace(value: number): Quaternion;
  19466. /**
  19467. * Scale the current quaternion values by a factor and add the result to a given quaternion
  19468. * @param scale defines the scale factor
  19469. * @param result defines the Quaternion object where to store the result
  19470. * @returns the unmodified current quaternion
  19471. */
  19472. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  19473. /**
  19474. * Multiplies two quaternions
  19475. * @param q1 defines the second operand
  19476. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  19477. */
  19478. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  19479. /**
  19480. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  19481. * @param q1 defines the second operand
  19482. * @param result defines the target quaternion
  19483. * @returns the current quaternion
  19484. */
  19485. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  19486. /**
  19487. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  19488. * @param q1 defines the second operand
  19489. * @returns the currentupdated quaternion
  19490. */
  19491. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  19492. /**
  19493. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  19494. * @param ref defines the target quaternion
  19495. * @returns the current quaternion
  19496. */
  19497. conjugateToRef(ref: Quaternion): Quaternion;
  19498. /**
  19499. * Conjugates in place (1-q) the current quaternion
  19500. * @returns the current updated quaternion
  19501. */
  19502. conjugateInPlace(): Quaternion;
  19503. /**
  19504. * Conjugates in place (1-q) the current quaternion
  19505. * @returns a new quaternion
  19506. */
  19507. conjugate(): Quaternion;
  19508. /**
  19509. * Gets length of current quaternion
  19510. * @returns the quaternion length (float)
  19511. */
  19512. length(): number;
  19513. /**
  19514. * Normalize in place the current quaternion
  19515. * @returns the current updated quaternion
  19516. */
  19517. normalize(): Quaternion;
  19518. /**
  19519. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  19520. * @param order is a reserved parameter and is ignore for now
  19521. * @returns a new Vector3 containing the Euler angles
  19522. */
  19523. toEulerAngles(order?: string): Vector3;
  19524. /**
  19525. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  19526. * @param result defines the vector which will be filled with the Euler angles
  19527. * @param order is a reserved parameter and is ignore for now
  19528. * @returns the current unchanged quaternion
  19529. */
  19530. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  19531. /**
  19532. * Updates the given rotation matrix with the current quaternion values
  19533. * @param result defines the target matrix
  19534. * @returns the current unchanged quaternion
  19535. */
  19536. toRotationMatrix(result: Matrix): Quaternion;
  19537. /**
  19538. * Updates the current quaternion from the given rotation matrix values
  19539. * @param matrix defines the source matrix
  19540. * @returns the current updated quaternion
  19541. */
  19542. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  19543. /**
  19544. * Creates a new quaternion from a rotation matrix
  19545. * @param matrix defines the source matrix
  19546. * @returns a new quaternion created from the given rotation matrix values
  19547. */
  19548. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  19549. /**
  19550. * Updates the given quaternion with the given rotation matrix values
  19551. * @param matrix defines the source matrix
  19552. * @param result defines the target quaternion
  19553. */
  19554. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  19555. /**
  19556. * Returns the dot product (float) between the quaternions "left" and "right"
  19557. * @param left defines the left operand
  19558. * @param right defines the right operand
  19559. * @returns the dot product
  19560. */
  19561. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  19562. /**
  19563. * Checks if the two quaternions are close to each other
  19564. * @param quat0 defines the first quaternion to check
  19565. * @param quat1 defines the second quaternion to check
  19566. * @returns true if the two quaternions are close to each other
  19567. */
  19568. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  19569. /**
  19570. * Creates an empty quaternion
  19571. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  19572. */
  19573. static Zero(): Quaternion;
  19574. /**
  19575. * Inverse a given quaternion
  19576. * @param q defines the source quaternion
  19577. * @returns a new quaternion as the inverted current quaternion
  19578. */
  19579. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  19580. /**
  19581. * Inverse a given quaternion
  19582. * @param q defines the source quaternion
  19583. * @param result the quaternion the result will be stored in
  19584. * @returns the result quaternion
  19585. */
  19586. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  19587. /**
  19588. * Creates an identity quaternion
  19589. * @returns the identity quaternion
  19590. */
  19591. static Identity(): Quaternion;
  19592. /**
  19593. * Gets a boolean indicating if the given quaternion is identity
  19594. * @param quaternion defines the quaternion to check
  19595. * @returns true if the quaternion is identity
  19596. */
  19597. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  19598. /**
  19599. * Creates a quaternion from a rotation around an axis
  19600. * @param axis defines the axis to use
  19601. * @param angle defines the angle to use
  19602. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  19603. */
  19604. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  19605. /**
  19606. * Creates a rotation around an axis and stores it into the given quaternion
  19607. * @param axis defines the axis to use
  19608. * @param angle defines the angle to use
  19609. * @param result defines the target quaternion
  19610. * @returns the target quaternion
  19611. */
  19612. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  19613. /**
  19614. * Creates a new quaternion from data stored into an array
  19615. * @param array defines the data source
  19616. * @param offset defines the offset in the source array where the data starts
  19617. * @returns a new quaternion
  19618. */
  19619. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  19620. /**
  19621. * Create a quaternion from Euler rotation angles
  19622. * @param x Pitch
  19623. * @param y Yaw
  19624. * @param z Roll
  19625. * @returns the new Quaternion
  19626. */
  19627. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  19628. /**
  19629. * Updates a quaternion from Euler rotation angles
  19630. * @param x Pitch
  19631. * @param y Yaw
  19632. * @param z Roll
  19633. * @param result the quaternion to store the result
  19634. * @returns the updated quaternion
  19635. */
  19636. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  19637. /**
  19638. * Create a quaternion from Euler rotation vector
  19639. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  19640. * @returns the new Quaternion
  19641. */
  19642. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  19643. /**
  19644. * Updates a quaternion from Euler rotation vector
  19645. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  19646. * @param result the quaternion to store the result
  19647. * @returns the updated quaternion
  19648. */
  19649. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  19650. /**
  19651. * Creates a new quaternion from the given Euler float angles (y, x, z)
  19652. * @param yaw defines the rotation around Y axis
  19653. * @param pitch defines the rotation around X axis
  19654. * @param roll defines the rotation around Z axis
  19655. * @returns the new quaternion
  19656. */
  19657. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  19658. /**
  19659. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  19660. * @param yaw defines the rotation around Y axis
  19661. * @param pitch defines the rotation around X axis
  19662. * @param roll defines the rotation around Z axis
  19663. * @param result defines the target quaternion
  19664. */
  19665. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  19666. /**
  19667. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  19668. * @param alpha defines the rotation around first axis
  19669. * @param beta defines the rotation around second axis
  19670. * @param gamma defines the rotation around third axis
  19671. * @returns the new quaternion
  19672. */
  19673. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  19674. /**
  19675. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  19676. * @param alpha defines the rotation around first axis
  19677. * @param beta defines the rotation around second axis
  19678. * @param gamma defines the rotation around third axis
  19679. * @param result defines the target quaternion
  19680. */
  19681. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  19682. /**
  19683. * 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)
  19684. * @param axis1 defines the first axis
  19685. * @param axis2 defines the second axis
  19686. * @param axis3 defines the third axis
  19687. * @returns the new quaternion
  19688. */
  19689. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  19690. /**
  19691. * 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
  19692. * @param axis1 defines the first axis
  19693. * @param axis2 defines the second axis
  19694. * @param axis3 defines the third axis
  19695. * @param ref defines the target quaternion
  19696. */
  19697. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  19698. /**
  19699. * Interpolates between two quaternions
  19700. * @param left defines first quaternion
  19701. * @param right defines second quaternion
  19702. * @param amount defines the gradient to use
  19703. * @returns the new interpolated quaternion
  19704. */
  19705. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  19706. /**
  19707. * Interpolates between two quaternions and stores it into a target quaternion
  19708. * @param left defines first quaternion
  19709. * @param right defines second quaternion
  19710. * @param amount defines the gradient to use
  19711. * @param result defines the target quaternion
  19712. */
  19713. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  19714. /**
  19715. * Interpolate between two quaternions using Hermite interpolation
  19716. * @param value1 defines first quaternion
  19717. * @param tangent1 defines the incoming tangent
  19718. * @param value2 defines second quaternion
  19719. * @param tangent2 defines the outgoing tangent
  19720. * @param amount defines the target quaternion
  19721. * @returns the new interpolated quaternion
  19722. */
  19723. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  19724. }
  19725. /**
  19726. * Class used to store matrix data (4x4)
  19727. */
  19728. class Matrix {
  19729. private static _updateFlagSeed;
  19730. private static _identityReadOnly;
  19731. private _isIdentity;
  19732. private _isIdentityDirty;
  19733. private _isIdentity3x2;
  19734. private _isIdentity3x2Dirty;
  19735. /**
  19736. * Gets the update flag of the matrix which is an unique number for the matrix.
  19737. * It will be incremented every time the matrix data change.
  19738. * You can use it to speed the comparison between two versions of the same matrix.
  19739. */
  19740. updateFlag: number;
  19741. private readonly _m;
  19742. /**
  19743. * Gets the internal data of the matrix
  19744. */
  19745. readonly m: DeepImmutable<Float32Array>;
  19746. /** @hidden */
  19747. _markAsUpdated(): void;
  19748. /** @hidden */
  19749. private _updateIdentityStatus;
  19750. /**
  19751. * Creates an empty matrix (filled with zeros)
  19752. */
  19753. constructor();
  19754. /**
  19755. * Check if the current matrix is identity
  19756. * @returns true is the matrix is the identity matrix
  19757. */
  19758. isIdentity(): boolean;
  19759. /**
  19760. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  19761. * @returns true is the matrix is the identity matrix
  19762. */
  19763. isIdentityAs3x2(): boolean;
  19764. /**
  19765. * Gets the determinant of the matrix
  19766. * @returns the matrix determinant
  19767. */
  19768. determinant(): number;
  19769. /**
  19770. * Returns the matrix as a Float32Array
  19771. * @returns the matrix underlying array
  19772. */
  19773. toArray(): DeepImmutable<Float32Array>;
  19774. /**
  19775. * Returns the matrix as a Float32Array
  19776. * @returns the matrix underlying array.
  19777. */
  19778. asArray(): DeepImmutable<Float32Array>;
  19779. /**
  19780. * Inverts the current matrix in place
  19781. * @returns the current inverted matrix
  19782. */
  19783. invert(): Matrix;
  19784. /**
  19785. * Sets all the matrix elements to zero
  19786. * @returns the current matrix
  19787. */
  19788. reset(): Matrix;
  19789. /**
  19790. * Adds the current matrix with a second one
  19791. * @param other defines the matrix to add
  19792. * @returns a new matrix as the addition of the current matrix and the given one
  19793. */
  19794. add(other: DeepImmutable<Matrix>): Matrix;
  19795. /**
  19796. * Sets the given matrix "result" to the addition of the current matrix and the given one
  19797. * @param other defines the matrix to add
  19798. * @param result defines the target matrix
  19799. * @returns the current matrix
  19800. */
  19801. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  19802. /**
  19803. * Adds in place the given matrix to the current matrix
  19804. * @param other defines the second operand
  19805. * @returns the current updated matrix
  19806. */
  19807. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  19808. /**
  19809. * Sets the given matrix to the current inverted Matrix
  19810. * @param other defines the target matrix
  19811. * @returns the unmodified current matrix
  19812. */
  19813. invertToRef(other: Matrix): Matrix;
  19814. /**
  19815. * add a value at the specified position in the current Matrix
  19816. * @param index the index of the value within the matrix. between 0 and 15.
  19817. * @param value the value to be added
  19818. * @returns the current updated matrix
  19819. */
  19820. addAtIndex(index: number, value: number): Matrix;
  19821. /**
  19822. * mutiply the specified position in the current Matrix by a value
  19823. * @param index the index of the value within the matrix. between 0 and 15.
  19824. * @param value the value to be added
  19825. * @returns the current updated matrix
  19826. */
  19827. multiplyAtIndex(index: number, value: number): Matrix;
  19828. /**
  19829. * Inserts the translation vector (using 3 floats) in the current matrix
  19830. * @param x defines the 1st component of the translation
  19831. * @param y defines the 2nd component of the translation
  19832. * @param z defines the 3rd component of the translation
  19833. * @returns the current updated matrix
  19834. */
  19835. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  19836. /**
  19837. * Inserts the translation vector in the current matrix
  19838. * @param vector3 defines the translation to insert
  19839. * @returns the current updated matrix
  19840. */
  19841. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  19842. /**
  19843. * Gets the translation value of the current matrix
  19844. * @returns a new Vector3 as the extracted translation from the matrix
  19845. */
  19846. getTranslation(): Vector3;
  19847. /**
  19848. * Fill a Vector3 with the extracted translation from the matrix
  19849. * @param result defines the Vector3 where to store the translation
  19850. * @returns the current matrix
  19851. */
  19852. getTranslationToRef(result: Vector3): Matrix;
  19853. /**
  19854. * Remove rotation and scaling part from the matrix
  19855. * @returns the updated matrix
  19856. */
  19857. removeRotationAndScaling(): Matrix;
  19858. /**
  19859. * Multiply two matrices
  19860. * @param other defines the second operand
  19861. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  19862. */
  19863. multiply(other: DeepImmutable<Matrix>): Matrix;
  19864. /**
  19865. * Copy the current matrix from the given one
  19866. * @param other defines the source matrix
  19867. * @returns the current updated matrix
  19868. */
  19869. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  19870. /**
  19871. * Populates the given array from the starting index with the current matrix values
  19872. * @param array defines the target array
  19873. * @param offset defines the offset in the target array where to start storing values
  19874. * @returns the current matrix
  19875. */
  19876. copyToArray(array: Float32Array, offset?: number): Matrix;
  19877. /**
  19878. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  19879. * @param other defines the second operand
  19880. * @param result defines the matrix where to store the multiplication
  19881. * @returns the current matrix
  19882. */
  19883. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  19884. /**
  19885. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  19886. * @param other defines the second operand
  19887. * @param result defines the array where to store the multiplication
  19888. * @param offset defines the offset in the target array where to start storing values
  19889. * @returns the current matrix
  19890. */
  19891. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  19892. /**
  19893. * Check equality between this matrix and a second one
  19894. * @param value defines the second matrix to compare
  19895. * @returns true is the current matrix and the given one values are strictly equal
  19896. */
  19897. equals(value: DeepImmutable<Matrix>): boolean;
  19898. /**
  19899. * Clone the current matrix
  19900. * @returns a new matrix from the current matrix
  19901. */
  19902. clone(): Matrix;
  19903. /**
  19904. * Returns the name of the current matrix class
  19905. * @returns the string "Matrix"
  19906. */
  19907. getClassName(): string;
  19908. /**
  19909. * Gets the hash code of the current matrix
  19910. * @returns the hash code
  19911. */
  19912. getHashCode(): number;
  19913. /**
  19914. * Decomposes the current Matrix into a translation, rotation and scaling components
  19915. * @param scale defines the scale vector3 given as a reference to update
  19916. * @param rotation defines the rotation quaternion given as a reference to update
  19917. * @param translation defines the translation vector3 given as a reference to update
  19918. * @returns true if operation was successful
  19919. */
  19920. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  19921. /**
  19922. * Gets specific row of the matrix
  19923. * @param index defines the number of the row to get
  19924. * @returns the index-th row of the current matrix as a new Vector4
  19925. */
  19926. getRow(index: number): Nullable<Vector4>;
  19927. /**
  19928. * Sets the index-th row of the current matrix to the vector4 values
  19929. * @param index defines the number of the row to set
  19930. * @param row defines the target vector4
  19931. * @returns the updated current matrix
  19932. */
  19933. setRow(index: number, row: Vector4): Matrix;
  19934. /**
  19935. * Compute the transpose of the matrix
  19936. * @returns the new transposed matrix
  19937. */
  19938. transpose(): Matrix;
  19939. /**
  19940. * Compute the transpose of the matrix and store it in a given matrix
  19941. * @param result defines the target matrix
  19942. * @returns the current matrix
  19943. */
  19944. transposeToRef(result: Matrix): Matrix;
  19945. /**
  19946. * Sets the index-th row of the current matrix with the given 4 x float values
  19947. * @param index defines the row index
  19948. * @param x defines the x component to set
  19949. * @param y defines the y component to set
  19950. * @param z defines the z component to set
  19951. * @param w defines the w component to set
  19952. * @returns the updated current matrix
  19953. */
  19954. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  19955. /**
  19956. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  19957. * @param scale defines the scale factor
  19958. * @returns a new matrix
  19959. */
  19960. scale(scale: number): Matrix;
  19961. /**
  19962. * Scale the current matrix values by a factor to a given result matrix
  19963. * @param scale defines the scale factor
  19964. * @param result defines the matrix to store the result
  19965. * @returns the current matrix
  19966. */
  19967. scaleToRef(scale: number, result: Matrix): Matrix;
  19968. /**
  19969. * Scale the current matrix values by a factor and add the result to a given matrix
  19970. * @param scale defines the scale factor
  19971. * @param result defines the Matrix to store the result
  19972. * @returns the current matrix
  19973. */
  19974. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  19975. /**
  19976. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  19977. * @param ref matrix to store the result
  19978. */
  19979. toNormalMatrix(ref: Matrix): void;
  19980. /**
  19981. * Gets only rotation part of the current matrix
  19982. * @returns a new matrix sets to the extracted rotation matrix from the current one
  19983. */
  19984. getRotationMatrix(): Matrix;
  19985. /**
  19986. * Extracts the rotation matrix from the current one and sets it as the given "result"
  19987. * @param result defines the target matrix to store data to
  19988. * @returns the current matrix
  19989. */
  19990. getRotationMatrixToRef(result: Matrix): Matrix;
  19991. /**
  19992. * Toggles model matrix from being right handed to left handed in place and vice versa
  19993. */
  19994. toggleModelMatrixHandInPlace(): void;
  19995. /**
  19996. * Toggles projection matrix from being right handed to left handed in place and vice versa
  19997. */
  19998. toggleProjectionMatrixHandInPlace(): void;
  19999. /**
  20000. * Creates a matrix from an array
  20001. * @param array defines the source array
  20002. * @param offset defines an offset in the source array
  20003. * @returns a new Matrix set from the starting index of the given array
  20004. */
  20005. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  20006. /**
  20007. * Copy the content of an array into a given matrix
  20008. * @param array defines the source array
  20009. * @param offset defines an offset in the source array
  20010. * @param result defines the target matrix
  20011. */
  20012. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  20013. /**
  20014. * Stores an array into a matrix after having multiplied each component by a given factor
  20015. * @param array defines the source array
  20016. * @param offset defines the offset in the source array
  20017. * @param scale defines the scaling factor
  20018. * @param result defines the target matrix
  20019. */
  20020. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  20021. /**
  20022. * Gets an identity matrix that must not be updated
  20023. */
  20024. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  20025. /**
  20026. * Stores a list of values (16) inside a given matrix
  20027. * @param initialM11 defines 1st value of 1st row
  20028. * @param initialM12 defines 2nd value of 1st row
  20029. * @param initialM13 defines 3rd value of 1st row
  20030. * @param initialM14 defines 4th value of 1st row
  20031. * @param initialM21 defines 1st value of 2nd row
  20032. * @param initialM22 defines 2nd value of 2nd row
  20033. * @param initialM23 defines 3rd value of 2nd row
  20034. * @param initialM24 defines 4th value of 2nd row
  20035. * @param initialM31 defines 1st value of 3rd row
  20036. * @param initialM32 defines 2nd value of 3rd row
  20037. * @param initialM33 defines 3rd value of 3rd row
  20038. * @param initialM34 defines 4th value of 3rd row
  20039. * @param initialM41 defines 1st value of 4th row
  20040. * @param initialM42 defines 2nd value of 4th row
  20041. * @param initialM43 defines 3rd value of 4th row
  20042. * @param initialM44 defines 4th value of 4th row
  20043. * @param result defines the target matrix
  20044. */
  20045. 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;
  20046. /**
  20047. * Creates new matrix from a list of values (16)
  20048. * @param initialM11 defines 1st value of 1st row
  20049. * @param initialM12 defines 2nd value of 1st row
  20050. * @param initialM13 defines 3rd value of 1st row
  20051. * @param initialM14 defines 4th value of 1st row
  20052. * @param initialM21 defines 1st value of 2nd row
  20053. * @param initialM22 defines 2nd value of 2nd row
  20054. * @param initialM23 defines 3rd value of 2nd row
  20055. * @param initialM24 defines 4th value of 2nd row
  20056. * @param initialM31 defines 1st value of 3rd row
  20057. * @param initialM32 defines 2nd value of 3rd row
  20058. * @param initialM33 defines 3rd value of 3rd row
  20059. * @param initialM34 defines 4th value of 3rd row
  20060. * @param initialM41 defines 1st value of 4th row
  20061. * @param initialM42 defines 2nd value of 4th row
  20062. * @param initialM43 defines 3rd value of 4th row
  20063. * @param initialM44 defines 4th value of 4th row
  20064. * @returns the new matrix
  20065. */
  20066. 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;
  20067. /**
  20068. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  20069. * @param scale defines the scale vector3
  20070. * @param rotation defines the rotation quaternion
  20071. * @param translation defines the translation vector3
  20072. * @returns a new matrix
  20073. */
  20074. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  20075. /**
  20076. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  20077. * @param scale defines the scale vector3
  20078. * @param rotation defines the rotation quaternion
  20079. * @param translation defines the translation vector3
  20080. * @param result defines the target matrix
  20081. */
  20082. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  20083. /**
  20084. * Creates a new identity matrix
  20085. * @returns a new identity matrix
  20086. */
  20087. static Identity(): Matrix;
  20088. /**
  20089. * Creates a new identity matrix and stores the result in a given matrix
  20090. * @param result defines the target matrix
  20091. */
  20092. static IdentityToRef(result: Matrix): void;
  20093. /**
  20094. * Creates a new zero matrix
  20095. * @returns a new zero matrix
  20096. */
  20097. static Zero(): Matrix;
  20098. /**
  20099. * Creates a new rotation matrix for "angle" radians around the X axis
  20100. * @param angle defines the angle (in radians) to use
  20101. * @return the new matrix
  20102. */
  20103. static RotationX(angle: number): Matrix;
  20104. /**
  20105. * Creates a new matrix as the invert of a given matrix
  20106. * @param source defines the source matrix
  20107. * @returns the new matrix
  20108. */
  20109. static Invert(source: DeepImmutable<Matrix>): Matrix;
  20110. /**
  20111. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  20112. * @param angle defines the angle (in radians) to use
  20113. * @param result defines the target matrix
  20114. */
  20115. static RotationXToRef(angle: number, result: Matrix): void;
  20116. /**
  20117. * Creates a new rotation matrix for "angle" radians around the Y axis
  20118. * @param angle defines the angle (in radians) to use
  20119. * @return the new matrix
  20120. */
  20121. static RotationY(angle: number): Matrix;
  20122. /**
  20123. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  20124. * @param angle defines the angle (in radians) to use
  20125. * @param result defines the target matrix
  20126. */
  20127. static RotationYToRef(angle: number, result: Matrix): void;
  20128. /**
  20129. * Creates a new rotation matrix for "angle" radians around the Z axis
  20130. * @param angle defines the angle (in radians) to use
  20131. * @return the new matrix
  20132. */
  20133. static RotationZ(angle: number): Matrix;
  20134. /**
  20135. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  20136. * @param angle defines the angle (in radians) to use
  20137. * @param result defines the target matrix
  20138. */
  20139. static RotationZToRef(angle: number, result: Matrix): void;
  20140. /**
  20141. * Creates a new rotation matrix for "angle" radians around the given axis
  20142. * @param axis defines the axis to use
  20143. * @param angle defines the angle (in radians) to use
  20144. * @return the new matrix
  20145. */
  20146. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  20147. /**
  20148. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  20149. * @param axis defines the axis to use
  20150. * @param angle defines the angle (in radians) to use
  20151. * @param result defines the target matrix
  20152. */
  20153. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  20154. /**
  20155. * Creates a rotation matrix
  20156. * @param yaw defines the yaw angle in radians (Y axis)
  20157. * @param pitch defines the pitch angle in radians (X axis)
  20158. * @param roll defines the roll angle in radians (X axis)
  20159. * @returns the new rotation matrix
  20160. */
  20161. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  20162. /**
  20163. * Creates a rotation matrix and stores it in a given matrix
  20164. * @param yaw defines the yaw angle in radians (Y axis)
  20165. * @param pitch defines the pitch angle in radians (X axis)
  20166. * @param roll defines the roll angle in radians (X axis)
  20167. * @param result defines the target matrix
  20168. */
  20169. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  20170. /**
  20171. * Creates a scaling matrix
  20172. * @param x defines the scale factor on X axis
  20173. * @param y defines the scale factor on Y axis
  20174. * @param z defines the scale factor on Z axis
  20175. * @returns the new matrix
  20176. */
  20177. static Scaling(x: number, y: number, z: number): Matrix;
  20178. /**
  20179. * Creates a scaling matrix and stores it in a given matrix
  20180. * @param x defines the scale factor on X axis
  20181. * @param y defines the scale factor on Y axis
  20182. * @param z defines the scale factor on Z axis
  20183. * @param result defines the target matrix
  20184. */
  20185. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  20186. /**
  20187. * Creates a translation matrix
  20188. * @param x defines the translation on X axis
  20189. * @param y defines the translation on Y axis
  20190. * @param z defines the translationon Z axis
  20191. * @returns the new matrix
  20192. */
  20193. static Translation(x: number, y: number, z: number): Matrix;
  20194. /**
  20195. * Creates a translation matrix and stores it in a given matrix
  20196. * @param x defines the translation on X axis
  20197. * @param y defines the translation on Y axis
  20198. * @param z defines the translationon Z axis
  20199. * @param result defines the target matrix
  20200. */
  20201. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  20202. /**
  20203. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  20204. * @param startValue defines the start value
  20205. * @param endValue defines the end value
  20206. * @param gradient defines the gradient factor
  20207. * @returns the new matrix
  20208. */
  20209. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  20210. /**
  20211. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  20212. * @param startValue defines the start value
  20213. * @param endValue defines the end value
  20214. * @param gradient defines the gradient factor
  20215. * @param result defines the Matrix object where to store data
  20216. */
  20217. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  20218. /**
  20219. * Builds a new matrix whose values are computed by:
  20220. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  20221. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  20222. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  20223. * @param startValue defines the first matrix
  20224. * @param endValue defines the second matrix
  20225. * @param gradient defines the gradient between the two matrices
  20226. * @returns the new matrix
  20227. */
  20228. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  20229. /**
  20230. * Update a matrix to values which are computed by:
  20231. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  20232. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  20233. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  20234. * @param startValue defines the first matrix
  20235. * @param endValue defines the second matrix
  20236. * @param gradient defines the gradient between the two matrices
  20237. * @param result defines the target matrix
  20238. */
  20239. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  20240. /**
  20241. * 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"
  20242. * This function works in left handed mode
  20243. * @param eye defines the final position of the entity
  20244. * @param target defines where the entity should look at
  20245. * @param up defines the up vector for the entity
  20246. * @returns the new matrix
  20247. */
  20248. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  20249. /**
  20250. * 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".
  20251. * This function works in left handed mode
  20252. * @param eye defines the final position of the entity
  20253. * @param target defines where the entity should look at
  20254. * @param up defines the up vector for the entity
  20255. * @param result defines the target matrix
  20256. */
  20257. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  20258. /**
  20259. * 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"
  20260. * This function works in right handed mode
  20261. * @param eye defines the final position of the entity
  20262. * @param target defines where the entity should look at
  20263. * @param up defines the up vector for the entity
  20264. * @returns the new matrix
  20265. */
  20266. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  20267. /**
  20268. * 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".
  20269. * This function works in right handed mode
  20270. * @param eye defines the final position of the entity
  20271. * @param target defines where the entity should look at
  20272. * @param up defines the up vector for the entity
  20273. * @param result defines the target matrix
  20274. */
  20275. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  20276. /**
  20277. * Create a left-handed orthographic projection matrix
  20278. * @param width defines the viewport width
  20279. * @param height defines the viewport height
  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 orthographic projection matrix
  20283. */
  20284. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  20285. /**
  20286. * Store a left-handed orthographic projection to a given matrix
  20287. * @param width defines the viewport width
  20288. * @param height defines the viewport height
  20289. * @param znear defines the near clip plane
  20290. * @param zfar defines the far clip plane
  20291. * @param result defines the target matrix
  20292. */
  20293. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  20294. /**
  20295. * Create a left-handed orthographic projection matrix
  20296. * @param left defines the viewport left coordinate
  20297. * @param right defines the viewport right coordinate
  20298. * @param bottom defines the viewport bottom coordinate
  20299. * @param top defines the viewport top coordinate
  20300. * @param znear defines the near clip plane
  20301. * @param zfar defines the far clip plane
  20302. * @returns a new matrix as a left-handed orthographic projection matrix
  20303. */
  20304. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  20305. /**
  20306. * Stores a left-handed orthographic projection into a given matrix
  20307. * @param left defines the viewport left coordinate
  20308. * @param right defines the viewport right coordinate
  20309. * @param bottom defines the viewport bottom coordinate
  20310. * @param top defines the viewport top coordinate
  20311. * @param znear defines the near clip plane
  20312. * @param zfar defines the far clip plane
  20313. * @param result defines the target matrix
  20314. */
  20315. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  20316. /**
  20317. * Creates a right-handed orthographic projection matrix
  20318. * @param left defines the viewport left coordinate
  20319. * @param right defines the viewport right coordinate
  20320. * @param bottom defines the viewport bottom coordinate
  20321. * @param top defines the viewport top coordinate
  20322. * @param znear defines the near clip plane
  20323. * @param zfar defines the far clip plane
  20324. * @returns a new matrix as a right-handed orthographic projection matrix
  20325. */
  20326. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  20327. /**
  20328. * Stores a right-handed orthographic projection into a given matrix
  20329. * @param left defines the viewport left coordinate
  20330. * @param right defines the viewport right coordinate
  20331. * @param bottom defines the viewport bottom coordinate
  20332. * @param top defines the viewport top coordinate
  20333. * @param znear defines the near clip plane
  20334. * @param zfar defines the far clip plane
  20335. * @param result defines the target matrix
  20336. */
  20337. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  20338. /**
  20339. * Creates a left-handed perspective projection matrix
  20340. * @param width defines the viewport width
  20341. * @param height defines the viewport height
  20342. * @param znear defines the near clip plane
  20343. * @param zfar defines the far clip plane
  20344. * @returns a new matrix as a left-handed perspective projection matrix
  20345. */
  20346. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  20347. /**
  20348. * Creates a left-handed perspective projection matrix
  20349. * @param fov defines the horizontal field of view
  20350. * @param aspect defines the aspect ratio
  20351. * @param znear defines the near clip plane
  20352. * @param zfar defines the far clip plane
  20353. * @returns a new matrix as a left-handed perspective projection matrix
  20354. */
  20355. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  20356. /**
  20357. * Stores a left-handed perspective projection into a given matrix
  20358. * @param fov defines the horizontal field of view
  20359. * @param aspect defines the aspect ratio
  20360. * @param znear defines the near clip plane
  20361. * @param zfar defines the far clip plane
  20362. * @param result defines the target matrix
  20363. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  20364. */
  20365. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  20366. /**
  20367. * Creates a right-handed perspective projection matrix
  20368. * @param fov defines the horizontal field of view
  20369. * @param aspect defines the aspect ratio
  20370. * @param znear defines the near clip plane
  20371. * @param zfar defines the far clip plane
  20372. * @returns a new matrix as a right-handed perspective projection matrix
  20373. */
  20374. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  20375. /**
  20376. * Stores a right-handed perspective projection into a given matrix
  20377. * @param fov defines the horizontal field of view
  20378. * @param aspect defines the aspect ratio
  20379. * @param znear defines the near clip plane
  20380. * @param zfar defines the far clip plane
  20381. * @param result defines the target matrix
  20382. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  20383. */
  20384. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  20385. /**
  20386. * Stores a perspective projection for WebVR info a given matrix
  20387. * @param fov defines the field of view
  20388. * @param znear defines the near clip plane
  20389. * @param zfar defines the far clip plane
  20390. * @param result defines the target matrix
  20391. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  20392. */
  20393. static PerspectiveFovWebVRToRef(fov: {
  20394. upDegrees: number;
  20395. downDegrees: number;
  20396. leftDegrees: number;
  20397. rightDegrees: number;
  20398. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  20399. /**
  20400. * Computes a complete transformation matrix
  20401. * @param viewport defines the viewport to use
  20402. * @param world defines the world matrix
  20403. * @param view defines the view matrix
  20404. * @param projection defines the projection matrix
  20405. * @param zmin defines the near clip plane
  20406. * @param zmax defines the far clip plane
  20407. * @returns the transformation matrix
  20408. */
  20409. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  20410. /**
  20411. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  20412. * @param matrix defines the matrix to use
  20413. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  20414. */
  20415. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  20416. /**
  20417. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  20418. * @param matrix defines the matrix to use
  20419. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  20420. */
  20421. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  20422. /**
  20423. * Compute the transpose of a given matrix
  20424. * @param matrix defines the matrix to transpose
  20425. * @returns the new matrix
  20426. */
  20427. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  20428. /**
  20429. * Compute the transpose of a matrix and store it in a target matrix
  20430. * @param matrix defines the matrix to transpose
  20431. * @param result defines the target matrix
  20432. */
  20433. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  20434. /**
  20435. * Computes a reflection matrix from a plane
  20436. * @param plane defines the reflection plane
  20437. * @returns a new matrix
  20438. */
  20439. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  20440. /**
  20441. * Computes a reflection matrix from a plane
  20442. * @param plane defines the reflection plane
  20443. * @param result defines the target matrix
  20444. */
  20445. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  20446. /**
  20447. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  20448. * @param xaxis defines the value of the 1st axis
  20449. * @param yaxis defines the value of the 2nd axis
  20450. * @param zaxis defines the value of the 3rd axis
  20451. * @param result defines the target matrix
  20452. */
  20453. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  20454. /**
  20455. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  20456. * @param quat defines the quaternion to use
  20457. * @param result defines the target matrix
  20458. */
  20459. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  20460. }
  20461. /**
  20462. * Represens a plane by the equation ax + by + cz + d = 0
  20463. */
  20464. class Plane {
  20465. /**
  20466. * Normal of the plane (a,b,c)
  20467. */
  20468. normal: Vector3;
  20469. /**
  20470. * d component of the plane
  20471. */
  20472. d: number;
  20473. /**
  20474. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  20475. * @param a a component of the plane
  20476. * @param b b component of the plane
  20477. * @param c c component of the plane
  20478. * @param d d component of the plane
  20479. */
  20480. constructor(a: number, b: number, c: number, d: number);
  20481. /**
  20482. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  20483. */
  20484. asArray(): number[];
  20485. /**
  20486. * @returns a new plane copied from the current Plane.
  20487. */
  20488. clone(): Plane;
  20489. /**
  20490. * @returns the string "Plane".
  20491. */
  20492. getClassName(): string;
  20493. /**
  20494. * @returns the Plane hash code.
  20495. */
  20496. getHashCode(): number;
  20497. /**
  20498. * Normalize the current Plane in place.
  20499. * @returns the updated Plane.
  20500. */
  20501. normalize(): Plane;
  20502. /**
  20503. * Applies a transformation the plane and returns the result
  20504. * @param transformation the transformation matrix to be applied to the plane
  20505. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  20506. */
  20507. transform(transformation: DeepImmutable<Matrix>): Plane;
  20508. /**
  20509. * Calcualtte the dot product between the point and the plane normal
  20510. * @param point point to calculate the dot product with
  20511. * @returns the dot product (float) of the point coordinates and the plane normal.
  20512. */
  20513. dotCoordinate(point: DeepImmutable<Vector3>): number;
  20514. /**
  20515. * Updates the current Plane from the plane defined by the three given points.
  20516. * @param point1 one of the points used to contruct the plane
  20517. * @param point2 one of the points used to contruct the plane
  20518. * @param point3 one of the points used to contruct the plane
  20519. * @returns the updated Plane.
  20520. */
  20521. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  20522. /**
  20523. * Checks if the plane is facing a given direction
  20524. * @param direction the direction to check if the plane is facing
  20525. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  20526. * @returns True is the vector "direction" is the same side than the plane normal.
  20527. */
  20528. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  20529. /**
  20530. * Calculates the distance to a point
  20531. * @param point point to calculate distance to
  20532. * @returns the signed distance (float) from the given point to the Plane.
  20533. */
  20534. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  20535. /**
  20536. * Creates a plane from an array
  20537. * @param array the array to create a plane from
  20538. * @returns a new Plane from the given array.
  20539. */
  20540. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  20541. /**
  20542. * Creates a plane from three points
  20543. * @param point1 point used to create the plane
  20544. * @param point2 point used to create the plane
  20545. * @param point3 point used to create the plane
  20546. * @returns a new Plane defined by the three given points.
  20547. */
  20548. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  20549. /**
  20550. * Creates a plane from an origin point and a normal
  20551. * @param origin origin of the plane to be constructed
  20552. * @param normal normal of the plane to be constructed
  20553. * @returns a new Plane the normal vector to this plane at the given origin point.
  20554. * Note : the vector "normal" is updated because normalized.
  20555. */
  20556. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  20557. /**
  20558. * Calculates the distance from a plane and a point
  20559. * @param origin origin of the plane to be constructed
  20560. * @param normal normal of the plane to be constructed
  20561. * @param point point to calculate distance to
  20562. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  20563. */
  20564. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  20565. }
  20566. /**
  20567. * Class used to represent a viewport on screen
  20568. */
  20569. class Viewport {
  20570. /** viewport left coordinate */
  20571. x: number;
  20572. /** viewport top coordinate */
  20573. y: number;
  20574. /**viewport width */
  20575. width: number;
  20576. /** viewport height */
  20577. height: number;
  20578. /**
  20579. * Creates a Viewport object located at (x, y) and sized (width, height)
  20580. * @param x defines viewport left coordinate
  20581. * @param y defines viewport top coordinate
  20582. * @param width defines the viewport width
  20583. * @param height defines the viewport height
  20584. */
  20585. constructor(
  20586. /** viewport left coordinate */
  20587. x: number,
  20588. /** viewport top coordinate */
  20589. y: number,
  20590. /**viewport width */
  20591. width: number,
  20592. /** viewport height */
  20593. height: number);
  20594. /**
  20595. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  20596. * @param renderWidthOrEngine defines either an engine or the rendering width
  20597. * @param renderHeight defines the rendering height
  20598. * @returns a new Viewport
  20599. */
  20600. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  20601. /**
  20602. * Returns a new Viewport copied from the current one
  20603. * @returns a new Viewport
  20604. */
  20605. clone(): Viewport;
  20606. }
  20607. /**
  20608. * Reprasents a camera frustum
  20609. */
  20610. class Frustum {
  20611. /**
  20612. * Gets the planes representing the frustum
  20613. * @param transform matrix to be applied to the returned planes
  20614. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  20615. */
  20616. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  20617. /**
  20618. * Gets the near frustum plane transformed by the transform matrix
  20619. * @param transform transformation matrix to be applied to the resulting frustum plane
  20620. * @param frustumPlane the resuling frustum plane
  20621. */
  20622. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20623. /**
  20624. * Gets the far frustum plane transformed by the transform matrix
  20625. * @param transform transformation matrix to be applied to the resulting frustum plane
  20626. * @param frustumPlane the resuling frustum plane
  20627. */
  20628. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20629. /**
  20630. * Gets the left frustum plane transformed by the transform matrix
  20631. * @param transform transformation matrix to be applied to the resulting frustum plane
  20632. * @param frustumPlane the resuling frustum plane
  20633. */
  20634. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20635. /**
  20636. * Gets the right frustum plane transformed by the transform matrix
  20637. * @param transform transformation matrix to be applied to the resulting frustum plane
  20638. * @param frustumPlane the resuling frustum plane
  20639. */
  20640. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20641. /**
  20642. * Gets the top frustum plane transformed by the transform matrix
  20643. * @param transform transformation matrix to be applied to the resulting frustum plane
  20644. * @param frustumPlane the resuling frustum plane
  20645. */
  20646. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20647. /**
  20648. * Gets the bottom frustum plane transformed by the transform matrix
  20649. * @param transform transformation matrix to be applied to the resulting frustum plane
  20650. * @param frustumPlane the resuling frustum plane
  20651. */
  20652. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20653. /**
  20654. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  20655. * @param transform transformation matrix to be applied to the resulting frustum planes
  20656. * @param frustumPlanes the resuling frustum planes
  20657. */
  20658. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  20659. }
  20660. /** Defines supported spaces */
  20661. enum Space {
  20662. /** Local (object) space */
  20663. LOCAL = 0,
  20664. /** World space */
  20665. WORLD = 1,
  20666. /** Bone space */
  20667. BONE = 2
  20668. }
  20669. /** Defines the 3 main axes */
  20670. class Axis {
  20671. /** X axis */
  20672. static X: Vector3;
  20673. /** Y axis */
  20674. static Y: Vector3;
  20675. /** Z axis */
  20676. static Z: Vector3;
  20677. }
  20678. /** Class used to represent a Bezier curve */
  20679. class BezierCurve {
  20680. /**
  20681. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  20682. * @param t defines the time
  20683. * @param x1 defines the left coordinate on X axis
  20684. * @param y1 defines the left coordinate on Y axis
  20685. * @param x2 defines the right coordinate on X axis
  20686. * @param y2 defines the right coordinate on Y axis
  20687. * @returns the interpolated value
  20688. */
  20689. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  20690. }
  20691. /**
  20692. * Defines potential orientation for back face culling
  20693. */
  20694. enum Orientation {
  20695. /**
  20696. * Clockwise
  20697. */
  20698. CW = 0,
  20699. /** Counter clockwise */
  20700. CCW = 1
  20701. }
  20702. /**
  20703. * Defines angle representation
  20704. */
  20705. class Angle {
  20706. private _radians;
  20707. /**
  20708. * Creates an Angle object of "radians" radians (float).
  20709. */
  20710. constructor(radians: number);
  20711. /**
  20712. * Get value in degrees
  20713. * @returns the Angle value in degrees (float)
  20714. */
  20715. degrees(): number;
  20716. /**
  20717. * Get value in radians
  20718. * @returns the Angle value in radians (float)
  20719. */
  20720. radians(): number;
  20721. /**
  20722. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  20723. * @param a defines first vector
  20724. * @param b defines second vector
  20725. * @returns a new Angle
  20726. */
  20727. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  20728. /**
  20729. * Gets a new Angle object from the given float in radians
  20730. * @param radians defines the angle value in radians
  20731. * @returns a new Angle
  20732. */
  20733. static FromRadians(radians: number): Angle;
  20734. /**
  20735. * Gets a new Angle object from the given float in degrees
  20736. * @param degrees defines the angle value in degrees
  20737. * @returns a new Angle
  20738. */
  20739. static FromDegrees(degrees: number): Angle;
  20740. }
  20741. /**
  20742. * This represents an arc in a 2d space.
  20743. */
  20744. class Arc2 {
  20745. /** Defines the start point of the arc */
  20746. startPoint: Vector2;
  20747. /** Defines the mid point of the arc */
  20748. midPoint: Vector2;
  20749. /** Defines the end point of the arc */
  20750. endPoint: Vector2;
  20751. /**
  20752. * Defines the center point of the arc.
  20753. */
  20754. centerPoint: Vector2;
  20755. /**
  20756. * Defines the radius of the arc.
  20757. */
  20758. radius: number;
  20759. /**
  20760. * Defines the angle of the arc (from mid point to end point).
  20761. */
  20762. angle: Angle;
  20763. /**
  20764. * Defines the start angle of the arc (from start point to middle point).
  20765. */
  20766. startAngle: Angle;
  20767. /**
  20768. * Defines the orientation of the arc (clock wise/counter clock wise).
  20769. */
  20770. orientation: Orientation;
  20771. /**
  20772. * Creates an Arc object from the three given points : start, middle and end.
  20773. * @param startPoint Defines the start point of the arc
  20774. * @param midPoint Defines the midlle point of the arc
  20775. * @param endPoint Defines the end point of the arc
  20776. */
  20777. constructor(
  20778. /** Defines the start point of the arc */
  20779. startPoint: Vector2,
  20780. /** Defines the mid point of the arc */
  20781. midPoint: Vector2,
  20782. /** Defines the end point of the arc */
  20783. endPoint: Vector2);
  20784. }
  20785. /**
  20786. * Represents a 2D path made up of multiple 2D points
  20787. */
  20788. class Path2 {
  20789. private _points;
  20790. private _length;
  20791. /**
  20792. * If the path start and end point are the same
  20793. */
  20794. closed: boolean;
  20795. /**
  20796. * Creates a Path2 object from the starting 2D coordinates x and y.
  20797. * @param x the starting points x value
  20798. * @param y the starting points y value
  20799. */
  20800. constructor(x: number, y: number);
  20801. /**
  20802. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  20803. * @param x the added points x value
  20804. * @param y the added points y value
  20805. * @returns the updated Path2.
  20806. */
  20807. addLineTo(x: number, y: number): Path2;
  20808. /**
  20809. * 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.
  20810. * @param midX middle point x value
  20811. * @param midY middle point y value
  20812. * @param endX end point x value
  20813. * @param endY end point y value
  20814. * @param numberOfSegments (default: 36)
  20815. * @returns the updated Path2.
  20816. */
  20817. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  20818. /**
  20819. * Closes the Path2.
  20820. * @returns the Path2.
  20821. */
  20822. close(): Path2;
  20823. /**
  20824. * Gets the sum of the distance between each sequential point in the path
  20825. * @returns the Path2 total length (float).
  20826. */
  20827. length(): number;
  20828. /**
  20829. * Gets the points which construct the path
  20830. * @returns the Path2 internal array of points.
  20831. */
  20832. getPoints(): Vector2[];
  20833. /**
  20834. * Retreives the point at the distance aways from the starting point
  20835. * @param normalizedLengthPosition the length along the path to retreive the point from
  20836. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  20837. */
  20838. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  20839. /**
  20840. * Creates a new path starting from an x and y position
  20841. * @param x starting x value
  20842. * @param y starting y value
  20843. * @returns a new Path2 starting at the coordinates (x, y).
  20844. */
  20845. static StartingAt(x: number, y: number): Path2;
  20846. }
  20847. /**
  20848. * Represents a 3D path made up of multiple 3D points
  20849. */
  20850. class Path3D {
  20851. /**
  20852. * an array of Vector3, the curve axis of the Path3D
  20853. */
  20854. path: Vector3[];
  20855. private _curve;
  20856. private _distances;
  20857. private _tangents;
  20858. private _normals;
  20859. private _binormals;
  20860. private _raw;
  20861. /**
  20862. * new Path3D(path, normal, raw)
  20863. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  20864. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  20865. * @param path an array of Vector3, the curve axis of the Path3D
  20866. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  20867. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  20868. */
  20869. constructor(
  20870. /**
  20871. * an array of Vector3, the curve axis of the Path3D
  20872. */
  20873. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  20874. /**
  20875. * Returns the Path3D array of successive Vector3 designing its curve.
  20876. * @returns the Path3D array of successive Vector3 designing its curve.
  20877. */
  20878. getCurve(): Vector3[];
  20879. /**
  20880. * Returns an array populated with tangent vectors on each Path3D curve point.
  20881. * @returns an array populated with tangent vectors on each Path3D curve point.
  20882. */
  20883. getTangents(): Vector3[];
  20884. /**
  20885. * Returns an array populated with normal vectors on each Path3D curve point.
  20886. * @returns an array populated with normal vectors on each Path3D curve point.
  20887. */
  20888. getNormals(): Vector3[];
  20889. /**
  20890. * Returns an array populated with binormal vectors on each Path3D curve point.
  20891. * @returns an array populated with binormal vectors on each Path3D curve point.
  20892. */
  20893. getBinormals(): Vector3[];
  20894. /**
  20895. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  20896. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  20897. */
  20898. getDistances(): number[];
  20899. /**
  20900. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  20901. * @param path path which all values are copied into the curves points
  20902. * @param firstNormal which should be projected onto the curve
  20903. * @returns the same object updated.
  20904. */
  20905. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  20906. private _compute;
  20907. private _getFirstNonNullVector;
  20908. private _getLastNonNullVector;
  20909. private _normalVector;
  20910. }
  20911. /**
  20912. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  20913. * A Curve3 is designed from a series of successive Vector3.
  20914. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  20915. */
  20916. class Curve3 {
  20917. private _points;
  20918. private _length;
  20919. /**
  20920. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  20921. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  20922. * @param v1 (Vector3) the control point
  20923. * @param v2 (Vector3) the end point of the Quadratic Bezier
  20924. * @param nbPoints (integer) the wanted number of points in the curve
  20925. * @returns the created Curve3
  20926. */
  20927. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  20928. /**
  20929. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  20930. * @param v0 (Vector3) the origin point of the Cubic Bezier
  20931. * @param v1 (Vector3) the first control point
  20932. * @param v2 (Vector3) the second control point
  20933. * @param v3 (Vector3) the end point of the Cubic Bezier
  20934. * @param nbPoints (integer) the wanted number of points in the curve
  20935. * @returns the created Curve3
  20936. */
  20937. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  20938. /**
  20939. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  20940. * @param p1 (Vector3) the origin point of the Hermite Spline
  20941. * @param t1 (Vector3) the tangent vector at the origin point
  20942. * @param p2 (Vector3) the end point of the Hermite Spline
  20943. * @param t2 (Vector3) the tangent vector at the end point
  20944. * @param nbPoints (integer) the wanted number of points in the curve
  20945. * @returns the created Curve3
  20946. */
  20947. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  20948. /**
  20949. * Returns a Curve3 object along a CatmullRom Spline curve :
  20950. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  20951. * @param nbPoints (integer) the wanted number of points between each curve control points
  20952. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  20953. * @returns the created Curve3
  20954. */
  20955. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  20956. /**
  20957. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  20958. * A Curve3 is designed from a series of successive Vector3.
  20959. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  20960. * @param points points which make up the curve
  20961. */
  20962. constructor(points: Vector3[]);
  20963. /**
  20964. * @returns the Curve3 stored array of successive Vector3
  20965. */
  20966. getPoints(): Vector3[];
  20967. /**
  20968. * @returns the computed length (float) of the curve.
  20969. */
  20970. length(): number;
  20971. /**
  20972. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  20973. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  20974. * curveA and curveB keep unchanged.
  20975. * @param curve the curve to continue from this curve
  20976. * @returns the newly constructed curve
  20977. */
  20978. continue(curve: DeepImmutable<Curve3>): Curve3;
  20979. private _computeLength;
  20980. }
  20981. /**
  20982. * Contains position and normal vectors for a vertex
  20983. */
  20984. class PositionNormalVertex {
  20985. /** the position of the vertex (defaut: 0,0,0) */
  20986. position: Vector3;
  20987. /** the normal of the vertex (defaut: 0,1,0) */
  20988. normal: Vector3;
  20989. /**
  20990. * Creates a PositionNormalVertex
  20991. * @param position the position of the vertex (defaut: 0,0,0)
  20992. * @param normal the normal of the vertex (defaut: 0,1,0)
  20993. */
  20994. constructor(
  20995. /** the position of the vertex (defaut: 0,0,0) */
  20996. position?: Vector3,
  20997. /** the normal of the vertex (defaut: 0,1,0) */
  20998. normal?: Vector3);
  20999. /**
  21000. * Clones the PositionNormalVertex
  21001. * @returns the cloned PositionNormalVertex
  21002. */
  21003. clone(): PositionNormalVertex;
  21004. }
  21005. /**
  21006. * Contains position, normal and uv vectors for a vertex
  21007. */
  21008. class PositionNormalTextureVertex {
  21009. /** the position of the vertex (defaut: 0,0,0) */
  21010. position: Vector3;
  21011. /** the normal of the vertex (defaut: 0,1,0) */
  21012. normal: Vector3;
  21013. /** the uv of the vertex (default: 0,0) */
  21014. uv: Vector2;
  21015. /**
  21016. * Creates a PositionNormalTextureVertex
  21017. * @param position the position of the vertex (defaut: 0,0,0)
  21018. * @param normal the normal of the vertex (defaut: 0,1,0)
  21019. * @param uv the uv of the vertex (default: 0,0)
  21020. */
  21021. constructor(
  21022. /** the position of the vertex (defaut: 0,0,0) */
  21023. position?: Vector3,
  21024. /** the normal of the vertex (defaut: 0,1,0) */
  21025. normal?: Vector3,
  21026. /** the uv of the vertex (default: 0,0) */
  21027. uv?: Vector2);
  21028. /**
  21029. * Clones the PositionNormalTextureVertex
  21030. * @returns the cloned PositionNormalTextureVertex
  21031. */
  21032. clone(): PositionNormalTextureVertex;
  21033. }
  21034. /**
  21035. * @hidden
  21036. */
  21037. class Tmp {
  21038. static Color3: Color3[];
  21039. static Color4: Color4[];
  21040. static Vector2: Vector2[];
  21041. static Vector3: Vector3[];
  21042. static Vector4: Vector4[];
  21043. static Quaternion: Quaternion[];
  21044. static Matrix: Matrix[];
  21045. }
  21046. }
  21047. declare module BABYLON {
  21048. /**
  21049. * Class representing spherical polynomial coefficients to the 3rd degree
  21050. */
  21051. class SphericalPolynomial {
  21052. /**
  21053. * The x coefficients of the spherical polynomial
  21054. */
  21055. x: Vector3;
  21056. /**
  21057. * The y coefficients of the spherical polynomial
  21058. */
  21059. y: Vector3;
  21060. /**
  21061. * The z coefficients of the spherical polynomial
  21062. */
  21063. z: Vector3;
  21064. /**
  21065. * The xx coefficients of the spherical polynomial
  21066. */
  21067. xx: Vector3;
  21068. /**
  21069. * The yy coefficients of the spherical polynomial
  21070. */
  21071. yy: Vector3;
  21072. /**
  21073. * The zz coefficients of the spherical polynomial
  21074. */
  21075. zz: Vector3;
  21076. /**
  21077. * The xy coefficients of the spherical polynomial
  21078. */
  21079. xy: Vector3;
  21080. /**
  21081. * The yz coefficients of the spherical polynomial
  21082. */
  21083. yz: Vector3;
  21084. /**
  21085. * The zx coefficients of the spherical polynomial
  21086. */
  21087. zx: Vector3;
  21088. /**
  21089. * Adds an ambient color to the spherical polynomial
  21090. * @param color the color to add
  21091. */
  21092. addAmbient(color: Color3): void;
  21093. /**
  21094. * Scales the spherical polynomial by the given amount
  21095. * @param scale the amount to scale
  21096. */
  21097. scale(scale: number): void;
  21098. /**
  21099. * Gets the spherical polynomial from harmonics
  21100. * @param harmonics the spherical harmonics
  21101. * @returns the spherical polynomial
  21102. */
  21103. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21104. /**
  21105. * Constructs a spherical polynomial from an array.
  21106. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21107. * @returns the spherical polynomial
  21108. */
  21109. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21110. }
  21111. /**
  21112. * Class representing spherical harmonics coefficients to the 3rd degree
  21113. */
  21114. class SphericalHarmonics {
  21115. /**
  21116. * The l0,0 coefficients of the spherical harmonics
  21117. */
  21118. l00: Vector3;
  21119. /**
  21120. * The l1,-1 coefficients of the spherical harmonics
  21121. */
  21122. l1_1: Vector3;
  21123. /**
  21124. * The l1,0 coefficients of the spherical harmonics
  21125. */
  21126. l10: Vector3;
  21127. /**
  21128. * The l1,1 coefficients of the spherical harmonics
  21129. */
  21130. l11: Vector3;
  21131. /**
  21132. * The l2,-2 coefficients of the spherical harmonics
  21133. */
  21134. l2_2: Vector3;
  21135. /**
  21136. * The l2,-1 coefficients of the spherical harmonics
  21137. */
  21138. l2_1: Vector3;
  21139. /**
  21140. * The l2,0 coefficients of the spherical harmonics
  21141. */
  21142. l20: Vector3;
  21143. /**
  21144. * The l2,1 coefficients of the spherical harmonics
  21145. */
  21146. l21: Vector3;
  21147. /**
  21148. * The l2,2 coefficients of the spherical harmonics
  21149. */
  21150. lL22: Vector3;
  21151. /**
  21152. * Adds a light to the spherical harmonics
  21153. * @param direction the direction of the light
  21154. * @param color the color of the light
  21155. * @param deltaSolidAngle the delta solid angle of the light
  21156. */
  21157. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21158. /**
  21159. * Scales the spherical harmonics by the given amount
  21160. * @param scale the amount to scale
  21161. */
  21162. scale(scale: number): void;
  21163. /**
  21164. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21165. *
  21166. * ```
  21167. * E_lm = A_l * L_lm
  21168. * ```
  21169. *
  21170. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21171. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21172. * the scaling factors are given in equation 9.
  21173. */
  21174. convertIncidentRadianceToIrradiance(): void;
  21175. /**
  21176. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21177. *
  21178. * ```
  21179. * L = (1/pi) * E * rho
  21180. * ```
  21181. *
  21182. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21183. */
  21184. convertIrradianceToLambertianRadiance(): void;
  21185. /**
  21186. * Gets the spherical harmonics from polynomial
  21187. * @param polynomial the spherical polynomial
  21188. * @returns the spherical harmonics
  21189. */
  21190. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21191. /**
  21192. * Constructs a spherical harmonics from an array.
  21193. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21194. * @returns the spherical harmonics
  21195. */
  21196. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21197. }
  21198. }
  21199. declare module BABYLON {
  21200. /**
  21201. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21202. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21203. * 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;
  21204. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21205. */
  21206. class ColorCurves {
  21207. private _dirty;
  21208. private _tempColor;
  21209. private _globalCurve;
  21210. private _highlightsCurve;
  21211. private _midtonesCurve;
  21212. private _shadowsCurve;
  21213. private _positiveCurve;
  21214. private _negativeCurve;
  21215. private _globalHue;
  21216. private _globalDensity;
  21217. private _globalSaturation;
  21218. private _globalExposure;
  21219. /**
  21220. * Gets the global Hue value.
  21221. * 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).
  21222. */
  21223. /**
  21224. * Sets the global Hue value.
  21225. * 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).
  21226. */
  21227. globalHue: number;
  21228. /**
  21229. * Gets the global Density value.
  21230. * 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.
  21231. * Values less than zero provide a filter of opposite hue.
  21232. */
  21233. /**
  21234. * Sets the global Density value.
  21235. * 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.
  21236. * Values less than zero provide a filter of opposite hue.
  21237. */
  21238. globalDensity: number;
  21239. /**
  21240. * Gets the global Saturation value.
  21241. * 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.
  21242. */
  21243. /**
  21244. * Sets the global Saturation value.
  21245. * 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.
  21246. */
  21247. globalSaturation: number;
  21248. /**
  21249. * Gets the global Exposure value.
  21250. * 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.
  21251. */
  21252. /**
  21253. * Sets the global Exposure 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 exposure and negative values decrease exposure.
  21255. */
  21256. globalExposure: number;
  21257. private _highlightsHue;
  21258. private _highlightsDensity;
  21259. private _highlightsSaturation;
  21260. private _highlightsExposure;
  21261. /**
  21262. * Gets the highlights Hue value.
  21263. * 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).
  21264. */
  21265. /**
  21266. * Sets the highlights Hue value.
  21267. * 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).
  21268. */
  21269. highlightsHue: number;
  21270. /**
  21271. * Gets the highlights Density value.
  21272. * 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.
  21273. * Values less than zero provide a filter of opposite hue.
  21274. */
  21275. /**
  21276. * Sets the highlights Density value.
  21277. * 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.
  21278. * Values less than zero provide a filter of opposite hue.
  21279. */
  21280. highlightsDensity: number;
  21281. /**
  21282. * Gets the highlights Saturation value.
  21283. * 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.
  21284. */
  21285. /**
  21286. * Sets the highlights Saturation value.
  21287. * 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.
  21288. */
  21289. highlightsSaturation: number;
  21290. /**
  21291. * Gets the highlights Exposure value.
  21292. * 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.
  21293. */
  21294. /**
  21295. * Sets the highlights Exposure 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 exposure and negative values decrease exposure.
  21297. */
  21298. highlightsExposure: number;
  21299. private _midtonesHue;
  21300. private _midtonesDensity;
  21301. private _midtonesSaturation;
  21302. private _midtonesExposure;
  21303. /**
  21304. * Gets the midtones Hue value.
  21305. * 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).
  21306. */
  21307. /**
  21308. * Sets the midtones Hue value.
  21309. * 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).
  21310. */
  21311. midtonesHue: number;
  21312. /**
  21313. * Gets the midtones Density value.
  21314. * 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.
  21315. * Values less than zero provide a filter of opposite hue.
  21316. */
  21317. /**
  21318. * Sets the midtones Density value.
  21319. * 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.
  21320. * Values less than zero provide a filter of opposite hue.
  21321. */
  21322. midtonesDensity: number;
  21323. /**
  21324. * Gets the midtones Saturation value.
  21325. * 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.
  21326. */
  21327. /**
  21328. * Sets the midtones Saturation value.
  21329. * 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.
  21330. */
  21331. midtonesSaturation: number;
  21332. /**
  21333. * Gets the midtones Exposure value.
  21334. * 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.
  21335. */
  21336. /**
  21337. * Sets the midtones Exposure value.
  21338. * 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.
  21339. */
  21340. midtonesExposure: number;
  21341. private _shadowsHue;
  21342. private _shadowsDensity;
  21343. private _shadowsSaturation;
  21344. private _shadowsExposure;
  21345. /**
  21346. * Gets the shadows Hue value.
  21347. * 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).
  21348. */
  21349. /**
  21350. * Sets the shadows Hue value.
  21351. * 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).
  21352. */
  21353. shadowsHue: number;
  21354. /**
  21355. * Gets the shadows Density value.
  21356. * 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.
  21357. * Values less than zero provide a filter of opposite hue.
  21358. */
  21359. /**
  21360. * Sets the shadows Density value.
  21361. * 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.
  21362. * Values less than zero provide a filter of opposite hue.
  21363. */
  21364. shadowsDensity: number;
  21365. /**
  21366. * Gets the shadows Saturation value.
  21367. * 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.
  21368. */
  21369. /**
  21370. * Sets the shadows Saturation value.
  21371. * 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.
  21372. */
  21373. shadowsSaturation: number;
  21374. /**
  21375. * Gets the shadows Exposure value.
  21376. * 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.
  21377. */
  21378. /**
  21379. * Sets the shadows Exposure value.
  21380. * 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.
  21381. */
  21382. shadowsExposure: number;
  21383. /**
  21384. * Returns the class name
  21385. * @returns The class name
  21386. */
  21387. getClassName(): string;
  21388. /**
  21389. * Binds the color curves to the shader.
  21390. * @param colorCurves The color curve to bind
  21391. * @param effect The effect to bind to
  21392. * @param positiveUniform The positive uniform shader parameter
  21393. * @param neutralUniform The neutral uniform shader parameter
  21394. * @param negativeUniform The negative uniform shader parameter
  21395. */
  21396. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  21397. /**
  21398. * Prepare the list of uniforms associated with the ColorCurves effects.
  21399. * @param uniformsList The list of uniforms used in the effect
  21400. */
  21401. static PrepareUniforms(uniformsList: string[]): void;
  21402. /**
  21403. * Returns color grading data based on a hue, density, saturation and exposure value.
  21404. * @param filterHue The hue of the color filter.
  21405. * @param filterDensity The density of the color filter.
  21406. * @param saturation The saturation.
  21407. * @param exposure The exposure.
  21408. * @param result The result data container.
  21409. */
  21410. private getColorGradingDataToRef;
  21411. /**
  21412. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  21413. * @param value The input slider value in range [-100,100].
  21414. * @returns Adjusted value.
  21415. */
  21416. private static applyColorGradingSliderNonlinear;
  21417. /**
  21418. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  21419. * @param hue The hue (H) input.
  21420. * @param saturation The saturation (S) input.
  21421. * @param brightness The brightness (B) input.
  21422. * @result An RGBA color represented as Vector4.
  21423. */
  21424. private static fromHSBToRef;
  21425. /**
  21426. * Returns a value clamped between min and max
  21427. * @param value The value to clamp
  21428. * @param min The minimum of value
  21429. * @param max The maximum of value
  21430. * @returns The clamped value.
  21431. */
  21432. private static clamp;
  21433. /**
  21434. * Clones the current color curve instance.
  21435. * @return The cloned curves
  21436. */
  21437. clone(): ColorCurves;
  21438. /**
  21439. * Serializes the current color curve instance to a json representation.
  21440. * @return a JSON representation
  21441. */
  21442. serialize(): any;
  21443. /**
  21444. * Parses the color curve from a json representation.
  21445. * @param source the JSON source to parse
  21446. * @return The parsed curves
  21447. */
  21448. static Parse(source: any): ColorCurves;
  21449. }
  21450. }
  21451. declare module BABYLON {
  21452. /**
  21453. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  21454. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  21455. */
  21456. class EffectFallbacks {
  21457. private _defines;
  21458. private _currentRank;
  21459. private _maxRank;
  21460. private _mesh;
  21461. /**
  21462. * Removes the fallback from the bound mesh.
  21463. */
  21464. unBindMesh(): void;
  21465. /**
  21466. * Adds a fallback on the specified property.
  21467. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  21468. * @param define The name of the define in the shader
  21469. */
  21470. addFallback(rank: number, define: string): void;
  21471. /**
  21472. * Sets the mesh to use CPU skinning when needing to fallback.
  21473. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  21474. * @param mesh The mesh to use the fallbacks.
  21475. */
  21476. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  21477. /**
  21478. * Checks to see if more fallbacks are still availible.
  21479. */
  21480. readonly isMoreFallbacks: boolean;
  21481. /**
  21482. * Removes the defines that shoould be removed when falling back.
  21483. * @param currentDefines defines the current define statements for the shader.
  21484. * @param effect defines the current effect we try to compile
  21485. * @returns The resulting defines with defines of the current rank removed.
  21486. */
  21487. reduce(currentDefines: string, effect: Effect): string;
  21488. }
  21489. /**
  21490. * Options to be used when creating an effect.
  21491. */
  21492. class EffectCreationOptions {
  21493. /**
  21494. * Atrributes that will be used in the shader.
  21495. */
  21496. attributes: string[];
  21497. /**
  21498. * Uniform varible names that will be set in the shader.
  21499. */
  21500. uniformsNames: string[];
  21501. /**
  21502. * Uniform buffer varible names that will be set in the shader.
  21503. */
  21504. uniformBuffersNames: string[];
  21505. /**
  21506. * Sampler texture variable names that will be set in the shader.
  21507. */
  21508. samplers: string[];
  21509. /**
  21510. * Define statements that will be set in the shader.
  21511. */
  21512. defines: any;
  21513. /**
  21514. * Possible fallbacks for this effect to improve performance when needed.
  21515. */
  21516. fallbacks: Nullable<EffectFallbacks>;
  21517. /**
  21518. * Callback that will be called when the shader is compiled.
  21519. */
  21520. onCompiled: Nullable<(effect: Effect) => void>;
  21521. /**
  21522. * Callback that will be called if an error occurs during shader compilation.
  21523. */
  21524. onError: Nullable<(effect: Effect, errors: string) => void>;
  21525. /**
  21526. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  21527. */
  21528. indexParameters: any;
  21529. /**
  21530. * Max number of lights that can be used in the shader.
  21531. */
  21532. maxSimultaneousLights: number;
  21533. /**
  21534. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  21535. */
  21536. transformFeedbackVaryings: Nullable<string[]>;
  21537. }
  21538. /**
  21539. * Effect containing vertex and fragment shader that can be executed on an object.
  21540. */
  21541. class Effect {
  21542. /**
  21543. * Name of the effect.
  21544. */
  21545. name: any;
  21546. /**
  21547. * String container all the define statements that should be set on the shader.
  21548. */
  21549. defines: string;
  21550. /**
  21551. * Callback that will be called when the shader is compiled.
  21552. */
  21553. onCompiled: Nullable<(effect: Effect) => void>;
  21554. /**
  21555. * Callback that will be called if an error occurs during shader compilation.
  21556. */
  21557. onError: Nullable<(effect: Effect, errors: string) => void>;
  21558. /**
  21559. * Callback that will be called when effect is bound.
  21560. */
  21561. onBind: Nullable<(effect: Effect) => void>;
  21562. /**
  21563. * Unique ID of the effect.
  21564. */
  21565. uniqueId: number;
  21566. /**
  21567. * Observable that will be called when the shader is compiled.
  21568. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  21569. */
  21570. onCompileObservable: Observable<Effect>;
  21571. /**
  21572. * Observable that will be called if an error occurs during shader compilation.
  21573. */
  21574. onErrorObservable: Observable<Effect>;
  21575. /** @hidden */
  21576. _onBindObservable: Nullable<Observable<Effect>>;
  21577. /**
  21578. * Observable that will be called when effect is bound.
  21579. */
  21580. readonly onBindObservable: Observable<Effect>;
  21581. /** @hidden */
  21582. _bonesComputationForcedToCPU: boolean;
  21583. private static _uniqueIdSeed;
  21584. private _engine;
  21585. private _uniformBuffersNames;
  21586. private _uniformsNames;
  21587. private _samplers;
  21588. private _isReady;
  21589. private _compilationError;
  21590. private _attributesNames;
  21591. private _attributes;
  21592. private _uniforms;
  21593. /**
  21594. * Key for the effect.
  21595. * @hidden
  21596. */
  21597. _key: string;
  21598. private _indexParameters;
  21599. private _fallbacks;
  21600. private _vertexSourceCode;
  21601. private _fragmentSourceCode;
  21602. private _vertexSourceCodeOverride;
  21603. private _fragmentSourceCodeOverride;
  21604. private _transformFeedbackVaryings;
  21605. /**
  21606. * Compiled shader to webGL program.
  21607. * @hidden
  21608. */
  21609. _program: WebGLProgram;
  21610. private _valueCache;
  21611. private static _baseCache;
  21612. /**
  21613. * Instantiates an effect.
  21614. * An effect can be used to create/manage/execute vertex and fragment shaders.
  21615. * @param baseName Name of the effect.
  21616. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  21617. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  21618. * @param samplers List of sampler variables that will be passed to the shader.
  21619. * @param engine Engine to be used to render the effect
  21620. * @param defines Define statements to be added to the shader.
  21621. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  21622. * @param onCompiled Callback that will be called when the shader is compiled.
  21623. * @param onError Callback that will be called if an error occurs during shader compilation.
  21624. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  21625. */
  21626. 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);
  21627. /**
  21628. * Unique key for this effect
  21629. */
  21630. readonly key: string;
  21631. /**
  21632. * If the effect has been compiled and prepared.
  21633. * @returns if the effect is compiled and prepared.
  21634. */
  21635. isReady(): boolean;
  21636. /**
  21637. * The engine the effect was initialized with.
  21638. * @returns the engine.
  21639. */
  21640. getEngine(): Engine;
  21641. /**
  21642. * The compiled webGL program for the effect
  21643. * @returns the webGL program.
  21644. */
  21645. getProgram(): WebGLProgram;
  21646. /**
  21647. * The set of names of attribute variables for the shader.
  21648. * @returns An array of attribute names.
  21649. */
  21650. getAttributesNames(): string[];
  21651. /**
  21652. * Returns the attribute at the given index.
  21653. * @param index The index of the attribute.
  21654. * @returns The location of the attribute.
  21655. */
  21656. getAttributeLocation(index: number): number;
  21657. /**
  21658. * Returns the attribute based on the name of the variable.
  21659. * @param name of the attribute to look up.
  21660. * @returns the attribute location.
  21661. */
  21662. getAttributeLocationByName(name: string): number;
  21663. /**
  21664. * The number of attributes.
  21665. * @returns the numnber of attributes.
  21666. */
  21667. getAttributesCount(): number;
  21668. /**
  21669. * Gets the index of a uniform variable.
  21670. * @param uniformName of the uniform to look up.
  21671. * @returns the index.
  21672. */
  21673. getUniformIndex(uniformName: string): number;
  21674. /**
  21675. * Returns the attribute based on the name of the variable.
  21676. * @param uniformName of the uniform to look up.
  21677. * @returns the location of the uniform.
  21678. */
  21679. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  21680. /**
  21681. * Returns an array of sampler variable names
  21682. * @returns The array of sampler variable neames.
  21683. */
  21684. getSamplers(): string[];
  21685. /**
  21686. * The error from the last compilation.
  21687. * @returns the error string.
  21688. */
  21689. getCompilationError(): string;
  21690. /**
  21691. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  21692. * @param func The callback to be used.
  21693. */
  21694. executeWhenCompiled(func: (effect: Effect) => void): void;
  21695. private _checkIsReady;
  21696. /** @hidden */
  21697. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  21698. /** @hidden */
  21699. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  21700. /** @hidden */
  21701. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  21702. private _processShaderConversion;
  21703. private _processIncludes;
  21704. private _processPrecision;
  21705. /**
  21706. * Recompiles the webGL program
  21707. * @param vertexSourceCode The source code for the vertex shader.
  21708. * @param fragmentSourceCode The source code for the fragment shader.
  21709. * @param onCompiled Callback called when completed.
  21710. * @param onError Callback called on error.
  21711. * @hidden
  21712. */
  21713. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  21714. /**
  21715. * Gets the uniform locations of the the specified variable names
  21716. * @param names THe names of the variables to lookup.
  21717. * @returns Array of locations in the same order as variable names.
  21718. */
  21719. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  21720. /**
  21721. * Prepares the effect
  21722. * @hidden
  21723. */
  21724. _prepareEffect(): void;
  21725. /**
  21726. * Checks if the effect is supported. (Must be called after compilation)
  21727. */
  21728. readonly isSupported: boolean;
  21729. /**
  21730. * Binds a texture to the engine to be used as output of the shader.
  21731. * @param channel Name of the output variable.
  21732. * @param texture Texture to bind.
  21733. * @hidden
  21734. */
  21735. _bindTexture(channel: string, texture: InternalTexture): void;
  21736. /**
  21737. * Sets a texture on the engine to be used in the shader.
  21738. * @param channel Name of the sampler variable.
  21739. * @param texture Texture to set.
  21740. */
  21741. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  21742. /**
  21743. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  21744. * @param channel Name of the sampler variable.
  21745. * @param texture Texture to set.
  21746. */
  21747. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  21748. /**
  21749. * Sets an array of textures on the engine to be used in the shader.
  21750. * @param channel Name of the variable.
  21751. * @param textures Textures to set.
  21752. */
  21753. setTextureArray(channel: string, textures: BaseTexture[]): void;
  21754. /**
  21755. * 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)
  21756. * @param channel Name of the sampler variable.
  21757. * @param postProcess Post process to get the input texture from.
  21758. */
  21759. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  21760. /**
  21761. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  21762. * 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)
  21763. * @param channel Name of the sampler variable.
  21764. * @param postProcess Post process to get the output texture from.
  21765. */
  21766. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  21767. /** @hidden */
  21768. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  21769. /** @hidden */
  21770. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  21771. /** @hidden */
  21772. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  21773. /** @hidden */
  21774. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  21775. /**
  21776. * Binds a buffer to a uniform.
  21777. * @param buffer Buffer to bind.
  21778. * @param name Name of the uniform variable to bind to.
  21779. */
  21780. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  21781. /**
  21782. * Binds block to a uniform.
  21783. * @param blockName Name of the block to bind.
  21784. * @param index Index to bind.
  21785. */
  21786. bindUniformBlock(blockName: string, index: number): void;
  21787. /**
  21788. * Sets an interger value on a uniform variable.
  21789. * @param uniformName Name of the variable.
  21790. * @param value Value to be set.
  21791. * @returns this effect.
  21792. */
  21793. setInt(uniformName: string, value: number): Effect;
  21794. /**
  21795. * Sets an int array on a uniform variable.
  21796. * @param uniformName Name of the variable.
  21797. * @param array array to be set.
  21798. * @returns this effect.
  21799. */
  21800. setIntArray(uniformName: string, array: Int32Array): Effect;
  21801. /**
  21802. * 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)
  21803. * @param uniformName Name of the variable.
  21804. * @param array array to be set.
  21805. * @returns this effect.
  21806. */
  21807. setIntArray2(uniformName: string, array: Int32Array): Effect;
  21808. /**
  21809. * 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)
  21810. * @param uniformName Name of the variable.
  21811. * @param array array to be set.
  21812. * @returns this effect.
  21813. */
  21814. setIntArray3(uniformName: string, array: Int32Array): Effect;
  21815. /**
  21816. * 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)
  21817. * @param uniformName Name of the variable.
  21818. * @param array array to be set.
  21819. * @returns this effect.
  21820. */
  21821. setIntArray4(uniformName: string, array: Int32Array): Effect;
  21822. /**
  21823. * Sets an float array on a uniform variable.
  21824. * @param uniformName Name of the variable.
  21825. * @param array array to be set.
  21826. * @returns this effect.
  21827. */
  21828. setFloatArray(uniformName: string, array: Float32Array): Effect;
  21829. /**
  21830. * 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)
  21831. * @param uniformName Name of the variable.
  21832. * @param array array to be set.
  21833. * @returns this effect.
  21834. */
  21835. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  21836. /**
  21837. * 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)
  21838. * @param uniformName Name of the variable.
  21839. * @param array array to be set.
  21840. * @returns this effect.
  21841. */
  21842. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  21843. /**
  21844. * 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)
  21845. * @param uniformName Name of the variable.
  21846. * @param array array to be set.
  21847. * @returns this effect.
  21848. */
  21849. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  21850. /**
  21851. * Sets an array on a uniform variable.
  21852. * @param uniformName Name of the variable.
  21853. * @param array array to be set.
  21854. * @returns this effect.
  21855. */
  21856. setArray(uniformName: string, array: number[]): Effect;
  21857. /**
  21858. * 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)
  21859. * @param uniformName Name of the variable.
  21860. * @param array array to be set.
  21861. * @returns this effect.
  21862. */
  21863. setArray2(uniformName: string, array: number[]): Effect;
  21864. /**
  21865. * 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)
  21866. * @param uniformName Name of the variable.
  21867. * @param array array to be set.
  21868. * @returns this effect.
  21869. */
  21870. setArray3(uniformName: string, array: number[]): Effect;
  21871. /**
  21872. * 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)
  21873. * @param uniformName Name of the variable.
  21874. * @param array array to be set.
  21875. * @returns this effect.
  21876. */
  21877. setArray4(uniformName: string, array: number[]): Effect;
  21878. /**
  21879. * Sets matrices on a uniform variable.
  21880. * @param uniformName Name of the variable.
  21881. * @param matrices matrices to be set.
  21882. * @returns this effect.
  21883. */
  21884. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  21885. /**
  21886. * Sets matrix on a uniform variable.
  21887. * @param uniformName Name of the variable.
  21888. * @param matrix matrix to be set.
  21889. * @returns this effect.
  21890. */
  21891. setMatrix(uniformName: string, matrix: Matrix): Effect;
  21892. /**
  21893. * 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)
  21894. * @param uniformName Name of the variable.
  21895. * @param matrix matrix to be set.
  21896. * @returns this effect.
  21897. */
  21898. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  21899. /**
  21900. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  21901. * @param uniformName Name of the variable.
  21902. * @param matrix matrix to be set.
  21903. * @returns this effect.
  21904. */
  21905. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  21906. /**
  21907. * Sets a float on a uniform variable.
  21908. * @param uniformName Name of the variable.
  21909. * @param value value to be set.
  21910. * @returns this effect.
  21911. */
  21912. setFloat(uniformName: string, value: number): Effect;
  21913. /**
  21914. * Sets a boolean on a uniform variable.
  21915. * @param uniformName Name of the variable.
  21916. * @param bool value to be set.
  21917. * @returns this effect.
  21918. */
  21919. setBool(uniformName: string, bool: boolean): Effect;
  21920. /**
  21921. * Sets a Vector2 on a uniform variable.
  21922. * @param uniformName Name of the variable.
  21923. * @param vector2 vector2 to be set.
  21924. * @returns this effect.
  21925. */
  21926. setVector2(uniformName: string, vector2: Vector2): Effect;
  21927. /**
  21928. * Sets a float2 on a uniform variable.
  21929. * @param uniformName Name of the variable.
  21930. * @param x First float in float2.
  21931. * @param y Second float in float2.
  21932. * @returns this effect.
  21933. */
  21934. setFloat2(uniformName: string, x: number, y: number): Effect;
  21935. /**
  21936. * Sets a Vector3 on a uniform variable.
  21937. * @param uniformName Name of the variable.
  21938. * @param vector3 Value to be set.
  21939. * @returns this effect.
  21940. */
  21941. setVector3(uniformName: string, vector3: Vector3): Effect;
  21942. /**
  21943. * Sets a float3 on a uniform variable.
  21944. * @param uniformName Name of the variable.
  21945. * @param x First float in float3.
  21946. * @param y Second float in float3.
  21947. * @param z Third float in float3.
  21948. * @returns this effect.
  21949. */
  21950. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  21951. /**
  21952. * Sets a Vector4 on a uniform variable.
  21953. * @param uniformName Name of the variable.
  21954. * @param vector4 Value to be set.
  21955. * @returns this effect.
  21956. */
  21957. setVector4(uniformName: string, vector4: Vector4): Effect;
  21958. /**
  21959. * Sets a float4 on a uniform variable.
  21960. * @param uniformName Name of the variable.
  21961. * @param x First float in float4.
  21962. * @param y Second float in float4.
  21963. * @param z Third float in float4.
  21964. * @param w Fourth float in float4.
  21965. * @returns this effect.
  21966. */
  21967. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  21968. /**
  21969. * Sets a Color3 on a uniform variable.
  21970. * @param uniformName Name of the variable.
  21971. * @param color3 Value to be set.
  21972. * @returns this effect.
  21973. */
  21974. setColor3(uniformName: string, color3: Color3): Effect;
  21975. /**
  21976. * Sets a Color4 on a uniform variable.
  21977. * @param uniformName Name of the variable.
  21978. * @param color3 Value to be set.
  21979. * @param alpha Alpha value to be set.
  21980. * @returns this effect.
  21981. */
  21982. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  21983. /**
  21984. * Sets a Color4 on a uniform variable
  21985. * @param uniformName defines the name of the variable
  21986. * @param color4 defines the value to be set
  21987. * @returns this effect.
  21988. */
  21989. setDirectColor4(uniformName: string, color4: Color4): Effect;
  21990. /**
  21991. * This function will add a new shader to the shader store
  21992. * @param name the name of the shader
  21993. * @param pixelShader optional pixel shader content
  21994. * @param vertexShader optional vertex shader content
  21995. */
  21996. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  21997. /**
  21998. * Store of each shader (The can be looked up using effect.key)
  21999. */
  22000. static ShadersStore: {
  22001. [key: string]: string;
  22002. };
  22003. /**
  22004. * Store of each included file for a shader (The can be looked up using effect.key)
  22005. */
  22006. static IncludesShadersStore: {
  22007. [key: string]: string;
  22008. };
  22009. /**
  22010. * Resets the cache of effects.
  22011. */
  22012. static ResetCache(): void;
  22013. }
  22014. }
  22015. declare module BABYLON {
  22016. /**
  22017. * This represents all the required information to add a fresnel effect on a material:
  22018. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  22019. */
  22020. class FresnelParameters {
  22021. private _isEnabled;
  22022. /**
  22023. * Define if the fresnel effect is enable or not.
  22024. */
  22025. isEnabled: boolean;
  22026. /**
  22027. * Define the color used on edges (grazing angle)
  22028. */
  22029. leftColor: Color3;
  22030. /**
  22031. * Define the color used on center
  22032. */
  22033. rightColor: Color3;
  22034. /**
  22035. * Define bias applied to computed fresnel term
  22036. */
  22037. bias: number;
  22038. /**
  22039. * Defined the power exponent applied to fresnel term
  22040. */
  22041. power: number;
  22042. /**
  22043. * Clones the current fresnel and its valuues
  22044. * @returns a clone fresnel configuration
  22045. */
  22046. clone(): FresnelParameters;
  22047. /**
  22048. * Serializes the current fresnel parameters to a JSON representation.
  22049. * @return the JSON serialization
  22050. */
  22051. serialize(): any;
  22052. /**
  22053. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  22054. * @param parsedFresnelParameters Define the JSON representation
  22055. * @returns the parsed parameters
  22056. */
  22057. static Parse(parsedFresnelParameters: any): FresnelParameters;
  22058. }
  22059. }
  22060. declare module BABYLON {
  22061. /**
  22062. * Interface to follow in your material defines to integrate easily the
  22063. * Image proccessing functions.
  22064. * @hidden
  22065. */
  22066. interface IImageProcessingConfigurationDefines {
  22067. IMAGEPROCESSING: boolean;
  22068. VIGNETTE: boolean;
  22069. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22070. VIGNETTEBLENDMODEOPAQUE: boolean;
  22071. TONEMAPPING: boolean;
  22072. TONEMAPPING_ACES: boolean;
  22073. CONTRAST: boolean;
  22074. EXPOSURE: boolean;
  22075. COLORCURVES: boolean;
  22076. COLORGRADING: boolean;
  22077. COLORGRADING3D: boolean;
  22078. SAMPLER3DGREENDEPTH: boolean;
  22079. SAMPLER3DBGRMAP: boolean;
  22080. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22081. }
  22082. /**
  22083. * @hidden
  22084. */
  22085. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22086. IMAGEPROCESSING: boolean;
  22087. VIGNETTE: boolean;
  22088. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22089. VIGNETTEBLENDMODEOPAQUE: boolean;
  22090. TONEMAPPING: boolean;
  22091. TONEMAPPING_ACES: boolean;
  22092. CONTRAST: boolean;
  22093. COLORCURVES: boolean;
  22094. COLORGRADING: boolean;
  22095. COLORGRADING3D: boolean;
  22096. SAMPLER3DGREENDEPTH: boolean;
  22097. SAMPLER3DBGRMAP: boolean;
  22098. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22099. EXPOSURE: boolean;
  22100. constructor();
  22101. }
  22102. /**
  22103. * This groups together the common properties used for image processing either in direct forward pass
  22104. * or through post processing effect depending on the use of the image processing pipeline in your scene
  22105. * or not.
  22106. */
  22107. class ImageProcessingConfiguration {
  22108. /**
  22109. * Default tone mapping applied in BabylonJS.
  22110. */
  22111. static readonly TONEMAPPING_STANDARD: number;
  22112. /**
  22113. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  22114. * to other engines rendering to increase portability.
  22115. */
  22116. static readonly TONEMAPPING_ACES: number;
  22117. /**
  22118. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  22119. */
  22120. colorCurves: Nullable<ColorCurves>;
  22121. private _colorCurvesEnabled;
  22122. /**
  22123. * Gets wether the color curves effect is enabled.
  22124. */
  22125. /**
  22126. * Sets wether the color curves effect is enabled.
  22127. */
  22128. colorCurvesEnabled: boolean;
  22129. private _colorGradingTexture;
  22130. /**
  22131. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  22132. */
  22133. /**
  22134. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  22135. */
  22136. colorGradingTexture: Nullable<BaseTexture>;
  22137. private _colorGradingEnabled;
  22138. /**
  22139. * Gets wether the color grading effect is enabled.
  22140. */
  22141. /**
  22142. * Sets wether the color grading effect is enabled.
  22143. */
  22144. colorGradingEnabled: boolean;
  22145. private _colorGradingWithGreenDepth;
  22146. /**
  22147. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  22148. */
  22149. /**
  22150. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  22151. */
  22152. colorGradingWithGreenDepth: boolean;
  22153. private _colorGradingBGR;
  22154. /**
  22155. * Gets wether the color grading texture contains BGR values.
  22156. */
  22157. /**
  22158. * Sets wether the color grading texture contains BGR values.
  22159. */
  22160. colorGradingBGR: boolean;
  22161. /** @hidden */
  22162. _exposure: number;
  22163. /**
  22164. * Gets the Exposure used in the effect.
  22165. */
  22166. /**
  22167. * Sets the Exposure used in the effect.
  22168. */
  22169. exposure: number;
  22170. private _toneMappingEnabled;
  22171. /**
  22172. * Gets wether the tone mapping effect is enabled.
  22173. */
  22174. /**
  22175. * Sets wether the tone mapping effect is enabled.
  22176. */
  22177. toneMappingEnabled: boolean;
  22178. private _toneMappingType;
  22179. /**
  22180. * Gets the type of tone mapping effect.
  22181. */
  22182. /**
  22183. * Sets the type of tone mapping effect used in BabylonJS.
  22184. */
  22185. toneMappingType: number;
  22186. protected _contrast: number;
  22187. /**
  22188. * Gets the contrast used in the effect.
  22189. */
  22190. /**
  22191. * Sets the contrast used in the effect.
  22192. */
  22193. contrast: number;
  22194. /**
  22195. * Vignette stretch size.
  22196. */
  22197. vignetteStretch: number;
  22198. /**
  22199. * Vignette centre X Offset.
  22200. */
  22201. vignetteCentreX: number;
  22202. /**
  22203. * Vignette centre Y Offset.
  22204. */
  22205. vignetteCentreY: number;
  22206. /**
  22207. * Vignette weight or intensity of the vignette effect.
  22208. */
  22209. vignetteWeight: number;
  22210. /**
  22211. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  22212. * if vignetteEnabled is set to true.
  22213. */
  22214. vignetteColor: Color4;
  22215. /**
  22216. * Camera field of view used by the Vignette effect.
  22217. */
  22218. vignetteCameraFov: number;
  22219. private _vignetteBlendMode;
  22220. /**
  22221. * Gets the vignette blend mode allowing different kind of effect.
  22222. */
  22223. /**
  22224. * Sets the vignette blend mode allowing different kind of effect.
  22225. */
  22226. vignetteBlendMode: number;
  22227. private _vignetteEnabled;
  22228. /**
  22229. * Gets wether the vignette effect is enabled.
  22230. */
  22231. /**
  22232. * Sets wether the vignette effect is enabled.
  22233. */
  22234. vignetteEnabled: boolean;
  22235. private _applyByPostProcess;
  22236. /**
  22237. * Gets wether the image processing is applied through a post process or not.
  22238. */
  22239. /**
  22240. * Sets wether the image processing is applied through a post process or not.
  22241. */
  22242. applyByPostProcess: boolean;
  22243. private _isEnabled;
  22244. /**
  22245. * Gets wether the image processing is enabled or not.
  22246. */
  22247. /**
  22248. * Sets wether the image processing is enabled or not.
  22249. */
  22250. isEnabled: boolean;
  22251. /**
  22252. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  22253. */
  22254. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  22255. /**
  22256. * Method called each time the image processing information changes requires to recompile the effect.
  22257. */
  22258. protected _updateParameters(): void;
  22259. /**
  22260. * Gets the current class name.
  22261. * @return "ImageProcessingConfiguration"
  22262. */
  22263. getClassName(): string;
  22264. /**
  22265. * Prepare the list of uniforms associated with the Image Processing effects.
  22266. * @param uniforms The list of uniforms used in the effect
  22267. * @param defines the list of defines currently in use
  22268. */
  22269. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  22270. /**
  22271. * Prepare the list of samplers associated with the Image Processing effects.
  22272. * @param samplersList The list of uniforms used in the effect
  22273. * @param defines the list of defines currently in use
  22274. */
  22275. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  22276. /**
  22277. * Prepare the list of defines associated to the shader.
  22278. * @param defines the list of defines to complete
  22279. * @param forPostProcess Define if we are currently in post process mode or not
  22280. */
  22281. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  22282. /**
  22283. * Returns true if all the image processing information are ready.
  22284. * @returns True if ready, otherwise, false
  22285. */
  22286. isReady(): boolean;
  22287. /**
  22288. * Binds the image processing to the shader.
  22289. * @param effect The effect to bind to
  22290. * @param aspectRatio Define the current aspect ratio of the effect
  22291. */
  22292. bind(effect: Effect, aspectRatio?: number): void;
  22293. /**
  22294. * Clones the current image processing instance.
  22295. * @return The cloned image processing
  22296. */
  22297. clone(): ImageProcessingConfiguration;
  22298. /**
  22299. * Serializes the current image processing instance to a json representation.
  22300. * @return a JSON representation
  22301. */
  22302. serialize(): any;
  22303. /**
  22304. * Parses the image processing from a json representation.
  22305. * @param source the JSON source to parse
  22306. * @return The parsed image processing
  22307. */
  22308. static Parse(source: any): ImageProcessingConfiguration;
  22309. private static _VIGNETTEMODE_MULTIPLY;
  22310. private static _VIGNETTEMODE_OPAQUE;
  22311. /**
  22312. * Used to apply the vignette as a mix with the pixel color.
  22313. */
  22314. static readonly VIGNETTEMODE_MULTIPLY: number;
  22315. /**
  22316. * Used to apply the vignette as a replacement of the pixel color.
  22317. */
  22318. static readonly VIGNETTEMODE_OPAQUE: number;
  22319. }
  22320. }
  22321. declare module BABYLON {
  22322. /**
  22323. * Manages the defines for the Material
  22324. */
  22325. class MaterialDefines {
  22326. private _keys;
  22327. private _isDirty;
  22328. /** @hidden */
  22329. _renderId: number;
  22330. /** @hidden */
  22331. _areLightsDirty: boolean;
  22332. /** @hidden */
  22333. _areAttributesDirty: boolean;
  22334. /** @hidden */
  22335. _areTexturesDirty: boolean;
  22336. /** @hidden */
  22337. _areFresnelDirty: boolean;
  22338. /** @hidden */
  22339. _areMiscDirty: boolean;
  22340. /** @hidden */
  22341. _areImageProcessingDirty: boolean;
  22342. /** @hidden */
  22343. _normals: boolean;
  22344. /** @hidden */
  22345. _uvs: boolean;
  22346. /** @hidden */
  22347. _needNormals: boolean;
  22348. /** @hidden */
  22349. _needUVs: boolean;
  22350. /**
  22351. * Specifies if the material needs to be re-calculated
  22352. */
  22353. readonly isDirty: boolean;
  22354. /**
  22355. * Marks the material to indicate that it has been re-calculated
  22356. */
  22357. markAsProcessed(): void;
  22358. /**
  22359. * Marks the material to indicate that it needs to be re-calculated
  22360. */
  22361. markAsUnprocessed(): void;
  22362. /**
  22363. * Marks the material to indicate all of its defines need to be re-calculated
  22364. */
  22365. markAllAsDirty(): void;
  22366. /**
  22367. * Marks the material to indicate that image processing needs to be re-calculated
  22368. */
  22369. markAsImageProcessingDirty(): void;
  22370. /**
  22371. * Marks the material to indicate the lights need to be re-calculated
  22372. */
  22373. markAsLightDirty(): void;
  22374. /**
  22375. * Marks the attribute state as changed
  22376. */
  22377. markAsAttributesDirty(): void;
  22378. /**
  22379. * Marks the texture state as changed
  22380. */
  22381. markAsTexturesDirty(): void;
  22382. /**
  22383. * Marks the fresnel state as changed
  22384. */
  22385. markAsFresnelDirty(): void;
  22386. /**
  22387. * Marks the misc state as changed
  22388. */
  22389. markAsMiscDirty(): void;
  22390. /**
  22391. * Rebuilds the material defines
  22392. */
  22393. rebuild(): void;
  22394. /**
  22395. * Specifies if two material defines are equal
  22396. * @param other - A material define instance to compare to
  22397. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  22398. */
  22399. isEqual(other: MaterialDefines): boolean;
  22400. /**
  22401. * Clones this instance's defines to another instance
  22402. * @param other - material defines to clone values to
  22403. */
  22404. cloneTo(other: MaterialDefines): void;
  22405. /**
  22406. * Resets the material define values
  22407. */
  22408. reset(): void;
  22409. /**
  22410. * Converts the material define values to a string
  22411. * @returns - String of material define information
  22412. */
  22413. toString(): string;
  22414. }
  22415. /**
  22416. * Base class for the main features of a material in Babylon.js
  22417. */
  22418. class Material implements IAnimatable {
  22419. private static _TriangleFillMode;
  22420. private static _WireFrameFillMode;
  22421. private static _PointFillMode;
  22422. private static _PointListDrawMode;
  22423. private static _LineListDrawMode;
  22424. private static _LineLoopDrawMode;
  22425. private static _LineStripDrawMode;
  22426. private static _TriangleStripDrawMode;
  22427. private static _TriangleFanDrawMode;
  22428. /**
  22429. * Returns the triangle fill mode
  22430. */
  22431. static readonly TriangleFillMode: number;
  22432. /**
  22433. * Returns the wireframe mode
  22434. */
  22435. static readonly WireFrameFillMode: number;
  22436. /**
  22437. * Returns the point fill mode
  22438. */
  22439. static readonly PointFillMode: number;
  22440. /**
  22441. * Returns the point list draw mode
  22442. */
  22443. static readonly PointListDrawMode: number;
  22444. /**
  22445. * Returns the line list draw mode
  22446. */
  22447. static readonly LineListDrawMode: number;
  22448. /**
  22449. * Returns the line loop draw mode
  22450. */
  22451. static readonly LineLoopDrawMode: number;
  22452. /**
  22453. * Returns the line strip draw mode
  22454. */
  22455. static readonly LineStripDrawMode: number;
  22456. /**
  22457. * Returns the triangle strip draw mode
  22458. */
  22459. static readonly TriangleStripDrawMode: number;
  22460. /**
  22461. * Returns the triangle fan draw mode
  22462. */
  22463. static readonly TriangleFanDrawMode: number;
  22464. /**
  22465. * Stores the clock-wise side orientation
  22466. */
  22467. private static _ClockWiseSideOrientation;
  22468. /**
  22469. * Stores the counter clock-wise side orientation
  22470. */
  22471. private static _CounterClockWiseSideOrientation;
  22472. /**
  22473. * Returns the clock-wise side orientation
  22474. */
  22475. static readonly ClockWiseSideOrientation: number;
  22476. /**
  22477. * Returns the counter clock-wise side orientation
  22478. */
  22479. static readonly CounterClockWiseSideOrientation: number;
  22480. /**
  22481. * The dirty texture flag value
  22482. */
  22483. static readonly TextureDirtyFlag: number;
  22484. /**
  22485. * The dirty light flag value
  22486. */
  22487. static readonly LightDirtyFlag: number;
  22488. /**
  22489. * The dirty fresnel flag value
  22490. */
  22491. static readonly FresnelDirtyFlag: number;
  22492. /**
  22493. * The dirty attribute flag value
  22494. */
  22495. static readonly AttributesDirtyFlag: number;
  22496. /**
  22497. * The dirty misc flag value
  22498. */
  22499. static readonly MiscDirtyFlag: number;
  22500. /**
  22501. * The all dirty flag value
  22502. */
  22503. static readonly AllDirtyFlag: number;
  22504. /**
  22505. * The ID of the material
  22506. */
  22507. id: string;
  22508. /**
  22509. * Gets or sets the unique id of the material
  22510. */
  22511. uniqueId: number;
  22512. /**
  22513. * The name of the material
  22514. */
  22515. name: string;
  22516. /**
  22517. * Gets or sets user defined metadata
  22518. */
  22519. metadata: any;
  22520. /**
  22521. * For internal use only. Please do not use.
  22522. */
  22523. reservedDataStore: any;
  22524. /**
  22525. * Specifies if the ready state should be checked on each call
  22526. */
  22527. checkReadyOnEveryCall: boolean;
  22528. /**
  22529. * Specifies if the ready state should be checked once
  22530. */
  22531. checkReadyOnlyOnce: boolean;
  22532. /**
  22533. * The state of the material
  22534. */
  22535. state: string;
  22536. /**
  22537. * The alpha value of the material
  22538. */
  22539. protected _alpha: number;
  22540. /**
  22541. * Sets the alpha value of the material
  22542. */
  22543. /**
  22544. * Gets the alpha value of the material
  22545. */
  22546. alpha: number;
  22547. /**
  22548. * Specifies if back face culling is enabled
  22549. */
  22550. protected _backFaceCulling: boolean;
  22551. /**
  22552. * Sets the back-face culling state
  22553. */
  22554. /**
  22555. * Gets the back-face culling state
  22556. */
  22557. backFaceCulling: boolean;
  22558. /**
  22559. * Stores the value for side orientation
  22560. */
  22561. sideOrientation: number;
  22562. /**
  22563. * Callback triggered when the material is compiled
  22564. */
  22565. onCompiled: (effect: Effect) => void;
  22566. /**
  22567. * Callback triggered when an error occurs
  22568. */
  22569. onError: (effect: Effect, errors: string) => void;
  22570. /**
  22571. * Callback triggered to get the render target textures
  22572. */
  22573. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22574. /**
  22575. * Gets a boolean indicating that current material needs to register RTT
  22576. */
  22577. readonly hasRenderTargetTextures: boolean;
  22578. /**
  22579. * Specifies if the material should be serialized
  22580. */
  22581. doNotSerialize: boolean;
  22582. /**
  22583. * @hidden
  22584. */
  22585. _storeEffectOnSubMeshes: boolean;
  22586. /**
  22587. * Stores the animations for the material
  22588. */
  22589. animations: Array<Animation>;
  22590. /**
  22591. * An event triggered when the material is disposed
  22592. */
  22593. onDisposeObservable: Observable<Material>;
  22594. /**
  22595. * An observer which watches for dispose events
  22596. */
  22597. private _onDisposeObserver;
  22598. private _onUnBindObservable;
  22599. /**
  22600. * Called during a dispose event
  22601. */
  22602. onDispose: () => void;
  22603. private _onBindObservable;
  22604. /**
  22605. * An event triggered when the material is bound
  22606. */
  22607. readonly onBindObservable: Observable<AbstractMesh>;
  22608. /**
  22609. * An observer which watches for bind events
  22610. */
  22611. private _onBindObserver;
  22612. /**
  22613. * Called during a bind event
  22614. */
  22615. onBind: (Mesh: AbstractMesh) => void;
  22616. /**
  22617. * An event triggered when the material is unbound
  22618. */
  22619. readonly onUnBindObservable: Observable<Material>;
  22620. /**
  22621. * Stores the value of the alpha mode
  22622. */
  22623. private _alphaMode;
  22624. /**
  22625. * Sets the value of the alpha mode.
  22626. *
  22627. * | Value | Type | Description |
  22628. * | --- | --- | --- |
  22629. * | 0 | ALPHA_DISABLE | |
  22630. * | 1 | ALPHA_ADD | |
  22631. * | 2 | ALPHA_COMBINE | |
  22632. * | 3 | ALPHA_SUBTRACT | |
  22633. * | 4 | ALPHA_MULTIPLY | |
  22634. * | 5 | ALPHA_MAXIMIZED | |
  22635. * | 6 | ALPHA_ONEONE | |
  22636. * | 7 | ALPHA_PREMULTIPLIED | |
  22637. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22638. * | 9 | ALPHA_INTERPOLATE | |
  22639. * | 10 | ALPHA_SCREENMODE | |
  22640. *
  22641. */
  22642. /**
  22643. * Gets the value of the alpha mode
  22644. */
  22645. alphaMode: number;
  22646. /**
  22647. * Stores the state of the need depth pre-pass value
  22648. */
  22649. private _needDepthPrePass;
  22650. /**
  22651. * Sets the need depth pre-pass value
  22652. */
  22653. /**
  22654. * Gets the depth pre-pass value
  22655. */
  22656. needDepthPrePass: boolean;
  22657. /**
  22658. * Specifies if depth writing should be disabled
  22659. */
  22660. disableDepthWrite: boolean;
  22661. /**
  22662. * Specifies if depth writing should be forced
  22663. */
  22664. forceDepthWrite: boolean;
  22665. /**
  22666. * Specifies if there should be a separate pass for culling
  22667. */
  22668. separateCullingPass: boolean;
  22669. /**
  22670. * Stores the state specifing if fog should be enabled
  22671. */
  22672. private _fogEnabled;
  22673. /**
  22674. * Sets the state for enabling fog
  22675. */
  22676. /**
  22677. * Gets the value of the fog enabled state
  22678. */
  22679. fogEnabled: boolean;
  22680. /**
  22681. * Stores the size of points
  22682. */
  22683. pointSize: number;
  22684. /**
  22685. * Stores the z offset value
  22686. */
  22687. zOffset: number;
  22688. /**
  22689. * Gets a value specifying if wireframe mode is enabled
  22690. */
  22691. /**
  22692. * Sets the state of wireframe mode
  22693. */
  22694. wireframe: boolean;
  22695. /**
  22696. * Gets the value specifying if point clouds are enabled
  22697. */
  22698. /**
  22699. * Sets the state of point cloud mode
  22700. */
  22701. pointsCloud: boolean;
  22702. /**
  22703. * Gets the material fill mode
  22704. */
  22705. /**
  22706. * Sets the material fill mode
  22707. */
  22708. fillMode: number;
  22709. /**
  22710. * @hidden
  22711. * Stores the effects for the material
  22712. */
  22713. _effect: Nullable<Effect>;
  22714. /**
  22715. * @hidden
  22716. * Specifies if the material was previously ready
  22717. */
  22718. _wasPreviouslyReady: boolean;
  22719. /**
  22720. * Specifies if uniform buffers should be used
  22721. */
  22722. private _useUBO;
  22723. /**
  22724. * Stores a reference to the scene
  22725. */
  22726. private _scene;
  22727. /**
  22728. * Stores the fill mode state
  22729. */
  22730. private _fillMode;
  22731. /**
  22732. * Specifies if the depth write state should be cached
  22733. */
  22734. private _cachedDepthWriteState;
  22735. /**
  22736. * Stores the uniform buffer
  22737. */
  22738. protected _uniformBuffer: UniformBuffer;
  22739. /** @hidden */
  22740. _indexInSceneMaterialArray: number;
  22741. /** @hidden */
  22742. meshMap: Nullable<{
  22743. [id: string]: AbstractMesh | undefined;
  22744. }>;
  22745. /**
  22746. * Creates a material instance
  22747. * @param name defines the name of the material
  22748. * @param scene defines the scene to reference
  22749. * @param doNotAdd specifies if the material should be added to the scene
  22750. */
  22751. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22752. /**
  22753. * Returns a string representation of the current material
  22754. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22755. * @returns a string with material information
  22756. */
  22757. toString(fullDetails?: boolean): string;
  22758. /**
  22759. * Gets the class name of the material
  22760. * @returns a string with the class name of the material
  22761. */
  22762. getClassName(): string;
  22763. /**
  22764. * Specifies if updates for the material been locked
  22765. */
  22766. readonly isFrozen: boolean;
  22767. /**
  22768. * Locks updates for the material
  22769. */
  22770. freeze(): void;
  22771. /**
  22772. * Unlocks updates for the material
  22773. */
  22774. unfreeze(): void;
  22775. /**
  22776. * Specifies if the material is ready to be used
  22777. * @param mesh defines the mesh to check
  22778. * @param useInstances specifies if instances should be used
  22779. * @returns a boolean indicating if the material is ready to be used
  22780. */
  22781. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22782. /**
  22783. * Specifies that the submesh is ready to be used
  22784. * @param mesh defines the mesh to check
  22785. * @param subMesh defines which submesh to check
  22786. * @param useInstances specifies that instances should be used
  22787. * @returns a boolean indicating that the submesh is ready or not
  22788. */
  22789. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22790. /**
  22791. * Returns the material effect
  22792. * @returns the effect associated with the material
  22793. */
  22794. getEffect(): Nullable<Effect>;
  22795. /**
  22796. * Returns the current scene
  22797. * @returns a Scene
  22798. */
  22799. getScene(): Scene;
  22800. /**
  22801. * Specifies if the material will require alpha blending
  22802. * @returns a boolean specifying if alpha blending is needed
  22803. */
  22804. needAlphaBlending(): boolean;
  22805. /**
  22806. * Specifies if the mesh will require alpha blending
  22807. * @param mesh defines the mesh to check
  22808. * @returns a boolean specifying if alpha blending is needed for the mesh
  22809. */
  22810. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22811. /**
  22812. * Specifies if this material should be rendered in alpha test mode
  22813. * @returns a boolean specifying if an alpha test is needed.
  22814. */
  22815. needAlphaTesting(): boolean;
  22816. /**
  22817. * Gets the texture used for the alpha test
  22818. * @returns the texture to use for alpha testing
  22819. */
  22820. getAlphaTestTexture(): Nullable<BaseTexture>;
  22821. /**
  22822. * Marks the material to indicate that it needs to be re-calculated
  22823. */
  22824. markDirty(): void;
  22825. /** @hidden */
  22826. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22827. /**
  22828. * Binds the material to the mesh
  22829. * @param world defines the world transformation matrix
  22830. * @param mesh defines the mesh to bind the material to
  22831. */
  22832. bind(world: Matrix, mesh?: Mesh): void;
  22833. /**
  22834. * Binds the submesh to the material
  22835. * @param world defines the world transformation matrix
  22836. * @param mesh defines the mesh containing the submesh
  22837. * @param subMesh defines the submesh to bind the material to
  22838. */
  22839. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22840. /**
  22841. * Binds the world matrix to the material
  22842. * @param world defines the world transformation matrix
  22843. */
  22844. bindOnlyWorldMatrix(world: Matrix): void;
  22845. /**
  22846. * Binds the scene's uniform buffer to the effect.
  22847. * @param effect defines the effect to bind to the scene uniform buffer
  22848. * @param sceneUbo defines the uniform buffer storing scene data
  22849. */
  22850. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22851. /**
  22852. * Binds the view matrix to the effect
  22853. * @param effect defines the effect to bind the view matrix to
  22854. */
  22855. bindView(effect: Effect): void;
  22856. /**
  22857. * Binds the view projection matrix to the effect
  22858. * @param effect defines the effect to bind the view projection matrix to
  22859. */
  22860. bindViewProjection(effect: Effect): void;
  22861. /**
  22862. * Specifies if material alpha testing should be turned on for the mesh
  22863. * @param mesh defines the mesh to check
  22864. */
  22865. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22866. /**
  22867. * Processes to execute after binding the material to a mesh
  22868. * @param mesh defines the rendered mesh
  22869. */
  22870. protected _afterBind(mesh?: Mesh): void;
  22871. /**
  22872. * Unbinds the material from the mesh
  22873. */
  22874. unbind(): void;
  22875. /**
  22876. * Gets the active textures from the material
  22877. * @returns an array of textures
  22878. */
  22879. getActiveTextures(): BaseTexture[];
  22880. /**
  22881. * Specifies if the material uses a texture
  22882. * @param texture defines the texture to check against the material
  22883. * @returns a boolean specifying if the material uses the texture
  22884. */
  22885. hasTexture(texture: BaseTexture): boolean;
  22886. /**
  22887. * Makes a duplicate of the material, and gives it a new name
  22888. * @param name defines the new name for the duplicated material
  22889. * @returns the cloned material
  22890. */
  22891. clone(name: string): Nullable<Material>;
  22892. /**
  22893. * Gets the meshes bound to the material
  22894. * @returns an array of meshes bound to the material
  22895. */
  22896. getBindedMeshes(): AbstractMesh[];
  22897. /**
  22898. * Force shader compilation
  22899. * @param mesh defines the mesh associated with this material
  22900. * @param onCompiled defines a function to execute once the material is compiled
  22901. * @param options defines the options to configure the compilation
  22902. */
  22903. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22904. clipPlane: boolean;
  22905. }>): void;
  22906. /**
  22907. * Force shader compilation
  22908. * @param mesh defines the mesh that will use this material
  22909. * @param options defines additional options for compiling the shaders
  22910. * @returns a promise that resolves when the compilation completes
  22911. */
  22912. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22913. clipPlane: boolean;
  22914. }>): Promise<void>;
  22915. private static readonly _ImageProcessingDirtyCallBack;
  22916. private static readonly _TextureDirtyCallBack;
  22917. private static readonly _FresnelDirtyCallBack;
  22918. private static readonly _MiscDirtyCallBack;
  22919. private static readonly _LightsDirtyCallBack;
  22920. private static readonly _AttributeDirtyCallBack;
  22921. private static _FresnelAndMiscDirtyCallBack;
  22922. private static _TextureAndMiscDirtyCallBack;
  22923. private static readonly _DirtyCallbackArray;
  22924. private static readonly _RunDirtyCallBacks;
  22925. /**
  22926. * Marks a define in the material to indicate that it needs to be re-computed
  22927. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22928. */
  22929. markAsDirty(flag: number): void;
  22930. /**
  22931. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22932. * @param func defines a function which checks material defines against the submeshes
  22933. */
  22934. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22935. /**
  22936. * Indicates that image processing needs to be re-calculated for all submeshes
  22937. */
  22938. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22939. /**
  22940. * Indicates that textures need to be re-calculated for all submeshes
  22941. */
  22942. protected _markAllSubMeshesAsTexturesDirty(): void;
  22943. /**
  22944. * Indicates that fresnel needs to be re-calculated for all submeshes
  22945. */
  22946. protected _markAllSubMeshesAsFresnelDirty(): void;
  22947. /**
  22948. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22949. */
  22950. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22951. /**
  22952. * Indicates that lights need to be re-calculated for all submeshes
  22953. */
  22954. protected _markAllSubMeshesAsLightsDirty(): void;
  22955. /**
  22956. * Indicates that attributes need to be re-calculated for all submeshes
  22957. */
  22958. protected _markAllSubMeshesAsAttributesDirty(): void;
  22959. /**
  22960. * Indicates that misc needs to be re-calculated for all submeshes
  22961. */
  22962. protected _markAllSubMeshesAsMiscDirty(): void;
  22963. /**
  22964. * Indicates that textures and misc need to be re-calculated for all submeshes
  22965. */
  22966. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22967. /**
  22968. * Disposes the material
  22969. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22970. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22971. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22972. */
  22973. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22974. /** @hidden */
  22975. private releaseVertexArrayObject;
  22976. /**
  22977. * Serializes this material
  22978. * @returns the serialized material object
  22979. */
  22980. serialize(): any;
  22981. /**
  22982. * Creates a MultiMaterial from parsed MultiMaterial data.
  22983. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22984. * @param scene defines the hosting scene
  22985. * @returns a new MultiMaterial
  22986. */
  22987. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22988. /**
  22989. * Creates a material from parsed material data
  22990. * @param parsedMaterial defines parsed material data
  22991. * @param scene defines the hosting scene
  22992. * @param rootUrl defines the root URL to use to load textures
  22993. * @returns a new material
  22994. */
  22995. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22996. }
  22997. }
  22998. declare module BABYLON {
  22999. /**
  23000. * "Static Class" containing the most commonly used helper while dealing with material for
  23001. * rendering purpose.
  23002. *
  23003. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  23004. *
  23005. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  23006. */
  23007. class MaterialHelper {
  23008. /**
  23009. * Bind the current view position to an effect.
  23010. * @param effect The effect to be bound
  23011. * @param scene The scene the eyes position is used from
  23012. */
  23013. static BindEyePosition(effect: Effect, scene: Scene): void;
  23014. /**
  23015. * Helps preparing the defines values about the UVs in used in the effect.
  23016. * UVs are shared as much as we can accross channels in the shaders.
  23017. * @param texture The texture we are preparing the UVs for
  23018. * @param defines The defines to update
  23019. * @param key The channel key "diffuse", "specular"... used in the shader
  23020. */
  23021. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  23022. /**
  23023. * Binds a texture matrix value to its corrsponding uniform
  23024. * @param texture The texture to bind the matrix for
  23025. * @param uniformBuffer The uniform buffer receivin the data
  23026. * @param key The channel key "diffuse", "specular"... used in the shader
  23027. */
  23028. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  23029. /**
  23030. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  23031. * @param mesh defines the current mesh
  23032. * @param scene defines the current scene
  23033. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  23034. * @param pointsCloud defines if point cloud rendering has to be turned on
  23035. * @param fogEnabled defines if fog has to be turned on
  23036. * @param alphaTest defines if alpha testing has to be turned on
  23037. * @param defines defines the current list of defines
  23038. */
  23039. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  23040. /**
  23041. * Helper used to prepare the list of defines associated with frame values for shader compilation
  23042. * @param scene defines the current scene
  23043. * @param engine defines the current engine
  23044. * @param defines specifies the list of active defines
  23045. * @param useInstances defines if instances have to be turned on
  23046. * @param useClipPlane defines if clip plane have to be turned on
  23047. */
  23048. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  23049. /**
  23050. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  23051. * @param mesh The mesh containing the geometry data we will draw
  23052. * @param defines The defines to update
  23053. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  23054. * @param useBones Precise whether bones should be used or not (override mesh info)
  23055. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  23056. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  23057. * @returns false if defines are considered not dirty and have not been checked
  23058. */
  23059. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  23060. /**
  23061. * Prepares the defines related to the light information passed in parameter
  23062. * @param scene The scene we are intending to draw
  23063. * @param mesh The mesh the effect is compiling for
  23064. * @param defines The defines to update
  23065. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  23066. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  23067. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  23068. * @returns true if normals will be required for the rest of the effect
  23069. */
  23070. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  23071. /**
  23072. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  23073. * that won t be acctive due to defines being turned off.
  23074. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  23075. * @param samplersList The samplers list
  23076. * @param defines The defines helping in the list generation
  23077. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  23078. */
  23079. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  23080. /**
  23081. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  23082. * @param defines The defines to update while falling back
  23083. * @param fallbacks The authorized effect fallbacks
  23084. * @param maxSimultaneousLights The maximum number of lights allowed
  23085. * @param rank the current rank of the Effect
  23086. * @returns The newly affected rank
  23087. */
  23088. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  23089. /**
  23090. * Prepares the list of attributes required for morph targets according to the effect defines.
  23091. * @param attribs The current list of supported attribs
  23092. * @param mesh The mesh to prepare the morph targets attributes for
  23093. * @param defines The current Defines of the effect
  23094. */
  23095. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  23096. /**
  23097. * Prepares the list of attributes required for bones according to the effect defines.
  23098. * @param attribs The current list of supported attribs
  23099. * @param mesh The mesh to prepare the bones attributes for
  23100. * @param defines The current Defines of the effect
  23101. * @param fallbacks The current efffect fallback strategy
  23102. */
  23103. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  23104. /**
  23105. * Prepares the list of attributes required for instances according to the effect defines.
  23106. * @param attribs The current list of supported attribs
  23107. * @param defines The current Defines of the effect
  23108. */
  23109. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  23110. /**
  23111. * Binds the light shadow information to the effect for the given mesh.
  23112. * @param light The light containing the generator
  23113. * @param scene The scene the lights belongs to
  23114. * @param mesh The mesh we are binding the information to render
  23115. * @param lightIndex The light index in the effect used to render the mesh
  23116. * @param effect The effect we are binding the data to
  23117. */
  23118. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  23119. /**
  23120. * Binds the light information to the effect.
  23121. * @param light The light containing the generator
  23122. * @param effect The effect we are binding the data to
  23123. * @param lightIndex The light index in the effect used to render
  23124. */
  23125. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  23126. /**
  23127. * Binds the lights information from the scene to the effect for the given mesh.
  23128. * @param scene The scene the lights belongs to
  23129. * @param mesh The mesh we are binding the information to render
  23130. * @param effect The effect we are binding the data to
  23131. * @param defines The generated defines for the effect
  23132. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  23133. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  23134. */
  23135. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  23136. private static _tempFogColor;
  23137. /**
  23138. * Binds the fog information from the scene to the effect for the given mesh.
  23139. * @param scene The scene the lights belongs to
  23140. * @param mesh The mesh we are binding the information to render
  23141. * @param effect The effect we are binding the data to
  23142. * @param linearSpace Defines if the fog effect is applied in linear space
  23143. */
  23144. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  23145. /**
  23146. * Binds the bones information from the mesh to the effect.
  23147. * @param mesh The mesh we are binding the information to render
  23148. * @param effect The effect we are binding the data to
  23149. */
  23150. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  23151. /**
  23152. * Binds the morph targets information from the mesh to the effect.
  23153. * @param abstractMesh The mesh we are binding the information to render
  23154. * @param effect The effect we are binding the data to
  23155. */
  23156. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  23157. /**
  23158. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  23159. * @param defines The generated defines used in the effect
  23160. * @param effect The effect we are binding the data to
  23161. * @param scene The scene we are willing to render with logarithmic scale for
  23162. */
  23163. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  23164. /**
  23165. * Binds the clip plane information from the scene to the effect.
  23166. * @param scene The scene the clip plane information are extracted from
  23167. * @param effect The effect we are binding the data to
  23168. */
  23169. static BindClipPlane(effect: Effect, scene: Scene): void;
  23170. }
  23171. }
  23172. declare module BABYLON {
  23173. /**
  23174. * A multi-material is used to apply different materials to different parts of the same object without the need of
  23175. * separate meshes. This can be use to improve performances.
  23176. * @see http://doc.babylonjs.com/how_to/multi_materials
  23177. */
  23178. class MultiMaterial extends Material {
  23179. private _subMaterials;
  23180. /**
  23181. * Gets or Sets the list of Materials used within the multi material.
  23182. * They need to be ordered according to the submeshes order in the associated mesh
  23183. */
  23184. subMaterials: Nullable<Material>[];
  23185. /**
  23186. * Function used to align with Node.getChildren()
  23187. * @returns the list of Materials used within the multi material
  23188. */
  23189. getChildren(): Nullable<Material>[];
  23190. /**
  23191. * Instantiates a new Multi Material
  23192. * A multi-material is used to apply different materials to different parts of the same object without the need of
  23193. * separate meshes. This can be use to improve performances.
  23194. * @see http://doc.babylonjs.com/how_to/multi_materials
  23195. * @param name Define the name in the scene
  23196. * @param scene Define the scene the material belongs to
  23197. */
  23198. constructor(name: string, scene: Scene);
  23199. private _hookArray;
  23200. /**
  23201. * Get one of the submaterial by its index in the submaterials array
  23202. * @param index The index to look the sub material at
  23203. * @returns The Material if the index has been defined
  23204. */
  23205. getSubMaterial(index: number): Nullable<Material>;
  23206. /**
  23207. * Get the list of active textures for the whole sub materials list.
  23208. * @returns All the textures that will be used during the rendering
  23209. */
  23210. getActiveTextures(): BaseTexture[];
  23211. /**
  23212. * Gets the current class name of the material e.g. "MultiMaterial"
  23213. * Mainly use in serialization.
  23214. * @returns the class name
  23215. */
  23216. getClassName(): string;
  23217. /**
  23218. * Checks if the material is ready to render the requested sub mesh
  23219. * @param mesh Define the mesh the submesh belongs to
  23220. * @param subMesh Define the sub mesh to look readyness for
  23221. * @param useInstances Define whether or not the material is used with instances
  23222. * @returns true if ready, otherwise false
  23223. */
  23224. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  23225. /**
  23226. * Clones the current material and its related sub materials
  23227. * @param name Define the name of the newly cloned material
  23228. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  23229. * @returns the cloned material
  23230. */
  23231. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  23232. /**
  23233. * Serializes the materials into a JSON representation.
  23234. * @returns the JSON representation
  23235. */
  23236. serialize(): any;
  23237. /**
  23238. * Dispose the material and release its associated resources
  23239. * @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)
  23240. * @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)
  23241. */
  23242. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  23243. }
  23244. }
  23245. declare module BABYLON {
  23246. /**
  23247. * Base class of materials working in push mode in babylon JS
  23248. * @hidden
  23249. */
  23250. class PushMaterial extends Material {
  23251. protected _activeEffect: Effect;
  23252. protected _normalMatrix: Matrix;
  23253. /**
  23254. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  23255. * This means that the material can keep using a previous shader while a new one is being compiled.
  23256. * This is mostly used when shader parallel compilation is supported (true by default)
  23257. */
  23258. allowShaderHotSwapping: boolean;
  23259. constructor(name: string, scene: Scene);
  23260. getEffect(): Effect;
  23261. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23262. /**
  23263. * Binds the given world matrix to the active effect
  23264. *
  23265. * @param world the matrix to bind
  23266. */
  23267. bindOnlyWorldMatrix(world: Matrix): void;
  23268. /**
  23269. * Binds the given normal matrix to the active effect
  23270. *
  23271. * @param normalMatrix the matrix to bind
  23272. */
  23273. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  23274. bind(world: Matrix, mesh?: Mesh): void;
  23275. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  23276. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  23277. }
  23278. }
  23279. declare module BABYLON {
  23280. /**
  23281. * Defines the options associated with the creation of a shader material.
  23282. */
  23283. interface IShaderMaterialOptions {
  23284. /**
  23285. * Does the material work in alpha blend mode
  23286. */
  23287. needAlphaBlending: boolean;
  23288. /**
  23289. * Does the material work in alpha test mode
  23290. */
  23291. needAlphaTesting: boolean;
  23292. /**
  23293. * The list of attribute names used in the shader
  23294. */
  23295. attributes: string[];
  23296. /**
  23297. * The list of unifrom names used in the shader
  23298. */
  23299. uniforms: string[];
  23300. /**
  23301. * The list of UBO names used in the shader
  23302. */
  23303. uniformBuffers: string[];
  23304. /**
  23305. * The list of sampler names used in the shader
  23306. */
  23307. samplers: string[];
  23308. /**
  23309. * The list of defines used in the shader
  23310. */
  23311. defines: string[];
  23312. }
  23313. /**
  23314. * 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.
  23315. *
  23316. * This returned material effects how the mesh will look based on the code in the shaders.
  23317. *
  23318. * @see http://doc.babylonjs.com/how_to/shader_material
  23319. */
  23320. class ShaderMaterial extends Material {
  23321. private _shaderPath;
  23322. private _options;
  23323. private _textures;
  23324. private _textureArrays;
  23325. private _floats;
  23326. private _ints;
  23327. private _floatsArrays;
  23328. private _colors3;
  23329. private _colors3Arrays;
  23330. private _colors4;
  23331. private _vectors2;
  23332. private _vectors3;
  23333. private _vectors4;
  23334. private _matrices;
  23335. private _matrices3x3;
  23336. private _matrices2x2;
  23337. private _vectors2Arrays;
  23338. private _vectors3Arrays;
  23339. private _cachedWorldViewMatrix;
  23340. private _renderId;
  23341. /**
  23342. * Instantiate a new shader material.
  23343. * 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.
  23344. * This returned material effects how the mesh will look based on the code in the shaders.
  23345. * @see http://doc.babylonjs.com/how_to/shader_material
  23346. * @param name Define the name of the material in the scene
  23347. * @param scene Define the scene the material belongs to
  23348. * @param shaderPath Defines the route to the shader code in one of three ways:
  23349. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  23350. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  23351. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  23352. * @param options Define the options used to create the shader
  23353. */
  23354. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  23355. /**
  23356. * Gets the current class name of the material e.g. "ShaderMaterial"
  23357. * Mainly use in serialization.
  23358. * @returns the class name
  23359. */
  23360. getClassName(): string;
  23361. /**
  23362. * Specifies if the material will require alpha blending
  23363. * @returns a boolean specifying if alpha blending is needed
  23364. */
  23365. needAlphaBlending(): boolean;
  23366. /**
  23367. * Specifies if this material should be rendered in alpha test mode
  23368. * @returns a boolean specifying if an alpha test is needed.
  23369. */
  23370. needAlphaTesting(): boolean;
  23371. private _checkUniform;
  23372. /**
  23373. * Set a texture in the shader.
  23374. * @param name Define the name of the uniform samplers as defined in the shader
  23375. * @param texture Define the texture to bind to this sampler
  23376. * @return the material itself allowing "fluent" like uniform updates
  23377. */
  23378. setTexture(name: string, texture: Texture): ShaderMaterial;
  23379. /**
  23380. * Set a texture array in the shader.
  23381. * @param name Define the name of the uniform sampler array as defined in the shader
  23382. * @param textures Define the list of textures to bind to this sampler
  23383. * @return the material itself allowing "fluent" like uniform updates
  23384. */
  23385. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  23386. /**
  23387. * Set a float in the shader.
  23388. * @param name Define the name of the uniform as defined in the shader
  23389. * @param value Define the value to give to the uniform
  23390. * @return the material itself allowing "fluent" like uniform updates
  23391. */
  23392. setFloat(name: string, value: number): ShaderMaterial;
  23393. /**
  23394. * Set a int in the shader.
  23395. * @param name Define the name of the uniform as defined in the shader
  23396. * @param value Define the value to give to the uniform
  23397. * @return the material itself allowing "fluent" like uniform updates
  23398. */
  23399. setInt(name: string, value: number): ShaderMaterial;
  23400. /**
  23401. * Set an array of floats in the shader.
  23402. * @param name Define the name of the uniform as defined in the shader
  23403. * @param value Define the value to give to the uniform
  23404. * @return the material itself allowing "fluent" like uniform updates
  23405. */
  23406. setFloats(name: string, value: number[]): ShaderMaterial;
  23407. /**
  23408. * Set a vec3 in the shader from a Color3.
  23409. * @param name Define the name of the uniform as defined in the shader
  23410. * @param value Define the value to give to the uniform
  23411. * @return the material itself allowing "fluent" like uniform updates
  23412. */
  23413. setColor3(name: string, value: Color3): ShaderMaterial;
  23414. /**
  23415. * Set a vec3 array in the shader from a Color3 array.
  23416. * @param name Define the name of the uniform as defined in the shader
  23417. * @param value Define the value to give to the uniform
  23418. * @return the material itself allowing "fluent" like uniform updates
  23419. */
  23420. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  23421. /**
  23422. * Set a vec4 in the shader from a Color4.
  23423. * @param name Define the name of the uniform as defined in the shader
  23424. * @param value Define the value to give to the uniform
  23425. * @return the material itself allowing "fluent" like uniform updates
  23426. */
  23427. setColor4(name: string, value: Color4): ShaderMaterial;
  23428. /**
  23429. * Set a vec2 in the shader from a Vector2.
  23430. * @param name Define the name of the uniform as defined in the shader
  23431. * @param value Define the value to give to the uniform
  23432. * @return the material itself allowing "fluent" like uniform updates
  23433. */
  23434. setVector2(name: string, value: Vector2): ShaderMaterial;
  23435. /**
  23436. * Set a vec3 in the shader from a Vector3.
  23437. * @param name Define the name of the uniform as defined in the shader
  23438. * @param value Define the value to give to the uniform
  23439. * @return the material itself allowing "fluent" like uniform updates
  23440. */
  23441. setVector3(name: string, value: Vector3): ShaderMaterial;
  23442. /**
  23443. * Set a vec4 in the shader from a Vector4.
  23444. * @param name Define the name of the uniform as defined in the shader
  23445. * @param value Define the value to give to the uniform
  23446. * @return the material itself allowing "fluent" like uniform updates
  23447. */
  23448. setVector4(name: string, value: Vector4): ShaderMaterial;
  23449. /**
  23450. * Set a mat4 in the shader from a Matrix.
  23451. * @param name Define the name of the uniform as defined in the shader
  23452. * @param value Define the value to give to the uniform
  23453. * @return the material itself allowing "fluent" like uniform updates
  23454. */
  23455. setMatrix(name: string, value: Matrix): ShaderMaterial;
  23456. /**
  23457. * Set a mat3 in the shader from a Float32Array.
  23458. * @param name Define the name of the uniform as defined in the shader
  23459. * @param value Define the value to give to the uniform
  23460. * @return the material itself allowing "fluent" like uniform updates
  23461. */
  23462. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  23463. /**
  23464. * Set a mat2 in the shader from a Float32Array.
  23465. * @param name Define the name of the uniform as defined in the shader
  23466. * @param value Define the value to give to the uniform
  23467. * @return the material itself allowing "fluent" like uniform updates
  23468. */
  23469. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  23470. /**
  23471. * Set a vec2 array in the shader from a number array.
  23472. * @param name Define the name of the uniform as defined in the shader
  23473. * @param value Define the value to give to the uniform
  23474. * @return the material itself allowing "fluent" like uniform updates
  23475. */
  23476. setArray2(name: string, value: number[]): ShaderMaterial;
  23477. /**
  23478. * Set a vec3 array in the shader from a number array.
  23479. * @param name Define the name of the uniform as defined in the shader
  23480. * @param value Define the value to give to the uniform
  23481. * @return the material itself allowing "fluent" like uniform updates
  23482. */
  23483. setArray3(name: string, value: number[]): ShaderMaterial;
  23484. private _checkCache;
  23485. /**
  23486. * Checks if the material is ready to render the requested mesh
  23487. * @param mesh Define the mesh to render
  23488. * @param useInstances Define whether or not the material is used with instances
  23489. * @returns true if ready, otherwise false
  23490. */
  23491. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23492. /**
  23493. * Binds the world matrix to the material
  23494. * @param world defines the world transformation matrix
  23495. */
  23496. bindOnlyWorldMatrix(world: Matrix): void;
  23497. /**
  23498. * Binds the material to the mesh
  23499. * @param world defines the world transformation matrix
  23500. * @param mesh defines the mesh to bind the material to
  23501. */
  23502. bind(world: Matrix, mesh?: Mesh): void;
  23503. /**
  23504. * Gets the active textures from the material
  23505. * @returns an array of textures
  23506. */
  23507. getActiveTextures(): BaseTexture[];
  23508. /**
  23509. * Specifies if the material uses a texture
  23510. * @param texture defines the texture to check against the material
  23511. * @returns a boolean specifying if the material uses the texture
  23512. */
  23513. hasTexture(texture: BaseTexture): boolean;
  23514. /**
  23515. * Makes a duplicate of the material, and gives it a new name
  23516. * @param name defines the new name for the duplicated material
  23517. * @returns the cloned material
  23518. */
  23519. clone(name: string): ShaderMaterial;
  23520. /**
  23521. * Disposes the material
  23522. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23523. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23524. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23525. */
  23526. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23527. /**
  23528. * Serializes this material in a JSON representation
  23529. * @returns the serialized material object
  23530. */
  23531. serialize(): any;
  23532. /**
  23533. * Creates a shader material from parsed shader material data
  23534. * @param source defines the JSON represnetation of the material
  23535. * @param scene defines the hosting scene
  23536. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23537. * @returns a new material
  23538. */
  23539. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  23540. }
  23541. }
  23542. declare module BABYLON {
  23543. /** @hidden */
  23544. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23545. MAINUV1: boolean;
  23546. MAINUV2: boolean;
  23547. DIFFUSE: boolean;
  23548. DIFFUSEDIRECTUV: number;
  23549. AMBIENT: boolean;
  23550. AMBIENTDIRECTUV: number;
  23551. OPACITY: boolean;
  23552. OPACITYDIRECTUV: number;
  23553. OPACITYRGB: boolean;
  23554. REFLECTION: boolean;
  23555. EMISSIVE: boolean;
  23556. EMISSIVEDIRECTUV: number;
  23557. SPECULAR: boolean;
  23558. SPECULARDIRECTUV: number;
  23559. BUMP: boolean;
  23560. BUMPDIRECTUV: number;
  23561. PARALLAX: boolean;
  23562. PARALLAXOCCLUSION: boolean;
  23563. SPECULAROVERALPHA: boolean;
  23564. CLIPPLANE: boolean;
  23565. CLIPPLANE2: boolean;
  23566. CLIPPLANE3: boolean;
  23567. CLIPPLANE4: boolean;
  23568. ALPHATEST: boolean;
  23569. DEPTHPREPASS: boolean;
  23570. ALPHAFROMDIFFUSE: boolean;
  23571. POINTSIZE: boolean;
  23572. FOG: boolean;
  23573. SPECULARTERM: boolean;
  23574. DIFFUSEFRESNEL: boolean;
  23575. OPACITYFRESNEL: boolean;
  23576. REFLECTIONFRESNEL: boolean;
  23577. REFRACTIONFRESNEL: boolean;
  23578. EMISSIVEFRESNEL: boolean;
  23579. FRESNEL: boolean;
  23580. NORMAL: boolean;
  23581. UV1: boolean;
  23582. UV2: boolean;
  23583. VERTEXCOLOR: boolean;
  23584. VERTEXALPHA: boolean;
  23585. NUM_BONE_INFLUENCERS: number;
  23586. BonesPerMesh: number;
  23587. BONETEXTURE: boolean;
  23588. INSTANCES: boolean;
  23589. GLOSSINESS: boolean;
  23590. ROUGHNESS: boolean;
  23591. EMISSIVEASILLUMINATION: boolean;
  23592. LINKEMISSIVEWITHDIFFUSE: boolean;
  23593. REFLECTIONFRESNELFROMSPECULAR: boolean;
  23594. LIGHTMAP: boolean;
  23595. LIGHTMAPDIRECTUV: number;
  23596. OBJECTSPACE_NORMALMAP: boolean;
  23597. USELIGHTMAPASSHADOWMAP: boolean;
  23598. REFLECTIONMAP_3D: boolean;
  23599. REFLECTIONMAP_SPHERICAL: boolean;
  23600. REFLECTIONMAP_PLANAR: boolean;
  23601. REFLECTIONMAP_CUBIC: boolean;
  23602. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  23603. REFLECTIONMAP_PROJECTION: boolean;
  23604. REFLECTIONMAP_SKYBOX: boolean;
  23605. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  23606. REFLECTIONMAP_EXPLICIT: boolean;
  23607. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  23608. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  23609. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  23610. INVERTCUBICMAP: boolean;
  23611. LOGARITHMICDEPTH: boolean;
  23612. REFRACTION: boolean;
  23613. REFRACTIONMAP_3D: boolean;
  23614. REFLECTIONOVERALPHA: boolean;
  23615. TWOSIDEDLIGHTING: boolean;
  23616. SHADOWFLOAT: boolean;
  23617. MORPHTARGETS: boolean;
  23618. MORPHTARGETS_NORMAL: boolean;
  23619. MORPHTARGETS_TANGENT: boolean;
  23620. NUM_MORPH_INFLUENCERS: number;
  23621. NONUNIFORMSCALING: boolean;
  23622. PREMULTIPLYALPHA: boolean;
  23623. IMAGEPROCESSING: boolean;
  23624. VIGNETTE: boolean;
  23625. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23626. VIGNETTEBLENDMODEOPAQUE: boolean;
  23627. TONEMAPPING: boolean;
  23628. TONEMAPPING_ACES: boolean;
  23629. CONTRAST: boolean;
  23630. COLORCURVES: boolean;
  23631. COLORGRADING: boolean;
  23632. COLORGRADING3D: boolean;
  23633. SAMPLER3DGREENDEPTH: boolean;
  23634. SAMPLER3DBGRMAP: boolean;
  23635. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23636. /**
  23637. * If the reflection texture on this material is in linear color space
  23638. * @hidden
  23639. */
  23640. IS_REFLECTION_LINEAR: boolean;
  23641. /**
  23642. * If the refraction texture on this material is in linear color space
  23643. * @hidden
  23644. */
  23645. IS_REFRACTION_LINEAR: boolean;
  23646. EXPOSURE: boolean;
  23647. constructor();
  23648. setReflectionMode(modeToEnable: string): void;
  23649. }
  23650. /**
  23651. * This is the default material used in Babylon. It is the best trade off between quality
  23652. * and performances.
  23653. * @see http://doc.babylonjs.com/babylon101/materials
  23654. */
  23655. class StandardMaterial extends PushMaterial {
  23656. private _diffuseTexture;
  23657. /**
  23658. * The basic texture of the material as viewed under a light.
  23659. */
  23660. diffuseTexture: Nullable<BaseTexture>;
  23661. private _ambientTexture;
  23662. /**
  23663. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  23664. */
  23665. ambientTexture: Nullable<BaseTexture>;
  23666. private _opacityTexture;
  23667. /**
  23668. * Define the transparency of the material from a texture.
  23669. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  23670. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  23671. */
  23672. opacityTexture: Nullable<BaseTexture>;
  23673. private _reflectionTexture;
  23674. /**
  23675. * Define the texture used to display the reflection.
  23676. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23677. */
  23678. reflectionTexture: Nullable<BaseTexture>;
  23679. private _emissiveTexture;
  23680. /**
  23681. * Define texture of the material as if self lit.
  23682. * This will be mixed in the final result even in the absence of light.
  23683. */
  23684. emissiveTexture: Nullable<BaseTexture>;
  23685. private _specularTexture;
  23686. /**
  23687. * Define how the color and intensity of the highlight given by the light in the material.
  23688. */
  23689. specularTexture: Nullable<BaseTexture>;
  23690. private _bumpTexture;
  23691. /**
  23692. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  23693. * 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.
  23694. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  23695. */
  23696. bumpTexture: Nullable<BaseTexture>;
  23697. private _lightmapTexture;
  23698. /**
  23699. * Complex lighting can be computationally expensive to compute at runtime.
  23700. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  23701. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  23702. */
  23703. lightmapTexture: Nullable<BaseTexture>;
  23704. private _refractionTexture;
  23705. /**
  23706. * Define the texture used to display the refraction.
  23707. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23708. */
  23709. refractionTexture: Nullable<BaseTexture>;
  23710. /**
  23711. * The color of the material lit by the environmental background lighting.
  23712. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  23713. */
  23714. ambientColor: Color3;
  23715. /**
  23716. * The basic color of the material as viewed under a light.
  23717. */
  23718. diffuseColor: Color3;
  23719. /**
  23720. * Define how the color and intensity of the highlight given by the light in the material.
  23721. */
  23722. specularColor: Color3;
  23723. /**
  23724. * Define the color of the material as if self lit.
  23725. * This will be mixed in the final result even in the absence of light.
  23726. */
  23727. emissiveColor: Color3;
  23728. /**
  23729. * Defines how sharp are the highlights in the material.
  23730. * The bigger the value the sharper giving a more glossy feeling to the result.
  23731. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  23732. */
  23733. specularPower: number;
  23734. private _useAlphaFromDiffuseTexture;
  23735. /**
  23736. * Does the transparency come from the diffuse texture alpha channel.
  23737. */
  23738. useAlphaFromDiffuseTexture: boolean;
  23739. private _useEmissiveAsIllumination;
  23740. /**
  23741. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  23742. */
  23743. useEmissiveAsIllumination: boolean;
  23744. private _linkEmissiveWithDiffuse;
  23745. /**
  23746. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  23747. * the emissive level when the final color is close to one.
  23748. */
  23749. linkEmissiveWithDiffuse: boolean;
  23750. private _useSpecularOverAlpha;
  23751. /**
  23752. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  23753. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  23754. */
  23755. useSpecularOverAlpha: boolean;
  23756. private _useReflectionOverAlpha;
  23757. /**
  23758. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  23759. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  23760. */
  23761. useReflectionOverAlpha: boolean;
  23762. private _disableLighting;
  23763. /**
  23764. * Does lights from the scene impacts this material.
  23765. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  23766. */
  23767. disableLighting: boolean;
  23768. private _useObjectSpaceNormalMap;
  23769. /**
  23770. * Allows using an object space normal map (instead of tangent space).
  23771. */
  23772. useObjectSpaceNormalMap: boolean;
  23773. private _useParallax;
  23774. /**
  23775. * Is parallax enabled or not.
  23776. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  23777. */
  23778. useParallax: boolean;
  23779. private _useParallaxOcclusion;
  23780. /**
  23781. * Is parallax occlusion enabled or not.
  23782. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  23783. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  23784. */
  23785. useParallaxOcclusion: boolean;
  23786. /**
  23787. * 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.
  23788. */
  23789. parallaxScaleBias: number;
  23790. private _roughness;
  23791. /**
  23792. * Helps to define how blurry the reflections should appears in the material.
  23793. */
  23794. roughness: number;
  23795. /**
  23796. * In case of refraction, define the value of the indice of refraction.
  23797. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23798. */
  23799. indexOfRefraction: number;
  23800. /**
  23801. * Invert the refraction texture alongside the y axis.
  23802. * It can be useful with procedural textures or probe for instance.
  23803. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23804. */
  23805. invertRefractionY: boolean;
  23806. /**
  23807. * Defines the alpha limits in alpha test mode.
  23808. */
  23809. alphaCutOff: number;
  23810. private _useLightmapAsShadowmap;
  23811. /**
  23812. * In case of light mapping, define whether the map contains light or shadow informations.
  23813. */
  23814. useLightmapAsShadowmap: boolean;
  23815. private _diffuseFresnelParameters;
  23816. /**
  23817. * Define the diffuse fresnel parameters of the material.
  23818. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23819. */
  23820. diffuseFresnelParameters: FresnelParameters;
  23821. private _opacityFresnelParameters;
  23822. /**
  23823. * Define the opacity fresnel parameters of the material.
  23824. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23825. */
  23826. opacityFresnelParameters: FresnelParameters;
  23827. private _reflectionFresnelParameters;
  23828. /**
  23829. * Define the reflection fresnel parameters of the material.
  23830. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23831. */
  23832. reflectionFresnelParameters: FresnelParameters;
  23833. private _refractionFresnelParameters;
  23834. /**
  23835. * Define the refraction fresnel parameters of the material.
  23836. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23837. */
  23838. refractionFresnelParameters: FresnelParameters;
  23839. private _emissiveFresnelParameters;
  23840. /**
  23841. * Define the emissive fresnel parameters of the material.
  23842. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23843. */
  23844. emissiveFresnelParameters: FresnelParameters;
  23845. private _useReflectionFresnelFromSpecular;
  23846. /**
  23847. * If true automatically deducts the fresnels values from the material specularity.
  23848. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23849. */
  23850. useReflectionFresnelFromSpecular: boolean;
  23851. private _useGlossinessFromSpecularMapAlpha;
  23852. /**
  23853. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  23854. */
  23855. useGlossinessFromSpecularMapAlpha: boolean;
  23856. private _maxSimultaneousLights;
  23857. /**
  23858. * Defines the maximum number of lights that can be used in the material
  23859. */
  23860. maxSimultaneousLights: number;
  23861. private _invertNormalMapX;
  23862. /**
  23863. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  23864. */
  23865. invertNormalMapX: boolean;
  23866. private _invertNormalMapY;
  23867. /**
  23868. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  23869. */
  23870. invertNormalMapY: boolean;
  23871. private _twoSidedLighting;
  23872. /**
  23873. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  23874. */
  23875. twoSidedLighting: boolean;
  23876. /**
  23877. * Default configuration related to image processing available in the standard Material.
  23878. */
  23879. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23880. /**
  23881. * Gets the image processing configuration used either in this material.
  23882. */
  23883. /**
  23884. * Sets the Default image processing configuration used either in the this material.
  23885. *
  23886. * If sets to null, the scene one is in use.
  23887. */
  23888. imageProcessingConfiguration: ImageProcessingConfiguration;
  23889. /**
  23890. * Keep track of the image processing observer to allow dispose and replace.
  23891. */
  23892. private _imageProcessingObserver;
  23893. /**
  23894. * Attaches a new image processing configuration to the Standard Material.
  23895. * @param configuration
  23896. */
  23897. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23898. /**
  23899. * Gets wether the color curves effect is enabled.
  23900. */
  23901. /**
  23902. * Sets wether the color curves effect is enabled.
  23903. */
  23904. cameraColorCurvesEnabled: boolean;
  23905. /**
  23906. * Gets wether the color grading effect is enabled.
  23907. */
  23908. /**
  23909. * Gets wether the color grading effect is enabled.
  23910. */
  23911. cameraColorGradingEnabled: boolean;
  23912. /**
  23913. * Gets wether tonemapping is enabled or not.
  23914. */
  23915. /**
  23916. * Sets wether tonemapping is enabled or not
  23917. */
  23918. cameraToneMappingEnabled: boolean;
  23919. /**
  23920. * The camera exposure used on this material.
  23921. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23922. * This corresponds to a photographic exposure.
  23923. */
  23924. /**
  23925. * The camera exposure used on this material.
  23926. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23927. * This corresponds to a photographic exposure.
  23928. */
  23929. cameraExposure: number;
  23930. /**
  23931. * Gets The camera contrast used on this material.
  23932. */
  23933. /**
  23934. * Sets The camera contrast used on this material.
  23935. */
  23936. cameraContrast: number;
  23937. /**
  23938. * Gets the Color Grading 2D Lookup Texture.
  23939. */
  23940. /**
  23941. * Sets the Color Grading 2D Lookup Texture.
  23942. */
  23943. cameraColorGradingTexture: Nullable<BaseTexture>;
  23944. /**
  23945. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23946. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23947. * 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;
  23948. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23949. */
  23950. /**
  23951. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23952. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23953. * 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;
  23954. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23955. */
  23956. cameraColorCurves: Nullable<ColorCurves>;
  23957. /**
  23958. * Custom callback helping to override the default shader used in the material.
  23959. */
  23960. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  23961. protected _renderTargets: SmartArray<RenderTargetTexture>;
  23962. protected _worldViewProjectionMatrix: Matrix;
  23963. protected _globalAmbientColor: Color3;
  23964. protected _useLogarithmicDepth: boolean;
  23965. /**
  23966. * Instantiates a new standard material.
  23967. * This is the default material used in Babylon. It is the best trade off between quality
  23968. * and performances.
  23969. * @see http://doc.babylonjs.com/babylon101/materials
  23970. * @param name Define the name of the material in the scene
  23971. * @param scene Define the scene the material belong to
  23972. */
  23973. constructor(name: string, scene: Scene);
  23974. /**
  23975. * Gets a boolean indicating that current material needs to register RTT
  23976. */
  23977. readonly hasRenderTargetTextures: boolean;
  23978. /**
  23979. * Gets the current class name of the material e.g. "StandardMaterial"
  23980. * Mainly use in serialization.
  23981. * @returns the class name
  23982. */
  23983. getClassName(): string;
  23984. /**
  23985. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  23986. * You can try switching to logarithmic depth.
  23987. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  23988. */
  23989. useLogarithmicDepth: boolean;
  23990. /**
  23991. * Specifies if the material will require alpha blending
  23992. * @returns a boolean specifying if alpha blending is needed
  23993. */
  23994. needAlphaBlending(): boolean;
  23995. /**
  23996. * Specifies if this material should be rendered in alpha test mode
  23997. * @returns a boolean specifying if an alpha test is needed.
  23998. */
  23999. needAlphaTesting(): boolean;
  24000. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  24001. /**
  24002. * Get the texture used for alpha test purpose.
  24003. * @returns the diffuse texture in case of the standard material.
  24004. */
  24005. getAlphaTestTexture(): Nullable<BaseTexture>;
  24006. /**
  24007. * Get if the submesh is ready to be used and all its information available.
  24008. * Child classes can use it to update shaders
  24009. * @param mesh defines the mesh to check
  24010. * @param subMesh defines which submesh to check
  24011. * @param useInstances specifies that instances should be used
  24012. * @returns a boolean indicating that the submesh is ready or not
  24013. */
  24014. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24015. /**
  24016. * Builds the material UBO layouts.
  24017. * Used internally during the effect preparation.
  24018. */
  24019. buildUniformLayout(): void;
  24020. /**
  24021. * Unbinds the material from the mesh
  24022. */
  24023. unbind(): void;
  24024. /**
  24025. * Binds the submesh to this material by preparing the effect and shader to draw
  24026. * @param world defines the world transformation matrix
  24027. * @param mesh defines the mesh containing the submesh
  24028. * @param subMesh defines the submesh to bind the material to
  24029. */
  24030. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24031. /**
  24032. * Get the list of animatables in the material.
  24033. * @returns the list of animatables object used in the material
  24034. */
  24035. getAnimatables(): IAnimatable[];
  24036. /**
  24037. * Gets the active textures from the material
  24038. * @returns an array of textures
  24039. */
  24040. getActiveTextures(): BaseTexture[];
  24041. /**
  24042. * Specifies if the material uses a texture
  24043. * @param texture defines the texture to check against the material
  24044. * @returns a boolean specifying if the material uses the texture
  24045. */
  24046. hasTexture(texture: BaseTexture): boolean;
  24047. /**
  24048. * Disposes the material
  24049. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24050. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24051. */
  24052. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  24053. /**
  24054. * Makes a duplicate of the material, and gives it a new name
  24055. * @param name defines the new name for the duplicated material
  24056. * @returns the cloned material
  24057. */
  24058. clone(name: string): StandardMaterial;
  24059. /**
  24060. * Serializes this material in a JSON representation
  24061. * @returns the serialized material object
  24062. */
  24063. serialize(): any;
  24064. /**
  24065. * Creates a standard material from parsed material data
  24066. * @param source defines the JSON representation of the material
  24067. * @param scene defines the hosting scene
  24068. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24069. * @returns a new standard material
  24070. */
  24071. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  24072. private static _DiffuseTextureEnabled;
  24073. /**
  24074. * Are diffuse textures enabled in the application.
  24075. */
  24076. static DiffuseTextureEnabled: boolean;
  24077. private static _AmbientTextureEnabled;
  24078. /**
  24079. * Are ambient textures enabled in the application.
  24080. */
  24081. static AmbientTextureEnabled: boolean;
  24082. private static _OpacityTextureEnabled;
  24083. /**
  24084. * Are opacity textures enabled in the application.
  24085. */
  24086. static OpacityTextureEnabled: boolean;
  24087. private static _ReflectionTextureEnabled;
  24088. /**
  24089. * Are reflection textures enabled in the application.
  24090. */
  24091. static ReflectionTextureEnabled: boolean;
  24092. private static _EmissiveTextureEnabled;
  24093. /**
  24094. * Are emissive textures enabled in the application.
  24095. */
  24096. static EmissiveTextureEnabled: boolean;
  24097. private static _SpecularTextureEnabled;
  24098. /**
  24099. * Are specular textures enabled in the application.
  24100. */
  24101. static SpecularTextureEnabled: boolean;
  24102. private static _BumpTextureEnabled;
  24103. /**
  24104. * Are bump textures enabled in the application.
  24105. */
  24106. static BumpTextureEnabled: boolean;
  24107. private static _LightmapTextureEnabled;
  24108. /**
  24109. * Are lightmap textures enabled in the application.
  24110. */
  24111. static LightmapTextureEnabled: boolean;
  24112. private static _RefractionTextureEnabled;
  24113. /**
  24114. * Are refraction textures enabled in the application.
  24115. */
  24116. static RefractionTextureEnabled: boolean;
  24117. private static _ColorGradingTextureEnabled;
  24118. /**
  24119. * Are color grading textures enabled in the application.
  24120. */
  24121. static ColorGradingTextureEnabled: boolean;
  24122. private static _FresnelEnabled;
  24123. /**
  24124. * Are fresnels enabled in the application.
  24125. */
  24126. static FresnelEnabled: boolean;
  24127. }
  24128. }
  24129. declare module BABYLON {
  24130. /**
  24131. * Uniform buffer objects.
  24132. *
  24133. * Handles blocks of uniform on the GPU.
  24134. *
  24135. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  24136. *
  24137. * For more information, please refer to :
  24138. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  24139. */
  24140. class UniformBuffer {
  24141. private _engine;
  24142. private _buffer;
  24143. private _data;
  24144. private _bufferData;
  24145. private _dynamic?;
  24146. private _uniformLocations;
  24147. private _uniformSizes;
  24148. private _uniformLocationPointer;
  24149. private _needSync;
  24150. private _noUBO;
  24151. private _currentEffect;
  24152. private static _MAX_UNIFORM_SIZE;
  24153. private static _tempBuffer;
  24154. /**
  24155. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  24156. * This is dynamic to allow compat with webgl 1 and 2.
  24157. * You will need to pass the name of the uniform as well as the value.
  24158. */
  24159. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  24160. /**
  24161. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  24162. * This is dynamic to allow compat with webgl 1 and 2.
  24163. * You will need to pass the name of the uniform as well as the value.
  24164. */
  24165. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  24166. /**
  24167. * Lambda to Update a single float in a uniform buffer.
  24168. * This is dynamic to allow compat with webgl 1 and 2.
  24169. * You will need to pass the name of the uniform as well as the value.
  24170. */
  24171. updateFloat: (name: string, x: number) => void;
  24172. /**
  24173. * Lambda to Update a vec2 of float in a uniform buffer.
  24174. * This is dynamic to allow compat with webgl 1 and 2.
  24175. * You will need to pass the name of the uniform as well as the value.
  24176. */
  24177. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  24178. /**
  24179. * Lambda to Update a vec3 of float in a uniform buffer.
  24180. * This is dynamic to allow compat with webgl 1 and 2.
  24181. * You will need to pass the name of the uniform as well as the value.
  24182. */
  24183. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  24184. /**
  24185. * Lambda to Update a vec4 of float in a uniform buffer.
  24186. * This is dynamic to allow compat with webgl 1 and 2.
  24187. * You will need to pass the name of the uniform as well as the value.
  24188. */
  24189. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  24190. /**
  24191. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  24192. * This is dynamic to allow compat with webgl 1 and 2.
  24193. * You will need to pass the name of the uniform as well as the value.
  24194. */
  24195. updateMatrix: (name: string, mat: Matrix) => void;
  24196. /**
  24197. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  24198. * This is dynamic to allow compat with webgl 1 and 2.
  24199. * You will need to pass the name of the uniform as well as the value.
  24200. */
  24201. updateVector3: (name: string, vector: Vector3) => void;
  24202. /**
  24203. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  24204. * This is dynamic to allow compat with webgl 1 and 2.
  24205. * You will need to pass the name of the uniform as well as the value.
  24206. */
  24207. updateVector4: (name: string, vector: Vector4) => void;
  24208. /**
  24209. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  24210. * This is dynamic to allow compat with webgl 1 and 2.
  24211. * You will need to pass the name of the uniform as well as the value.
  24212. */
  24213. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  24214. /**
  24215. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  24216. * This is dynamic to allow compat with webgl 1 and 2.
  24217. * You will need to pass the name of the uniform as well as the value.
  24218. */
  24219. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  24220. /**
  24221. * Instantiates a new Uniform buffer objects.
  24222. *
  24223. * Handles blocks of uniform on the GPU.
  24224. *
  24225. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  24226. *
  24227. * For more information, please refer to :
  24228. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  24229. * @param engine Define the engine the buffer is associated with
  24230. * @param data Define the data contained in the buffer
  24231. * @param dynamic Define if the buffer is updatable
  24232. */
  24233. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  24234. /**
  24235. * Indicates if the buffer is using the WebGL2 UBO implementation,
  24236. * or just falling back on setUniformXXX calls.
  24237. */
  24238. readonly useUbo: boolean;
  24239. /**
  24240. * Indicates if the WebGL underlying uniform buffer is in sync
  24241. * with the javascript cache data.
  24242. */
  24243. readonly isSync: boolean;
  24244. /**
  24245. * Indicates if the WebGL underlying uniform buffer is dynamic.
  24246. * Also, a dynamic UniformBuffer will disable cache verification and always
  24247. * update the underlying WebGL uniform buffer to the GPU.
  24248. * @returns if Dynamic, otherwise false
  24249. */
  24250. isDynamic(): boolean;
  24251. /**
  24252. * The data cache on JS side.
  24253. * @returns the underlying data as a float array
  24254. */
  24255. getData(): Float32Array;
  24256. /**
  24257. * The underlying WebGL Uniform buffer.
  24258. * @returns the webgl buffer
  24259. */
  24260. getBuffer(): Nullable<WebGLBuffer>;
  24261. /**
  24262. * std140 layout specifies how to align data within an UBO structure.
  24263. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  24264. * for specs.
  24265. */
  24266. private _fillAlignment;
  24267. /**
  24268. * Adds an uniform in the buffer.
  24269. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  24270. * for the layout to be correct !
  24271. * @param name Name of the uniform, as used in the uniform block in the shader.
  24272. * @param size Data size, or data directly.
  24273. */
  24274. addUniform(name: string, size: number | number[]): void;
  24275. /**
  24276. * Adds a Matrix 4x4 to the uniform buffer.
  24277. * @param name Name of the uniform, as used in the uniform block in the shader.
  24278. * @param mat A 4x4 matrix.
  24279. */
  24280. addMatrix(name: string, mat: Matrix): void;
  24281. /**
  24282. * Adds a vec2 to the uniform buffer.
  24283. * @param name Name of the uniform, as used in the uniform block in the shader.
  24284. * @param x Define the x component value of the vec2
  24285. * @param y Define the y component value of the vec2
  24286. */
  24287. addFloat2(name: string, x: number, y: number): void;
  24288. /**
  24289. * Adds a vec3 to the uniform buffer.
  24290. * @param name Name of the uniform, as used in the uniform block in the shader.
  24291. * @param x Define the x component value of the vec3
  24292. * @param y Define the y component value of the vec3
  24293. * @param z Define the z component value of the vec3
  24294. */
  24295. addFloat3(name: string, x: number, y: number, z: number): void;
  24296. /**
  24297. * Adds a vec3 to the uniform buffer.
  24298. * @param name Name of the uniform, as used in the uniform block in the shader.
  24299. * @param color Define the vec3 from a Color
  24300. */
  24301. addColor3(name: string, color: Color3): void;
  24302. /**
  24303. * Adds a vec4 to the uniform buffer.
  24304. * @param name Name of the uniform, as used in the uniform block in the shader.
  24305. * @param color Define the rgb components from a Color
  24306. * @param alpha Define the a component of the vec4
  24307. */
  24308. addColor4(name: string, color: Color3, alpha: number): void;
  24309. /**
  24310. * Adds a vec3 to the uniform buffer.
  24311. * @param name Name of the uniform, as used in the uniform block in the shader.
  24312. * @param vector Define the vec3 components from a Vector
  24313. */
  24314. addVector3(name: string, vector: Vector3): void;
  24315. /**
  24316. * Adds a Matrix 3x3 to the uniform buffer.
  24317. * @param name Name of the uniform, as used in the uniform block in the shader.
  24318. */
  24319. addMatrix3x3(name: string): void;
  24320. /**
  24321. * Adds a Matrix 2x2 to the uniform buffer.
  24322. * @param name Name of the uniform, as used in the uniform block in the shader.
  24323. */
  24324. addMatrix2x2(name: string): void;
  24325. /**
  24326. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  24327. */
  24328. create(): void;
  24329. /** @hidden */
  24330. _rebuild(): void;
  24331. /**
  24332. * Updates the WebGL Uniform Buffer on the GPU.
  24333. * If the `dynamic` flag is set to true, no cache comparison is done.
  24334. * Otherwise, the buffer will be updated only if the cache differs.
  24335. */
  24336. update(): void;
  24337. /**
  24338. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  24339. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  24340. * @param data Define the flattened data
  24341. * @param size Define the size of the data.
  24342. */
  24343. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  24344. private _updateMatrix3x3ForUniform;
  24345. private _updateMatrix3x3ForEffect;
  24346. private _updateMatrix2x2ForEffect;
  24347. private _updateMatrix2x2ForUniform;
  24348. private _updateFloatForEffect;
  24349. private _updateFloatForUniform;
  24350. private _updateFloat2ForEffect;
  24351. private _updateFloat2ForUniform;
  24352. private _updateFloat3ForEffect;
  24353. private _updateFloat3ForUniform;
  24354. private _updateFloat4ForEffect;
  24355. private _updateFloat4ForUniform;
  24356. private _updateMatrixForEffect;
  24357. private _updateMatrixForUniform;
  24358. private _updateVector3ForEffect;
  24359. private _updateVector3ForUniform;
  24360. private _updateVector4ForEffect;
  24361. private _updateVector4ForUniform;
  24362. private _updateColor3ForEffect;
  24363. private _updateColor3ForUniform;
  24364. private _updateColor4ForEffect;
  24365. private _updateColor4ForUniform;
  24366. /**
  24367. * Sets a sampler uniform on the effect.
  24368. * @param name Define the name of the sampler.
  24369. * @param texture Define the texture to set in the sampler
  24370. */
  24371. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  24372. /**
  24373. * Directly updates the value of the uniform in the cache AND on the GPU.
  24374. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  24375. * @param data Define the flattened data
  24376. */
  24377. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  24378. /**
  24379. * Binds this uniform buffer to an effect.
  24380. * @param effect Define the effect to bind the buffer to
  24381. * @param name Name of the uniform block in the shader.
  24382. */
  24383. bindToEffect(effect: Effect, name: string): void;
  24384. /**
  24385. * Disposes the uniform buffer.
  24386. */
  24387. dispose(): void;
  24388. }
  24389. }
  24390. declare module BABYLON {
  24391. /**
  24392. * Defines a target to use with MorphTargetManager
  24393. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24394. */
  24395. class MorphTarget implements IAnimatable {
  24396. /** defines the name of the target */
  24397. name: string;
  24398. /**
  24399. * Gets or sets the list of animations
  24400. */
  24401. animations: Animation[];
  24402. private _scene;
  24403. private _positions;
  24404. private _normals;
  24405. private _tangents;
  24406. private _influence;
  24407. /**
  24408. * Observable raised when the influence changes
  24409. */
  24410. onInfluenceChanged: Observable<boolean>;
  24411. /** @hidden */
  24412. _onDataLayoutChanged: Observable<void>;
  24413. /**
  24414. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  24415. */
  24416. influence: number;
  24417. /**
  24418. * Gets or sets the id of the morph Target
  24419. */
  24420. id: string;
  24421. private _animationPropertiesOverride;
  24422. /**
  24423. * Gets or sets the animation properties override
  24424. */
  24425. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24426. /**
  24427. * Creates a new MorphTarget
  24428. * @param name defines the name of the target
  24429. * @param influence defines the influence to use
  24430. */
  24431. constructor(
  24432. /** defines the name of the target */
  24433. name: string, influence?: number, scene?: Nullable<Scene>);
  24434. /**
  24435. * Gets a boolean defining if the target contains position data
  24436. */
  24437. readonly hasPositions: boolean;
  24438. /**
  24439. * Gets a boolean defining if the target contains normal data
  24440. */
  24441. readonly hasNormals: boolean;
  24442. /**
  24443. * Gets a boolean defining if the target contains tangent data
  24444. */
  24445. readonly hasTangents: boolean;
  24446. /**
  24447. * Affects position data to this target
  24448. * @param data defines the position data to use
  24449. */
  24450. setPositions(data: Nullable<FloatArray>): void;
  24451. /**
  24452. * Gets the position data stored in this target
  24453. * @returns a FloatArray containing the position data (or null if not present)
  24454. */
  24455. getPositions(): Nullable<FloatArray>;
  24456. /**
  24457. * Affects normal data to this target
  24458. * @param data defines the normal data to use
  24459. */
  24460. setNormals(data: Nullable<FloatArray>): void;
  24461. /**
  24462. * Gets the normal data stored in this target
  24463. * @returns a FloatArray containing the normal data (or null if not present)
  24464. */
  24465. getNormals(): Nullable<FloatArray>;
  24466. /**
  24467. * Affects tangent data to this target
  24468. * @param data defines the tangent data to use
  24469. */
  24470. setTangents(data: Nullable<FloatArray>): void;
  24471. /**
  24472. * Gets the tangent data stored in this target
  24473. * @returns a FloatArray containing the tangent data (or null if not present)
  24474. */
  24475. getTangents(): Nullable<FloatArray>;
  24476. /**
  24477. * Serializes the current target into a Serialization object
  24478. * @returns the serialized object
  24479. */
  24480. serialize(): any;
  24481. /**
  24482. * Returns the string "MorphTarget"
  24483. * @returns "MorphTarget"
  24484. */
  24485. getClassName(): string;
  24486. /**
  24487. * Creates a new target from serialized data
  24488. * @param serializationObject defines the serialized data to use
  24489. * @returns a new MorphTarget
  24490. */
  24491. static Parse(serializationObject: any): MorphTarget;
  24492. /**
  24493. * Creates a MorphTarget from mesh data
  24494. * @param mesh defines the source mesh
  24495. * @param name defines the name to use for the new target
  24496. * @param influence defines the influence to attach to the target
  24497. * @returns a new MorphTarget
  24498. */
  24499. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  24500. }
  24501. }
  24502. declare module BABYLON {
  24503. /**
  24504. * This class is used to deform meshes using morphing between different targets
  24505. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24506. */
  24507. class MorphTargetManager {
  24508. private _targets;
  24509. private _targetInfluenceChangedObservers;
  24510. private _targetDataLayoutChangedObservers;
  24511. private _activeTargets;
  24512. private _scene;
  24513. private _influences;
  24514. private _supportsNormals;
  24515. private _supportsTangents;
  24516. private _vertexCount;
  24517. private _uniqueId;
  24518. private _tempInfluences;
  24519. /**
  24520. * Creates a new MorphTargetManager
  24521. * @param scene defines the current scene
  24522. */
  24523. constructor(scene?: Nullable<Scene>);
  24524. /**
  24525. * Gets the unique ID of this manager
  24526. */
  24527. readonly uniqueId: number;
  24528. /**
  24529. * Gets the number of vertices handled by this manager
  24530. */
  24531. readonly vertexCount: number;
  24532. /**
  24533. * Gets a boolean indicating if this manager supports morphing of normals
  24534. */
  24535. readonly supportsNormals: boolean;
  24536. /**
  24537. * Gets a boolean indicating if this manager supports morphing of tangents
  24538. */
  24539. readonly supportsTangents: boolean;
  24540. /**
  24541. * Gets the number of targets stored in this manager
  24542. */
  24543. readonly numTargets: number;
  24544. /**
  24545. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24546. */
  24547. readonly numInfluencers: number;
  24548. /**
  24549. * Gets the list of influences (one per target)
  24550. */
  24551. readonly influences: Float32Array;
  24552. /**
  24553. * Gets the active target at specified index. An active target is a target with an influence > 0
  24554. * @param index defines the index to check
  24555. * @returns the requested target
  24556. */
  24557. getActiveTarget(index: number): MorphTarget;
  24558. /**
  24559. * Gets the target at specified index
  24560. * @param index defines the index to check
  24561. * @returns the requested target
  24562. */
  24563. getTarget(index: number): MorphTarget;
  24564. /**
  24565. * Add a new target to this manager
  24566. * @param target defines the target to add
  24567. */
  24568. addTarget(target: MorphTarget): void;
  24569. /**
  24570. * Removes a target from the manager
  24571. * @param target defines the target to remove
  24572. */
  24573. removeTarget(target: MorphTarget): void;
  24574. /**
  24575. * Serializes the current manager into a Serialization object
  24576. * @returns the serialized object
  24577. */
  24578. serialize(): any;
  24579. private _syncActiveTargets;
  24580. /**
  24581. * Syncrhonize the targets with all the meshes using this morph target manager
  24582. */
  24583. synchronize(): void;
  24584. /**
  24585. * Creates a new MorphTargetManager from serialized data
  24586. * @param serializationObject defines the serialized data
  24587. * @param scene defines the hosting scene
  24588. * @returns the new MorphTargetManager
  24589. */
  24590. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24591. }
  24592. }
  24593. declare module BABYLON {
  24594. /**
  24595. * Class used to store all common mesh properties
  24596. */
  24597. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24598. /** No occlusion */
  24599. static OCCLUSION_TYPE_NONE: number;
  24600. /** Occlusion set to optimisitic */
  24601. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24602. /** Occlusion set to strict */
  24603. static OCCLUSION_TYPE_STRICT: number;
  24604. /** Use an accurante occlusion algorithm */
  24605. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24606. /** Use a conservative occlusion algorithm */
  24607. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24608. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24609. * Test order :
  24610. * Is the bounding sphere outside the frustum ?
  24611. * If not, are the bounding box vertices outside the frustum ?
  24612. * It not, then the cullable object is in the frustum.
  24613. */
  24614. static readonly CULLINGSTRATEGY_STANDARD: number;
  24615. /** Culling strategy : Bounding Sphere Only.
  24616. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24617. * It's also less accurate than the standard because some not visible objects can still be selected.
  24618. * Test : is the bounding sphere outside the frustum ?
  24619. * If not, then the cullable object is in the frustum.
  24620. */
  24621. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24622. /** Culling strategy : Optimistic Inclusion.
  24623. * This in an inclusion test first, then the standard exclusion test.
  24624. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24625. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  24626. * Anyway, it's as accurate as the standard strategy.
  24627. * Test :
  24628. * Is the cullable object bounding sphere center in the frustum ?
  24629. * If not, apply the default culling strategy.
  24630. */
  24631. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24632. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24633. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24634. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24635. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  24636. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24637. * Test :
  24638. * Is the cullable object bounding sphere center in the frustum ?
  24639. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24640. */
  24641. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24642. /**
  24643. * No billboard
  24644. */
  24645. static readonly BILLBOARDMODE_NONE: number;
  24646. /** Billboard on X axis */
  24647. static readonly BILLBOARDMODE_X: number;
  24648. /** Billboard on Y axis */
  24649. static readonly BILLBOARDMODE_Y: number;
  24650. /** Billboard on Z axis */
  24651. static readonly BILLBOARDMODE_Z: number;
  24652. /** Billboard on all axes */
  24653. static readonly BILLBOARDMODE_ALL: number;
  24654. private _facetData;
  24655. /**
  24656. * The culling strategy to use to check whether the mesh must be rendered or not.
  24657. * This value can be changed at any time and will be used on the next render mesh selection.
  24658. * The possible values are :
  24659. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24660. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24661. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24662. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24663. * Please read each static variable documentation to get details about the culling process.
  24664. * */
  24665. cullingStrategy: number;
  24666. /**
  24667. * Gets the number of facets in the mesh
  24668. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24669. */
  24670. readonly facetNb: number;
  24671. /**
  24672. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24673. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24674. */
  24675. partitioningSubdivisions: number;
  24676. /**
  24677. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24678. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24679. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24680. */
  24681. partitioningBBoxRatio: number;
  24682. /**
  24683. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24684. * Works only for updatable meshes.
  24685. * Doesn't work with multi-materials
  24686. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24687. */
  24688. mustDepthSortFacets: boolean;
  24689. /**
  24690. * The location (Vector3) where the facet depth sort must be computed from.
  24691. * By default, the active camera position.
  24692. * Used only when facet depth sort is enabled
  24693. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24694. */
  24695. facetDepthSortFrom: Vector3;
  24696. /**
  24697. * gets a boolean indicating if facetData is enabled
  24698. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24699. */
  24700. readonly isFacetDataEnabled: boolean;
  24701. /** @hidden */
  24702. _updateNonUniformScalingState(value: boolean): boolean;
  24703. /**
  24704. * An event triggered when this mesh collides with another one
  24705. */
  24706. onCollideObservable: Observable<AbstractMesh>;
  24707. private _onCollideObserver;
  24708. /** Set a function to call when this mesh collides with another one */
  24709. onCollide: () => void;
  24710. /**
  24711. * An event triggered when the collision's position changes
  24712. */
  24713. onCollisionPositionChangeObservable: Observable<Vector3>;
  24714. private _onCollisionPositionChangeObserver;
  24715. /** Set a function to call when the collision's position changes */
  24716. onCollisionPositionChange: () => void;
  24717. /**
  24718. * An event triggered when material is changed
  24719. */
  24720. onMaterialChangedObservable: Observable<AbstractMesh>;
  24721. /**
  24722. * Gets or sets the orientation for POV movement & rotation
  24723. */
  24724. definedFacingForward: boolean;
  24725. /** @hidden */
  24726. _occlusionQuery: Nullable<WebGLQuery>;
  24727. private _visibility;
  24728. /**
  24729. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24730. */
  24731. /**
  24732. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24733. */
  24734. visibility: number;
  24735. /** Gets or sets the alpha index used to sort transparent meshes
  24736. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24737. */
  24738. alphaIndex: number;
  24739. /**
  24740. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24741. */
  24742. isVisible: boolean;
  24743. /**
  24744. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24745. */
  24746. isPickable: boolean;
  24747. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24748. showSubMeshesBoundingBox: boolean;
  24749. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24750. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24751. */
  24752. isBlocker: boolean;
  24753. /**
  24754. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24755. */
  24756. enablePointerMoveEvents: boolean;
  24757. /**
  24758. * Specifies the rendering group id for this mesh (0 by default)
  24759. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24760. */
  24761. renderingGroupId: number;
  24762. private _material;
  24763. /** Gets or sets current material */
  24764. material: Nullable<Material>;
  24765. private _receiveShadows;
  24766. /**
  24767. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24768. * @see http://doc.babylonjs.com/babylon101/shadows
  24769. */
  24770. receiveShadows: boolean;
  24771. /** Defines color to use when rendering outline */
  24772. outlineColor: Color3;
  24773. /** Define width to use when rendering outline */
  24774. outlineWidth: number;
  24775. /** Defines color to use when rendering overlay */
  24776. overlayColor: Color3;
  24777. /** Defines alpha to use when rendering overlay */
  24778. overlayAlpha: number;
  24779. private _hasVertexAlpha;
  24780. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24781. hasVertexAlpha: boolean;
  24782. private _useVertexColors;
  24783. /** 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) */
  24784. useVertexColors: boolean;
  24785. private _computeBonesUsingShaders;
  24786. /**
  24787. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24788. */
  24789. computeBonesUsingShaders: boolean;
  24790. private _numBoneInfluencers;
  24791. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24792. numBoneInfluencers: number;
  24793. private _applyFog;
  24794. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24795. applyFog: boolean;
  24796. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24797. useOctreeForRenderingSelection: boolean;
  24798. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24799. useOctreeForPicking: boolean;
  24800. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24801. useOctreeForCollisions: boolean;
  24802. private _layerMask;
  24803. /**
  24804. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24805. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24806. */
  24807. layerMask: number;
  24808. /**
  24809. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24810. */
  24811. alwaysSelectAsActiveMesh: boolean;
  24812. /**
  24813. * Gets or sets the current action manager
  24814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24815. */
  24816. actionManager: Nullable<ActionManager>;
  24817. private _checkCollisions;
  24818. private _collisionMask;
  24819. private _collisionGroup;
  24820. /**
  24821. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24822. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24823. */
  24824. ellipsoid: Vector3;
  24825. /**
  24826. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24827. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24828. */
  24829. ellipsoidOffset: Vector3;
  24830. private _collider;
  24831. private _oldPositionForCollisions;
  24832. private _diffPositionForCollisions;
  24833. /**
  24834. * Gets or sets a collision mask used to mask collisions (default is -1).
  24835. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24836. */
  24837. collisionMask: number;
  24838. /**
  24839. * Gets or sets the current collision group mask (-1 by default).
  24840. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24841. */
  24842. collisionGroup: number;
  24843. /**
  24844. * Defines edge width used when edgesRenderer is enabled
  24845. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24846. */
  24847. edgesWidth: number;
  24848. /**
  24849. * Defines edge color used when edgesRenderer is enabled
  24850. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24851. */
  24852. edgesColor: Color4;
  24853. /** @hidden */
  24854. _edgesRenderer: Nullable<IEdgesRenderer>;
  24855. /** @hidden */
  24856. _masterMesh: Nullable<AbstractMesh>;
  24857. /** @hidden */
  24858. _boundingInfo: Nullable<BoundingInfo>;
  24859. /** @hidden */
  24860. _renderId: number;
  24861. /**
  24862. * Gets or sets the list of subMeshes
  24863. * @see http://doc.babylonjs.com/how_to/multi_materials
  24864. */
  24865. subMeshes: SubMesh[];
  24866. /** @hidden */
  24867. _intersectionsInProgress: AbstractMesh[];
  24868. /** @hidden */
  24869. _unIndexed: boolean;
  24870. /** @hidden */
  24871. _lightSources: Light[];
  24872. /** @hidden */
  24873. readonly _positions: Nullable<Vector3[]>;
  24874. /** @hidden */
  24875. _waitingActions: any;
  24876. /** @hidden */
  24877. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24878. private _skeleton;
  24879. /** @hidden */
  24880. _bonesTransformMatrices: Nullable<Float32Array>;
  24881. /**
  24882. * Gets or sets a skeleton to apply skining transformations
  24883. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24884. */
  24885. skeleton: Nullable<Skeleton>;
  24886. /**
  24887. * An event triggered when the mesh is rebuilt.
  24888. */
  24889. onRebuildObservable: Observable<AbstractMesh>;
  24890. /**
  24891. * Creates a new AbstractMesh
  24892. * @param name defines the name of the mesh
  24893. * @param scene defines the hosting scene
  24894. */
  24895. constructor(name: string, scene?: Nullable<Scene>);
  24896. /**
  24897. * Returns the string "AbstractMesh"
  24898. * @returns "AbstractMesh"
  24899. */
  24900. getClassName(): string;
  24901. /**
  24902. * Gets a string representation of the current mesh
  24903. * @param fullDetails defines a boolean indicating if full details must be included
  24904. * @returns a string representation of the current mesh
  24905. */
  24906. toString(fullDetails?: boolean): string;
  24907. /** @hidden */
  24908. _rebuild(): void;
  24909. /** @hidden */
  24910. _resyncLightSources(): void;
  24911. /** @hidden */
  24912. _resyncLighSource(light: Light): void;
  24913. /** @hidden */
  24914. _unBindEffect(): void;
  24915. /** @hidden */
  24916. _removeLightSource(light: Light): void;
  24917. private _markSubMeshesAsDirty;
  24918. /** @hidden */
  24919. _markSubMeshesAsLightDirty(): void;
  24920. /** @hidden */
  24921. _markSubMeshesAsAttributesDirty(): void;
  24922. /** @hidden */
  24923. _markSubMeshesAsMiscDirty(): void;
  24924. /**
  24925. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24926. */
  24927. scaling: Vector3;
  24928. /**
  24929. * Returns true if the mesh is blocked. Implemented by child classes
  24930. */
  24931. readonly isBlocked: boolean;
  24932. /**
  24933. * Returns the mesh itself by default. Implemented by child classes
  24934. * @param camera defines the camera to use to pick the right LOD level
  24935. * @returns the currentAbstractMesh
  24936. */
  24937. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24938. /**
  24939. * Returns 0 by default. Implemented by child classes
  24940. * @returns an integer
  24941. */
  24942. getTotalVertices(): number;
  24943. /**
  24944. * Returns a positive integer : the total number of indices in this mesh geometry.
  24945. * @returns the numner of indices or zero if the mesh has no geometry.
  24946. */
  24947. getTotalIndices(): number;
  24948. /**
  24949. * Returns null by default. Implemented by child classes
  24950. * @returns null
  24951. */
  24952. getIndices(): Nullable<IndicesArray>;
  24953. /**
  24954. * Returns the array of the requested vertex data kind. Implemented by child classes
  24955. * @param kind defines the vertex data kind to use
  24956. * @returns null
  24957. */
  24958. getVerticesData(kind: string): Nullable<FloatArray>;
  24959. /**
  24960. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24961. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24962. * Note that a new underlying VertexBuffer object is created each call.
  24963. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24964. * @param kind defines vertex data kind:
  24965. * * BABYLON.VertexBuffer.PositionKind
  24966. * * BABYLON.VertexBuffer.UVKind
  24967. * * BABYLON.VertexBuffer.UV2Kind
  24968. * * BABYLON.VertexBuffer.UV3Kind
  24969. * * BABYLON.VertexBuffer.UV4Kind
  24970. * * BABYLON.VertexBuffer.UV5Kind
  24971. * * BABYLON.VertexBuffer.UV6Kind
  24972. * * BABYLON.VertexBuffer.ColorKind
  24973. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24974. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24975. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24976. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24977. * @param data defines the data source
  24978. * @param updatable defines if the data must be flagged as updatable (or static)
  24979. * @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
  24980. * @returns the current mesh
  24981. */
  24982. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24983. /**
  24984. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24985. * If the mesh has no geometry, it is simply returned as it is.
  24986. * @param kind defines vertex data kind:
  24987. * * BABYLON.VertexBuffer.PositionKind
  24988. * * BABYLON.VertexBuffer.UVKind
  24989. * * BABYLON.VertexBuffer.UV2Kind
  24990. * * BABYLON.VertexBuffer.UV3Kind
  24991. * * BABYLON.VertexBuffer.UV4Kind
  24992. * * BABYLON.VertexBuffer.UV5Kind
  24993. * * BABYLON.VertexBuffer.UV6Kind
  24994. * * BABYLON.VertexBuffer.ColorKind
  24995. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24996. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24997. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24998. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24999. * @param data defines the data source
  25000. * @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
  25001. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25002. * @returns the current mesh
  25003. */
  25004. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25005. /**
  25006. * Sets the mesh indices,
  25007. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25008. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25009. * @param totalVertices Defines the total number of vertices
  25010. * @returns the current mesh
  25011. */
  25012. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25013. /**
  25014. * Gets a boolean indicating if specific vertex data is present
  25015. * @param kind defines the vertex data kind to use
  25016. * @returns true is data kind is present
  25017. */
  25018. isVerticesDataPresent(kind: string): boolean;
  25019. /**
  25020. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25021. * @returns a BoundingInfo
  25022. */
  25023. getBoundingInfo(): BoundingInfo;
  25024. /**
  25025. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25026. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  25027. * @returns the current mesh
  25028. */
  25029. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  25030. /**
  25031. * Overwrite the current bounding info
  25032. * @param boundingInfo defines the new bounding info
  25033. * @returns the current mesh
  25034. */
  25035. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25036. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25037. readonly useBones: boolean;
  25038. /** @hidden */
  25039. _preActivate(): void;
  25040. /** @hidden */
  25041. _preActivateForIntermediateRendering(renderId: number): void;
  25042. /** @hidden */
  25043. _activate(renderId: number): void;
  25044. /**
  25045. * Gets the current world matrix
  25046. * @returns a Matrix
  25047. */
  25048. getWorldMatrix(): Matrix;
  25049. /** @hidden */
  25050. _getWorldMatrixDeterminant(): number;
  25051. /**
  25052. * Perform relative position change from the point of view of behind the front of the mesh.
  25053. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25054. * Supports definition of mesh facing forward or backward
  25055. * @param amountRight defines the distance on the right axis
  25056. * @param amountUp defines the distance on the up axis
  25057. * @param amountForward defines the distance on the forward axis
  25058. * @returns the current mesh
  25059. */
  25060. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25061. /**
  25062. * Calculate relative position change from the point of view of behind the front of the mesh.
  25063. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25064. * Supports definition of mesh facing forward or backward
  25065. * @param amountRight defines the distance on the right axis
  25066. * @param amountUp defines the distance on the up axis
  25067. * @param amountForward defines the distance on the forward axis
  25068. * @returns the new displacement vector
  25069. */
  25070. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25071. /**
  25072. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25073. * Supports definition of mesh facing forward or backward
  25074. * @param flipBack defines the flip
  25075. * @param twirlClockwise defines the twirl
  25076. * @param tiltRight defines the tilt
  25077. * @returns the current mesh
  25078. */
  25079. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25080. /**
  25081. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25082. * Supports definition of mesh facing forward or backward.
  25083. * @param flipBack defines the flip
  25084. * @param twirlClockwise defines the twirl
  25085. * @param tiltRight defines the tilt
  25086. * @returns the new rotation vector
  25087. */
  25088. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25089. /**
  25090. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  25091. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25092. * @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
  25093. * @returns the new bounding vectors
  25094. */
  25095. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25096. min: Vector3;
  25097. max: Vector3;
  25098. };
  25099. /**
  25100. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25101. * This means the mesh underlying bounding box and sphere are recomputed.
  25102. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25103. * @returns the current mesh
  25104. */
  25105. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25106. /** @hidden */
  25107. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25108. /** @hidden */
  25109. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25110. /** @hidden */
  25111. _updateBoundingInfo(): AbstractMesh;
  25112. /** @hidden */
  25113. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25114. /** @hidden */
  25115. protected _afterComputeWorldMatrix(): void;
  25116. /**
  25117. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25118. * A mesh is in the frustum if its bounding box intersects the frustum
  25119. * @param frustumPlanes defines the frustum to test
  25120. * @returns true if the mesh is in the frustum planes
  25121. */
  25122. isInFrustum(frustumPlanes: Plane[]): boolean;
  25123. /**
  25124. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25125. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25126. * @param frustumPlanes defines the frustum to test
  25127. * @returns true if the mesh is completely in the frustum planes
  25128. */
  25129. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25130. /**
  25131. * True if the mesh intersects another mesh or a SolidParticle object
  25132. * @param mesh defines a target mesh or SolidParticle to test
  25133. * @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)
  25134. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25135. * @returns true if there is an intersection
  25136. */
  25137. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25138. /**
  25139. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25140. * @param point defines the point to test
  25141. * @returns true if there is an intersection
  25142. */
  25143. intersectsPoint(point: Vector3): boolean;
  25144. /**
  25145. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25146. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25147. */
  25148. checkCollisions: boolean;
  25149. /**
  25150. * Gets Collider object used to compute collisions (not physics)
  25151. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25152. */
  25153. readonly collider: Collider;
  25154. /**
  25155. * Move the mesh using collision engine
  25156. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25157. * @param displacement defines the requested displacement vector
  25158. * @returns the current mesh
  25159. */
  25160. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25161. private _onCollisionPositionChange;
  25162. /** @hidden */
  25163. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25164. /** @hidden */
  25165. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25166. /** @hidden */
  25167. _checkCollision(collider: Collider): AbstractMesh;
  25168. /** @hidden */
  25169. _generatePointsArray(): boolean;
  25170. /**
  25171. * Checks if the passed Ray intersects with the mesh
  25172. * @param ray defines the ray to use
  25173. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25174. * @returns the picking info
  25175. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25176. */
  25177. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  25178. /**
  25179. * Clones the current mesh
  25180. * @param name defines the mesh name
  25181. * @param newParent defines the new mesh parent
  25182. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25183. * @returns the new mesh
  25184. */
  25185. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25186. /**
  25187. * Disposes all the submeshes of the current meshnp
  25188. * @returns the current mesh
  25189. */
  25190. releaseSubMeshes(): AbstractMesh;
  25191. /**
  25192. * Releases resources associated with this abstract mesh.
  25193. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25194. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25195. */
  25196. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25197. /**
  25198. * Adds the passed mesh as a child to the current mesh
  25199. * @param mesh defines the child mesh
  25200. * @returns the current mesh
  25201. */
  25202. addChild(mesh: AbstractMesh): AbstractMesh;
  25203. /**
  25204. * Removes the passed mesh from the current mesh children list
  25205. * @param mesh defines the child mesh
  25206. * @returns the current mesh
  25207. */
  25208. removeChild(mesh: AbstractMesh): AbstractMesh;
  25209. /** @hidden */
  25210. private _initFacetData;
  25211. /**
  25212. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25213. * This method can be called within the render loop.
  25214. * 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
  25215. * @returns the current mesh
  25216. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25217. */
  25218. updateFacetData(): AbstractMesh;
  25219. /**
  25220. * Returns the facetLocalNormals array.
  25221. * The normals are expressed in the mesh local spac
  25222. * @returns an array of Vector3
  25223. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25224. */
  25225. getFacetLocalNormals(): Vector3[];
  25226. /**
  25227. * Returns the facetLocalPositions array.
  25228. * The facet positions are expressed in the mesh local space
  25229. * @returns an array of Vector3
  25230. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25231. */
  25232. getFacetLocalPositions(): Vector3[];
  25233. /**
  25234. * Returns the facetLocalPartioning array
  25235. * @returns an array of array of numbers
  25236. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25237. */
  25238. getFacetLocalPartitioning(): number[][];
  25239. /**
  25240. * Returns the i-th facet position in the world system.
  25241. * This method allocates a new Vector3 per call
  25242. * @param i defines the facet index
  25243. * @returns a new Vector3
  25244. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25245. */
  25246. getFacetPosition(i: number): Vector3;
  25247. /**
  25248. * Sets the reference Vector3 with the i-th facet position in the world system
  25249. * @param i defines the facet index
  25250. * @param ref defines the target vector
  25251. * @returns the current mesh
  25252. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25253. */
  25254. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25255. /**
  25256. * Returns the i-th facet normal in the world system.
  25257. * This method allocates a new Vector3 per call
  25258. * @param i defines the facet index
  25259. * @returns a new Vector3
  25260. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25261. */
  25262. getFacetNormal(i: number): Vector3;
  25263. /**
  25264. * Sets the reference Vector3 with the i-th facet normal in the world system
  25265. * @param i defines the facet index
  25266. * @param ref defines the target vector
  25267. * @returns the current mesh
  25268. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25269. */
  25270. getFacetNormalToRef(i: number, ref: Vector3): this;
  25271. /**
  25272. * 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)
  25273. * @param x defines x coordinate
  25274. * @param y defines y coordinate
  25275. * @param z defines z coordinate
  25276. * @returns the array of facet indexes
  25277. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25278. */
  25279. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25280. /**
  25281. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25282. * @param projected sets as the (x,y,z) world projection on the facet
  25283. * @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
  25284. * @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
  25285. * @param x defines x coordinate
  25286. * @param y defines y coordinate
  25287. * @param z defines z coordinate
  25288. * @returns the face index if found (or null instead)
  25289. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25290. */
  25291. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25292. /**
  25293. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25294. * @param projected sets as the (x,y,z) local projection on the facet
  25295. * @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
  25296. * @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
  25297. * @param x defines x coordinate
  25298. * @param y defines y coordinate
  25299. * @param z defines z coordinate
  25300. * @returns the face index if found (or null instead)
  25301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25302. */
  25303. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25304. /**
  25305. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25306. * @returns the parameters
  25307. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25308. */
  25309. getFacetDataParameters(): any;
  25310. /**
  25311. * Disables the feature FacetData and frees the related memory
  25312. * @returns the current mesh
  25313. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25314. */
  25315. disableFacetData(): AbstractMesh;
  25316. /**
  25317. * Updates the AbstractMesh indices array
  25318. * @param indices defines the data source
  25319. * @returns the current mesh
  25320. */
  25321. updateIndices(indices: IndicesArray): AbstractMesh;
  25322. /**
  25323. * Creates new normals data for the mesh
  25324. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25325. * @returns the current mesh
  25326. */
  25327. createNormals(updatable: boolean): AbstractMesh;
  25328. /**
  25329. * Align the mesh with a normal
  25330. * @param normal defines the normal to use
  25331. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25332. * @returns the current mesh
  25333. */
  25334. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25335. /** @hidden */
  25336. _checkOcclusionQuery(): boolean;
  25337. }
  25338. }
  25339. declare module BABYLON {
  25340. /**
  25341. * Class used to store data that will be store in GPU memory
  25342. */
  25343. class Buffer {
  25344. private _engine;
  25345. private _buffer;
  25346. /** @hidden */
  25347. _data: Nullable<DataArray>;
  25348. private _updatable;
  25349. private _instanced;
  25350. /**
  25351. * Gets the byte stride.
  25352. */
  25353. readonly byteStride: number;
  25354. /**
  25355. * Constructor
  25356. * @param engine the engine
  25357. * @param data the data to use for this buffer
  25358. * @param updatable whether the data is updatable
  25359. * @param stride the stride (optional)
  25360. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  25361. * @param instanced whether the buffer is instanced (optional)
  25362. * @param useBytes set to true if the stride in in bytes (optional)
  25363. */
  25364. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  25365. /**
  25366. * Create a new VertexBuffer based on the current buffer
  25367. * @param kind defines the vertex buffer kind (position, normal, etc.)
  25368. * @param offset defines offset in the buffer (0 by default)
  25369. * @param size defines the size in floats of attributes (position is 3 for instance)
  25370. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  25371. * @param instanced defines if the vertex buffer contains indexed data
  25372. * @param useBytes defines if the offset and stride are in bytes
  25373. * @returns the new vertex buffer
  25374. */
  25375. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  25376. /**
  25377. * Gets a boolean indicating if the Buffer is updatable?
  25378. * @returns true if the buffer is updatable
  25379. */
  25380. isUpdatable(): boolean;
  25381. /**
  25382. * Gets current buffer's data
  25383. * @returns a DataArray or null
  25384. */
  25385. getData(): Nullable<DataArray>;
  25386. /**
  25387. * Gets underlying native buffer
  25388. * @returns underlying native buffer
  25389. */
  25390. getBuffer(): Nullable<WebGLBuffer>;
  25391. /**
  25392. * Gets the stride in float32 units (i.e. byte stride / 4).
  25393. * May not be an integer if the byte stride is not divisible by 4.
  25394. * DEPRECATED. Use byteStride instead.
  25395. * @returns the stride in float32 units
  25396. */
  25397. getStrideSize(): number;
  25398. /**
  25399. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  25400. * @param data defines the data to store
  25401. */
  25402. create(data?: Nullable<DataArray>): void;
  25403. /** @hidden */
  25404. _rebuild(): void;
  25405. /**
  25406. * Update current buffer data
  25407. * @param data defines the data to store
  25408. */
  25409. update(data: DataArray): void;
  25410. /**
  25411. * Updates the data directly.
  25412. * @param data the new data
  25413. * @param offset the new offset
  25414. * @param vertexCount the vertex count (optional)
  25415. * @param useBytes set to true if the offset is in bytes
  25416. */
  25417. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  25418. /**
  25419. * Release all resources
  25420. */
  25421. dispose(): void;
  25422. }
  25423. }
  25424. declare module BABYLON {
  25425. /**
  25426. * Class for building Constructive Solid Geometry
  25427. */
  25428. class CSG {
  25429. private polygons;
  25430. /**
  25431. * The world matrix
  25432. */
  25433. matrix: Matrix;
  25434. /**
  25435. * Stores the position
  25436. */
  25437. position: Vector3;
  25438. /**
  25439. * Stores the rotation
  25440. */
  25441. rotation: Vector3;
  25442. /**
  25443. * Stores the rotation quaternion
  25444. */
  25445. rotationQuaternion: Nullable<Quaternion>;
  25446. /**
  25447. * Stores the scaling vector
  25448. */
  25449. scaling: Vector3;
  25450. /**
  25451. * Convert the BABYLON.Mesh to BABYLON.CSG
  25452. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  25453. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  25454. */
  25455. static FromMesh(mesh: Mesh): CSG;
  25456. /**
  25457. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  25458. * @param polygons Polygons used to construct a BABYLON.CSG solid
  25459. */
  25460. private static FromPolygons;
  25461. /**
  25462. * Clones, or makes a deep copy, of the BABYLON.CSG
  25463. * @returns A new BABYLON.CSG
  25464. */
  25465. clone(): CSG;
  25466. /**
  25467. * Unions this CSG with another CSG
  25468. * @param csg The CSG to union against this CSG
  25469. * @returns The unioned CSG
  25470. */
  25471. union(csg: CSG): CSG;
  25472. /**
  25473. * Unions this CSG with another CSG in place
  25474. * @param csg The CSG to union against this CSG
  25475. */
  25476. unionInPlace(csg: CSG): void;
  25477. /**
  25478. * Subtracts this CSG with another CSG
  25479. * @param csg The CSG to subtract against this CSG
  25480. * @returns A new BABYLON.CSG
  25481. */
  25482. subtract(csg: CSG): CSG;
  25483. /**
  25484. * Subtracts this CSG with another CSG in place
  25485. * @param csg The CSG to subtact against this CSG
  25486. */
  25487. subtractInPlace(csg: CSG): void;
  25488. /**
  25489. * Intersect this CSG with another CSG
  25490. * @param csg The CSG to intersect against this CSG
  25491. * @returns A new BABYLON.CSG
  25492. */
  25493. intersect(csg: CSG): CSG;
  25494. /**
  25495. * Intersects this CSG with another CSG in place
  25496. * @param csg The CSG to intersect against this CSG
  25497. */
  25498. intersectInPlace(csg: CSG): void;
  25499. /**
  25500. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  25501. * not modified.
  25502. * @returns A new BABYLON.CSG solid with solid and empty space switched
  25503. */
  25504. inverse(): CSG;
  25505. /**
  25506. * Inverses the BABYLON.CSG in place
  25507. */
  25508. inverseInPlace(): void;
  25509. /**
  25510. * This is used to keep meshes transformations so they can be restored
  25511. * when we build back a Babylon Mesh
  25512. * NB : All CSG operations are performed in world coordinates
  25513. * @param csg The BABYLON.CSG to copy the transform attributes from
  25514. * @returns This BABYLON.CSG
  25515. */
  25516. copyTransformAttributes(csg: CSG): CSG;
  25517. /**
  25518. * Build Raw mesh from CSG
  25519. * Coordinates here are in world space
  25520. * @param name The name of the mesh geometry
  25521. * @param scene The BABYLON.Scene
  25522. * @param keepSubMeshes Specifies if the submeshes should be kept
  25523. * @returns A new BABYLON.Mesh
  25524. */
  25525. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  25526. /**
  25527. * Build Mesh from CSG taking material and transforms into account
  25528. * @param name The name of the BABYLON.Mesh
  25529. * @param material The material of the BABYLON.Mesh
  25530. * @param scene The BABYLON.Scene
  25531. * @param keepSubMeshes Specifies if submeshes should be kept
  25532. * @returns The new BABYLON.Mesh
  25533. */
  25534. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  25535. }
  25536. }
  25537. declare module BABYLON {
  25538. /**
  25539. * Class used to store geometry data (vertex buffers + index buffer)
  25540. */
  25541. class Geometry implements IGetSetVerticesData {
  25542. /**
  25543. * Gets or sets the ID of the geometry
  25544. */
  25545. id: string;
  25546. /**
  25547. * Gets or sets the unique ID of the geometry
  25548. */
  25549. uniqueId: number;
  25550. /**
  25551. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25552. */
  25553. delayLoadState: number;
  25554. /**
  25555. * Gets the file containing the data to load when running in delay load state
  25556. */
  25557. delayLoadingFile: Nullable<string>;
  25558. /**
  25559. * Callback called when the geometry is updated
  25560. */
  25561. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25562. private _scene;
  25563. private _engine;
  25564. private _meshes;
  25565. private _totalVertices;
  25566. /** @hidden */
  25567. _indices: IndicesArray;
  25568. /** @hidden */
  25569. _vertexBuffers: {
  25570. [key: string]: VertexBuffer;
  25571. };
  25572. private _isDisposed;
  25573. private _extend;
  25574. private _boundingBias;
  25575. /** @hidden */
  25576. _delayInfo: Array<string>;
  25577. private _indexBuffer;
  25578. private _indexBufferIsUpdatable;
  25579. /** @hidden */
  25580. _boundingInfo: Nullable<BoundingInfo>;
  25581. /** @hidden */
  25582. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25583. /** @hidden */
  25584. _softwareSkinningFrameId: number;
  25585. private _vertexArrayObjects;
  25586. private _updatable;
  25587. /** @hidden */
  25588. _positions: Nullable<Vector3[]>;
  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. /**
  25593. * 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
  25594. */
  25595. boundingBias: Vector2;
  25596. /**
  25597. * Static function used to attach a new empty geometry to a mesh
  25598. * @param mesh defines the mesh to attach the geometry to
  25599. * @returns the new Geometry
  25600. */
  25601. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25602. /**
  25603. * Creates a new geometry
  25604. * @param id defines the unique ID
  25605. * @param scene defines the hosting scene
  25606. * @param vertexData defines the VertexData used to get geometry data
  25607. * @param updatable defines if geometry must be updatable (false by default)
  25608. * @param mesh defines the mesh that will be associated with the geometry
  25609. */
  25610. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25611. /**
  25612. * Gets the current extend of the geometry
  25613. */
  25614. readonly extend: {
  25615. minimum: Vector3;
  25616. maximum: Vector3;
  25617. };
  25618. /**
  25619. * Gets the hosting scene
  25620. * @returns the hosting Scene
  25621. */
  25622. getScene(): Scene;
  25623. /**
  25624. * Gets the hosting engine
  25625. * @returns the hosting Engine
  25626. */
  25627. getEngine(): Engine;
  25628. /**
  25629. * Defines if the geometry is ready to use
  25630. * @returns true if the geometry is ready to be used
  25631. */
  25632. isReady(): boolean;
  25633. /**
  25634. * Gets a value indicating that the geometry should not be serialized
  25635. */
  25636. readonly doNotSerialize: boolean;
  25637. /** @hidden */
  25638. _rebuild(): void;
  25639. /**
  25640. * Affects all geometry data in one call
  25641. * @param vertexData defines the geometry data
  25642. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25643. */
  25644. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25645. /**
  25646. * Set specific vertex data
  25647. * @param kind defines the data kind (Position, normal, etc...)
  25648. * @param data defines the vertex data to use
  25649. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25650. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25651. */
  25652. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25653. /**
  25654. * Removes a specific vertex data
  25655. * @param kind defines the data kind (Position, normal, etc...)
  25656. */
  25657. removeVerticesData(kind: string): void;
  25658. /**
  25659. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25660. * @param buffer defines the vertex buffer to use
  25661. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25662. */
  25663. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25664. /**
  25665. * Update a specific vertex buffer
  25666. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25667. * It will do nothing if the buffer is not updatable
  25668. * @param kind defines the data kind (Position, normal, etc...)
  25669. * @param data defines the data to use
  25670. * @param offset defines the offset in the target buffer where to store the data
  25671. * @param useBytes set to true if the offset is in bytes
  25672. */
  25673. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25674. /**
  25675. * Update a specific vertex buffer
  25676. * This function will create a new buffer if the current one is not updatable
  25677. * @param kind defines the data kind (Position, normal, etc...)
  25678. * @param data defines the data to use
  25679. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25680. */
  25681. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25682. private _updateBoundingInfo;
  25683. /** @hidden */
  25684. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25685. /**
  25686. * Gets total number of vertices
  25687. * @returns the total number of vertices
  25688. */
  25689. getTotalVertices(): number;
  25690. /**
  25691. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25692. * @param kind defines the data kind (Position, normal, etc...)
  25693. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25694. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25695. * @returns a float array containing vertex data
  25696. */
  25697. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25698. /**
  25699. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25700. * @param kind defines the data kind (Position, normal, etc...)
  25701. * @returns true if the vertex buffer with the specified kind is updatable
  25702. */
  25703. isVertexBufferUpdatable(kind: string): boolean;
  25704. /**
  25705. * Gets a specific vertex buffer
  25706. * @param kind defines the data kind (Position, normal, etc...)
  25707. * @returns a VertexBuffer
  25708. */
  25709. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25710. /**
  25711. * Returns all vertex buffers
  25712. * @return an object holding all vertex buffers indexed by kind
  25713. */
  25714. getVertexBuffers(): Nullable<{
  25715. [key: string]: VertexBuffer;
  25716. }>;
  25717. /**
  25718. * Gets a boolean indicating if specific vertex buffer is present
  25719. * @param kind defines the data kind (Position, normal, etc...)
  25720. * @returns true if data is present
  25721. */
  25722. isVerticesDataPresent(kind: string): boolean;
  25723. /**
  25724. * Gets a list of all attached data kinds (Position, normal, etc...)
  25725. * @returns a list of string containing all kinds
  25726. */
  25727. getVerticesDataKinds(): string[];
  25728. /**
  25729. * Update index buffer
  25730. * @param indices defines the indices to store in the index buffer
  25731. * @param offset defines the offset in the target buffer where to store the data
  25732. */
  25733. updateIndices(indices: IndicesArray, offset?: number): void;
  25734. /**
  25735. * Creates a new index buffer
  25736. * @param indices defines the indices to store in the index buffer
  25737. * @param totalVertices defines the total number of vertices (could be null)
  25738. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25739. */
  25740. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25741. /**
  25742. * Return the total number of indices
  25743. * @returns the total number of indices
  25744. */
  25745. getTotalIndices(): number;
  25746. /**
  25747. * Gets the index buffer array
  25748. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25749. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25750. * @returns the index buffer array
  25751. */
  25752. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25753. /**
  25754. * Gets the index buffer
  25755. * @return the index buffer
  25756. */
  25757. getIndexBuffer(): Nullable<WebGLBuffer>;
  25758. /** @hidden */
  25759. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25760. /**
  25761. * Release the associated resources for a specific mesh
  25762. * @param mesh defines the source mesh
  25763. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25764. */
  25765. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25766. /**
  25767. * Apply current geometry to a given mesh
  25768. * @param mesh defines the mesh to apply geometry to
  25769. */
  25770. applyToMesh(mesh: Mesh): void;
  25771. private _updateExtend;
  25772. private _applyToMesh;
  25773. private notifyUpdate;
  25774. /**
  25775. * Load the geometry if it was flagged as delay loaded
  25776. * @param scene defines the hosting scene
  25777. * @param onLoaded defines a callback called when the geometry is loaded
  25778. */
  25779. load(scene: Scene, onLoaded?: () => void): void;
  25780. private _queueLoad;
  25781. /**
  25782. * Invert the geometry to move from a right handed system to a left handed one.
  25783. */
  25784. toLeftHanded(): void;
  25785. /** @hidden */
  25786. _resetPointsArrayCache(): void;
  25787. /** @hidden */
  25788. _generatePointsArray(): boolean;
  25789. /**
  25790. * Gets a value indicating if the geometry is disposed
  25791. * @returns true if the geometry was disposed
  25792. */
  25793. isDisposed(): boolean;
  25794. private _disposeVertexArrayObjects;
  25795. /**
  25796. * Free all associated resources
  25797. */
  25798. dispose(): void;
  25799. /**
  25800. * Clone the current geometry into a new geometry
  25801. * @param id defines the unique ID of the new geometry
  25802. * @returns a new geometry object
  25803. */
  25804. copy(id: string): Geometry;
  25805. /**
  25806. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25807. * @return a JSON representation of the current geometry data (without the vertices data)
  25808. */
  25809. serialize(): any;
  25810. private toNumberArray;
  25811. /**
  25812. * Serialize all vertices data into a JSON oject
  25813. * @returns a JSON representation of the current geometry data
  25814. */
  25815. serializeVerticeData(): any;
  25816. /**
  25817. * Extracts a clone of a mesh geometry
  25818. * @param mesh defines the source mesh
  25819. * @param id defines the unique ID of the new geometry object
  25820. * @returns the new geometry object
  25821. */
  25822. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25823. /**
  25824. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25825. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25826. * Be aware Math.random() could cause collisions, but:
  25827. * "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"
  25828. * @returns a string containing a new GUID
  25829. */
  25830. static RandomId(): string;
  25831. /** @hidden */
  25832. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25833. private static _CleanMatricesWeights;
  25834. /**
  25835. * Create a new geometry from persisted data (Using .babylon file format)
  25836. * @param parsedVertexData defines the persisted data
  25837. * @param scene defines the hosting scene
  25838. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25839. * @returns the new geometry object
  25840. */
  25841. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25842. }
  25843. /**
  25844. * Abstract class used to provide common services for all typed geometries
  25845. * @hidden
  25846. */
  25847. class _PrimitiveGeometry extends Geometry {
  25848. private _canBeRegenerated;
  25849. private _beingRegenerated;
  25850. /**
  25851. * Creates a new typed geometry
  25852. * @param id defines the unique ID of the geometry
  25853. * @param scene defines the hosting scene
  25854. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25855. * @param mesh defines the hosting mesh (can be null)
  25856. */
  25857. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25858. /**
  25859. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25860. * @returns true if the geometry can be regenerated
  25861. */
  25862. canBeRegenerated(): boolean;
  25863. /**
  25864. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25865. */
  25866. regenerate(): void;
  25867. /**
  25868. * Clone the geometry
  25869. * @param id defines the unique ID of the new geometry
  25870. * @returns the new geometry
  25871. */
  25872. asNewGeometry(id: string): Geometry;
  25873. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25874. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25875. /** @hidden */
  25876. _regenerateVertexData(): VertexData;
  25877. copy(id: string): Geometry;
  25878. serialize(): any;
  25879. }
  25880. /**
  25881. * Creates a ribbon geometry
  25882. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25883. */
  25884. class RibbonGeometry extends _PrimitiveGeometry {
  25885. /**
  25886. * Defines the array of paths to use
  25887. */
  25888. pathArray: Vector3[][];
  25889. /**
  25890. * Defines if the last and first points of each path in your pathArray must be joined
  25891. */
  25892. closeArray: boolean;
  25893. /**
  25894. * Defines if the last and first points of each path in your pathArray must be joined
  25895. */
  25896. closePath: boolean;
  25897. /**
  25898. * Defines the offset between points
  25899. */
  25900. offset: number;
  25901. /**
  25902. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25903. */
  25904. side: number;
  25905. /**
  25906. * Creates a ribbon geometry
  25907. * @param id defines the unique ID of the geometry
  25908. * @param scene defines the hosting scene
  25909. * @param pathArray defines the array of paths to use
  25910. * @param closeArray defines if the last path and the first path must be joined
  25911. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25912. * @param offset defines the offset between points
  25913. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25914. * @param mesh defines the hosting mesh (can be null)
  25915. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25916. */
  25917. constructor(id: string, scene: Scene,
  25918. /**
  25919. * Defines the array of paths to use
  25920. */
  25921. pathArray: Vector3[][],
  25922. /**
  25923. * Defines if the last and first points of each path in your pathArray must be joined
  25924. */
  25925. closeArray: boolean,
  25926. /**
  25927. * Defines if the last and first points of each path in your pathArray must be joined
  25928. */
  25929. closePath: boolean,
  25930. /**
  25931. * Defines the offset between points
  25932. */
  25933. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25934. /**
  25935. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25936. */
  25937. side?: number);
  25938. /** @hidden */
  25939. _regenerateVertexData(): VertexData;
  25940. copy(id: string): Geometry;
  25941. }
  25942. /**
  25943. * Creates a box geometry
  25944. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25945. */
  25946. class BoxGeometry extends _PrimitiveGeometry {
  25947. /**
  25948. * Defines the zise of the box (width, height and depth are the same)
  25949. */
  25950. size: number;
  25951. /**
  25952. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25953. */
  25954. side: number;
  25955. /**
  25956. * Creates a box geometry
  25957. * @param id defines the unique ID of the geometry
  25958. * @param scene defines the hosting scene
  25959. * @param size defines the zise of the box (width, height and depth are the same)
  25960. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25961. * @param mesh defines the hosting mesh (can be null)
  25962. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25963. */
  25964. constructor(id: string, scene: Scene,
  25965. /**
  25966. * Defines the zise of the box (width, height and depth are the same)
  25967. */
  25968. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25969. /**
  25970. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25971. */
  25972. side?: number);
  25973. /** @hidden */
  25974. _regenerateVertexData(): VertexData;
  25975. copy(id: string): Geometry;
  25976. serialize(): any;
  25977. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25978. }
  25979. /**
  25980. * Creates a sphere geometry
  25981. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25982. */
  25983. class SphereGeometry extends _PrimitiveGeometry {
  25984. /**
  25985. * Defines the number of segments to use to create the sphere
  25986. */
  25987. segments: number;
  25988. /**
  25989. * Defines the diameter of the sphere
  25990. */
  25991. diameter: number;
  25992. /**
  25993. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25994. */
  25995. side: number;
  25996. /**
  25997. * Create a new sphere geometry
  25998. * @param id defines the unique ID of the geometry
  25999. * @param scene defines the hosting scene
  26000. * @param segments defines the number of segments to use to create the sphere
  26001. * @param diameter defines the diameter of the sphere
  26002. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26003. * @param mesh defines the hosting mesh (can be null)
  26004. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26005. */
  26006. constructor(id: string, scene: Scene,
  26007. /**
  26008. * Defines the number of segments to use to create the sphere
  26009. */
  26010. segments: number,
  26011. /**
  26012. * Defines the diameter of the sphere
  26013. */
  26014. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26015. /**
  26016. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26017. */
  26018. side?: number);
  26019. /** @hidden */
  26020. _regenerateVertexData(): VertexData;
  26021. copy(id: string): Geometry;
  26022. serialize(): any;
  26023. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  26024. }
  26025. /**
  26026. * Creates a disc geometry
  26027. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26028. */
  26029. class DiscGeometry extends _PrimitiveGeometry {
  26030. /**
  26031. * Defines the radius of the disc
  26032. */
  26033. radius: number;
  26034. /**
  26035. * Defines the tesselation factor to apply to the disc
  26036. */
  26037. tessellation: number;
  26038. /**
  26039. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26040. */
  26041. side: number;
  26042. /**
  26043. * Creates a new disc geometry
  26044. * @param id defines the unique ID of the geometry
  26045. * @param scene defines the hosting scene
  26046. * @param radius defines the radius of the disc
  26047. * @param tessellation defines the tesselation factor to apply to the disc
  26048. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26049. * @param mesh defines the hosting mesh (can be null)
  26050. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26051. */
  26052. constructor(id: string, scene: Scene,
  26053. /**
  26054. * Defines the radius of the disc
  26055. */
  26056. radius: number,
  26057. /**
  26058. * Defines the tesselation factor to apply to the disc
  26059. */
  26060. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26061. /**
  26062. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26063. */
  26064. side?: number);
  26065. /** @hidden */
  26066. _regenerateVertexData(): VertexData;
  26067. copy(id: string): Geometry;
  26068. }
  26069. /**
  26070. * Creates a new cylinder geometry
  26071. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  26072. */
  26073. class CylinderGeometry extends _PrimitiveGeometry {
  26074. /**
  26075. * Defines the height of the cylinder
  26076. */
  26077. height: number;
  26078. /**
  26079. * Defines the diameter of the cylinder's top cap
  26080. */
  26081. diameterTop: number;
  26082. /**
  26083. * Defines the diameter of the cylinder's bottom cap
  26084. */
  26085. diameterBottom: number;
  26086. /**
  26087. * Defines the tessellation factor to apply to the cylinder
  26088. */
  26089. tessellation: number;
  26090. /**
  26091. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  26092. */
  26093. subdivisions: number;
  26094. /**
  26095. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26096. */
  26097. side: number;
  26098. /**
  26099. * Creates a new cylinder geometry
  26100. * @param id defines the unique ID of the geometry
  26101. * @param scene defines the hosting scene
  26102. * @param height defines the height of the cylinder
  26103. * @param diameterTop defines the diameter of the cylinder's top cap
  26104. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  26105. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  26106. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  26107. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26108. * @param mesh defines the hosting mesh (can be null)
  26109. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26110. */
  26111. constructor(id: string, scene: Scene,
  26112. /**
  26113. * Defines the height of the cylinder
  26114. */
  26115. height: number,
  26116. /**
  26117. * Defines the diameter of the cylinder's top cap
  26118. */
  26119. diameterTop: number,
  26120. /**
  26121. * Defines the diameter of the cylinder's bottom cap
  26122. */
  26123. diameterBottom: number,
  26124. /**
  26125. * Defines the tessellation factor to apply to the cylinder
  26126. */
  26127. tessellation: number,
  26128. /**
  26129. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  26130. */
  26131. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26132. /**
  26133. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26134. */
  26135. side?: number);
  26136. /** @hidden */
  26137. _regenerateVertexData(): VertexData;
  26138. copy(id: string): Geometry;
  26139. serialize(): any;
  26140. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  26141. }
  26142. /**
  26143. * Creates a new torus geometry
  26144. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  26145. */
  26146. class TorusGeometry extends _PrimitiveGeometry {
  26147. /**
  26148. * Defines the diameter of the torus
  26149. */
  26150. diameter: number;
  26151. /**
  26152. * Defines the thickness of the torus (ie. internal diameter)
  26153. */
  26154. thickness: number;
  26155. /**
  26156. * Defines the tesselation factor to apply to the torus
  26157. */
  26158. tessellation: number;
  26159. /**
  26160. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26161. */
  26162. side: number;
  26163. /**
  26164. * Creates a new torus geometry
  26165. * @param id defines the unique ID of the geometry
  26166. * @param scene defines the hosting scene
  26167. * @param diameter defines the diameter of the torus
  26168. * @param thickness defines the thickness of the torus (ie. internal diameter)
  26169. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  26170. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26171. * @param mesh defines the hosting mesh (can be null)
  26172. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26173. */
  26174. constructor(id: string, scene: Scene,
  26175. /**
  26176. * Defines the diameter of the torus
  26177. */
  26178. diameter: number,
  26179. /**
  26180. * Defines the thickness of the torus (ie. internal diameter)
  26181. */
  26182. thickness: number,
  26183. /**
  26184. * Defines the tesselation factor to apply to the torus
  26185. */
  26186. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26187. /**
  26188. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26189. */
  26190. side?: number);
  26191. /** @hidden */
  26192. _regenerateVertexData(): VertexData;
  26193. copy(id: string): Geometry;
  26194. serialize(): any;
  26195. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  26196. }
  26197. /**
  26198. * Creates a new ground geometry
  26199. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  26200. */
  26201. class GroundGeometry extends _PrimitiveGeometry {
  26202. /**
  26203. * Defines the width of the ground
  26204. */
  26205. width: number;
  26206. /**
  26207. * Defines the height of the ground
  26208. */
  26209. height: number;
  26210. /**
  26211. * Defines the subdivisions to apply to the ground
  26212. */
  26213. subdivisions: number;
  26214. /**
  26215. * Creates a new ground geometry
  26216. * @param id defines the unique ID of the geometry
  26217. * @param scene defines the hosting scene
  26218. * @param width defines the width of the ground
  26219. * @param height defines the height of the ground
  26220. * @param subdivisions defines the subdivisions to apply to the ground
  26221. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26222. * @param mesh defines the hosting mesh (can be null)
  26223. */
  26224. constructor(id: string, scene: Scene,
  26225. /**
  26226. * Defines the width of the ground
  26227. */
  26228. width: number,
  26229. /**
  26230. * Defines the height of the ground
  26231. */
  26232. height: number,
  26233. /**
  26234. * Defines the subdivisions to apply to the ground
  26235. */
  26236. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  26237. /** @hidden */
  26238. _regenerateVertexData(): VertexData;
  26239. copy(id: string): Geometry;
  26240. serialize(): any;
  26241. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  26242. }
  26243. /**
  26244. * Creates a tiled ground geometry
  26245. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  26246. */
  26247. class TiledGroundGeometry extends _PrimitiveGeometry {
  26248. /**
  26249. * Defines the minimum value on X axis
  26250. */
  26251. xmin: number;
  26252. /**
  26253. * Defines the minimum value on Z axis
  26254. */
  26255. zmin: number;
  26256. /**
  26257. * Defines the maximum value on X axis
  26258. */
  26259. xmax: number;
  26260. /**
  26261. * Defines the maximum value on Z axis
  26262. */
  26263. zmax: number;
  26264. /**
  26265. * Defines the subdivisions to apply to the ground
  26266. */
  26267. subdivisions: {
  26268. w: number;
  26269. h: number;
  26270. };
  26271. /**
  26272. * Defines the precision to use when computing the tiles
  26273. */
  26274. precision: {
  26275. w: number;
  26276. h: number;
  26277. };
  26278. /**
  26279. * Creates a tiled ground geometry
  26280. * @param id defines the unique ID of the geometry
  26281. * @param scene defines the hosting scene
  26282. * @param xmin defines the minimum value on X axis
  26283. * @param zmin defines the minimum value on Z axis
  26284. * @param xmax defines the maximum value on X axis
  26285. * @param zmax defines the maximum value on Z axis
  26286. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  26287. * @param precision defines the precision to use when computing the tiles
  26288. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26289. * @param mesh defines the hosting mesh (can be null)
  26290. */
  26291. constructor(id: string, scene: Scene,
  26292. /**
  26293. * Defines the minimum value on X axis
  26294. */
  26295. xmin: number,
  26296. /**
  26297. * Defines the minimum value on Z axis
  26298. */
  26299. zmin: number,
  26300. /**
  26301. * Defines the maximum value on X axis
  26302. */
  26303. xmax: number,
  26304. /**
  26305. * Defines the maximum value on Z axis
  26306. */
  26307. zmax: number,
  26308. /**
  26309. * Defines the subdivisions to apply to the ground
  26310. */
  26311. subdivisions: {
  26312. w: number;
  26313. h: number;
  26314. },
  26315. /**
  26316. * Defines the precision to use when computing the tiles
  26317. */
  26318. precision: {
  26319. w: number;
  26320. h: number;
  26321. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  26322. /** @hidden */
  26323. _regenerateVertexData(): VertexData;
  26324. copy(id: string): Geometry;
  26325. }
  26326. /**
  26327. * Creates a plane geometry
  26328. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  26329. */
  26330. class PlaneGeometry extends _PrimitiveGeometry {
  26331. /**
  26332. * Defines the size of the plane (width === height)
  26333. */
  26334. size: number;
  26335. /**
  26336. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26337. */
  26338. side: number;
  26339. /**
  26340. * Creates a plane geometry
  26341. * @param id defines the unique ID of the geometry
  26342. * @param scene defines the hosting scene
  26343. * @param size defines the size of the plane (width === height)
  26344. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26345. * @param mesh defines the hosting mesh (can be null)
  26346. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26347. */
  26348. constructor(id: string, scene: Scene,
  26349. /**
  26350. * Defines the size of the plane (width === height)
  26351. */
  26352. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26353. /**
  26354. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26355. */
  26356. side?: number);
  26357. /** @hidden */
  26358. _regenerateVertexData(): VertexData;
  26359. copy(id: string): Geometry;
  26360. serialize(): any;
  26361. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  26362. }
  26363. /**
  26364. * Creates a torus knot geometry
  26365. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  26366. */
  26367. class TorusKnotGeometry extends _PrimitiveGeometry {
  26368. /**
  26369. * Defines the radius of the torus knot
  26370. */
  26371. radius: number;
  26372. /**
  26373. * Defines the thickness of the torus knot tube
  26374. */
  26375. tube: number;
  26376. /**
  26377. * Defines the number of radial segments
  26378. */
  26379. radialSegments: number;
  26380. /**
  26381. * Defines the number of tubular segments
  26382. */
  26383. tubularSegments: number;
  26384. /**
  26385. * Defines the first number of windings
  26386. */
  26387. p: number;
  26388. /**
  26389. * Defines the second number of windings
  26390. */
  26391. q: number;
  26392. /**
  26393. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26394. */
  26395. side: number;
  26396. /**
  26397. * Creates a torus knot geometry
  26398. * @param id defines the unique ID of the geometry
  26399. * @param scene defines the hosting scene
  26400. * @param radius defines the radius of the torus knot
  26401. * @param tube defines the thickness of the torus knot tube
  26402. * @param radialSegments defines the number of radial segments
  26403. * @param tubularSegments defines the number of tubular segments
  26404. * @param p defines the first number of windings
  26405. * @param q defines the second number of windings
  26406. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26407. * @param mesh defines the hosting mesh (can be null)
  26408. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26409. */
  26410. constructor(id: string, scene: Scene,
  26411. /**
  26412. * Defines the radius of the torus knot
  26413. */
  26414. radius: number,
  26415. /**
  26416. * Defines the thickness of the torus knot tube
  26417. */
  26418. tube: number,
  26419. /**
  26420. * Defines the number of radial segments
  26421. */
  26422. radialSegments: number,
  26423. /**
  26424. * Defines the number of tubular segments
  26425. */
  26426. tubularSegments: number,
  26427. /**
  26428. * Defines the first number of windings
  26429. */
  26430. p: number,
  26431. /**
  26432. * Defines the second number of windings
  26433. */
  26434. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26435. /**
  26436. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26437. */
  26438. side?: number);
  26439. /** @hidden */
  26440. _regenerateVertexData(): VertexData;
  26441. copy(id: string): Geometry;
  26442. serialize(): any;
  26443. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  26444. }
  26445. }
  26446. declare module BABYLON {
  26447. /**
  26448. * Mesh representing the gorund
  26449. */
  26450. class GroundMesh extends Mesh {
  26451. /** If octree should be generated */
  26452. generateOctree: boolean;
  26453. private _heightQuads;
  26454. /** @hidden */
  26455. _subdivisionsX: number;
  26456. /** @hidden */
  26457. _subdivisionsY: number;
  26458. /** @hidden */
  26459. _width: number;
  26460. /** @hidden */
  26461. _height: number;
  26462. /** @hidden */
  26463. _minX: number;
  26464. /** @hidden */
  26465. _maxX: number;
  26466. /** @hidden */
  26467. _minZ: number;
  26468. /** @hidden */
  26469. _maxZ: number;
  26470. constructor(name: string, scene: Scene);
  26471. /**
  26472. * "GroundMesh"
  26473. * @returns "GroundMesh"
  26474. */
  26475. getClassName(): string;
  26476. /**
  26477. * The minimum of x and y subdivisions
  26478. */
  26479. readonly subdivisions: number;
  26480. /**
  26481. * X subdivisions
  26482. */
  26483. readonly subdivisionsX: number;
  26484. /**
  26485. * Y subdivisions
  26486. */
  26487. readonly subdivisionsY: number;
  26488. /**
  26489. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26490. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26491. * @param chunksCount the number of subdivisions for x and y
  26492. * @param octreeBlocksSize (Default: 32)
  26493. */
  26494. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26495. /**
  26496. * Returns a height (y) value in the Worl system :
  26497. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26498. * @param x x coordinate
  26499. * @param z z coordinate
  26500. * @returns the ground y position if (x, z) are outside the ground surface.
  26501. */
  26502. getHeightAtCoordinates(x: number, z: number): number;
  26503. /**
  26504. * Returns a normalized vector (Vector3) orthogonal to the ground
  26505. * at the ground coordinates (x, z) expressed in the World system.
  26506. * @param x x coordinate
  26507. * @param z z coordinate
  26508. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26509. */
  26510. getNormalAtCoordinates(x: number, z: number): Vector3;
  26511. /**
  26512. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26513. * at the ground coordinates (x, z) expressed in the World system.
  26514. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26515. * @param x x coordinate
  26516. * @param z z coordinate
  26517. * @param ref vector to store the result
  26518. * @returns the GroundMesh.
  26519. */
  26520. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26521. /**
  26522. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26523. * if the ground has been updated.
  26524. * This can be used in the render loop.
  26525. * @returns the GroundMesh.
  26526. */
  26527. updateCoordinateHeights(): GroundMesh;
  26528. private _getFacetAt;
  26529. private _initHeightQuads;
  26530. private _computeHeightQuads;
  26531. /**
  26532. * Serializes this ground mesh
  26533. * @param serializationObject object to write serialization to
  26534. */
  26535. serialize(serializationObject: any): void;
  26536. /**
  26537. * Parses a serialized ground mesh
  26538. * @param parsedMesh the serialized mesh
  26539. * @param scene the scene to create the ground mesh in
  26540. * @returns the created ground mesh
  26541. */
  26542. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26543. }
  26544. }
  26545. declare module BABYLON {
  26546. /**
  26547. * Creates an instance based on a source mesh.
  26548. */
  26549. class InstancedMesh extends AbstractMesh {
  26550. private _sourceMesh;
  26551. private _currentLOD;
  26552. /** @hidden */
  26553. _indexInSourceMeshInstanceArray: number;
  26554. constructor(name: string, source: Mesh);
  26555. /**
  26556. * Returns the string "InstancedMesh".
  26557. */
  26558. getClassName(): string;
  26559. /**
  26560. * If the source mesh receives shadows
  26561. */
  26562. readonly receiveShadows: boolean;
  26563. /**
  26564. * The material of the source mesh
  26565. */
  26566. readonly material: Nullable<Material>;
  26567. /**
  26568. * Visibility of the source mesh
  26569. */
  26570. readonly visibility: number;
  26571. /**
  26572. * Skeleton of the source mesh
  26573. */
  26574. readonly skeleton: Nullable<Skeleton>;
  26575. /**
  26576. * Rendering ground id of the source mesh
  26577. */
  26578. renderingGroupId: number;
  26579. /**
  26580. * Returns the total number of vertices (integer).
  26581. */
  26582. getTotalVertices(): number;
  26583. /**
  26584. * Returns a positive integer : the total number of indices in this mesh geometry.
  26585. * @returns the numner of indices or zero if the mesh has no geometry.
  26586. */
  26587. getTotalIndices(): number;
  26588. /**
  26589. * The source mesh of the instance
  26590. */
  26591. readonly sourceMesh: Mesh;
  26592. /**
  26593. * Is this node ready to be used/rendered
  26594. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26595. * @return {boolean} is it ready
  26596. */
  26597. isReady(completeCheck?: boolean): boolean;
  26598. /**
  26599. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26600. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26601. * @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.
  26602. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26603. */
  26604. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26605. /**
  26606. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26607. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26608. * The `data` are either a numeric array either a Float32Array.
  26609. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26610. * 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).
  26611. * Note that a new underlying VertexBuffer object is created each call.
  26612. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26613. *
  26614. * Possible `kind` values :
  26615. * - BABYLON.VertexBuffer.PositionKind
  26616. * - BABYLON.VertexBuffer.UVKind
  26617. * - BABYLON.VertexBuffer.UV2Kind
  26618. * - BABYLON.VertexBuffer.UV3Kind
  26619. * - BABYLON.VertexBuffer.UV4Kind
  26620. * - BABYLON.VertexBuffer.UV5Kind
  26621. * - BABYLON.VertexBuffer.UV6Kind
  26622. * - BABYLON.VertexBuffer.ColorKind
  26623. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26624. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26625. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26626. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26627. *
  26628. * Returns the Mesh.
  26629. */
  26630. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26631. /**
  26632. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26633. * If the mesh has no geometry, it is simply returned as it is.
  26634. * The `data` are either a numeric array either a Float32Array.
  26635. * No new underlying VertexBuffer object is created.
  26636. * 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.
  26637. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26638. *
  26639. * Possible `kind` values :
  26640. * - BABYLON.VertexBuffer.PositionKind
  26641. * - BABYLON.VertexBuffer.UVKind
  26642. * - BABYLON.VertexBuffer.UV2Kind
  26643. * - BABYLON.VertexBuffer.UV3Kind
  26644. * - BABYLON.VertexBuffer.UV4Kind
  26645. * - BABYLON.VertexBuffer.UV5Kind
  26646. * - BABYLON.VertexBuffer.UV6Kind
  26647. * - BABYLON.VertexBuffer.ColorKind
  26648. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26649. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26650. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26651. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26652. *
  26653. * Returns the Mesh.
  26654. */
  26655. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26656. /**
  26657. * Sets the mesh indices.
  26658. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26659. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26660. * This method creates a new index buffer each call.
  26661. * Returns the Mesh.
  26662. */
  26663. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26664. /**
  26665. * Boolean : True if the mesh owns the requested kind of data.
  26666. */
  26667. isVerticesDataPresent(kind: string): boolean;
  26668. /**
  26669. * Returns an array of indices (IndicesArray).
  26670. */
  26671. getIndices(): Nullable<IndicesArray>;
  26672. readonly _positions: Nullable<Vector3[]>;
  26673. /**
  26674. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26675. * This means the mesh underlying bounding box and sphere are recomputed.
  26676. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26677. * @returns the current mesh
  26678. */
  26679. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  26680. /** @hidden */
  26681. _preActivate(): InstancedMesh;
  26682. /** @hidden */
  26683. _activate(renderId: number): InstancedMesh;
  26684. /**
  26685. * Returns the current associated LOD AbstractMesh.
  26686. */
  26687. getLOD(camera: Camera): AbstractMesh;
  26688. /** @hidden */
  26689. _syncSubMeshes(): InstancedMesh;
  26690. /** @hidden */
  26691. _generatePointsArray(): boolean;
  26692. /**
  26693. * Creates a new InstancedMesh from the current mesh.
  26694. * - name (string) : the cloned mesh name
  26695. * - newParent (optional Node) : the optional Node to parent the clone to.
  26696. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26697. *
  26698. * Returns the clone.
  26699. */
  26700. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26701. /**
  26702. * Disposes the InstancedMesh.
  26703. * Returns nothing.
  26704. */
  26705. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26706. }
  26707. }
  26708. declare module BABYLON {
  26709. /**
  26710. * Line mesh
  26711. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26712. */
  26713. class LinesMesh extends Mesh {
  26714. /**
  26715. * If vertex color should be applied to the mesh
  26716. */
  26717. useVertexColor?: boolean | undefined;
  26718. /**
  26719. * If vertex alpha should be applied to the mesh
  26720. */
  26721. useVertexAlpha?: boolean | undefined;
  26722. /**
  26723. * Color of the line (Default: White)
  26724. */
  26725. color: Color3;
  26726. /**
  26727. * Alpha of the line (Default: 1)
  26728. */
  26729. alpha: number;
  26730. /**
  26731. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26732. * This margin is expressed in world space coordinates, so its value may vary.
  26733. * Default value is 0.1
  26734. */
  26735. intersectionThreshold: number;
  26736. private _colorShader;
  26737. /**
  26738. * Creates a new LinesMesh
  26739. * @param name defines the name
  26740. * @param scene defines the hosting scene
  26741. * @param parent defines the parent mesh if any
  26742. * @param source defines the optional source LinesMesh used to clone data from
  26743. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26744. * When false, achieved by calling a clone(), also passing False.
  26745. * This will make creation of children, recursive.
  26746. * @param useVertexColor defines if this LinesMesh supports vertex color
  26747. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26748. */
  26749. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26750. /**
  26751. * If vertex color should be applied to the mesh
  26752. */
  26753. useVertexColor?: boolean | undefined,
  26754. /**
  26755. * If vertex alpha should be applied to the mesh
  26756. */
  26757. useVertexAlpha?: boolean | undefined);
  26758. /**
  26759. * Returns the string "LineMesh"
  26760. */
  26761. getClassName(): string;
  26762. /**
  26763. * @hidden
  26764. */
  26765. /**
  26766. * @hidden
  26767. */
  26768. material: Material;
  26769. /**
  26770. * @hidden
  26771. */
  26772. readonly checkCollisions: boolean;
  26773. /** @hidden */
  26774. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26775. /** @hidden */
  26776. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26777. /**
  26778. * Disposes of the line mesh
  26779. * @param doNotRecurse If children should be disposed
  26780. */
  26781. dispose(doNotRecurse?: boolean): void;
  26782. /**
  26783. * Returns a new LineMesh object cloned from the current one.
  26784. */
  26785. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26786. /**
  26787. * Creates a new InstancedLinesMesh object from the mesh model.
  26788. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26789. * @param name defines the name of the new instance
  26790. * @returns a new InstancedLinesMesh
  26791. */
  26792. createInstance(name: string): InstancedLinesMesh;
  26793. }
  26794. /**
  26795. * Creates an instance based on a source LinesMesh
  26796. */
  26797. class InstancedLinesMesh extends InstancedMesh {
  26798. /**
  26799. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26800. * This margin is expressed in world space coordinates, so its value may vary.
  26801. * Initilized with the intersectionThreshold value of the source LinesMesh
  26802. */
  26803. intersectionThreshold: number;
  26804. constructor(name: string, source: LinesMesh);
  26805. /**
  26806. * Returns the string "InstancedLinesMesh".
  26807. */
  26808. getClassName(): string;
  26809. }
  26810. }
  26811. declare module BABYLON {
  26812. /**
  26813. * @hidden
  26814. **/
  26815. class _CreationDataStorage {
  26816. closePath?: boolean;
  26817. closeArray?: boolean;
  26818. idx: number[];
  26819. dashSize: number;
  26820. gapSize: number;
  26821. path3D: Path3D;
  26822. pathArray: Vector3[][];
  26823. arc: number;
  26824. radius: number;
  26825. cap: number;
  26826. tessellation: number;
  26827. }
  26828. /**
  26829. * @hidden
  26830. **/
  26831. class _InstanceDataStorage {
  26832. visibleInstances: any;
  26833. renderIdForInstances: number[];
  26834. batchCache: _InstancesBatch;
  26835. instancesBufferSize: number;
  26836. instancesBuffer: Nullable<Buffer>;
  26837. instancesData: Float32Array;
  26838. overridenInstanceCount: number;
  26839. }
  26840. /**
  26841. * @hidden
  26842. **/
  26843. class _InstancesBatch {
  26844. mustReturn: boolean;
  26845. visibleInstances: Nullable<InstancedMesh[]>[];
  26846. renderSelf: boolean[];
  26847. }
  26848. /**
  26849. * Class used to represent renderable models
  26850. */
  26851. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26852. /**
  26853. * Mesh side orientation : usually the external or front surface
  26854. */
  26855. static readonly FRONTSIDE: number;
  26856. /**
  26857. * Mesh side orientation : usually the internal or back surface
  26858. */
  26859. static readonly BACKSIDE: number;
  26860. /**
  26861. * Mesh side orientation : both internal and external or front and back surfaces
  26862. */
  26863. static readonly DOUBLESIDE: number;
  26864. /**
  26865. * Mesh side orientation : by default, `FRONTSIDE`
  26866. */
  26867. static readonly DEFAULTSIDE: number;
  26868. /**
  26869. * Mesh cap setting : no cap
  26870. */
  26871. static readonly NO_CAP: number;
  26872. /**
  26873. * Mesh cap setting : one cap at the beginning of the mesh
  26874. */
  26875. static readonly CAP_START: number;
  26876. /**
  26877. * Mesh cap setting : one cap at the end of the mesh
  26878. */
  26879. static readonly CAP_END: number;
  26880. /**
  26881. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26882. */
  26883. static readonly CAP_ALL: number;
  26884. private _onBeforeRenderObservable;
  26885. private _onAfterRenderObservable;
  26886. private _onBeforeDrawObservable;
  26887. /**
  26888. * An event triggered before rendering the mesh
  26889. */
  26890. readonly onBeforeRenderObservable: Observable<Mesh>;
  26891. /**
  26892. * An event triggered after rendering the mesh
  26893. */
  26894. readonly onAfterRenderObservable: Observable<Mesh>;
  26895. /**
  26896. * An event triggered before drawing the mesh
  26897. */
  26898. readonly onBeforeDrawObservable: Observable<Mesh>;
  26899. private _onBeforeDrawObserver;
  26900. /**
  26901. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26902. */
  26903. onBeforeDraw: () => void;
  26904. /**
  26905. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26906. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26907. */
  26908. delayLoadState: number;
  26909. /**
  26910. * Gets the list of instances created from this mesh
  26911. * it is not supposed to be modified manually.
  26912. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26913. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26914. */
  26915. instances: InstancedMesh[];
  26916. /**
  26917. * Gets the file containing delay loading data for this mesh
  26918. */
  26919. delayLoadingFile: string;
  26920. /** @hidden */
  26921. _binaryInfo: any;
  26922. private _LODLevels;
  26923. /**
  26924. * User defined function used to change how LOD level selection is done
  26925. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26926. */
  26927. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26928. private _morphTargetManager;
  26929. /**
  26930. * Gets or sets the morph target manager
  26931. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26932. */
  26933. morphTargetManager: Nullable<MorphTargetManager>;
  26934. /** @hidden */
  26935. _creationDataStorage: Nullable<_CreationDataStorage>;
  26936. /** @hidden */
  26937. _geometry: Nullable<Geometry>;
  26938. /** @hidden */
  26939. _delayInfo: Array<string>;
  26940. /** @hidden */
  26941. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26942. /** @hidden */
  26943. _instanceDataStorage: _InstanceDataStorage;
  26944. private _effectiveMaterial;
  26945. /** @hidden */
  26946. _shouldGenerateFlatShading: boolean;
  26947. private _preActivateId;
  26948. /** @hidden */
  26949. _originalBuilderSideOrientation: number;
  26950. /**
  26951. * Use this property to change the original side orientation defined at construction time
  26952. */
  26953. overrideMaterialSideOrientation: Nullable<number>;
  26954. private _areNormalsFrozen;
  26955. private _sourcePositions;
  26956. private _sourceNormals;
  26957. private _source;
  26958. private meshMap;
  26959. /**
  26960. * Gets the source mesh (the one used to clone this one from)
  26961. */
  26962. readonly source: Nullable<Mesh>;
  26963. /**
  26964. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26965. */
  26966. isUnIndexed: boolean;
  26967. /**
  26968. * @constructor
  26969. * @param name The value used by scene.getMeshByName() to do a lookup.
  26970. * @param scene The scene to add this mesh to.
  26971. * @param parent The parent of this mesh, if it has one
  26972. * @param source An optional Mesh from which geometry is shared, cloned.
  26973. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26974. * When false, achieved by calling a clone(), also passing False.
  26975. * This will make creation of children, recursive.
  26976. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26977. */
  26978. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26979. /**
  26980. * Gets the class name
  26981. * @returns the string "Mesh".
  26982. */
  26983. getClassName(): string;
  26984. /**
  26985. * Returns a description of this mesh
  26986. * @param fullDetails define if full details about this mesh must be used
  26987. * @returns a descriptive string representing this mesh
  26988. */
  26989. toString(fullDetails?: boolean): string;
  26990. /** @hidden */
  26991. _unBindEffect(): void;
  26992. /**
  26993. * Gets a boolean indicating if this mesh has LOD
  26994. */
  26995. readonly hasLODLevels: boolean;
  26996. /**
  26997. * Gets the list of MeshLODLevel associated with the current mesh
  26998. * @returns an array of MeshLODLevel
  26999. */
  27000. getLODLevels(): MeshLODLevel[];
  27001. private _sortLODLevels;
  27002. /**
  27003. * Add a mesh as LOD level triggered at the given distance.
  27004. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27005. * @param distance The distance from the center of the object to show this level
  27006. * @param mesh The mesh to be added as LOD level (can be null)
  27007. * @return This mesh (for chaining)
  27008. */
  27009. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27010. /**
  27011. * Returns the LOD level mesh at the passed distance or null if not found.
  27012. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27013. * @param distance The distance from the center of the object to show this level
  27014. * @returns a Mesh or `null`
  27015. */
  27016. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27017. /**
  27018. * Remove a mesh from the LOD array
  27019. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27020. * @param mesh defines the mesh to be removed
  27021. * @return This mesh (for chaining)
  27022. */
  27023. removeLODLevel(mesh: Mesh): Mesh;
  27024. /**
  27025. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27026. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27027. * @param camera defines the camera to use to compute distance
  27028. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27029. * @return This mesh (for chaining)
  27030. */
  27031. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27032. /**
  27033. * Gets the mesh internal Geometry object
  27034. */
  27035. readonly geometry: Nullable<Geometry>;
  27036. /**
  27037. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27038. * @returns the total number of vertices
  27039. */
  27040. getTotalVertices(): number;
  27041. /**
  27042. * Returns the content of an associated vertex buffer
  27043. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27044. * - BABYLON.VertexBuffer.PositionKind
  27045. * - BABYLON.VertexBuffer.UVKind
  27046. * - BABYLON.VertexBuffer.UV2Kind
  27047. * - BABYLON.VertexBuffer.UV3Kind
  27048. * - BABYLON.VertexBuffer.UV4Kind
  27049. * - BABYLON.VertexBuffer.UV5Kind
  27050. * - BABYLON.VertexBuffer.UV6Kind
  27051. * - BABYLON.VertexBuffer.ColorKind
  27052. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27053. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27054. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27055. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27056. * @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
  27057. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27058. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27059. */
  27060. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27061. /**
  27062. * Returns the mesh VertexBuffer object from the requested `kind`
  27063. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27064. * - BABYLON.VertexBuffer.PositionKind
  27065. * - BABYLON.VertexBuffer.UVKind
  27066. * - BABYLON.VertexBuffer.UV2Kind
  27067. * - BABYLON.VertexBuffer.UV3Kind
  27068. * - BABYLON.VertexBuffer.UV4Kind
  27069. * - BABYLON.VertexBuffer.UV5Kind
  27070. * - BABYLON.VertexBuffer.UV6Kind
  27071. * - BABYLON.VertexBuffer.ColorKind
  27072. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27073. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27074. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27075. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27076. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27077. */
  27078. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27079. /**
  27080. * Tests if a specific vertex buffer is associated with this mesh
  27081. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27082. * - BABYLON.VertexBuffer.PositionKind
  27083. * - BABYLON.VertexBuffer.UVKind
  27084. * - BABYLON.VertexBuffer.UV2Kind
  27085. * - BABYLON.VertexBuffer.UV3Kind
  27086. * - BABYLON.VertexBuffer.UV4Kind
  27087. * - BABYLON.VertexBuffer.UV5Kind
  27088. * - BABYLON.VertexBuffer.UV6Kind
  27089. * - BABYLON.VertexBuffer.ColorKind
  27090. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27091. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27092. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27093. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27094. * @returns a boolean
  27095. */
  27096. isVerticesDataPresent(kind: string): boolean;
  27097. /**
  27098. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27099. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27100. * - BABYLON.VertexBuffer.PositionKind
  27101. * - BABYLON.VertexBuffer.UVKind
  27102. * - BABYLON.VertexBuffer.UV2Kind
  27103. * - BABYLON.VertexBuffer.UV3Kind
  27104. * - BABYLON.VertexBuffer.UV4Kind
  27105. * - BABYLON.VertexBuffer.UV5Kind
  27106. * - BABYLON.VertexBuffer.UV6Kind
  27107. * - BABYLON.VertexBuffer.ColorKind
  27108. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27109. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27110. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27111. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27112. * @returns a boolean
  27113. */
  27114. isVertexBufferUpdatable(kind: string): boolean;
  27115. /**
  27116. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27117. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27118. * - BABYLON.VertexBuffer.PositionKind
  27119. * - BABYLON.VertexBuffer.UVKind
  27120. * - BABYLON.VertexBuffer.UV2Kind
  27121. * - BABYLON.VertexBuffer.UV3Kind
  27122. * - BABYLON.VertexBuffer.UV4Kind
  27123. * - BABYLON.VertexBuffer.UV5Kind
  27124. * - BABYLON.VertexBuffer.UV6Kind
  27125. * - BABYLON.VertexBuffer.ColorKind
  27126. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27127. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27128. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27129. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27130. * @returns an array of strings
  27131. */
  27132. getVerticesDataKinds(): string[];
  27133. /**
  27134. * Returns a positive integer : the total number of indices in this mesh geometry.
  27135. * @returns the numner of indices or zero if the mesh has no geometry.
  27136. */
  27137. getTotalIndices(): number;
  27138. /**
  27139. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27140. * @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.
  27141. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27142. * @returns the indices array or an empty array if the mesh has no geometry
  27143. */
  27144. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27145. readonly isBlocked: boolean;
  27146. /**
  27147. * Determine if the current mesh is ready to be rendered
  27148. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27149. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27150. * @returns true if all associated assets are ready (material, textures, shaders)
  27151. */
  27152. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27153. /**
  27154. * 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.
  27155. */
  27156. readonly areNormalsFrozen: boolean;
  27157. /**
  27158. * 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.
  27159. * @returns the current mesh
  27160. */
  27161. freezeNormals(): Mesh;
  27162. /**
  27163. * 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
  27164. * @returns the current mesh
  27165. */
  27166. unfreezeNormals(): Mesh;
  27167. /**
  27168. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27169. */
  27170. overridenInstanceCount: number;
  27171. /** @hidden */
  27172. _preActivate(): Mesh;
  27173. /** @hidden */
  27174. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27175. /** @hidden */
  27176. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27177. /**
  27178. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27179. * This means the mesh underlying bounding box and sphere are recomputed.
  27180. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27181. * @returns the current mesh
  27182. */
  27183. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27184. /** @hidden */
  27185. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27186. /**
  27187. * This function will subdivide the mesh into multiple submeshes
  27188. * @param count defines the expected number of submeshes
  27189. */
  27190. subdivide(count: number): void;
  27191. /**
  27192. * Copy a FloatArray into a specific associated vertex buffer
  27193. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27194. * - BABYLON.VertexBuffer.PositionKind
  27195. * - BABYLON.VertexBuffer.UVKind
  27196. * - BABYLON.VertexBuffer.UV2Kind
  27197. * - BABYLON.VertexBuffer.UV3Kind
  27198. * - BABYLON.VertexBuffer.UV4Kind
  27199. * - BABYLON.VertexBuffer.UV5Kind
  27200. * - BABYLON.VertexBuffer.UV6Kind
  27201. * - BABYLON.VertexBuffer.ColorKind
  27202. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27203. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27204. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27205. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27206. * @param data defines the data source
  27207. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27208. * @param stride defines the data stride size (can be null)
  27209. * @returns the current mesh
  27210. */
  27211. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  27212. /**
  27213. * Flags an associated vertex buffer as updatable
  27214. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27215. * - BABYLON.VertexBuffer.PositionKind
  27216. * - BABYLON.VertexBuffer.UVKind
  27217. * - BABYLON.VertexBuffer.UV2Kind
  27218. * - BABYLON.VertexBuffer.UV3Kind
  27219. * - BABYLON.VertexBuffer.UV4Kind
  27220. * - BABYLON.VertexBuffer.UV5Kind
  27221. * - BABYLON.VertexBuffer.UV6Kind
  27222. * - BABYLON.VertexBuffer.ColorKind
  27223. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27224. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27225. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27226. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27227. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27228. */
  27229. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27230. /**
  27231. * Sets the mesh global Vertex Buffer
  27232. * @param buffer defines the buffer to use
  27233. * @returns the current mesh
  27234. */
  27235. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27236. /**
  27237. * Update a specific associated vertex buffer
  27238. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27239. * - BABYLON.VertexBuffer.PositionKind
  27240. * - BABYLON.VertexBuffer.UVKind
  27241. * - BABYLON.VertexBuffer.UV2Kind
  27242. * - BABYLON.VertexBuffer.UV3Kind
  27243. * - BABYLON.VertexBuffer.UV4Kind
  27244. * - BABYLON.VertexBuffer.UV5Kind
  27245. * - BABYLON.VertexBuffer.UV6Kind
  27246. * - BABYLON.VertexBuffer.ColorKind
  27247. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27248. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27249. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27250. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27251. * @param data defines the data source
  27252. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27253. * @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)
  27254. * @returns the current mesh
  27255. */
  27256. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  27257. /**
  27258. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27259. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27260. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27261. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27262. * @returns the current mesh
  27263. */
  27264. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27265. /**
  27266. * Creates a un-shared specific occurence of the geometry for the mesh.
  27267. * @returns the current mesh
  27268. */
  27269. makeGeometryUnique(): Mesh;
  27270. /**
  27271. * Set the index buffer of this mesh
  27272. * @param indices defines the source data
  27273. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27274. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27275. * @returns the current mesh
  27276. */
  27277. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  27278. /**
  27279. * Update the current index buffer
  27280. * @param indices defines the source data
  27281. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27282. * @returns the current mesh
  27283. */
  27284. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  27285. /**
  27286. * Invert the geometry to move from a right handed system to a left handed one.
  27287. * @returns the current mesh
  27288. */
  27289. toLeftHanded(): Mesh;
  27290. /** @hidden */
  27291. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27292. /** @hidden */
  27293. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  27294. /**
  27295. * Registers for this mesh a javascript function called just before the rendering process
  27296. * @param func defines the function to call before rendering this mesh
  27297. * @returns the current mesh
  27298. */
  27299. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27300. /**
  27301. * Disposes a previously registered javascript function called before the rendering
  27302. * @param func defines the function to remove
  27303. * @returns the current mesh
  27304. */
  27305. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27306. /**
  27307. * Registers for this mesh a javascript function called just after the rendering is complete
  27308. * @param func defines the function to call after rendering this mesh
  27309. * @returns the current mesh
  27310. */
  27311. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27312. /**
  27313. * Disposes a previously registered javascript function called after the rendering.
  27314. * @param func defines the function to remove
  27315. * @returns the current mesh
  27316. */
  27317. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27318. /** @hidden */
  27319. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  27320. /** @hidden */
  27321. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27322. /** @hidden */
  27323. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27324. /**
  27325. * 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
  27326. * @param subMesh defines the subMesh to render
  27327. * @param enableAlphaMode defines if alpha mode can be changed
  27328. * @returns the current mesh
  27329. */
  27330. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  27331. private _onBeforeDraw;
  27332. /**
  27333. * Renormalize the mesh and patch it up if there are no weights
  27334. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27335. * However in the case of zero weights then we set just a single influence to 1.
  27336. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27337. */
  27338. cleanMatrixWeights(): void;
  27339. private normalizeSkinFourWeights;
  27340. private normalizeSkinWeightsAndExtra;
  27341. /**
  27342. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27343. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27344. * the user know there was an issue with importing the mesh
  27345. * @returns a validation object with skinned, valid and report string
  27346. */
  27347. validateSkinning(): {
  27348. skinned: boolean;
  27349. valid: boolean;
  27350. report: string;
  27351. };
  27352. /** @hidden */
  27353. _checkDelayState(): Mesh;
  27354. private _queueLoad;
  27355. /**
  27356. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27357. * A mesh is in the frustum if its bounding box intersects the frustum
  27358. * @param frustumPlanes defines the frustum to test
  27359. * @returns true if the mesh is in the frustum planes
  27360. */
  27361. isInFrustum(frustumPlanes: Plane[]): boolean;
  27362. /**
  27363. * Sets the mesh material by the material or multiMaterial `id` property
  27364. * @param id is a string identifying the material or the multiMaterial
  27365. * @returns the current mesh
  27366. */
  27367. setMaterialByID(id: string): Mesh;
  27368. /**
  27369. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27370. * @returns an array of IAnimatable
  27371. */
  27372. getAnimatables(): IAnimatable[];
  27373. /**
  27374. * Modifies the mesh geometry according to the passed transformation matrix.
  27375. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27376. * The mesh normals are modified using the same transformation.
  27377. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27378. * @param transform defines the transform matrix to use
  27379. * @see http://doc.babylonjs.com/resources/baking_transformations
  27380. * @returns the current mesh
  27381. */
  27382. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27383. /**
  27384. * Modifies the mesh geometry according to its own current World Matrix.
  27385. * The mesh World Matrix is then reset.
  27386. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27387. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27388. * @see http://doc.babylonjs.com/resources/baking_transformations
  27389. * @returns the current mesh
  27390. */
  27391. bakeCurrentTransformIntoVertices(): Mesh;
  27392. /** @hidden */
  27393. readonly _positions: Nullable<Vector3[]>;
  27394. /** @hidden */
  27395. _resetPointsArrayCache(): Mesh;
  27396. /** @hidden */
  27397. _generatePointsArray(): boolean;
  27398. /**
  27399. * Returns a new Mesh object generated from the current mesh properties.
  27400. * This method must not get confused with createInstance()
  27401. * @param name is a string, the name given to the new mesh
  27402. * @param newParent can be any Node object (default `null`)
  27403. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27404. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27405. * @returns a new mesh
  27406. */
  27407. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27408. /**
  27409. * Releases resources associated with this mesh.
  27410. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27411. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27412. */
  27413. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27414. /**
  27415. * Modifies the mesh geometry according to a displacement map.
  27416. * 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.
  27417. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27418. * @param url is a string, the URL from the image file is to be downloaded.
  27419. * @param minHeight is the lower limit of the displacement.
  27420. * @param maxHeight is the upper limit of the displacement.
  27421. * @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.
  27422. * @param uvOffset is an optional vector2 used to offset UV.
  27423. * @param uvScale is an optional vector2 used to scale UV.
  27424. * @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.
  27425. * @returns the Mesh.
  27426. */
  27427. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27428. /**
  27429. * Modifies the mesh geometry according to a displacementMap buffer.
  27430. * 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.
  27431. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27432. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27433. * @param heightMapWidth is the width of the buffer image.
  27434. * @param heightMapHeight is the height of the buffer image.
  27435. * @param minHeight is the lower limit of the displacement.
  27436. * @param maxHeight is the upper limit of the displacement.
  27437. * @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.
  27438. * @param uvOffset is an optional vector2 used to offset UV.
  27439. * @param uvScale is an optional vector2 used to scale UV.
  27440. * @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.
  27441. * @returns the Mesh.
  27442. */
  27443. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27444. /**
  27445. * Modify the mesh to get a flat shading rendering.
  27446. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27447. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27448. * @returns current mesh
  27449. */
  27450. convertToFlatShadedMesh(): Mesh;
  27451. /**
  27452. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27453. * In other words, more vertices, no more indices and a single bigger VBO.
  27454. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27455. * @returns current mesh
  27456. */
  27457. convertToUnIndexedMesh(): Mesh;
  27458. /**
  27459. * Inverses facet orientations.
  27460. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27461. * @param flipNormals will also inverts the normals
  27462. * @returns current mesh
  27463. */
  27464. flipFaces(flipNormals?: boolean): Mesh;
  27465. /**
  27466. * Creates a new InstancedMesh object from the mesh model.
  27467. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27468. * @param name defines the name of the new instance
  27469. * @returns a new InstancedMesh
  27470. */
  27471. createInstance(name: string): InstancedMesh;
  27472. /**
  27473. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27474. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27475. * @returns the current mesh
  27476. */
  27477. synchronizeInstances(): Mesh;
  27478. /**
  27479. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27480. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27481. * This should be used together with the simplification to avoid disappearing triangles.
  27482. * @param successCallback an optional success callback to be called after the optimization finished.
  27483. * @returns the current mesh
  27484. */
  27485. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27486. /**
  27487. * Serialize current mesh
  27488. * @param serializationObject defines the object which will receive the serialization data
  27489. */
  27490. serialize(serializationObject: any): void;
  27491. /** @hidden */
  27492. _syncGeometryWithMorphTargetManager(): void;
  27493. /**
  27494. * Returns a new Mesh object parsed from the source provided.
  27495. * @param parsedMesh is the source
  27496. * @param scene defines the hosting scene
  27497. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27498. * @returns a new Mesh
  27499. */
  27500. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27501. /**
  27502. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27503. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27504. * @param name defines the name of the mesh to create
  27505. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27506. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27507. * @param closePath creates a seam between the first and the last points of each path of the path array
  27508. * @param offset is taken in account only if the `pathArray` is containing a single path
  27509. * @param scene defines the hosting scene
  27510. * @param updatable defines if the mesh must be flagged as updatable
  27511. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27512. * @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)
  27513. * @returns a new Mesh
  27514. */
  27515. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27516. /**
  27517. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27518. * @param name defines the name of the mesh to create
  27519. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27520. * @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
  27521. * @param scene defines the hosting scene
  27522. * @param updatable defines if the mesh must be flagged as updatable
  27523. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27524. * @returns a new Mesh
  27525. */
  27526. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27527. /**
  27528. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27529. * @param name defines the name of the mesh to create
  27530. * @param size sets the size (float) of each box side (default 1)
  27531. * @param scene defines the hosting scene
  27532. * @param updatable defines if the mesh must be flagged as updatable
  27533. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27534. * @returns a new Mesh
  27535. */
  27536. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27537. /**
  27538. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27539. * @param name defines the name of the mesh to create
  27540. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27541. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27542. * @param scene defines the hosting scene
  27543. * @param updatable defines if the mesh must be flagged as updatable
  27544. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27545. * @returns a new Mesh
  27546. */
  27547. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27548. /**
  27549. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27550. * @param name defines the name of the mesh to create
  27551. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27552. * @param diameterTop set the top cap diameter (floats, default 1)
  27553. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27554. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27555. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27556. * @param scene defines the hosting scene
  27557. * @param updatable defines if the mesh must be flagged as updatable
  27558. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27559. * @returns a new Mesh
  27560. */
  27561. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27562. /**
  27563. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27564. * @param name defines the name of the mesh to create
  27565. * @param diameter sets the diameter size (float) of the torus (default 1)
  27566. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27567. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27568. * @param scene defines the hosting scene
  27569. * @param updatable defines if the mesh must be flagged as updatable
  27570. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27571. * @returns a new Mesh
  27572. */
  27573. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27574. /**
  27575. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27576. * @param name defines the name of the mesh to create
  27577. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27578. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27579. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27580. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27581. * @param p the number of windings on X axis (positive integers, default 2)
  27582. * @param q the number of windings on Y axis (positive integers, default 3)
  27583. * @param scene defines the hosting scene
  27584. * @param updatable defines if the mesh must be flagged as updatable
  27585. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27586. * @returns a new Mesh
  27587. */
  27588. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27589. /**
  27590. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27591. * @param name defines the name of the mesh to create
  27592. * @param points is an array successive Vector3
  27593. * @param scene defines the hosting scene
  27594. * @param updatable defines if the mesh must be flagged as updatable
  27595. * @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).
  27596. * @returns a new Mesh
  27597. */
  27598. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27599. /**
  27600. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27601. * @param name defines the name of the mesh to create
  27602. * @param points is an array successive Vector3
  27603. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27604. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27605. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27606. * @param scene defines the hosting scene
  27607. * @param updatable defines if the mesh must be flagged as updatable
  27608. * @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)
  27609. * @returns a new Mesh
  27610. */
  27611. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27612. /**
  27613. * Creates a polygon mesh.
  27614. * Please consider using the same method from the MeshBuilder class instead.
  27615. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27616. * 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.
  27617. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27618. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27619. * Remember you can only change the shape positions, not their number when updating a polygon.
  27620. */
  27621. /**
  27622. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27623. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27624. * @param name defines the name of the mesh to create
  27625. * @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
  27626. * @param scene defines the hosting scene
  27627. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27628. * @param updatable defines if the mesh must be flagged as updatable
  27629. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27630. * @returns a new Mesh
  27631. */
  27632. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27633. /**
  27634. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27635. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27636. * @param name defines the name of the mesh to create
  27637. * @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
  27638. * @param depth defines the height of extrusion
  27639. * @param scene defines the hosting scene
  27640. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27641. * @param updatable defines if the mesh must be flagged as updatable
  27642. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27643. * @returns a new Mesh
  27644. */
  27645. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27646. /**
  27647. * Creates an extruded shape mesh.
  27648. * 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
  27649. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27650. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27651. * @param name defines the name of the mesh to create
  27652. * @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
  27653. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27654. * @param scale is the value to scale the shape
  27655. * @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
  27656. * @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
  27657. * @param scene defines the hosting scene
  27658. * @param updatable defines if the mesh must be flagged as updatable
  27659. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27660. * @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)
  27661. * @returns a new Mesh
  27662. */
  27663. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27664. /**
  27665. * Creates an custom extruded shape mesh.
  27666. * The custom extrusion is a parametric shape.
  27667. * It has no predefined shape. Its final shape will depend on the input parameters.
  27668. * Please consider using the same method from the MeshBuilder class instead
  27669. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27670. * @param name defines the name of the mesh to create
  27671. * @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
  27672. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27673. * @param scaleFunction is a custom Javascript function called on each path point
  27674. * @param rotationFunction is a custom Javascript function called on each path point
  27675. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27676. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27677. * @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
  27678. * @param scene defines the hosting scene
  27679. * @param updatable defines if the mesh must be flagged as updatable
  27680. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27681. * @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)
  27682. * @returns a new Mesh
  27683. */
  27684. 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;
  27685. /**
  27686. * Creates lathe mesh.
  27687. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27688. * Please consider using the same method from the MeshBuilder class instead
  27689. * @param name defines the name of the mesh to create
  27690. * @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
  27691. * @param radius is the radius value of the lathe
  27692. * @param tessellation is the side number of the lathe.
  27693. * @param scene defines the hosting scene
  27694. * @param updatable defines if the mesh must be flagged as updatable
  27695. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27696. * @returns a new Mesh
  27697. */
  27698. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27699. /**
  27700. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27701. * @param name defines the name of the mesh to create
  27702. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27703. * @param scene defines the hosting scene
  27704. * @param updatable defines if the mesh must be flagged as updatable
  27705. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27706. * @returns a new Mesh
  27707. */
  27708. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27709. /**
  27710. * Creates a ground mesh.
  27711. * Please consider using the same method from the MeshBuilder class instead
  27712. * @param name defines the name of the mesh to create
  27713. * @param width set the width of the ground
  27714. * @param height set the height of the ground
  27715. * @param subdivisions sets the number of subdivisions per side
  27716. * @param scene defines the hosting scene
  27717. * @param updatable defines if the mesh must be flagged as updatable
  27718. * @returns a new Mesh
  27719. */
  27720. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27721. /**
  27722. * Creates a tiled ground mesh.
  27723. * Please consider using the same method from the MeshBuilder class instead
  27724. * @param name defines the name of the mesh to create
  27725. * @param xmin set the ground minimum X coordinate
  27726. * @param zmin set the ground minimum Y coordinate
  27727. * @param xmax set the ground maximum X coordinate
  27728. * @param zmax set the ground maximum Z coordinate
  27729. * @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
  27730. * @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
  27731. * @param scene defines the hosting scene
  27732. * @param updatable defines if the mesh must be flagged as updatable
  27733. * @returns a new Mesh
  27734. */
  27735. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27736. w: number;
  27737. h: number;
  27738. }, precision: {
  27739. w: number;
  27740. h: number;
  27741. }, scene: Scene, updatable?: boolean): Mesh;
  27742. /**
  27743. * Creates a ground mesh from a height map.
  27744. * Please consider using the same method from the MeshBuilder class instead
  27745. * @see http://doc.babylonjs.com/babylon101/height_map
  27746. * @param name defines the name of the mesh to create
  27747. * @param url sets the URL of the height map image resource
  27748. * @param width set the ground width size
  27749. * @param height set the ground height size
  27750. * @param subdivisions sets the number of subdivision per side
  27751. * @param minHeight is the minimum altitude on the ground
  27752. * @param maxHeight is the maximum altitude on the ground
  27753. * @param scene defines the hosting scene
  27754. * @param updatable defines if the mesh must be flagged as updatable
  27755. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27756. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27757. * @returns a new Mesh
  27758. */
  27759. 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;
  27760. /**
  27761. * Creates a tube mesh.
  27762. * The tube is a parametric shape.
  27763. * It has no predefined shape. Its final shape will depend on the input parameters.
  27764. * Please consider using the same method from the MeshBuilder class instead
  27765. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27766. * @param name defines the name of the mesh to create
  27767. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27768. * @param radius sets the tube radius size
  27769. * @param tessellation is the number of sides on the tubular surface
  27770. * @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
  27771. * @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
  27772. * @param scene defines the hosting scene
  27773. * @param updatable defines if the mesh must be flagged as updatable
  27774. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27775. * @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)
  27776. * @returns a new Mesh
  27777. */
  27778. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27779. (i: number, distance: number): number;
  27780. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27781. /**
  27782. * Creates a polyhedron mesh.
  27783. * Please consider using the same method from the MeshBuilder class instead.
  27784. * * 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
  27785. * * The parameter `size` (positive float, default 1) sets the polygon size
  27786. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27787. * * 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`
  27788. * * 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
  27789. * * 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)`)
  27790. * * 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
  27791. * * 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
  27792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27793. * * 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
  27794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27795. * @param name defines the name of the mesh to create
  27796. * @param options defines the options used to create the mesh
  27797. * @param scene defines the hosting scene
  27798. * @returns a new Mesh
  27799. */
  27800. static CreatePolyhedron(name: string, options: {
  27801. type?: number;
  27802. size?: number;
  27803. sizeX?: number;
  27804. sizeY?: number;
  27805. sizeZ?: number;
  27806. custom?: any;
  27807. faceUV?: Vector4[];
  27808. faceColors?: Color4[];
  27809. updatable?: boolean;
  27810. sideOrientation?: number;
  27811. }, scene: Scene): Mesh;
  27812. /**
  27813. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27814. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27815. * * 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`)
  27816. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27817. * * 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
  27818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27819. * * 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
  27820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27821. * @param name defines the name of the mesh
  27822. * @param options defines the options used to create the mesh
  27823. * @param scene defines the hosting scene
  27824. * @returns a new Mesh
  27825. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27826. */
  27827. static CreateIcoSphere(name: string, options: {
  27828. radius?: number;
  27829. flat?: boolean;
  27830. subdivisions?: number;
  27831. sideOrientation?: number;
  27832. updatable?: boolean;
  27833. }, scene: Scene): Mesh;
  27834. /**
  27835. * Creates a decal mesh.
  27836. * Please consider using the same method from the MeshBuilder class instead.
  27837. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27838. * @param name defines the name of the mesh
  27839. * @param sourceMesh defines the mesh receiving the decal
  27840. * @param position sets the position of the decal in world coordinates
  27841. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27842. * @param size sets the decal scaling
  27843. * @param angle sets the angle to rotate the decal
  27844. * @returns a new Mesh
  27845. */
  27846. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27847. /**
  27848. * Prepare internal position array for software CPU skinning
  27849. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27850. */
  27851. setPositionsForCPUSkinning(): Float32Array;
  27852. /**
  27853. * Prepare internal normal array for software CPU skinning
  27854. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27855. */
  27856. setNormalsForCPUSkinning(): Float32Array;
  27857. /**
  27858. * Updates the vertex buffer by applying transformation from the bones
  27859. * @param skeleton defines the skeleton to apply to current mesh
  27860. * @returns the current mesh
  27861. */
  27862. applySkeleton(skeleton: Skeleton): Mesh;
  27863. /**
  27864. * 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
  27865. * @param meshes defines the list of meshes to scan
  27866. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27867. */
  27868. static MinMax(meshes: AbstractMesh[]): {
  27869. min: Vector3;
  27870. max: Vector3;
  27871. };
  27872. /**
  27873. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27874. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27875. * @returns a vector3
  27876. */
  27877. static Center(meshesOrMinMaxVector: {
  27878. min: Vector3;
  27879. max: Vector3;
  27880. } | AbstractMesh[]): Vector3;
  27881. /**
  27882. * Merge the array of meshes into a single mesh for performance reasons.
  27883. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27884. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27885. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27886. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27887. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27888. * @returns a new mesh
  27889. */
  27890. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27891. /** @hidden */
  27892. addInstance(instance: InstancedMesh): void;
  27893. /** @hidden */
  27894. removeInstance(instance: InstancedMesh): void;
  27895. }
  27896. }
  27897. declare module BABYLON {
  27898. /**
  27899. * Define an interface for all classes that will get and set the data on vertices
  27900. */
  27901. interface IGetSetVerticesData {
  27902. /**
  27903. * Gets a boolean indicating if specific vertex data is present
  27904. * @param kind defines the vertex data kind to use
  27905. * @returns true is data kind is present
  27906. */
  27907. isVerticesDataPresent(kind: string): boolean;
  27908. /**
  27909. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27910. * @param kind defines the data kind (Position, normal, etc...)
  27911. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27912. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27913. * @returns a float array containing vertex data
  27914. */
  27915. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27916. /**
  27917. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27918. * @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.
  27919. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27920. * @returns the indices array or an empty array if the mesh has no geometry
  27921. */
  27922. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27923. /**
  27924. * Set specific vertex data
  27925. * @param kind defines the data kind (Position, normal, etc...)
  27926. * @param data defines the vertex data to use
  27927. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27928. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27929. */
  27930. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27931. /**
  27932. * Update a specific associated vertex buffer
  27933. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27934. * - BABYLON.VertexBuffer.PositionKind
  27935. * - BABYLON.VertexBuffer.UVKind
  27936. * - BABYLON.VertexBuffer.UV2Kind
  27937. * - BABYLON.VertexBuffer.UV3Kind
  27938. * - BABYLON.VertexBuffer.UV4Kind
  27939. * - BABYLON.VertexBuffer.UV5Kind
  27940. * - BABYLON.VertexBuffer.UV6Kind
  27941. * - BABYLON.VertexBuffer.ColorKind
  27942. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27943. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27944. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27945. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27946. * @param data defines the data source
  27947. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27948. * @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)
  27949. */
  27950. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27951. /**
  27952. * Creates a new index buffer
  27953. * @param indices defines the indices to store in the index buffer
  27954. * @param totalVertices defines the total number of vertices (could be null)
  27955. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27956. */
  27957. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27958. }
  27959. /**
  27960. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27961. */
  27962. class VertexData {
  27963. /**
  27964. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27965. */
  27966. positions: Nullable<FloatArray>;
  27967. /**
  27968. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27969. */
  27970. normals: Nullable<FloatArray>;
  27971. /**
  27972. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27973. */
  27974. tangents: Nullable<FloatArray>;
  27975. /**
  27976. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27977. */
  27978. uvs: Nullable<FloatArray>;
  27979. /**
  27980. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27981. */
  27982. uvs2: Nullable<FloatArray>;
  27983. /**
  27984. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27985. */
  27986. uvs3: Nullable<FloatArray>;
  27987. /**
  27988. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27989. */
  27990. uvs4: Nullable<FloatArray>;
  27991. /**
  27992. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27993. */
  27994. uvs5: Nullable<FloatArray>;
  27995. /**
  27996. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27997. */
  27998. uvs6: Nullable<FloatArray>;
  27999. /**
  28000. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  28001. */
  28002. colors: Nullable<FloatArray>;
  28003. /**
  28004. * 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).
  28005. */
  28006. matricesIndices: Nullable<FloatArray>;
  28007. /**
  28008. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  28009. */
  28010. matricesWeights: Nullable<FloatArray>;
  28011. /**
  28012. * An array extending the number of possible indices
  28013. */
  28014. matricesIndicesExtra: Nullable<FloatArray>;
  28015. /**
  28016. * An array extending the number of possible weights when the number of indices is extended
  28017. */
  28018. matricesWeightsExtra: Nullable<FloatArray>;
  28019. /**
  28020. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  28021. */
  28022. indices: Nullable<IndicesArray>;
  28023. /**
  28024. * Uses the passed data array to set the set the values for the specified kind of data
  28025. * @param data a linear array of floating numbers
  28026. * @param kind the type of data that is being set, eg positions, colors etc
  28027. */
  28028. set(data: FloatArray, kind: string): void;
  28029. /**
  28030. * Associates the vertexData to the passed Mesh.
  28031. * Sets it as updatable or not (default `false`)
  28032. * @param mesh the mesh the vertexData is applied to
  28033. * @param updatable when used and having the value true allows new data to update the vertexData
  28034. * @returns the VertexData
  28035. */
  28036. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  28037. /**
  28038. * Associates the vertexData to the passed Geometry.
  28039. * Sets it as updatable or not (default `false`)
  28040. * @param geometry the geometry the vertexData is applied to
  28041. * @param updatable when used and having the value true allows new data to update the vertexData
  28042. * @returns VertexData
  28043. */
  28044. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  28045. /**
  28046. * Updates the associated mesh
  28047. * @param mesh the mesh to be updated
  28048. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  28049. * @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
  28050. * @returns VertexData
  28051. */
  28052. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  28053. /**
  28054. * Updates the associated geometry
  28055. * @param geometry the geometry to be updated
  28056. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  28057. * @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
  28058. * @returns VertexData.
  28059. */
  28060. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  28061. private _applyTo;
  28062. private _update;
  28063. /**
  28064. * Transforms each position and each normal of the vertexData according to the passed Matrix
  28065. * @param matrix the transforming matrix
  28066. * @returns the VertexData
  28067. */
  28068. transform(matrix: Matrix): VertexData;
  28069. /**
  28070. * Merges the passed VertexData into the current one
  28071. * @param other the VertexData to be merged into the current one
  28072. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  28073. * @returns the modified VertexData
  28074. */
  28075. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  28076. private _mergeElement;
  28077. private _validate;
  28078. /**
  28079. * Serializes the VertexData
  28080. * @returns a serialized object
  28081. */
  28082. serialize(): any;
  28083. /**
  28084. * Extracts the vertexData from a mesh
  28085. * @param mesh the mesh from which to extract the VertexData
  28086. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  28087. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  28088. * @returns the object VertexData associated to the passed mesh
  28089. */
  28090. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  28091. /**
  28092. * Extracts the vertexData from the geometry
  28093. * @param geometry the geometry from which to extract the VertexData
  28094. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  28095. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  28096. * @returns the object VertexData associated to the passed mesh
  28097. */
  28098. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  28099. private static _ExtractFrom;
  28100. /**
  28101. * Creates the VertexData for a Ribbon
  28102. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  28103. * * pathArray array of paths, each of which an array of successive Vector3
  28104. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  28105. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  28106. * * 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
  28107. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28108. * * 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)
  28109. * * 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)
  28110. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  28111. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  28112. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  28113. * @returns the VertexData of the ribbon
  28114. */
  28115. static CreateRibbon(options: {
  28116. pathArray: Vector3[][];
  28117. closeArray?: boolean;
  28118. closePath?: boolean;
  28119. offset?: number;
  28120. sideOrientation?: number;
  28121. frontUVs?: Vector4;
  28122. backUVs?: Vector4;
  28123. invertUV?: boolean;
  28124. uvs?: Vector2[];
  28125. colors?: Color4[];
  28126. }): VertexData;
  28127. /**
  28128. * Creates the VertexData for a box
  28129. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28130. * * size sets the width, height and depth of the box to the value of size, optional default 1
  28131. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  28132. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  28133. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  28134. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  28135. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  28136. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28137. * * 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)
  28138. * * 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)
  28139. * @returns the VertexData of the box
  28140. */
  28141. static CreateBox(options: {
  28142. size?: number;
  28143. width?: number;
  28144. height?: number;
  28145. depth?: number;
  28146. faceUV?: Vector4[];
  28147. faceColors?: Color4[];
  28148. sideOrientation?: number;
  28149. frontUVs?: Vector4;
  28150. backUVs?: Vector4;
  28151. }): VertexData;
  28152. /**
  28153. * Creates the VertexData for an ellipsoid, defaults to a sphere
  28154. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28155. * * segments sets the number of horizontal strips optional, default 32
  28156. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  28157. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  28158. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  28159. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  28160. * * 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
  28161. * * 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
  28162. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28163. * * 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)
  28164. * * 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)
  28165. * @returns the VertexData of the ellipsoid
  28166. */
  28167. static CreateSphere(options: {
  28168. segments?: number;
  28169. diameter?: number;
  28170. diameterX?: number;
  28171. diameterY?: number;
  28172. diameterZ?: number;
  28173. arc?: number;
  28174. slice?: number;
  28175. sideOrientation?: number;
  28176. frontUVs?: Vector4;
  28177. backUVs?: Vector4;
  28178. }): VertexData;
  28179. /**
  28180. * Creates the VertexData for a cylinder, cone or prism
  28181. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28182. * * height sets the height (y direction) of the cylinder, optional, default 2
  28183. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  28184. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  28185. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  28186. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  28187. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  28188. * * 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
  28189. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28190. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28191. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  28192. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  28193. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28194. * * 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)
  28195. * * 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)
  28196. * @returns the VertexData of the cylinder, cone or prism
  28197. */
  28198. static CreateCylinder(options: {
  28199. height?: number;
  28200. diameterTop?: number;
  28201. diameterBottom?: number;
  28202. diameter?: number;
  28203. tessellation?: number;
  28204. subdivisions?: number;
  28205. arc?: number;
  28206. faceColors?: Color4[];
  28207. faceUV?: Vector4[];
  28208. hasRings?: boolean;
  28209. enclose?: boolean;
  28210. sideOrientation?: number;
  28211. frontUVs?: Vector4;
  28212. backUVs?: Vector4;
  28213. }): VertexData;
  28214. /**
  28215. * Creates the VertexData for a torus
  28216. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28217. * * diameter the diameter of the torus, optional default 1
  28218. * * thickness the diameter of the tube forming the torus, optional default 0.5
  28219. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  28220. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28221. * * 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)
  28222. * * 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)
  28223. * @returns the VertexData of the torus
  28224. */
  28225. static CreateTorus(options: {
  28226. diameter?: number;
  28227. thickness?: number;
  28228. tessellation?: number;
  28229. sideOrientation?: number;
  28230. frontUVs?: Vector4;
  28231. backUVs?: Vector4;
  28232. }): VertexData;
  28233. /**
  28234. * Creates the VertexData of the LineSystem
  28235. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  28236. * - lines an array of lines, each line being an array of successive Vector3
  28237. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  28238. * @returns the VertexData of the LineSystem
  28239. */
  28240. static CreateLineSystem(options: {
  28241. lines: Vector3[][];
  28242. colors?: Nullable<Color4[][]>;
  28243. }): VertexData;
  28244. /**
  28245. * Create the VertexData for a DashedLines
  28246. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  28247. * - points an array successive Vector3
  28248. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  28249. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  28250. * - dashNb the intended total number of dashes, optional, default 200
  28251. * @returns the VertexData for the DashedLines
  28252. */
  28253. static CreateDashedLines(options: {
  28254. points: Vector3[];
  28255. dashSize?: number;
  28256. gapSize?: number;
  28257. dashNb?: number;
  28258. }): VertexData;
  28259. /**
  28260. * Creates the VertexData for a Ground
  28261. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  28262. * - width the width (x direction) of the ground, optional, default 1
  28263. * - height the height (z direction) of the ground, optional, default 1
  28264. * - subdivisions the number of subdivisions per side, optional, default 1
  28265. * @returns the VertexData of the Ground
  28266. */
  28267. static CreateGround(options: {
  28268. width?: number;
  28269. height?: number;
  28270. subdivisions?: number;
  28271. subdivisionsX?: number;
  28272. subdivisionsY?: number;
  28273. }): VertexData;
  28274. /**
  28275. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  28276. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  28277. * * xmin the ground minimum X coordinate, optional, default -1
  28278. * * zmin the ground minimum Z coordinate, optional, default -1
  28279. * * xmax the ground maximum X coordinate, optional, default 1
  28280. * * zmax the ground maximum Z coordinate, optional, default 1
  28281. * * 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}
  28282. * * 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}
  28283. * @returns the VertexData of the TiledGround
  28284. */
  28285. static CreateTiledGround(options: {
  28286. xmin: number;
  28287. zmin: number;
  28288. xmax: number;
  28289. zmax: number;
  28290. subdivisions?: {
  28291. w: number;
  28292. h: number;
  28293. };
  28294. precision?: {
  28295. w: number;
  28296. h: number;
  28297. };
  28298. }): VertexData;
  28299. /**
  28300. * Creates the VertexData of the Ground designed from a heightmap
  28301. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  28302. * * width the width (x direction) of the ground
  28303. * * height the height (z direction) of the ground
  28304. * * subdivisions the number of subdivisions per side
  28305. * * minHeight the minimum altitude on the ground, optional, default 0
  28306. * * maxHeight the maximum altitude on the ground, optional default 1
  28307. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  28308. * * buffer the array holding the image color data
  28309. * * bufferWidth the width of image
  28310. * * bufferHeight the height of image
  28311. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  28312. * @returns the VertexData of the Ground designed from a heightmap
  28313. */
  28314. static CreateGroundFromHeightMap(options: {
  28315. width: number;
  28316. height: number;
  28317. subdivisions: number;
  28318. minHeight: number;
  28319. maxHeight: number;
  28320. colorFilter: Color3;
  28321. buffer: Uint8Array;
  28322. bufferWidth: number;
  28323. bufferHeight: number;
  28324. alphaFilter: number;
  28325. }): VertexData;
  28326. /**
  28327. * Creates the VertexData for a Plane
  28328. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  28329. * * size sets the width and height of the plane to the value of size, optional default 1
  28330. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  28331. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  28332. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28333. * * 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)
  28334. * * 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)
  28335. * @returns the VertexData of the box
  28336. */
  28337. static CreatePlane(options: {
  28338. size?: number;
  28339. width?: number;
  28340. height?: number;
  28341. sideOrientation?: number;
  28342. frontUVs?: Vector4;
  28343. backUVs?: Vector4;
  28344. }): VertexData;
  28345. /**
  28346. * Creates the VertexData of the Disc or regular Polygon
  28347. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  28348. * * radius the radius of the disc, optional default 0.5
  28349. * * tessellation the number of polygon sides, optional, default 64
  28350. * * 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
  28351. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28352. * * 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)
  28353. * * 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)
  28354. * @returns the VertexData of the box
  28355. */
  28356. static CreateDisc(options: {
  28357. radius?: number;
  28358. tessellation?: number;
  28359. arc?: number;
  28360. sideOrientation?: number;
  28361. frontUVs?: Vector4;
  28362. backUVs?: Vector4;
  28363. }): VertexData;
  28364. /**
  28365. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  28366. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  28367. * @param polygon a mesh built from polygonTriangulation.build()
  28368. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28369. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28370. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28371. * @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)
  28372. * @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)
  28373. * @returns the VertexData of the Polygon
  28374. */
  28375. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  28376. /**
  28377. * Creates the VertexData of the IcoSphere
  28378. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  28379. * * radius the radius of the IcoSphere, optional default 1
  28380. * * radiusX allows stretching in the x direction, optional, default radius
  28381. * * radiusY allows stretching in the y direction, optional, default radius
  28382. * * radiusZ allows stretching in the z direction, optional, default radius
  28383. * * flat when true creates a flat shaded mesh, optional, default true
  28384. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28385. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28386. * * 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)
  28387. * * 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)
  28388. * @returns the VertexData of the IcoSphere
  28389. */
  28390. static CreateIcoSphere(options: {
  28391. radius?: number;
  28392. radiusX?: number;
  28393. radiusY?: number;
  28394. radiusZ?: number;
  28395. flat?: boolean;
  28396. subdivisions?: number;
  28397. sideOrientation?: number;
  28398. frontUVs?: Vector4;
  28399. backUVs?: Vector4;
  28400. }): VertexData;
  28401. /**
  28402. * Creates the VertexData for a Polyhedron
  28403. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  28404. * * type provided types are:
  28405. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  28406. * * 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)
  28407. * * size the size of the IcoSphere, optional default 1
  28408. * * sizeX allows stretching in the x direction, optional, default size
  28409. * * sizeY allows stretching in the y direction, optional, default size
  28410. * * sizeZ allows stretching in the z direction, optional, default size
  28411. * * 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
  28412. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28413. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28414. * * flat when true creates a flat shaded mesh, optional, default true
  28415. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28416. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28417. * * 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)
  28418. * * 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)
  28419. * @returns the VertexData of the Polyhedron
  28420. */
  28421. static CreatePolyhedron(options: {
  28422. type?: number;
  28423. size?: number;
  28424. sizeX?: number;
  28425. sizeY?: number;
  28426. sizeZ?: number;
  28427. custom?: any;
  28428. faceUV?: Vector4[];
  28429. faceColors?: Color4[];
  28430. flat?: boolean;
  28431. sideOrientation?: number;
  28432. frontUVs?: Vector4;
  28433. backUVs?: Vector4;
  28434. }): VertexData;
  28435. /**
  28436. * Creates the VertexData for a TorusKnot
  28437. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  28438. * * radius the radius of the torus knot, optional, default 2
  28439. * * tube the thickness of the tube, optional, default 0.5
  28440. * * radialSegments the number of sides on each tube segments, optional, default 32
  28441. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  28442. * * p the number of windings around the z axis, optional, default 2
  28443. * * q the number of windings around the x axis, optional, default 3
  28444. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28445. * * 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)
  28446. * * 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)
  28447. * @returns the VertexData of the Torus Knot
  28448. */
  28449. static CreateTorusKnot(options: {
  28450. radius?: number;
  28451. tube?: number;
  28452. radialSegments?: number;
  28453. tubularSegments?: number;
  28454. p?: number;
  28455. q?: number;
  28456. sideOrientation?: number;
  28457. frontUVs?: Vector4;
  28458. backUVs?: Vector4;
  28459. }): VertexData;
  28460. /**
  28461. * Compute normals for given positions and indices
  28462. * @param positions an array of vertex positions, [...., x, y, z, ......]
  28463. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  28464. * @param normals an array of vertex normals, [...., x, y, z, ......]
  28465. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  28466. * * facetNormals : optional array of facet normals (vector3)
  28467. * * facetPositions : optional array of facet positions (vector3)
  28468. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  28469. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  28470. * * bInfo : optional bounding info, required for facetPartitioning computation
  28471. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  28472. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  28473. * * useRightHandedSystem: optional boolean to for right handed system computation
  28474. * * depthSort : optional boolean to enable the facet depth sort computation
  28475. * * distanceTo : optional Vector3 to compute the facet depth from this location
  28476. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  28477. */
  28478. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  28479. facetNormals?: any;
  28480. facetPositions?: any;
  28481. facetPartitioning?: any;
  28482. ratio?: number;
  28483. bInfo?: any;
  28484. bbSize?: Vector3;
  28485. subDiv?: any;
  28486. useRightHandedSystem?: boolean;
  28487. depthSort?: boolean;
  28488. distanceTo?: Vector3;
  28489. depthSortedFacets?: any;
  28490. }): void;
  28491. private static _ComputeSides;
  28492. /**
  28493. * Applies VertexData created from the imported parameters to the geometry
  28494. * @param parsedVertexData the parsed data from an imported file
  28495. * @param geometry the geometry to apply the VertexData to
  28496. */
  28497. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  28498. }
  28499. }
  28500. declare module BABYLON {
  28501. /**
  28502. * Class containing static functions to help procedurally build meshes
  28503. */
  28504. class MeshBuilder {
  28505. private static _UpdateSideOrientation;
  28506. /**
  28507. * Creates a box mesh
  28508. * * The parameter `size` sets the size (float) of each box side (default 1)
  28509. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  28510. * * 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)
  28511. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28513. * * 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
  28514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28515. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  28516. * @param name defines the name of the mesh
  28517. * @param options defines the options used to create the mesh
  28518. * @param scene defines the hosting scene
  28519. * @returns the box mesh
  28520. */
  28521. static CreateBox(name: string, options: {
  28522. size?: number;
  28523. width?: number;
  28524. height?: number;
  28525. depth?: number;
  28526. faceUV?: Vector4[];
  28527. faceColors?: Color4[];
  28528. sideOrientation?: number;
  28529. frontUVs?: Vector4;
  28530. backUVs?: Vector4;
  28531. updatable?: boolean;
  28532. }, scene?: Nullable<Scene>): Mesh;
  28533. /**
  28534. * Creates a sphere mesh
  28535. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  28536. * * 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`)
  28537. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  28538. * * 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
  28539. * * 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)
  28540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28541. * * 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
  28542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28543. * @param name defines the name of the mesh
  28544. * @param options defines the options used to create the mesh
  28545. * @param scene defines the hosting scene
  28546. * @returns the sphere mesh
  28547. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  28548. */
  28549. static CreateSphere(name: string, options: {
  28550. segments?: number;
  28551. diameter?: number;
  28552. diameterX?: number;
  28553. diameterY?: number;
  28554. diameterZ?: number;
  28555. arc?: number;
  28556. slice?: number;
  28557. sideOrientation?: number;
  28558. frontUVs?: Vector4;
  28559. backUVs?: Vector4;
  28560. updatable?: boolean;
  28561. }, scene: any): Mesh;
  28562. /**
  28563. * Creates a plane polygonal mesh. By default, this is a disc
  28564. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28565. * * 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
  28566. * * 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
  28567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28568. * * 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
  28569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28570. * @param name defines the name of the mesh
  28571. * @param options defines the options used to create the mesh
  28572. * @param scene defines the hosting scene
  28573. * @returns the plane polygonal mesh
  28574. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28575. */
  28576. static CreateDisc(name: string, options: {
  28577. radius?: number;
  28578. tessellation?: number;
  28579. arc?: number;
  28580. updatable?: boolean;
  28581. sideOrientation?: number;
  28582. frontUVs?: Vector4;
  28583. backUVs?: Vector4;
  28584. }, scene?: Nullable<Scene>): Mesh;
  28585. /**
  28586. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28587. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28588. * * 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`)
  28589. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28590. * * 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
  28591. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28592. * * 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
  28593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28594. * @param name defines the name of the mesh
  28595. * @param options defines the options used to create the mesh
  28596. * @param scene defines the hosting scene
  28597. * @returns the icosahedron mesh
  28598. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28599. */
  28600. static CreateIcoSphere(name: string, options: {
  28601. radius?: number;
  28602. radiusX?: number;
  28603. radiusY?: number;
  28604. radiusZ?: number;
  28605. flat?: boolean;
  28606. subdivisions?: number;
  28607. sideOrientation?: number;
  28608. frontUVs?: Vector4;
  28609. backUVs?: Vector4;
  28610. updatable?: boolean;
  28611. }, scene: Scene): Mesh;
  28612. /**
  28613. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28614. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28615. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28616. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28617. * * 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
  28618. * * 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
  28619. * * 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
  28620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28621. * * 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
  28622. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28623. * * 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
  28624. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28625. * * 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
  28626. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28628. * @param name defines the name of the mesh
  28629. * @param options defines the options used to create the mesh
  28630. * @param scene defines the hosting scene
  28631. * @returns the ribbon mesh
  28632. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  28633. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28634. */
  28635. static CreateRibbon(name: string, options: {
  28636. pathArray: Vector3[][];
  28637. closeArray?: boolean;
  28638. closePath?: boolean;
  28639. offset?: number;
  28640. updatable?: boolean;
  28641. sideOrientation?: number;
  28642. frontUVs?: Vector4;
  28643. backUVs?: Vector4;
  28644. instance?: Mesh;
  28645. invertUV?: boolean;
  28646. uvs?: Vector2[];
  28647. colors?: Color4[];
  28648. }, scene?: Nullable<Scene>): Mesh;
  28649. /**
  28650. * Creates a cylinder or a cone mesh
  28651. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28652. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28653. * * 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.
  28654. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28655. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28656. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28657. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28658. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28659. * * 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).
  28660. * * 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
  28661. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28662. * * 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
  28663. * * 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.
  28664. * * If `enclose` is false, a ring surface is one element.
  28665. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28666. * * 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
  28667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28668. * * 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
  28669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28670. * @param name defines the name of the mesh
  28671. * @param options defines the options used to create the mesh
  28672. * @param scene defines the hosting scene
  28673. * @returns the cylinder mesh
  28674. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  28675. */
  28676. static CreateCylinder(name: string, options: {
  28677. height?: number;
  28678. diameterTop?: number;
  28679. diameterBottom?: number;
  28680. diameter?: number;
  28681. tessellation?: number;
  28682. subdivisions?: number;
  28683. arc?: number;
  28684. faceColors?: Color4[];
  28685. faceUV?: Vector4[];
  28686. updatable?: boolean;
  28687. hasRings?: boolean;
  28688. enclose?: boolean;
  28689. sideOrientation?: number;
  28690. frontUVs?: Vector4;
  28691. backUVs?: Vector4;
  28692. }, scene: any): Mesh;
  28693. /**
  28694. * Creates a torus mesh
  28695. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28696. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28697. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28699. * * 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
  28700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28701. * @param name defines the name of the mesh
  28702. * @param options defines the options used to create the mesh
  28703. * @param scene defines the hosting scene
  28704. * @returns the torus mesh
  28705. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  28706. */
  28707. static CreateTorus(name: string, options: {
  28708. diameter?: number;
  28709. thickness?: number;
  28710. tessellation?: number;
  28711. updatable?: boolean;
  28712. sideOrientation?: number;
  28713. frontUVs?: Vector4;
  28714. backUVs?: Vector4;
  28715. }, scene: any): Mesh;
  28716. /**
  28717. * Creates a torus knot mesh
  28718. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28719. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28720. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28721. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28723. * * 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
  28724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28725. * @param name defines the name of the mesh
  28726. * @param options defines the options used to create the mesh
  28727. * @param scene defines the hosting scene
  28728. * @returns the torus knot mesh
  28729. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  28730. */
  28731. static CreateTorusKnot(name: string, options: {
  28732. radius?: number;
  28733. tube?: number;
  28734. radialSegments?: number;
  28735. tubularSegments?: number;
  28736. p?: number;
  28737. q?: number;
  28738. updatable?: boolean;
  28739. sideOrientation?: number;
  28740. frontUVs?: Vector4;
  28741. backUVs?: Vector4;
  28742. }, scene: any): Mesh;
  28743. /**
  28744. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28745. * * 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
  28746. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28747. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28748. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28749. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28750. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28751. * * 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
  28752. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28754. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28755. * @param name defines the name of the new line system
  28756. * @param options defines the options used to create the line system
  28757. * @param scene defines the hosting scene
  28758. * @returns a new line system mesh
  28759. */
  28760. static CreateLineSystem(name: string, options: {
  28761. lines: Vector3[][];
  28762. updatable?: boolean;
  28763. instance?: Nullable<LinesMesh>;
  28764. colors?: Nullable<Color4[][]>;
  28765. useVertexAlpha?: boolean;
  28766. }, scene: Nullable<Scene>): LinesMesh;
  28767. /**
  28768. * Creates a line mesh
  28769. * 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
  28770. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28771. * * The parameter `points` is an array successive Vector3
  28772. * * 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
  28773. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28774. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28775. * * When updating an instance, remember that only point positions can change, not the number of points
  28776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28777. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  28778. * @param name defines the name of the new line system
  28779. * @param options defines the options used to create the line system
  28780. * @param scene defines the hosting scene
  28781. * @returns a new line mesh
  28782. */
  28783. static CreateLines(name: string, options: {
  28784. points: Vector3[];
  28785. updatable?: boolean;
  28786. instance?: Nullable<LinesMesh>;
  28787. colors?: Color4[];
  28788. useVertexAlpha?: boolean;
  28789. }, scene?: Nullable<Scene>): LinesMesh;
  28790. /**
  28791. * Creates a dashed line mesh
  28792. * * 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
  28793. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28794. * * The parameter `points` is an array successive Vector3
  28795. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28796. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28797. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28798. * * 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
  28799. * * When updating an instance, remember that only point positions can change, not the number of points
  28800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28801. * @param name defines the name of the mesh
  28802. * @param options defines the options used to create the mesh
  28803. * @param scene defines the hosting scene
  28804. * @returns the dashed line mesh
  28805. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28806. */
  28807. static CreateDashedLines(name: string, options: {
  28808. points: Vector3[];
  28809. dashSize?: number;
  28810. gapSize?: number;
  28811. dashNb?: number;
  28812. updatable?: boolean;
  28813. instance?: LinesMesh;
  28814. }, scene?: Nullable<Scene>): LinesMesh;
  28815. /**
  28816. * 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.
  28817. * * 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.
  28818. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28819. * * 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.
  28820. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28821. * * 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
  28822. * * 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
  28823. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28825. * * 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
  28826. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28828. * @param name defines the name of the mesh
  28829. * @param options defines the options used to create the mesh
  28830. * @param scene defines the hosting scene
  28831. * @returns the extruded shape mesh
  28832. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28833. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28834. */
  28835. static ExtrudeShape(name: string, options: {
  28836. shape: Vector3[];
  28837. path: Vector3[];
  28838. scale?: number;
  28839. rotation?: number;
  28840. cap?: number;
  28841. updatable?: boolean;
  28842. sideOrientation?: number;
  28843. frontUVs?: Vector4;
  28844. backUVs?: Vector4;
  28845. instance?: Mesh;
  28846. invertUV?: boolean;
  28847. }, scene?: Nullable<Scene>): Mesh;
  28848. /**
  28849. * Creates an custom extruded shape mesh.
  28850. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28851. * * 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.
  28852. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28853. * * 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
  28854. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28855. * * 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
  28856. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28857. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28858. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28859. * * 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
  28860. * * 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
  28861. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28863. * * 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
  28864. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28866. * @param name defines the name of the mesh
  28867. * @param options defines the options used to create the mesh
  28868. * @param scene defines the hosting scene
  28869. * @returns the custom extruded shape mesh
  28870. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28871. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28872. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28873. */
  28874. static ExtrudeShapeCustom(name: string, options: {
  28875. shape: Vector3[];
  28876. path: Vector3[];
  28877. scaleFunction?: any;
  28878. rotationFunction?: any;
  28879. ribbonCloseArray?: boolean;
  28880. ribbonClosePath?: boolean;
  28881. cap?: number;
  28882. updatable?: boolean;
  28883. sideOrientation?: number;
  28884. frontUVs?: Vector4;
  28885. backUVs?: Vector4;
  28886. instance?: Mesh;
  28887. invertUV?: boolean;
  28888. }, scene: Scene): Mesh;
  28889. /**
  28890. * Creates lathe mesh.
  28891. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28892. * * 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
  28893. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28894. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28895. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28896. * * 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
  28897. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28898. * * 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
  28899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28900. * * 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
  28901. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28903. * @param name defines the name of the mesh
  28904. * @param options defines the options used to create the mesh
  28905. * @param scene defines the hosting scene
  28906. * @returns the lathe mesh
  28907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28908. */
  28909. static CreateLathe(name: string, options: {
  28910. shape: Vector3[];
  28911. radius?: number;
  28912. tessellation?: number;
  28913. clip?: number;
  28914. arc?: number;
  28915. closed?: boolean;
  28916. updatable?: boolean;
  28917. sideOrientation?: number;
  28918. frontUVs?: Vector4;
  28919. backUVs?: Vector4;
  28920. cap?: number;
  28921. invertUV?: boolean;
  28922. }, scene: Scene): Mesh;
  28923. /**
  28924. * Creates a plane mesh
  28925. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28926. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28927. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28929. * * 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
  28930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28931. * @param name defines the name of the mesh
  28932. * @param options defines the options used to create the mesh
  28933. * @param scene defines the hosting scene
  28934. * @returns the plane mesh
  28935. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  28936. */
  28937. static CreatePlane(name: string, options: {
  28938. size?: number;
  28939. width?: number;
  28940. height?: number;
  28941. sideOrientation?: number;
  28942. frontUVs?: Vector4;
  28943. backUVs?: Vector4;
  28944. updatable?: boolean;
  28945. sourcePlane?: Plane;
  28946. }, scene: Scene): Mesh;
  28947. /**
  28948. * Creates a ground mesh
  28949. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28950. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28952. * @param name defines the name of the mesh
  28953. * @param options defines the options used to create the mesh
  28954. * @param scene defines the hosting scene
  28955. * @returns the ground mesh
  28956. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  28957. */
  28958. static CreateGround(name: string, options: {
  28959. width?: number;
  28960. height?: number;
  28961. subdivisions?: number;
  28962. subdivisionsX?: number;
  28963. subdivisionsY?: number;
  28964. updatable?: boolean;
  28965. }, scene: any): Mesh;
  28966. /**
  28967. * Creates a tiled ground mesh
  28968. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28969. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28970. * * 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
  28971. * * 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
  28972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28973. * @param name defines the name of the mesh
  28974. * @param options defines the options used to create the mesh
  28975. * @param scene defines the hosting scene
  28976. * @returns the tiled ground mesh
  28977. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  28978. */
  28979. static CreateTiledGround(name: string, options: {
  28980. xmin: number;
  28981. zmin: number;
  28982. xmax: number;
  28983. zmax: number;
  28984. subdivisions?: {
  28985. w: number;
  28986. h: number;
  28987. };
  28988. precision?: {
  28989. w: number;
  28990. h: number;
  28991. };
  28992. updatable?: boolean;
  28993. }, scene: Scene): Mesh;
  28994. /**
  28995. * Creates a ground mesh from a height map
  28996. * * The parameter `url` sets the URL of the height map image resource.
  28997. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28998. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28999. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  29000. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  29001. * * 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.
  29002. * * 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).
  29003. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29005. * @param name defines the name of the mesh
  29006. * @param url defines the url to the height map
  29007. * @param options defines the options used to create the mesh
  29008. * @param scene defines the hosting scene
  29009. * @returns the ground mesh
  29010. * @see https://doc.babylonjs.com/babylon101/height_map
  29011. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  29012. */
  29013. static CreateGroundFromHeightMap(name: string, url: string, options: {
  29014. width?: number;
  29015. height?: number;
  29016. subdivisions?: number;
  29017. minHeight?: number;
  29018. maxHeight?: number;
  29019. colorFilter?: Color3;
  29020. alphaFilter?: number;
  29021. updatable?: boolean;
  29022. onReady?: (mesh: GroundMesh) => void;
  29023. }, scene: Scene): GroundMesh;
  29024. /**
  29025. * Creates a polygon mesh
  29026. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  29027. * * 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
  29028. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29030. * * 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)
  29031. * * Remember you can only change the shape positions, not their number when updating a polygon
  29032. * @param name defines the name of the mesh
  29033. * @param options defines the options used to create the mesh
  29034. * @param scene defines the hosting scene
  29035. * @returns the polygon mesh
  29036. */
  29037. static CreatePolygon(name: string, options: {
  29038. shape: Vector3[];
  29039. holes?: Vector3[][];
  29040. depth?: number;
  29041. faceUV?: Vector4[];
  29042. faceColors?: Color4[];
  29043. updatable?: boolean;
  29044. sideOrientation?: number;
  29045. frontUVs?: Vector4;
  29046. backUVs?: Vector4;
  29047. }, scene: Scene): Mesh;
  29048. /**
  29049. * Creates an extruded polygon mesh, with depth in the Y direction.
  29050. * * 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)
  29051. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  29052. * @param name defines the name of the mesh
  29053. * @param options defines the options used to create the mesh
  29054. * @param scene defines the hosting scene
  29055. * @returns the polygon mesh
  29056. */
  29057. static ExtrudePolygon(name: string, options: {
  29058. shape: Vector3[];
  29059. holes?: Vector3[][];
  29060. depth?: number;
  29061. faceUV?: Vector4[];
  29062. faceColors?: Color4[];
  29063. updatable?: boolean;
  29064. sideOrientation?: number;
  29065. frontUVs?: Vector4;
  29066. backUVs?: Vector4;
  29067. }, scene: Scene): Mesh;
  29068. /**
  29069. * Creates a tube mesh.
  29070. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  29071. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  29072. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  29073. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  29074. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  29075. * * 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)
  29076. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  29077. * * 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
  29078. * * 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
  29079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29080. * * 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
  29081. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  29082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29083. * @param name defines the name of the mesh
  29084. * @param options defines the options used to create the mesh
  29085. * @param scene defines the hosting scene
  29086. * @returns the tube mesh
  29087. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29088. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  29089. */
  29090. static CreateTube(name: string, options: {
  29091. path: Vector3[];
  29092. radius?: number;
  29093. tessellation?: number;
  29094. radiusFunction?: {
  29095. (i: number, distance: number): number;
  29096. };
  29097. cap?: number;
  29098. arc?: number;
  29099. updatable?: boolean;
  29100. sideOrientation?: number;
  29101. frontUVs?: Vector4;
  29102. backUVs?: Vector4;
  29103. instance?: Mesh;
  29104. invertUV?: boolean;
  29105. }, scene: Scene): Mesh;
  29106. /**
  29107. * Creates a polyhedron mesh
  29108. * * 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
  29109. * * The parameter `size` (positive float, default 1) sets the polygon size
  29110. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29111. * * 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`
  29112. * * 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
  29113. * * 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)`)
  29114. * * 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
  29115. * * 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
  29116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29117. * * 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
  29118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29119. * @param name defines the name of the mesh
  29120. * @param options defines the options used to create the mesh
  29121. * @param scene defines the hosting scene
  29122. * @returns the polyhedron mesh
  29123. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  29124. */
  29125. static CreatePolyhedron(name: string, options: {
  29126. type?: number;
  29127. size?: number;
  29128. sizeX?: number;
  29129. sizeY?: number;
  29130. sizeZ?: number;
  29131. custom?: any;
  29132. faceUV?: Vector4[];
  29133. faceColors?: Color4[];
  29134. flat?: boolean;
  29135. updatable?: boolean;
  29136. sideOrientation?: number;
  29137. frontUVs?: Vector4;
  29138. backUVs?: Vector4;
  29139. }, scene: Scene): Mesh;
  29140. /**
  29141. * Creates a decal mesh.
  29142. * 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
  29143. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  29144. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  29145. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  29146. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  29147. * @param name defines the name of the mesh
  29148. * @param sourceMesh defines the mesh where the decal must be applied
  29149. * @param options defines the options used to create the mesh
  29150. * @param scene defines the hosting scene
  29151. * @returns the decal mesh
  29152. * @see https://doc.babylonjs.com/how_to/decals
  29153. */
  29154. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  29155. position?: Vector3;
  29156. normal?: Vector3;
  29157. size?: Vector3;
  29158. angle?: number;
  29159. }): Mesh;
  29160. private static _ExtrudeShapeGeneric;
  29161. }
  29162. }
  29163. declare module BABYLON {
  29164. /**
  29165. * Class used to represent a specific level of detail of a mesh
  29166. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  29167. */
  29168. class MeshLODLevel {
  29169. /** Defines the distance where this level should star being displayed */
  29170. distance: number;
  29171. /** Defines the mesh to use to render this level */
  29172. mesh: Nullable<Mesh>;
  29173. /**
  29174. * Creates a new LOD level
  29175. * @param distance defines the distance where this level should star being displayed
  29176. * @param mesh defines the mesh to use to render this level
  29177. */
  29178. constructor(
  29179. /** Defines the distance where this level should star being displayed */
  29180. distance: number,
  29181. /** Defines the mesh to use to render this level */
  29182. mesh: Nullable<Mesh>);
  29183. }
  29184. }
  29185. declare module BABYLON {
  29186. /**
  29187. * A simplifier interface for future simplification implementations
  29188. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29189. */
  29190. interface ISimplifier {
  29191. /**
  29192. * Simplification of a given mesh according to the given settings.
  29193. * Since this requires computation, it is assumed that the function runs async.
  29194. * @param settings The settings of the simplification, including quality and distance
  29195. * @param successCallback A callback that will be called after the mesh was simplified.
  29196. * @param errorCallback in case of an error, this callback will be called. optional.
  29197. */
  29198. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  29199. }
  29200. /**
  29201. * Expected simplification settings.
  29202. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  29203. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29204. */
  29205. interface ISimplificationSettings {
  29206. /**
  29207. * Gets or sets the expected quality
  29208. */
  29209. quality: number;
  29210. /**
  29211. * Gets or sets the distance when this optimized version should be used
  29212. */
  29213. distance: number;
  29214. /**
  29215. * Gets an already optimized mesh
  29216. */
  29217. optimizeMesh?: boolean;
  29218. }
  29219. /**
  29220. * Class used to specify simplification options
  29221. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29222. */
  29223. class SimplificationSettings implements ISimplificationSettings {
  29224. /** expected quality */
  29225. quality: number;
  29226. /** distance when this optimized version should be used */
  29227. distance: number;
  29228. /** already optimized mesh */
  29229. optimizeMesh?: boolean | undefined;
  29230. /**
  29231. * Creates a SimplificationSettings
  29232. * @param quality expected quality
  29233. * @param distance distance when this optimized version should be used
  29234. * @param optimizeMesh already optimized mesh
  29235. */
  29236. constructor(
  29237. /** expected quality */
  29238. quality: number,
  29239. /** distance when this optimized version should be used */
  29240. distance: number,
  29241. /** already optimized mesh */
  29242. optimizeMesh?: boolean | undefined);
  29243. }
  29244. /**
  29245. * Interface used to define a simplification task
  29246. */
  29247. interface ISimplificationTask {
  29248. /**
  29249. * Array of settings
  29250. */
  29251. settings: Array<ISimplificationSettings>;
  29252. /**
  29253. * Simplification type
  29254. */
  29255. simplificationType: SimplificationType;
  29256. /**
  29257. * Mesh to simplify
  29258. */
  29259. mesh: Mesh;
  29260. /**
  29261. * Callback called on success
  29262. */
  29263. successCallback?: () => void;
  29264. /**
  29265. * Defines if parallel processing can be used
  29266. */
  29267. parallelProcessing: boolean;
  29268. }
  29269. /**
  29270. * Queue used to order the simplification tasks
  29271. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29272. */
  29273. class SimplificationQueue {
  29274. private _simplificationArray;
  29275. /**
  29276. * Gets a boolean indicating that the process is still running
  29277. */
  29278. running: boolean;
  29279. /**
  29280. * Creates a new queue
  29281. */
  29282. constructor();
  29283. /**
  29284. * Adds a new simplification task
  29285. * @param task defines a task to add
  29286. */
  29287. addTask(task: ISimplificationTask): void;
  29288. /**
  29289. * Execute next task
  29290. */
  29291. executeNext(): void;
  29292. /**
  29293. * Execute a simplification task
  29294. * @param task defines the task to run
  29295. */
  29296. runSimplification(task: ISimplificationTask): void;
  29297. private getSimplifier;
  29298. }
  29299. /**
  29300. * The implemented types of simplification
  29301. * At the moment only Quadratic Error Decimation is implemented
  29302. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29303. */
  29304. enum SimplificationType {
  29305. /** Quadratic error decimation */
  29306. QUADRATIC = 0
  29307. }
  29308. }
  29309. declare module BABYLON {
  29310. interface Scene {
  29311. /** @hidden (Backing field) */
  29312. _simplificationQueue: SimplificationQueue;
  29313. /**
  29314. * Gets or sets the simplification queue attached to the scene
  29315. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29316. */
  29317. simplificationQueue: SimplificationQueue;
  29318. }
  29319. interface Mesh {
  29320. /**
  29321. * Simplify the mesh according to the given array of settings.
  29322. * Function will return immediately and will simplify async
  29323. * @param settings a collection of simplification settings
  29324. * @param parallelProcessing should all levels calculate parallel or one after the other
  29325. * @param simplificationType the type of simplification to run
  29326. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  29327. * @returns the current mesh
  29328. */
  29329. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  29330. }
  29331. /**
  29332. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  29333. * created in a scene
  29334. */
  29335. class SimplicationQueueSceneComponent implements ISceneComponent {
  29336. /**
  29337. * The component name helpfull to identify the component in the list of scene components.
  29338. */
  29339. readonly name: string;
  29340. /**
  29341. * The scene the component belongs to.
  29342. */
  29343. scene: Scene;
  29344. /**
  29345. * Creates a new instance of the component for the given scene
  29346. * @param scene Defines the scene to register the component in
  29347. */
  29348. constructor(scene: Scene);
  29349. /**
  29350. * Registers the component in a given scene
  29351. */
  29352. register(): void;
  29353. /**
  29354. * Rebuilds the elements related to this component in case of
  29355. * context lost for instance.
  29356. */
  29357. rebuild(): void;
  29358. /**
  29359. * Disposes the component and the associated ressources
  29360. */
  29361. dispose(): void;
  29362. private _beforeCameraUpdate;
  29363. }
  29364. }
  29365. declare module BABYLON {
  29366. /**
  29367. * Polygon
  29368. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29369. */
  29370. class Polygon {
  29371. /**
  29372. * Creates a rectangle
  29373. * @param xmin bottom X coord
  29374. * @param ymin bottom Y coord
  29375. * @param xmax top X coord
  29376. * @param ymax top Y coord
  29377. * @returns points that make the resulting rectation
  29378. */
  29379. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  29380. /**
  29381. * Creates a circle
  29382. * @param radius radius of circle
  29383. * @param cx scale in x
  29384. * @param cy scale in y
  29385. * @param numberOfSides number of sides that make up the circle
  29386. * @returns points that make the resulting circle
  29387. */
  29388. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  29389. /**
  29390. * Creates a polygon from input string
  29391. * @param input Input polygon data
  29392. * @returns the parsed points
  29393. */
  29394. static Parse(input: string): Vector2[];
  29395. /**
  29396. * Starts building a polygon from x and y coordinates
  29397. * @param x x coordinate
  29398. * @param y y coordinate
  29399. * @returns the started path2
  29400. */
  29401. static StartingAt(x: number, y: number): Path2;
  29402. }
  29403. /**
  29404. * Builds a polygon
  29405. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  29406. */
  29407. class PolygonMeshBuilder {
  29408. private _points;
  29409. private _outlinepoints;
  29410. private _holes;
  29411. private _name;
  29412. private _scene;
  29413. private _epoints;
  29414. private _eholes;
  29415. private _addToepoint;
  29416. /**
  29417. * Creates a PolygonMeshBuilder
  29418. * @param name name of the builder
  29419. * @param contours Path of the polygon
  29420. * @param scene scene to add to
  29421. */
  29422. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  29423. /**
  29424. * Adds a whole within the polygon
  29425. * @param hole Array of points defining the hole
  29426. * @returns this
  29427. */
  29428. addHole(hole: Vector2[]): PolygonMeshBuilder;
  29429. /**
  29430. * Creates the polygon
  29431. * @param updatable If the mesh should be updatable
  29432. * @param depth The depth of the mesh created
  29433. * @returns the created mesh
  29434. */
  29435. build(updatable?: boolean, depth?: number): Mesh;
  29436. /**
  29437. * Adds a side to the polygon
  29438. * @param positions points that make the polygon
  29439. * @param normals normals of the polygon
  29440. * @param uvs uvs of the polygon
  29441. * @param indices indices of the polygon
  29442. * @param bounds bounds of the polygon
  29443. * @param points points of the polygon
  29444. * @param depth depth of the polygon
  29445. * @param flip flip of the polygon
  29446. */
  29447. private addSide;
  29448. }
  29449. }
  29450. declare module BABYLON {
  29451. /**
  29452. * Base class for submeshes
  29453. */
  29454. class BaseSubMesh {
  29455. /** @hidden */
  29456. _materialDefines: Nullable<MaterialDefines>;
  29457. /** @hidden */
  29458. _materialEffect: Nullable<Effect>;
  29459. /**
  29460. * Gets associated effect
  29461. */
  29462. readonly effect: Nullable<Effect>;
  29463. /**
  29464. * Sets associated effect (effect used to render this submesh)
  29465. * @param effect defines the effect to associate with
  29466. * @param defines defines the set of defines used to compile this effect
  29467. */
  29468. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29469. }
  29470. /**
  29471. * Defines a subdivision inside a mesh
  29472. */
  29473. class SubMesh extends BaseSubMesh implements ICullable {
  29474. /** the material index to use */
  29475. materialIndex: number;
  29476. /** vertex index start */
  29477. verticesStart: number;
  29478. /** vertices count */
  29479. verticesCount: number;
  29480. /** index start */
  29481. indexStart: number;
  29482. /** indices count */
  29483. indexCount: number;
  29484. /** @hidden */
  29485. _linesIndexCount: number;
  29486. private _mesh;
  29487. private _renderingMesh;
  29488. private _boundingInfo;
  29489. private _linesIndexBuffer;
  29490. /** @hidden */
  29491. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29492. /** @hidden */
  29493. _trianglePlanes: Plane[];
  29494. /** @hidden */
  29495. _lastColliderTransformMatrix: Matrix;
  29496. /** @hidden */
  29497. _renderId: number;
  29498. /** @hidden */
  29499. _alphaIndex: number;
  29500. /** @hidden */
  29501. _distanceToCamera: number;
  29502. /** @hidden */
  29503. _id: number;
  29504. private _currentMaterial;
  29505. /**
  29506. * Add a new submesh to a mesh
  29507. * @param materialIndex defines the material index to use
  29508. * @param verticesStart defines vertex index start
  29509. * @param verticesCount defines vertices count
  29510. * @param indexStart defines index start
  29511. * @param indexCount defines indices count
  29512. * @param mesh defines the parent mesh
  29513. * @param renderingMesh defines an optional rendering mesh
  29514. * @param createBoundingBox defines if bounding box should be created for this submesh
  29515. * @returns the new submesh
  29516. */
  29517. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29518. /**
  29519. * Creates a new submesh
  29520. * @param materialIndex defines the material index to use
  29521. * @param verticesStart defines vertex index start
  29522. * @param verticesCount defines vertices count
  29523. * @param indexStart defines index start
  29524. * @param indexCount defines indices count
  29525. * @param mesh defines the parent mesh
  29526. * @param renderingMesh defines an optional rendering mesh
  29527. * @param createBoundingBox defines if bounding box should be created for this submesh
  29528. */
  29529. constructor(
  29530. /** the material index to use */
  29531. materialIndex: number,
  29532. /** vertex index start */
  29533. verticesStart: number,
  29534. /** vertices count */
  29535. verticesCount: number,
  29536. /** index start */
  29537. indexStart: number,
  29538. /** indices count */
  29539. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  29540. /**
  29541. * Returns true if this submesh covers the entire parent mesh
  29542. * @ignorenaming
  29543. */
  29544. readonly IsGlobal: boolean;
  29545. /**
  29546. * Returns the submesh BoudingInfo object
  29547. * @returns current bounding info (or mesh's one if the submesh is global)
  29548. */
  29549. getBoundingInfo(): BoundingInfo;
  29550. /**
  29551. * Sets the submesh BoundingInfo
  29552. * @param boundingInfo defines the new bounding info to use
  29553. * @returns the SubMesh
  29554. */
  29555. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29556. /**
  29557. * Returns the mesh of the current submesh
  29558. * @return the parent mesh
  29559. */
  29560. getMesh(): AbstractMesh;
  29561. /**
  29562. * Returns the rendering mesh of the submesh
  29563. * @returns the rendering mesh (could be different from parent mesh)
  29564. */
  29565. getRenderingMesh(): Mesh;
  29566. /**
  29567. * Returns the submesh material
  29568. * @returns null or the current material
  29569. */
  29570. getMaterial(): Nullable<Material>;
  29571. /**
  29572. * Sets a new updated BoundingInfo object to the submesh
  29573. * @returns the SubMesh
  29574. */
  29575. refreshBoundingInfo(): SubMesh;
  29576. /** @hidden */
  29577. _checkCollision(collider: Collider): boolean;
  29578. /**
  29579. * Updates the submesh BoundingInfo
  29580. * @param world defines the world matrix to use to update the bounding info
  29581. * @returns the submesh
  29582. */
  29583. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  29584. /**
  29585. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29586. * @param frustumPlanes defines the frustum planes
  29587. * @returns true if the submesh is intersecting with the frustum
  29588. */
  29589. isInFrustum(frustumPlanes: Plane[]): boolean;
  29590. /**
  29591. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29592. * @param frustumPlanes defines the frustum planes
  29593. * @returns true if the submesh is inside the frustum
  29594. */
  29595. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29596. /**
  29597. * Renders the submesh
  29598. * @param enableAlphaMode defines if alpha needs to be used
  29599. * @returns the submesh
  29600. */
  29601. render(enableAlphaMode: boolean): SubMesh;
  29602. /**
  29603. * @hidden
  29604. */
  29605. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29606. /**
  29607. * Checks if the submesh intersects with a ray
  29608. * @param ray defines the ray to test
  29609. * @returns true is the passed ray intersects the submesh bounding box
  29610. */
  29611. canIntersects(ray: Ray): boolean;
  29612. /**
  29613. * Intersects current submesh with a ray
  29614. * @param ray defines the ray to test
  29615. * @param positions defines mesh's positions array
  29616. * @param indices defines mesh's indices array
  29617. * @param fastCheck defines if only bounding info should be used
  29618. * @returns intersection info or null if no intersection
  29619. */
  29620. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29621. /** @hidden */
  29622. private _intersectLines;
  29623. /** @hidden */
  29624. private _intersectTriangles;
  29625. /** @hidden */
  29626. _rebuild(): void;
  29627. /**
  29628. * Creates a new submesh from the passed mesh
  29629. * @param newMesh defines the new hosting mesh
  29630. * @param newRenderingMesh defines an optional rendering mesh
  29631. * @returns the new submesh
  29632. */
  29633. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29634. /**
  29635. * Release associated resources
  29636. */
  29637. dispose(): void;
  29638. /**
  29639. * Creates a new submesh from indices data
  29640. * @param materialIndex the index of the main mesh material
  29641. * @param startIndex the index where to start the copy in the mesh indices array
  29642. * @param indexCount the number of indices to copy then from the startIndex
  29643. * @param mesh the main mesh to create the submesh from
  29644. * @param renderingMesh the optional rendering mesh
  29645. * @returns a new submesh
  29646. */
  29647. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29648. }
  29649. }
  29650. declare module BABYLON {
  29651. /**
  29652. * 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.
  29653. * @see https://doc.babylonjs.com/how_to/transformnode
  29654. */
  29655. class TransformNode extends Node {
  29656. /**
  29657. * Object will not rotate to face the camera
  29658. */
  29659. static BILLBOARDMODE_NONE: number;
  29660. /**
  29661. * Object will rotate to face the camera but only on the x axis
  29662. */
  29663. static BILLBOARDMODE_X: number;
  29664. /**
  29665. * Object will rotate to face the camera but only on the y axis
  29666. */
  29667. static BILLBOARDMODE_Y: number;
  29668. /**
  29669. * Object will rotate to face the camera but only on the z axis
  29670. */
  29671. static BILLBOARDMODE_Z: number;
  29672. /**
  29673. * Object will rotate to face the camera
  29674. */
  29675. static BILLBOARDMODE_ALL: number;
  29676. private _forward;
  29677. private _forwardInverted;
  29678. private _up;
  29679. private _right;
  29680. private _rightInverted;
  29681. private _position;
  29682. private _rotation;
  29683. private _rotationQuaternion;
  29684. protected _scaling: Vector3;
  29685. protected _isDirty: boolean;
  29686. private _transformToBoneReferal;
  29687. /**
  29688. * Set the billboard mode. Default is 0.
  29689. *
  29690. * | Value | Type | Description |
  29691. * | --- | --- | --- |
  29692. * | 0 | BILLBOARDMODE_NONE | |
  29693. * | 1 | BILLBOARDMODE_X | |
  29694. * | 2 | BILLBOARDMODE_Y | |
  29695. * | 4 | BILLBOARDMODE_Z | |
  29696. * | 7 | BILLBOARDMODE_ALL | |
  29697. *
  29698. */
  29699. billboardMode: number;
  29700. /**
  29701. * 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
  29702. */
  29703. scalingDeterminant: number;
  29704. /**
  29705. * Sets the distance of the object to max, often used by skybox
  29706. */
  29707. infiniteDistance: boolean;
  29708. /**
  29709. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29710. * By default the system will update normals to compensate
  29711. */
  29712. ignoreNonUniformScaling: boolean;
  29713. /** @hidden */
  29714. _poseMatrix: Matrix;
  29715. /** @hidden */
  29716. _localMatrix: Matrix;
  29717. private _absolutePosition;
  29718. private _pivotMatrix;
  29719. private _pivotMatrixInverse;
  29720. protected _postMultiplyPivotMatrix: boolean;
  29721. protected _isWorldMatrixFrozen: boolean;
  29722. /** @hidden */
  29723. _indexInSceneTransformNodesArray: number;
  29724. /**
  29725. * An event triggered after the world matrix is updated
  29726. */
  29727. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29728. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29729. /**
  29730. * Gets a string identifying the name of the class
  29731. * @returns "TransformNode" string
  29732. */
  29733. getClassName(): string;
  29734. /**
  29735. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29736. */
  29737. position: Vector3;
  29738. /**
  29739. * 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)).
  29740. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29741. */
  29742. rotation: Vector3;
  29743. /**
  29744. * 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)).
  29745. */
  29746. scaling: Vector3;
  29747. /**
  29748. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29749. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29750. */
  29751. rotationQuaternion: Nullable<Quaternion>;
  29752. /**
  29753. * The forward direction of that transform in world space.
  29754. */
  29755. readonly forward: Vector3;
  29756. /**
  29757. * The up direction of that transform in world space.
  29758. */
  29759. readonly up: Vector3;
  29760. /**
  29761. * The right direction of that transform in world space.
  29762. */
  29763. readonly right: Vector3;
  29764. /**
  29765. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29766. * @param matrix the matrix to copy the pose from
  29767. * @returns this TransformNode.
  29768. */
  29769. updatePoseMatrix(matrix: Matrix): TransformNode;
  29770. /**
  29771. * Returns the mesh Pose matrix.
  29772. * @returns the pose matrix
  29773. */
  29774. getPoseMatrix(): Matrix;
  29775. /** @hidden */
  29776. _isSynchronized(): boolean;
  29777. /** @hidden */
  29778. _initCache(): void;
  29779. /**
  29780. * Flag the transform node as dirty (Forcing it to update everything)
  29781. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29782. * @returns this transform node
  29783. */
  29784. markAsDirty(property: string): TransformNode;
  29785. /**
  29786. * Returns the current mesh absolute position.
  29787. * Returns a Vector3.
  29788. */
  29789. readonly absolutePosition: Vector3;
  29790. /**
  29791. * Sets a new matrix to apply before all other transformation
  29792. * @param matrix defines the transform matrix
  29793. * @returns the current TransformNode
  29794. */
  29795. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29796. /**
  29797. * Sets a new pivot matrix to the current node
  29798. * @param matrix defines the new pivot matrix to use
  29799. * @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
  29800. * @returns the current TransformNode
  29801. */
  29802. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29803. /**
  29804. * Returns the mesh pivot matrix.
  29805. * Default : Identity.
  29806. * @returns the matrix
  29807. */
  29808. getPivotMatrix(): Matrix;
  29809. /**
  29810. * Prevents the World matrix to be computed any longer.
  29811. * @returns the TransformNode.
  29812. */
  29813. freezeWorldMatrix(): TransformNode;
  29814. /**
  29815. * Allows back the World matrix computation.
  29816. * @returns the TransformNode.
  29817. */
  29818. unfreezeWorldMatrix(): this;
  29819. /**
  29820. * True if the World matrix has been frozen.
  29821. */
  29822. readonly isWorldMatrixFrozen: boolean;
  29823. /**
  29824. * Retuns the mesh absolute position in the World.
  29825. * @returns a Vector3.
  29826. */
  29827. getAbsolutePosition(): Vector3;
  29828. /**
  29829. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29830. * @param absolutePosition the absolute position to set
  29831. * @returns the TransformNode.
  29832. */
  29833. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29834. /**
  29835. * Sets the mesh position in its local space.
  29836. * @param vector3 the position to set in localspace
  29837. * @returns the TransformNode.
  29838. */
  29839. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29840. /**
  29841. * Returns the mesh position in the local space from the current World matrix values.
  29842. * @returns a new Vector3.
  29843. */
  29844. getPositionExpressedInLocalSpace(): Vector3;
  29845. /**
  29846. * Translates the mesh along the passed Vector3 in its local space.
  29847. * @param vector3 the distance to translate in localspace
  29848. * @returns the TransformNode.
  29849. */
  29850. locallyTranslate(vector3: Vector3): TransformNode;
  29851. private static _lookAtVectorCache;
  29852. /**
  29853. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29854. * @param targetPoint the position (must be in same space as current mesh) to look at
  29855. * @param yawCor optional yaw (y-axis) correction in radians
  29856. * @param pitchCor optional pitch (x-axis) correction in radians
  29857. * @param rollCor optional roll (z-axis) correction in radians
  29858. * @param space the choosen space of the target
  29859. * @returns the TransformNode.
  29860. */
  29861. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29862. /**
  29863. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29864. * This Vector3 is expressed in the World space.
  29865. * @param localAxis axis to rotate
  29866. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29867. */
  29868. getDirection(localAxis: Vector3): Vector3;
  29869. /**
  29870. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29871. * localAxis is expressed in the mesh local space.
  29872. * result is computed in the Wordl space from the mesh World matrix.
  29873. * @param localAxis axis to rotate
  29874. * @param result the resulting transformnode
  29875. * @returns this TransformNode.
  29876. */
  29877. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29878. /**
  29879. * Sets this transform node rotation to the given local axis.
  29880. * @param localAxis the axis in local space
  29881. * @param yawCor optional yaw (y-axis) correction in radians
  29882. * @param pitchCor optional pitch (x-axis) correction in radians
  29883. * @param rollCor optional roll (z-axis) correction in radians
  29884. * @returns this TransformNode
  29885. */
  29886. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  29887. /**
  29888. * Sets a new pivot point to the current node
  29889. * @param point defines the new pivot point to use
  29890. * @param space defines if the point is in world or local space (local by default)
  29891. * @returns the current TransformNode
  29892. */
  29893. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29894. /**
  29895. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29896. * @returns the pivot point
  29897. */
  29898. getPivotPoint(): Vector3;
  29899. /**
  29900. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29901. * @param result the vector3 to store the result
  29902. * @returns this TransformNode.
  29903. */
  29904. getPivotPointToRef(result: Vector3): TransformNode;
  29905. /**
  29906. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29907. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29908. */
  29909. getAbsolutePivotPoint(): Vector3;
  29910. /**
  29911. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29912. * @param result vector3 to store the result
  29913. * @returns this TransformNode.
  29914. */
  29915. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29916. /**
  29917. * Defines the passed node as the parent of the current node.
  29918. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29919. * @param node the node ot set as the parent
  29920. * @returns this TransformNode.
  29921. */
  29922. setParent(node: Nullable<Node>): TransformNode;
  29923. private _nonUniformScaling;
  29924. /**
  29925. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29926. */
  29927. readonly nonUniformScaling: boolean;
  29928. /** @hidden */
  29929. _updateNonUniformScalingState(value: boolean): boolean;
  29930. /**
  29931. * Attach the current TransformNode to another TransformNode associated with a bone
  29932. * @param bone Bone affecting the TransformNode
  29933. * @param affectedTransformNode TransformNode associated with the bone
  29934. * @returns this object
  29935. */
  29936. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29937. /**
  29938. * Detach the transform node if its associated with a bone
  29939. * @returns this object
  29940. */
  29941. detachFromBone(): TransformNode;
  29942. private static _rotationAxisCache;
  29943. /**
  29944. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29945. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29946. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29947. * The passed axis is also normalized.
  29948. * @param axis the axis to rotate around
  29949. * @param amount the amount to rotate in radians
  29950. * @param space Space to rotate in (Default: local)
  29951. * @returns the TransformNode.
  29952. */
  29953. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29954. /**
  29955. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29956. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29957. * The passed axis is also normalized. .
  29958. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29959. * @param point the point to rotate around
  29960. * @param axis the axis to rotate around
  29961. * @param amount the amount to rotate in radians
  29962. * @returns the TransformNode
  29963. */
  29964. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29965. /**
  29966. * Translates the mesh along the axis vector for the passed distance in the given space.
  29967. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29968. * @param axis the axis to translate in
  29969. * @param distance the distance to translate
  29970. * @param space Space to rotate in (Default: local)
  29971. * @returns the TransformNode.
  29972. */
  29973. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29974. /**
  29975. * Adds a rotation step to the mesh current rotation.
  29976. * x, y, z are Euler angles expressed in radians.
  29977. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29978. * This means this rotation is made in the mesh local space only.
  29979. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29980. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29981. * ```javascript
  29982. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29983. * ```
  29984. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29985. * 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.
  29986. * @param x Rotation to add
  29987. * @param y Rotation to add
  29988. * @param z Rotation to add
  29989. * @returns the TransformNode.
  29990. */
  29991. addRotation(x: number, y: number, z: number): TransformNode;
  29992. /**
  29993. * Computes the world matrix of the node
  29994. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29995. * @returns the world matrix
  29996. */
  29997. computeWorldMatrix(force?: boolean): Matrix;
  29998. protected _afterComputeWorldMatrix(): void;
  29999. /**
  30000. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  30001. * @param func callback function to add
  30002. *
  30003. * @returns the TransformNode.
  30004. */
  30005. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  30006. /**
  30007. * Removes a registered callback function.
  30008. * @param func callback function to remove
  30009. * @returns the TransformNode.
  30010. */
  30011. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  30012. /**
  30013. * Gets the position of the current mesh in camera space
  30014. * @param camera defines the camera to use
  30015. * @returns a position
  30016. */
  30017. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  30018. /**
  30019. * Returns the distance from the mesh to the active camera
  30020. * @param camera defines the camera to use
  30021. * @returns the distance
  30022. */
  30023. getDistanceToCamera(camera?: Nullable<Camera>): number;
  30024. /**
  30025. * Clone the current transform node
  30026. * @param name Name of the new clone
  30027. * @param newParent New parent for the clone
  30028. * @param doNotCloneChildren Do not clone children hierarchy
  30029. * @returns the new transform node
  30030. */
  30031. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  30032. /**
  30033. * Serializes the objects information.
  30034. * @param currentSerializationObject defines the object to serialize in
  30035. * @returns the serialized object
  30036. */
  30037. serialize(currentSerializationObject?: any): any;
  30038. /**
  30039. * Returns a new TransformNode object parsed from the source provided.
  30040. * @param parsedTransformNode is the source.
  30041. * @param scene the scne the object belongs to
  30042. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  30043. * @returns a new TransformNode object parsed from the source provided.
  30044. */
  30045. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  30046. /**
  30047. * Releases resources associated with this transform node.
  30048. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30049. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30050. */
  30051. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30052. }
  30053. }
  30054. declare module BABYLON {
  30055. /**
  30056. * Specialized buffer used to store vertex data
  30057. */
  30058. class VertexBuffer {
  30059. /** @hidden */
  30060. _buffer: Buffer;
  30061. private _kind;
  30062. private _size;
  30063. private _ownsBuffer;
  30064. private _instanced;
  30065. private _instanceDivisor;
  30066. /**
  30067. * The byte type.
  30068. */
  30069. static readonly BYTE: number;
  30070. /**
  30071. * The unsigned byte type.
  30072. */
  30073. static readonly UNSIGNED_BYTE: number;
  30074. /**
  30075. * The short type.
  30076. */
  30077. static readonly SHORT: number;
  30078. /**
  30079. * The unsigned short type.
  30080. */
  30081. static readonly UNSIGNED_SHORT: number;
  30082. /**
  30083. * The integer type.
  30084. */
  30085. static readonly INT: number;
  30086. /**
  30087. * The unsigned integer type.
  30088. */
  30089. static readonly UNSIGNED_INT: number;
  30090. /**
  30091. * The float type.
  30092. */
  30093. static readonly FLOAT: number;
  30094. /**
  30095. * Gets or sets the instance divisor when in instanced mode
  30096. */
  30097. instanceDivisor: number;
  30098. /**
  30099. * Gets the byte stride.
  30100. */
  30101. readonly byteStride: number;
  30102. /**
  30103. * Gets the byte offset.
  30104. */
  30105. readonly byteOffset: number;
  30106. /**
  30107. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  30108. */
  30109. readonly normalized: boolean;
  30110. /**
  30111. * Gets the data type of each component in the array.
  30112. */
  30113. readonly type: number;
  30114. /**
  30115. * Constructor
  30116. * @param engine the engine
  30117. * @param data the data to use for this vertex buffer
  30118. * @param kind the vertex buffer kind
  30119. * @param updatable whether the data is updatable
  30120. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  30121. * @param stride the stride (optional)
  30122. * @param instanced whether the buffer is instanced (optional)
  30123. * @param offset the offset of the data (optional)
  30124. * @param size the number of components (optional)
  30125. * @param type the type of the component (optional)
  30126. * @param normalized whether the data contains normalized data (optional)
  30127. * @param useBytes set to true if stride and offset are in bytes (optional)
  30128. */
  30129. 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);
  30130. /** @hidden */
  30131. _rebuild(): void;
  30132. /**
  30133. * Returns the kind of the VertexBuffer (string)
  30134. * @returns a string
  30135. */
  30136. getKind(): string;
  30137. /**
  30138. * Gets a boolean indicating if the VertexBuffer is updatable?
  30139. * @returns true if the buffer is updatable
  30140. */
  30141. isUpdatable(): boolean;
  30142. /**
  30143. * Gets current buffer's data
  30144. * @returns a DataArray or null
  30145. */
  30146. getData(): Nullable<DataArray>;
  30147. /**
  30148. * Gets underlying native buffer
  30149. * @returns underlying native buffer
  30150. */
  30151. getBuffer(): Nullable<WebGLBuffer>;
  30152. /**
  30153. * Gets the stride in float32 units (i.e. byte stride / 4).
  30154. * May not be an integer if the byte stride is not divisible by 4.
  30155. * DEPRECATED. Use byteStride instead.
  30156. * @returns the stride in float32 units
  30157. */
  30158. getStrideSize(): number;
  30159. /**
  30160. * Returns the offset as a multiple of the type byte length.
  30161. * DEPRECATED. Use byteOffset instead.
  30162. * @returns the offset in bytes
  30163. */
  30164. getOffset(): number;
  30165. /**
  30166. * Returns the number of components per vertex attribute (integer)
  30167. * @returns the size in float
  30168. */
  30169. getSize(): number;
  30170. /**
  30171. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  30172. * @returns true if this buffer is instanced
  30173. */
  30174. getIsInstanced(): boolean;
  30175. /**
  30176. * Returns the instancing divisor, zero for non-instanced (integer).
  30177. * @returns a number
  30178. */
  30179. getInstanceDivisor(): number;
  30180. /**
  30181. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  30182. * @param data defines the data to store
  30183. */
  30184. create(data?: DataArray): void;
  30185. /**
  30186. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  30187. * This function will create a new buffer if the current one is not updatable
  30188. * @param data defines the data to store
  30189. */
  30190. update(data: DataArray): void;
  30191. /**
  30192. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  30193. * Returns the directly updated WebGLBuffer.
  30194. * @param data the new data
  30195. * @param offset the new offset
  30196. * @param useBytes set to true if the offset is in bytes
  30197. */
  30198. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  30199. /**
  30200. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  30201. */
  30202. dispose(): void;
  30203. /**
  30204. * Enumerates each value of this vertex buffer as numbers.
  30205. * @param count the number of values to enumerate
  30206. * @param callback the callback function called for each value
  30207. */
  30208. forEach(count: number, callback: (value: number, index: number) => void): void;
  30209. /**
  30210. * Positions
  30211. */
  30212. static readonly PositionKind: string;
  30213. /**
  30214. * Normals
  30215. */
  30216. static readonly NormalKind: string;
  30217. /**
  30218. * Tangents
  30219. */
  30220. static readonly TangentKind: string;
  30221. /**
  30222. * Texture coordinates
  30223. */
  30224. static readonly UVKind: string;
  30225. /**
  30226. * Texture coordinates 2
  30227. */
  30228. static readonly UV2Kind: string;
  30229. /**
  30230. * Texture coordinates 3
  30231. */
  30232. static readonly UV3Kind: string;
  30233. /**
  30234. * Texture coordinates 4
  30235. */
  30236. static readonly UV4Kind: string;
  30237. /**
  30238. * Texture coordinates 5
  30239. */
  30240. static readonly UV5Kind: string;
  30241. /**
  30242. * Texture coordinates 6
  30243. */
  30244. static readonly UV6Kind: string;
  30245. /**
  30246. * Colors
  30247. */
  30248. static readonly ColorKind: string;
  30249. /**
  30250. * Matrix indices (for bones)
  30251. */
  30252. static readonly MatricesIndicesKind: string;
  30253. /**
  30254. * Matrix weights (for bones)
  30255. */
  30256. static readonly MatricesWeightsKind: string;
  30257. /**
  30258. * Additional matrix indices (for bones)
  30259. */
  30260. static readonly MatricesIndicesExtraKind: string;
  30261. /**
  30262. * Additional matrix weights (for bones)
  30263. */
  30264. static readonly MatricesWeightsExtraKind: string;
  30265. /**
  30266. * Deduces the stride given a kind.
  30267. * @param kind The kind string to deduce
  30268. * @returns The deduced stride
  30269. */
  30270. static DeduceStride(kind: string): number;
  30271. /**
  30272. * Gets the byte length of the given type.
  30273. * @param type the type
  30274. * @returns the number of bytes
  30275. */
  30276. static GetTypeByteLength(type: number): number;
  30277. /**
  30278. * Enumerates each value of the given parameters as numbers.
  30279. * @param data the data to enumerate
  30280. * @param byteOffset the byte offset of the data
  30281. * @param byteStride the byte stride of the data
  30282. * @param componentCount the number of components per element
  30283. * @param componentType the type of the component
  30284. * @param count the total number of components
  30285. * @param normalized whether the data is normalized
  30286. * @param callback the callback function called for each value
  30287. */
  30288. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  30289. private static _GetFloatValue;
  30290. }
  30291. }
  30292. declare module BABYLON {
  30293. /**
  30294. * Class used to enable access to IndexedDB
  30295. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30296. */
  30297. class Database implements IOfflineProvider {
  30298. private _callbackManifestChecked;
  30299. private _currentSceneUrl;
  30300. private _db;
  30301. private _enableSceneOffline;
  30302. private _enableTexturesOffline;
  30303. private _manifestVersionFound;
  30304. private _mustUpdateRessources;
  30305. private _hasReachedQuota;
  30306. private _isSupported;
  30307. private _idbFactory;
  30308. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30309. private static IsUASupportingBlobStorage;
  30310. /**
  30311. * Gets a boolean indicating if Database storate is enabled (off by default)
  30312. */
  30313. static IDBStorageEnabled: boolean;
  30314. /**
  30315. * Gets a boolean indicating if scene must be saved in the database
  30316. */
  30317. readonly enableSceneOffline: boolean;
  30318. /**
  30319. * Gets a boolean indicating if textures must be saved in the database
  30320. */
  30321. readonly enableTexturesOffline: boolean;
  30322. /**
  30323. * Creates a new Database
  30324. * @param urlToScene defines the url to load the scene
  30325. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30326. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30327. */
  30328. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30329. private static _ParseURL;
  30330. private static _ReturnFullUrlLocation;
  30331. private _checkManifestFile;
  30332. /**
  30333. * Open the database and make it available
  30334. * @param successCallback defines the callback to call on success
  30335. * @param errorCallback defines the callback to call on error
  30336. */
  30337. open(successCallback: () => void, errorCallback: () => void): void;
  30338. /**
  30339. * Loads an image from the database
  30340. * @param url defines the url to load from
  30341. * @param image defines the target DOM image
  30342. */
  30343. loadImage(url: string, image: HTMLImageElement): void;
  30344. private _loadImageFromDBAsync;
  30345. private _saveImageIntoDBAsync;
  30346. private _checkVersionFromDB;
  30347. private _loadVersionFromDBAsync;
  30348. private _saveVersionIntoDBAsync;
  30349. /**
  30350. * Loads a file from database
  30351. * @param url defines the URL to load from
  30352. * @param sceneLoaded defines a callback to call on success
  30353. * @param progressCallBack defines a callback to call when progress changed
  30354. * @param errorCallback defines a callback to call on error
  30355. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30356. */
  30357. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30358. private _loadFileAsync;
  30359. private _saveFileAsync;
  30360. }
  30361. }
  30362. declare module BABYLON {
  30363. /**
  30364. * Class used to enable access to offline support
  30365. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30366. */
  30367. interface IOfflineProvider {
  30368. /**
  30369. * Gets a boolean indicating if scene must be saved in the database
  30370. */
  30371. enableSceneOffline: boolean;
  30372. /**
  30373. * Gets a boolean indicating if textures must be saved in the database
  30374. */
  30375. enableTexturesOffline: boolean;
  30376. /**
  30377. * Open the offline support and make it available
  30378. * @param successCallback defines the callback to call on success
  30379. * @param errorCallback defines the callback to call on error
  30380. */
  30381. open(successCallback: () => void, errorCallback: () => void): void;
  30382. /**
  30383. * Loads an image from the offline support
  30384. * @param url defines the url to load from
  30385. * @param image defines the target DOM image
  30386. */
  30387. loadImage(url: string, image: HTMLImageElement): void;
  30388. /**
  30389. * Loads a file from offline support
  30390. * @param url defines the URL to load from
  30391. * @param sceneLoaded defines a callback to call on success
  30392. * @param progressCallBack defines a callback to call when progress changed
  30393. * @param errorCallback defines a callback to call on error
  30394. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30395. */
  30396. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30397. }
  30398. }
  30399. declare module BABYLON {
  30400. /**
  30401. * This represents the base class for particle system in Babylon.
  30402. * 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.
  30403. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  30404. * @example https://doc.babylonjs.com/babylon101/particles
  30405. */
  30406. class BaseParticleSystem {
  30407. /**
  30408. * Source color is added to the destination color without alpha affecting the result
  30409. */
  30410. static BLENDMODE_ONEONE: number;
  30411. /**
  30412. * Blend current color and particle color using particle’s alpha
  30413. */
  30414. static BLENDMODE_STANDARD: number;
  30415. /**
  30416. * Add current color and particle color multiplied by particle’s alpha
  30417. */
  30418. static BLENDMODE_ADD: number;
  30419. /**
  30420. * Multiply current color with particle color
  30421. */
  30422. static BLENDMODE_MULTIPLY: number;
  30423. /**
  30424. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  30425. */
  30426. static BLENDMODE_MULTIPLYADD: number;
  30427. /**
  30428. * List of animations used by the particle system.
  30429. */
  30430. animations: Animation[];
  30431. /**
  30432. * The id of the Particle system.
  30433. */
  30434. id: string;
  30435. /**
  30436. * The friendly name of the Particle system.
  30437. */
  30438. name: string;
  30439. /**
  30440. * The rendering group used by the Particle system to chose when to render.
  30441. */
  30442. renderingGroupId: number;
  30443. /**
  30444. * The emitter represents the Mesh or position we are attaching the particle system to.
  30445. */
  30446. emitter: Nullable<AbstractMesh | Vector3>;
  30447. /**
  30448. * The maximum number of particles to emit per frame
  30449. */
  30450. emitRate: number;
  30451. /**
  30452. * If you want to launch only a few particles at once, that can be done, as well.
  30453. */
  30454. manualEmitCount: number;
  30455. /**
  30456. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30457. */
  30458. updateSpeed: number;
  30459. /**
  30460. * The amount of time the particle system is running (depends of the overall update speed).
  30461. */
  30462. targetStopDuration: number;
  30463. /**
  30464. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30465. */
  30466. disposeOnStop: boolean;
  30467. /**
  30468. * Minimum power of emitting particles.
  30469. */
  30470. minEmitPower: number;
  30471. /**
  30472. * Maximum power of emitting particles.
  30473. */
  30474. maxEmitPower: number;
  30475. /**
  30476. * Minimum life time of emitting particles.
  30477. */
  30478. minLifeTime: number;
  30479. /**
  30480. * Maximum life time of emitting particles.
  30481. */
  30482. maxLifeTime: number;
  30483. /**
  30484. * Minimum Size of emitting particles.
  30485. */
  30486. minSize: number;
  30487. /**
  30488. * Maximum Size of emitting particles.
  30489. */
  30490. maxSize: number;
  30491. /**
  30492. * Minimum scale of emitting particles on X axis.
  30493. */
  30494. minScaleX: number;
  30495. /**
  30496. * Maximum scale of emitting particles on X axis.
  30497. */
  30498. maxScaleX: number;
  30499. /**
  30500. * Minimum scale of emitting particles on Y axis.
  30501. */
  30502. minScaleY: number;
  30503. /**
  30504. * Maximum scale of emitting particles on Y axis.
  30505. */
  30506. maxScaleY: number;
  30507. /**
  30508. * Gets or sets the minimal initial rotation in radians.
  30509. */
  30510. minInitialRotation: number;
  30511. /**
  30512. * Gets or sets the maximal initial rotation in radians.
  30513. */
  30514. maxInitialRotation: number;
  30515. /**
  30516. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30517. */
  30518. minAngularSpeed: number;
  30519. /**
  30520. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30521. */
  30522. maxAngularSpeed: number;
  30523. /**
  30524. * The texture used to render each particle. (this can be a spritesheet)
  30525. */
  30526. particleTexture: Nullable<Texture>;
  30527. /**
  30528. * The layer mask we are rendering the particles through.
  30529. */
  30530. layerMask: number;
  30531. /**
  30532. * This can help using your own shader to render the particle system.
  30533. * The according effect will be created
  30534. */
  30535. customShader: any;
  30536. /**
  30537. * By default particle system starts as soon as they are created. This prevents the
  30538. * automatic start to happen and let you decide when to start emitting particles.
  30539. */
  30540. preventAutoStart: boolean;
  30541. private _noiseTexture;
  30542. /**
  30543. * Gets or sets a texture used to add random noise to particle positions
  30544. */
  30545. noiseTexture: Nullable<ProceduralTexture>;
  30546. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30547. noiseStrength: Vector3;
  30548. /**
  30549. * Callback triggered when the particle animation is ending.
  30550. */
  30551. onAnimationEnd: Nullable<() => void>;
  30552. /**
  30553. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  30554. */
  30555. blendMode: number;
  30556. /**
  30557. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30558. * to override the particles.
  30559. */
  30560. forceDepthWrite: boolean;
  30561. /** 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 */
  30562. preWarmCycles: number;
  30563. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  30564. preWarmStepOffset: number;
  30565. /**
  30566. * 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)
  30567. */
  30568. spriteCellChangeSpeed: number;
  30569. /**
  30570. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30571. */
  30572. startSpriteCellID: number;
  30573. /**
  30574. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30575. */
  30576. endSpriteCellID: number;
  30577. /**
  30578. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30579. */
  30580. spriteCellWidth: number;
  30581. /**
  30582. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30583. */
  30584. spriteCellHeight: number;
  30585. /**
  30586. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30587. */
  30588. spriteRandomStartCell: boolean;
  30589. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30590. translationPivot: Vector2;
  30591. /** @hidden */
  30592. protected _isAnimationSheetEnabled: boolean;
  30593. /**
  30594. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30595. */
  30596. beginAnimationOnStart: boolean;
  30597. /**
  30598. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30599. */
  30600. beginAnimationFrom: number;
  30601. /**
  30602. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30603. */
  30604. beginAnimationTo: number;
  30605. /**
  30606. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30607. */
  30608. beginAnimationLoop: boolean;
  30609. /**
  30610. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  30611. */
  30612. isAnimationSheetEnabled: boolean;
  30613. /**
  30614. * Get hosting scene
  30615. * @returns the scene
  30616. */
  30617. getScene(): Scene;
  30618. /**
  30619. * You can use gravity if you want to give an orientation to your particles.
  30620. */
  30621. gravity: Vector3;
  30622. protected _colorGradients: Nullable<Array<ColorGradient>>;
  30623. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  30624. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  30625. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  30626. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  30627. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  30628. protected _dragGradients: Nullable<Array<FactorGradient>>;
  30629. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  30630. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  30631. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  30632. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  30633. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  30634. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  30635. /**
  30636. * Defines the delay in milliseconds before starting the system (0 by default)
  30637. */
  30638. startDelay: number;
  30639. /**
  30640. * Gets the current list of drag gradients.
  30641. * You must use addDragGradient and removeDragGradient to udpate this list
  30642. * @returns the list of drag gradients
  30643. */
  30644. getDragGradients(): Nullable<Array<FactorGradient>>;
  30645. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30646. limitVelocityDamping: number;
  30647. /**
  30648. * Gets the current list of limit velocity gradients.
  30649. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30650. * @returns the list of limit velocity gradients
  30651. */
  30652. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30653. /**
  30654. * Gets the current list of color gradients.
  30655. * You must use addColorGradient and removeColorGradient to udpate this list
  30656. * @returns the list of color gradients
  30657. */
  30658. getColorGradients(): Nullable<Array<ColorGradient>>;
  30659. /**
  30660. * Gets the current list of size gradients.
  30661. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30662. * @returns the list of size gradients
  30663. */
  30664. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30665. /**
  30666. * Gets the current list of color remap gradients.
  30667. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30668. * @returns the list of color remap gradients
  30669. */
  30670. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30671. /**
  30672. * Gets the current list of alpha remap gradients.
  30673. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30674. * @returns the list of alpha remap gradients
  30675. */
  30676. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30677. /**
  30678. * Gets the current list of life time gradients.
  30679. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30680. * @returns the list of life time gradients
  30681. */
  30682. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30683. /**
  30684. * Gets the current list of angular speed gradients.
  30685. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30686. * @returns the list of angular speed gradients
  30687. */
  30688. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30689. /**
  30690. * Gets the current list of velocity gradients.
  30691. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30692. * @returns the list of velocity gradients
  30693. */
  30694. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30695. /**
  30696. * Gets the current list of start size gradients.
  30697. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30698. * @returns the list of start size gradients
  30699. */
  30700. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30701. /**
  30702. * Gets the current list of emit rate gradients.
  30703. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30704. * @returns the list of emit rate gradients
  30705. */
  30706. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30707. /**
  30708. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30709. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30710. */
  30711. direction1: Vector3;
  30712. /**
  30713. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30714. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30715. */
  30716. direction2: Vector3;
  30717. /**
  30718. * 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.
  30719. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30720. */
  30721. minEmitBox: Vector3;
  30722. /**
  30723. * 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.
  30724. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30725. */
  30726. maxEmitBox: Vector3;
  30727. /**
  30728. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30729. */
  30730. color1: Color4;
  30731. /**
  30732. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30733. */
  30734. color2: Color4;
  30735. /**
  30736. * Color the particle will have at the end of its lifetime
  30737. */
  30738. colorDead: Color4;
  30739. /**
  30740. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  30741. */
  30742. textureMask: Color4;
  30743. /**
  30744. * The particle emitter type defines the emitter used by the particle system.
  30745. * It can be for example box, sphere, or cone...
  30746. */
  30747. particleEmitterType: IParticleEmitterType;
  30748. /** @hidden */
  30749. _isSubEmitter: boolean;
  30750. /**
  30751. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30752. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30753. */
  30754. billboardMode: number;
  30755. protected _isBillboardBased: boolean;
  30756. /**
  30757. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30758. */
  30759. isBillboardBased: boolean;
  30760. /**
  30761. * The scene the particle system belongs to.
  30762. */
  30763. protected _scene: Scene;
  30764. /**
  30765. * Local cache of defines for image processing.
  30766. */
  30767. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  30768. /**
  30769. * Default configuration related to image processing available in the standard Material.
  30770. */
  30771. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30772. /**
  30773. * Gets the image processing configuration used either in this material.
  30774. */
  30775. /**
  30776. * Sets the Default image processing configuration used either in the this material.
  30777. *
  30778. * If sets to null, the scene one is in use.
  30779. */
  30780. imageProcessingConfiguration: ImageProcessingConfiguration;
  30781. /**
  30782. * Attaches a new image processing configuration to the Standard Material.
  30783. * @param configuration
  30784. */
  30785. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30786. /** @hidden */
  30787. protected _reset(): void;
  30788. /** @hidden */
  30789. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  30790. /**
  30791. * Instantiates a particle system.
  30792. * 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.
  30793. * @param name The name of the particle system
  30794. */
  30795. constructor(name: string);
  30796. /**
  30797. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30798. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30799. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30800. * @returns the emitter
  30801. */
  30802. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30803. /**
  30804. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30805. * @param radius The radius of the hemisphere to emit from
  30806. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30807. * @returns the emitter
  30808. */
  30809. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  30810. /**
  30811. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30812. * @param radius The radius of the sphere to emit from
  30813. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30814. * @returns the emitter
  30815. */
  30816. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  30817. /**
  30818. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30819. * @param radius The radius of the sphere to emit from
  30820. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30821. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30822. * @returns the emitter
  30823. */
  30824. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  30825. /**
  30826. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30827. * @param radius The radius of the emission cylinder
  30828. * @param height The height of the emission cylinder
  30829. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30830. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30831. * @returns the emitter
  30832. */
  30833. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  30834. /**
  30835. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30836. * @param radius The radius of the cylinder to emit from
  30837. * @param height The height of the emission cylinder
  30838. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30839. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30840. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30841. * @returns the emitter
  30842. */
  30843. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  30844. /**
  30845. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30846. * @param radius The radius of the cone to emit from
  30847. * @param angle The base angle of the cone
  30848. * @returns the emitter
  30849. */
  30850. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  30851. /**
  30852. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30853. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30854. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30855. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30856. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30857. * @returns the emitter
  30858. */
  30859. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30860. }
  30861. }
  30862. declare module BABYLON {
  30863. /**
  30864. * This represents a GPU particle system in Babylon
  30865. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  30866. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  30867. */
  30868. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  30869. /**
  30870. * The layer mask we are rendering the particles through.
  30871. */
  30872. layerMask: number;
  30873. private _capacity;
  30874. private _activeCount;
  30875. private _currentActiveCount;
  30876. private _accumulatedCount;
  30877. private _renderEffect;
  30878. private _updateEffect;
  30879. private _buffer0;
  30880. private _buffer1;
  30881. private _spriteBuffer;
  30882. private _updateVAO;
  30883. private _renderVAO;
  30884. private _targetIndex;
  30885. private _sourceBuffer;
  30886. private _targetBuffer;
  30887. private _engine;
  30888. private _currentRenderId;
  30889. private _started;
  30890. private _stopped;
  30891. private _timeDelta;
  30892. private _randomTexture;
  30893. private _randomTexture2;
  30894. private _attributesStrideSize;
  30895. private _updateEffectOptions;
  30896. private _randomTextureSize;
  30897. private _actualFrame;
  30898. private readonly _rawTextureWidth;
  30899. /**
  30900. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  30901. */
  30902. static readonly IsSupported: boolean;
  30903. /**
  30904. * An event triggered when the system is disposed.
  30905. */
  30906. onDisposeObservable: Observable<GPUParticleSystem>;
  30907. /**
  30908. * Gets the maximum number of particles active at the same time.
  30909. * @returns The max number of active particles.
  30910. */
  30911. getCapacity(): number;
  30912. /**
  30913. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30914. * to override the particles.
  30915. */
  30916. forceDepthWrite: boolean;
  30917. /**
  30918. * Gets or set the number of active particles
  30919. */
  30920. activeParticleCount: number;
  30921. private _preWarmDone;
  30922. /**
  30923. * Is this system ready to be used/rendered
  30924. * @return true if the system is ready
  30925. */
  30926. isReady(): boolean;
  30927. /**
  30928. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30929. * @returns True if it has been started, otherwise false.
  30930. */
  30931. isStarted(): boolean;
  30932. /**
  30933. * Starts the particle system and begins to emit
  30934. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30935. */
  30936. start(delay?: number): void;
  30937. /**
  30938. * Stops the particle system.
  30939. */
  30940. stop(): void;
  30941. /**
  30942. * Remove all active particles
  30943. */
  30944. reset(): void;
  30945. /**
  30946. * Returns the string "GPUParticleSystem"
  30947. * @returns a string containing the class name
  30948. */
  30949. getClassName(): string;
  30950. private _colorGradientsTexture;
  30951. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  30952. /**
  30953. * Adds a new color gradient
  30954. * @param gradient defines the gradient to use (between 0 and 1)
  30955. * @param color1 defines the color to affect to the specified gradient
  30956. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30957. * @returns the current particle system
  30958. */
  30959. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  30960. /**
  30961. * Remove a specific color gradient
  30962. * @param gradient defines the gradient to remove
  30963. * @returns the current particle system
  30964. */
  30965. removeColorGradient(gradient: number): GPUParticleSystem;
  30966. private _angularSpeedGradientsTexture;
  30967. private _sizeGradientsTexture;
  30968. private _velocityGradientsTexture;
  30969. private _limitVelocityGradientsTexture;
  30970. private _dragGradientsTexture;
  30971. private _addFactorGradient;
  30972. /**
  30973. * Adds a new size gradient
  30974. * @param gradient defines the gradient to use (between 0 and 1)
  30975. * @param factor defines the size factor to affect to the specified gradient
  30976. * @returns the current particle system
  30977. */
  30978. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  30979. /**
  30980. * Remove a specific size gradient
  30981. * @param gradient defines the gradient to remove
  30982. * @returns the current particle system
  30983. */
  30984. removeSizeGradient(gradient: number): GPUParticleSystem;
  30985. /**
  30986. * Adds a new angular speed gradient
  30987. * @param gradient defines the gradient to use (between 0 and 1)
  30988. * @param factor defines the angular speed to affect to the specified gradient
  30989. * @returns the current particle system
  30990. */
  30991. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  30992. /**
  30993. * Remove a specific angular speed gradient
  30994. * @param gradient defines the gradient to remove
  30995. * @returns the current particle system
  30996. */
  30997. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  30998. /**
  30999. * Adds a new velocity gradient
  31000. * @param gradient defines the gradient to use (between 0 and 1)
  31001. * @param factor defines the velocity to affect to the specified gradient
  31002. * @returns the current particle system
  31003. */
  31004. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  31005. /**
  31006. * Remove a specific velocity gradient
  31007. * @param gradient defines the gradient to remove
  31008. * @returns the current particle system
  31009. */
  31010. removeVelocityGradient(gradient: number): GPUParticleSystem;
  31011. /**
  31012. * Adds a new limit velocity gradient
  31013. * @param gradient defines the gradient to use (between 0 and 1)
  31014. * @param factor defines the limit velocity value to affect to the specified gradient
  31015. * @returns the current particle system
  31016. */
  31017. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  31018. /**
  31019. * Remove a specific limit velocity gradient
  31020. * @param gradient defines the gradient to remove
  31021. * @returns the current particle system
  31022. */
  31023. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  31024. /**
  31025. * Adds a new drag gradient
  31026. * @param gradient defines the gradient to use (between 0 and 1)
  31027. * @param factor defines the drag value to affect to the specified gradient
  31028. * @returns the current particle system
  31029. */
  31030. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  31031. /**
  31032. * Remove a specific drag gradient
  31033. * @param gradient defines the gradient to remove
  31034. * @returns the current particle system
  31035. */
  31036. removeDragGradient(gradient: number): GPUParticleSystem;
  31037. /**
  31038. * Not supported by GPUParticleSystem
  31039. * @param gradient defines the gradient to use (between 0 and 1)
  31040. * @param factor defines the emit rate value to affect to the specified gradient
  31041. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31042. * @returns the current particle system
  31043. */
  31044. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31045. /**
  31046. * Not supported by GPUParticleSystem
  31047. * @param gradient defines the gradient to remove
  31048. * @returns the current particle system
  31049. */
  31050. removeEmitRateGradient(gradient: number): IParticleSystem;
  31051. /**
  31052. * Not supported by GPUParticleSystem
  31053. * @param gradient defines the gradient to use (between 0 and 1)
  31054. * @param factor defines the start size value to affect to the specified gradient
  31055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31056. * @returns the current particle system
  31057. */
  31058. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31059. /**
  31060. * Not supported by GPUParticleSystem
  31061. * @param gradient defines the gradient to remove
  31062. * @returns the current particle system
  31063. */
  31064. removeStartSizeGradient(gradient: number): IParticleSystem;
  31065. /**
  31066. * Not supported by GPUParticleSystem
  31067. * @param gradient defines the gradient to use (between 0 and 1)
  31068. * @param min defines the color remap minimal range
  31069. * @param max defines the color remap maximal range
  31070. * @returns the current particle system
  31071. */
  31072. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31073. /**
  31074. * Not supported by GPUParticleSystem
  31075. * @param gradient defines the gradient to remove
  31076. * @returns the current particle system
  31077. */
  31078. removeColorRemapGradient(gradient: number): IParticleSystem;
  31079. /**
  31080. * Not supported by GPUParticleSystem
  31081. * @param gradient defines the gradient to use (between 0 and 1)
  31082. * @param min defines the alpha remap minimal range
  31083. * @param max defines the alpha remap maximal range
  31084. * @returns the current particle system
  31085. */
  31086. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31087. /**
  31088. * Not supported by GPUParticleSystem
  31089. * @param gradient defines the gradient to remove
  31090. * @returns the current particle system
  31091. */
  31092. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31093. /**
  31094. * Not supported by GPUParticleSystem
  31095. * @param gradient defines the gradient to use (between 0 and 1)
  31096. * @param color defines the color to affect to the specified gradient
  31097. * @returns the current particle system
  31098. */
  31099. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31100. /**
  31101. * Not supported by GPUParticleSystem
  31102. * @param gradient defines the gradient to remove
  31103. * @returns the current particle system
  31104. */
  31105. removeRampGradient(gradient: number): IParticleSystem;
  31106. /**
  31107. * Not supported by GPUParticleSystem
  31108. * @returns the list of ramp gradients
  31109. */
  31110. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31111. /**
  31112. * Not supported by GPUParticleSystem
  31113. * Gets or sets a boolean indicating that ramp gradients must be used
  31114. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31115. */
  31116. useRampGradients: boolean;
  31117. /**
  31118. * Not supported by GPUParticleSystem
  31119. * @param gradient defines the gradient to use (between 0 and 1)
  31120. * @param factor defines the life time factor to affect to the specified gradient
  31121. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31122. * @returns the current particle system
  31123. */
  31124. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31125. /**
  31126. * Not supported by GPUParticleSystem
  31127. * @param gradient defines the gradient to remove
  31128. * @returns the current particle system
  31129. */
  31130. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31131. /**
  31132. * Instantiates a GPU particle system.
  31133. * 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.
  31134. * @param name The name of the particle system
  31135. * @param options The options used to create the system
  31136. * @param scene The scene the particle system belongs to
  31137. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31138. */
  31139. constructor(name: string, options: Partial<{
  31140. capacity: number;
  31141. randomTextureSize: number;
  31142. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  31143. protected _reset(): void;
  31144. private _createUpdateVAO;
  31145. private _createRenderVAO;
  31146. private _initialize;
  31147. /** @hidden */
  31148. _recreateUpdateEffect(): void;
  31149. /** @hidden */
  31150. _recreateRenderEffect(): void;
  31151. /**
  31152. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  31153. * @param preWarm defines if we are in the pre-warmimg phase
  31154. */
  31155. animate(preWarm?: boolean): void;
  31156. private _createFactorGradientTexture;
  31157. private _createSizeGradientTexture;
  31158. private _createAngularSpeedGradientTexture;
  31159. private _createVelocityGradientTexture;
  31160. private _createLimitVelocityGradientTexture;
  31161. private _createDragGradientTexture;
  31162. private _createColorGradientTexture;
  31163. /**
  31164. * Renders the particle system in its current state
  31165. * @param preWarm defines if the system should only update the particles but not render them
  31166. * @returns the current number of particles
  31167. */
  31168. render(preWarm?: boolean): number;
  31169. /**
  31170. * Rebuilds the particle system
  31171. */
  31172. rebuild(): void;
  31173. private _releaseBuffers;
  31174. private _releaseVAOs;
  31175. /**
  31176. * Disposes the particle system and free the associated resources
  31177. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31178. */
  31179. dispose(disposeTexture?: boolean): void;
  31180. /**
  31181. * Clones the particle system.
  31182. * @param name The name of the cloned object
  31183. * @param newEmitter The new emitter to use
  31184. * @returns the cloned particle system
  31185. */
  31186. clone(name: string, newEmitter: any): GPUParticleSystem;
  31187. /**
  31188. * Serializes the particle system to a JSON object.
  31189. * @returns the JSON object
  31190. */
  31191. serialize(): any;
  31192. /**
  31193. * Parses a JSON object to create a GPU particle system.
  31194. * @param parsedParticleSystem The JSON object to parse
  31195. * @param scene The scene to create the particle system in
  31196. * @param rootUrl The root url to use to load external dependencies like texture
  31197. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  31198. * @returns the parsed GPU particle system
  31199. */
  31200. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  31201. }
  31202. }
  31203. declare module BABYLON {
  31204. /**
  31205. * Interface representing a particle system in Babylon.js.
  31206. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  31207. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  31208. */
  31209. interface IParticleSystem {
  31210. /**
  31211. * List of animations used by the particle system.
  31212. */
  31213. animations: Animation[];
  31214. /**
  31215. * The id of the Particle system.
  31216. */
  31217. id: string;
  31218. /**
  31219. * The name of the Particle system.
  31220. */
  31221. name: string;
  31222. /**
  31223. * The emitter represents the Mesh or position we are attaching the particle system to.
  31224. */
  31225. emitter: Nullable<AbstractMesh | Vector3>;
  31226. /**
  31227. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  31228. */
  31229. isBillboardBased: boolean;
  31230. /**
  31231. * The rendering group used by the Particle system to chose when to render.
  31232. */
  31233. renderingGroupId: number;
  31234. /**
  31235. * The layer mask we are rendering the particles through.
  31236. */
  31237. layerMask: number;
  31238. /**
  31239. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31240. */
  31241. updateSpeed: number;
  31242. /**
  31243. * The amount of time the particle system is running (depends of the overall update speed).
  31244. */
  31245. targetStopDuration: number;
  31246. /**
  31247. * The texture used to render each particle. (this can be a spritesheet)
  31248. */
  31249. particleTexture: Nullable<Texture>;
  31250. /**
  31251. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  31252. */
  31253. blendMode: number;
  31254. /**
  31255. * Minimum life time of emitting particles.
  31256. */
  31257. minLifeTime: number;
  31258. /**
  31259. * Maximum life time of emitting particles.
  31260. */
  31261. maxLifeTime: number;
  31262. /**
  31263. * Minimum Size of emitting particles.
  31264. */
  31265. minSize: number;
  31266. /**
  31267. * Maximum Size of emitting particles.
  31268. */
  31269. maxSize: number;
  31270. /**
  31271. * Minimum scale of emitting particles on X axis.
  31272. */
  31273. minScaleX: number;
  31274. /**
  31275. * Maximum scale of emitting particles on X axis.
  31276. */
  31277. maxScaleX: number;
  31278. /**
  31279. * Minimum scale of emitting particles on Y axis.
  31280. */
  31281. minScaleY: number;
  31282. /**
  31283. * Maximum scale of emitting particles on Y axis.
  31284. */
  31285. maxScaleY: number;
  31286. /**
  31287. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31288. */
  31289. color1: Color4;
  31290. /**
  31291. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31292. */
  31293. color2: Color4;
  31294. /**
  31295. * Color the particle will have at the end of its lifetime.
  31296. */
  31297. colorDead: Color4;
  31298. /**
  31299. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  31300. */
  31301. emitRate: number;
  31302. /**
  31303. * You can use gravity if you want to give an orientation to your particles.
  31304. */
  31305. gravity: Vector3;
  31306. /**
  31307. * Minimum power of emitting particles.
  31308. */
  31309. minEmitPower: number;
  31310. /**
  31311. * Maximum power of emitting particles.
  31312. */
  31313. maxEmitPower: number;
  31314. /**
  31315. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31316. */
  31317. minAngularSpeed: number;
  31318. /**
  31319. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31320. */
  31321. maxAngularSpeed: number;
  31322. /**
  31323. * Gets or sets the minimal initial rotation in radians.
  31324. */
  31325. minInitialRotation: number;
  31326. /**
  31327. * Gets or sets the maximal initial rotation in radians.
  31328. */
  31329. maxInitialRotation: number;
  31330. /**
  31331. * The particle emitter type defines the emitter used by the particle system.
  31332. * It can be for example box, sphere, or cone...
  31333. */
  31334. particleEmitterType: Nullable<IParticleEmitterType>;
  31335. /**
  31336. * Defines the delay in milliseconds before starting the system (0 by default)
  31337. */
  31338. startDelay: number;
  31339. /**
  31340. * 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
  31341. */
  31342. preWarmCycles: number;
  31343. /**
  31344. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  31345. */
  31346. preWarmStepOffset: number;
  31347. /**
  31348. * 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)
  31349. */
  31350. spriteCellChangeSpeed: number;
  31351. /**
  31352. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  31353. */
  31354. startSpriteCellID: number;
  31355. /**
  31356. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  31357. */
  31358. endSpriteCellID: number;
  31359. /**
  31360. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  31361. */
  31362. spriteCellWidth: number;
  31363. /**
  31364. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  31365. */
  31366. spriteCellHeight: number;
  31367. /**
  31368. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31369. */
  31370. spriteRandomStartCell: boolean;
  31371. /**
  31372. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  31373. */
  31374. isAnimationSheetEnabled: boolean;
  31375. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31376. translationPivot: Vector2;
  31377. /**
  31378. * Gets or sets a texture used to add random noise to particle positions
  31379. */
  31380. noiseTexture: Nullable<BaseTexture>;
  31381. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31382. noiseStrength: Vector3;
  31383. /**
  31384. * Gets or sets the billboard mode to use when isBillboardBased = true.
  31385. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  31386. */
  31387. billboardMode: number;
  31388. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  31389. limitVelocityDamping: number;
  31390. /**
  31391. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31392. */
  31393. beginAnimationOnStart: boolean;
  31394. /**
  31395. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31396. */
  31397. beginAnimationFrom: number;
  31398. /**
  31399. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31400. */
  31401. beginAnimationTo: number;
  31402. /**
  31403. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31404. */
  31405. beginAnimationLoop: boolean;
  31406. /**
  31407. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31408. */
  31409. disposeOnStop: boolean;
  31410. /**
  31411. * Gets the maximum number of particles active at the same time.
  31412. * @returns The max number of active particles.
  31413. */
  31414. getCapacity(): number;
  31415. /**
  31416. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31417. * @returns True if it has been started, otherwise false.
  31418. */
  31419. isStarted(): boolean;
  31420. /**
  31421. * Animates the particle system for this frame.
  31422. */
  31423. animate(): void;
  31424. /**
  31425. * Renders the particle system in its current state.
  31426. * @returns the current number of particles
  31427. */
  31428. render(): number;
  31429. /**
  31430. * Dispose the particle system and frees its associated resources.
  31431. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31432. */
  31433. dispose(disposeTexture?: boolean): void;
  31434. /**
  31435. * Clones the particle system.
  31436. * @param name The name of the cloned object
  31437. * @param newEmitter The new emitter to use
  31438. * @returns the cloned particle system
  31439. */
  31440. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  31441. /**
  31442. * Serializes the particle system to a JSON object.
  31443. * @returns the JSON object
  31444. */
  31445. serialize(): any;
  31446. /**
  31447. * Rebuild the particle system
  31448. */
  31449. rebuild(): void;
  31450. /**
  31451. * Starts the particle system and begins to emit
  31452. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  31453. */
  31454. start(delay?: number): void;
  31455. /**
  31456. * Stops the particle system.
  31457. */
  31458. stop(): void;
  31459. /**
  31460. * Remove all active particles
  31461. */
  31462. reset(): void;
  31463. /**
  31464. * Is this system ready to be used/rendered
  31465. * @return true if the system is ready
  31466. */
  31467. isReady(): boolean;
  31468. /**
  31469. * Adds a new color gradient
  31470. * @param gradient defines the gradient to use (between 0 and 1)
  31471. * @param color1 defines the color to affect to the specified gradient
  31472. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31473. * @returns the current particle system
  31474. */
  31475. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31476. /**
  31477. * Remove a specific color gradient
  31478. * @param gradient defines the gradient to remove
  31479. * @returns the current particle system
  31480. */
  31481. removeColorGradient(gradient: number): IParticleSystem;
  31482. /**
  31483. * Adds a new size gradient
  31484. * @param gradient defines the gradient to use (between 0 and 1)
  31485. * @param factor defines the size factor to affect to the specified gradient
  31486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31487. * @returns the current particle system
  31488. */
  31489. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31490. /**
  31491. * Remove a specific size gradient
  31492. * @param gradient defines the gradient to remove
  31493. * @returns the current particle system
  31494. */
  31495. removeSizeGradient(gradient: number): IParticleSystem;
  31496. /**
  31497. * Gets the current list of color gradients.
  31498. * You must use addColorGradient and removeColorGradient to udpate this list
  31499. * @returns the list of color gradients
  31500. */
  31501. getColorGradients(): Nullable<Array<ColorGradient>>;
  31502. /**
  31503. * Gets the current list of size gradients.
  31504. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31505. * @returns the list of size gradients
  31506. */
  31507. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31508. /**
  31509. * Gets the current list of angular speed gradients.
  31510. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31511. * @returns the list of angular speed gradients
  31512. */
  31513. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31514. /**
  31515. * Adds a new angular speed gradient
  31516. * @param gradient defines the gradient to use (between 0 and 1)
  31517. * @param factor defines the angular speed to affect to the specified gradient
  31518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31519. * @returns the current particle system
  31520. */
  31521. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31522. /**
  31523. * Remove a specific angular speed gradient
  31524. * @param gradient defines the gradient to remove
  31525. * @returns the current particle system
  31526. */
  31527. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31528. /**
  31529. * Gets the current list of velocity gradients.
  31530. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31531. * @returns the list of velocity gradients
  31532. */
  31533. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31534. /**
  31535. * Adds a new velocity gradient
  31536. * @param gradient defines the gradient to use (between 0 and 1)
  31537. * @param factor defines the velocity to affect to the specified gradient
  31538. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31539. * @returns the current particle system
  31540. */
  31541. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31542. /**
  31543. * Remove a specific velocity gradient
  31544. * @param gradient defines the gradient to remove
  31545. * @returns the current particle system
  31546. */
  31547. removeVelocityGradient(gradient: number): IParticleSystem;
  31548. /**
  31549. * Gets the current list of limit velocity gradients.
  31550. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31551. * @returns the list of limit velocity gradients
  31552. */
  31553. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31554. /**
  31555. * Adds a new limit velocity gradient
  31556. * @param gradient defines the gradient to use (between 0 and 1)
  31557. * @param factor defines the limit velocity to affect to the specified gradient
  31558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31559. * @returns the current particle system
  31560. */
  31561. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31562. /**
  31563. * Remove a specific limit velocity gradient
  31564. * @param gradient defines the gradient to remove
  31565. * @returns the current particle system
  31566. */
  31567. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31568. /**
  31569. * Adds a new drag gradient
  31570. * @param gradient defines the gradient to use (between 0 and 1)
  31571. * @param factor defines the drag to affect to the specified gradient
  31572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31573. * @returns the current particle system
  31574. */
  31575. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31576. /**
  31577. * Remove a specific drag gradient
  31578. * @param gradient defines the gradient to remove
  31579. * @returns the current particle system
  31580. */
  31581. removeDragGradient(gradient: number): IParticleSystem;
  31582. /**
  31583. * Gets the current list of drag gradients.
  31584. * You must use addDragGradient and removeDragGradient to udpate this list
  31585. * @returns the list of drag gradients
  31586. */
  31587. getDragGradients(): Nullable<Array<FactorGradient>>;
  31588. /**
  31589. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31590. * @param gradient defines the gradient to use (between 0 and 1)
  31591. * @param factor defines the emit rate to affect to the specified gradient
  31592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31593. * @returns the current particle system
  31594. */
  31595. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31596. /**
  31597. * Remove a specific emit rate gradient
  31598. * @param gradient defines the gradient to remove
  31599. * @returns the current particle system
  31600. */
  31601. removeEmitRateGradient(gradient: number): IParticleSystem;
  31602. /**
  31603. * Gets the current list of emit rate gradients.
  31604. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31605. * @returns the list of emit rate gradients
  31606. */
  31607. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31608. /**
  31609. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31610. * @param gradient defines the gradient to use (between 0 and 1)
  31611. * @param factor defines the start size to affect to the specified gradient
  31612. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31613. * @returns the current particle system
  31614. */
  31615. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31616. /**
  31617. * Remove a specific start size gradient
  31618. * @param gradient defines the gradient to remove
  31619. * @returns the current particle system
  31620. */
  31621. removeStartSizeGradient(gradient: number): IParticleSystem;
  31622. /**
  31623. * Gets the current list of start size gradients.
  31624. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31625. * @returns the list of start size gradients
  31626. */
  31627. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31628. /**
  31629. * Adds a new life time gradient
  31630. * @param gradient defines the gradient to use (between 0 and 1)
  31631. * @param factor defines the life time factor to affect to the specified gradient
  31632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31633. * @returns the current particle system
  31634. */
  31635. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31636. /**
  31637. * Remove a specific life time gradient
  31638. * @param gradient defines the gradient to remove
  31639. * @returns the current particle system
  31640. */
  31641. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31642. /**
  31643. * Gets the current list of life time gradients.
  31644. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31645. * @returns the list of life time gradients
  31646. */
  31647. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31648. /**
  31649. * Gets the current list of color gradients.
  31650. * You must use addColorGradient and removeColorGradient to udpate this list
  31651. * @returns the list of color gradients
  31652. */
  31653. getColorGradients(): Nullable<Array<ColorGradient>>;
  31654. /**
  31655. * Adds a new ramp gradient used to remap particle colors
  31656. * @param gradient defines the gradient to use (between 0 and 1)
  31657. * @param color defines the color to affect to the specified gradient
  31658. * @returns the current particle system
  31659. */
  31660. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31661. /**
  31662. * Gets the current list of ramp gradients.
  31663. * You must use addRampGradient and removeRampGradient to udpate this list
  31664. * @returns the list of ramp gradients
  31665. */
  31666. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31667. /** Gets or sets a boolean indicating that ramp gradients must be used
  31668. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31669. */
  31670. useRampGradients: boolean;
  31671. /**
  31672. * Adds a new color remap gradient
  31673. * @param gradient defines the gradient to use (between 0 and 1)
  31674. * @param min defines the color remap minimal range
  31675. * @param max defines the color remap maximal range
  31676. * @returns the current particle system
  31677. */
  31678. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31679. /**
  31680. * Gets the current list of color remap gradients.
  31681. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31682. * @returns the list of color remap gradients
  31683. */
  31684. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31685. /**
  31686. * Adds a new alpha remap gradient
  31687. * @param gradient defines the gradient to use (between 0 and 1)
  31688. * @param min defines the alpha remap minimal range
  31689. * @param max defines the alpha remap maximal range
  31690. * @returns the current particle system
  31691. */
  31692. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31693. /**
  31694. * Gets the current list of alpha remap gradients.
  31695. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31696. * @returns the list of alpha remap gradients
  31697. */
  31698. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31699. /**
  31700. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31701. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31702. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31703. * @returns the emitter
  31704. */
  31705. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31706. /**
  31707. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31708. * @param radius The radius of the hemisphere to emit from
  31709. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31710. * @returns the emitter
  31711. */
  31712. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  31713. /**
  31714. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31715. * @param radius The radius of the sphere to emit from
  31716. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31717. * @returns the emitter
  31718. */
  31719. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  31720. /**
  31721. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31722. * @param radius The radius of the sphere to emit from
  31723. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31724. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31725. * @returns the emitter
  31726. */
  31727. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31728. /**
  31729. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31730. * @param radius The radius of the emission cylinder
  31731. * @param height The height of the emission cylinder
  31732. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31733. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31734. * @returns the emitter
  31735. */
  31736. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  31737. /**
  31738. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31739. * @param radius The radius of the cylinder to emit from
  31740. * @param height The height of the emission cylinder
  31741. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31742. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31743. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31744. * @returns the emitter
  31745. */
  31746. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31747. /**
  31748. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31749. * @param radius The radius of the cone to emit from
  31750. * @param angle The base angle of the cone
  31751. * @returns the emitter
  31752. */
  31753. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  31754. /**
  31755. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31756. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31757. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31758. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31759. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31760. * @returns the emitter
  31761. */
  31762. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31763. /**
  31764. * Get hosting scene
  31765. * @returns the scene
  31766. */
  31767. getScene(): Scene;
  31768. }
  31769. }
  31770. declare module BABYLON {
  31771. /**
  31772. * A particle represents one of the element emitted by a particle system.
  31773. * This is mainly define by its coordinates, direction, velocity and age.
  31774. */
  31775. class Particle {
  31776. /**
  31777. * The particle system the particle belongs to.
  31778. */
  31779. particleSystem: ParticleSystem;
  31780. private static _Count;
  31781. /**
  31782. * Unique ID of the particle
  31783. */
  31784. id: number;
  31785. /**
  31786. * The world position of the particle in the scene.
  31787. */
  31788. position: Vector3;
  31789. /**
  31790. * The world direction of the particle in the scene.
  31791. */
  31792. direction: Vector3;
  31793. /**
  31794. * The color of the particle.
  31795. */
  31796. color: Color4;
  31797. /**
  31798. * The color change of the particle per step.
  31799. */
  31800. colorStep: Color4;
  31801. /**
  31802. * Defines how long will the life of the particle be.
  31803. */
  31804. lifeTime: number;
  31805. /**
  31806. * The current age of the particle.
  31807. */
  31808. age: number;
  31809. /**
  31810. * The current size of the particle.
  31811. */
  31812. size: number;
  31813. /**
  31814. * The current scale of the particle.
  31815. */
  31816. scale: Vector2;
  31817. /**
  31818. * The current angle of the particle.
  31819. */
  31820. angle: number;
  31821. /**
  31822. * Defines how fast is the angle changing.
  31823. */
  31824. angularSpeed: number;
  31825. /**
  31826. * Defines the cell index used by the particle to be rendered from a sprite.
  31827. */
  31828. cellIndex: number;
  31829. /**
  31830. * The information required to support color remapping
  31831. */
  31832. remapData: Vector4;
  31833. /** @hidden */
  31834. _randomCellOffset?: number;
  31835. /** @hidden */
  31836. _initialDirection: Nullable<Vector3>;
  31837. /** @hidden */
  31838. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  31839. /** @hidden */
  31840. _initialStartSpriteCellID: number;
  31841. /** @hidden */
  31842. _initialEndSpriteCellID: number;
  31843. /** @hidden */
  31844. _currentColorGradient: Nullable<ColorGradient>;
  31845. /** @hidden */
  31846. _currentColor1: Color4;
  31847. /** @hidden */
  31848. _currentColor2: Color4;
  31849. /** @hidden */
  31850. _currentSizeGradient: Nullable<FactorGradient>;
  31851. /** @hidden */
  31852. _currentSize1: number;
  31853. /** @hidden */
  31854. _currentSize2: number;
  31855. /** @hidden */
  31856. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  31857. /** @hidden */
  31858. _currentAngularSpeed1: number;
  31859. /** @hidden */
  31860. _currentAngularSpeed2: number;
  31861. /** @hidden */
  31862. _currentVelocityGradient: Nullable<FactorGradient>;
  31863. /** @hidden */
  31864. _currentVelocity1: number;
  31865. /** @hidden */
  31866. _currentVelocity2: number;
  31867. /** @hidden */
  31868. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  31869. /** @hidden */
  31870. _currentLimitVelocity1: number;
  31871. /** @hidden */
  31872. _currentLimitVelocity2: number;
  31873. /** @hidden */
  31874. _currentDragGradient: Nullable<FactorGradient>;
  31875. /** @hidden */
  31876. _currentDrag1: number;
  31877. /** @hidden */
  31878. _currentDrag2: number;
  31879. /** @hidden */
  31880. _randomNoiseCoordinates1: Vector3;
  31881. /** @hidden */
  31882. _randomNoiseCoordinates2: Vector3;
  31883. /**
  31884. * Creates a new instance Particle
  31885. * @param particleSystem the particle system the particle belongs to
  31886. */
  31887. constructor(
  31888. /**
  31889. * The particle system the particle belongs to.
  31890. */
  31891. particleSystem: ParticleSystem);
  31892. private updateCellInfoFromSystem;
  31893. /**
  31894. * Defines how the sprite cell index is updated for the particle
  31895. */
  31896. updateCellIndex(): void;
  31897. /** @hidden */
  31898. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  31899. /** @hidden */
  31900. _inheritParticleInfoToSubEmitters(): void;
  31901. /** @hidden */
  31902. _reset(): void;
  31903. /**
  31904. * Copy the properties of particle to another one.
  31905. * @param other the particle to copy the information to.
  31906. */
  31907. copyTo(other: Particle): void;
  31908. }
  31909. }
  31910. declare module BABYLON {
  31911. /**
  31912. * This class is made for on one-liner static method to help creating particle system set.
  31913. */
  31914. class ParticleHelper {
  31915. /**
  31916. * Gets or sets base Assets URL
  31917. */
  31918. static BaseAssetsUrl: string;
  31919. /**
  31920. * Create a default particle system that you can tweak
  31921. * @param emitter defines the emitter to use
  31922. * @param capacity defines the system capacity (default is 500 particles)
  31923. * @param scene defines the hosting scene
  31924. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  31925. * @returns the new Particle system
  31926. */
  31927. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  31928. /**
  31929. * This is the main static method (one-liner) of this helper to create different particle systems
  31930. * @param type This string represents the type to the particle system to create
  31931. * @param scene The scene where the particle system should live
  31932. * @param gpu If the system will use gpu
  31933. * @returns the ParticleSystemSet created
  31934. */
  31935. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  31936. /**
  31937. * Static function used to export a particle system to a ParticleSystemSet variable.
  31938. * Please note that the emitter shape is not exported
  31939. * @param systems defines the particle systems to export
  31940. * @returns the created particle system set
  31941. */
  31942. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  31943. }
  31944. }
  31945. declare module BABYLON {
  31946. /**
  31947. * This represents a particle system in Babylon.
  31948. * 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.
  31949. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31950. * @example https://doc.babylonjs.com/babylon101/particles
  31951. */
  31952. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  31953. /**
  31954. * Billboard mode will only apply to Y axis
  31955. */
  31956. static readonly BILLBOARDMODE_Y: number;
  31957. /**
  31958. * Billboard mode will apply to all axes
  31959. */
  31960. static readonly BILLBOARDMODE_ALL: number;
  31961. /**
  31962. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  31963. */
  31964. static readonly BILLBOARDMODE_STRETCHED: number;
  31965. /**
  31966. * This function can be defined to provide custom update for active particles.
  31967. * This function will be called instead of regular update (age, position, color, etc.).
  31968. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  31969. */
  31970. updateFunction: (particles: Particle[]) => void;
  31971. private _emitterWorldMatrix;
  31972. /**
  31973. * This function can be defined to specify initial direction for every new particle.
  31974. * It by default use the emitterType defined function
  31975. */
  31976. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  31977. /**
  31978. * This function can be defined to specify initial position for every new particle.
  31979. * It by default use the emitterType defined function
  31980. */
  31981. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  31982. /**
  31983. * @hidden
  31984. */
  31985. _inheritedVelocityOffset: Vector3;
  31986. /**
  31987. * An event triggered when the system is disposed
  31988. */
  31989. onDisposeObservable: Observable<ParticleSystem>;
  31990. private _onDisposeObserver;
  31991. /**
  31992. * Sets a callback that will be triggered when the system is disposed
  31993. */
  31994. onDispose: () => void;
  31995. private _particles;
  31996. private _epsilon;
  31997. private _capacity;
  31998. private _stockParticles;
  31999. private _newPartsExcess;
  32000. private _vertexData;
  32001. private _vertexBuffer;
  32002. private _vertexBuffers;
  32003. private _spriteBuffer;
  32004. private _indexBuffer;
  32005. private _effect;
  32006. private _customEffect;
  32007. private _cachedDefines;
  32008. private _scaledColorStep;
  32009. private _colorDiff;
  32010. private _scaledDirection;
  32011. private _scaledGravity;
  32012. private _currentRenderId;
  32013. private _alive;
  32014. private _useInstancing;
  32015. private _started;
  32016. private _stopped;
  32017. private _actualFrame;
  32018. private _scaledUpdateSpeed;
  32019. private _vertexBufferSize;
  32020. /** @hidden */
  32021. _currentEmitRateGradient: Nullable<FactorGradient>;
  32022. /** @hidden */
  32023. _currentEmitRate1: number;
  32024. /** @hidden */
  32025. _currentEmitRate2: number;
  32026. /** @hidden */
  32027. _currentStartSizeGradient: Nullable<FactorGradient>;
  32028. /** @hidden */
  32029. _currentStartSize1: number;
  32030. /** @hidden */
  32031. _currentStartSize2: number;
  32032. private readonly _rawTextureWidth;
  32033. private _rampGradientsTexture;
  32034. private _useRampGradients;
  32035. /** Gets or sets a boolean indicating that ramp gradients must be used
  32036. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  32037. */
  32038. useRampGradients: boolean;
  32039. /**
  32040. * 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.
  32041. * 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: [])
  32042. */
  32043. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  32044. private _subEmitters;
  32045. /**
  32046. * @hidden
  32047. * If the particle systems emitter should be disposed when the particle system is disposed
  32048. */
  32049. _disposeEmitterOnDispose: boolean;
  32050. /**
  32051. * The current active Sub-systems, this property is used by the root particle system only.
  32052. */
  32053. activeSubSystems: Array<ParticleSystem>;
  32054. private _rootParticleSystem;
  32055. /**
  32056. * Gets the current list of active particles
  32057. */
  32058. readonly particles: Particle[];
  32059. /**
  32060. * Returns the string "ParticleSystem"
  32061. * @returns a string containing the class name
  32062. */
  32063. getClassName(): string;
  32064. /**
  32065. * Instantiates a particle system.
  32066. * 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.
  32067. * @param name The name of the particle system
  32068. * @param capacity The max number of particles alive at the same time
  32069. * @param scene The scene the particle system belongs to
  32070. * @param customEffect a custom effect used to change the way particles are rendered by default
  32071. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  32072. * @param epsilon Offset used to render the particles
  32073. */
  32074. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  32075. private _addFactorGradient;
  32076. private _removeFactorGradient;
  32077. /**
  32078. * Adds a new life time gradient
  32079. * @param gradient defines the gradient to use (between 0 and 1)
  32080. * @param factor defines the life time factor to affect to the specified gradient
  32081. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32082. * @returns the current particle system
  32083. */
  32084. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32085. /**
  32086. * Remove a specific life time gradient
  32087. * @param gradient defines the gradient to remove
  32088. * @returns the current particle system
  32089. */
  32090. removeLifeTimeGradient(gradient: number): IParticleSystem;
  32091. /**
  32092. * Adds a new size gradient
  32093. * @param gradient defines the gradient to use (between 0 and 1)
  32094. * @param factor defines the size factor to affect to the specified gradient
  32095. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32096. * @returns the current particle system
  32097. */
  32098. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32099. /**
  32100. * Remove a specific size gradient
  32101. * @param gradient defines the gradient to remove
  32102. * @returns the current particle system
  32103. */
  32104. removeSizeGradient(gradient: number): IParticleSystem;
  32105. /**
  32106. * Adds a new color remap gradient
  32107. * @param gradient defines the gradient to use (between 0 and 1)
  32108. * @param min defines the color remap minimal range
  32109. * @param max defines the color remap maximal range
  32110. * @returns the current particle system
  32111. */
  32112. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32113. /**
  32114. * Remove a specific color remap gradient
  32115. * @param gradient defines the gradient to remove
  32116. * @returns the current particle system
  32117. */
  32118. removeColorRemapGradient(gradient: number): IParticleSystem;
  32119. /**
  32120. * Adds a new alpha remap gradient
  32121. * @param gradient defines the gradient to use (between 0 and 1)
  32122. * @param min defines the alpha remap minimal range
  32123. * @param max defines the alpha remap maximal range
  32124. * @returns the current particle system
  32125. */
  32126. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32127. /**
  32128. * Remove a specific alpha remap gradient
  32129. * @param gradient defines the gradient to remove
  32130. * @returns the current particle system
  32131. */
  32132. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  32133. /**
  32134. * Adds a new angular speed gradient
  32135. * @param gradient defines the gradient to use (between 0 and 1)
  32136. * @param factor defines the angular speed to affect to the specified gradient
  32137. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32138. * @returns the current particle system
  32139. */
  32140. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32141. /**
  32142. * Remove a specific angular speed gradient
  32143. * @param gradient defines the gradient to remove
  32144. * @returns the current particle system
  32145. */
  32146. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  32147. /**
  32148. * Adds a new velocity gradient
  32149. * @param gradient defines the gradient to use (between 0 and 1)
  32150. * @param factor defines the velocity to affect to the specified gradient
  32151. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32152. * @returns the current particle system
  32153. */
  32154. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32155. /**
  32156. * Remove a specific velocity gradient
  32157. * @param gradient defines the gradient to remove
  32158. * @returns the current particle system
  32159. */
  32160. removeVelocityGradient(gradient: number): IParticleSystem;
  32161. /**
  32162. * Adds a new limit velocity gradient
  32163. * @param gradient defines the gradient to use (between 0 and 1)
  32164. * @param factor defines the limit velocity value to affect to the specified gradient
  32165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32166. * @returns the current particle system
  32167. */
  32168. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32169. /**
  32170. * Remove a specific limit velocity gradient
  32171. * @param gradient defines the gradient to remove
  32172. * @returns the current particle system
  32173. */
  32174. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  32175. /**
  32176. * Adds a new drag gradient
  32177. * @param gradient defines the gradient to use (between 0 and 1)
  32178. * @param factor defines the drag value to affect to the specified gradient
  32179. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32180. * @returns the current particle system
  32181. */
  32182. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32183. /**
  32184. * Remove a specific drag gradient
  32185. * @param gradient defines the gradient to remove
  32186. * @returns the current particle system
  32187. */
  32188. removeDragGradient(gradient: number): IParticleSystem;
  32189. /**
  32190. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  32191. * @param gradient defines the gradient to use (between 0 and 1)
  32192. * @param factor defines the emit rate value to affect to the specified gradient
  32193. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32194. * @returns the current particle system
  32195. */
  32196. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32197. /**
  32198. * Remove a specific emit rate gradient
  32199. * @param gradient defines the gradient to remove
  32200. * @returns the current particle system
  32201. */
  32202. removeEmitRateGradient(gradient: number): IParticleSystem;
  32203. /**
  32204. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  32205. * @param gradient defines the gradient to use (between 0 and 1)
  32206. * @param factor defines the start size value to affect to the specified gradient
  32207. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32208. * @returns the current particle system
  32209. */
  32210. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32211. /**
  32212. * Remove a specific start size gradient
  32213. * @param gradient defines the gradient to remove
  32214. * @returns the current particle system
  32215. */
  32216. removeStartSizeGradient(gradient: number): IParticleSystem;
  32217. private _createRampGradientTexture;
  32218. /**
  32219. * Gets the current list of ramp gradients.
  32220. * You must use addRampGradient and removeRampGradient to udpate this list
  32221. * @returns the list of ramp gradients
  32222. */
  32223. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32224. /**
  32225. * Adds a new ramp gradient used to remap particle colors
  32226. * @param gradient defines the gradient to use (between 0 and 1)
  32227. * @param color defines the color to affect to the specified gradient
  32228. * @returns the current particle system
  32229. */
  32230. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  32231. /**
  32232. * Remove a specific ramp gradient
  32233. * @param gradient defines the gradient to remove
  32234. * @returns the current particle system
  32235. */
  32236. removeRampGradient(gradient: number): ParticleSystem;
  32237. /**
  32238. * Adds a new color gradient
  32239. * @param gradient defines the gradient to use (between 0 and 1)
  32240. * @param color1 defines the color to affect to the specified gradient
  32241. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32242. * @returns this particle system
  32243. */
  32244. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32245. /**
  32246. * Remove a specific color gradient
  32247. * @param gradient defines the gradient to remove
  32248. * @returns this particle system
  32249. */
  32250. removeColorGradient(gradient: number): IParticleSystem;
  32251. private _fetchR;
  32252. protected _reset(): void;
  32253. private _resetEffect;
  32254. private _createVertexBuffers;
  32255. private _createIndexBuffer;
  32256. /**
  32257. * Gets the maximum number of particles active at the same time.
  32258. * @returns The max number of active particles.
  32259. */
  32260. getCapacity(): number;
  32261. /**
  32262. * Gets whether there are still active particles in the system.
  32263. * @returns True if it is alive, otherwise false.
  32264. */
  32265. isAlive(): boolean;
  32266. /**
  32267. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32268. * @returns True if it has been started, otherwise false.
  32269. */
  32270. isStarted(): boolean;
  32271. private _prepareSubEmitterInternalArray;
  32272. /**
  32273. * Starts the particle system and begins to emit
  32274. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  32275. */
  32276. start(delay?: number): void;
  32277. /**
  32278. * Stops the particle system.
  32279. * @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.
  32280. */
  32281. stop(stopSubEmitters?: boolean): void;
  32282. /**
  32283. * Remove all active particles
  32284. */
  32285. reset(): void;
  32286. /**
  32287. * @hidden (for internal use only)
  32288. */
  32289. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  32290. /**
  32291. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  32292. * Its lifetime will start back at 0.
  32293. */
  32294. recycleParticle: (particle: Particle) => void;
  32295. private _stopSubEmitters;
  32296. private _createParticle;
  32297. private _removeFromRoot;
  32298. private _emitFromParticle;
  32299. private _update;
  32300. /** @hidden */
  32301. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  32302. /** @hidden */
  32303. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  32304. /** @hidden */
  32305. private _getEffect;
  32306. /**
  32307. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32308. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  32309. */
  32310. animate(preWarmOnly?: boolean): void;
  32311. private _appendParticleVertices;
  32312. /**
  32313. * Rebuilds the particle system.
  32314. */
  32315. rebuild(): void;
  32316. /**
  32317. * Is this system ready to be used/rendered
  32318. * @return true if the system is ready
  32319. */
  32320. isReady(): boolean;
  32321. private _render;
  32322. /**
  32323. * Renders the particle system in its current state.
  32324. * @returns the current number of particles
  32325. */
  32326. render(): number;
  32327. /**
  32328. * Disposes the particle system and free the associated resources
  32329. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32330. */
  32331. dispose(disposeTexture?: boolean): void;
  32332. /**
  32333. * Clones the particle system.
  32334. * @param name The name of the cloned object
  32335. * @param newEmitter The new emitter to use
  32336. * @returns the cloned particle system
  32337. */
  32338. clone(name: string, newEmitter: any): ParticleSystem;
  32339. /**
  32340. * Serializes the particle system to a JSON object.
  32341. * @returns the JSON object
  32342. */
  32343. serialize(): any;
  32344. /** @hidden */
  32345. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  32346. /** @hidden */
  32347. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  32348. /**
  32349. * Parses a JSON object to create a particle system.
  32350. * @param parsedParticleSystem The JSON object to parse
  32351. * @param scene The scene to create the particle system in
  32352. * @param rootUrl The root url to use to load external dependencies like texture
  32353. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32354. * @returns the Parsed particle system
  32355. */
  32356. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  32357. }
  32358. }
  32359. declare module BABYLON {
  32360. interface Engine {
  32361. /**
  32362. * Create an effect to use with particle systems.
  32363. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  32364. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  32365. * @param uniformsNames defines a list of attribute names
  32366. * @param samplers defines an array of string used to represent textures
  32367. * @param defines defines the string containing the defines to use to compile the shaders
  32368. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32369. * @param onCompiled defines a function to call when the effect creation is successful
  32370. * @param onError defines a function to call when the effect creation has failed
  32371. * @returns the new Effect
  32372. */
  32373. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  32374. }
  32375. interface Mesh {
  32376. /**
  32377. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  32378. * @returns an array of IParticleSystem
  32379. */
  32380. getEmittedParticleSystems(): IParticleSystem[];
  32381. /**
  32382. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  32383. * @returns an array of IParticleSystem
  32384. */
  32385. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  32386. }
  32387. }
  32388. declare module BABYLON {
  32389. /**
  32390. * Represents a set of particle systems working together to create a specific effect
  32391. */
  32392. class ParticleSystemSet implements IDisposable {
  32393. private _emitterCreationOptions;
  32394. private _emitterNode;
  32395. /**
  32396. * Gets the particle system list
  32397. */
  32398. systems: IParticleSystem[];
  32399. /**
  32400. * Gets the emitter node used with this set
  32401. */
  32402. readonly emitterNode: Nullable<TransformNode>;
  32403. /**
  32404. * Creates a new emitter mesh as a sphere
  32405. * @param options defines the options used to create the sphere
  32406. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  32407. * @param scene defines the hosting scene
  32408. */
  32409. setEmitterAsSphere(options: {
  32410. diameter: number;
  32411. segments: number;
  32412. color: Color3;
  32413. }, renderingGroupId: number, scene: Scene): void;
  32414. /**
  32415. * Starts all particle systems of the set
  32416. * @param emitter defines an optional mesh to use as emitter for the particle systems
  32417. */
  32418. start(emitter?: AbstractMesh): void;
  32419. /**
  32420. * Release all associated resources
  32421. */
  32422. dispose(): void;
  32423. /**
  32424. * Serialize the set into a JSON compatible object
  32425. * @returns a JSON compatible representation of the set
  32426. */
  32427. serialize(): any;
  32428. /**
  32429. * Parse a new ParticleSystemSet from a serialized source
  32430. * @param data defines a JSON compatible representation of the set
  32431. * @param scene defines the hosting scene
  32432. * @param gpu defines if we want GPU particles or CPU particles
  32433. * @returns a new ParticleSystemSet
  32434. */
  32435. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  32436. }
  32437. }
  32438. declare module BABYLON {
  32439. /**
  32440. * Represents one particle of a solid particle system.
  32441. */
  32442. class SolidParticle {
  32443. /**
  32444. * particle global index
  32445. */
  32446. idx: number;
  32447. /**
  32448. * The color of the particle
  32449. */
  32450. color: Nullable<Color4>;
  32451. /**
  32452. * The world space position of the particle.
  32453. */
  32454. position: Vector3;
  32455. /**
  32456. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32457. */
  32458. rotation: Vector3;
  32459. /**
  32460. * The world space rotation quaternion of the particle.
  32461. */
  32462. rotationQuaternion: Nullable<Quaternion>;
  32463. /**
  32464. * The scaling of the particle.
  32465. */
  32466. scaling: Vector3;
  32467. /**
  32468. * The uvs of the particle.
  32469. */
  32470. uvs: Vector4;
  32471. /**
  32472. * The current speed of the particle.
  32473. */
  32474. velocity: Vector3;
  32475. /**
  32476. * The pivot point in the particle local space.
  32477. */
  32478. pivot: Vector3;
  32479. /**
  32480. * Must the particle be translated from its pivot point in its local space ?
  32481. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32482. * Default : false
  32483. */
  32484. translateFromPivot: boolean;
  32485. /**
  32486. * Is the particle active or not ?
  32487. */
  32488. alive: boolean;
  32489. /**
  32490. * Is the particle visible or not ?
  32491. */
  32492. isVisible: boolean;
  32493. /**
  32494. * Index of this particle in the global "positions" array (Internal use)
  32495. * @hidden
  32496. */
  32497. _pos: number;
  32498. /**
  32499. * @hidden Index of this particle in the global "indices" array (Internal use)
  32500. */
  32501. _ind: number;
  32502. /**
  32503. * @hidden ModelShape of this particle (Internal use)
  32504. */
  32505. _model: ModelShape;
  32506. /**
  32507. * ModelShape id of this particle
  32508. */
  32509. shapeId: number;
  32510. /**
  32511. * Index of the particle in its shape id (Internal use)
  32512. */
  32513. idxInShape: number;
  32514. /**
  32515. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32516. */
  32517. _modelBoundingInfo: BoundingInfo;
  32518. /**
  32519. * @hidden Particle BoundingInfo object (Internal use)
  32520. */
  32521. _boundingInfo: BoundingInfo;
  32522. /**
  32523. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32524. */
  32525. _sps: SolidParticleSystem;
  32526. /**
  32527. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32528. */
  32529. _stillInvisible: boolean;
  32530. /**
  32531. * @hidden Last computed particle rotation matrix
  32532. */
  32533. _rotationMatrix: number[];
  32534. /**
  32535. * Parent particle Id, if any.
  32536. * Default null.
  32537. */
  32538. parentId: Nullable<number>;
  32539. /**
  32540. * @hidden Internal global position in the SPS.
  32541. */
  32542. _globalPosition: Vector3;
  32543. /**
  32544. * Creates a Solid Particle object.
  32545. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32546. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  32547. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32548. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32549. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32550. * @param shapeId (integer) is the model shape identifier in the SPS.
  32551. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32552. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32553. */
  32554. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  32555. /**
  32556. * Legacy support, changed scale to scaling
  32557. */
  32558. /**
  32559. * Legacy support, changed scale to scaling
  32560. */
  32561. scale: Vector3;
  32562. /**
  32563. * Legacy support, changed quaternion to rotationQuaternion
  32564. */
  32565. /**
  32566. * Legacy support, changed quaternion to rotationQuaternion
  32567. */
  32568. quaternion: Nullable<Quaternion>;
  32569. /**
  32570. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32571. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32572. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32573. * @returns true if it intersects
  32574. */
  32575. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32576. /**
  32577. * get the rotation matrix of the particle
  32578. * @hidden
  32579. */
  32580. getRotationMatrix(m: Matrix): void;
  32581. }
  32582. /**
  32583. * Represents the shape of the model used by one particle of a solid particle system.
  32584. * SPS internal tool, don't use it manually.
  32585. */
  32586. class ModelShape {
  32587. /**
  32588. * The shape id
  32589. * @hidden
  32590. */
  32591. shapeID: number;
  32592. /**
  32593. * flat array of model positions (internal use)
  32594. * @hidden
  32595. */
  32596. _shape: Vector3[];
  32597. /**
  32598. * flat array of model UVs (internal use)
  32599. * @hidden
  32600. */
  32601. _shapeUV: number[];
  32602. /**
  32603. * length of the shape in the model indices array (internal use)
  32604. * @hidden
  32605. */
  32606. _indicesLength: number;
  32607. /**
  32608. * Custom position function (internal use)
  32609. * @hidden
  32610. */
  32611. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32612. /**
  32613. * Custom vertex function (internal use)
  32614. * @hidden
  32615. */
  32616. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32617. /**
  32618. * 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.
  32619. * SPS internal tool, don't use it manually.
  32620. * @hidden
  32621. */
  32622. 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>);
  32623. }
  32624. /**
  32625. * Represents a Depth Sorted Particle in the solid particle system.
  32626. */
  32627. class DepthSortedParticle {
  32628. /**
  32629. * Index of the particle in the "indices" array
  32630. */
  32631. ind: number;
  32632. /**
  32633. * Length of the particle shape in the "indices" array
  32634. */
  32635. indicesLength: number;
  32636. /**
  32637. * Squared distance from the particle to the camera
  32638. */
  32639. sqDistance: number;
  32640. }
  32641. }
  32642. declare module BABYLON {
  32643. /**
  32644. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32645. *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.
  32646. * The SPS is also a particle system. It provides some methods to manage the particles.
  32647. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32648. *
  32649. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  32650. */
  32651. class SolidParticleSystem implements IDisposable {
  32652. /**
  32653. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32654. * Example : var p = SPS.particles[i];
  32655. */
  32656. particles: SolidParticle[];
  32657. /**
  32658. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32659. */
  32660. nbParticles: number;
  32661. /**
  32662. * If the particles must ever face the camera (default false). Useful for planar particles.
  32663. */
  32664. billboard: boolean;
  32665. /**
  32666. * Recompute normals when adding a shape
  32667. */
  32668. recomputeNormals: boolean;
  32669. /**
  32670. * This a counter ofr your own usage. It's not set by any SPS functions.
  32671. */
  32672. counter: number;
  32673. /**
  32674. * The SPS name. This name is also given to the underlying mesh.
  32675. */
  32676. name: string;
  32677. /**
  32678. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32679. */
  32680. mesh: Mesh;
  32681. /**
  32682. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32683. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  32684. */
  32685. vars: any;
  32686. /**
  32687. * This array is populated when the SPS is set as 'pickable'.
  32688. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32689. * Each element of this array is an object `{idx: int, faceId: int}`.
  32690. * `idx` is the picked particle index in the `SPS.particles` array
  32691. * `faceId` is the picked face index counted within this particle.
  32692. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  32693. */
  32694. pickedParticles: {
  32695. idx: number;
  32696. faceId: number;
  32697. }[];
  32698. /**
  32699. * This array is populated when `enableDepthSort` is set to true.
  32700. * Each element of this array is an instance of the class DepthSortedParticle.
  32701. */
  32702. depthSortedParticles: DepthSortedParticle[];
  32703. /**
  32704. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32705. * @hidden
  32706. */
  32707. _bSphereOnly: boolean;
  32708. /**
  32709. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32710. * @hidden
  32711. */
  32712. _bSphereRadiusFactor: number;
  32713. private _scene;
  32714. private _positions;
  32715. private _indices;
  32716. private _normals;
  32717. private _colors;
  32718. private _uvs;
  32719. private _indices32;
  32720. private _positions32;
  32721. private _normals32;
  32722. private _fixedNormal32;
  32723. private _colors32;
  32724. private _uvs32;
  32725. private _index;
  32726. private _updatable;
  32727. private _pickable;
  32728. private _isVisibilityBoxLocked;
  32729. private _alwaysVisible;
  32730. private _depthSort;
  32731. private _shapeCounter;
  32732. private _copy;
  32733. private _color;
  32734. private _computeParticleColor;
  32735. private _computeParticleTexture;
  32736. private _computeParticleRotation;
  32737. private _computeParticleVertex;
  32738. private _computeBoundingBox;
  32739. private _depthSortParticles;
  32740. private _camera;
  32741. private _mustUnrotateFixedNormals;
  32742. private _particlesIntersect;
  32743. private _needs32Bits;
  32744. /**
  32745. * Creates a SPS (Solid Particle System) object.
  32746. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32747. * @param scene (Scene) is the scene in which the SPS is added.
  32748. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32749. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32750. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32751. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32752. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32753. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32754. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32755. */
  32756. constructor(name: string, scene: Scene, options?: {
  32757. updatable?: boolean;
  32758. isPickable?: boolean;
  32759. enableDepthSort?: boolean;
  32760. particleIntersection?: boolean;
  32761. boundingSphereOnly?: boolean;
  32762. bSphereRadiusFactor?: number;
  32763. });
  32764. /**
  32765. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32766. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32767. * @returns the created mesh
  32768. */
  32769. buildMesh(): Mesh;
  32770. /**
  32771. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32772. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32773. * Thus the particles generated from `digest()` have their property `position` set yet.
  32774. * @param mesh ( Mesh ) is the mesh to be digested
  32775. * @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
  32776. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32777. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32778. * @returns the current SPS
  32779. */
  32780. digest(mesh: Mesh, options?: {
  32781. facetNb?: number;
  32782. number?: number;
  32783. delta?: number;
  32784. }): SolidParticleSystem;
  32785. private _unrotateFixedNormals;
  32786. private _resetCopy;
  32787. private _meshBuilder;
  32788. private _posToShape;
  32789. private _uvsToShapeUV;
  32790. private _addParticle;
  32791. /**
  32792. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32793. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  32794. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32795. * @param nb (positive integer) the number of particles to be created from this model
  32796. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32797. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32798. * @returns the number of shapes in the system
  32799. */
  32800. addShape(mesh: Mesh, nb: number, options?: {
  32801. positionFunction?: any;
  32802. vertexFunction?: any;
  32803. }): number;
  32804. private _rebuildParticle;
  32805. /**
  32806. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32807. * @returns the SPS.
  32808. */
  32809. rebuildMesh(): SolidParticleSystem;
  32810. /**
  32811. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32812. * This method calls `updateParticle()` for each particle of the SPS.
  32813. * For an animated SPS, it is usually called within the render loop.
  32814. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32815. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32816. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32817. * @returns the SPS.
  32818. */
  32819. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32820. /**
  32821. * Disposes the SPS.
  32822. */
  32823. dispose(): void;
  32824. /**
  32825. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32826. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32827. * @returns the SPS.
  32828. */
  32829. refreshVisibleSize(): SolidParticleSystem;
  32830. /**
  32831. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32832. * @param size the size (float) of the visibility box
  32833. * note : this doesn't lock the SPS mesh bounding box.
  32834. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32835. */
  32836. setVisibilityBox(size: number): void;
  32837. /**
  32838. * Gets whether the SPS as always visible or not
  32839. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32840. */
  32841. /**
  32842. * Sets the SPS as always visible or not
  32843. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32844. */
  32845. isAlwaysVisible: boolean;
  32846. /**
  32847. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32848. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32849. */
  32850. /**
  32851. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32852. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32853. */
  32854. isVisibilityBoxLocked: boolean;
  32855. /**
  32856. * Tells to `setParticles()` to compute the particle rotations or not.
  32857. * Default value : true. The SPS is faster when it's set to false.
  32858. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32859. */
  32860. /**
  32861. * Gets if `setParticles()` computes the particle rotations or not.
  32862. * Default value : true. The SPS is faster when it's set to false.
  32863. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32864. */
  32865. computeParticleRotation: boolean;
  32866. /**
  32867. * Tells to `setParticles()` to compute the particle colors or not.
  32868. * Default value : true. The SPS is faster when it's set to false.
  32869. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32870. */
  32871. /**
  32872. * Gets if `setParticles()` computes the particle colors or not.
  32873. * Default value : true. The SPS is faster when it's set to false.
  32874. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32875. */
  32876. computeParticleColor: boolean;
  32877. /**
  32878. * Gets if `setParticles()` computes the particle textures or not.
  32879. * Default value : true. The SPS is faster when it's set to false.
  32880. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32881. */
  32882. computeParticleTexture: boolean;
  32883. /**
  32884. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32885. * Default value : false. The SPS is faster when it's set to false.
  32886. * Note : the particle custom vertex positions aren't stored values.
  32887. */
  32888. /**
  32889. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32890. * Default value : false. The SPS is faster when it's set to false.
  32891. * Note : the particle custom vertex positions aren't stored values.
  32892. */
  32893. computeParticleVertex: boolean;
  32894. /**
  32895. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32896. */
  32897. /**
  32898. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32899. */
  32900. computeBoundingBox: boolean;
  32901. /**
  32902. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32903. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32904. * Default : `true`
  32905. */
  32906. /**
  32907. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32908. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32909. * Default : `true`
  32910. */
  32911. depthSortParticles: boolean;
  32912. /**
  32913. * This function does nothing. It may be overwritten to set all the particle first values.
  32914. * The SPS doesn't call this function, you may have to call it by your own.
  32915. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32916. */
  32917. initParticles(): void;
  32918. /**
  32919. * This function does nothing. It may be overwritten to recycle a particle.
  32920. * The SPS doesn't call this function, you may have to call it by your own.
  32921. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32922. * @param particle The particle to recycle
  32923. * @returns the recycled particle
  32924. */
  32925. recycleParticle(particle: SolidParticle): SolidParticle;
  32926. /**
  32927. * Updates a particle : this function should be overwritten by the user.
  32928. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32929. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32930. * @example : just set a particle position or velocity and recycle conditions
  32931. * @param particle The particle to update
  32932. * @returns the updated particle
  32933. */
  32934. updateParticle(particle: SolidParticle): SolidParticle;
  32935. /**
  32936. * Updates a vertex of a particle : it can be overwritten by the user.
  32937. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32938. * @param particle the current particle
  32939. * @param vertex the current index of the current particle
  32940. * @param pt the index of the current vertex in the particle shape
  32941. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  32942. * @example : just set a vertex particle position
  32943. * @returns the updated vertex
  32944. */
  32945. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  32946. /**
  32947. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32948. * This does nothing and may be overwritten by the user.
  32949. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32950. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32951. * @param update the boolean update value actually passed to setParticles()
  32952. */
  32953. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32954. /**
  32955. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32956. * This will be passed three parameters.
  32957. * This does nothing and may be overwritten by the user.
  32958. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32959. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32960. * @param update the boolean update value actually passed to setParticles()
  32961. */
  32962. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32963. }
  32964. }
  32965. declare module BABYLON {
  32966. /**
  32967. * Type of sub emitter
  32968. */
  32969. enum SubEmitterType {
  32970. /**
  32971. * Attached to the particle over it's lifetime
  32972. */
  32973. ATTACHED = 0,
  32974. /**
  32975. * Created when the particle dies
  32976. */
  32977. END = 1
  32978. }
  32979. /**
  32980. * Sub emitter class used to emit particles from an existing particle
  32981. */
  32982. class SubEmitter {
  32983. /**
  32984. * the particle system to be used by the sub emitter
  32985. */
  32986. particleSystem: ParticleSystem;
  32987. /**
  32988. * Type of the submitter (Default: END)
  32989. */
  32990. type: SubEmitterType;
  32991. /**
  32992. * 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)
  32993. * Note: This only is supported when using an emitter of type Mesh
  32994. */
  32995. inheritDirection: boolean;
  32996. /**
  32997. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  32998. */
  32999. inheritedVelocityAmount: number;
  33000. /**
  33001. * Creates a sub emitter
  33002. * @param particleSystem the particle system to be used by the sub emitter
  33003. */
  33004. constructor(
  33005. /**
  33006. * the particle system to be used by the sub emitter
  33007. */
  33008. particleSystem: ParticleSystem);
  33009. /**
  33010. * Clones the sub emitter
  33011. * @returns the cloned sub emitter
  33012. */
  33013. clone(): SubEmitter;
  33014. /**
  33015. * Serialize current object to a JSON object
  33016. * @returns the serialized object
  33017. */
  33018. serialize(): any;
  33019. /**
  33020. * Creates a new SubEmitter from a serialized JSON version
  33021. * @param serializationObject defines the JSON object to read from
  33022. * @param scene defines the hosting scene
  33023. * @param rootUrl defines the rootUrl for data loading
  33024. * @returns a new SubEmitter
  33025. */
  33026. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  33027. /** Release associated resources */
  33028. dispose(): void;
  33029. }
  33030. }
  33031. declare module BABYLON {
  33032. /**
  33033. * Interface used to describe a physics joint
  33034. */
  33035. interface PhysicsImpostorJoint {
  33036. /** Defines the main impostor to which the joint is linked */
  33037. mainImpostor: PhysicsImpostor;
  33038. /** Defines the impostor that is connected to the main impostor using this joint */
  33039. connectedImpostor: PhysicsImpostor;
  33040. /** Defines the joint itself */
  33041. joint: PhysicsJoint;
  33042. }
  33043. /** @hidden */
  33044. interface IPhysicsEnginePlugin {
  33045. world: any;
  33046. name: string;
  33047. setGravity(gravity: Vector3): void;
  33048. setTimeStep(timeStep: number): void;
  33049. getTimeStep(): number;
  33050. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  33051. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33052. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33053. generatePhysicsBody(impostor: PhysicsImpostor): void;
  33054. removePhysicsBody(impostor: PhysicsImpostor): void;
  33055. generateJoint(joint: PhysicsImpostorJoint): void;
  33056. removeJoint(joint: PhysicsImpostorJoint): void;
  33057. isSupported(): boolean;
  33058. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33059. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33060. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33061. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33062. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33063. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33064. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33065. getBodyMass(impostor: PhysicsImpostor): number;
  33066. getBodyFriction(impostor: PhysicsImpostor): number;
  33067. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33068. getBodyRestitution(impostor: PhysicsImpostor): number;
  33069. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33070. sleepBody(impostor: PhysicsImpostor): void;
  33071. wakeUpBody(impostor: PhysicsImpostor): void;
  33072. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33073. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  33074. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33075. getRadius(impostor: PhysicsImpostor): number;
  33076. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33077. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33078. dispose(): void;
  33079. }
  33080. /**
  33081. * Interface used to define a physics engine
  33082. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33083. */
  33084. interface IPhysicsEngine {
  33085. /**
  33086. * Gets the gravity vector used by the simulation
  33087. */
  33088. gravity: Vector3;
  33089. /**
  33090. * Sets the gravity vector used by the simulation
  33091. * @param gravity defines the gravity vector to use
  33092. */
  33093. setGravity(gravity: Vector3): void;
  33094. /**
  33095. * Set the time step of the physics engine.
  33096. * Default is 1/60.
  33097. * To slow it down, enter 1/600 for example.
  33098. * To speed it up, 1/30
  33099. * @param newTimeStep the new timestep to apply to this world.
  33100. */
  33101. setTimeStep(newTimeStep: number): void;
  33102. /**
  33103. * Get the time step of the physics engine.
  33104. * @returns the current time step
  33105. */
  33106. getTimeStep(): number;
  33107. /**
  33108. * Release all resources
  33109. */
  33110. dispose(): void;
  33111. /**
  33112. * Gets the name of the current physics plugin
  33113. * @returns the name of the plugin
  33114. */
  33115. getPhysicsPluginName(): string;
  33116. /**
  33117. * Adding a new impostor for the impostor tracking.
  33118. * This will be done by the impostor itself.
  33119. * @param impostor the impostor to add
  33120. */
  33121. addImpostor(impostor: PhysicsImpostor): void;
  33122. /**
  33123. * Remove an impostor from the engine.
  33124. * This impostor and its mesh will not longer be updated by the physics engine.
  33125. * @param impostor the impostor to remove
  33126. */
  33127. removeImpostor(impostor: PhysicsImpostor): void;
  33128. /**
  33129. * Add a joint to the physics engine
  33130. * @param mainImpostor defines the main impostor to which the joint is added.
  33131. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33132. * @param joint defines the joint that will connect both impostors.
  33133. */
  33134. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33135. /**
  33136. * Removes a joint from the simulation
  33137. * @param mainImpostor defines the impostor used with the joint
  33138. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33139. * @param joint defines the joint to remove
  33140. */
  33141. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): 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. * Called by the scene. No need to call it.
  33166. * @param delta defines the timespam between frames
  33167. */
  33168. _step(delta: number): void;
  33169. }
  33170. }
  33171. declare module BABYLON {
  33172. /**
  33173. * Class used to control physics engine
  33174. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33175. */
  33176. class PhysicsEngine implements IPhysicsEngine {
  33177. private _physicsPlugin;
  33178. /**
  33179. * Global value used to control the smallest number supported by the simulation
  33180. */
  33181. static Epsilon: number;
  33182. private _impostors;
  33183. private _joints;
  33184. /**
  33185. * Gets the gravity vector used by the simulation
  33186. */
  33187. gravity: Vector3;
  33188. /**
  33189. * Creates a new Physics Engine
  33190. * @param gravity defines the gravity vector used by the simulation
  33191. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  33192. */
  33193. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  33194. /**
  33195. * Sets the gravity vector used by the simulation
  33196. * @param gravity defines the gravity vector to use
  33197. */
  33198. setGravity(gravity: Vector3): void;
  33199. /**
  33200. * Set the time step of the physics engine.
  33201. * Default is 1/60.
  33202. * To slow it down, enter 1/600 for example.
  33203. * To speed it up, 1/30
  33204. * @param newTimeStep defines the new timestep to apply to this world.
  33205. */
  33206. setTimeStep(newTimeStep?: number): void;
  33207. /**
  33208. * Get the time step of the physics engine.
  33209. * @returns the current time step
  33210. */
  33211. getTimeStep(): number;
  33212. /**
  33213. * Release all resources
  33214. */
  33215. dispose(): void;
  33216. /**
  33217. * Gets the name of the current physics plugin
  33218. * @returns the name of the plugin
  33219. */
  33220. getPhysicsPluginName(): string;
  33221. /**
  33222. * Adding a new impostor for the impostor tracking.
  33223. * This will be done by the impostor itself.
  33224. * @param impostor the impostor to add
  33225. */
  33226. addImpostor(impostor: PhysicsImpostor): void;
  33227. /**
  33228. * Remove an impostor from the engine.
  33229. * This impostor and its mesh will not longer be updated by the physics engine.
  33230. * @param impostor the impostor to remove
  33231. */
  33232. removeImpostor(impostor: PhysicsImpostor): void;
  33233. /**
  33234. * Add a joint to the physics engine
  33235. * @param mainImpostor defines the main impostor to which the joint is added.
  33236. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33237. * @param joint defines the joint that will connect both impostors.
  33238. */
  33239. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33240. /**
  33241. * Removes a joint from the simulation
  33242. * @param mainImpostor defines the impostor used with the joint
  33243. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33244. * @param joint defines the joint to remove
  33245. */
  33246. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33247. /**
  33248. * Called by the scene. No need to call it.
  33249. * @param delta defines the timespam between frames
  33250. */
  33251. _step(delta: number): void;
  33252. /**
  33253. * Gets the current plugin used to run the simulation
  33254. * @returns current plugin
  33255. */
  33256. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33257. /**
  33258. * Gets the list of physic impostors
  33259. * @returns an array of PhysicsImpostor
  33260. */
  33261. getImpostors(): Array<PhysicsImpostor>;
  33262. /**
  33263. * Gets the impostor for a physics enabled object
  33264. * @param object defines the object impersonated by the impostor
  33265. * @returns the PhysicsImpostor or null if not found
  33266. */
  33267. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33268. /**
  33269. * Gets the impostor for a physics body object
  33270. * @param body defines physics body used by the impostor
  33271. * @returns the PhysicsImpostor or null if not found
  33272. */
  33273. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33274. }
  33275. }
  33276. declare module BABYLON {
  33277. interface Scene {
  33278. /** @hidden (Backing field) */
  33279. _physicsEngine: Nullable<IPhysicsEngine>;
  33280. /**
  33281. * Gets the current physics engine
  33282. * @returns a IPhysicsEngine or null if none attached
  33283. */
  33284. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  33285. /**
  33286. * Enables physics to the current scene
  33287. * @param gravity defines the scene's gravity for the physics engine
  33288. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  33289. * @return a boolean indicating if the physics engine was initialized
  33290. */
  33291. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  33292. /**
  33293. * Disables and disposes the physics engine associated with the scene
  33294. */
  33295. disablePhysicsEngine(): void;
  33296. /**
  33297. * Gets a boolean indicating if there is an active physics engine
  33298. * @returns a boolean indicating if there is an active physics engine
  33299. */
  33300. isPhysicsEnabled(): boolean;
  33301. /**
  33302. * Deletes a physics compound impostor
  33303. * @param compound defines the compound to delete
  33304. */
  33305. deleteCompoundImpostor(compound: any): void;
  33306. /**
  33307. * An event triggered when physic simulation is about to be run
  33308. */
  33309. onBeforePhysicsObservable: Observable<Scene>;
  33310. /**
  33311. * An event triggered when physic simulation has been done
  33312. */
  33313. onAfterPhysicsObservable: Observable<Scene>;
  33314. }
  33315. interface AbstractMesh {
  33316. /** @hidden */
  33317. _physicsImpostor: Nullable<PhysicsImpostor>;
  33318. /**
  33319. * Gets or sets impostor used for physic simulation
  33320. * @see http://doc.babylonjs.com/features/physics_engine
  33321. */
  33322. physicsImpostor: Nullable<PhysicsImpostor>;
  33323. /**
  33324. * Gets the current physics impostor
  33325. * @see http://doc.babylonjs.com/features/physics_engine
  33326. * @returns a physics impostor or null
  33327. */
  33328. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  33329. /** Apply a physic impulse to the mesh
  33330. * @param force defines the force to apply
  33331. * @param contactPoint defines where to apply the force
  33332. * @returns the current mesh
  33333. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33334. */
  33335. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  33336. /**
  33337. * Creates a physic joint between two meshes
  33338. * @param otherMesh defines the other mesh to use
  33339. * @param pivot1 defines the pivot to use on this mesh
  33340. * @param pivot2 defines the pivot to use on the other mesh
  33341. * @param options defines additional options (can be plugin dependent)
  33342. * @returns the current mesh
  33343. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  33344. */
  33345. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  33346. /** @hidden */
  33347. _disposePhysicsObserver: Nullable<Observer<Node>>;
  33348. }
  33349. /**
  33350. * Defines the physics engine scene component responsible to manage a physics engine
  33351. */
  33352. class PhysicsEngineSceneComponent implements ISceneComponent {
  33353. /**
  33354. * The component name helpful to identify the component in the list of scene components.
  33355. */
  33356. readonly name: string;
  33357. /**
  33358. * The scene the component belongs to.
  33359. */
  33360. scene: Scene;
  33361. /**
  33362. * Creates a new instance of the component for the given scene
  33363. * @param scene Defines the scene to register the component in
  33364. */
  33365. constructor(scene: Scene);
  33366. /**
  33367. * Registers the component in a given scene
  33368. */
  33369. register(): void;
  33370. /**
  33371. * Rebuilds the elements related to this component in case of
  33372. * context lost for instance.
  33373. */
  33374. rebuild(): void;
  33375. /**
  33376. * Disposes the component and the associated ressources
  33377. */
  33378. dispose(): void;
  33379. }
  33380. }
  33381. declare module BABYLON {
  33382. /**
  33383. * A helper for physics simulations
  33384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33385. */
  33386. class PhysicsHelper {
  33387. private _scene;
  33388. private _physicsEngine;
  33389. /**
  33390. * Initializes the Physics helper
  33391. * @param scene Babylon.js scene
  33392. */
  33393. constructor(scene: Scene);
  33394. /**
  33395. * Applies a radial explosion impulse
  33396. * @param origin the origin of the explosion
  33397. * @param radius the explosion radius
  33398. * @param strength the explosion strength
  33399. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33400. * @returns A physics radial explosion event, or null
  33401. */
  33402. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33403. /**
  33404. * Applies a radial explosion force
  33405. * @param origin the origin of the explosion
  33406. * @param radius the explosion radius
  33407. * @param strength the explosion strength
  33408. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33409. * @returns A physics radial explosion event, or null
  33410. */
  33411. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33412. /**
  33413. * Creates a gravitational field
  33414. * @param origin the origin of the explosion
  33415. * @param radius the explosion radius
  33416. * @param strength the explosion strength
  33417. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33418. * @returns A physics gravitational field event, or null
  33419. */
  33420. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  33421. /**
  33422. * Creates a physics updraft event
  33423. * @param origin the origin of the updraft
  33424. * @param radius the radius of the updraft
  33425. * @param strength the strength of the updraft
  33426. * @param height the height of the updraft
  33427. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  33428. * @returns A physics updraft event, or null
  33429. */
  33430. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  33431. /**
  33432. * Creates a physics vortex event
  33433. * @param origin the of the vortex
  33434. * @param radius the radius of the vortex
  33435. * @param strength the strength of the vortex
  33436. * @param height the height of the vortex
  33437. * @returns a Physics vortex event, or null
  33438. * A physics vortex event or null
  33439. */
  33440. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  33441. }
  33442. /**
  33443. * Represents a physics radial explosion event
  33444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33445. */
  33446. class PhysicsRadialExplosionEvent {
  33447. private _scene;
  33448. private _sphere;
  33449. private _sphereOptions;
  33450. private _rays;
  33451. private _dataFetched;
  33452. /**
  33453. * Initializes a radial explosioin event
  33454. * @param scene BabylonJS scene
  33455. */
  33456. constructor(scene: Scene);
  33457. /**
  33458. * Returns the data related to the radial explosion event (sphere & rays).
  33459. * @returns The radial explosion event data
  33460. */
  33461. getData(): PhysicsRadialExplosionEventData;
  33462. /**
  33463. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  33464. * @param impostor A physics imposter
  33465. * @param origin the origin of the explosion
  33466. * @param radius the explosion radius
  33467. * @param strength the explosion strength
  33468. * @param falloff possible options: Constant & Linear
  33469. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  33470. */
  33471. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  33472. /**
  33473. * Disposes the sphere.
  33474. * @param force Specifies if the sphere should be disposed by force
  33475. */
  33476. dispose(force?: boolean): void;
  33477. /*** Helpers ***/
  33478. private _prepareSphere;
  33479. private _intersectsWithSphere;
  33480. }
  33481. /**
  33482. * Represents a gravitational field event
  33483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33484. */
  33485. class PhysicsGravitationalFieldEvent {
  33486. private _physicsHelper;
  33487. private _scene;
  33488. private _origin;
  33489. private _radius;
  33490. private _strength;
  33491. private _falloff;
  33492. private _tickCallback;
  33493. private _sphere;
  33494. private _dataFetched;
  33495. /**
  33496. * Initializes the physics gravitational field event
  33497. * @param physicsHelper A physics helper
  33498. * @param scene BabylonJS scene
  33499. * @param origin The origin position of the gravitational field event
  33500. * @param radius The radius of the gravitational field event
  33501. * @param strength The strength of the gravitational field event
  33502. * @param falloff The falloff for the gravitational field event
  33503. */
  33504. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  33505. /**
  33506. * Returns the data related to the gravitational field event (sphere).
  33507. * @returns A gravitational field event
  33508. */
  33509. getData(): PhysicsGravitationalFieldEventData;
  33510. /**
  33511. * Enables the gravitational field.
  33512. */
  33513. enable(): void;
  33514. /**
  33515. * Disables the gravitational field.
  33516. */
  33517. disable(): void;
  33518. /**
  33519. * Disposes the sphere.
  33520. * @param force The force to dispose from the gravitational field event
  33521. */
  33522. dispose(force?: boolean): void;
  33523. private _tick;
  33524. }
  33525. /**
  33526. * Represents a physics updraft event
  33527. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33528. */
  33529. class PhysicsUpdraftEvent {
  33530. private _scene;
  33531. private _origin;
  33532. private _radius;
  33533. private _strength;
  33534. private _height;
  33535. private _updraftMode;
  33536. private _physicsEngine;
  33537. private _originTop;
  33538. private _originDirection;
  33539. private _tickCallback;
  33540. private _cylinder;
  33541. private _cylinderPosition;
  33542. private _dataFetched;
  33543. /**
  33544. * Initializes the physics updraft event
  33545. * @param _scene BabylonJS scene
  33546. * @param _origin The origin position of the updraft
  33547. * @param _radius The radius of the updraft
  33548. * @param _strength The strength of the updraft
  33549. * @param _height The height of the updraft
  33550. * @param _updraftMode The mode of the updraft
  33551. */
  33552. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  33553. /**
  33554. * Returns the data related to the updraft event (cylinder).
  33555. * @returns A physics updraft event
  33556. */
  33557. getData(): PhysicsUpdraftEventData;
  33558. /**
  33559. * Enables the updraft.
  33560. */
  33561. enable(): void;
  33562. /**
  33563. * Disables the cortex.
  33564. */
  33565. disable(): void;
  33566. /**
  33567. * Disposes the sphere.
  33568. * @param force Specifies if the updraft should be disposed by force
  33569. */
  33570. dispose(force?: boolean): void;
  33571. private getImpostorForceAndContactPoint;
  33572. private _tick;
  33573. /*** Helpers ***/
  33574. private _prepareCylinder;
  33575. private _intersectsWithCylinder;
  33576. }
  33577. /**
  33578. * Represents a physics vortex event
  33579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33580. */
  33581. class PhysicsVortexEvent {
  33582. private _scene;
  33583. private _origin;
  33584. private _radius;
  33585. private _strength;
  33586. private _height;
  33587. private _physicsEngine;
  33588. private _originTop;
  33589. private _centripetalForceThreshold;
  33590. private _updraftMultiplier;
  33591. private _tickCallback;
  33592. private _cylinder;
  33593. private _cylinderPosition;
  33594. private _dataFetched;
  33595. /**
  33596. * Initializes the physics vortex event
  33597. * @param _scene The BabylonJS scene
  33598. * @param _origin The origin position of the vortex
  33599. * @param _radius The radius of the vortex
  33600. * @param _strength The strength of the vortex
  33601. * @param _height The height of the vortex
  33602. */
  33603. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  33604. /**
  33605. * Returns the data related to the vortex event (cylinder).
  33606. * @returns The physics vortex event data
  33607. */
  33608. getData(): PhysicsVortexEventData;
  33609. /**
  33610. * Enables the vortex.
  33611. */
  33612. enable(): void;
  33613. /**
  33614. * Disables the cortex.
  33615. */
  33616. disable(): void;
  33617. /**
  33618. * Disposes the sphere.
  33619. * @param force
  33620. */
  33621. dispose(force?: boolean): void;
  33622. private getImpostorForceAndContactPoint;
  33623. private _tick;
  33624. /*** Helpers ***/
  33625. private _prepareCylinder;
  33626. private _intersectsWithCylinder;
  33627. }
  33628. /**
  33629. * The strenght of the force in correspondence to the distance of the affected object
  33630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33631. */
  33632. enum PhysicsRadialImpulseFalloff {
  33633. /** Defines that impulse is constant in strength across it's whole radius */
  33634. Constant = 0,
  33635. /** DEfines that impulse gets weaker if it's further from the origin */
  33636. Linear = 1
  33637. }
  33638. /**
  33639. * The strength of the force in correspondence to the distance of the affected object
  33640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33641. */
  33642. enum PhysicsUpdraftMode {
  33643. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  33644. Center = 0,
  33645. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  33646. Perpendicular = 1
  33647. }
  33648. /**
  33649. * Interface for a physics force and contact point
  33650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33651. */
  33652. interface PhysicsForceAndContactPoint {
  33653. /**
  33654. * The force applied at the contact point
  33655. */
  33656. force: Vector3;
  33657. /**
  33658. * The contact point
  33659. */
  33660. contactPoint: Vector3;
  33661. }
  33662. /**
  33663. * Interface for radial explosion event data
  33664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33665. */
  33666. interface PhysicsRadialExplosionEventData {
  33667. /**
  33668. * A sphere used for the radial explosion event
  33669. */
  33670. sphere: Mesh;
  33671. /**
  33672. * An array of rays for the radial explosion event
  33673. */
  33674. rays: Array<Ray>;
  33675. }
  33676. /**
  33677. * Interface for gravitational field event data
  33678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33679. */
  33680. interface PhysicsGravitationalFieldEventData {
  33681. /**
  33682. * A sphere mesh used for the gravitational field event
  33683. */
  33684. sphere: Mesh;
  33685. }
  33686. /**
  33687. * Interface for updraft event data
  33688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33689. */
  33690. interface PhysicsUpdraftEventData {
  33691. /**
  33692. * A cylinder used for the updraft event
  33693. */
  33694. cylinder: Mesh;
  33695. }
  33696. /**
  33697. * Interface for vortex event data
  33698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33699. */
  33700. interface PhysicsVortexEventData {
  33701. /**
  33702. * A cylinder used for the vortex event
  33703. */
  33704. cylinder: Mesh;
  33705. }
  33706. }
  33707. declare module BABYLON {
  33708. /**
  33709. * The interface for the physics imposter parameters
  33710. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33711. */
  33712. interface PhysicsImpostorParameters {
  33713. /**
  33714. * The mass of the physics imposter
  33715. */
  33716. mass: number;
  33717. /**
  33718. * The friction of the physics imposter
  33719. */
  33720. friction?: number;
  33721. /**
  33722. * The coefficient of restitution of the physics imposter
  33723. */
  33724. restitution?: number;
  33725. /**
  33726. * The native options of the physics imposter
  33727. */
  33728. nativeOptions?: any;
  33729. /**
  33730. * Specifies if the parent should be ignored
  33731. */
  33732. ignoreParent?: boolean;
  33733. /**
  33734. * Specifies if bi-directional transformations should be disabled
  33735. */
  33736. disableBidirectionalTransformation?: boolean;
  33737. }
  33738. /**
  33739. * Interface for a physics-enabled object
  33740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33741. */
  33742. interface IPhysicsEnabledObject {
  33743. /**
  33744. * The position of the physics-enabled object
  33745. */
  33746. position: Vector3;
  33747. /**
  33748. * The rotation of the physics-enabled object
  33749. */
  33750. rotationQuaternion: Nullable<Quaternion>;
  33751. /**
  33752. * The scale of the physics-enabled object
  33753. */
  33754. scaling: Vector3;
  33755. /**
  33756. * The rotation of the physics-enabled object
  33757. */
  33758. rotation?: Vector3;
  33759. /**
  33760. * The parent of the physics-enabled object
  33761. */
  33762. parent?: any;
  33763. /**
  33764. * The bounding info of the physics-enabled object
  33765. * @returns The bounding info of the physics-enabled object
  33766. */
  33767. getBoundingInfo(): BoundingInfo;
  33768. /**
  33769. * Computes the world matrix
  33770. * @param force Specifies if the world matrix should be computed by force
  33771. * @returns A world matrix
  33772. */
  33773. computeWorldMatrix(force: boolean): Matrix;
  33774. /**
  33775. * Gets the world matrix
  33776. * @returns A world matrix
  33777. */
  33778. getWorldMatrix?(): Matrix;
  33779. /**
  33780. * Gets the child meshes
  33781. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33782. * @returns An array of abstract meshes
  33783. */
  33784. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33785. /**
  33786. * Gets the vertex data
  33787. * @param kind The type of vertex data
  33788. * @returns A nullable array of numbers, or a float32 array
  33789. */
  33790. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33791. /**
  33792. * Gets the indices from the mesh
  33793. * @returns A nullable array of index arrays
  33794. */
  33795. getIndices?(): Nullable<IndicesArray>;
  33796. /**
  33797. * Gets the scene from the mesh
  33798. * @returns the indices array or null
  33799. */
  33800. getScene?(): Scene;
  33801. /**
  33802. * Gets the absolute position from the mesh
  33803. * @returns the absolute position
  33804. */
  33805. getAbsolutePosition(): Vector3;
  33806. /**
  33807. * Gets the absolute pivot point from the mesh
  33808. * @returns the absolute pivot point
  33809. */
  33810. getAbsolutePivotPoint(): Vector3;
  33811. /**
  33812. * Rotates the mesh
  33813. * @param axis The axis of rotation
  33814. * @param amount The amount of rotation
  33815. * @param space The space of the rotation
  33816. * @returns The rotation transform node
  33817. */
  33818. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33819. /**
  33820. * Translates the mesh
  33821. * @param axis The axis of translation
  33822. * @param distance The distance of translation
  33823. * @param space The space of the translation
  33824. * @returns The transform node
  33825. */
  33826. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33827. /**
  33828. * Sets the absolute position of the mesh
  33829. * @param absolutePosition The absolute position of the mesh
  33830. * @returns The transform node
  33831. */
  33832. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33833. /**
  33834. * Gets the class name of the mesh
  33835. * @returns The class name
  33836. */
  33837. getClassName(): string;
  33838. }
  33839. /**
  33840. * Represents a physics imposter
  33841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33842. */
  33843. class PhysicsImpostor {
  33844. /**
  33845. * The physics-enabled object used as the physics imposter
  33846. */
  33847. object: IPhysicsEnabledObject;
  33848. /**
  33849. * The type of the physics imposter
  33850. */
  33851. type: number;
  33852. private _options;
  33853. private _scene?;
  33854. /**
  33855. * The default object size of the imposter
  33856. */
  33857. static DEFAULT_OBJECT_SIZE: Vector3;
  33858. /**
  33859. * The identity quaternion of the imposter
  33860. */
  33861. static IDENTITY_QUATERNION: Quaternion;
  33862. /** @hidden */
  33863. _pluginData: any;
  33864. private _physicsEngine;
  33865. private _physicsBody;
  33866. private _bodyUpdateRequired;
  33867. private _onBeforePhysicsStepCallbacks;
  33868. private _onAfterPhysicsStepCallbacks;
  33869. /** @hidden */
  33870. _onPhysicsCollideCallbacks: Array<{
  33871. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  33872. otherImpostors: Array<PhysicsImpostor>;
  33873. }>;
  33874. private _deltaPosition;
  33875. private _deltaRotation;
  33876. private _deltaRotationConjugated;
  33877. private _parent;
  33878. private _isDisposed;
  33879. private static _tmpVecs;
  33880. private static _tmpQuat;
  33881. /**
  33882. * Specifies if the physics imposter is disposed
  33883. */
  33884. readonly isDisposed: boolean;
  33885. /**
  33886. * Gets the mass of the physics imposter
  33887. */
  33888. mass: number;
  33889. /**
  33890. * Gets the coefficient of friction
  33891. */
  33892. /**
  33893. * Sets the coefficient of friction
  33894. */
  33895. friction: number;
  33896. /**
  33897. * Gets the coefficient of restitution
  33898. */
  33899. /**
  33900. * Sets the coefficient of restitution
  33901. */
  33902. restitution: number;
  33903. /**
  33904. * The unique id of the physics imposter
  33905. * set by the physics engine when adding this impostor to the array
  33906. */
  33907. uniqueId: number;
  33908. private _joints;
  33909. /**
  33910. * Initializes the physics imposter
  33911. * @param object The physics-enabled object used as the physics imposter
  33912. * @param type The type of the physics imposter
  33913. * @param _options The options for the physics imposter
  33914. * @param _scene The Babylon scene
  33915. */
  33916. constructor(
  33917. /**
  33918. * The physics-enabled object used as the physics imposter
  33919. */
  33920. object: IPhysicsEnabledObject,
  33921. /**
  33922. * The type of the physics imposter
  33923. */
  33924. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33925. /**
  33926. * This function will completly initialize this impostor.
  33927. * It will create a new body - but only if this mesh has no parent.
  33928. * If it has, this impostor will not be used other than to define the impostor
  33929. * of the child mesh.
  33930. * @hidden
  33931. */
  33932. _init(): void;
  33933. private _getPhysicsParent;
  33934. /**
  33935. * Should a new body be generated.
  33936. * @returns boolean specifying if body initialization is required
  33937. */
  33938. isBodyInitRequired(): boolean;
  33939. /**
  33940. * Sets the updated scaling
  33941. * @param updated Specifies if the scaling is updated
  33942. */
  33943. setScalingUpdated(updated: boolean): void;
  33944. /**
  33945. * Force a regeneration of this or the parent's impostor's body.
  33946. * Use under cautious - This will remove all joints already implemented.
  33947. */
  33948. forceUpdate(): void;
  33949. /**
  33950. * Gets the body that holds this impostor. Either its own, or its parent.
  33951. */
  33952. /**
  33953. * Set the physics body. Used mainly by the physics engine/plugin
  33954. */
  33955. physicsBody: any;
  33956. /**
  33957. * Get the parent of the physics imposter
  33958. * @returns Physics imposter or null
  33959. */
  33960. /**
  33961. * Sets the parent of the physics imposter
  33962. */
  33963. parent: Nullable<PhysicsImpostor>;
  33964. /**
  33965. * Resets the update flags
  33966. */
  33967. resetUpdateFlags(): void;
  33968. /**
  33969. * Gets the object extend size
  33970. * @returns the object extend size
  33971. */
  33972. getObjectExtendSize(): Vector3;
  33973. /**
  33974. * Gets the object center
  33975. * @returns The object center
  33976. */
  33977. getObjectCenter(): Vector3;
  33978. /**
  33979. * Get a specific parametes from the options parameter
  33980. * @param paramName The object parameter name
  33981. * @returns The object parameter
  33982. */
  33983. getParam(paramName: string): any;
  33984. /**
  33985. * Sets a specific parameter in the options given to the physics plugin
  33986. * @param paramName The parameter name
  33987. * @param value The value of the parameter
  33988. */
  33989. setParam(paramName: string, value: number): void;
  33990. /**
  33991. * Specifically change the body's mass option. Won't recreate the physics body object
  33992. * @param mass The mass of the physics imposter
  33993. */
  33994. setMass(mass: number): void;
  33995. /**
  33996. * Gets the linear velocity
  33997. * @returns linear velocity or null
  33998. */
  33999. getLinearVelocity(): Nullable<Vector3>;
  34000. /**
  34001. * Sets the linear velocity
  34002. * @param velocity linear velocity or null
  34003. */
  34004. setLinearVelocity(velocity: Nullable<Vector3>): void;
  34005. /**
  34006. * Gets the angular velocity
  34007. * @returns angular velocity or null
  34008. */
  34009. getAngularVelocity(): Nullable<Vector3>;
  34010. /**
  34011. * Sets the angular velocity
  34012. * @param velocity The velocity or null
  34013. */
  34014. setAngularVelocity(velocity: Nullable<Vector3>): void;
  34015. /**
  34016. * Execute a function with the physics plugin native code
  34017. * Provide a function the will have two variables - the world object and the physics body object
  34018. * @param func The function to execute with the physics plugin native code
  34019. */
  34020. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  34021. /**
  34022. * Register a function that will be executed before the physics world is stepping forward
  34023. * @param func The function to execute before the physics world is stepped forward
  34024. */
  34025. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34026. /**
  34027. * Unregister a function that will be executed before the physics world is stepping forward
  34028. * @param func The function to execute before the physics world is stepped forward
  34029. */
  34030. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34031. /**
  34032. * Register a function that will be executed after the physics step
  34033. * @param func The function to execute after physics step
  34034. */
  34035. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34036. /**
  34037. * Unregisters a function that will be executed after the physics step
  34038. * @param func The function to execute after physics step
  34039. */
  34040. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34041. /**
  34042. * register a function that will be executed when this impostor collides against a different body
  34043. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  34044. * @param func Callback that is executed on collision
  34045. */
  34046. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  34047. /**
  34048. * Unregisters the physics imposter on contact
  34049. * @param collideAgainst The physics object to collide against
  34050. * @param func Callback to execute on collision
  34051. */
  34052. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  34053. private _tmpQuat;
  34054. private _tmpQuat2;
  34055. /**
  34056. * Get the parent rotation
  34057. * @returns The parent rotation
  34058. */
  34059. getParentsRotation(): Quaternion;
  34060. /**
  34061. * this function is executed by the physics engine.
  34062. */
  34063. beforeStep: () => void;
  34064. /**
  34065. * this function is executed by the physics engine
  34066. */
  34067. afterStep: () => void;
  34068. /**
  34069. * Legacy collision detection event support
  34070. */
  34071. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  34072. /**
  34073. * event and body object due to cannon's event-based architecture.
  34074. */
  34075. onCollide: (e: {
  34076. body: any;
  34077. }) => void;
  34078. /**
  34079. * Apply a force
  34080. * @param force The force to apply
  34081. * @param contactPoint The contact point for the force
  34082. * @returns The physics imposter
  34083. */
  34084. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34085. /**
  34086. * Apply an impulse
  34087. * @param force The impulse force
  34088. * @param contactPoint The contact point for the impulse force
  34089. * @returns The physics imposter
  34090. */
  34091. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34092. /**
  34093. * A help function to create a joint
  34094. * @param otherImpostor A physics imposter used to create a joint
  34095. * @param jointType The type of joint
  34096. * @param jointData The data for the joint
  34097. * @returns The physics imposter
  34098. */
  34099. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  34100. /**
  34101. * Add a joint to this impostor with a different impostor
  34102. * @param otherImpostor A physics imposter used to add a joint
  34103. * @param joint The joint to add
  34104. * @returns The physics imposter
  34105. */
  34106. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  34107. /**
  34108. * Will keep this body still, in a sleep mode.
  34109. * @returns the physics imposter
  34110. */
  34111. sleep(): PhysicsImpostor;
  34112. /**
  34113. * Wake the body up.
  34114. * @returns The physics imposter
  34115. */
  34116. wakeUp(): PhysicsImpostor;
  34117. /**
  34118. * Clones the physics imposter
  34119. * @param newObject The physics imposter clones to this physics-enabled object
  34120. * @returns A nullable physics imposter
  34121. */
  34122. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  34123. /**
  34124. * Disposes the physics imposter
  34125. */
  34126. dispose(): void;
  34127. /**
  34128. * Sets the delta position
  34129. * @param position The delta position amount
  34130. */
  34131. setDeltaPosition(position: Vector3): void;
  34132. /**
  34133. * Sets the delta rotation
  34134. * @param rotation The delta rotation amount
  34135. */
  34136. setDeltaRotation(rotation: Quaternion): void;
  34137. /**
  34138. * Gets the box size of the physics imposter and stores the result in the input parameter
  34139. * @param result Stores the box size
  34140. * @returns The physics imposter
  34141. */
  34142. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  34143. /**
  34144. * Gets the radius of the physics imposter
  34145. * @returns Radius of the physics imposter
  34146. */
  34147. getRadius(): number;
  34148. /**
  34149. * Sync a bone with this impostor
  34150. * @param bone The bone to sync to the impostor.
  34151. * @param boneMesh The mesh that the bone is influencing.
  34152. * @param jointPivot The pivot of the joint / bone in local space.
  34153. * @param distToJoint Optional distance from the impostor to the joint.
  34154. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34155. */
  34156. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  34157. /**
  34158. * Sync impostor to a bone
  34159. * @param bone The bone that the impostor will be synced to.
  34160. * @param boneMesh The mesh that the bone is influencing.
  34161. * @param jointPivot The pivot of the joint / bone in local space.
  34162. * @param distToJoint Optional distance from the impostor to the joint.
  34163. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34164. * @param boneAxis Optional vector3 axis the bone is aligned with
  34165. */
  34166. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  34167. /**
  34168. * No-Imposter type
  34169. */
  34170. static NoImpostor: number;
  34171. /**
  34172. * Sphere-Imposter type
  34173. */
  34174. static SphereImpostor: number;
  34175. /**
  34176. * Box-Imposter type
  34177. */
  34178. static BoxImpostor: number;
  34179. /**
  34180. * Plane-Imposter type
  34181. */
  34182. static PlaneImpostor: number;
  34183. /**
  34184. * Mesh-imposter type
  34185. */
  34186. static MeshImpostor: number;
  34187. /**
  34188. * Cylinder-Imposter type
  34189. */
  34190. static CylinderImpostor: number;
  34191. /**
  34192. * Particle-Imposter type
  34193. */
  34194. static ParticleImpostor: number;
  34195. /**
  34196. * Heightmap-Imposter type
  34197. */
  34198. static HeightmapImpostor: number;
  34199. }
  34200. }
  34201. declare module BABYLON {
  34202. /**
  34203. * Interface for Physics-Joint data
  34204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34205. */
  34206. interface PhysicsJointData {
  34207. /**
  34208. * The main pivot of the joint
  34209. */
  34210. mainPivot?: Vector3;
  34211. /**
  34212. * The connected pivot of the joint
  34213. */
  34214. connectedPivot?: Vector3;
  34215. /**
  34216. * The main axis of the joint
  34217. */
  34218. mainAxis?: Vector3;
  34219. /**
  34220. * The connected axis of the joint
  34221. */
  34222. connectedAxis?: Vector3;
  34223. /**
  34224. * The collision of the joint
  34225. */
  34226. collision?: boolean;
  34227. /**
  34228. * Native Oimo/Cannon/Energy data
  34229. */
  34230. nativeParams?: any;
  34231. }
  34232. /**
  34233. * This is a holder class for the physics joint created by the physics plugin
  34234. * It holds a set of functions to control the underlying joint
  34235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34236. */
  34237. class PhysicsJoint {
  34238. /**
  34239. * The type of the physics joint
  34240. */
  34241. type: number;
  34242. /**
  34243. * The data for the physics joint
  34244. */
  34245. jointData: PhysicsJointData;
  34246. private _physicsJoint;
  34247. protected _physicsPlugin: IPhysicsEnginePlugin;
  34248. /**
  34249. * Initializes the physics joint
  34250. * @param type The type of the physics joint
  34251. * @param jointData The data for the physics joint
  34252. */
  34253. constructor(
  34254. /**
  34255. * The type of the physics joint
  34256. */
  34257. type: number,
  34258. /**
  34259. * The data for the physics joint
  34260. */
  34261. jointData: PhysicsJointData);
  34262. /**
  34263. * Gets the physics joint
  34264. */
  34265. /**
  34266. * Sets the physics joint
  34267. */
  34268. physicsJoint: any;
  34269. /**
  34270. * Sets the physics plugin
  34271. */
  34272. physicsPlugin: IPhysicsEnginePlugin;
  34273. /**
  34274. * Execute a function that is physics-plugin specific.
  34275. * @param {Function} func the function that will be executed.
  34276. * It accepts two parameters: the physics world and the physics joint
  34277. */
  34278. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  34279. /**
  34280. * Distance-Joint type
  34281. */
  34282. static DistanceJoint: number;
  34283. /**
  34284. * Hinge-Joint type
  34285. */
  34286. static HingeJoint: number;
  34287. /**
  34288. * Ball-and-Socket joint type
  34289. */
  34290. static BallAndSocketJoint: number;
  34291. /**
  34292. * Wheel-Joint type
  34293. */
  34294. static WheelJoint: number;
  34295. /**
  34296. * Slider-Joint type
  34297. */
  34298. static SliderJoint: number;
  34299. /**
  34300. * Prismatic-Joint type
  34301. */
  34302. static PrismaticJoint: number;
  34303. /**
  34304. * Universal-Joint type
  34305. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  34306. */
  34307. static UniversalJoint: number;
  34308. /**
  34309. * Hinge-Joint 2 type
  34310. */
  34311. static Hinge2Joint: number;
  34312. /**
  34313. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  34314. */
  34315. static PointToPointJoint: number;
  34316. /**
  34317. * Spring-Joint type
  34318. */
  34319. static SpringJoint: number;
  34320. /**
  34321. * Lock-Joint type
  34322. */
  34323. static LockJoint: number;
  34324. }
  34325. /**
  34326. * A class representing a physics distance joint
  34327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34328. */
  34329. class DistanceJoint extends PhysicsJoint {
  34330. /**
  34331. *
  34332. * @param jointData The data for the Distance-Joint
  34333. */
  34334. constructor(jointData: DistanceJointData);
  34335. /**
  34336. * Update the predefined distance.
  34337. * @param maxDistance The maximum preferred distance
  34338. * @param minDistance The minimum preferred distance
  34339. */
  34340. updateDistance(maxDistance: number, minDistance?: number): void;
  34341. }
  34342. /**
  34343. * Represents a Motor-Enabled Joint
  34344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34345. */
  34346. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  34347. /**
  34348. * Initializes the Motor-Enabled Joint
  34349. * @param type The type of the joint
  34350. * @param jointData The physica joint data for the joint
  34351. */
  34352. constructor(type: number, jointData: PhysicsJointData);
  34353. /**
  34354. * Set the motor values.
  34355. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34356. * @param force the force to apply
  34357. * @param maxForce max force for this motor.
  34358. */
  34359. setMotor(force?: number, maxForce?: number): void;
  34360. /**
  34361. * Set the motor's limits.
  34362. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34363. * @param upperLimit The upper limit of the motor
  34364. * @param lowerLimit The lower limit of the motor
  34365. */
  34366. setLimit(upperLimit: number, lowerLimit?: number): void;
  34367. }
  34368. /**
  34369. * This class represents a single physics Hinge-Joint
  34370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34371. */
  34372. class HingeJoint extends MotorEnabledJoint {
  34373. /**
  34374. * Initializes the Hinge-Joint
  34375. * @param jointData The joint data for the Hinge-Joint
  34376. */
  34377. constructor(jointData: PhysicsJointData);
  34378. /**
  34379. * Set the motor values.
  34380. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34381. * @param {number} force the force to apply
  34382. * @param {number} maxForce max force for this motor.
  34383. */
  34384. setMotor(force?: number, maxForce?: number): void;
  34385. /**
  34386. * Set the motor's limits.
  34387. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34388. * @param upperLimit The upper limit of the motor
  34389. * @param lowerLimit The lower limit of the motor
  34390. */
  34391. setLimit(upperLimit: number, lowerLimit?: number): void;
  34392. }
  34393. /**
  34394. * This class represents a dual hinge physics joint (same as wheel joint)
  34395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34396. */
  34397. class Hinge2Joint extends MotorEnabledJoint {
  34398. /**
  34399. * Initializes the Hinge2-Joint
  34400. * @param jointData The joint data for the Hinge2-Joint
  34401. */
  34402. constructor(jointData: PhysicsJointData);
  34403. /**
  34404. * Set the motor values.
  34405. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34406. * @param {number} force the force to apply
  34407. * @param {number} maxForce max force for this motor.
  34408. * @param {motorIndex} the motor's index, 0 or 1.
  34409. */
  34410. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34411. /**
  34412. * Set the motor limits.
  34413. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34414. * @param {number} upperLimit the upper limit
  34415. * @param {number} lowerLimit lower limit
  34416. * @param {motorIndex} the motor's index, 0 or 1.
  34417. */
  34418. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34419. }
  34420. /**
  34421. * Interface for a motor enabled joint
  34422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34423. */
  34424. interface IMotorEnabledJoint {
  34425. /**
  34426. * Physics joint
  34427. */
  34428. physicsJoint: any;
  34429. /**
  34430. * Sets the motor of the motor-enabled joint
  34431. * @param force The force of the motor
  34432. * @param maxForce The maximum force of the motor
  34433. * @param motorIndex The index of the motor
  34434. */
  34435. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34436. /**
  34437. * Sets the limit of the motor
  34438. * @param upperLimit The upper limit of the motor
  34439. * @param lowerLimit The lower limit of the motor
  34440. * @param motorIndex The index of the motor
  34441. */
  34442. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34443. }
  34444. /**
  34445. * Joint data for a Distance-Joint
  34446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34447. */
  34448. interface DistanceJointData extends PhysicsJointData {
  34449. /**
  34450. * Max distance the 2 joint objects can be apart
  34451. */
  34452. maxDistance: number;
  34453. }
  34454. /**
  34455. * Joint data from a spring joint
  34456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34457. */
  34458. interface SpringJointData extends PhysicsJointData {
  34459. /**
  34460. * Length of the spring
  34461. */
  34462. length: number;
  34463. /**
  34464. * Stiffness of the spring
  34465. */
  34466. stiffness: number;
  34467. /**
  34468. * Damping of the spring
  34469. */
  34470. damping: number;
  34471. /** this callback will be called when applying the force to the impostors. */
  34472. forceApplicationCallback: () => void;
  34473. }
  34474. }
  34475. declare module BABYLON {
  34476. interface AbstractScene {
  34477. /**
  34478. * The list of reflection probes added to the scene
  34479. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34480. */
  34481. reflectionProbes: Array<ReflectionProbe>;
  34482. /**
  34483. * Removes the given reflection probe from this scene.
  34484. * @param toRemove The reflection probe to remove
  34485. * @returns The index of the removed reflection probe
  34486. */
  34487. removeReflectionProbe(toRemove: ReflectionProbe): number;
  34488. /**
  34489. * Adds the given reflection probe to this scene.
  34490. * @param newReflectionProbe The reflection probe to add
  34491. */
  34492. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  34493. }
  34494. /**
  34495. * Class used to generate realtime reflection / refraction cube textures
  34496. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34497. */
  34498. class ReflectionProbe {
  34499. /** defines the name of the probe */
  34500. name: string;
  34501. private _scene;
  34502. private _renderTargetTexture;
  34503. private _projectionMatrix;
  34504. private _viewMatrix;
  34505. private _target;
  34506. private _add;
  34507. private _attachedMesh;
  34508. private _invertYAxis;
  34509. /** Gets or sets probe position (center of the cube map) */
  34510. position: Vector3;
  34511. /**
  34512. * Creates a new reflection probe
  34513. * @param name defines the name of the probe
  34514. * @param size defines the texture resolution (for each face)
  34515. * @param scene defines the hosting scene
  34516. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  34517. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  34518. */
  34519. constructor(
  34520. /** defines the name of the probe */
  34521. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  34522. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  34523. samples: number;
  34524. /** Gets or sets the refresh rate to use (on every frame by default) */
  34525. refreshRate: number;
  34526. /**
  34527. * Gets the hosting scene
  34528. * @returns a Scene
  34529. */
  34530. getScene(): Scene;
  34531. /** Gets the internal CubeTexture used to render to */
  34532. readonly cubeTexture: RenderTargetTexture;
  34533. /** Gets the list of meshes to render */
  34534. readonly renderList: Nullable<AbstractMesh[]>;
  34535. /**
  34536. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  34537. * @param mesh defines the mesh to attach to
  34538. */
  34539. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  34540. /**
  34541. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  34542. * @param renderingGroupId The rendering group id corresponding to its index
  34543. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34544. */
  34545. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34546. /**
  34547. * Clean all associated resources
  34548. */
  34549. dispose(): void;
  34550. /**
  34551. * Converts the reflection probe information to a readable string for debug purpose.
  34552. * @param fullDetails Supports for multiple levels of logging within scene loading
  34553. * @returns the human readable reflection probe info
  34554. */
  34555. toString(fullDetails?: boolean): string;
  34556. /**
  34557. * Get the class name of the relfection probe.
  34558. * @returns "ReflectionProbe"
  34559. */
  34560. getClassName(): string;
  34561. /**
  34562. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  34563. * @returns The JSON representation of the texture
  34564. */
  34565. serialize(): any;
  34566. /**
  34567. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  34568. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  34569. * @param scene Define the scene the parsed reflection probe should be instantiated in
  34570. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  34571. * @returns The parsed reflection probe if successful
  34572. */
  34573. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  34574. }
  34575. }
  34576. declare module BABYLON {
  34577. interface Scene {
  34578. /** @hidden (Backing field) */
  34579. _boundingBoxRenderer: BoundingBoxRenderer;
  34580. /** @hidden (Backing field) */
  34581. _forceShowBoundingBoxes: boolean;
  34582. /**
  34583. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  34584. */
  34585. forceShowBoundingBoxes: boolean;
  34586. /**
  34587. * Gets the bounding box renderer associated with the scene
  34588. * @returns a BoundingBoxRenderer
  34589. */
  34590. getBoundingBoxRenderer(): BoundingBoxRenderer;
  34591. }
  34592. interface AbstractMesh {
  34593. /** @hidden (Backing field) */
  34594. _showBoundingBox: boolean;
  34595. /**
  34596. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  34597. */
  34598. showBoundingBox: boolean;
  34599. }
  34600. /**
  34601. * Component responsible of rendering the bounding box of the meshes in a scene.
  34602. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  34603. */
  34604. class BoundingBoxRenderer implements ISceneComponent {
  34605. /**
  34606. * The component name helpfull to identify the component in the list of scene components.
  34607. */
  34608. readonly name: string;
  34609. /**
  34610. * The scene the component belongs to.
  34611. */
  34612. scene: Scene;
  34613. /**
  34614. * Color of the bounding box lines placed in front of an object
  34615. */
  34616. frontColor: Color3;
  34617. /**
  34618. * Color of the bounding box lines placed behind an object
  34619. */
  34620. backColor: Color3;
  34621. /**
  34622. * Defines if the renderer should show the back lines or not
  34623. */
  34624. showBackLines: boolean;
  34625. /**
  34626. * @hidden
  34627. */
  34628. renderList: SmartArray<BoundingBox>;
  34629. private _colorShader;
  34630. private _vertexBuffers;
  34631. private _indexBuffer;
  34632. /**
  34633. * Instantiates a new bounding box renderer in a scene.
  34634. * @param scene the scene the renderer renders in
  34635. */
  34636. constructor(scene: Scene);
  34637. /**
  34638. * Registers the component in a given scene
  34639. */
  34640. register(): void;
  34641. private _evaluateSubMesh;
  34642. private _activeMesh;
  34643. private _prepareRessources;
  34644. private _createIndexBuffer;
  34645. /**
  34646. * Rebuilds the elements related to this component in case of
  34647. * context lost for instance.
  34648. */
  34649. rebuild(): void;
  34650. /**
  34651. * @hidden
  34652. */
  34653. reset(): void;
  34654. /**
  34655. * Render the bounding boxes of a specific rendering group
  34656. * @param renderingGroupId defines the rendering group to render
  34657. */
  34658. render(renderingGroupId: number): void;
  34659. /**
  34660. * In case of occlusion queries, we can render the occlusion bounding box through this method
  34661. * @param mesh Define the mesh to render the occlusion bounding box for
  34662. */
  34663. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  34664. /**
  34665. * Dispose and release the resources attached to this renderer.
  34666. */
  34667. dispose(): void;
  34668. }
  34669. }
  34670. declare module BABYLON {
  34671. /**
  34672. * This represents a depth renderer in Babylon.
  34673. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  34674. */
  34675. class DepthRenderer {
  34676. private _scene;
  34677. private _depthMap;
  34678. private _effect;
  34679. private _cachedDefines;
  34680. private _camera;
  34681. /**
  34682. * Specifiess that the depth renderer will only be used within
  34683. * the camera it is created for.
  34684. * This can help forcing its rendering during the camera processing.
  34685. */
  34686. useOnlyInActiveCamera: boolean;
  34687. /**
  34688. * Instantiates a depth renderer
  34689. * @param scene The scene the renderer belongs to
  34690. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  34691. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  34692. */
  34693. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  34694. /**
  34695. * Creates the depth rendering effect and checks if the effect is ready.
  34696. * @param subMesh The submesh to be used to render the depth map of
  34697. * @param useInstances If multiple world instances should be used
  34698. * @returns if the depth renderer is ready to render the depth map
  34699. */
  34700. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34701. /**
  34702. * Gets the texture which the depth map will be written to.
  34703. * @returns The depth map texture
  34704. */
  34705. getDepthMap(): RenderTargetTexture;
  34706. /**
  34707. * Disposes of the depth renderer.
  34708. */
  34709. dispose(): void;
  34710. }
  34711. }
  34712. declare module BABYLON {
  34713. interface Scene {
  34714. /** @hidden (Backing field) */
  34715. _depthRenderer: {
  34716. [id: string]: DepthRenderer;
  34717. };
  34718. /**
  34719. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  34720. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  34721. * @returns the created depth renderer
  34722. */
  34723. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  34724. /**
  34725. * Disables a depth renderer for a given camera
  34726. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  34727. */
  34728. disableDepthRenderer(camera?: Nullable<Camera>): void;
  34729. }
  34730. /**
  34731. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  34732. * in several rendering techniques.
  34733. */
  34734. class DepthRendererSceneComponent implements ISceneComponent {
  34735. /**
  34736. * The component name helpfull to identify the component in the list of scene components.
  34737. */
  34738. readonly name: string;
  34739. /**
  34740. * The scene the component belongs to.
  34741. */
  34742. scene: Scene;
  34743. /**
  34744. * Creates a new instance of the component for the given scene
  34745. * @param scene Defines the scene to register the component in
  34746. */
  34747. constructor(scene: Scene);
  34748. /**
  34749. * Registers the component in a given scene
  34750. */
  34751. register(): void;
  34752. /**
  34753. * Rebuilds the elements related to this component in case of
  34754. * context lost for instance.
  34755. */
  34756. rebuild(): void;
  34757. /**
  34758. * Disposes the component and the associated ressources
  34759. */
  34760. dispose(): void;
  34761. private _gatherRenderTargets;
  34762. private _gatherActiveCameraRenderTargets;
  34763. }
  34764. }
  34765. declare module BABYLON {
  34766. interface AbstractMesh {
  34767. /**
  34768. * Disables the mesh edge rendering mode
  34769. * @returns the currentAbstractMesh
  34770. */
  34771. disableEdgesRendering(): AbstractMesh;
  34772. /**
  34773. * Enables the edge rendering mode on the mesh.
  34774. * This mode makes the mesh edges visible
  34775. * @param epsilon defines the maximal distance between two angles to detect a face
  34776. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34777. * @returns the currentAbstractMesh
  34778. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34779. */
  34780. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34781. /**
  34782. * Gets the edgesRenderer associated with the mesh
  34783. */
  34784. edgesRenderer: Nullable<EdgesRenderer>;
  34785. }
  34786. interface LinesMesh {
  34787. /**
  34788. * Enables the edge rendering mode on the mesh.
  34789. * This mode makes the mesh edges visible
  34790. * @param epsilon defines the maximal distance between two angles to detect a face
  34791. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34792. * @returns the currentAbstractMesh
  34793. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34794. */
  34795. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34796. }
  34797. interface InstancedLinesMesh {
  34798. /**
  34799. * Enables the edge rendering mode on the mesh.
  34800. * This mode makes the mesh edges visible
  34801. * @param epsilon defines the maximal distance between two angles to detect a face
  34802. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34803. * @returns the current InstancedLinesMesh
  34804. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34805. */
  34806. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  34807. }
  34808. /**
  34809. * Defines the minimum contract an Edges renderer should follow.
  34810. */
  34811. interface IEdgesRenderer extends IDisposable {
  34812. /**
  34813. * Gets or sets a boolean indicating if the edgesRenderer is active
  34814. */
  34815. isEnabled: boolean;
  34816. /**
  34817. * Renders the edges of the attached mesh,
  34818. */
  34819. render(): void;
  34820. /**
  34821. * Checks wether or not the edges renderer is ready to render.
  34822. * @return true if ready, otherwise false.
  34823. */
  34824. isReady(): boolean;
  34825. }
  34826. /**
  34827. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  34828. */
  34829. class EdgesRenderer implements IEdgesRenderer {
  34830. /**
  34831. * Define the size of the edges with an orthographic camera
  34832. */
  34833. edgesWidthScalerForOrthographic: number;
  34834. /**
  34835. * Define the size of the edges with a perspective camera
  34836. */
  34837. edgesWidthScalerForPerspective: number;
  34838. protected _source: AbstractMesh;
  34839. protected _linesPositions: number[];
  34840. protected _linesNormals: number[];
  34841. protected _linesIndices: number[];
  34842. protected _epsilon: number;
  34843. protected _indicesCount: number;
  34844. protected _lineShader: ShaderMaterial;
  34845. protected _ib: WebGLBuffer;
  34846. protected _buffers: {
  34847. [key: string]: Nullable<VertexBuffer>;
  34848. };
  34849. protected _checkVerticesInsteadOfIndices: boolean;
  34850. private _meshRebuildObserver;
  34851. private _meshDisposeObserver;
  34852. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  34853. isEnabled: boolean;
  34854. /**
  34855. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  34856. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  34857. * @param source Mesh used to create edges
  34858. * @param epsilon sum of angles in adjacency to check for edge
  34859. * @param checkVerticesInsteadOfIndices
  34860. * @param generateEdgesLines - should generate Lines or only prepare resources.
  34861. */
  34862. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  34863. protected _prepareRessources(): void;
  34864. /** @hidden */
  34865. _rebuild(): void;
  34866. /**
  34867. * Releases the required resources for the edges renderer
  34868. */
  34869. dispose(): void;
  34870. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  34871. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  34872. /**
  34873. * Checks if the pair of p0 and p1 is en edge
  34874. * @param faceIndex
  34875. * @param edge
  34876. * @param faceNormals
  34877. * @param p0
  34878. * @param p1
  34879. * @private
  34880. */
  34881. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  34882. /**
  34883. * push line into the position, normal and index buffer
  34884. * @protected
  34885. */
  34886. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  34887. /**
  34888. * Generates lines edges from adjacencjes
  34889. * @private
  34890. */
  34891. _generateEdgesLines(): void;
  34892. /**
  34893. * Checks wether or not the edges renderer is ready to render.
  34894. * @return true if ready, otherwise false.
  34895. */
  34896. isReady(): boolean;
  34897. /**
  34898. * Renders the edges of the attached mesh,
  34899. */
  34900. render(): void;
  34901. }
  34902. }
  34903. declare module BABYLON {
  34904. /**
  34905. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  34906. */
  34907. class GeometryBufferRenderer {
  34908. /**
  34909. * Constant used to retrieve the position texture index in the G-Buffer textures array
  34910. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  34911. */
  34912. static readonly POSITION_TEXTURE_TYPE: number;
  34913. /**
  34914. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  34915. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  34916. */
  34917. static readonly VELOCITY_TEXTURE_TYPE: number;
  34918. /**
  34919. * Dictionary used to store the previous transformation matrices of each rendered mesh
  34920. * in order to compute objects velocities when enableVelocity is set to "true"
  34921. * @hidden
  34922. */
  34923. _previousTransformationMatrices: {
  34924. [index: number]: Matrix;
  34925. };
  34926. private _scene;
  34927. private _multiRenderTarget;
  34928. private _ratio;
  34929. private _enablePosition;
  34930. private _enableVelocity;
  34931. private _positionIndex;
  34932. private _velocityIndex;
  34933. protected _effect: Effect;
  34934. protected _cachedDefines: string;
  34935. /**
  34936. * Set the render list (meshes to be rendered) used in the G buffer.
  34937. */
  34938. renderList: Mesh[];
  34939. /**
  34940. * Gets wether or not G buffer are supported by the running hardware.
  34941. * This requires draw buffer supports
  34942. */
  34943. readonly isSupported: boolean;
  34944. /**
  34945. * Returns the index of the given texture type in the G-Buffer textures array
  34946. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  34947. * @returns the index of the given texture type in the G-Buffer textures array
  34948. */
  34949. getTextureIndex(textureType: number): number;
  34950. /**
  34951. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  34952. */
  34953. /**
  34954. * Sets whether or not objects positions are enabled for the G buffer.
  34955. */
  34956. enablePosition: boolean;
  34957. /**
  34958. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  34959. */
  34960. /**
  34961. * Sets wether or not objects velocities are enabled for the G buffer.
  34962. */
  34963. enableVelocity: boolean;
  34964. /**
  34965. * Gets the scene associated with the buffer.
  34966. */
  34967. readonly scene: Scene;
  34968. /**
  34969. * Gets the ratio used by the buffer during its creation.
  34970. * How big is the buffer related to the main canvas.
  34971. */
  34972. readonly ratio: number;
  34973. /**
  34974. * Creates a new G Buffer for the scene
  34975. * @param scene The scene the buffer belongs to
  34976. * @param ratio How big is the buffer related to the main canvas.
  34977. */
  34978. constructor(scene: Scene, ratio?: number);
  34979. /**
  34980. * Checks wether everything is ready to render a submesh to the G buffer.
  34981. * @param subMesh the submesh to check readiness for
  34982. * @param useInstances is the mesh drawn using instance or not
  34983. * @returns true if ready otherwise false
  34984. */
  34985. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34986. /**
  34987. * Gets the current underlying G Buffer.
  34988. * @returns the buffer
  34989. */
  34990. getGBuffer(): MultiRenderTarget;
  34991. /**
  34992. * Gets the number of samples used to render the buffer (anti aliasing).
  34993. */
  34994. /**
  34995. * Sets the number of samples used to render the buffer (anti aliasing).
  34996. */
  34997. samples: number;
  34998. /**
  34999. * Disposes the renderer and frees up associated resources.
  35000. */
  35001. dispose(): void;
  35002. protected _createRenderTargets(): void;
  35003. }
  35004. }
  35005. declare module BABYLON {
  35006. interface Scene {
  35007. /** @hidden (Backing field) */
  35008. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35009. /**
  35010. * Gets or Sets the current geometry buffer associated to the scene.
  35011. */
  35012. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35013. /**
  35014. * Enables a GeometryBufferRender and associates it with the scene
  35015. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  35016. * @returns the GeometryBufferRenderer
  35017. */
  35018. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  35019. /**
  35020. * Disables the GeometryBufferRender associated with the scene
  35021. */
  35022. disableGeometryBufferRenderer(): void;
  35023. }
  35024. /**
  35025. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  35026. * in several rendering techniques.
  35027. */
  35028. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  35029. /**
  35030. * The component name helpful to identify the component in the list of scene components.
  35031. */
  35032. readonly name: string;
  35033. /**
  35034. * The scene the component belongs to.
  35035. */
  35036. scene: Scene;
  35037. /**
  35038. * Creates a new instance of the component for the given scene
  35039. * @param scene Defines the scene to register the component in
  35040. */
  35041. constructor(scene: Scene);
  35042. /**
  35043. * Registers the component in a given scene
  35044. */
  35045. register(): void;
  35046. /**
  35047. * Rebuilds the elements related to this component in case of
  35048. * context lost for instance.
  35049. */
  35050. rebuild(): void;
  35051. /**
  35052. * Disposes the component and the associated ressources
  35053. */
  35054. dispose(): void;
  35055. private _gatherRenderTargets;
  35056. }
  35057. }
  35058. declare module BABYLON {
  35059. /**
  35060. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  35061. */
  35062. class LineEdgesRenderer extends EdgesRenderer {
  35063. /**
  35064. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  35065. * @param source LineMesh used to generate edges
  35066. * @param epsilon not important (specified angle for edge detection)
  35067. * @param checkVerticesInsteadOfIndices not important for LineMesh
  35068. */
  35069. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  35070. /**
  35071. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  35072. */
  35073. _generateEdgesLines(): void;
  35074. }
  35075. }
  35076. declare module BABYLON {
  35077. interface Scene {
  35078. /** @hidden */
  35079. _outlineRenderer: OutlineRenderer;
  35080. /**
  35081. * Gets the outline renderer associated with the scene
  35082. * @returns a OutlineRenderer
  35083. */
  35084. getOutlineRenderer(): OutlineRenderer;
  35085. }
  35086. interface AbstractMesh {
  35087. /** @hidden (Backing field) */
  35088. _renderOutline: boolean;
  35089. /**
  35090. * Gets or sets a boolean indicating if the outline must be rendered as well
  35091. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  35092. */
  35093. renderOutline: boolean;
  35094. /** @hidden (Backing field) */
  35095. _renderOverlay: boolean;
  35096. /**
  35097. * Gets or sets a boolean indicating if the overlay must be rendered as well
  35098. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  35099. */
  35100. renderOverlay: boolean;
  35101. }
  35102. /**
  35103. * This class is responsible to draw bothe outline/overlay of meshes.
  35104. * It should not be used directly but through the available method on mesh.
  35105. */
  35106. class OutlineRenderer implements ISceneComponent {
  35107. /**
  35108. * The name of the component. Each component must have a unique name.
  35109. */
  35110. name: string;
  35111. /**
  35112. * The scene the component belongs to.
  35113. */
  35114. scene: Scene;
  35115. /**
  35116. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  35117. */
  35118. zOffset: number;
  35119. private _engine;
  35120. private _effect;
  35121. private _cachedDefines;
  35122. private _savedDepthWrite;
  35123. /**
  35124. * Instantiates a new outline renderer. (There could be only one per scene).
  35125. * @param scene Defines the scene it belongs to
  35126. */
  35127. constructor(scene: Scene);
  35128. /**
  35129. * Register the component to one instance of a scene.
  35130. */
  35131. register(): void;
  35132. /**
  35133. * Rebuilds the elements related to this component in case of
  35134. * context lost for instance.
  35135. */
  35136. rebuild(): void;
  35137. /**
  35138. * Disposes the component and the associated ressources.
  35139. */
  35140. dispose(): void;
  35141. /**
  35142. * Renders the outline in the canvas.
  35143. * @param subMesh Defines the sumesh to render
  35144. * @param batch Defines the batch of meshes in case of instances
  35145. * @param useOverlay Defines if the rendering is for the overlay or the outline
  35146. */
  35147. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  35148. /**
  35149. * Returns whether or not the outline renderer is ready for a given submesh.
  35150. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  35151. * @param subMesh Defines the submesh to check readyness for
  35152. * @param useInstances Defines wheter wee are trying to render instances or not
  35153. * @returns true if ready otherwise false
  35154. */
  35155. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35156. private _beforeRenderingMesh;
  35157. private _afterRenderingMesh;
  35158. }
  35159. }
  35160. declare module BABYLON {
  35161. /**
  35162. * This represents the object necessary to create a rendering group.
  35163. * This is exclusively used and created by the rendering manager.
  35164. * To modify the behavior, you use the available helpers in your scene or meshes.
  35165. * @hidden
  35166. */
  35167. class RenderingGroup {
  35168. index: number;
  35169. private _scene;
  35170. private _opaqueSubMeshes;
  35171. private _transparentSubMeshes;
  35172. private _alphaTestSubMeshes;
  35173. private _depthOnlySubMeshes;
  35174. private _particleSystems;
  35175. private _spriteManagers;
  35176. private _opaqueSortCompareFn;
  35177. private _alphaTestSortCompareFn;
  35178. private _transparentSortCompareFn;
  35179. private _renderOpaque;
  35180. private _renderAlphaTest;
  35181. private _renderTransparent;
  35182. private _edgesRenderers;
  35183. onBeforeTransparentRendering: () => void;
  35184. /**
  35185. * Set the opaque sort comparison function.
  35186. * If null the sub meshes will be render in the order they were created
  35187. */
  35188. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35189. /**
  35190. * Set the alpha test sort comparison function.
  35191. * If null the sub meshes will be render in the order they were created
  35192. */
  35193. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35194. /**
  35195. * Set the transparent sort comparison function.
  35196. * If null the sub meshes will be render in the order they were created
  35197. */
  35198. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35199. /**
  35200. * Creates a new rendering group.
  35201. * @param index The rendering group index
  35202. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  35203. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  35204. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  35205. */
  35206. 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>);
  35207. /**
  35208. * Render all the sub meshes contained in the group.
  35209. * @param customRenderFunction Used to override the default render behaviour of the group.
  35210. * @returns true if rendered some submeshes.
  35211. */
  35212. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  35213. /**
  35214. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  35215. * @param subMeshes The submeshes to render
  35216. */
  35217. private renderOpaqueSorted;
  35218. /**
  35219. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  35220. * @param subMeshes The submeshes to render
  35221. */
  35222. private renderAlphaTestSorted;
  35223. /**
  35224. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  35225. * @param subMeshes The submeshes to render
  35226. */
  35227. private renderTransparentSorted;
  35228. /**
  35229. * Renders the submeshes in a specified order.
  35230. * @param subMeshes The submeshes to sort before render
  35231. * @param sortCompareFn The comparison function use to sort
  35232. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  35233. * @param transparent Specifies to activate blending if true
  35234. */
  35235. private static renderSorted;
  35236. /**
  35237. * Renders the submeshes in the order they were dispatched (no sort applied).
  35238. * @param subMeshes The submeshes to render
  35239. */
  35240. private static renderUnsorted;
  35241. /**
  35242. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35243. * are rendered back to front if in the same alpha index.
  35244. *
  35245. * @param a The first submesh
  35246. * @param b The second submesh
  35247. * @returns The result of the comparison
  35248. */
  35249. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  35250. /**
  35251. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35252. * are rendered back to front.
  35253. *
  35254. * @param a The first submesh
  35255. * @param b The second submesh
  35256. * @returns The result of the comparison
  35257. */
  35258. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  35259. /**
  35260. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35261. * are rendered front to back (prevent overdraw).
  35262. *
  35263. * @param a The first submesh
  35264. * @param b The second submesh
  35265. * @returns The result of the comparison
  35266. */
  35267. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  35268. /**
  35269. * Resets the different lists of submeshes to prepare a new frame.
  35270. */
  35271. prepare(): void;
  35272. dispose(): void;
  35273. /**
  35274. * Inserts the submesh in its correct queue depending on its material.
  35275. * @param subMesh The submesh to dispatch
  35276. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35277. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35278. */
  35279. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35280. dispatchSprites(spriteManager: ISpriteManager): void;
  35281. dispatchParticles(particleSystem: IParticleSystem): void;
  35282. private _renderParticles;
  35283. private _renderSprites;
  35284. }
  35285. }
  35286. declare module BABYLON {
  35287. /**
  35288. * Interface describing the different options available in the rendering manager
  35289. * regarding Auto Clear between groups.
  35290. */
  35291. interface IRenderingManagerAutoClearSetup {
  35292. /**
  35293. * Defines whether or not autoclear is enable.
  35294. */
  35295. autoClear: boolean;
  35296. /**
  35297. * Defines whether or not to autoclear the depth buffer.
  35298. */
  35299. depth: boolean;
  35300. /**
  35301. * Defines whether or not to autoclear the stencil buffer.
  35302. */
  35303. stencil: boolean;
  35304. }
  35305. /**
  35306. * This is the manager responsible of all the rendering for meshes sprites and particles.
  35307. * It is enable to manage the different groups as well as the different necessary sort functions.
  35308. * This should not be used directly aside of the few static configurations
  35309. */
  35310. class RenderingManager {
  35311. /**
  35312. * The max id used for rendering groups (not included)
  35313. */
  35314. static MAX_RENDERINGGROUPS: number;
  35315. /**
  35316. * The min id used for rendering groups (included)
  35317. */
  35318. static MIN_RENDERINGGROUPS: number;
  35319. /**
  35320. * Used to globally prevent autoclearing scenes.
  35321. */
  35322. static AUTOCLEAR: boolean;
  35323. /**
  35324. * @hidden
  35325. */
  35326. _useSceneAutoClearSetup: boolean;
  35327. private _scene;
  35328. private _renderingGroups;
  35329. private _depthStencilBufferAlreadyCleaned;
  35330. private _autoClearDepthStencil;
  35331. private _customOpaqueSortCompareFn;
  35332. private _customAlphaTestSortCompareFn;
  35333. private _customTransparentSortCompareFn;
  35334. private _renderingGroupInfo;
  35335. /**
  35336. * Instantiates a new rendering group for a particular scene
  35337. * @param scene Defines the scene the groups belongs to
  35338. */
  35339. constructor(scene: Scene);
  35340. private _clearDepthStencilBuffer;
  35341. /**
  35342. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  35343. * @hidden
  35344. */
  35345. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  35346. /**
  35347. * Resets the different information of the group to prepare a new frame
  35348. * @hidden
  35349. */
  35350. reset(): void;
  35351. /**
  35352. * Dispose and release the group and its associated resources.
  35353. * @hidden
  35354. */
  35355. dispose(): void;
  35356. /**
  35357. * Clear the info related to rendering groups preventing retention points during dispose.
  35358. */
  35359. freeRenderingGroups(): void;
  35360. private _prepareRenderingGroup;
  35361. /**
  35362. * Add a sprite manager to the rendering manager in order to render it this frame.
  35363. * @param spriteManager Define the sprite manager to render
  35364. */
  35365. dispatchSprites(spriteManager: ISpriteManager): void;
  35366. /**
  35367. * Add a particle system to the rendering manager in order to render it this frame.
  35368. * @param particleSystem Define the particle system to render
  35369. */
  35370. dispatchParticles(particleSystem: IParticleSystem): void;
  35371. /**
  35372. * Add a submesh to the manager in order to render it this frame
  35373. * @param subMesh The submesh to dispatch
  35374. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35375. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35376. */
  35377. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35378. /**
  35379. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35380. * This allowed control for front to back rendering or reversly depending of the special needs.
  35381. *
  35382. * @param renderingGroupId The rendering group id corresponding to its index
  35383. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35384. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35385. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35386. */
  35387. 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;
  35388. /**
  35389. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35390. *
  35391. * @param renderingGroupId The rendering group id corresponding to its index
  35392. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35393. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35394. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35395. */
  35396. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35397. /**
  35398. * Gets the current auto clear configuration for one rendering group of the rendering
  35399. * manager.
  35400. * @param index the rendering group index to get the information for
  35401. * @returns The auto clear setup for the requested rendering group
  35402. */
  35403. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35404. }
  35405. }
  35406. declare module BABYLON {
  35407. /**
  35408. * Renders a layer on top of an existing scene
  35409. */
  35410. class UtilityLayerRenderer implements IDisposable {
  35411. /** the original scene that will be rendered on top of */
  35412. originalScene: Scene;
  35413. private _pointerCaptures;
  35414. private _lastPointerEvents;
  35415. private static _DefaultUtilityLayer;
  35416. private static _DefaultKeepDepthUtilityLayer;
  35417. /**
  35418. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  35419. */
  35420. pickUtilitySceneFirst: boolean;
  35421. /**
  35422. * 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)
  35423. */
  35424. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  35425. /**
  35426. * 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)
  35427. */
  35428. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  35429. /**
  35430. * The scene that is rendered on top of the original scene
  35431. */
  35432. utilityLayerScene: Scene;
  35433. /**
  35434. * If the utility layer should automatically be rendered on top of existing scene
  35435. */
  35436. shouldRender: boolean;
  35437. /**
  35438. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  35439. */
  35440. onlyCheckPointerDownEvents: boolean;
  35441. /**
  35442. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  35443. */
  35444. processAllEvents: boolean;
  35445. /**
  35446. * Observable raised when the pointer move from the utility layer scene to the main scene
  35447. */
  35448. onPointerOutObservable: Observable<number>;
  35449. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  35450. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  35451. private _afterRenderObserver;
  35452. private _sceneDisposeObserver;
  35453. private _originalPointerObserver;
  35454. /**
  35455. * Instantiates a UtilityLayerRenderer
  35456. * @param originalScene the original scene that will be rendered on top of
  35457. * @param handleEvents boolean indicating if the utility layer should handle events
  35458. */
  35459. constructor(
  35460. /** the original scene that will be rendered on top of */
  35461. originalScene: Scene, handleEvents?: boolean);
  35462. private _notifyObservers;
  35463. /**
  35464. * Renders the utility layers scene on top of the original scene
  35465. */
  35466. render(): void;
  35467. /**
  35468. * Disposes of the renderer
  35469. */
  35470. dispose(): void;
  35471. private _updateCamera;
  35472. }
  35473. }
  35474. declare module BABYLON {
  35475. /**
  35476. * Class used to represent a sprite
  35477. * @see http://doc.babylonjs.com/babylon101/sprites
  35478. */
  35479. class Sprite {
  35480. /** defines the name */
  35481. name: string;
  35482. /** Gets or sets the current world position */
  35483. position: Vector3;
  35484. /** Gets or sets the main color */
  35485. color: Color4;
  35486. /** Gets or sets the width */
  35487. width: number;
  35488. /** Gets or sets the height */
  35489. height: number;
  35490. /** Gets or sets rotation angle */
  35491. angle: number;
  35492. /** Gets or sets the cell index in the sprite sheet */
  35493. cellIndex: number;
  35494. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  35495. invertU: number;
  35496. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  35497. invertV: number;
  35498. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  35499. disposeWhenFinishedAnimating: boolean;
  35500. /** Gets the list of attached animations */
  35501. animations: Animation[];
  35502. /** Gets or sets a boolean indicating if the sprite can be picked */
  35503. isPickable: boolean;
  35504. /**
  35505. * Gets or sets the associated action manager
  35506. */
  35507. actionManager: Nullable<ActionManager>;
  35508. private _animationStarted;
  35509. private _loopAnimation;
  35510. private _fromIndex;
  35511. private _toIndex;
  35512. private _delay;
  35513. private _direction;
  35514. private _manager;
  35515. private _time;
  35516. private _onAnimationEnd;
  35517. /**
  35518. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  35519. */
  35520. isVisible: boolean;
  35521. /**
  35522. * Gets or sets the sprite size
  35523. */
  35524. size: number;
  35525. /**
  35526. * Creates a new Sprite
  35527. * @param name defines the name
  35528. * @param manager defines the manager
  35529. */
  35530. constructor(
  35531. /** defines the name */
  35532. name: string, manager: ISpriteManager);
  35533. /**
  35534. * Starts an animation
  35535. * @param from defines the initial key
  35536. * @param to defines the end key
  35537. * @param loop defines if the animation must loop
  35538. * @param delay defines the start delay (in ms)
  35539. * @param onAnimationEnd defines a callback to call when animation ends
  35540. */
  35541. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  35542. /** Stops current animation (if any) */
  35543. stopAnimation(): void;
  35544. /** @hidden */
  35545. _animate(deltaTime: number): void;
  35546. /** Release associated resources */
  35547. dispose(): void;
  35548. }
  35549. }
  35550. declare module BABYLON {
  35551. /**
  35552. * Defines the minimum interface to fullfil in order to be a sprite manager.
  35553. */
  35554. interface ISpriteManager extends IDisposable {
  35555. /**
  35556. * Restricts the camera to viewing objects with the same layerMask.
  35557. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  35558. */
  35559. layerMask: number;
  35560. /**
  35561. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35562. */
  35563. isPickable: boolean;
  35564. /**
  35565. * Specifies the rendering group id for this mesh (0 by default)
  35566. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35567. */
  35568. renderingGroupId: number;
  35569. /**
  35570. * Defines the list of sprites managed by the manager.
  35571. */
  35572. sprites: Array<Sprite>;
  35573. /**
  35574. * Tests the intersection of a sprite with a specific ray.
  35575. * @param ray The ray we are sending to test the collision
  35576. * @param camera The camera space we are sending rays in
  35577. * @param predicate A predicate allowing excluding sprites from the list of object to test
  35578. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  35579. * @returns picking info or null.
  35580. */
  35581. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  35582. /**
  35583. * Renders the list of sprites on screen.
  35584. */
  35585. render(): void;
  35586. }
  35587. /**
  35588. * Class used to manage multiple sprites on the same spritesheet
  35589. * @see http://doc.babylonjs.com/babylon101/sprites
  35590. */
  35591. class SpriteManager implements ISpriteManager {
  35592. /** defines the manager's name */
  35593. name: string;
  35594. /** Gets the list of sprites */
  35595. sprites: Sprite[];
  35596. /** Gets or sets the rendering group id (0 by default) */
  35597. renderingGroupId: number;
  35598. /** Gets or sets camera layer mask */
  35599. layerMask: number;
  35600. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  35601. fogEnabled: boolean;
  35602. /** Gets or sets a boolean indicating if the sprites are pickable */
  35603. isPickable: boolean;
  35604. /** Defines the default width of a cell in the spritesheet */
  35605. cellWidth: number;
  35606. /** Defines the default height of a cell in the spritesheet */
  35607. cellHeight: number;
  35608. /**
  35609. * An event triggered when the manager is disposed.
  35610. */
  35611. onDisposeObservable: Observable<SpriteManager>;
  35612. private _onDisposeObserver;
  35613. /**
  35614. * Callback called when the manager is disposed
  35615. */
  35616. onDispose: () => void;
  35617. private _capacity;
  35618. private _spriteTexture;
  35619. private _epsilon;
  35620. private _scene;
  35621. private _vertexData;
  35622. private _buffer;
  35623. private _vertexBuffers;
  35624. private _indexBuffer;
  35625. private _effectBase;
  35626. private _effectFog;
  35627. /**
  35628. * Gets or sets the spritesheet texture
  35629. */
  35630. texture: Texture;
  35631. /**
  35632. * Creates a new sprite manager
  35633. * @param name defines the manager's name
  35634. * @param imgUrl defines the sprite sheet url
  35635. * @param capacity defines the maximum allowed number of sprites
  35636. * @param cellSize defines the size of a sprite cell
  35637. * @param scene defines the hosting scene
  35638. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  35639. * @param samplingMode defines the smapling mode to use with spritesheet
  35640. */
  35641. constructor(
  35642. /** defines the manager's name */
  35643. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  35644. private _appendSpriteVertex;
  35645. /**
  35646. * Intersects the sprites with a ray
  35647. * @param ray defines the ray to intersect with
  35648. * @param camera defines the current active camera
  35649. * @param predicate defines a predicate used to select candidate sprites
  35650. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  35651. * @returns null if no hit or a PickingInfo
  35652. */
  35653. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  35654. /**
  35655. * Render all child sprites
  35656. */
  35657. render(): void;
  35658. /**
  35659. * Release associated resources
  35660. */
  35661. dispose(): void;
  35662. }
  35663. }
  35664. declare module BABYLON {
  35665. interface Scene {
  35666. /** @hidden */
  35667. _pointerOverSprite: Nullable<Sprite>;
  35668. /** @hidden */
  35669. _pickedDownSprite: Nullable<Sprite>;
  35670. /** @hidden */
  35671. _tempSpritePickingRay: Nullable<Ray>;
  35672. /**
  35673. * All of the sprite managers added to this scene
  35674. * @see http://doc.babylonjs.com/babylon101/sprites
  35675. */
  35676. spriteManagers: Array<ISpriteManager>;
  35677. /**
  35678. * An event triggered when sprites rendering is about to start
  35679. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  35680. */
  35681. onBeforeSpritesRenderingObservable: Observable<Scene>;
  35682. /**
  35683. * An event triggered when sprites rendering is done
  35684. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  35685. */
  35686. onAfterSpritesRenderingObservable: Observable<Scene>;
  35687. /** @hidden */
  35688. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35689. /** Launch a ray to try to pick a sprite in the scene
  35690. * @param x position on screen
  35691. * @param y position on screen
  35692. * @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
  35693. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35694. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35695. * @returns a PickingInfo
  35696. */
  35697. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35698. /** Use the given ray to pick a sprite in the scene
  35699. * @param ray The ray (in world space) to use to pick meshes
  35700. * @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
  35701. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35702. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  35703. * @returns a PickingInfo
  35704. */
  35705. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35706. /**
  35707. * Force the sprite under the pointer
  35708. * @param sprite defines the sprite to use
  35709. */
  35710. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  35711. /**
  35712. * Gets the sprite under the pointer
  35713. * @returns a Sprite or null if no sprite is under the pointer
  35714. */
  35715. getPointerOverSprite(): Nullable<Sprite>;
  35716. }
  35717. /**
  35718. * Defines the sprite scene component responsible to manage sprites
  35719. * in a given scene.
  35720. */
  35721. class SpriteSceneComponent implements ISceneComponent {
  35722. /**
  35723. * The component name helpfull to identify the component in the list of scene components.
  35724. */
  35725. readonly name: string;
  35726. /**
  35727. * The scene the component belongs to.
  35728. */
  35729. scene: Scene;
  35730. /** @hidden */
  35731. private _spritePredicate;
  35732. /**
  35733. * Creates a new instance of the component for the given scene
  35734. * @param scene Defines the scene to register the component in
  35735. */
  35736. constructor(scene: Scene);
  35737. /**
  35738. * Registers the component in a given scene
  35739. */
  35740. register(): void;
  35741. /**
  35742. * Rebuilds the elements related to this component in case of
  35743. * context lost for instance.
  35744. */
  35745. rebuild(): void;
  35746. /**
  35747. * Disposes the component and the associated ressources.
  35748. */
  35749. dispose(): void;
  35750. private _pickSpriteButKeepRay;
  35751. private _pointerMove;
  35752. private _pointerDown;
  35753. private _pointerUp;
  35754. }
  35755. }
  35756. declare module BABYLON {
  35757. /**
  35758. * Postprocess used to generate anaglyphic rendering
  35759. */
  35760. class AnaglyphPostProcess extends PostProcess {
  35761. private _passedProcess;
  35762. /**
  35763. * Creates a new AnaglyphPostProcess
  35764. * @param name defines postprocess name
  35765. * @param options defines creation options or target ratio scale
  35766. * @param rigCameras defines cameras using this postprocess
  35767. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  35768. * @param engine defines hosting engine
  35769. * @param reusable defines if the postprocess will be reused multiple times per frame
  35770. */
  35771. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  35772. }
  35773. }
  35774. declare module BABYLON {
  35775. /**
  35776. * Post process used to render in black and white
  35777. */
  35778. class BlackAndWhitePostProcess extends PostProcess {
  35779. /**
  35780. * Linear about to convert he result to black and white (default: 1)
  35781. */
  35782. degree: number;
  35783. /**
  35784. * Creates a black and white post process
  35785. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  35786. * @param name The name of the effect.
  35787. * @param options The required width/height ratio to downsize to before computing the render pass.
  35788. * @param camera The camera to apply the render pass to.
  35789. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35790. * @param engine The engine which the post process will be applied. (default: current engine)
  35791. * @param reusable If the post process can be reused on the same frame. (default: false)
  35792. */
  35793. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35794. }
  35795. }
  35796. declare module BABYLON {
  35797. /**
  35798. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  35799. */
  35800. class BloomEffect extends PostProcessRenderEffect {
  35801. private bloomScale;
  35802. /**
  35803. * @hidden Internal
  35804. */
  35805. _effects: Array<PostProcess>;
  35806. /**
  35807. * @hidden Internal
  35808. */
  35809. _downscale: ExtractHighlightsPostProcess;
  35810. private _blurX;
  35811. private _blurY;
  35812. private _merge;
  35813. /**
  35814. * The luminance threshold to find bright areas of the image to bloom.
  35815. */
  35816. threshold: number;
  35817. /**
  35818. * The strength of the bloom.
  35819. */
  35820. weight: number;
  35821. /**
  35822. * Specifies the size of the bloom blur kernel, relative to the final output size
  35823. */
  35824. kernel: number;
  35825. /**
  35826. * Creates a new instance of @see BloomEffect
  35827. * @param scene The scene the effect belongs to.
  35828. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  35829. * @param bloomKernel The size of the kernel to be used when applying the blur.
  35830. * @param bloomWeight The the strength of bloom.
  35831. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  35832. * @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)
  35833. */
  35834. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  35835. /**
  35836. * Disposes each of the internal effects for a given camera.
  35837. * @param camera The camera to dispose the effect on.
  35838. */
  35839. disposeEffects(camera: Camera): void;
  35840. /**
  35841. * @hidden Internal
  35842. */
  35843. _updateEffects(): void;
  35844. /**
  35845. * Internal
  35846. * @returns if all the contained post processes are ready.
  35847. * @hidden
  35848. */
  35849. _isReady(): boolean;
  35850. }
  35851. }
  35852. declare module BABYLON {
  35853. /**
  35854. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  35855. */
  35856. class BloomMergePostProcess extends PostProcess {
  35857. /** Weight of the bloom to be added to the original input. */
  35858. weight: number;
  35859. /**
  35860. * Creates a new instance of @see BloomMergePostProcess
  35861. * @param name The name of the effect.
  35862. * @param originalFromInput Post process which's input will be used for the merge.
  35863. * @param blurred Blurred highlights post process which's output will be used.
  35864. * @param weight Weight of the bloom to be added to the original input.
  35865. * @param options The required width/height ratio to downsize to before computing the render pass.
  35866. * @param camera The camera to apply the render pass to.
  35867. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35868. * @param engine The engine which the post process will be applied. (default: current engine)
  35869. * @param reusable If the post process can be reused on the same frame. (default: false)
  35870. * @param textureType Type of textures used when performing the post process. (default: 0)
  35871. * @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)
  35872. */
  35873. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  35874. /** Weight of the bloom to be added to the original input. */
  35875. weight: 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 Blur Post Process which blurs an image based on a kernel and direction.
  35881. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  35882. */
  35883. class BlurPostProcess extends PostProcess {
  35884. /** The direction in which to blur the image. */
  35885. direction: Vector2;
  35886. private blockCompilation;
  35887. protected _kernel: number;
  35888. protected _idealKernel: number;
  35889. protected _packedFloat: boolean;
  35890. private _staticDefines;
  35891. /**
  35892. * Sets the length in pixels of the blur sample region
  35893. */
  35894. /**
  35895. * Gets the length in pixels of the blur sample region
  35896. */
  35897. kernel: number;
  35898. /**
  35899. * Sets wether or not the blur needs to unpack/repack floats
  35900. */
  35901. /**
  35902. * Gets wether or not the blur is unpacking/repacking floats
  35903. */
  35904. packedFloat: boolean;
  35905. /**
  35906. * Creates a new instance BlurPostProcess
  35907. * @param name The name of the effect.
  35908. * @param direction The direction in which to blur the image.
  35909. * @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.
  35910. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35911. * @param camera The camera to apply the render pass to.
  35912. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35913. * @param engine The engine which the post process will be applied. (default: current engine)
  35914. * @param reusable If the post process can be reused on the same frame. (default: false)
  35915. * @param textureType Type of textures used when performing the post process. (default: 0)
  35916. * @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)
  35917. */
  35918. constructor(name: string,
  35919. /** The direction in which to blur the image. */
  35920. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  35921. /**
  35922. * Updates the effect with the current post process compile time values and recompiles the shader.
  35923. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35924. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35925. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35926. * @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
  35927. * @param onCompiled Called when the shader has been compiled.
  35928. * @param onError Called if there is an error when compiling a shader.
  35929. */
  35930. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35931. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35932. /**
  35933. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  35934. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  35935. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  35936. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  35937. * The gaps between physical kernels are compensated for in the weighting of the samples
  35938. * @param idealKernel Ideal blur kernel.
  35939. * @return Nearest best kernel.
  35940. */
  35941. protected _nearestBestKernel(idealKernel: number): number;
  35942. /**
  35943. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  35944. * @param x The point on the Gaussian distribution to sample.
  35945. * @return the value of the Gaussian function at x.
  35946. */
  35947. protected _gaussianWeight(x: number): number;
  35948. /**
  35949. * Generates a string that can be used as a floating point number in GLSL.
  35950. * @param x Value to print.
  35951. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  35952. * @return GLSL float string.
  35953. */
  35954. protected _glslFloat(x: number, decimalFigures?: number): string;
  35955. }
  35956. }
  35957. declare module BABYLON {
  35958. /**
  35959. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  35960. */
  35961. class ChromaticAberrationPostProcess extends PostProcess {
  35962. /**
  35963. * The amount of seperation of rgb channels (default: 30)
  35964. */
  35965. aberrationAmount: number;
  35966. /**
  35967. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  35968. */
  35969. radialIntensity: number;
  35970. /**
  35971. * 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))
  35972. */
  35973. direction: Vector2;
  35974. /**
  35975. * 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))
  35976. */
  35977. centerPosition: Vector2;
  35978. /**
  35979. * Creates a new instance ChromaticAberrationPostProcess
  35980. * @param name The name of the effect.
  35981. * @param screenWidth The width of the screen to apply the effect on.
  35982. * @param screenHeight The height of the screen to apply the effect on.
  35983. * @param options The required width/height ratio to downsize to before computing the render pass.
  35984. * @param camera The camera to apply the render pass to.
  35985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35986. * @param engine The engine which the post process will be applied. (default: current engine)
  35987. * @param reusable If the post process can be reused on the same frame. (default: false)
  35988. * @param textureType Type of textures used when performing the post process. (default: 0)
  35989. * @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)
  35990. */
  35991. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35992. }
  35993. }
  35994. declare module BABYLON {
  35995. /**
  35996. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  35997. */
  35998. class CircleOfConfusionPostProcess extends PostProcess {
  35999. /**
  36000. * 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.
  36001. */
  36002. lensSize: number;
  36003. /**
  36004. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  36005. */
  36006. fStop: number;
  36007. /**
  36008. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  36009. */
  36010. focusDistance: number;
  36011. /**
  36012. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  36013. */
  36014. focalLength: number;
  36015. private _depthTexture;
  36016. /**
  36017. * Creates a new instance CircleOfConfusionPostProcess
  36018. * @param name The name of the effect.
  36019. * @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.
  36020. * @param options The required width/height ratio to downsize to before computing the render pass.
  36021. * @param camera The camera to apply the render pass to.
  36022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36023. * @param engine The engine which the post process will be applied. (default: current engine)
  36024. * @param reusable If the post process can be reused on the same frame. (default: false)
  36025. * @param textureType Type of textures used when performing the post process. (default: 0)
  36026. * @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)
  36027. */
  36028. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36029. /**
  36030. * 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.
  36031. */
  36032. depthTexture: RenderTargetTexture;
  36033. }
  36034. }
  36035. declare module BABYLON {
  36036. /**
  36037. *
  36038. * This post-process allows the modification of rendered colors by using
  36039. * a 'look-up table' (LUT). This effect is also called Color Grading.
  36040. *
  36041. * The object needs to be provided an url to a texture containing the color
  36042. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  36043. * Use an image editing software to tweak the LUT to match your needs.
  36044. *
  36045. * For an example of a color LUT, see here:
  36046. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  36047. * For explanations on color grading, see here:
  36048. * @see http://udn.epicgames.com/Three/ColorGrading.html
  36049. *
  36050. */
  36051. class ColorCorrectionPostProcess extends PostProcess {
  36052. private _colorTableTexture;
  36053. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36054. }
  36055. }
  36056. declare module BABYLON {
  36057. /**
  36058. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  36059. * input texture to perform effects such as edge detection or sharpening
  36060. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  36061. */
  36062. class ConvolutionPostProcess extends PostProcess {
  36063. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  36064. kernel: number[];
  36065. /**
  36066. * Creates a new instance ConvolutionPostProcess
  36067. * @param name The name of the effect.
  36068. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  36069. * @param options The required width/height ratio to downsize to before computing the render pass.
  36070. * @param camera The camera to apply the render pass to.
  36071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36072. * @param engine The engine which the post process will be applied. (default: current engine)
  36073. * @param reusable If the post process can be reused on the same frame. (default: false)
  36074. * @param textureType Type of textures used when performing the post process. (default: 0)
  36075. */
  36076. constructor(name: string,
  36077. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  36078. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  36079. /**
  36080. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  36081. */
  36082. static EdgeDetect0Kernel: number[];
  36083. /**
  36084. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  36085. */
  36086. static EdgeDetect1Kernel: number[];
  36087. /**
  36088. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  36089. */
  36090. static EdgeDetect2Kernel: number[];
  36091. /**
  36092. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  36093. */
  36094. static SharpenKernel: number[];
  36095. /**
  36096. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  36097. */
  36098. static EmbossKernel: number[];
  36099. /**
  36100. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  36101. */
  36102. static GaussianKernel: number[];
  36103. }
  36104. }
  36105. declare module BABYLON {
  36106. /**
  36107. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  36108. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  36109. * based on samples that have a large difference in distance than the center pixel.
  36110. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  36111. */
  36112. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  36113. direction: Vector2;
  36114. /**
  36115. * Creates a new instance CircleOfConfusionPostProcess
  36116. * @param name The name of the effect.
  36117. * @param scene The scene the effect belongs to.
  36118. * @param direction The direction the blur should be applied.
  36119. * @param kernel The size of the kernel used to blur.
  36120. * @param options The required width/height ratio to downsize to before computing the render pass.
  36121. * @param camera The camera to apply the render pass to.
  36122. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  36123. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  36124. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36125. * @param engine The engine which the post process will be applied. (default: current engine)
  36126. * @param reusable If the post process can be reused on the same frame. (default: false)
  36127. * @param textureType Type of textures used when performing the post process. (default: 0)
  36128. * @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)
  36129. */
  36130. 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);
  36131. }
  36132. }
  36133. declare module BABYLON {
  36134. /**
  36135. * Specifies the level of max blur that should be applied when using the depth of field effect
  36136. */
  36137. enum DepthOfFieldEffectBlurLevel {
  36138. /**
  36139. * Subtle blur
  36140. */
  36141. Low = 0,
  36142. /**
  36143. * Medium blur
  36144. */
  36145. Medium = 1,
  36146. /**
  36147. * Large blur
  36148. */
  36149. High = 2
  36150. }
  36151. /**
  36152. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  36153. */
  36154. class DepthOfFieldEffect extends PostProcessRenderEffect {
  36155. private _circleOfConfusion;
  36156. /**
  36157. * @hidden Internal, blurs from high to low
  36158. */
  36159. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  36160. private _depthOfFieldBlurY;
  36161. private _dofMerge;
  36162. /**
  36163. * @hidden Internal post processes in depth of field effect
  36164. */
  36165. _effects: Array<PostProcess>;
  36166. /**
  36167. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  36168. */
  36169. focalLength: number;
  36170. /**
  36171. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  36172. */
  36173. fStop: number;
  36174. /**
  36175. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  36176. */
  36177. focusDistance: number;
  36178. /**
  36179. * 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.
  36180. */
  36181. lensSize: number;
  36182. /**
  36183. * Creates a new instance DepthOfFieldEffect
  36184. * @param scene The scene the effect belongs to.
  36185. * @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.
  36186. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  36187. * @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)
  36188. */
  36189. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  36190. /**
  36191. * 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.
  36192. */
  36193. depthTexture: RenderTargetTexture;
  36194. /**
  36195. * Disposes each of the internal effects for a given camera.
  36196. * @param camera The camera to dispose the effect on.
  36197. */
  36198. disposeEffects(camera: Camera): void;
  36199. /**
  36200. * @hidden Internal
  36201. */
  36202. _updateEffects(): void;
  36203. /**
  36204. * Internal
  36205. * @returns if all the contained post processes are ready.
  36206. * @hidden
  36207. */
  36208. _isReady(): boolean;
  36209. }
  36210. }
  36211. declare module BABYLON {
  36212. /**
  36213. * Options to be set when merging outputs from the default pipeline.
  36214. */
  36215. class DepthOfFieldMergePostProcessOptions {
  36216. /**
  36217. * The original image to merge on top of
  36218. */
  36219. originalFromInput: PostProcess;
  36220. /**
  36221. * Parameters to perform the merge of the depth of field effect
  36222. */
  36223. depthOfField?: {
  36224. circleOfConfusion: PostProcess;
  36225. blurSteps: Array<PostProcess>;
  36226. };
  36227. /**
  36228. * Parameters to perform the merge of bloom effect
  36229. */
  36230. bloom?: {
  36231. blurred: PostProcess;
  36232. weight: number;
  36233. };
  36234. }
  36235. /**
  36236. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  36237. */
  36238. class DepthOfFieldMergePostProcess extends PostProcess {
  36239. private blurSteps;
  36240. /**
  36241. * Creates a new instance of DepthOfFieldMergePostProcess
  36242. * @param name The name of the effect.
  36243. * @param originalFromInput Post process which's input will be used for the merge.
  36244. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  36245. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  36246. * @param options The required width/height ratio to downsize to before computing the render pass.
  36247. * @param camera The camera to apply the render pass to.
  36248. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36249. * @param engine The engine which the post process will be applied. (default: current engine)
  36250. * @param reusable If the post process can be reused on the same frame. (default: false)
  36251. * @param textureType Type of textures used when performing the post process. (default: 0)
  36252. * @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)
  36253. */
  36254. 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);
  36255. /**
  36256. * Updates the effect with the current post process compile time values and recompiles the shader.
  36257. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  36258. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  36259. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  36260. * @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
  36261. * @param onCompiled Called when the shader has been compiled.
  36262. * @param onError Called if there is an error when compiling a shader.
  36263. */
  36264. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  36265. }
  36266. }
  36267. declare module BABYLON {
  36268. /**
  36269. * DisplayPassPostProcess which produces an output the same as it's input
  36270. */
  36271. class DisplayPassPostProcess extends PostProcess {
  36272. /**
  36273. * Creates the DisplayPassPostProcess
  36274. * @param name The name of the effect.
  36275. * @param options The required width/height ratio to downsize to before computing the render pass.
  36276. * @param camera The camera to apply the render pass to.
  36277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36278. * @param engine The engine which the post process will be applied. (default: current engine)
  36279. * @param reusable If the post process can be reused on the same frame. (default: false)
  36280. */
  36281. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36282. }
  36283. }
  36284. declare module BABYLON {
  36285. /**
  36286. * 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.
  36287. */
  36288. class ExtractHighlightsPostProcess extends PostProcess {
  36289. /**
  36290. * The luminance threshold, pixels below this value will be set to black.
  36291. */
  36292. threshold: number;
  36293. /** @hidden */
  36294. _exposure: number;
  36295. /**
  36296. * Post process which has the input texture to be used when performing highlight extraction
  36297. * @hidden
  36298. */
  36299. _inputPostProcess: Nullable<PostProcess>;
  36300. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36301. }
  36302. }
  36303. declare module BABYLON {
  36304. /**
  36305. * Applies a kernel filter to the image
  36306. */
  36307. class FilterPostProcess extends PostProcess {
  36308. /** The matrix to be applied to the image */
  36309. kernelMatrix: Matrix;
  36310. /**
  36311. *
  36312. * @param name The name of the effect.
  36313. * @param kernelMatrix The matrix to be applied to the image
  36314. * @param options The required width/height ratio to downsize to before computing the render pass.
  36315. * @param camera The camera to apply the render pass to.
  36316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36317. * @param engine The engine which the post process will be applied. (default: current engine)
  36318. * @param reusable If the post process can be reused on the same frame. (default: false)
  36319. */
  36320. constructor(name: string,
  36321. /** The matrix to be applied to the image */
  36322. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36323. }
  36324. }
  36325. declare module BABYLON {
  36326. /**
  36327. * Fxaa post process
  36328. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  36329. */
  36330. class FxaaPostProcess extends PostProcess {
  36331. /** @hidden */
  36332. texelWidth: number;
  36333. /** @hidden */
  36334. texelHeight: number;
  36335. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  36336. private _getDefines;
  36337. }
  36338. }
  36339. declare module BABYLON {
  36340. /**
  36341. * The GrainPostProcess adds noise to the image at mid luminance levels
  36342. */
  36343. class GrainPostProcess extends PostProcess {
  36344. /**
  36345. * The intensity of the grain added (default: 30)
  36346. */
  36347. intensity: number;
  36348. /**
  36349. * If the grain should be randomized on every frame
  36350. */
  36351. animated: boolean;
  36352. /**
  36353. * Creates a new instance of @see GrainPostProcess
  36354. * @param name The name of the effect.
  36355. * @param options The required width/height ratio to downsize to before computing the render pass.
  36356. * @param camera The camera to apply the render pass to.
  36357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36358. * @param engine The engine which the post process will be applied. (default: current engine)
  36359. * @param reusable If the post process can be reused on the same frame. (default: false)
  36360. * @param textureType Type of textures used when performing the post process. (default: 0)
  36361. * @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)
  36362. */
  36363. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36364. }
  36365. }
  36366. declare module BABYLON {
  36367. /**
  36368. * Extracts highlights from the image
  36369. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36370. */
  36371. class HighlightsPostProcess extends PostProcess {
  36372. /**
  36373. * Extracts highlights from the image
  36374. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36375. * @param name The name of the effect.
  36376. * @param options The required width/height ratio to downsize to before computing the render pass.
  36377. * @param camera The camera to apply the render pass to.
  36378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36379. * @param engine The engine which the post process will be applied. (default: current engine)
  36380. * @param reusable If the post process can be reused on the same frame. (default: false)
  36381. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  36382. */
  36383. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  36384. }
  36385. }
  36386. declare module BABYLON {
  36387. /**
  36388. * ImageProcessingPostProcess
  36389. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  36390. */
  36391. class ImageProcessingPostProcess extends PostProcess {
  36392. /**
  36393. * Default configuration related to image processing available in the PBR Material.
  36394. */
  36395. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36396. /**
  36397. * Gets the image processing configuration used either in this material.
  36398. */
  36399. /**
  36400. * Sets the Default image processing configuration used either in the this material.
  36401. *
  36402. * If sets to null, the scene one is in use.
  36403. */
  36404. imageProcessingConfiguration: ImageProcessingConfiguration;
  36405. /**
  36406. * Keep track of the image processing observer to allow dispose and replace.
  36407. */
  36408. private _imageProcessingObserver;
  36409. /**
  36410. * Attaches a new image processing configuration to the PBR Material.
  36411. * @param configuration
  36412. */
  36413. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  36414. /**
  36415. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  36416. */
  36417. /**
  36418. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  36419. */
  36420. colorCurves: Nullable<ColorCurves>;
  36421. /**
  36422. * Gets wether the color curves effect is enabled.
  36423. */
  36424. /**
  36425. * Sets wether the color curves effect is enabled.
  36426. */
  36427. colorCurvesEnabled: boolean;
  36428. /**
  36429. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  36430. */
  36431. /**
  36432. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  36433. */
  36434. colorGradingTexture: Nullable<BaseTexture>;
  36435. /**
  36436. * Gets wether the color grading effect is enabled.
  36437. */
  36438. /**
  36439. * Gets wether the color grading effect is enabled.
  36440. */
  36441. colorGradingEnabled: boolean;
  36442. /**
  36443. * Gets exposure used in the effect.
  36444. */
  36445. /**
  36446. * Sets exposure used in the effect.
  36447. */
  36448. exposure: number;
  36449. /**
  36450. * Gets wether tonemapping is enabled or not.
  36451. */
  36452. /**
  36453. * Sets wether tonemapping is enabled or not
  36454. */
  36455. toneMappingEnabled: boolean;
  36456. /**
  36457. * Gets contrast used in the effect.
  36458. */
  36459. /**
  36460. * Sets contrast used in the effect.
  36461. */
  36462. contrast: number;
  36463. /**
  36464. * Gets Vignette stretch size.
  36465. */
  36466. /**
  36467. * Sets Vignette stretch size.
  36468. */
  36469. vignetteStretch: number;
  36470. /**
  36471. * Gets Vignette centre X Offset.
  36472. */
  36473. /**
  36474. * Sets Vignette centre X Offset.
  36475. */
  36476. vignetteCentreX: number;
  36477. /**
  36478. * Gets Vignette centre Y Offset.
  36479. */
  36480. /**
  36481. * Sets Vignette centre Y Offset.
  36482. */
  36483. vignetteCentreY: number;
  36484. /**
  36485. * Gets Vignette weight or intensity of the vignette effect.
  36486. */
  36487. /**
  36488. * Sets Vignette weight or intensity of the vignette effect.
  36489. */
  36490. vignetteWeight: number;
  36491. /**
  36492. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  36493. * if vignetteEnabled is set to true.
  36494. */
  36495. /**
  36496. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  36497. * if vignetteEnabled is set to true.
  36498. */
  36499. vignetteColor: Color4;
  36500. /**
  36501. * Gets Camera field of view used by the Vignette effect.
  36502. */
  36503. /**
  36504. * Sets Camera field of view used by the Vignette effect.
  36505. */
  36506. vignetteCameraFov: number;
  36507. /**
  36508. * Gets the vignette blend mode allowing different kind of effect.
  36509. */
  36510. /**
  36511. * Sets the vignette blend mode allowing different kind of effect.
  36512. */
  36513. vignetteBlendMode: number;
  36514. /**
  36515. * Gets wether the vignette effect is enabled.
  36516. */
  36517. /**
  36518. * Sets wether the vignette effect is enabled.
  36519. */
  36520. vignetteEnabled: boolean;
  36521. private _fromLinearSpace;
  36522. /**
  36523. * Gets wether the input of the processing is in Gamma or Linear Space.
  36524. */
  36525. /**
  36526. * Sets wether the input of the processing is in Gamma or Linear Space.
  36527. */
  36528. fromLinearSpace: boolean;
  36529. /**
  36530. * Defines cache preventing GC.
  36531. */
  36532. private _defines;
  36533. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  36534. /**
  36535. * "ImageProcessingPostProcess"
  36536. * @returns "ImageProcessingPostProcess"
  36537. */
  36538. getClassName(): string;
  36539. protected _updateParameters(): void;
  36540. dispose(camera?: Camera): void;
  36541. }
  36542. }
  36543. declare module BABYLON {
  36544. /**
  36545. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  36546. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  36547. * As an example, all you have to do is to create the post-process:
  36548. * var mb = new BABYLON.MotionBlurPostProcess(
  36549. * 'mb', // The name of the effect.
  36550. * scene, // The scene containing the objects to blur according to their velocity.
  36551. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  36552. * camera // The camera to apply the render pass to.
  36553. * );
  36554. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  36555. */
  36556. class MotionBlurPostProcess extends PostProcess {
  36557. /**
  36558. * Defines how much the image is blurred by the movement. Default value is equal to 1
  36559. */
  36560. motionStrength: number;
  36561. /**
  36562. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  36563. */
  36564. /**
  36565. * Sets the number of iterations to be used for motion blur quality
  36566. */
  36567. motionBlurSamples: number;
  36568. private _motionBlurSamples;
  36569. private _geometryBufferRenderer;
  36570. /**
  36571. * Creates a new instance MotionBlurPostProcess
  36572. * @param name The name of the effect.
  36573. * @param scene The scene containing the objects to blur according to their velocity.
  36574. * @param options The required width/height ratio to downsize to before computing the render pass.
  36575. * @param camera The camera to apply the render pass to.
  36576. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36577. * @param engine The engine which the post process will be applied. (default: current engine)
  36578. * @param reusable If the post process can be reused on the same frame. (default: false)
  36579. * @param textureType Type of textures used when performing the post process. (default: 0)
  36580. * @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)
  36581. */
  36582. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36583. /**
  36584. * Disposes the post process.
  36585. * @param camera The camera to dispose the post process on.
  36586. */
  36587. dispose(camera?: Camera): void;
  36588. }
  36589. }
  36590. declare module BABYLON {
  36591. /**
  36592. * PassPostProcess which produces an output the same as it's input
  36593. */
  36594. class PassPostProcess extends PostProcess {
  36595. /**
  36596. * Creates the PassPostProcess
  36597. * @param name The name of the effect.
  36598. * @param options The required width/height ratio to downsize to before computing the render pass.
  36599. * @param camera The camera to apply the render pass to.
  36600. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36601. * @param engine The engine which the post process will be applied. (default: current engine)
  36602. * @param reusable If the post process can be reused on the same frame. (default: false)
  36603. * @param textureType The type of texture to be used when performing the post processing.
  36604. * @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)
  36605. */
  36606. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36607. }
  36608. /**
  36609. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36610. */
  36611. class PassCubePostProcess extends PostProcess {
  36612. private _face;
  36613. /**
  36614. * Gets or sets the cube face to display.
  36615. * * 0 is +X
  36616. * * 1 is -X
  36617. * * 2 is +Y
  36618. * * 3 is -Y
  36619. * * 4 is +Z
  36620. * * 5 is -Z
  36621. */
  36622. face: number;
  36623. /**
  36624. * Creates the PassCubePostProcess
  36625. * @param name The name of the effect.
  36626. * @param options The required width/height ratio to downsize to before computing the render pass.
  36627. * @param camera The camera to apply the render pass to.
  36628. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36629. * @param engine The engine which the post process will be applied. (default: current engine)
  36630. * @param reusable If the post process can be reused on the same frame. (default: false)
  36631. * @param textureType The type of texture to be used when performing the post processing.
  36632. * @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)
  36633. */
  36634. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36635. }
  36636. }
  36637. declare module BABYLON {
  36638. /**
  36639. * Size options for a post process
  36640. */
  36641. type PostProcessOptions = {
  36642. width: number;
  36643. height: number;
  36644. };
  36645. /**
  36646. * PostProcess can be used to apply a shader to a texture after it has been rendered
  36647. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36648. */
  36649. class PostProcess {
  36650. /** Name of the PostProcess. */
  36651. name: string;
  36652. /**
  36653. * Width of the texture to apply the post process on
  36654. */
  36655. width: number;
  36656. /**
  36657. * Height of the texture to apply the post process on
  36658. */
  36659. height: number;
  36660. /**
  36661. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  36662. * @hidden
  36663. */
  36664. _outputTexture: Nullable<InternalTexture>;
  36665. /**
  36666. * Sampling mode used by the shader
  36667. * See https://doc.babylonjs.com/classes/3.1/texture
  36668. */
  36669. renderTargetSamplingMode: number;
  36670. /**
  36671. * Clear color to use when screen clearing
  36672. */
  36673. clearColor: Color4;
  36674. /**
  36675. * If the buffer needs to be cleared before applying the post process. (default: true)
  36676. * Should be set to false if shader will overwrite all previous pixels.
  36677. */
  36678. autoClear: boolean;
  36679. /**
  36680. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  36681. */
  36682. alphaMode: number;
  36683. /**
  36684. * Sets the setAlphaBlendConstants of the babylon engine
  36685. */
  36686. alphaConstants: Color4;
  36687. /**
  36688. * Animations to be used for the post processing
  36689. */
  36690. animations: Animation[];
  36691. /**
  36692. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  36693. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  36694. */
  36695. enablePixelPerfectMode: boolean;
  36696. /**
  36697. * Force the postprocess to be applied without taking in account viewport
  36698. */
  36699. forceFullscreenViewport: boolean;
  36700. /**
  36701. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  36702. *
  36703. * | Value | Type | Description |
  36704. * | ----- | ----------------------------------- | ----------- |
  36705. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  36706. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  36707. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  36708. *
  36709. */
  36710. scaleMode: number;
  36711. /**
  36712. * Force textures to be a power of two (default: false)
  36713. */
  36714. alwaysForcePOT: boolean;
  36715. private _samples;
  36716. /**
  36717. * Number of sample textures (default: 1)
  36718. */
  36719. samples: number;
  36720. /**
  36721. * Modify the scale of the post process to be the same as the viewport (default: false)
  36722. */
  36723. adaptScaleToCurrentViewport: boolean;
  36724. private _camera;
  36725. private _scene;
  36726. private _engine;
  36727. private _options;
  36728. private _reusable;
  36729. private _textureType;
  36730. /**
  36731. * Smart array of input and output textures for the post process.
  36732. * @hidden
  36733. */
  36734. _textures: SmartArray<InternalTexture>;
  36735. /**
  36736. * The index in _textures that corresponds to the output texture.
  36737. * @hidden
  36738. */
  36739. _currentRenderTextureInd: number;
  36740. private _effect;
  36741. private _samplers;
  36742. private _fragmentUrl;
  36743. private _vertexUrl;
  36744. private _parameters;
  36745. private _scaleRatio;
  36746. protected _indexParameters: any;
  36747. private _shareOutputWithPostProcess;
  36748. private _texelSize;
  36749. private _forcedOutputTexture;
  36750. /**
  36751. * An event triggered when the postprocess is activated.
  36752. */
  36753. onActivateObservable: Observable<Camera>;
  36754. private _onActivateObserver;
  36755. /**
  36756. * A function that is added to the onActivateObservable
  36757. */
  36758. onActivate: Nullable<(camera: Camera) => void>;
  36759. /**
  36760. * An event triggered when the postprocess changes its size.
  36761. */
  36762. onSizeChangedObservable: Observable<PostProcess>;
  36763. private _onSizeChangedObserver;
  36764. /**
  36765. * A function that is added to the onSizeChangedObservable
  36766. */
  36767. onSizeChanged: (postProcess: PostProcess) => void;
  36768. /**
  36769. * An event triggered when the postprocess applies its effect.
  36770. */
  36771. onApplyObservable: Observable<Effect>;
  36772. private _onApplyObserver;
  36773. /**
  36774. * A function that is added to the onApplyObservable
  36775. */
  36776. onApply: (effect: Effect) => void;
  36777. /**
  36778. * An event triggered before rendering the postprocess
  36779. */
  36780. onBeforeRenderObservable: Observable<Effect>;
  36781. private _onBeforeRenderObserver;
  36782. /**
  36783. * A function that is added to the onBeforeRenderObservable
  36784. */
  36785. onBeforeRender: (effect: Effect) => void;
  36786. /**
  36787. * An event triggered after rendering the postprocess
  36788. */
  36789. onAfterRenderObservable: Observable<Effect>;
  36790. private _onAfterRenderObserver;
  36791. /**
  36792. * A function that is added to the onAfterRenderObservable
  36793. */
  36794. onAfterRender: (efect: Effect) => void;
  36795. /**
  36796. * 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
  36797. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  36798. */
  36799. inputTexture: InternalTexture;
  36800. /**
  36801. * Gets the camera which post process is applied to.
  36802. * @returns The camera the post process is applied to.
  36803. */
  36804. getCamera(): Camera;
  36805. /**
  36806. * Gets the texel size of the postprocess.
  36807. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  36808. */
  36809. readonly texelSize: Vector2;
  36810. /**
  36811. * Creates a new instance PostProcess
  36812. * @param name The name of the PostProcess.
  36813. * @param fragmentUrl The url of the fragment shader to be used.
  36814. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  36815. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  36816. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  36817. * @param camera The camera to apply the render pass to.
  36818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36819. * @param engine The engine which the post process will be applied. (default: current engine)
  36820. * @param reusable If the post process can be reused on the same frame. (default: false)
  36821. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  36822. * @param textureType Type of textures used when performing the post process. (default: 0)
  36823. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  36824. * @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
  36825. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  36826. */
  36827. constructor(
  36828. /** Name of the PostProcess. */
  36829. 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);
  36830. /**
  36831. * Gets the engine which this post process belongs to.
  36832. * @returns The engine the post process was enabled with.
  36833. */
  36834. getEngine(): Engine;
  36835. /**
  36836. * The effect that is created when initializing the post process.
  36837. * @returns The created effect corrisponding the the postprocess.
  36838. */
  36839. getEffect(): Effect;
  36840. /**
  36841. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  36842. * @param postProcess The post process to share the output with.
  36843. * @returns This post process.
  36844. */
  36845. shareOutputWith(postProcess: PostProcess): PostProcess;
  36846. /**
  36847. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  36848. * This should be called if the post process that shares output with this post process is disabled/disposed.
  36849. */
  36850. useOwnOutput(): void;
  36851. /**
  36852. * Updates the effect with the current post process compile time values and recompiles the shader.
  36853. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  36854. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  36855. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  36856. * @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
  36857. * @param onCompiled Called when the shader has been compiled.
  36858. * @param onError Called if there is an error when compiling a shader.
  36859. */
  36860. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  36861. /**
  36862. * The post process is reusable if it can be used multiple times within one frame.
  36863. * @returns If the post process is reusable
  36864. */
  36865. isReusable(): boolean;
  36866. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  36867. markTextureDirty(): void;
  36868. /**
  36869. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  36870. * 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.
  36871. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  36872. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  36873. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  36874. * @returns The target texture that was bound to be written to.
  36875. */
  36876. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  36877. /**
  36878. * If the post process is supported.
  36879. */
  36880. readonly isSupported: boolean;
  36881. /**
  36882. * The aspect ratio of the output texture.
  36883. */
  36884. readonly aspectRatio: number;
  36885. /**
  36886. * Get a value indicating if the post-process is ready to be used
  36887. * @returns true if the post-process is ready (shader is compiled)
  36888. */
  36889. isReady(): boolean;
  36890. /**
  36891. * Binds all textures and uniforms to the shader, this will be run on every pass.
  36892. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  36893. */
  36894. apply(): Nullable<Effect>;
  36895. private _disposeTextures;
  36896. /**
  36897. * Disposes the post process.
  36898. * @param camera The camera to dispose the post process on.
  36899. */
  36900. dispose(camera?: Camera): void;
  36901. }
  36902. }
  36903. declare module BABYLON {
  36904. /**
  36905. * PostProcessManager is used to manage one or more post processes or post process pipelines
  36906. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36907. */
  36908. class PostProcessManager {
  36909. private _scene;
  36910. private _indexBuffer;
  36911. private _vertexBuffers;
  36912. /**
  36913. * Creates a new instance PostProcess
  36914. * @param scene The scene that the post process is associated with.
  36915. */
  36916. constructor(scene: Scene);
  36917. private _prepareBuffers;
  36918. private _buildIndexBuffer;
  36919. /**
  36920. * Rebuilds the vertex buffers of the manager.
  36921. * @hidden
  36922. */
  36923. _rebuild(): void;
  36924. /**
  36925. * Prepares a frame to be run through a post process.
  36926. * @param sourceTexture The input texture to the post procesess. (default: null)
  36927. * @param postProcesses An array of post processes to be run. (default: null)
  36928. * @returns True if the post processes were able to be run.
  36929. * @hidden
  36930. */
  36931. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  36932. /**
  36933. * Manually render a set of post processes to a texture.
  36934. * @param postProcesses An array of post processes to be run.
  36935. * @param targetTexture The target texture to render to.
  36936. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  36937. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  36938. * @param lodLevel defines which lod of the texture to render to
  36939. */
  36940. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  36941. /**
  36942. * Finalize the result of the output of the postprocesses.
  36943. * @param doNotPresent If true the result will not be displayed to the screen.
  36944. * @param targetTexture The target texture to render to.
  36945. * @param faceIndex The index of the face to bind the target texture to.
  36946. * @param postProcesses The array of post processes to render.
  36947. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  36948. * @hidden
  36949. */
  36950. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  36951. /**
  36952. * Disposes of the post process manager.
  36953. */
  36954. dispose(): void;
  36955. }
  36956. }
  36957. declare module BABYLON {
  36958. /**
  36959. * Post process which applies a refractin texture
  36960. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  36961. */
  36962. class RefractionPostProcess extends PostProcess {
  36963. /** the base color of the refraction (used to taint the rendering) */
  36964. color: Color3;
  36965. /** simulated refraction depth */
  36966. depth: number;
  36967. /** the coefficient of the base color (0 to remove base color tainting) */
  36968. colorLevel: number;
  36969. private _refTexture;
  36970. private _ownRefractionTexture;
  36971. /**
  36972. * Gets or sets the refraction texture
  36973. * Please note that you are responsible for disposing the texture if you set it manually
  36974. */
  36975. refractionTexture: Texture;
  36976. /**
  36977. * Initializes the RefractionPostProcess
  36978. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  36979. * @param name The name of the effect.
  36980. * @param refractionTextureUrl Url of the refraction texture to use
  36981. * @param color the base color of the refraction (used to taint the rendering)
  36982. * @param depth simulated refraction depth
  36983. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  36984. * @param camera The camera to apply the render pass to.
  36985. * @param options The required width/height ratio to downsize to before computing the render pass.
  36986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36987. * @param engine The engine which the post process will be applied. (default: current engine)
  36988. * @param reusable If the post process can be reused on the same frame. (default: false)
  36989. */
  36990. constructor(name: string, refractionTextureUrl: string,
  36991. /** the base color of the refraction (used to taint the rendering) */
  36992. color: Color3,
  36993. /** simulated refraction depth */
  36994. depth: number,
  36995. /** the coefficient of the base color (0 to remove base color tainting) */
  36996. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36997. /**
  36998. * Disposes of the post process
  36999. * @param camera Camera to dispose post process on
  37000. */
  37001. dispose(camera: Camera): void;
  37002. }
  37003. }
  37004. declare module BABYLON {
  37005. /**
  37006. * The SharpenPostProcess applies a sharpen kernel to every pixel
  37007. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  37008. */
  37009. class SharpenPostProcess extends PostProcess {
  37010. /**
  37011. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  37012. */
  37013. colorAmount: number;
  37014. /**
  37015. * How much sharpness should be applied (default: 0.3)
  37016. */
  37017. edgeAmount: number;
  37018. /**
  37019. * Creates a new instance ConvolutionPostProcess
  37020. * @param name The name of the effect.
  37021. * @param options The required width/height ratio to downsize to before computing the render pass.
  37022. * @param camera The camera to apply the render pass to.
  37023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37024. * @param engine The engine which the post process will be applied. (default: current engine)
  37025. * @param reusable If the post process can be reused on the same frame. (default: false)
  37026. * @param textureType Type of textures used when performing the post process. (default: 0)
  37027. * @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)
  37028. */
  37029. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37030. }
  37031. }
  37032. declare module BABYLON {
  37033. /**
  37034. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37035. */
  37036. class StereoscopicInterlacePostProcess extends PostProcess {
  37037. private _stepSize;
  37038. private _passedProcess;
  37039. /**
  37040. * Initializes a StereoscopicInterlacePostProcess
  37041. * @param name The name of the effect.
  37042. * @param rigCameras The rig cameras to be appled to the post process
  37043. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37045. * @param engine The engine which the post process will be applied. (default: current engine)
  37046. * @param reusable If the post process can be reused on the same frame. (default: false)
  37047. */
  37048. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37049. }
  37050. }
  37051. declare module BABYLON {
  37052. /** Defines operator used for tonemapping */
  37053. enum TonemappingOperator {
  37054. /** Hable */
  37055. Hable = 0,
  37056. /** Reinhard */
  37057. Reinhard = 1,
  37058. /** HejiDawson */
  37059. HejiDawson = 2,
  37060. /** Photographic */
  37061. Photographic = 3
  37062. }
  37063. /**
  37064. * Defines a post process to apply tone mapping
  37065. */
  37066. class TonemapPostProcess extends PostProcess {
  37067. private _operator;
  37068. /** Defines the required exposure adjustement */
  37069. exposureAdjustment: number;
  37070. /**
  37071. * Creates a new TonemapPostProcess
  37072. * @param name defines the name of the postprocess
  37073. * @param _operator defines the operator to use
  37074. * @param exposureAdjustment defines the required exposure adjustement
  37075. * @param camera defines the camera to use (can be null)
  37076. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  37077. * @param engine defines the hosting engine (can be ignore if camera is set)
  37078. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  37079. */
  37080. constructor(name: string, _operator: TonemappingOperator,
  37081. /** Defines the required exposure adjustement */
  37082. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  37083. }
  37084. }
  37085. declare module BABYLON {
  37086. /**
  37087. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  37088. */
  37089. class VolumetricLightScatteringPostProcess extends PostProcess {
  37090. private _volumetricLightScatteringPass;
  37091. private _volumetricLightScatteringRTT;
  37092. private _viewPort;
  37093. private _screenCoordinates;
  37094. private _cachedDefines;
  37095. /**
  37096. * If not undefined, the mesh position is computed from the attached node position
  37097. */
  37098. attachedNode: {
  37099. position: Vector3;
  37100. };
  37101. /**
  37102. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  37103. */
  37104. customMeshPosition: Vector3;
  37105. /**
  37106. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  37107. */
  37108. useCustomMeshPosition: boolean;
  37109. /**
  37110. * If the post-process should inverse the light scattering direction
  37111. */
  37112. invert: boolean;
  37113. /**
  37114. * The internal mesh used by the post-process
  37115. */
  37116. mesh: Mesh;
  37117. /**
  37118. * @hidden
  37119. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  37120. */
  37121. useDiffuseColor: boolean;
  37122. /**
  37123. * Array containing the excluded meshes not rendered in the internal pass
  37124. */
  37125. excludedMeshes: AbstractMesh[];
  37126. /**
  37127. * Controls the overall intensity of the post-process
  37128. */
  37129. exposure: number;
  37130. /**
  37131. * Dissipates each sample's contribution in range [0, 1]
  37132. */
  37133. decay: number;
  37134. /**
  37135. * Controls the overall intensity of each sample
  37136. */
  37137. weight: number;
  37138. /**
  37139. * Controls the density of each sample
  37140. */
  37141. density: number;
  37142. /**
  37143. * @constructor
  37144. * @param name The post-process name
  37145. * @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)
  37146. * @param camera The camera that the post-process will be attached to
  37147. * @param mesh The mesh used to create the light scattering
  37148. * @param samples The post-process quality, default 100
  37149. * @param samplingModeThe post-process filtering mode
  37150. * @param engine The babylon engine
  37151. * @param reusable If the post-process is reusable
  37152. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  37153. */
  37154. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  37155. /**
  37156. * Returns the string "VolumetricLightScatteringPostProcess"
  37157. * @returns "VolumetricLightScatteringPostProcess"
  37158. */
  37159. getClassName(): string;
  37160. private _isReady;
  37161. /**
  37162. * Sets the new light position for light scattering effect
  37163. * @param position The new custom light position
  37164. */
  37165. setCustomMeshPosition(position: Vector3): void;
  37166. /**
  37167. * Returns the light position for light scattering effect
  37168. * @return Vector3 The custom light position
  37169. */
  37170. getCustomMeshPosition(): Vector3;
  37171. /**
  37172. * Disposes the internal assets and detaches the post-process from the camera
  37173. */
  37174. dispose(camera: Camera): void;
  37175. /**
  37176. * Returns the render target texture used by the post-process
  37177. * @return the render target texture used by the post-process
  37178. */
  37179. getPass(): RenderTargetTexture;
  37180. private _meshExcluded;
  37181. private _createPass;
  37182. private _updateMeshScreenCoordinates;
  37183. /**
  37184. * Creates a default mesh for the Volumeric Light Scattering post-process
  37185. * @param name The mesh name
  37186. * @param scene The scene where to create the mesh
  37187. * @return the default mesh
  37188. */
  37189. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  37190. }
  37191. }
  37192. declare module BABYLON {
  37193. /**
  37194. * VRDistortionCorrectionPostProcess used for mobile VR
  37195. */
  37196. class VRDistortionCorrectionPostProcess extends PostProcess {
  37197. private _isRightEye;
  37198. private _distortionFactors;
  37199. private _postProcessScaleFactor;
  37200. private _lensCenterOffset;
  37201. private _scaleIn;
  37202. private _scaleFactor;
  37203. private _lensCenter;
  37204. /**
  37205. * Initializes the VRDistortionCorrectionPostProcess
  37206. * @param name The name of the effect.
  37207. * @param camera The camera to apply the render pass to.
  37208. * @param isRightEye If this is for the right eye distortion
  37209. * @param vrMetrics All the required metrics for the VR camera
  37210. */
  37211. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37212. }
  37213. }
  37214. declare module BABYLON {
  37215. /**
  37216. * @hidden
  37217. **/
  37218. class _AlphaState {
  37219. private _isAlphaBlendDirty;
  37220. private _isBlendFunctionParametersDirty;
  37221. private _isBlendEquationParametersDirty;
  37222. private _isBlendConstantsDirty;
  37223. private _alphaBlend;
  37224. private _blendFunctionParameters;
  37225. private _blendEquationParameters;
  37226. private _blendConstants;
  37227. /**
  37228. * Initializes the state.
  37229. */
  37230. constructor();
  37231. readonly isDirty: boolean;
  37232. alphaBlend: boolean;
  37233. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  37234. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  37235. setAlphaEquationParameters(rgb: number, alpha: number): void;
  37236. reset(): void;
  37237. apply(gl: WebGLRenderingContext): void;
  37238. }
  37239. }
  37240. declare module BABYLON {
  37241. /**
  37242. * @hidden
  37243. **/
  37244. class _DepthCullingState {
  37245. private _isDepthTestDirty;
  37246. private _isDepthMaskDirty;
  37247. private _isDepthFuncDirty;
  37248. private _isCullFaceDirty;
  37249. private _isCullDirty;
  37250. private _isZOffsetDirty;
  37251. private _isFrontFaceDirty;
  37252. private _depthTest;
  37253. private _depthMask;
  37254. private _depthFunc;
  37255. private _cull;
  37256. private _cullFace;
  37257. private _zOffset;
  37258. private _frontFace;
  37259. /**
  37260. * Initializes the state.
  37261. */
  37262. constructor();
  37263. readonly isDirty: boolean;
  37264. zOffset: number;
  37265. cullFace: Nullable<number>;
  37266. cull: Nullable<boolean>;
  37267. depthFunc: Nullable<number>;
  37268. depthMask: boolean;
  37269. depthTest: boolean;
  37270. frontFace: Nullable<number>;
  37271. reset(): void;
  37272. apply(gl: WebGLRenderingContext): void;
  37273. }
  37274. }
  37275. declare module BABYLON {
  37276. /**
  37277. * @hidden
  37278. **/
  37279. class _StencilState {
  37280. private _isStencilTestDirty;
  37281. private _isStencilMaskDirty;
  37282. private _isStencilFuncDirty;
  37283. private _isStencilOpDirty;
  37284. private _stencilTest;
  37285. private _stencilMask;
  37286. private _stencilFunc;
  37287. private _stencilFuncRef;
  37288. private _stencilFuncMask;
  37289. private _stencilOpStencilFail;
  37290. private _stencilOpDepthFail;
  37291. private _stencilOpStencilDepthPass;
  37292. readonly isDirty: boolean;
  37293. stencilFunc: number;
  37294. stencilFuncRef: number;
  37295. stencilFuncMask: number;
  37296. stencilOpStencilFail: number;
  37297. stencilOpDepthFail: number;
  37298. stencilOpStencilDepthPass: number;
  37299. stencilMask: number;
  37300. stencilTest: boolean;
  37301. constructor();
  37302. reset(): void;
  37303. apply(gl: WebGLRenderingContext): void;
  37304. }
  37305. }
  37306. declare module BABYLON {
  37307. /**
  37308. * Class used to evalaute queries containing `and` and `or` operators
  37309. */
  37310. class AndOrNotEvaluator {
  37311. /**
  37312. * Evaluate a query
  37313. * @param query defines the query to evaluate
  37314. * @param evaluateCallback defines the callback used to filter result
  37315. * @returns true if the query matches
  37316. */
  37317. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  37318. private static _HandleParenthesisContent;
  37319. private static _SimplifyNegation;
  37320. }
  37321. }
  37322. declare module BABYLON {
  37323. /**
  37324. * Defines the list of states available for a task inside a AssetsManager
  37325. */
  37326. enum AssetTaskState {
  37327. /**
  37328. * Initialization
  37329. */
  37330. INIT = 0,
  37331. /**
  37332. * Running
  37333. */
  37334. RUNNING = 1,
  37335. /**
  37336. * Done
  37337. */
  37338. DONE = 2,
  37339. /**
  37340. * Error
  37341. */
  37342. ERROR = 3
  37343. }
  37344. /**
  37345. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  37346. */
  37347. abstract class AbstractAssetTask {
  37348. /**
  37349. * Task name
  37350. */ name: string;
  37351. /**
  37352. * Callback called when the task is successful
  37353. */
  37354. onSuccess: (task: any) => void;
  37355. /**
  37356. * Callback called when the task is not successful
  37357. */
  37358. onError: (task: any, message?: string, exception?: any) => void;
  37359. /**
  37360. * Creates a new AssetsManager
  37361. * @param name defines the name of the task
  37362. */
  37363. constructor(
  37364. /**
  37365. * Task name
  37366. */ name: string);
  37367. private _isCompleted;
  37368. private _taskState;
  37369. private _errorObject;
  37370. /**
  37371. * Get if the task is completed
  37372. */
  37373. readonly isCompleted: boolean;
  37374. /**
  37375. * Gets the current state of the task
  37376. */
  37377. readonly taskState: AssetTaskState;
  37378. /**
  37379. * Gets the current error object (if task is in error)
  37380. */
  37381. readonly errorObject: {
  37382. message?: string;
  37383. exception?: any;
  37384. };
  37385. /**
  37386. * Internal only
  37387. * @hidden
  37388. */
  37389. _setErrorObject(message?: string, exception?: any): void;
  37390. /**
  37391. * Execute the current task
  37392. * @param scene defines the scene where you want your assets to be loaded
  37393. * @param onSuccess is a callback called when the task is successfully executed
  37394. * @param onError is a callback called if an error occurs
  37395. */
  37396. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37397. /**
  37398. * Execute the current task
  37399. * @param scene defines the scene where you want your assets to be loaded
  37400. * @param onSuccess is a callback called when the task is successfully executed
  37401. * @param onError is a callback called if an error occurs
  37402. */
  37403. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37404. /**
  37405. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  37406. * This can be used with failed tasks that have the reason for failure fixed.
  37407. */
  37408. reset(): void;
  37409. private onErrorCallback;
  37410. private onDoneCallback;
  37411. }
  37412. /**
  37413. * Define the interface used by progress events raised during assets loading
  37414. */
  37415. interface IAssetsProgressEvent {
  37416. /**
  37417. * Defines the number of remaining tasks to process
  37418. */
  37419. remainingCount: number;
  37420. /**
  37421. * Defines the total number of tasks
  37422. */
  37423. totalCount: number;
  37424. /**
  37425. * Defines the task that was just processed
  37426. */
  37427. task: AbstractAssetTask;
  37428. }
  37429. /**
  37430. * Class used to share progress information about assets loading
  37431. */
  37432. class AssetsProgressEvent implements IAssetsProgressEvent {
  37433. /**
  37434. * Defines the number of remaining tasks to process
  37435. */
  37436. remainingCount: number;
  37437. /**
  37438. * Defines the total number of tasks
  37439. */
  37440. totalCount: number;
  37441. /**
  37442. * Defines the task that was just processed
  37443. */
  37444. task: AbstractAssetTask;
  37445. /**
  37446. * Creates a AssetsProgressEvent
  37447. * @param remainingCount defines the number of remaining tasks to process
  37448. * @param totalCount defines the total number of tasks
  37449. * @param task defines the task that was just processed
  37450. */
  37451. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  37452. }
  37453. /**
  37454. * Define a task used by AssetsManager to load meshes
  37455. */
  37456. class MeshAssetTask extends AbstractAssetTask {
  37457. /**
  37458. * Defines the name of the task
  37459. */
  37460. name: string;
  37461. /**
  37462. * Defines the list of mesh's names you want to load
  37463. */
  37464. meshesNames: any;
  37465. /**
  37466. * Defines the root url to use as a base to load your meshes and associated resources
  37467. */
  37468. rootUrl: string;
  37469. /**
  37470. * Defines the filename of the scene to load from
  37471. */
  37472. sceneFilename: string;
  37473. /**
  37474. * Gets the list of loaded meshes
  37475. */
  37476. loadedMeshes: Array<AbstractMesh>;
  37477. /**
  37478. * Gets the list of loaded particle systems
  37479. */
  37480. loadedParticleSystems: Array<IParticleSystem>;
  37481. /**
  37482. * Gets the list of loaded skeletons
  37483. */
  37484. loadedSkeletons: Array<Skeleton>;
  37485. /**
  37486. * Callback called when the task is successful
  37487. */
  37488. onSuccess: (task: MeshAssetTask) => void;
  37489. /**
  37490. * Callback called when the task is successful
  37491. */
  37492. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  37493. /**
  37494. * Creates a new MeshAssetTask
  37495. * @param name defines the name of the task
  37496. * @param meshesNames defines the list of mesh's names you want to load
  37497. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  37498. * @param sceneFilename defines the filename of the scene to load from
  37499. */
  37500. constructor(
  37501. /**
  37502. * Defines the name of the task
  37503. */
  37504. name: string,
  37505. /**
  37506. * Defines the list of mesh's names you want to load
  37507. */
  37508. meshesNames: any,
  37509. /**
  37510. * Defines the root url to use as a base to load your meshes and associated resources
  37511. */
  37512. rootUrl: string,
  37513. /**
  37514. * Defines the filename of the scene to load from
  37515. */
  37516. sceneFilename: string);
  37517. /**
  37518. * Execute the current task
  37519. * @param scene defines the scene where you want your assets to be loaded
  37520. * @param onSuccess is a callback called when the task is successfully executed
  37521. * @param onError is a callback called if an error occurs
  37522. */
  37523. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37524. }
  37525. /**
  37526. * Define a task used by AssetsManager to load text content
  37527. */
  37528. class TextFileAssetTask extends AbstractAssetTask {
  37529. /**
  37530. * Defines the name of the task
  37531. */
  37532. name: string;
  37533. /**
  37534. * Defines the location of the file to load
  37535. */
  37536. url: string;
  37537. /**
  37538. * Gets the loaded text string
  37539. */
  37540. text: string;
  37541. /**
  37542. * Callback called when the task is successful
  37543. */
  37544. onSuccess: (task: TextFileAssetTask) => void;
  37545. /**
  37546. * Callback called when the task is successful
  37547. */
  37548. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  37549. /**
  37550. * Creates a new TextFileAssetTask object
  37551. * @param name defines the name of the task
  37552. * @param url defines the location of the file to load
  37553. */
  37554. constructor(
  37555. /**
  37556. * Defines the name of the task
  37557. */
  37558. name: string,
  37559. /**
  37560. * Defines the location of the file to load
  37561. */
  37562. url: string);
  37563. /**
  37564. * Execute the current task
  37565. * @param scene defines the scene where you want your assets to be loaded
  37566. * @param onSuccess is a callback called when the task is successfully executed
  37567. * @param onError is a callback called if an error occurs
  37568. */
  37569. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37570. }
  37571. /**
  37572. * Define a task used by AssetsManager to load binary data
  37573. */
  37574. class BinaryFileAssetTask extends AbstractAssetTask {
  37575. /**
  37576. * Defines the name of the task
  37577. */
  37578. name: string;
  37579. /**
  37580. * Defines the location of the file to load
  37581. */
  37582. url: string;
  37583. /**
  37584. * Gets the lodaded data (as an array buffer)
  37585. */
  37586. data: ArrayBuffer;
  37587. /**
  37588. * Callback called when the task is successful
  37589. */
  37590. onSuccess: (task: BinaryFileAssetTask) => void;
  37591. /**
  37592. * Callback called when the task is successful
  37593. */
  37594. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37595. /**
  37596. * Creates a new BinaryFileAssetTask object
  37597. * @param name defines the name of the new task
  37598. * @param url defines the location of the file to load
  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. * Execute the current task
  37611. * @param scene defines the scene where you want your assets to be loaded
  37612. * @param onSuccess is a callback called when the task is successfully executed
  37613. * @param onError is a callback called if an error occurs
  37614. */
  37615. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37616. }
  37617. /**
  37618. * Define a task used by AssetsManager to load images
  37619. */
  37620. class ImageAssetTask extends AbstractAssetTask {
  37621. /**
  37622. * Defines the name of the task
  37623. */
  37624. name: string;
  37625. /**
  37626. * Defines the location of the image to load
  37627. */
  37628. url: string;
  37629. /**
  37630. * Gets the loaded images
  37631. */
  37632. image: HTMLImageElement;
  37633. /**
  37634. * Callback called when the task is successful
  37635. */
  37636. onSuccess: (task: ImageAssetTask) => void;
  37637. /**
  37638. * Callback called when the task is successful
  37639. */
  37640. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37641. /**
  37642. * Creates a new ImageAssetTask
  37643. * @param name defines the name of the task
  37644. * @param url defines the location of the image to load
  37645. */
  37646. constructor(
  37647. /**
  37648. * Defines the name of the task
  37649. */
  37650. name: string,
  37651. /**
  37652. * Defines the location of the image to load
  37653. */
  37654. url: string);
  37655. /**
  37656. * Execute the current task
  37657. * @param scene defines the scene where you want your assets to be loaded
  37658. * @param onSuccess is a callback called when the task is successfully executed
  37659. * @param onError is a callback called if an error occurs
  37660. */
  37661. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37662. }
  37663. /**
  37664. * Defines the interface used by texture loading tasks
  37665. */
  37666. interface ITextureAssetTask<TEX extends BaseTexture> {
  37667. /**
  37668. * Gets the loaded texture
  37669. */
  37670. texture: TEX;
  37671. }
  37672. /**
  37673. * Define a task used by AssetsManager to load 2D textures
  37674. */
  37675. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37676. /**
  37677. * Defines the name of the task
  37678. */
  37679. name: string;
  37680. /**
  37681. * Defines the location of the file to load
  37682. */
  37683. url: string;
  37684. /**
  37685. * Defines if mipmap should not be generated (default is false)
  37686. */
  37687. noMipmap?: boolean | undefined;
  37688. /**
  37689. * Defines if texture must be inverted on Y axis (default is false)
  37690. */
  37691. invertY?: boolean | undefined;
  37692. /**
  37693. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37694. */
  37695. samplingMode: number;
  37696. /**
  37697. * Gets the loaded texture
  37698. */
  37699. texture: Texture;
  37700. /**
  37701. * Callback called when the task is successful
  37702. */
  37703. onSuccess: (task: TextureAssetTask) => void;
  37704. /**
  37705. * Callback called when the task is successful
  37706. */
  37707. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37708. /**
  37709. * Creates a new TextureAssetTask object
  37710. * @param name defines the name of the task
  37711. * @param url defines the location of the file to load
  37712. * @param noMipmap defines if mipmap should not be generated (default is false)
  37713. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37714. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37715. */
  37716. constructor(
  37717. /**
  37718. * Defines the name of the task
  37719. */
  37720. name: string,
  37721. /**
  37722. * Defines the location of the file to load
  37723. */
  37724. url: string,
  37725. /**
  37726. * Defines if mipmap should not be generated (default is false)
  37727. */
  37728. noMipmap?: boolean | undefined,
  37729. /**
  37730. * Defines if texture must be inverted on Y axis (default is false)
  37731. */
  37732. invertY?: boolean | undefined,
  37733. /**
  37734. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37735. */
  37736. samplingMode?: number);
  37737. /**
  37738. * Execute the current task
  37739. * @param scene defines the scene where you want your assets to be loaded
  37740. * @param onSuccess is a callback called when the task is successfully executed
  37741. * @param onError is a callback called if an error occurs
  37742. */
  37743. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37744. }
  37745. /**
  37746. * Define a task used by AssetsManager to load cube textures
  37747. */
  37748. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37749. /**
  37750. * Defines the name of the task
  37751. */
  37752. name: string;
  37753. /**
  37754. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37755. */
  37756. url: string;
  37757. /**
  37758. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37759. */
  37760. extensions?: string[] | undefined;
  37761. /**
  37762. * Defines if mipmaps should not be generated (default is false)
  37763. */
  37764. noMipmap?: boolean | undefined;
  37765. /**
  37766. * Defines the explicit list of files (undefined by default)
  37767. */
  37768. files?: string[] | undefined;
  37769. /**
  37770. * Gets the loaded texture
  37771. */
  37772. texture: CubeTexture;
  37773. /**
  37774. * Callback called when the task is successful
  37775. */
  37776. onSuccess: (task: CubeTextureAssetTask) => void;
  37777. /**
  37778. * Callback called when the task is successful
  37779. */
  37780. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37781. /**
  37782. * Creates a new CubeTextureAssetTask
  37783. * @param name defines the name of the task
  37784. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37785. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37786. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37787. * @param files defines the explicit list of files (undefined by default)
  37788. */
  37789. constructor(
  37790. /**
  37791. * Defines the name of the task
  37792. */
  37793. name: string,
  37794. /**
  37795. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37796. */
  37797. url: string,
  37798. /**
  37799. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37800. */
  37801. extensions?: string[] | undefined,
  37802. /**
  37803. * Defines if mipmaps should not be generated (default is false)
  37804. */
  37805. noMipmap?: boolean | undefined,
  37806. /**
  37807. * Defines the explicit list of files (undefined by default)
  37808. */
  37809. files?: string[] | undefined);
  37810. /**
  37811. * Execute the current task
  37812. * @param scene defines the scene where you want your assets to be loaded
  37813. * @param onSuccess is a callback called when the task is successfully executed
  37814. * @param onError is a callback called if an error occurs
  37815. */
  37816. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37817. }
  37818. /**
  37819. * Define a task used by AssetsManager to load HDR cube textures
  37820. */
  37821. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37822. /**
  37823. * Defines the name of the task
  37824. */
  37825. name: string;
  37826. /**
  37827. * Defines the location of the file to load
  37828. */
  37829. url: string;
  37830. /**
  37831. * Defines the desired size (the more it increases the longer the generation will be)
  37832. */
  37833. size: number;
  37834. /**
  37835. * Defines if mipmaps should not be generated (default is false)
  37836. */
  37837. noMipmap: boolean;
  37838. /**
  37839. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37840. */
  37841. generateHarmonics: boolean;
  37842. /**
  37843. * 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)
  37844. */
  37845. gammaSpace: boolean;
  37846. /**
  37847. * Internal Use Only
  37848. */
  37849. reserved: boolean;
  37850. /**
  37851. * Gets the loaded texture
  37852. */
  37853. texture: HDRCubeTexture;
  37854. /**
  37855. * Callback called when the task is successful
  37856. */
  37857. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37858. /**
  37859. * Callback called when the task is successful
  37860. */
  37861. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37862. /**
  37863. * Creates a new HDRCubeTextureAssetTask object
  37864. * @param name defines the name of the task
  37865. * @param url defines the location of the file to load
  37866. * @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.
  37867. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37868. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37869. * @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)
  37870. * @param reserved Internal use only
  37871. */
  37872. constructor(
  37873. /**
  37874. * Defines the name of the task
  37875. */
  37876. name: string,
  37877. /**
  37878. * Defines the location of the file to load
  37879. */
  37880. url: string,
  37881. /**
  37882. * Defines the desired size (the more it increases the longer the generation will be)
  37883. */
  37884. size: number,
  37885. /**
  37886. * Defines if mipmaps should not be generated (default is false)
  37887. */
  37888. noMipmap?: boolean,
  37889. /**
  37890. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37891. */
  37892. generateHarmonics?: boolean,
  37893. /**
  37894. * 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)
  37895. */
  37896. gammaSpace?: boolean,
  37897. /**
  37898. * Internal Use Only
  37899. */
  37900. reserved?: boolean);
  37901. /**
  37902. * Execute the current task
  37903. * @param scene defines the scene where you want your assets to be loaded
  37904. * @param onSuccess is a callback called when the task is successfully executed
  37905. * @param onError is a callback called if an error occurs
  37906. */
  37907. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37908. }
  37909. /**
  37910. * This class can be used to easily import assets into a scene
  37911. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37912. */
  37913. class AssetsManager {
  37914. private _scene;
  37915. private _isLoading;
  37916. protected _tasks: AbstractAssetTask[];
  37917. protected _waitingTasksCount: number;
  37918. protected _totalTasksCount: number;
  37919. /**
  37920. * Callback called when all tasks are processed
  37921. */
  37922. onFinish: (tasks: AbstractAssetTask[]) => void;
  37923. /**
  37924. * Callback called when a task is successful
  37925. */
  37926. onTaskSuccess: (task: AbstractAssetTask) => void;
  37927. /**
  37928. * Callback called when a task had an error
  37929. */
  37930. onTaskError: (task: AbstractAssetTask) => void;
  37931. /**
  37932. * Callback called when a task is done (whatever the result is)
  37933. */
  37934. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37935. /**
  37936. * Observable called when all tasks are processed
  37937. */
  37938. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37939. /**
  37940. * Observable called when a task had an error
  37941. */
  37942. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37943. /**
  37944. * Observable called when a task is successful
  37945. */
  37946. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37947. /**
  37948. * Observable called when a task is done (whatever the result is)
  37949. */
  37950. onProgressObservable: Observable<IAssetsProgressEvent>;
  37951. /**
  37952. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37953. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37954. */
  37955. useDefaultLoadingScreen: boolean;
  37956. /**
  37957. * Creates a new AssetsManager
  37958. * @param scene defines the scene to work on
  37959. */
  37960. constructor(scene: Scene);
  37961. /**
  37962. * Add a MeshAssetTask to the list of active tasks
  37963. * @param taskName defines the name of the new task
  37964. * @param meshesNames defines the name of meshes to load
  37965. * @param rootUrl defines the root url to use to locate files
  37966. * @param sceneFilename defines the filename of the scene file
  37967. * @returns a new MeshAssetTask object
  37968. */
  37969. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37970. /**
  37971. * Add a TextFileAssetTask to the list of active tasks
  37972. * @param taskName defines the name of the new task
  37973. * @param url defines the url of the file to load
  37974. * @returns a new TextFileAssetTask object
  37975. */
  37976. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37977. /**
  37978. * Add a BinaryFileAssetTask to the list of active tasks
  37979. * @param taskName defines the name of the new task
  37980. * @param url defines the url of the file to load
  37981. * @returns a new BinaryFileAssetTask object
  37982. */
  37983. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37984. /**
  37985. * Add a ImageAssetTask to the list of active tasks
  37986. * @param taskName defines the name of the new task
  37987. * @param url defines the url of the file to load
  37988. * @returns a new ImageAssetTask object
  37989. */
  37990. addImageTask(taskName: string, url: string): ImageAssetTask;
  37991. /**
  37992. * Add a TextureAssetTask to the list of active tasks
  37993. * @param taskName defines the name of the new task
  37994. * @param url defines the url of the file to load
  37995. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37996. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37997. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37998. * @returns a new TextureAssetTask object
  37999. */
  38000. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  38001. /**
  38002. * Add a CubeTextureAssetTask to the list of active tasks
  38003. * @param taskName defines the name of the new task
  38004. * @param url defines the url of the file to load
  38005. * @param extensions defines the extension to use to load the cube map (can be null)
  38006. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  38007. * @param files defines the list of files to load (can be null)
  38008. * @returns a new CubeTextureAssetTask object
  38009. */
  38010. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  38011. /**
  38012. *
  38013. * Add a HDRCubeTextureAssetTask to the list of active tasks
  38014. * @param taskName defines the name of the new task
  38015. * @param url defines the url of the file to load
  38016. * @param size defines the size you want for the cubemap (can be null)
  38017. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  38018. * @param generateHarmonics defines if you want to automatically generate (true by default)
  38019. * @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)
  38020. * @param reserved Internal use only
  38021. * @returns a new HDRCubeTextureAssetTask object
  38022. */
  38023. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  38024. /**
  38025. * Remove a task from the assets manager.
  38026. * @param task the task to remove
  38027. */
  38028. removeTask(task: AbstractAssetTask): void;
  38029. private _decreaseWaitingTasksCount;
  38030. private _runTask;
  38031. /**
  38032. * Reset the AssetsManager and remove all tasks
  38033. * @return the current instance of the AssetsManager
  38034. */
  38035. reset(): AssetsManager;
  38036. /**
  38037. * Start the loading process
  38038. * @return the current instance of the AssetsManager
  38039. */
  38040. load(): AssetsManager;
  38041. }
  38042. }
  38043. declare module BABYLON {
  38044. /**
  38045. * Direct draw surface info
  38046. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  38047. */
  38048. interface DDSInfo {
  38049. /**
  38050. * Width of the texture
  38051. */
  38052. width: number;
  38053. /**
  38054. * Width of the texture
  38055. */
  38056. height: number;
  38057. /**
  38058. * Number of Mipmaps for the texture
  38059. * @see https://en.wikipedia.org/wiki/Mipmap
  38060. */
  38061. mipmapCount: number;
  38062. /**
  38063. * If the textures format is a known fourCC format
  38064. * @see https://www.fourcc.org/
  38065. */
  38066. isFourCC: boolean;
  38067. /**
  38068. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  38069. */
  38070. isRGB: boolean;
  38071. /**
  38072. * If the texture is a lumincance format
  38073. */
  38074. isLuminance: boolean;
  38075. /**
  38076. * If this is a cube texture
  38077. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  38078. */
  38079. isCube: boolean;
  38080. /**
  38081. * If the texture is a compressed format eg. FOURCC_DXT1
  38082. */
  38083. isCompressed: boolean;
  38084. /**
  38085. * The dxgiFormat of the texture
  38086. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  38087. */
  38088. dxgiFormat: number;
  38089. /**
  38090. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  38091. */
  38092. textureType: number;
  38093. /**
  38094. * Sphericle polynomial created for the dds texture
  38095. */
  38096. sphericalPolynomial?: SphericalPolynomial;
  38097. }
  38098. /**
  38099. * Class used to provide DDS decompression tools
  38100. */
  38101. class DDSTools {
  38102. /**
  38103. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  38104. */
  38105. static StoreLODInAlphaChannel: boolean;
  38106. /**
  38107. * Gets DDS information from an array buffer
  38108. * @param arrayBuffer defines the array buffer to read data from
  38109. * @returns the DDS information
  38110. */
  38111. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  38112. private static _FloatView;
  38113. private static _Int32View;
  38114. private static _ToHalfFloat;
  38115. private static _FromHalfFloat;
  38116. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  38117. private static _GetHalfFloatRGBAArrayBuffer;
  38118. private static _GetFloatRGBAArrayBuffer;
  38119. private static _GetFloatAsUIntRGBAArrayBuffer;
  38120. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  38121. private static _GetRGBAArrayBuffer;
  38122. private static _ExtractLongWordOrder;
  38123. private static _GetRGBArrayBuffer;
  38124. private static _GetLuminanceArrayBuffer;
  38125. /**
  38126. * Uploads DDS Levels to a Babylon Texture
  38127. * @hidden
  38128. */
  38129. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  38130. }
  38131. }
  38132. declare module BABYLON {
  38133. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38134. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38135. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38136. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38137. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38138. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38139. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38140. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38141. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38142. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38143. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38144. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38145. /**
  38146. * Decorator used to define property that can be serialized as reference to a camera
  38147. * @param sourceName defines the name of the property to decorate
  38148. */
  38149. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38150. /**
  38151. * Class used to help serialization objects
  38152. */
  38153. class SerializationHelper {
  38154. /**
  38155. * Static function used to serialized a specific entity
  38156. * @param entity defines the entity to serialize
  38157. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38158. * @returns a JSON compatible object representing the serialization of the entity
  38159. */
  38160. static Serialize<T>(entity: T, serializationObject?: any): any;
  38161. /**
  38162. * Creates a new entity from a serialization data object
  38163. * @param creationFunction defines a function used to instanciated the new entity
  38164. * @param source defines the source serialization data
  38165. * @param scene defines the hosting scene
  38166. * @param rootUrl defines the root url for resources
  38167. * @returns a new entity
  38168. */
  38169. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38170. /**
  38171. * Clones an object
  38172. * @param creationFunction defines the function used to instanciate the new object
  38173. * @param source defines the source object
  38174. * @returns the cloned object
  38175. */
  38176. static Clone<T>(creationFunction: () => T, source: T): T;
  38177. /**
  38178. * Instanciates a new object based on a source one (some data will be shared between both object)
  38179. * @param creationFunction defines the function used to instanciate the new object
  38180. * @param source defines the source object
  38181. * @returns the new object
  38182. */
  38183. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38184. }
  38185. }
  38186. declare module BABYLON {
  38187. /**
  38188. * Wrapper class for promise with external resolve and reject.
  38189. */
  38190. class Deferred<T> {
  38191. /**
  38192. * The promise associated with this deferred object.
  38193. */
  38194. readonly promise: Promise<T>;
  38195. private _resolve;
  38196. private _reject;
  38197. /**
  38198. * The resolve method of the promise associated with this deferred object.
  38199. */
  38200. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  38201. /**
  38202. * The reject method of the promise associated with this deferred object.
  38203. */
  38204. readonly reject: (reason?: any) => void;
  38205. /**
  38206. * Constructor for this deferred object.
  38207. */
  38208. constructor();
  38209. }
  38210. }
  38211. declare module BABYLON {
  38212. /**
  38213. * Raw texture data and descriptor sufficient for WebGL texture upload
  38214. */
  38215. interface EnvironmentTextureInfo {
  38216. /**
  38217. * Version of the environment map
  38218. */
  38219. version: number;
  38220. /**
  38221. * Width of image
  38222. */
  38223. width: number;
  38224. /**
  38225. * Irradiance information stored in the file.
  38226. */
  38227. irradiance: any;
  38228. /**
  38229. * Specular information stored in the file.
  38230. */
  38231. specular: any;
  38232. }
  38233. /**
  38234. * Sets of helpers addressing the serialization and deserialization of environment texture
  38235. * stored in a BabylonJS env file.
  38236. * Those files are usually stored as .env files.
  38237. */
  38238. class EnvironmentTextureTools {
  38239. /**
  38240. * Magic number identifying the env file.
  38241. */
  38242. private static _MagicBytes;
  38243. /**
  38244. * Gets the environment info from an env file.
  38245. * @param data The array buffer containing the .env bytes.
  38246. * @returns the environment file info (the json header) if successfully parsed.
  38247. */
  38248. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  38249. /**
  38250. * Creates an environment texture from a loaded cube texture.
  38251. * @param texture defines the cube texture to convert in env file
  38252. * @return a promise containing the environment data if succesfull.
  38253. */
  38254. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  38255. /**
  38256. * Creates a JSON representation of the spherical data.
  38257. * @param texture defines the texture containing the polynomials
  38258. * @return the JSON representation of the spherical info
  38259. */
  38260. private static _CreateEnvTextureIrradiance;
  38261. /**
  38262. * Uploads the texture info contained in the env file to the GPU.
  38263. * @param texture defines the internal texture to upload to
  38264. * @param arrayBuffer defines the buffer cotaining the data to load
  38265. * @param info defines the texture info retrieved through the GetEnvInfo method
  38266. * @returns a promise
  38267. */
  38268. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  38269. /**
  38270. * Uploads the levels of image data to the GPU.
  38271. * @param texture defines the internal texture to upload to
  38272. * @param imageData defines the array buffer views of image data [mipmap][face]
  38273. * @returns a promise
  38274. */
  38275. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  38276. /**
  38277. * Uploads spherical polynomials information to the texture.
  38278. * @param texture defines the texture we are trying to upload the information to
  38279. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  38280. */
  38281. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  38282. }
  38283. }
  38284. declare module BABYLON {
  38285. /**
  38286. * Class used to help managing file picking and drag'n'drop
  38287. */
  38288. class FilesInput {
  38289. /**
  38290. * List of files ready to be loaded
  38291. */
  38292. static FilesToLoad: {
  38293. [key: string]: File;
  38294. };
  38295. /**
  38296. * Callback called when a file is processed
  38297. */
  38298. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  38299. private _engine;
  38300. private _currentScene;
  38301. private _sceneLoadedCallback;
  38302. private _progressCallback;
  38303. private _additionalRenderLoopLogicCallback;
  38304. private _textureLoadingCallback;
  38305. private _startingProcessingFilesCallback;
  38306. private _onReloadCallback;
  38307. private _errorCallback;
  38308. private _elementToMonitor;
  38309. private _sceneFileToLoad;
  38310. private _filesToLoad;
  38311. /**
  38312. * Creates a new FilesInput
  38313. * @param engine defines the rendering engine
  38314. * @param scene defines the hosting scene
  38315. * @param sceneLoadedCallback callback called when scene is loaded
  38316. * @param progressCallback callback called to track progress
  38317. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  38318. * @param textureLoadingCallback callback called when a texture is loading
  38319. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  38320. * @param onReloadCallback callback called when a reload is requested
  38321. * @param errorCallback callback call if an error occurs
  38322. */
  38323. 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);
  38324. private _dragEnterHandler;
  38325. private _dragOverHandler;
  38326. private _dropHandler;
  38327. /**
  38328. * Calls this function to listen to drag'n'drop events on a specific DOM element
  38329. * @param elementToMonitor defines the DOM element to track
  38330. */
  38331. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  38332. /**
  38333. * Release all associated resources
  38334. */
  38335. dispose(): void;
  38336. private renderFunction;
  38337. private drag;
  38338. private drop;
  38339. private _traverseFolder;
  38340. private _processFiles;
  38341. /**
  38342. * Load files from a drop event
  38343. * @param event defines the drop event to use as source
  38344. */
  38345. loadFiles(event: any): void;
  38346. private _processReload;
  38347. /**
  38348. * Reload the current scene from the loaded files
  38349. */
  38350. reload(): void;
  38351. }
  38352. }
  38353. declare module BABYLON {
  38354. /**
  38355. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  38356. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  38357. */
  38358. class KhronosTextureContainer {
  38359. /** contents of the KTX container file */
  38360. arrayBuffer: any;
  38361. private static HEADER_LEN;
  38362. private static COMPRESSED_2D;
  38363. private static COMPRESSED_3D;
  38364. private static TEX_2D;
  38365. private static TEX_3D;
  38366. /**
  38367. * Gets the openGL type
  38368. */
  38369. glType: number;
  38370. /**
  38371. * Gets the openGL type size
  38372. */
  38373. glTypeSize: number;
  38374. /**
  38375. * Gets the openGL format
  38376. */
  38377. glFormat: number;
  38378. /**
  38379. * Gets the openGL internal format
  38380. */
  38381. glInternalFormat: number;
  38382. /**
  38383. * Gets the base internal format
  38384. */
  38385. glBaseInternalFormat: number;
  38386. /**
  38387. * Gets image width in pixel
  38388. */
  38389. pixelWidth: number;
  38390. /**
  38391. * Gets image height in pixel
  38392. */
  38393. pixelHeight: number;
  38394. /**
  38395. * Gets image depth in pixels
  38396. */
  38397. pixelDepth: number;
  38398. /**
  38399. * Gets the number of array elements
  38400. */
  38401. numberOfArrayElements: number;
  38402. /**
  38403. * Gets the number of faces
  38404. */
  38405. numberOfFaces: number;
  38406. /**
  38407. * Gets the number of mipmap levels
  38408. */
  38409. numberOfMipmapLevels: number;
  38410. /**
  38411. * Gets the bytes of key value data
  38412. */
  38413. bytesOfKeyValueData: number;
  38414. /**
  38415. * Gets the load type
  38416. */
  38417. loadType: number;
  38418. /**
  38419. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  38420. */
  38421. isInvalid: boolean;
  38422. /**
  38423. * Creates a new KhronosTextureContainer
  38424. * @param arrayBuffer contents of the KTX container file
  38425. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  38426. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  38427. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  38428. */
  38429. constructor(
  38430. /** contents of the KTX container file */
  38431. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  38432. /**
  38433. * Uploads KTX content to a Babylon Texture.
  38434. * It is assumed that the texture has already been created & is currently bound
  38435. * @hidden
  38436. */
  38437. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  38438. private _upload2DCompressedLevels;
  38439. }
  38440. }
  38441. declare module BABYLON {
  38442. /**
  38443. * A class serves as a medium between the observable and its observers
  38444. */
  38445. class EventState {
  38446. /**
  38447. * Create a new EventState
  38448. * @param mask defines the mask associated with this state
  38449. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38450. * @param target defines the original target of the state
  38451. * @param currentTarget defines the current target of the state
  38452. */
  38453. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  38454. /**
  38455. * Initialize the current event state
  38456. * @param mask defines the mask associated with this state
  38457. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38458. * @param target defines the original target of the state
  38459. * @param currentTarget defines the current target of the state
  38460. * @returns the current event state
  38461. */
  38462. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  38463. /**
  38464. * An Observer can set this property to true to prevent subsequent observers of being notified
  38465. */
  38466. skipNextObservers: boolean;
  38467. /**
  38468. * Get the mask value that were used to trigger the event corresponding to this EventState object
  38469. */
  38470. mask: number;
  38471. /**
  38472. * The object that originally notified the event
  38473. */
  38474. target?: any;
  38475. /**
  38476. * The current object in the bubbling phase
  38477. */
  38478. currentTarget?: any;
  38479. /**
  38480. * This will be populated with the return value of the last function that was executed.
  38481. * If it is the first function in the callback chain it will be the event data.
  38482. */
  38483. lastReturnValue?: any;
  38484. }
  38485. /**
  38486. * Represent an Observer registered to a given Observable object.
  38487. */
  38488. class Observer<T> {
  38489. /**
  38490. * Defines the callback to call when the observer is notified
  38491. */
  38492. callback: (eventData: T, eventState: EventState) => void;
  38493. /**
  38494. * Defines the mask of the observer (used to filter notifications)
  38495. */
  38496. mask: number;
  38497. /**
  38498. * Defines the current scope used to restore the JS context
  38499. */
  38500. scope: any;
  38501. /** @hidden */
  38502. _willBeUnregistered: boolean;
  38503. /**
  38504. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  38505. */
  38506. unregisterOnNextCall: boolean;
  38507. /**
  38508. * Creates a new observer
  38509. * @param callback defines the callback to call when the observer is notified
  38510. * @param mask defines the mask of the observer (used to filter notifications)
  38511. * @param scope defines the current scope used to restore the JS context
  38512. */
  38513. constructor(
  38514. /**
  38515. * Defines the callback to call when the observer is notified
  38516. */
  38517. callback: (eventData: T, eventState: EventState) => void,
  38518. /**
  38519. * Defines the mask of the observer (used to filter notifications)
  38520. */
  38521. mask: number,
  38522. /**
  38523. * Defines the current scope used to restore the JS context
  38524. */
  38525. scope?: any);
  38526. }
  38527. /**
  38528. * Represent a list of observers registered to multiple Observables object.
  38529. */
  38530. class MultiObserver<T> {
  38531. private _observers;
  38532. private _observables;
  38533. /**
  38534. * Release associated resources
  38535. */
  38536. dispose(): void;
  38537. /**
  38538. * Raise a callback when one of the observable will notify
  38539. * @param observables defines a list of observables to watch
  38540. * @param callback defines the callback to call on notification
  38541. * @param mask defines the mask used to filter notifications
  38542. * @param scope defines the current scope used to restore the JS context
  38543. * @returns the new MultiObserver
  38544. */
  38545. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  38546. }
  38547. /**
  38548. * The Observable class is a simple implementation of the Observable pattern.
  38549. *
  38550. * 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.
  38551. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  38552. * 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).
  38553. * 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.
  38554. */
  38555. class Observable<T> {
  38556. private _observers;
  38557. private _eventState;
  38558. private _onObserverAdded;
  38559. /**
  38560. * Creates a new observable
  38561. * @param onObserverAdded defines a callback to call when a new observer is added
  38562. */
  38563. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  38564. /**
  38565. * Create a new Observer with the specified callback
  38566. * @param callback the callback that will be executed for that Observer
  38567. * @param mask the mask used to filter observers
  38568. * @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.
  38569. * @param scope optional scope for the callback to be called from
  38570. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38571. * @returns the new observer created for the callback
  38572. */
  38573. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38574. /**
  38575. * Create a new Observer with the specified callback and unregisters after the next notification
  38576. * @param callback the callback that will be executed for that Observer
  38577. * @returns the new observer created for the callback
  38578. */
  38579. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38580. /**
  38581. * Remove an Observer from the Observable object
  38582. * @param observer the instance of the Observer to remove
  38583. * @returns false if it doesn't belong to this Observable
  38584. */
  38585. remove(observer: Nullable<Observer<T>>): boolean;
  38586. /**
  38587. * Remove a callback from the Observable object
  38588. * @param callback the callback to remove
  38589. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38590. * @returns false if it doesn't belong to this Observable
  38591. */
  38592. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38593. private _deferUnregister;
  38594. private _remove;
  38595. /**
  38596. * Notify all Observers by calling their respective callback with the given data
  38597. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38598. * @param eventData defines the data to send to all observers
  38599. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38600. * @param target defines the original target of the state
  38601. * @param currentTarget defines the current target of the state
  38602. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38603. */
  38604. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38605. /**
  38606. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38607. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38608. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38609. * and it is crucial that all callbacks will be executed.
  38610. * The order of the callbacks is kept, callbacks are not executed parallel.
  38611. *
  38612. * @param eventData The data to be sent to each callback
  38613. * @param mask is used to filter observers defaults to -1
  38614. * @param target defines the callback target (see EventState)
  38615. * @param currentTarget defines he current object in the bubbling phase
  38616. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38617. */
  38618. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38619. /**
  38620. * Notify a specific observer
  38621. * @param observer defines the observer to notify
  38622. * @param eventData defines the data to be sent to each callback
  38623. * @param mask is used to filter observers defaults to -1
  38624. */
  38625. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38626. /**
  38627. * Gets a boolean indicating if the observable has at least one observer
  38628. * @returns true is the Observable has at least one Observer registered
  38629. */
  38630. hasObservers(): boolean;
  38631. /**
  38632. * Clear the list of observers
  38633. */
  38634. clear(): void;
  38635. /**
  38636. * Clone the current observable
  38637. * @returns a new observable
  38638. */
  38639. clone(): Observable<T>;
  38640. /**
  38641. * Does this observable handles observer registered with a given mask
  38642. * @param mask defines the mask to be tested
  38643. * @return whether or not one observer registered with the given mask is handeled
  38644. **/
  38645. hasSpecificMask(mask?: number): boolean;
  38646. }
  38647. }
  38648. declare module BABYLON {
  38649. /**
  38650. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38651. */
  38652. class PerformanceMonitor {
  38653. private _enabled;
  38654. private _rollingFrameTime;
  38655. private _lastFrameTimeMs;
  38656. /**
  38657. * constructor
  38658. * @param frameSampleSize The number of samples required to saturate the sliding window
  38659. */
  38660. constructor(frameSampleSize?: number);
  38661. /**
  38662. * Samples current frame
  38663. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38664. */
  38665. sampleFrame(timeMs?: number): void;
  38666. /**
  38667. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38668. */
  38669. readonly averageFrameTime: number;
  38670. /**
  38671. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38672. */
  38673. readonly averageFrameTimeVariance: number;
  38674. /**
  38675. * Returns the frame time of the most recent frame
  38676. */
  38677. readonly instantaneousFrameTime: number;
  38678. /**
  38679. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38680. */
  38681. readonly averageFPS: number;
  38682. /**
  38683. * Returns the average framerate in frames per second using the most recent frame time
  38684. */
  38685. readonly instantaneousFPS: number;
  38686. /**
  38687. * Returns true if enough samples have been taken to completely fill the sliding window
  38688. */
  38689. readonly isSaturated: boolean;
  38690. /**
  38691. * Enables contributions to the sliding window sample set
  38692. */
  38693. enable(): void;
  38694. /**
  38695. * Disables contributions to the sliding window sample set
  38696. * Samples will not be interpolated over the disabled period
  38697. */
  38698. disable(): void;
  38699. /**
  38700. * Returns true if sampling is enabled
  38701. */
  38702. readonly isEnabled: boolean;
  38703. /**
  38704. * Resets performance monitor
  38705. */
  38706. reset(): void;
  38707. }
  38708. /**
  38709. * RollingAverage
  38710. *
  38711. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38712. */
  38713. class RollingAverage {
  38714. /**
  38715. * Current average
  38716. */
  38717. average: number;
  38718. /**
  38719. * Current variance
  38720. */
  38721. variance: number;
  38722. protected _samples: Array<number>;
  38723. protected _sampleCount: number;
  38724. protected _pos: number;
  38725. protected _m2: number;
  38726. /**
  38727. * constructor
  38728. * @param length The number of samples required to saturate the sliding window
  38729. */
  38730. constructor(length: number);
  38731. /**
  38732. * Adds a sample to the sample set
  38733. * @param v The sample value
  38734. */
  38735. add(v: number): void;
  38736. /**
  38737. * Returns previously added values or null if outside of history or outside the sliding window domain
  38738. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38739. * @return Value previously recorded with add() or null if outside of range
  38740. */
  38741. history(i: number): number;
  38742. /**
  38743. * Returns true if enough samples have been taken to completely fill the sliding window
  38744. * @return true if sample-set saturated
  38745. */
  38746. isSaturated(): boolean;
  38747. /**
  38748. * Resets the rolling average (equivalent to 0 samples taken so far)
  38749. */
  38750. reset(): void;
  38751. /**
  38752. * Wraps a value around the sample range boundaries
  38753. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38754. * @return Wrapped position in sample range
  38755. */
  38756. protected _wrapPosition(i: number): number;
  38757. }
  38758. }
  38759. declare module BABYLON {
  38760. /**
  38761. * Helper class that provides a small promise polyfill
  38762. */
  38763. class PromisePolyfill {
  38764. /**
  38765. * Static function used to check if the polyfill is required
  38766. * If this is the case then the function will inject the polyfill to window.Promise
  38767. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38768. */
  38769. static Apply(force?: boolean): void;
  38770. }
  38771. }
  38772. declare module BABYLON {
  38773. /**
  38774. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38775. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38776. */
  38777. class SceneOptimization {
  38778. /**
  38779. * Defines the priority of this optimization (0 by default which means first in the list)
  38780. */
  38781. priority: number;
  38782. /**
  38783. * Gets a string describing the action executed by the current optimization
  38784. * @returns description string
  38785. */
  38786. getDescription(): string;
  38787. /**
  38788. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38789. * @param scene defines the current scene where to apply this optimization
  38790. * @param optimizer defines the current optimizer
  38791. * @returns true if everything that can be done was applied
  38792. */
  38793. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38794. /**
  38795. * Creates the SceneOptimization object
  38796. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38797. * @param desc defines the description associated with the optimization
  38798. */
  38799. constructor(
  38800. /**
  38801. * Defines the priority of this optimization (0 by default which means first in the list)
  38802. */
  38803. priority?: number);
  38804. }
  38805. /**
  38806. * Defines an optimization used to reduce the size of render target textures
  38807. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38808. */
  38809. class TextureOptimization extends SceneOptimization {
  38810. /**
  38811. * Defines the priority of this optimization (0 by default which means first in the list)
  38812. */
  38813. priority: number;
  38814. /**
  38815. * 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
  38816. */
  38817. maximumSize: number;
  38818. /**
  38819. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38820. */
  38821. step: number;
  38822. /**
  38823. * Gets a string describing the action executed by the current optimization
  38824. * @returns description string
  38825. */
  38826. getDescription(): string;
  38827. /**
  38828. * Creates the TextureOptimization object
  38829. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38830. * @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
  38831. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38832. */
  38833. constructor(
  38834. /**
  38835. * Defines the priority of this optimization (0 by default which means first in the list)
  38836. */
  38837. priority?: number,
  38838. /**
  38839. * 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
  38840. */
  38841. maximumSize?: number,
  38842. /**
  38843. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38844. */
  38845. step?: number);
  38846. /**
  38847. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38848. * @param scene defines the current scene where to apply this optimization
  38849. * @param optimizer defines the current optimizer
  38850. * @returns true if everything that can be done was applied
  38851. */
  38852. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38853. }
  38854. /**
  38855. * Defines an optimization used to increase or decrease the rendering resolution
  38856. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38857. */
  38858. class HardwareScalingOptimization extends SceneOptimization {
  38859. /**
  38860. * Defines the priority of this optimization (0 by default which means first in the list)
  38861. */
  38862. priority: number;
  38863. /**
  38864. * Defines the maximum scale to use (2 by default)
  38865. */
  38866. maximumScale: number;
  38867. /**
  38868. * Defines the step to use between two passes (0.5 by default)
  38869. */
  38870. step: number;
  38871. private _currentScale;
  38872. private _directionOffset;
  38873. /**
  38874. * Gets a string describing the action executed by the current optimization
  38875. * @return description string
  38876. */
  38877. getDescription(): string;
  38878. /**
  38879. * Creates the HardwareScalingOptimization object
  38880. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38881. * @param maximumScale defines the maximum scale to use (2 by default)
  38882. * @param step defines the step to use between two passes (0.5 by default)
  38883. */
  38884. constructor(
  38885. /**
  38886. * Defines the priority of this optimization (0 by default which means first in the list)
  38887. */
  38888. priority?: number,
  38889. /**
  38890. * Defines the maximum scale to use (2 by default)
  38891. */
  38892. maximumScale?: number,
  38893. /**
  38894. * Defines the step to use between two passes (0.5 by default)
  38895. */
  38896. step?: number);
  38897. /**
  38898. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38899. * @param scene defines the current scene where to apply this optimization
  38900. * @param optimizer defines the current optimizer
  38901. * @returns true if everything that can be done was applied
  38902. */
  38903. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38904. }
  38905. /**
  38906. * Defines an optimization used to remove shadows
  38907. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38908. */
  38909. class ShadowsOptimization extends SceneOptimization {
  38910. /**
  38911. * Gets a string describing the action executed by the current optimization
  38912. * @return description string
  38913. */
  38914. getDescription(): string;
  38915. /**
  38916. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38917. * @param scene defines the current scene where to apply this optimization
  38918. * @param optimizer defines the current optimizer
  38919. * @returns true if everything that can be done was applied
  38920. */
  38921. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38922. }
  38923. /**
  38924. * Defines an optimization used to turn post-processes off
  38925. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38926. */
  38927. class PostProcessesOptimization extends SceneOptimization {
  38928. /**
  38929. * Gets a string describing the action executed by the current optimization
  38930. * @return description string
  38931. */
  38932. getDescription(): string;
  38933. /**
  38934. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38935. * @param scene defines the current scene where to apply this optimization
  38936. * @param optimizer defines the current optimizer
  38937. * @returns true if everything that can be done was applied
  38938. */
  38939. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38940. }
  38941. /**
  38942. * Defines an optimization used to turn lens flares off
  38943. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38944. */
  38945. class LensFlaresOptimization extends SceneOptimization {
  38946. /**
  38947. * Gets a string describing the action executed by the current optimization
  38948. * @return description string
  38949. */
  38950. getDescription(): string;
  38951. /**
  38952. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38953. * @param scene defines the current scene where to apply this optimization
  38954. * @param optimizer defines the current optimizer
  38955. * @returns true if everything that can be done was applied
  38956. */
  38957. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38958. }
  38959. /**
  38960. * Defines an optimization based on user defined callback.
  38961. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38962. */
  38963. class CustomOptimization extends SceneOptimization {
  38964. /**
  38965. * Callback called to apply the custom optimization.
  38966. */
  38967. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38968. /**
  38969. * Callback called to get custom description
  38970. */
  38971. onGetDescription: () => string;
  38972. /**
  38973. * Gets a string describing the action executed by the current optimization
  38974. * @returns description string
  38975. */
  38976. getDescription(): string;
  38977. /**
  38978. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38979. * @param scene defines the current scene where to apply this optimization
  38980. * @param optimizer defines the current optimizer
  38981. * @returns true if everything that can be done was applied
  38982. */
  38983. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38984. }
  38985. /**
  38986. * Defines an optimization used to turn particles off
  38987. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38988. */
  38989. class ParticlesOptimization extends SceneOptimization {
  38990. /**
  38991. * Gets a string describing the action executed by the current optimization
  38992. * @return description string
  38993. */
  38994. getDescription(): string;
  38995. /**
  38996. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38997. * @param scene defines the current scene where to apply this optimization
  38998. * @param optimizer defines the current optimizer
  38999. * @returns true if everything that can be done was applied
  39000. */
  39001. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  39002. }
  39003. /**
  39004. * Defines an optimization used to turn render targets off
  39005. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39006. */
  39007. class RenderTargetsOptimization extends SceneOptimization {
  39008. /**
  39009. * Gets a string describing the action executed by the current optimization
  39010. * @return description string
  39011. */
  39012. getDescription(): string;
  39013. /**
  39014. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  39015. * @param scene defines the current scene where to apply this optimization
  39016. * @param optimizer defines the current optimizer
  39017. * @returns true if everything that can be done was applied
  39018. */
  39019. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  39020. }
  39021. /**
  39022. * Defines an optimization used to merge meshes with compatible materials
  39023. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39024. */
  39025. class MergeMeshesOptimization extends SceneOptimization {
  39026. private static _UpdateSelectionTree;
  39027. /**
  39028. * Gets or sets a boolean which defines if optimization octree has to be updated
  39029. */
  39030. /**
  39031. * Gets or sets a boolean which defines if optimization octree has to be updated
  39032. */
  39033. static UpdateSelectionTree: boolean;
  39034. /**
  39035. * Gets a string describing the action executed by the current optimization
  39036. * @return description string
  39037. */
  39038. getDescription(): string;
  39039. private _canBeMerged;
  39040. /**
  39041. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  39042. * @param scene defines the current scene where to apply this optimization
  39043. * @param optimizer defines the current optimizer
  39044. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  39045. * @returns true if everything that can be done was applied
  39046. */
  39047. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  39048. }
  39049. /**
  39050. * Defines a list of options used by SceneOptimizer
  39051. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39052. */
  39053. class SceneOptimizerOptions {
  39054. /**
  39055. * Defines the target frame rate to reach (60 by default)
  39056. */
  39057. targetFrameRate: number;
  39058. /**
  39059. * Defines the interval between two checkes (2000ms by default)
  39060. */
  39061. trackerDuration: number;
  39062. /**
  39063. * Gets the list of optimizations to apply
  39064. */
  39065. optimizations: SceneOptimization[];
  39066. /**
  39067. * Creates a new list of options used by SceneOptimizer
  39068. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  39069. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  39070. */
  39071. constructor(
  39072. /**
  39073. * Defines the target frame rate to reach (60 by default)
  39074. */
  39075. targetFrameRate?: number,
  39076. /**
  39077. * Defines the interval between two checkes (2000ms by default)
  39078. */
  39079. trackerDuration?: number);
  39080. /**
  39081. * Add a new optimization
  39082. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  39083. * @returns the current SceneOptimizerOptions
  39084. */
  39085. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  39086. /**
  39087. * Add a new custom optimization
  39088. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  39089. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  39090. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  39091. * @returns the current SceneOptimizerOptions
  39092. */
  39093. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  39094. /**
  39095. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  39096. * @param targetFrameRate defines the target frame rate (60 by default)
  39097. * @returns a SceneOptimizerOptions object
  39098. */
  39099. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39100. /**
  39101. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  39102. * @param targetFrameRate defines the target frame rate (60 by default)
  39103. * @returns a SceneOptimizerOptions object
  39104. */
  39105. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39106. /**
  39107. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  39108. * @param targetFrameRate defines the target frame rate (60 by default)
  39109. * @returns a SceneOptimizerOptions object
  39110. */
  39111. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39112. }
  39113. /**
  39114. * Class used to run optimizations in order to reach a target frame rate
  39115. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39116. */
  39117. class SceneOptimizer implements IDisposable {
  39118. private _isRunning;
  39119. private _options;
  39120. private _scene;
  39121. private _currentPriorityLevel;
  39122. private _targetFrameRate;
  39123. private _trackerDuration;
  39124. private _currentFrameRate;
  39125. private _sceneDisposeObserver;
  39126. private _improvementMode;
  39127. /**
  39128. * Defines an observable called when the optimizer reaches the target frame rate
  39129. */
  39130. onSuccessObservable: Observable<SceneOptimizer>;
  39131. /**
  39132. * Defines an observable called when the optimizer enables an optimization
  39133. */
  39134. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  39135. /**
  39136. * Defines an observable called when the optimizer is not able to reach the target frame rate
  39137. */
  39138. onFailureObservable: Observable<SceneOptimizer>;
  39139. /**
  39140. * Gets a boolean indicating if the optimizer is in improvement mode
  39141. */
  39142. readonly isInImprovementMode: boolean;
  39143. /**
  39144. * Gets the current priority level (0 at start)
  39145. */
  39146. readonly currentPriorityLevel: number;
  39147. /**
  39148. * Gets the current frame rate checked by the SceneOptimizer
  39149. */
  39150. readonly currentFrameRate: number;
  39151. /**
  39152. * Gets or sets the current target frame rate (60 by default)
  39153. */
  39154. /**
  39155. * Gets or sets the current target frame rate (60 by default)
  39156. */
  39157. targetFrameRate: number;
  39158. /**
  39159. * Gets or sets the current interval between two checks (every 2000ms by default)
  39160. */
  39161. /**
  39162. * Gets or sets the current interval between two checks (every 2000ms by default)
  39163. */
  39164. trackerDuration: number;
  39165. /**
  39166. * Gets the list of active optimizations
  39167. */
  39168. readonly optimizations: SceneOptimization[];
  39169. /**
  39170. * Creates a new SceneOptimizer
  39171. * @param scene defines the scene to work on
  39172. * @param options defines the options to use with the SceneOptimizer
  39173. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  39174. * @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)
  39175. */
  39176. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  39177. /**
  39178. * Stops the current optimizer
  39179. */
  39180. stop(): void;
  39181. /**
  39182. * Reset the optimizer to initial step (current priority level = 0)
  39183. */
  39184. reset(): void;
  39185. /**
  39186. * Start the optimizer. By default it will try to reach a specific framerate
  39187. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  39188. */
  39189. start(): void;
  39190. private _checkCurrentState;
  39191. /**
  39192. * Release all resources
  39193. */
  39194. dispose(): void;
  39195. /**
  39196. * Helper function to create a SceneOptimizer with one single line of code
  39197. * @param scene defines the scene to work on
  39198. * @param options defines the options to use with the SceneOptimizer
  39199. * @param onSuccess defines a callback to call on success
  39200. * @param onFailure defines a callback to call on failure
  39201. * @returns the new SceneOptimizer object
  39202. */
  39203. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  39204. }
  39205. }
  39206. declare module BABYLON {
  39207. /**
  39208. * Class used to serialize a scene into a string
  39209. */
  39210. class SceneSerializer {
  39211. /**
  39212. * Clear cache used by a previous serialization
  39213. */
  39214. static ClearCache(): void;
  39215. /**
  39216. * Serialize a scene into a JSON compatible object
  39217. * @param scene defines the scene to serialize
  39218. * @returns a JSON compatible object
  39219. */
  39220. static Serialize(scene: Scene): any;
  39221. /**
  39222. * Serialize a mesh into a JSON compatible object
  39223. * @param toSerialize defines the mesh to serialize
  39224. * @param withParents defines if parents must be serialized as well
  39225. * @param withChildren defines if children must be serialized as well
  39226. * @returns a JSON compatible object
  39227. */
  39228. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  39229. }
  39230. }
  39231. declare module BABYLON {
  39232. /**
  39233. * Defines an array and its length.
  39234. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  39235. */
  39236. interface ISmartArrayLike<T> {
  39237. /**
  39238. * The data of the array.
  39239. */
  39240. data: Array<T>;
  39241. /**
  39242. * The active length of the array.
  39243. */
  39244. length: number;
  39245. }
  39246. /**
  39247. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39248. */
  39249. class SmartArray<T> implements ISmartArrayLike<T> {
  39250. /**
  39251. * The full set of data from the array.
  39252. */
  39253. data: Array<T>;
  39254. /**
  39255. * The active length of the array.
  39256. */
  39257. length: number;
  39258. protected _id: number;
  39259. /**
  39260. * Instantiates a Smart Array.
  39261. * @param capacity defines the default capacity of the array.
  39262. */
  39263. constructor(capacity: number);
  39264. /**
  39265. * Pushes a value at the end of the active data.
  39266. * @param value defines the object to push in the array.
  39267. */
  39268. push(value: T): void;
  39269. /**
  39270. * Iterates over the active data and apply the lambda to them.
  39271. * @param func defines the action to apply on each value.
  39272. */
  39273. forEach(func: (content: T) => void): void;
  39274. /**
  39275. * Sorts the full sets of data.
  39276. * @param compareFn defines the comparison function to apply.
  39277. */
  39278. sort(compareFn: (a: T, b: T) => number): void;
  39279. /**
  39280. * Resets the active data to an empty array.
  39281. */
  39282. reset(): void;
  39283. /**
  39284. * Releases all the data from the array as well as the array.
  39285. */
  39286. dispose(): void;
  39287. /**
  39288. * Concats the active data with a given array.
  39289. * @param array defines the data to concatenate with.
  39290. */
  39291. concat(array: any): void;
  39292. /**
  39293. * Returns the position of a value in the active data.
  39294. * @param value defines the value to find the index for
  39295. * @returns the index if found in the active data otherwise -1
  39296. */
  39297. indexOf(value: T): number;
  39298. /**
  39299. * Returns whether an element is part of the active data.
  39300. * @param value defines the value to look for
  39301. * @returns true if found in the active data otherwise false
  39302. */
  39303. contains(value: T): boolean;
  39304. private static _GlobalId;
  39305. }
  39306. /**
  39307. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39308. * The data in this array can only be present once
  39309. */
  39310. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  39311. private _duplicateId;
  39312. /**
  39313. * Pushes a value at the end of the active data.
  39314. * THIS DOES NOT PREVENT DUPPLICATE DATA
  39315. * @param value defines the object to push in the array.
  39316. */
  39317. push(value: T): void;
  39318. /**
  39319. * Pushes a value at the end of the active data.
  39320. * If the data is already present, it won t be added again
  39321. * @param value defines the object to push in the array.
  39322. * @returns true if added false if it was already present
  39323. */
  39324. pushNoDuplicate(value: T): boolean;
  39325. /**
  39326. * Resets the active data to an empty array.
  39327. */
  39328. reset(): void;
  39329. /**
  39330. * Concats the active data with a given array.
  39331. * This ensures no dupplicate will be present in the result.
  39332. * @param array defines the data to concatenate with.
  39333. */
  39334. concatWithNoDuplicate(array: any): void;
  39335. }
  39336. }
  39337. declare module BABYLON {
  39338. /**
  39339. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39340. * The underlying implementation relies on an associative array to ensure the best performances.
  39341. * The value can be anything including 'null' but except 'undefined'
  39342. */
  39343. class StringDictionary<T> {
  39344. /**
  39345. * This will clear this dictionary and copy the content from the 'source' one.
  39346. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39347. * @param source the dictionary to take the content from and copy to this dictionary
  39348. */
  39349. copyFrom(source: StringDictionary<T>): void;
  39350. /**
  39351. * Get a value based from its key
  39352. * @param key the given key to get the matching value from
  39353. * @return the value if found, otherwise undefined is returned
  39354. */
  39355. get(key: string): T | undefined;
  39356. /**
  39357. * Get a value from its key or add it if it doesn't exist.
  39358. * This method will ensure you that a given key/data will be present in the dictionary.
  39359. * @param key the given key to get the matching value from
  39360. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39361. * The factory will only be invoked if there's no data for the given key.
  39362. * @return the value corresponding to the key.
  39363. */
  39364. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39365. /**
  39366. * Get a value from its key if present in the dictionary otherwise add it
  39367. * @param key the key to get the value from
  39368. * @param val if there's no such key/value pair in the dictionary add it with this value
  39369. * @return the value corresponding to the key
  39370. */
  39371. getOrAdd(key: string, val: T): T;
  39372. /**
  39373. * Check if there's a given key in the dictionary
  39374. * @param key the key to check for
  39375. * @return true if the key is present, false otherwise
  39376. */
  39377. contains(key: string): boolean;
  39378. /**
  39379. * Add a new key and its corresponding value
  39380. * @param key the key to add
  39381. * @param value the value corresponding to the key
  39382. * @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
  39383. */
  39384. add(key: string, value: T): boolean;
  39385. /**
  39386. * Update a specific value associated to a key
  39387. * @param key defines the key to use
  39388. * @param value defines the value to store
  39389. * @returns true if the value was updated (or false if the key was not found)
  39390. */
  39391. set(key: string, value: T): boolean;
  39392. /**
  39393. * Get the element of the given key and remove it from the dictionary
  39394. * @param key defines the key to search
  39395. * @returns the value associated with the key or null if not found
  39396. */
  39397. getAndRemove(key: string): Nullable<T>;
  39398. /**
  39399. * Remove a key/value from the dictionary.
  39400. * @param key the key to remove
  39401. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39402. */
  39403. remove(key: string): boolean;
  39404. /**
  39405. * Clear the whole content of the dictionary
  39406. */
  39407. clear(): void;
  39408. /**
  39409. * Gets the current count
  39410. */
  39411. readonly count: number;
  39412. /**
  39413. * Execute a callback on each key/val of the dictionary.
  39414. * Note that you can remove any element in this dictionary in the callback implementation
  39415. * @param callback the callback to execute on a given key/value pair
  39416. */
  39417. forEach(callback: (key: string, val: T) => void): void;
  39418. /**
  39419. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39420. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39421. * Note that you can remove any element in this dictionary in the callback implementation
  39422. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39423. * @returns the first item
  39424. */
  39425. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39426. private _count;
  39427. private _data;
  39428. }
  39429. }
  39430. declare module BABYLON {
  39431. /**
  39432. * Class used to store custom tags
  39433. */
  39434. class Tags {
  39435. /**
  39436. * Adds support for tags on the given object
  39437. * @param obj defines the object to use
  39438. */
  39439. static EnableFor(obj: any): void;
  39440. /**
  39441. * Removes tags support
  39442. * @param obj defines the object to use
  39443. */
  39444. static DisableFor(obj: any): void;
  39445. /**
  39446. * Gets a boolean indicating if the given object has tags
  39447. * @param obj defines the object to use
  39448. * @returns a boolean
  39449. */
  39450. static HasTags(obj: any): boolean;
  39451. /**
  39452. * Gets the tags available on a given object
  39453. * @param obj defines the object to use
  39454. * @param asString defines if the tags must be returned as a string instead of an array of strings
  39455. * @returns the tags
  39456. */
  39457. static GetTags(obj: any, asString?: boolean): any;
  39458. /**
  39459. * Adds tags to an object
  39460. * @param obj defines the object to use
  39461. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  39462. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  39463. */
  39464. static AddTagsTo(obj: any, tagsString: string): void;
  39465. /**
  39466. * @hidden
  39467. */
  39468. static _AddTagTo(obj: any, tag: string): void;
  39469. /**
  39470. * Removes specific tags from a specific object
  39471. * @param obj defines the object to use
  39472. * @param tagsString defines the tags to remove
  39473. */
  39474. static RemoveTagsFrom(obj: any, tagsString: string): void;
  39475. /**
  39476. * @hidden
  39477. */
  39478. static _RemoveTagFrom(obj: any, tag: string): void;
  39479. /**
  39480. * Defines if tags hosted on an object match a given query
  39481. * @param obj defines the object to use
  39482. * @param tagsQuery defines the tag query
  39483. * @returns a boolean
  39484. */
  39485. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  39486. }
  39487. }
  39488. declare module BABYLON {
  39489. /**
  39490. * Class used to host texture specific utilities
  39491. */
  39492. class TextureTools {
  39493. /**
  39494. * Uses the GPU to create a copy texture rescaled at a given size
  39495. * @param texture Texture to copy from
  39496. * @param width defines the desired width
  39497. * @param height defines the desired height
  39498. * @param useBilinearMode defines if bilinear mode has to be used
  39499. * @return the generated texture
  39500. */
  39501. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  39502. /**
  39503. * Gets an environment BRDF texture for a given scene
  39504. * @param scene defines the hosting scene
  39505. * @returns the environment BRDF texture
  39506. */
  39507. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  39508. private static _environmentBRDFBase64Texture;
  39509. }
  39510. }
  39511. declare module BABYLON {
  39512. /**
  39513. * Based on jsTGALoader - Javascript loader for TGA file
  39514. * By Vincent Thibault
  39515. * @see http://blog.robrowser.com/javascript-tga-loader.html
  39516. */
  39517. class TGATools {
  39518. private static _TYPE_INDEXED;
  39519. private static _TYPE_RGB;
  39520. private static _TYPE_GREY;
  39521. private static _TYPE_RLE_INDEXED;
  39522. private static _TYPE_RLE_RGB;
  39523. private static _TYPE_RLE_GREY;
  39524. private static _ORIGIN_MASK;
  39525. private static _ORIGIN_SHIFT;
  39526. private static _ORIGIN_BL;
  39527. private static _ORIGIN_BR;
  39528. private static _ORIGIN_UL;
  39529. private static _ORIGIN_UR;
  39530. /**
  39531. * Gets the header of a TGA file
  39532. * @param data defines the TGA data
  39533. * @returns the header
  39534. */
  39535. static GetTGAHeader(data: Uint8Array): any;
  39536. /**
  39537. * Uploads TGA content to a Babylon Texture
  39538. * @hidden
  39539. */
  39540. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  39541. /** @hidden */
  39542. 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;
  39543. /** @hidden */
  39544. 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;
  39545. /** @hidden */
  39546. 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;
  39547. /** @hidden */
  39548. 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;
  39549. /** @hidden */
  39550. 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;
  39551. /** @hidden */
  39552. 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;
  39553. }
  39554. }
  39555. declare module BABYLON {
  39556. /**
  39557. * Interface for any object that can request an animation frame
  39558. */
  39559. interface ICustomAnimationFrameRequester {
  39560. /**
  39561. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  39562. */
  39563. renderFunction?: Function;
  39564. /**
  39565. * Called to request the next frame to render to
  39566. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39567. */
  39568. requestAnimationFrame: Function;
  39569. /**
  39570. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39571. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39572. */
  39573. requestID?: number;
  39574. }
  39575. /**
  39576. * Interface containing an array of animations
  39577. */
  39578. interface IAnimatable {
  39579. /**
  39580. * Array of animations
  39581. */
  39582. animations: Array<Animation>;
  39583. }
  39584. /** Interface used by value gradients (color, factor, ...) */
  39585. interface IValueGradient {
  39586. /**
  39587. * Gets or sets the gradient value (between 0 and 1)
  39588. */
  39589. gradient: number;
  39590. }
  39591. /** Class used to store color4 gradient */
  39592. class ColorGradient implements IValueGradient {
  39593. /**
  39594. * Gets or sets the gradient value (between 0 and 1)
  39595. */
  39596. gradient: number;
  39597. /**
  39598. * Gets or sets first associated color
  39599. */
  39600. color1: Color4;
  39601. /**
  39602. * Gets or sets second associated color
  39603. */
  39604. color2?: Color4;
  39605. /**
  39606. * Will get a color picked randomly between color1 and color2.
  39607. * If color2 is undefined then color1 will be used
  39608. * @param result defines the target Color4 to store the result in
  39609. */
  39610. getColorToRef(result: Color4): void;
  39611. }
  39612. /** Class used to store color 3 gradient */
  39613. class Color3Gradient implements IValueGradient {
  39614. /**
  39615. * Gets or sets the gradient value (between 0 and 1)
  39616. */
  39617. gradient: number;
  39618. /**
  39619. * Gets or sets the associated color
  39620. */
  39621. color: Color3;
  39622. }
  39623. /** Class used to store factor gradient */
  39624. class FactorGradient implements IValueGradient {
  39625. /**
  39626. * Gets or sets the gradient value (between 0 and 1)
  39627. */
  39628. gradient: number;
  39629. /**
  39630. * Gets or sets first associated factor
  39631. */
  39632. factor1: number;
  39633. /**
  39634. * Gets or sets second associated factor
  39635. */
  39636. factor2?: number;
  39637. /**
  39638. * Will get a number picked randomly between factor1 and factor2.
  39639. * If factor2 is undefined then factor1 will be used
  39640. * @returns the picked number
  39641. */
  39642. getFactor(): number;
  39643. }
  39644. /**
  39645. * @ignore
  39646. * Application error to support additional information when loading a file
  39647. */
  39648. class LoadFileError extends Error {
  39649. /** defines the optional XHR request */
  39650. request?: XMLHttpRequest | undefined;
  39651. private static _setPrototypeOf;
  39652. /**
  39653. * Creates a new LoadFileError
  39654. * @param message defines the message of the error
  39655. * @param request defines the optional XHR request
  39656. */
  39657. constructor(message: string,
  39658. /** defines the optional XHR request */
  39659. request?: XMLHttpRequest | undefined);
  39660. }
  39661. /**
  39662. * Class used to define a retry strategy when error happens while loading assets
  39663. */
  39664. class RetryStrategy {
  39665. /**
  39666. * Function used to defines an exponential back off strategy
  39667. * @param maxRetries defines the maximum number of retries (3 by default)
  39668. * @param baseInterval defines the interval between retries
  39669. * @returns the strategy function to use
  39670. */
  39671. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39672. }
  39673. /**
  39674. * File request interface
  39675. */
  39676. interface IFileRequest {
  39677. /**
  39678. * Raised when the request is complete (success or error).
  39679. */
  39680. onCompleteObservable: Observable<IFileRequest>;
  39681. /**
  39682. * Aborts the request for a file.
  39683. */
  39684. abort: () => void;
  39685. }
  39686. /**
  39687. * Class containing a set of static utilities functions
  39688. */
  39689. class Tools {
  39690. /**
  39691. * Gets or sets the base URL to use to load assets
  39692. */
  39693. static BaseUrl: string;
  39694. /**
  39695. * Enable/Disable Custom HTTP Request Headers globally.
  39696. * default = false
  39697. * @see CustomRequestHeaders
  39698. */
  39699. static UseCustomRequestHeaders: boolean;
  39700. /**
  39701. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39702. * i.e. when loading files, where the server/service expects an Authorization header.
  39703. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  39704. */
  39705. static CustomRequestHeaders: {
  39706. [key: string]: string;
  39707. };
  39708. /**
  39709. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39710. */
  39711. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39712. /**
  39713. * Default behaviour for cors in the application.
  39714. * It can be a string if the expected behavior is identical in the entire app.
  39715. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39716. */
  39717. static CorsBehavior: string | ((url: string | string[]) => string);
  39718. /**
  39719. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39720. * @ignorenaming
  39721. */
  39722. static UseFallbackTexture: boolean;
  39723. /**
  39724. * Use this object to register external classes like custom textures or material
  39725. * to allow the laoders to instantiate them
  39726. */
  39727. static RegisteredExternalClasses: {
  39728. [key: string]: Object;
  39729. };
  39730. /**
  39731. * Texture content used if a texture cannot loaded
  39732. * @ignorenaming
  39733. */
  39734. static fallbackTexture: string;
  39735. /**
  39736. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39737. * @param u defines the coordinate on X axis
  39738. * @param v defines the coordinate on Y axis
  39739. * @param width defines the width of the source data
  39740. * @param height defines the height of the source data
  39741. * @param pixels defines the source byte array
  39742. * @param color defines the output color
  39743. */
  39744. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39745. /**
  39746. * Interpolates between a and b via alpha
  39747. * @param a The lower value (returned when alpha = 0)
  39748. * @param b The upper value (returned when alpha = 1)
  39749. * @param alpha The interpolation-factor
  39750. * @return The mixed value
  39751. */
  39752. static Mix(a: number, b: number, alpha: number): number;
  39753. /**
  39754. * Tries to instantiate a new object from a given class name
  39755. * @param className defines the class name to instantiate
  39756. * @returns the new object or null if the system was not able to do the instantiation
  39757. */
  39758. static Instantiate(className: string): any;
  39759. /**
  39760. * Provides a slice function that will work even on IE
  39761. * @param data defines the array to slice
  39762. * @param start defines the start of the data (optional)
  39763. * @param end defines the end of the data (optional)
  39764. * @returns the new sliced array
  39765. */
  39766. static Slice<T>(data: T, start?: number, end?: number): T;
  39767. /**
  39768. * Polyfill for setImmediate
  39769. * @param action defines the action to execute after the current execution block
  39770. */
  39771. static SetImmediate(action: () => void): void;
  39772. /**
  39773. * Function indicating if a number is an exponent of 2
  39774. * @param value defines the value to test
  39775. * @returns true if the value is an exponent of 2
  39776. */
  39777. static IsExponentOfTwo(value: number): boolean;
  39778. private static _tmpFloatArray;
  39779. /**
  39780. * Returns the nearest 32-bit single precision float representation of a Number
  39781. * @param value A Number. If the parameter is of a different type, it will get converted
  39782. * to a number or to NaN if it cannot be converted
  39783. * @returns number
  39784. */
  39785. static FloatRound(value: number): number;
  39786. /**
  39787. * Find the next highest power of two.
  39788. * @param x Number to start search from.
  39789. * @return Next highest power of two.
  39790. */
  39791. static CeilingPOT(x: number): number;
  39792. /**
  39793. * Find the next lowest power of two.
  39794. * @param x Number to start search from.
  39795. * @return Next lowest power of two.
  39796. */
  39797. static FloorPOT(x: number): number;
  39798. /**
  39799. * Find the nearest power of two.
  39800. * @param x Number to start search from.
  39801. * @return Next nearest power of two.
  39802. */
  39803. static NearestPOT(x: number): number;
  39804. /**
  39805. * Get the closest exponent of two
  39806. * @param value defines the value to approximate
  39807. * @param max defines the maximum value to return
  39808. * @param mode defines how to define the closest value
  39809. * @returns closest exponent of two of the given value
  39810. */
  39811. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39812. /**
  39813. * Extracts the filename from a path
  39814. * @param path defines the path to use
  39815. * @returns the filename
  39816. */
  39817. static GetFilename(path: string): string;
  39818. /**
  39819. * Extracts the "folder" part of a path (everything before the filename).
  39820. * @param uri The URI to extract the info from
  39821. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39822. * @returns The "folder" part of the path
  39823. */
  39824. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39825. /**
  39826. * Extracts text content from a DOM element hierarchy
  39827. * @param element defines the root element
  39828. * @returns a string
  39829. */
  39830. static GetDOMTextContent(element: HTMLElement): string;
  39831. /**
  39832. * Convert an angle in radians to degrees
  39833. * @param angle defines the angle to convert
  39834. * @returns the angle in degrees
  39835. */
  39836. static ToDegrees(angle: number): number;
  39837. /**
  39838. * Convert an angle in degrees to radians
  39839. * @param angle defines the angle to convert
  39840. * @returns the angle in radians
  39841. */
  39842. static ToRadians(angle: number): number;
  39843. /**
  39844. * Encode a buffer to a base64 string
  39845. * @param buffer defines the buffer to encode
  39846. * @returns the encoded string
  39847. */
  39848. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39849. /**
  39850. * Extracts minimum and maximum values from a list of indexed positions
  39851. * @param positions defines the positions to use
  39852. * @param indices defines the indices to the positions
  39853. * @param indexStart defines the start index
  39854. * @param indexCount defines the end index
  39855. * @param bias defines bias value to add to the result
  39856. * @return minimum and maximum values
  39857. */
  39858. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39859. minimum: Vector3;
  39860. maximum: Vector3;
  39861. };
  39862. /**
  39863. * Extracts minimum and maximum values from a list of positions
  39864. * @param positions defines the positions to use
  39865. * @param start defines the start index in the positions array
  39866. * @param count defines the number of positions to handle
  39867. * @param bias defines bias value to add to the result
  39868. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39869. * @return minimum and maximum values
  39870. */
  39871. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39872. minimum: Vector3;
  39873. maximum: Vector3;
  39874. };
  39875. /**
  39876. * Returns an array if obj is not an array
  39877. * @param obj defines the object to evaluate as an array
  39878. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39879. * @returns either obj directly if obj is an array or a new array containing obj
  39880. */
  39881. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39882. /**
  39883. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39884. * @param size the number of element to construct and put in the array
  39885. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39886. * @returns a new array filled with new objects
  39887. */
  39888. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39889. /**
  39890. * Gets the pointer prefix to use
  39891. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39892. */
  39893. static GetPointerPrefix(): string;
  39894. /**
  39895. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39896. * @param func - the function to be called
  39897. * @param requester - the object that will request the next frame. Falls back to window.
  39898. * @returns frame number
  39899. */
  39900. static QueueNewFrame(func: () => void, requester?: any): number;
  39901. /**
  39902. * Ask the browser to promote the current element to fullscreen rendering mode
  39903. * @param element defines the DOM element to promote
  39904. */
  39905. static RequestFullscreen(element: HTMLElement): void;
  39906. /**
  39907. * Asks the browser to exit fullscreen mode
  39908. */
  39909. static ExitFullscreen(): void;
  39910. /**
  39911. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39912. * @param url define the url we are trying
  39913. * @param element define the dom element where to configure the cors policy
  39914. */
  39915. static SetCorsBehavior(url: string | string[], element: {
  39916. crossOrigin: string | null;
  39917. }): void;
  39918. /**
  39919. * Removes unwanted characters from an url
  39920. * @param url defines the url to clean
  39921. * @returns the cleaned url
  39922. */
  39923. static CleanUrl(url: string): string;
  39924. /**
  39925. * Gets or sets a function used to pre-process url before using them to load assets
  39926. */
  39927. static PreprocessUrl: (url: string) => string;
  39928. /**
  39929. * Loads an image as an HTMLImageElement.
  39930. * @param input url string, ArrayBuffer, or Blob to load
  39931. * @param onLoad callback called when the image successfully loads
  39932. * @param onError callback called when the image fails to load
  39933. * @param offlineProvider offline provider for caching
  39934. * @returns the HTMLImageElement of the loaded image
  39935. */
  39936. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39937. /**
  39938. * Loads a file
  39939. * @param url url string, ArrayBuffer, or Blob to load
  39940. * @param onSuccess callback called when the file successfully loads
  39941. * @param onProgress callback called while file is loading (if the server supports this mode)
  39942. * @param offlineProvider defines the offline provider for caching
  39943. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39944. * @param onError callback called when the file fails to load
  39945. * @returns a file request object
  39946. */
  39947. 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;
  39948. /**
  39949. * Load a script (identified by an url). When the url returns, the
  39950. * content of this file is added into a new script element, attached to the DOM (body element)
  39951. * @param scriptUrl defines the url of the script to laod
  39952. * @param onSuccess defines the callback called when the script is loaded
  39953. * @param onError defines the callback to call if an error occurs
  39954. */
  39955. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39956. /**
  39957. * Loads a file from a blob
  39958. * @param fileToLoad defines the blob to use
  39959. * @param callback defines the callback to call when data is loaded
  39960. * @param progressCallback defines the callback to call during loading process
  39961. * @returns a file request object
  39962. */
  39963. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39964. /**
  39965. * Loads a file
  39966. * @param fileToLoad defines the file to load
  39967. * @param callback defines the callback to call when data is loaded
  39968. * @param progressCallBack defines the callback to call during loading process
  39969. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39970. * @returns a file request object
  39971. */
  39972. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39973. /**
  39974. * Creates a data url from a given string content
  39975. * @param content defines the content to convert
  39976. * @returns the new data url link
  39977. */
  39978. static FileAsURL(content: string): string;
  39979. /**
  39980. * Format the given number to a specific decimal format
  39981. * @param value defines the number to format
  39982. * @param decimals defines the number of decimals to use
  39983. * @returns the formatted string
  39984. */
  39985. static Format(value: number, decimals?: number): string;
  39986. /**
  39987. * Checks if a given vector is inside a specific range
  39988. * @param v defines the vector to test
  39989. * @param min defines the minimum range
  39990. * @param max defines the maximum range
  39991. */
  39992. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39993. /**
  39994. * Tries to copy an object by duplicating every property
  39995. * @param source defines the source object
  39996. * @param destination defines the target object
  39997. * @param doNotCopyList defines a list of properties to avoid
  39998. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39999. */
  40000. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  40001. /**
  40002. * Gets a boolean indicating if the given object has no own property
  40003. * @param obj defines the object to test
  40004. * @returns true if object has no own property
  40005. */
  40006. static IsEmpty(obj: any): boolean;
  40007. /**
  40008. * Function used to register events at window level
  40009. * @param events defines the events to register
  40010. */
  40011. static RegisterTopRootEvents(events: {
  40012. name: string;
  40013. handler: Nullable<(e: FocusEvent) => any>;
  40014. }[]): void;
  40015. /**
  40016. * Function used to unregister events from window level
  40017. * @param events defines the events to unregister
  40018. */
  40019. static UnregisterTopRootEvents(events: {
  40020. name: string;
  40021. handler: Nullable<(e: FocusEvent) => any>;
  40022. }[]): void;
  40023. /**
  40024. * Dumps the current bound framebuffer
  40025. * @param width defines the rendering width
  40026. * @param height defines the rendering height
  40027. * @param engine defines the hosting engine
  40028. * @param successCallback defines the callback triggered once the data are available
  40029. * @param mimeType defines the mime type of the result
  40030. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  40031. */
  40032. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  40033. /**
  40034. * Converts the canvas data to blob.
  40035. * This acts as a polyfill for browsers not supporting the to blob function.
  40036. * @param canvas Defines the canvas to extract the data from
  40037. * @param successCallback Defines the callback triggered once the data are available
  40038. * @param mimeType Defines the mime type of the result
  40039. */
  40040. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  40041. /**
  40042. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  40043. * @param successCallback defines the callback triggered once the data are available
  40044. * @param mimeType defines the mime type of the result
  40045. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  40046. */
  40047. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  40048. /**
  40049. * Downloads a blob in the browser
  40050. * @param blob defines the blob to download
  40051. * @param fileName defines the name of the downloaded file
  40052. */
  40053. static Download(blob: Blob, fileName: string): void;
  40054. /**
  40055. * Captures a screenshot of the current rendering
  40056. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  40057. * @param engine defines the rendering engine
  40058. * @param camera defines the source camera
  40059. * @param size This parameter can be set to a single number or to an object with the
  40060. * following (optional) properties: precision, width, height. If a single number is passed,
  40061. * it will be used for both width and height. If an object is passed, the screenshot size
  40062. * will be derived from the parameters. The precision property is a multiplier allowing
  40063. * rendering at a higher or lower resolution
  40064. * @param successCallback defines the callback receives a single parameter which contains the
  40065. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40066. * src parameter of an <img> to display it
  40067. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  40068. * Check your browser for supported MIME types
  40069. */
  40070. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  40071. /**
  40072. * Generates an image screenshot from the specified camera.
  40073. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  40074. * @param engine The engine to use for rendering
  40075. * @param camera The camera to use for rendering
  40076. * @param size This parameter can be set to a single number or to an object with the
  40077. * following (optional) properties: precision, width, height. If a single number is passed,
  40078. * it will be used for both width and height. If an object is passed, the screenshot size
  40079. * will be derived from the parameters. The precision property is a multiplier allowing
  40080. * rendering at a higher or lower resolution
  40081. * @param successCallback The callback receives a single parameter which contains the
  40082. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40083. * src parameter of an <img> to display it
  40084. * @param mimeType The MIME type of the screenshot image (default: image/png).
  40085. * Check your browser for supported MIME types
  40086. * @param samples Texture samples (default: 1)
  40087. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40088. * @param fileName A name for for the downloaded file.
  40089. */
  40090. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  40091. /**
  40092. * Validates if xhr data is correct
  40093. * @param xhr defines the request to validate
  40094. * @param dataType defines the expected data type
  40095. * @returns true if data is correct
  40096. */
  40097. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  40098. /**
  40099. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  40100. * Be aware Math.random() could cause collisions, but:
  40101. * "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"
  40102. * @returns a pseudo random id
  40103. */
  40104. static RandomId(): string;
  40105. /**
  40106. * Test if the given uri is a base64 string
  40107. * @param uri The uri to test
  40108. * @return True if the uri is a base64 string or false otherwise
  40109. */
  40110. static IsBase64(uri: string): boolean;
  40111. /**
  40112. * Decode the given base64 uri.
  40113. * @param uri The uri to decode
  40114. * @return The decoded base64 data.
  40115. */
  40116. static DecodeBase64(uri: string): ArrayBuffer;
  40117. /**
  40118. * No log
  40119. */
  40120. static readonly NoneLogLevel: number;
  40121. /**
  40122. * Only message logs
  40123. */
  40124. static readonly MessageLogLevel: number;
  40125. /**
  40126. * Only warning logs
  40127. */
  40128. static readonly WarningLogLevel: number;
  40129. /**
  40130. * Only error logs
  40131. */
  40132. static readonly ErrorLogLevel: number;
  40133. /**
  40134. * All logs
  40135. */
  40136. static readonly AllLogLevel: number;
  40137. private static _LogCache;
  40138. /**
  40139. * Gets a value indicating the number of loading errors
  40140. * @ignorenaming
  40141. */
  40142. static errorsCount: number;
  40143. /**
  40144. * Callback called when a new log is added
  40145. */
  40146. static OnNewCacheEntry: (entry: string) => void;
  40147. private static _AddLogEntry;
  40148. private static _FormatMessage;
  40149. private static _LogDisabled;
  40150. private static _LogEnabled;
  40151. private static _WarnDisabled;
  40152. private static _WarnEnabled;
  40153. private static _ErrorDisabled;
  40154. private static _ErrorEnabled;
  40155. /**
  40156. * Log a message to the console
  40157. */
  40158. static Log: (message: string) => void;
  40159. /**
  40160. * Write a warning message to the console
  40161. */
  40162. static Warn: (message: string) => void;
  40163. /**
  40164. * Write an error message to the console
  40165. */
  40166. static Error: (message: string) => void;
  40167. /**
  40168. * Gets current log cache (list of logs)
  40169. */
  40170. static readonly LogCache: string;
  40171. /**
  40172. * Clears the log cache
  40173. */
  40174. static ClearLogCache(): void;
  40175. /**
  40176. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40177. */
  40178. static LogLevels: number;
  40179. /**
  40180. * Checks if the loaded document was accessed via `file:`-Protocol.
  40181. * @returns boolean
  40182. */
  40183. static IsFileURL(): boolean;
  40184. /**
  40185. * Checks if the window object exists
  40186. * @returns true if the window object exists
  40187. */
  40188. static IsWindowObjectExist(): boolean;
  40189. /**
  40190. * No performance log
  40191. */
  40192. static readonly PerformanceNoneLogLevel: number;
  40193. /**
  40194. * Use user marks to log performance
  40195. */
  40196. static readonly PerformanceUserMarkLogLevel: number;
  40197. /**
  40198. * Log performance to the console
  40199. */
  40200. static readonly PerformanceConsoleLogLevel: number;
  40201. private static _performance;
  40202. /**
  40203. * Sets the current performance log level
  40204. */
  40205. static PerformanceLogLevel: number;
  40206. private static _StartPerformanceCounterDisabled;
  40207. private static _EndPerformanceCounterDisabled;
  40208. private static _StartUserMark;
  40209. private static _EndUserMark;
  40210. private static _StartPerformanceConsole;
  40211. private static _EndPerformanceConsole;
  40212. /**
  40213. * Injects the @see CustomRequestHeaders into the given request
  40214. * @param request the request that should be used for injection
  40215. */
  40216. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  40217. /**
  40218. * Starts a performance counter
  40219. */
  40220. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40221. /**
  40222. * Ends a specific performance coutner
  40223. */
  40224. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40225. /**
  40226. * Gets either window.performance.now() if supported or Date.now() else
  40227. */
  40228. static readonly Now: number;
  40229. /**
  40230. * This method will return the name of the class used to create the instance of the given object.
  40231. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40232. * @param object the object to get the class name from
  40233. * @param isType defines if the object is actually a type
  40234. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40235. */
  40236. static GetClassName(object: any, isType?: boolean): string;
  40237. /**
  40238. * Gets the first element of an array satisfying a given predicate
  40239. * @param array defines the array to browse
  40240. * @param predicate defines the predicate to use
  40241. * @returns null if not found or the element
  40242. */
  40243. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40244. /**
  40245. * This method will return the name of the full name of the class, including its owning module (if any).
  40246. * 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).
  40247. * @param object the object to get the class name from
  40248. * @param isType defines if the object is actually a type
  40249. * @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.
  40250. * @ignorenaming
  40251. */
  40252. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40253. /**
  40254. * Returns a promise that resolves after the given amount of time.
  40255. * @param delay Number of milliseconds to delay
  40256. * @returns Promise that resolves after the given amount of time
  40257. */
  40258. static DelayAsync(delay: number): Promise<void>;
  40259. /**
  40260. * Gets the current gradient from an array of IValueGradient
  40261. * @param ratio defines the current ratio to get
  40262. * @param gradients defines the array of IValueGradient
  40263. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  40264. */
  40265. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  40266. }
  40267. /**
  40268. * This class is used to track a performance counter which is number based.
  40269. * The user has access to many properties which give statistics of different nature.
  40270. *
  40271. * The implementer can track two kinds of Performance Counter: time and count.
  40272. * 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.
  40273. * 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.
  40274. */
  40275. class PerfCounter {
  40276. /**
  40277. * Gets or sets a global boolean to turn on and off all the counters
  40278. */
  40279. static Enabled: boolean;
  40280. /**
  40281. * Returns the smallest value ever
  40282. */
  40283. readonly min: number;
  40284. /**
  40285. * Returns the biggest value ever
  40286. */
  40287. readonly max: number;
  40288. /**
  40289. * Returns the average value since the performance counter is running
  40290. */
  40291. readonly average: number;
  40292. /**
  40293. * Returns the average value of the last second the counter was monitored
  40294. */
  40295. readonly lastSecAverage: number;
  40296. /**
  40297. * Returns the current value
  40298. */
  40299. readonly current: number;
  40300. /**
  40301. * Gets the accumulated total
  40302. */
  40303. readonly total: number;
  40304. /**
  40305. * Gets the total value count
  40306. */
  40307. readonly count: number;
  40308. /**
  40309. * Creates a new counter
  40310. */
  40311. constructor();
  40312. /**
  40313. * Call this method to start monitoring a new frame.
  40314. * 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.
  40315. */
  40316. fetchNewFrame(): void;
  40317. /**
  40318. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40319. * @param newCount the count value to add to the monitored count
  40320. * @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.
  40321. */
  40322. addCount(newCount: number, fetchResult: boolean): void;
  40323. /**
  40324. * Start monitoring this performance counter
  40325. */
  40326. beginMonitoring(): void;
  40327. /**
  40328. * Compute the time lapsed since the previous beginMonitoring() call.
  40329. * @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
  40330. */
  40331. endMonitoring(newFrame?: boolean): void;
  40332. private _fetchResult;
  40333. private _startMonitoringTime;
  40334. private _min;
  40335. private _max;
  40336. private _average;
  40337. private _current;
  40338. private _totalValueCount;
  40339. private _totalAccumulated;
  40340. private _lastSecAverage;
  40341. private _lastSecAccumulated;
  40342. private _lastSecTime;
  40343. private _lastSecValueCount;
  40344. }
  40345. /**
  40346. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40347. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40348. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40349. * @param name The name of the class, case should be preserved
  40350. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40351. */
  40352. function className(name: string, module?: string): (target: Object) => void;
  40353. /**
  40354. * An implementation of a loop for asynchronous functions.
  40355. */
  40356. class AsyncLoop {
  40357. /**
  40358. * Defines the number of iterations for the loop
  40359. */
  40360. iterations: number;
  40361. /**
  40362. * Defines the current index of the loop.
  40363. */
  40364. index: number;
  40365. private _done;
  40366. private _fn;
  40367. private _successCallback;
  40368. /**
  40369. * Constructor.
  40370. * @param iterations the number of iterations.
  40371. * @param func the function to run each iteration
  40372. * @param successCallback the callback that will be called upon succesful execution
  40373. * @param offset starting offset.
  40374. */
  40375. constructor(
  40376. /**
  40377. * Defines the number of iterations for the loop
  40378. */
  40379. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40380. /**
  40381. * Execute the next iteration. Must be called after the last iteration was finished.
  40382. */
  40383. executeNext(): void;
  40384. /**
  40385. * Break the loop and run the success callback.
  40386. */
  40387. breakLoop(): void;
  40388. /**
  40389. * Create and run an async loop.
  40390. * @param iterations the number of iterations.
  40391. * @param fn the function to run each iteration
  40392. * @param successCallback the callback that will be called upon succesful execution
  40393. * @param offset starting offset.
  40394. * @returns the created async loop object
  40395. */
  40396. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40397. /**
  40398. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40399. * @param iterations total number of iterations
  40400. * @param syncedIterations number of synchronous iterations in each async iteration.
  40401. * @param fn the function to call each iteration.
  40402. * @param callback a success call back that will be called when iterating stops.
  40403. * @param breakFunction a break condition (optional)
  40404. * @param timeout timeout settings for the setTimeout function. default - 0.
  40405. * @returns the created async loop object
  40406. */
  40407. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40408. }
  40409. }
  40410. interface HTMLCanvasElement {
  40411. /** Track wether a record is in progress */
  40412. isRecording: boolean;
  40413. /** Capture Stream method defined by some browsers */
  40414. captureStream(fps?: number): MediaStream;
  40415. }
  40416. interface MediaRecorder {
  40417. /** Starts recording */
  40418. start(timeSlice: number): void;
  40419. /** Stops recording */
  40420. stop(): void;
  40421. /** Event raised when an error arised. */
  40422. onerror: (event: ErrorEvent) => void;
  40423. /** Event raised when the recording stops. */
  40424. onstop: (event: Event) => void;
  40425. /** Event raised when a new chunk of data is available and should be tracked. */
  40426. ondataavailable: (event: Event) => void;
  40427. }
  40428. interface MediaRecorderOptions {
  40429. /** The mime type you want to use as the recording container for the new MediaRecorder */
  40430. mimeType?: string;
  40431. /** The chosen bitrate for the audio component of the media. */
  40432. audioBitsPerSecond?: number;
  40433. /** The chosen bitrate for the video component of the media. */
  40434. videoBitsPerSecond?: number;
  40435. /** 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. */
  40436. bitsPerSecond?: number;
  40437. }
  40438. interface MediaRecorderConstructor {
  40439. /**
  40440. * A reference to the prototype.
  40441. */
  40442. readonly prototype: MediaRecorder;
  40443. /**
  40444. * Creates a new MediaRecorder.
  40445. * @param stream Defines the stream to record.
  40446. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  40447. */
  40448. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  40449. }
  40450. /**
  40451. * MediaRecoreder object available in some browsers.
  40452. */
  40453. declare var MediaRecorder: MediaRecorderConstructor;
  40454. declare module BABYLON {
  40455. /**
  40456. * This represents the different options avilable for the video capture.
  40457. */
  40458. interface VideoRecorderOptions {
  40459. /** Defines the mime type of the video */
  40460. mimeType: string;
  40461. /** Defines the video the video should be recorded at */
  40462. fps: number;
  40463. /** Defines the chunk size for the recording data */
  40464. recordChunckSize: number;
  40465. }
  40466. /**
  40467. * This can helps recording videos from BabylonJS.
  40468. * This is based on the available WebRTC functionalities of the browser.
  40469. *
  40470. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  40471. */
  40472. class VideoRecorder {
  40473. private static readonly _defaultOptions;
  40474. /**
  40475. * Returns wehther or not the VideoRecorder is available in your browser.
  40476. * @param engine Defines the Babylon Engine to check the support for
  40477. * @returns true if supported otherwise false
  40478. */
  40479. static IsSupported(engine: Engine): boolean;
  40480. private readonly _options;
  40481. private _canvas;
  40482. private _mediaRecorder;
  40483. private _recordedChunks;
  40484. private _fileName;
  40485. private _resolve;
  40486. private _reject;
  40487. /**
  40488. * True wether a recording is already in progress.
  40489. */
  40490. readonly isRecording: boolean;
  40491. /**
  40492. * Create a new VideoCapture object which can help converting what you see in Babylon to
  40493. * a video file.
  40494. * @param engine Defines the BabylonJS Engine you wish to record
  40495. * @param options Defines options that can be used to customized the capture
  40496. */
  40497. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  40498. /**
  40499. * Stops the current recording before the default capture timeout passed in the startRecording
  40500. * functions.
  40501. */
  40502. stopRecording(): void;
  40503. /**
  40504. * Starts recording the canvas for a max duration specified in parameters.
  40505. * @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.
  40506. * @param maxDuration Defines the maximum recording time in seconds.
  40507. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  40508. * @return a promise callback at the end of the recording with the video data in Blob.
  40509. */
  40510. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  40511. /**
  40512. * Releases internal resources used during the recording.
  40513. */
  40514. dispose(): void;
  40515. private _handleDataAvailable;
  40516. private _handleError;
  40517. private _handleStop;
  40518. }
  40519. }
  40520. declare module BABYLON {
  40521. /**
  40522. * Defines the potential axis of a Joystick
  40523. */
  40524. enum JoystickAxis {
  40525. /** X axis */
  40526. X = 0,
  40527. /** Y axis */
  40528. Y = 1,
  40529. /** Z axis */
  40530. Z = 2
  40531. }
  40532. /**
  40533. * Class used to define virtual joystick (used in touch mode)
  40534. */
  40535. class VirtualJoystick {
  40536. /**
  40537. * Gets or sets a boolean indicating that left and right values must be inverted
  40538. */
  40539. reverseLeftRight: boolean;
  40540. /**
  40541. * Gets or sets a boolean indicating that up and down values must be inverted
  40542. */
  40543. reverseUpDown: boolean;
  40544. /**
  40545. * Gets the offset value for the position (ie. the change of the position value)
  40546. */
  40547. deltaPosition: Vector3;
  40548. /**
  40549. * Gets a boolean indicating if the virtual joystick was pressed
  40550. */
  40551. pressed: boolean;
  40552. /**
  40553. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40554. */
  40555. static Canvas: Nullable<HTMLCanvasElement>;
  40556. private static _globalJoystickIndex;
  40557. private static vjCanvasContext;
  40558. private static vjCanvasWidth;
  40559. private static vjCanvasHeight;
  40560. private static halfWidth;
  40561. private _action;
  40562. private _axisTargetedByLeftAndRight;
  40563. private _axisTargetedByUpAndDown;
  40564. private _joystickSensibility;
  40565. private _inversedSensibility;
  40566. private _joystickPointerID;
  40567. private _joystickColor;
  40568. private _joystickPointerPos;
  40569. private _joystickPreviousPointerPos;
  40570. private _joystickPointerStartPos;
  40571. private _deltaJoystickVector;
  40572. private _leftJoystick;
  40573. private _touches;
  40574. private _onPointerDownHandlerRef;
  40575. private _onPointerMoveHandlerRef;
  40576. private _onPointerUpHandlerRef;
  40577. private _onResize;
  40578. /**
  40579. * Creates a new virtual joystick
  40580. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40581. */
  40582. constructor(leftJoystick?: boolean);
  40583. /**
  40584. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40585. * @param newJoystickSensibility defines the new sensibility
  40586. */
  40587. setJoystickSensibility(newJoystickSensibility: number): void;
  40588. private _onPointerDown;
  40589. private _onPointerMove;
  40590. private _onPointerUp;
  40591. /**
  40592. * Change the color of the virtual joystick
  40593. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40594. */
  40595. setJoystickColor(newColor: string): void;
  40596. /**
  40597. * Defines a callback to call when the joystick is touched
  40598. * @param action defines the callback
  40599. */
  40600. setActionOnTouch(action: () => any): void;
  40601. /**
  40602. * Defines which axis you'd like to control for left & right
  40603. * @param axis defines the axis to use
  40604. */
  40605. setAxisForLeftRight(axis: JoystickAxis): void;
  40606. /**
  40607. * Defines which axis you'd like to control for up & down
  40608. * @param axis defines the axis to use
  40609. */
  40610. setAxisForUpDown(axis: JoystickAxis): void;
  40611. private _drawVirtualJoystick;
  40612. /**
  40613. * Release internal HTML canvas
  40614. */
  40615. releaseCanvas(): void;
  40616. }
  40617. }
  40618. declare module BABYLON {
  40619. /**
  40620. * Helper class to push actions to a pool of workers.
  40621. */
  40622. class WorkerPool implements IDisposable {
  40623. private _workerInfos;
  40624. private _pendingActions;
  40625. /**
  40626. * Constructor
  40627. * @param workers Array of workers to use for actions
  40628. */
  40629. constructor(workers: Array<Worker>);
  40630. /**
  40631. * Terminates all workers and clears any pending actions.
  40632. */
  40633. dispose(): void;
  40634. /**
  40635. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40636. * pended until a worker has completed its action.
  40637. * @param action The action to perform. Call onComplete when the action is complete.
  40638. */
  40639. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40640. private _execute;
  40641. }
  40642. }
  40643. declare module BABYLON {
  40644. /**
  40645. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40646. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40647. */
  40648. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40649. /**
  40650. * Gets the name of the behavior.
  40651. */
  40652. readonly name: string;
  40653. private _zoomStopsAnimation;
  40654. private _idleRotationSpeed;
  40655. private _idleRotationWaitTime;
  40656. private _idleRotationSpinupTime;
  40657. /**
  40658. * Sets the flag that indicates if user zooming should stop animation.
  40659. */
  40660. /**
  40661. * Gets the flag that indicates if user zooming should stop animation.
  40662. */
  40663. zoomStopsAnimation: boolean;
  40664. /**
  40665. * Sets the default speed at which the camera rotates around the model.
  40666. */
  40667. /**
  40668. * Gets the default speed at which the camera rotates around the model.
  40669. */
  40670. idleRotationSpeed: number;
  40671. /**
  40672. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40673. */
  40674. /**
  40675. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40676. */
  40677. idleRotationWaitTime: number;
  40678. /**
  40679. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40680. */
  40681. /**
  40682. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40683. */
  40684. idleRotationSpinupTime: number;
  40685. /**
  40686. * Gets a value indicating if the camera is currently rotating because of this behavior
  40687. */
  40688. readonly rotationInProgress: boolean;
  40689. private _onPrePointerObservableObserver;
  40690. private _onAfterCheckInputsObserver;
  40691. private _attachedCamera;
  40692. private _isPointerDown;
  40693. private _lastFrameTime;
  40694. private _lastInteractionTime;
  40695. private _cameraRotationSpeed;
  40696. /**
  40697. * Initializes the behavior.
  40698. */
  40699. init(): void;
  40700. /**
  40701. * Attaches the behavior to its arc rotate camera.
  40702. * @param camera Defines the camera to attach the behavior to
  40703. */
  40704. attach(camera: ArcRotateCamera): void;
  40705. /**
  40706. * Detaches the behavior from its current arc rotate camera.
  40707. */
  40708. detach(): void;
  40709. /**
  40710. * Returns true if user is scrolling.
  40711. * @return true if user is scrolling.
  40712. */
  40713. private _userIsZooming;
  40714. private _lastFrameRadius;
  40715. private _shouldAnimationStopForInteraction;
  40716. /**
  40717. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40718. */
  40719. private _applyUserInteraction;
  40720. private _userIsMoving;
  40721. }
  40722. }
  40723. declare module BABYLON {
  40724. /**
  40725. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40726. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40727. */
  40728. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40729. /**
  40730. * Gets the name of the behavior.
  40731. */
  40732. readonly name: string;
  40733. /**
  40734. * The easing function used by animations
  40735. */
  40736. static EasingFunction: BackEase;
  40737. /**
  40738. * The easing mode used by animations
  40739. */
  40740. static EasingMode: number;
  40741. /**
  40742. * The duration of the animation, in milliseconds
  40743. */
  40744. transitionDuration: number;
  40745. /**
  40746. * Length of the distance animated by the transition when lower radius is reached
  40747. */
  40748. lowerRadiusTransitionRange: number;
  40749. /**
  40750. * Length of the distance animated by the transition when upper radius is reached
  40751. */
  40752. upperRadiusTransitionRange: number;
  40753. private _autoTransitionRange;
  40754. /**
  40755. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40756. */
  40757. /**
  40758. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40759. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40760. */
  40761. autoTransitionRange: boolean;
  40762. private _attachedCamera;
  40763. private _onAfterCheckInputsObserver;
  40764. private _onMeshTargetChangedObserver;
  40765. /**
  40766. * Initializes the behavior.
  40767. */
  40768. init(): void;
  40769. /**
  40770. * Attaches the behavior to its arc rotate camera.
  40771. * @param camera Defines the camera to attach the behavior to
  40772. */
  40773. attach(camera: ArcRotateCamera): void;
  40774. /**
  40775. * Detaches the behavior from its current arc rotate camera.
  40776. */
  40777. detach(): void;
  40778. private _radiusIsAnimating;
  40779. private _radiusBounceTransition;
  40780. private _animatables;
  40781. private _cachedWheelPrecision;
  40782. /**
  40783. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40784. * @param radiusLimit The limit to check against.
  40785. * @return Bool to indicate if at limit.
  40786. */
  40787. private _isRadiusAtLimit;
  40788. /**
  40789. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40790. * @param radiusDelta The delta by which to animate to. Can be negative.
  40791. */
  40792. private _applyBoundRadiusAnimation;
  40793. /**
  40794. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40795. */
  40796. protected _clearAnimationLocks(): void;
  40797. /**
  40798. * Stops and removes all animations that have been applied to the camera
  40799. */
  40800. stopAllAnimations(): void;
  40801. }
  40802. }
  40803. declare module BABYLON {
  40804. /**
  40805. * 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.
  40806. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40807. */
  40808. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40809. /**
  40810. * Gets the name of the behavior.
  40811. */
  40812. readonly name: string;
  40813. private _mode;
  40814. private _radiusScale;
  40815. private _positionScale;
  40816. private _defaultElevation;
  40817. private _elevationReturnTime;
  40818. private _elevationReturnWaitTime;
  40819. private _zoomStopsAnimation;
  40820. private _framingTime;
  40821. /**
  40822. * The easing function used by animations
  40823. */
  40824. static EasingFunction: ExponentialEase;
  40825. /**
  40826. * The easing mode used by animations
  40827. */
  40828. static EasingMode: number;
  40829. /**
  40830. * Sets the current mode used by the behavior
  40831. */
  40832. /**
  40833. * Gets current mode used by the behavior.
  40834. */
  40835. mode: number;
  40836. /**
  40837. * Sets the scale applied to the radius (1 by default)
  40838. */
  40839. /**
  40840. * Gets the scale applied to the radius
  40841. */
  40842. radiusScale: number;
  40843. /**
  40844. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40845. */
  40846. /**
  40847. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40848. */
  40849. positionScale: number;
  40850. /**
  40851. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40852. * behaviour is triggered, in radians.
  40853. */
  40854. /**
  40855. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40856. * behaviour is triggered, in radians.
  40857. */
  40858. defaultElevation: number;
  40859. /**
  40860. * Sets the time (in milliseconds) taken to return to the default beta position.
  40861. * Negative value indicates camera should not return to default.
  40862. */
  40863. /**
  40864. * Gets the time (in milliseconds) taken to return to the default beta position.
  40865. * Negative value indicates camera should not return to default.
  40866. */
  40867. elevationReturnTime: number;
  40868. /**
  40869. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40870. */
  40871. /**
  40872. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40873. */
  40874. elevationReturnWaitTime: number;
  40875. /**
  40876. * Sets the flag that indicates if user zooming should stop animation.
  40877. */
  40878. /**
  40879. * Gets the flag that indicates if user zooming should stop animation.
  40880. */
  40881. zoomStopsAnimation: boolean;
  40882. /**
  40883. * Sets the transition time when framing the mesh, in milliseconds
  40884. */
  40885. /**
  40886. * Gets the transition time when framing the mesh, in milliseconds
  40887. */
  40888. framingTime: number;
  40889. /**
  40890. * Define if the behavior should automatically change the configured
  40891. * camera limits and sensibilities.
  40892. */
  40893. autoCorrectCameraLimitsAndSensibility: boolean;
  40894. private _onPrePointerObservableObserver;
  40895. private _onAfterCheckInputsObserver;
  40896. private _onMeshTargetChangedObserver;
  40897. private _attachedCamera;
  40898. private _isPointerDown;
  40899. private _lastInteractionTime;
  40900. /**
  40901. * Initializes the behavior.
  40902. */
  40903. init(): void;
  40904. /**
  40905. * Attaches the behavior to its arc rotate camera.
  40906. * @param camera Defines the camera to attach the behavior to
  40907. */
  40908. attach(camera: ArcRotateCamera): void;
  40909. /**
  40910. * Detaches the behavior from its current arc rotate camera.
  40911. */
  40912. detach(): void;
  40913. private _animatables;
  40914. private _betaIsAnimating;
  40915. private _betaTransition;
  40916. private _radiusTransition;
  40917. private _vectorTransition;
  40918. /**
  40919. * Targets the given mesh and updates zoom level accordingly.
  40920. * @param mesh The mesh to target.
  40921. * @param radius Optional. If a cached radius position already exists, overrides default.
  40922. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40923. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40924. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40925. */
  40926. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40927. /**
  40928. * Targets the given mesh with its children and updates zoom level accordingly.
  40929. * @param mesh The mesh to target.
  40930. * @param radius Optional. If a cached radius position already exists, overrides default.
  40931. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40932. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40933. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40934. */
  40935. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40936. /**
  40937. * Targets the given meshes with their children and updates zoom level accordingly.
  40938. * @param meshes The mesh to target.
  40939. * @param radius Optional. If a cached radius position already exists, overrides default.
  40940. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40941. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40942. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40943. */
  40944. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40945. /**
  40946. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40947. * @param minimumWorld Determines the smaller position of the bounding box extend
  40948. * @param maximumWorld Determines the bigger position of the bounding box extend
  40949. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40950. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40951. */
  40952. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40953. /**
  40954. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40955. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40956. * frustum width.
  40957. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40958. * to fully enclose the mesh in the viewing frustum.
  40959. */
  40960. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40961. /**
  40962. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40963. * is automatically returned to its default position (expected to be above ground plane).
  40964. */
  40965. private _maintainCameraAboveGround;
  40966. /**
  40967. * Returns the frustum slope based on the canvas ratio and camera FOV
  40968. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40969. */
  40970. private _getFrustumSlope;
  40971. /**
  40972. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40973. */
  40974. private _clearAnimationLocks;
  40975. /**
  40976. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40977. */
  40978. private _applyUserInteraction;
  40979. /**
  40980. * Stops and removes all animations that have been applied to the camera
  40981. */
  40982. stopAllAnimations(): void;
  40983. /**
  40984. * Gets a value indicating if the user is moving the camera
  40985. */
  40986. readonly isUserIsMoving: boolean;
  40987. /**
  40988. * The camera can move all the way towards the mesh.
  40989. */
  40990. static IgnoreBoundsSizeMode: number;
  40991. /**
  40992. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40993. */
  40994. static FitFrustumSidesMode: number;
  40995. }
  40996. }
  40997. declare module BABYLON {
  40998. /**
  40999. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  41000. */
  41001. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  41002. private ui;
  41003. /**
  41004. * The name of the behavior
  41005. */
  41006. name: string;
  41007. /**
  41008. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  41009. */
  41010. distanceAwayFromFace: number;
  41011. /**
  41012. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  41013. */
  41014. distanceAwayFromBottomOfFace: number;
  41015. private _faceVectors;
  41016. private _target;
  41017. private _scene;
  41018. private _onRenderObserver;
  41019. private _tmpMatrix;
  41020. private _tmpVector;
  41021. /**
  41022. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  41023. * @param ui The transform node that should be attched to the mesh
  41024. */
  41025. constructor(ui: BABYLON.TransformNode);
  41026. /**
  41027. * Initializes the behavior
  41028. */
  41029. init(): void;
  41030. private _closestFace;
  41031. private _zeroVector;
  41032. private _lookAtTmpMatrix;
  41033. private _lookAtToRef;
  41034. /**
  41035. * Attaches the AttachToBoxBehavior to the passed in mesh
  41036. * @param target The mesh that the specified node will be attached to
  41037. */
  41038. attach(target: BABYLON.Mesh): void;
  41039. /**
  41040. * Detaches the behavior from the mesh
  41041. */
  41042. detach(): void;
  41043. }
  41044. }
  41045. declare module BABYLON {
  41046. /**
  41047. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  41048. */
  41049. class FadeInOutBehavior implements Behavior<Mesh> {
  41050. /**
  41051. * Time in milliseconds to delay before fading in (Default: 0)
  41052. */
  41053. delay: number;
  41054. /**
  41055. * Time in milliseconds for the mesh to fade in (Default: 300)
  41056. */
  41057. fadeInTime: number;
  41058. private _millisecondsPerFrame;
  41059. private _hovered;
  41060. private _hoverValue;
  41061. private _ownerNode;
  41062. /**
  41063. * Instatiates the FadeInOutBehavior
  41064. */
  41065. constructor();
  41066. /**
  41067. * The name of the behavior
  41068. */
  41069. readonly name: string;
  41070. /**
  41071. * Initializes the behavior
  41072. */
  41073. init(): void;
  41074. /**
  41075. * Attaches the fade behavior on the passed in mesh
  41076. * @param ownerNode The mesh that will be faded in/out once attached
  41077. */
  41078. attach(ownerNode: Mesh): void;
  41079. /**
  41080. * Detaches the behavior from the mesh
  41081. */
  41082. detach(): void;
  41083. /**
  41084. * Triggers the mesh to begin fading in or out
  41085. * @param value if the object should fade in or out (true to fade in)
  41086. */
  41087. fadeIn(value: boolean): void;
  41088. private _update;
  41089. private _setAllVisibility;
  41090. }
  41091. }
  41092. declare module BABYLON {
  41093. /**
  41094. * A behavior that when attached to a mesh will allow the mesh to be scaled
  41095. */
  41096. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  41097. private _dragBehaviorA;
  41098. private _dragBehaviorB;
  41099. private _startDistance;
  41100. private _initialScale;
  41101. private _targetScale;
  41102. private _ownerNode;
  41103. private _sceneRenderObserver;
  41104. /**
  41105. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  41106. */
  41107. constructor();
  41108. /**
  41109. * The name of the behavior
  41110. */
  41111. readonly name: string;
  41112. /**
  41113. * Initializes the behavior
  41114. */
  41115. init(): void;
  41116. private _getCurrentDistance;
  41117. /**
  41118. * Attaches the scale behavior the passed in mesh
  41119. * @param ownerNode The mesh that will be scaled around once attached
  41120. */
  41121. attach(ownerNode: Mesh): void;
  41122. /**
  41123. * Detaches the behavior from the mesh
  41124. */
  41125. detach(): void;
  41126. }
  41127. }
  41128. declare module BABYLON {
  41129. /**
  41130. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  41131. */
  41132. class PointerDragBehavior implements Behavior<AbstractMesh> {
  41133. private static _AnyMouseID;
  41134. private _attachedNode;
  41135. private _dragPlane;
  41136. private _scene;
  41137. private _pointerObserver;
  41138. private _beforeRenderObserver;
  41139. private static _planeScene;
  41140. /**
  41141. * 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)
  41142. */
  41143. maxDragAngle: number;
  41144. /**
  41145. * @hidden
  41146. */
  41147. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  41148. /**
  41149. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41150. */
  41151. currentDraggingPointerID: number;
  41152. /**
  41153. * The last position where the pointer hit the drag plane in world space
  41154. */
  41155. lastDragPosition: Vector3;
  41156. /**
  41157. * If the behavior is currently in a dragging state
  41158. */
  41159. dragging: boolean;
  41160. /**
  41161. * 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)
  41162. */
  41163. dragDeltaRatio: number;
  41164. /**
  41165. * If the drag plane orientation should be updated during the dragging (Default: true)
  41166. */
  41167. updateDragPlane: boolean;
  41168. private _debugMode;
  41169. private _moving;
  41170. /**
  41171. * Fires each time the attached mesh is dragged with the pointer
  41172. * * delta between last drag position and current drag position in world space
  41173. * * dragDistance along the drag axis
  41174. * * dragPlaneNormal normal of the current drag plane used during the drag
  41175. * * dragPlanePoint in world space where the drag intersects the drag plane
  41176. */
  41177. onDragObservable: Observable<{
  41178. delta: Vector3;
  41179. dragPlanePoint: Vector3;
  41180. dragPlaneNormal: Vector3;
  41181. dragDistance: number;
  41182. pointerId: number;
  41183. }>;
  41184. /**
  41185. * Fires each time a drag begins (eg. mouse down on mesh)
  41186. */
  41187. onDragStartObservable: Observable<{
  41188. dragPlanePoint: Vector3;
  41189. pointerId: number;
  41190. }>;
  41191. /**
  41192. * Fires each time a drag ends (eg. mouse release after drag)
  41193. */
  41194. onDragEndObservable: Observable<{
  41195. dragPlanePoint: Vector3;
  41196. pointerId: number;
  41197. }>;
  41198. /**
  41199. * If the attached mesh should be moved when dragged
  41200. */
  41201. moveAttached: boolean;
  41202. /**
  41203. * If the drag behavior will react to drag events (Default: true)
  41204. */
  41205. enabled: boolean;
  41206. /**
  41207. * If camera controls should be detached during the drag
  41208. */
  41209. detachCameraControls: boolean;
  41210. /**
  41211. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41212. */
  41213. useObjectOrienationForDragging: boolean;
  41214. private _options;
  41215. /**
  41216. * Creates a pointer drag behavior that can be attached to a mesh
  41217. * @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)
  41218. */
  41219. constructor(options?: {
  41220. dragAxis?: Vector3;
  41221. dragPlaneNormal?: Vector3;
  41222. });
  41223. /**
  41224. * Predicate to determine if it is valid to move the object to a new position when it is moved
  41225. */
  41226. validateDrag: (targetPosition: Vector3) => boolean;
  41227. /**
  41228. * The name of the behavior
  41229. */
  41230. readonly name: string;
  41231. /**
  41232. * Initializes the behavior
  41233. */
  41234. init(): void;
  41235. private _tmpVector;
  41236. private _alternatePickedPoint;
  41237. private _worldDragAxis;
  41238. private _targetPosition;
  41239. private _attachedElement;
  41240. /**
  41241. * Attaches the drag behavior the passed in mesh
  41242. * @param ownerNode The mesh that will be dragged around once attached
  41243. */
  41244. attach(ownerNode: AbstractMesh): void;
  41245. /**
  41246. * Force relase the drag action by code.
  41247. */
  41248. releaseDrag(): void;
  41249. private _startDragRay;
  41250. private _lastPointerRay;
  41251. /**
  41252. * Simulates the start of a pointer drag event on the behavior
  41253. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41254. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41255. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41256. */
  41257. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41258. private _startDrag;
  41259. private _dragDelta;
  41260. private _moveDrag;
  41261. private _pickWithRayOnDragPlane;
  41262. private _pointA;
  41263. private _pointB;
  41264. private _pointC;
  41265. private _lineA;
  41266. private _lineB;
  41267. private _localAxis;
  41268. private _lookAt;
  41269. private _updateDragPlanePosition;
  41270. /**
  41271. * Detaches the behavior from the mesh
  41272. */
  41273. detach(): void;
  41274. }
  41275. }
  41276. declare module BABYLON {
  41277. /**
  41278. * 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
  41279. */
  41280. class SixDofDragBehavior implements Behavior<Mesh> {
  41281. private static _virtualScene;
  41282. private _ownerNode;
  41283. private _sceneRenderObserver;
  41284. private _scene;
  41285. private _targetPosition;
  41286. private _virtualOriginMesh;
  41287. private _virtualDragMesh;
  41288. private _pointerObserver;
  41289. private _moving;
  41290. private _startingOrientation;
  41291. /**
  41292. * 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)
  41293. */
  41294. private zDragFactor;
  41295. /**
  41296. * If the object should rotate to face the drag origin
  41297. */
  41298. rotateDraggedObject: boolean;
  41299. /**
  41300. * If the behavior is currently in a dragging state
  41301. */
  41302. dragging: boolean;
  41303. /**
  41304. * 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)
  41305. */
  41306. dragDeltaRatio: number;
  41307. /**
  41308. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41309. */
  41310. currentDraggingPointerID: number;
  41311. /**
  41312. * If camera controls should be detached during the drag
  41313. */
  41314. detachCameraControls: boolean;
  41315. /**
  41316. * Fires each time a drag starts
  41317. */
  41318. onDragStartObservable: Observable<{}>;
  41319. /**
  41320. * Fires each time a drag ends (eg. mouse release after drag)
  41321. */
  41322. onDragEndObservable: Observable<{}>;
  41323. /**
  41324. * 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
  41325. */
  41326. constructor();
  41327. /**
  41328. * The name of the behavior
  41329. */
  41330. readonly name: string;
  41331. /**
  41332. * Initializes the behavior
  41333. */
  41334. init(): void;
  41335. /**
  41336. * Attaches the scale behavior the passed in mesh
  41337. * @param ownerNode The mesh that will be scaled around once attached
  41338. */
  41339. attach(ownerNode: Mesh): void;
  41340. /**
  41341. * Detaches the behavior from the mesh
  41342. */
  41343. detach(): void;
  41344. }
  41345. }
  41346. declare module BABYLON {
  41347. /**
  41348. * Contains an array of blocks representing the octree
  41349. */
  41350. interface IOctreeContainer<T> {
  41351. /**
  41352. * Blocks within the octree
  41353. */
  41354. blocks: Array<OctreeBlock<T>>;
  41355. }
  41356. /**
  41357. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41358. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41359. */
  41360. class Octree<T> {
  41361. /** 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.) */
  41362. maxDepth: number;
  41363. /**
  41364. * Blocks within the octree containing objects
  41365. */
  41366. blocks: Array<OctreeBlock<T>>;
  41367. /**
  41368. * Content stored in the octree
  41369. */
  41370. dynamicContent: T[];
  41371. private _maxBlockCapacity;
  41372. private _selectionContent;
  41373. private _creationFunc;
  41374. /**
  41375. * Creates a octree
  41376. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41377. * @param creationFunc function to be used to instatiate the octree
  41378. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41379. * @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.)
  41380. */
  41381. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41382. /** 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.) */
  41383. maxDepth?: number);
  41384. /**
  41385. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41386. * @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);
  41387. * @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);
  41388. * @param entries meshes to be added to the octree blocks
  41389. */
  41390. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41391. /**
  41392. * Adds a mesh to the octree
  41393. * @param entry Mesh to add to the octree
  41394. */
  41395. addMesh(entry: T): void;
  41396. /**
  41397. * Remove an element from the octree
  41398. * @param entry defines the element to remove
  41399. */
  41400. removeMesh(entry: T): void;
  41401. /**
  41402. * Selects an array of meshes within the frustum
  41403. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41404. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41405. * @returns array of meshes within the frustum
  41406. */
  41407. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41408. /**
  41409. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41410. * @param sphereCenter defines the bounding sphere center
  41411. * @param sphereRadius defines the bounding sphere radius
  41412. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41413. * @returns an array of objects that intersect the sphere
  41414. */
  41415. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41416. /**
  41417. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41418. * @param ray defines the ray to test with
  41419. * @returns array of intersected objects
  41420. */
  41421. intersectsRay(ray: Ray): SmartArray<T>;
  41422. /**
  41423. * @hidden
  41424. */
  41425. 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;
  41426. /**
  41427. * Adds a mesh into the octree block if it intersects the block
  41428. */
  41429. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41430. /**
  41431. * Adds a submesh into the octree block if it intersects the block
  41432. */
  41433. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41434. }
  41435. }
  41436. declare module BABYLON {
  41437. /**
  41438. * Class used to store a cell in an octree
  41439. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41440. */
  41441. class OctreeBlock<T> {
  41442. /**
  41443. * Gets the content of the current block
  41444. */
  41445. entries: T[];
  41446. /**
  41447. * Gets the list of block children
  41448. */
  41449. blocks: Array<OctreeBlock<T>>;
  41450. private _depth;
  41451. private _maxDepth;
  41452. private _capacity;
  41453. private _minPoint;
  41454. private _maxPoint;
  41455. private _boundingVectors;
  41456. private _creationFunc;
  41457. /**
  41458. * Creates a new block
  41459. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41460. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41461. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41462. * @param depth defines the current depth of this block in the octree
  41463. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41464. * @param creationFunc defines a callback to call when an element is added to the block
  41465. */
  41466. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41467. /**
  41468. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41469. */
  41470. readonly capacity: number;
  41471. /**
  41472. * Gets the minimum vector (in world space) of the block's bounding box
  41473. */
  41474. readonly minPoint: Vector3;
  41475. /**
  41476. * Gets the maximum vector (in world space) of the block's bounding box
  41477. */
  41478. readonly maxPoint: Vector3;
  41479. /**
  41480. * Add a new element to this block
  41481. * @param entry defines the element to add
  41482. */
  41483. addEntry(entry: T): void;
  41484. /**
  41485. * Remove an element from this block
  41486. * @param entry defines the element to remove
  41487. */
  41488. removeEntry(entry: T): void;
  41489. /**
  41490. * Add an array of elements to this block
  41491. * @param entries defines the array of elements to add
  41492. */
  41493. addEntries(entries: T[]): void;
  41494. /**
  41495. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41496. * @param frustumPlanes defines the frustum planes to test
  41497. * @param selection defines the array to store current content if selection is positive
  41498. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41499. */
  41500. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41501. /**
  41502. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41503. * @param sphereCenter defines the bounding sphere center
  41504. * @param sphereRadius defines the bounding sphere radius
  41505. * @param selection defines the array to store current content if selection is positive
  41506. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41507. */
  41508. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41509. /**
  41510. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41511. * @param ray defines the ray to test with
  41512. * @param selection defines the array to store current content if selection is positive
  41513. */
  41514. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41515. /**
  41516. * Subdivide the content into child blocks (this block will then be empty)
  41517. */
  41518. createInnerBlocks(): void;
  41519. }
  41520. }
  41521. declare module BABYLON {
  41522. interface Scene {
  41523. /**
  41524. * @hidden
  41525. * Backing Filed
  41526. */
  41527. _selectionOctree: Octree<AbstractMesh>;
  41528. /**
  41529. * Gets the octree used to boost mesh selection (picking)
  41530. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41531. */
  41532. selectionOctree: Octree<AbstractMesh>;
  41533. /**
  41534. * Creates or updates the octree used to boost selection (picking)
  41535. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41536. * @param maxCapacity defines the maximum capacity per leaf
  41537. * @param maxDepth defines the maximum depth of the octree
  41538. * @returns an octree of AbstractMesh
  41539. */
  41540. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41541. }
  41542. interface AbstractMesh {
  41543. /**
  41544. * @hidden
  41545. * Backing Field
  41546. */
  41547. _submeshesOctree: Octree<SubMesh>;
  41548. /**
  41549. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41550. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41551. * @param maxCapacity defines the maximum size of each block (64 by default)
  41552. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41553. * @returns the new octree
  41554. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41555. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41556. */
  41557. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41558. }
  41559. /**
  41560. * Defines the octree scene component responsible to manage any octrees
  41561. * in a given scene.
  41562. */
  41563. class OctreeSceneComponent {
  41564. /**
  41565. * The component name helpfull to identify the component in the list of scene components.
  41566. */
  41567. readonly name: string;
  41568. /**
  41569. * The scene the component belongs to.
  41570. */
  41571. scene: Scene;
  41572. /**
  41573. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41574. */
  41575. readonly checksIsEnabled: boolean;
  41576. /**
  41577. * Creates a new instance of the component for the given scene
  41578. * @param scene Defines the scene to register the component in
  41579. */
  41580. constructor(scene: Scene);
  41581. /**
  41582. * Registers the component in a given scene
  41583. */
  41584. register(): void;
  41585. /**
  41586. * Return the list of active meshes
  41587. * @returns the list of active meshes
  41588. */
  41589. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41590. /**
  41591. * Return the list of active sub meshes
  41592. * @param mesh The mesh to get the candidates sub meshes from
  41593. * @returns the list of active sub meshes
  41594. */
  41595. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41596. private _tempRay;
  41597. /**
  41598. * Return the list of sub meshes intersecting with a given local ray
  41599. * @param mesh defines the mesh to find the submesh for
  41600. * @param localRay defines the ray in local space
  41601. * @returns the list of intersecting sub meshes
  41602. */
  41603. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41604. /**
  41605. * Return the list of sub meshes colliding with a collider
  41606. * @param mesh defines the mesh to find the submesh for
  41607. * @param collider defines the collider to evaluate the collision against
  41608. * @returns the list of colliding sub meshes
  41609. */
  41610. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41611. /**
  41612. * Rebuilds the elements related to this component in case of
  41613. * context lost for instance.
  41614. */
  41615. rebuild(): void;
  41616. /**
  41617. * Disposes the component and the associated ressources.
  41618. */
  41619. dispose(): void;
  41620. }
  41621. }
  41622. declare module BABYLON {
  41623. /**
  41624. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41625. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41626. */
  41627. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41628. /**
  41629. * Creates a new AnaglyphArcRotateCamera
  41630. * @param name defines camera name
  41631. * @param alpha defines alpha angle (in radians)
  41632. * @param beta defines beta angle (in radians)
  41633. * @param radius defines radius
  41634. * @param target defines camera target
  41635. * @param interaxialDistance defines distance between each color axis
  41636. * @param scene defines the hosting scene
  41637. */
  41638. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41639. /**
  41640. * Gets camera class name
  41641. * @returns AnaglyphArcRotateCamera
  41642. */
  41643. getClassName(): string;
  41644. }
  41645. }
  41646. declare module BABYLON {
  41647. /**
  41648. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41649. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41650. */
  41651. class AnaglyphFreeCamera extends FreeCamera {
  41652. /**
  41653. * Creates a new AnaglyphFreeCamera
  41654. * @param name defines camera name
  41655. * @param position defines initial position
  41656. * @param interaxialDistance defines distance between each color axis
  41657. * @param scene defines the hosting scene
  41658. */
  41659. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41660. /**
  41661. * Gets camera class name
  41662. * @returns AnaglyphFreeCamera
  41663. */
  41664. getClassName(): string;
  41665. }
  41666. }
  41667. declare module BABYLON {
  41668. /**
  41669. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41670. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41671. */
  41672. class AnaglyphGamepadCamera extends GamepadCamera {
  41673. /**
  41674. * Creates a new AnaglyphGamepadCamera
  41675. * @param name defines camera name
  41676. * @param position defines initial position
  41677. * @param interaxialDistance defines distance between each color axis
  41678. * @param scene defines the hosting scene
  41679. */
  41680. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41681. /**
  41682. * Gets camera class name
  41683. * @returns AnaglyphGamepadCamera
  41684. */
  41685. getClassName(): string;
  41686. }
  41687. }
  41688. declare module BABYLON {
  41689. /**
  41690. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41691. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41692. */
  41693. class AnaglyphUniversalCamera extends UniversalCamera {
  41694. /**
  41695. * Creates a new AnaglyphUniversalCamera
  41696. * @param name defines camera name
  41697. * @param position defines initial position
  41698. * @param interaxialDistance defines distance between each color axis
  41699. * @param scene defines the hosting scene
  41700. */
  41701. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41702. /**
  41703. * Gets camera class name
  41704. * @returns AnaglyphUniversalCamera
  41705. */
  41706. getClassName(): string;
  41707. }
  41708. }
  41709. declare module BABYLON {
  41710. /**
  41711. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41712. * @see http://doc.babylonjs.com/features/cameras
  41713. */
  41714. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41715. /**
  41716. * Creates a new StereoscopicArcRotateCamera
  41717. * @param name defines camera name
  41718. * @param alpha defines alpha angle (in radians)
  41719. * @param beta defines beta angle (in radians)
  41720. * @param radius defines radius
  41721. * @param target defines camera target
  41722. * @param interaxialDistance defines distance between each color axis
  41723. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41724. * @param scene defines the hosting scene
  41725. */
  41726. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41727. /**
  41728. * Gets camera class name
  41729. * @returns StereoscopicArcRotateCamera
  41730. */
  41731. getClassName(): string;
  41732. }
  41733. }
  41734. declare module BABYLON {
  41735. /**
  41736. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41737. * @see http://doc.babylonjs.com/features/cameras
  41738. */
  41739. class StereoscopicFreeCamera extends FreeCamera {
  41740. /**
  41741. * Creates a new StereoscopicFreeCamera
  41742. * @param name defines camera name
  41743. * @param position defines initial position
  41744. * @param interaxialDistance defines distance between each color axis
  41745. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41746. * @param scene defines the hosting scene
  41747. */
  41748. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41749. /**
  41750. * Gets camera class name
  41751. * @returns StereoscopicFreeCamera
  41752. */
  41753. getClassName(): string;
  41754. }
  41755. }
  41756. declare module BABYLON {
  41757. /**
  41758. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41759. * @see http://doc.babylonjs.com/features/cameras
  41760. */
  41761. class StereoscopicGamepadCamera extends GamepadCamera {
  41762. /**
  41763. * Creates a new StereoscopicGamepadCamera
  41764. * @param name defines camera name
  41765. * @param position defines initial position
  41766. * @param interaxialDistance defines distance between each color axis
  41767. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41768. * @param scene defines the hosting scene
  41769. */
  41770. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41771. /**
  41772. * Gets camera class name
  41773. * @returns StereoscopicGamepadCamera
  41774. */
  41775. getClassName(): string;
  41776. }
  41777. }
  41778. declare module BABYLON {
  41779. /**
  41780. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41781. * @see http://doc.babylonjs.com/features/cameras
  41782. */
  41783. class StereoscopicUniversalCamera extends UniversalCamera {
  41784. /**
  41785. * Creates a new StereoscopicUniversalCamera
  41786. * @param name defines camera name
  41787. * @param position defines initial position
  41788. * @param interaxialDistance defines distance between each color axis
  41789. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41790. * @param scene defines the hosting scene
  41791. */
  41792. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41793. /**
  41794. * Gets camera class name
  41795. * @returns StereoscopicUniversalCamera
  41796. */
  41797. getClassName(): string;
  41798. }
  41799. }
  41800. declare module BABYLON {
  41801. /**
  41802. * Manage the gamepad inputs to control an arc rotate camera.
  41803. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41804. */
  41805. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41806. /**
  41807. * Defines the camera the input is attached to.
  41808. */
  41809. camera: ArcRotateCamera;
  41810. /**
  41811. * Defines the gamepad the input is gathering event from.
  41812. */
  41813. gamepad: Nullable<Gamepad>;
  41814. /**
  41815. * Defines the gamepad rotation sensiblity.
  41816. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41817. */
  41818. gamepadRotationSensibility: number;
  41819. /**
  41820. * Defines the gamepad move sensiblity.
  41821. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41822. */
  41823. gamepadMoveSensibility: number;
  41824. private _onGamepadConnectedObserver;
  41825. private _onGamepadDisconnectedObserver;
  41826. /**
  41827. * Attach the input controls to a specific dom element to get the input from.
  41828. * @param element Defines the element the controls should be listened from
  41829. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41830. */
  41831. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41832. /**
  41833. * Detach the current controls from the specified dom element.
  41834. * @param element Defines the element to stop listening the inputs from
  41835. */
  41836. detachControl(element: Nullable<HTMLElement>): void;
  41837. /**
  41838. * Update the current camera state depending on the inputs that have been used this frame.
  41839. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41840. */
  41841. checkInputs(): void;
  41842. /**
  41843. * Gets the class name of the current intput.
  41844. * @returns the class name
  41845. */
  41846. getClassName(): string;
  41847. /**
  41848. * Get the friendly name associated with the input class.
  41849. * @returns the input friendly name
  41850. */
  41851. getSimpleName(): string;
  41852. }
  41853. }
  41854. declare module BABYLON {
  41855. /**
  41856. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41857. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41858. */
  41859. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41860. /**
  41861. * Defines the camera the input is attached to.
  41862. */
  41863. camera: ArcRotateCamera;
  41864. /**
  41865. * Defines the list of key codes associated with the up action (increase alpha)
  41866. */
  41867. keysUp: number[];
  41868. /**
  41869. * Defines the list of key codes associated with the down action (decrease alpha)
  41870. */
  41871. keysDown: number[];
  41872. /**
  41873. * Defines the list of key codes associated with the left action (increase beta)
  41874. */
  41875. keysLeft: number[];
  41876. /**
  41877. * Defines the list of key codes associated with the right action (decrease beta)
  41878. */
  41879. keysRight: number[];
  41880. /**
  41881. * Defines the list of key codes associated with the reset action.
  41882. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41883. */
  41884. keysReset: number[];
  41885. /**
  41886. * Defines the panning sensibility of the inputs.
  41887. * (How fast is the camera paning)
  41888. */
  41889. panningSensibility: number;
  41890. /**
  41891. * Defines the zooming sensibility of the inputs.
  41892. * (How fast is the camera zooming)
  41893. */
  41894. zoomingSensibility: number;
  41895. /**
  41896. * Defines wether maintaining the alt key down switch the movement mode from
  41897. * orientation to zoom.
  41898. */
  41899. useAltToZoom: boolean;
  41900. /**
  41901. * Rotation speed of the camera
  41902. */
  41903. angularSpeed: number;
  41904. private _keys;
  41905. private _ctrlPressed;
  41906. private _altPressed;
  41907. private _onCanvasBlurObserver;
  41908. private _onKeyboardObserver;
  41909. private _engine;
  41910. private _scene;
  41911. /**
  41912. * Attach the input controls to a specific dom element to get the input from.
  41913. * @param element Defines the element the controls should be listened from
  41914. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41915. */
  41916. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41917. /**
  41918. * Detach the current controls from the specified dom element.
  41919. * @param element Defines the element to stop listening the inputs from
  41920. */
  41921. detachControl(element: Nullable<HTMLElement>): void;
  41922. /**
  41923. * Update the current camera state depending on the inputs that have been used this frame.
  41924. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41925. */
  41926. checkInputs(): void;
  41927. /**
  41928. * Gets the class name of the current intput.
  41929. * @returns the class name
  41930. */
  41931. getClassName(): string;
  41932. /**
  41933. * Get the friendly name associated with the input class.
  41934. * @returns the input friendly name
  41935. */
  41936. getSimpleName(): string;
  41937. }
  41938. }
  41939. declare module BABYLON {
  41940. /**
  41941. * Manage the mouse wheel inputs to control an arc rotate camera.
  41942. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41943. */
  41944. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41945. /**
  41946. * Defines the camera the input is attached to.
  41947. */
  41948. camera: ArcRotateCamera;
  41949. /**
  41950. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41951. */
  41952. wheelPrecision: number;
  41953. /**
  41954. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41955. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41956. */
  41957. wheelDeltaPercentage: number;
  41958. private _wheel;
  41959. private _observer;
  41960. /**
  41961. * Attach the input controls to a specific dom element to get the input from.
  41962. * @param element Defines the element the controls should be listened from
  41963. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41964. */
  41965. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41966. /**
  41967. * Detach the current controls from the specified dom element.
  41968. * @param element Defines the element to stop listening the inputs from
  41969. */
  41970. detachControl(element: Nullable<HTMLElement>): void;
  41971. /**
  41972. * Gets the class name of the current intput.
  41973. * @returns the class name
  41974. */
  41975. getClassName(): string;
  41976. /**
  41977. * Get the friendly name associated with the input class.
  41978. * @returns the input friendly name
  41979. */
  41980. getSimpleName(): string;
  41981. }
  41982. }
  41983. declare module BABYLON {
  41984. /**
  41985. * Manage the pointers inputs to control an arc rotate camera.
  41986. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41987. */
  41988. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41989. /**
  41990. * Defines the camera the input is attached to.
  41991. */
  41992. camera: ArcRotateCamera;
  41993. /**
  41994. * Defines the buttons associated with the input to handle camera move.
  41995. */
  41996. buttons: number[];
  41997. /**
  41998. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41999. */
  42000. angularSensibilityX: number;
  42001. /**
  42002. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42003. */
  42004. angularSensibilityY: number;
  42005. /**
  42006. * Defines the pointer pinch precision or how fast is the camera zooming.
  42007. */
  42008. pinchPrecision: number;
  42009. /**
  42010. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  42011. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42012. */
  42013. pinchDeltaPercentage: number;
  42014. /**
  42015. * Defines the pointer panning sensibility or how fast is the camera moving.
  42016. */
  42017. panningSensibility: number;
  42018. /**
  42019. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42020. */
  42021. multiTouchPanning: boolean;
  42022. /**
  42023. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  42024. */
  42025. multiTouchPanAndZoom: boolean;
  42026. /**
  42027. * Revers pinch action direction.
  42028. */
  42029. pinchInwards: boolean;
  42030. private _isPanClick;
  42031. private _pointerInput;
  42032. private _observer;
  42033. private _onMouseMove;
  42034. private _onGestureStart;
  42035. private _onGesture;
  42036. private _MSGestureHandler;
  42037. private _onLostFocus;
  42038. private _onContextMenu;
  42039. /**
  42040. * Attach the input controls to a specific dom element to get the input from.
  42041. * @param element Defines the element the controls should be listened from
  42042. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42043. */
  42044. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42045. /**
  42046. * Detach the current controls from the specified dom element.
  42047. * @param element Defines the element to stop listening the inputs from
  42048. */
  42049. detachControl(element: Nullable<HTMLElement>): void;
  42050. /**
  42051. * Gets the class name of the current intput.
  42052. * @returns the class name
  42053. */
  42054. getClassName(): string;
  42055. /**
  42056. * Get the friendly name associated with the input class.
  42057. * @returns the input friendly name
  42058. */
  42059. getSimpleName(): string;
  42060. }
  42061. }
  42062. declare module BABYLON {
  42063. /**
  42064. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42065. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42066. */
  42067. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42068. /**
  42069. * Defines the camera the input is attached to.
  42070. */
  42071. camera: ArcRotateCamera;
  42072. /**
  42073. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42074. */
  42075. alphaCorrection: number;
  42076. /**
  42077. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  42078. */
  42079. gammaCorrection: number;
  42080. private _alpha;
  42081. private _gamma;
  42082. private _dirty;
  42083. private _deviceOrientationHandler;
  42084. /**
  42085. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  42086. */
  42087. constructor();
  42088. /**
  42089. * Attach the input controls to a specific dom element to get the input from.
  42090. * @param element Defines the element the controls should be listened from
  42091. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42092. */
  42093. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42094. /** @hidden */
  42095. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  42096. /**
  42097. * Update the current camera state depending on the inputs that have been used this frame.
  42098. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42099. */
  42100. checkInputs(): void;
  42101. /**
  42102. * Detach the current controls from the specified dom element.
  42103. * @param element Defines the element to stop listening the inputs from
  42104. */
  42105. detachControl(element: Nullable<HTMLElement>): void;
  42106. /**
  42107. * Gets the class name of the current intput.
  42108. * @returns the class name
  42109. */
  42110. getClassName(): string;
  42111. /**
  42112. * Get the friendly name associated with the input class.
  42113. * @returns the input friendly name
  42114. */
  42115. getSimpleName(): string;
  42116. }
  42117. }
  42118. declare module BABYLON {
  42119. /**
  42120. * Listen to keyboard events to control the camera.
  42121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42122. */
  42123. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  42124. /**
  42125. * Defines the camera the input is attached to.
  42126. */
  42127. camera: FlyCamera;
  42128. /**
  42129. * The list of keyboard keys used to control the forward move of the camera.
  42130. */
  42131. keysForward: number[];
  42132. /**
  42133. * The list of keyboard keys used to control the backward move of the camera.
  42134. */
  42135. keysBackward: number[];
  42136. /**
  42137. * The list of keyboard keys used to control the forward move of the camera.
  42138. */
  42139. keysUp: number[];
  42140. /**
  42141. * The list of keyboard keys used to control the backward move of the camera.
  42142. */
  42143. keysDown: number[];
  42144. /**
  42145. * The list of keyboard keys used to control the right strafe move of the camera.
  42146. */
  42147. keysRight: number[];
  42148. /**
  42149. * The list of keyboard keys used to control the left strafe move of the camera.
  42150. */
  42151. keysLeft: number[];
  42152. private _keys;
  42153. private _onCanvasBlurObserver;
  42154. private _onKeyboardObserver;
  42155. private _engine;
  42156. private _scene;
  42157. /**
  42158. * Attach the input controls to a specific dom element to get the input from.
  42159. * @param element Defines the element the controls should be listened from
  42160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42161. */
  42162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42163. /**
  42164. * Detach the current controls from the specified dom element.
  42165. * @param element Defines the element to stop listening the inputs from
  42166. */
  42167. detachControl(element: Nullable<HTMLElement>): void;
  42168. /**
  42169. * Gets the class name of the current intput.
  42170. * @returns the class name
  42171. */
  42172. getClassName(): string;
  42173. /** @hidden */
  42174. _onLostFocus(e: FocusEvent): void;
  42175. /**
  42176. * Get the friendly name associated with the input class.
  42177. * @returns the input friendly name
  42178. */
  42179. getSimpleName(): string;
  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. }
  42187. declare module BABYLON {
  42188. /**
  42189. * Listen to mouse events to control the camera.
  42190. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42191. */
  42192. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42193. /**
  42194. * Defines the camera the input is attached to.
  42195. */
  42196. camera: FlyCamera;
  42197. /**
  42198. * Defines if touch is enabled. (Default is true.)
  42199. */
  42200. touchEnabled: boolean;
  42201. /**
  42202. * Defines the buttons associated with the input to handle camera rotation.
  42203. */
  42204. buttons: number[];
  42205. /**
  42206. * Assign buttons for Yaw control.
  42207. */
  42208. buttonsYaw: number[];
  42209. /**
  42210. * Assign buttons for Pitch control.
  42211. */
  42212. buttonsPitch: number[];
  42213. /**
  42214. * Assign buttons for Roll control.
  42215. */
  42216. buttonsRoll: number[];
  42217. /**
  42218. * Detect if any button is being pressed while mouse is moved.
  42219. * -1 = Mouse locked.
  42220. * 0 = Left button.
  42221. * 1 = Middle Button.
  42222. * 2 = Right Button.
  42223. */
  42224. activeButton: number;
  42225. /**
  42226. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42227. * Higher values reduce its sensitivity.
  42228. */
  42229. angularSensibility: number;
  42230. private _mousemoveCallback;
  42231. private _observer;
  42232. private _rollObserver;
  42233. private previousPosition;
  42234. private noPreventDefault;
  42235. private element;
  42236. /**
  42237. * Listen to mouse events to control the camera.
  42238. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42239. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42240. */
  42241. constructor(touchEnabled?: boolean);
  42242. /**
  42243. * Attach the mouse control to the HTML DOM element.
  42244. * @param element Defines the element that listens to the input events.
  42245. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  42246. */
  42247. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42248. /**
  42249. * Detach the current controls from the specified dom element.
  42250. * @param element Defines the element to stop listening the inputs from
  42251. */
  42252. detachControl(element: Nullable<HTMLElement>): void;
  42253. /**
  42254. * Gets the class name of the current input.
  42255. * @returns the class name.
  42256. */
  42257. getClassName(): string;
  42258. /**
  42259. * Get the friendly name associated with the input class.
  42260. * @returns the input's friendly name.
  42261. */
  42262. getSimpleName(): string;
  42263. private _pointerInput;
  42264. private _onMouseMove;
  42265. /**
  42266. * Rotate camera by mouse offset.
  42267. */
  42268. private rotateCamera;
  42269. }
  42270. }
  42271. declare module BABYLON {
  42272. /**
  42273. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42274. * Screen rotation is taken into account.
  42275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42276. */
  42277. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42278. private _camera;
  42279. private _screenOrientationAngle;
  42280. private _constantTranform;
  42281. private _screenQuaternion;
  42282. private _alpha;
  42283. private _beta;
  42284. private _gamma;
  42285. /**
  42286. * Instantiates a new input
  42287. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42288. */
  42289. constructor();
  42290. /**
  42291. * Define the camera controlled by the input.
  42292. */
  42293. camera: FreeCamera;
  42294. /**
  42295. * Attach the input controls to a specific dom element to get the input from.
  42296. * @param element Defines the element the controls should be listened from
  42297. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42298. */
  42299. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42300. private _orientationChanged;
  42301. private _deviceOrientation;
  42302. /**
  42303. * Detach the current controls from the specified dom element.
  42304. * @param element Defines the element to stop listening the inputs from
  42305. */
  42306. detachControl(element: Nullable<HTMLElement>): void;
  42307. /**
  42308. * Update the current camera state depending on the inputs that have been used this frame.
  42309. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42310. */
  42311. checkInputs(): void;
  42312. /**
  42313. * Gets the class name of the current intput.
  42314. * @returns the class name
  42315. */
  42316. getClassName(): string;
  42317. /**
  42318. * Get the friendly name associated with the input class.
  42319. * @returns the input friendly name
  42320. */
  42321. getSimpleName(): string;
  42322. }
  42323. }
  42324. declare module BABYLON {
  42325. /**
  42326. * Manage the gamepad inputs to control a free camera.
  42327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42328. */
  42329. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42330. /**
  42331. * Define the camera the input is attached to.
  42332. */
  42333. camera: FreeCamera;
  42334. /**
  42335. * Define the Gamepad controlling the input
  42336. */
  42337. gamepad: Nullable<Gamepad>;
  42338. /**
  42339. * Defines the gamepad rotation sensiblity.
  42340. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42341. */
  42342. gamepadAngularSensibility: number;
  42343. /**
  42344. * Defines the gamepad move sensiblity.
  42345. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42346. */
  42347. gamepadMoveSensibility: number;
  42348. private _onGamepadConnectedObserver;
  42349. private _onGamepadDisconnectedObserver;
  42350. private _cameraTransform;
  42351. private _deltaTransform;
  42352. private _vector3;
  42353. private _vector2;
  42354. /**
  42355. * Attach the input controls to a specific dom element to get the input from.
  42356. * @param element Defines the element the controls should be listened from
  42357. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42358. */
  42359. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42360. /**
  42361. * Detach the current controls from the specified dom element.
  42362. * @param element Defines the element to stop listening the inputs from
  42363. */
  42364. detachControl(element: Nullable<HTMLElement>): void;
  42365. /**
  42366. * Update the current camera state depending on the inputs that have been used this frame.
  42367. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42368. */
  42369. checkInputs(): void;
  42370. /**
  42371. * Gets the class name of the current intput.
  42372. * @returns the class name
  42373. */
  42374. getClassName(): string;
  42375. /**
  42376. * Get the friendly name associated with the input class.
  42377. * @returns the input friendly name
  42378. */
  42379. getSimpleName(): string;
  42380. }
  42381. }
  42382. declare module BABYLON {
  42383. /**
  42384. * Manage the keyboard inputs to control the movement of a free camera.
  42385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42386. */
  42387. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  42388. /**
  42389. * Defines the camera the input is attached to.
  42390. */
  42391. camera: FreeCamera;
  42392. /**
  42393. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  42394. */
  42395. keysUp: number[];
  42396. /**
  42397. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  42398. */
  42399. keysDown: number[];
  42400. /**
  42401. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  42402. */
  42403. keysLeft: number[];
  42404. /**
  42405. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  42406. */
  42407. keysRight: number[];
  42408. private _keys;
  42409. private _onCanvasBlurObserver;
  42410. private _onKeyboardObserver;
  42411. private _engine;
  42412. private _scene;
  42413. /**
  42414. * Attach the input controls to a specific dom element to get the input from.
  42415. * @param element Defines the element the controls should be listened from
  42416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42417. */
  42418. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42419. /**
  42420. * Detach the current controls from the specified dom element.
  42421. * @param element Defines the element to stop listening the inputs from
  42422. */
  42423. detachControl(element: Nullable<HTMLElement>): void;
  42424. /**
  42425. * Update the current camera state depending on the inputs that have been used this frame.
  42426. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42427. */
  42428. checkInputs(): void;
  42429. /**
  42430. * Gets the class name of the current intput.
  42431. * @returns the class name
  42432. */
  42433. getClassName(): string;
  42434. /** @hidden */
  42435. _onLostFocus(e: FocusEvent): void;
  42436. /**
  42437. * Get the friendly name associated with the input class.
  42438. * @returns the input friendly name
  42439. */
  42440. getSimpleName(): string;
  42441. }
  42442. }
  42443. declare module BABYLON {
  42444. /**
  42445. * Manage the mouse inputs to control the movement of a free camera.
  42446. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42447. */
  42448. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  42449. /**
  42450. * Define if touch is enabled in the mouse input
  42451. */
  42452. touchEnabled: boolean;
  42453. /**
  42454. * Defines the camera the input is attached to.
  42455. */
  42456. camera: FreeCamera;
  42457. /**
  42458. * Defines the buttons associated with the input to handle camera move.
  42459. */
  42460. buttons: number[];
  42461. /**
  42462. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  42463. */
  42464. angularSensibility: number;
  42465. private _pointerInput;
  42466. private _onMouseMove;
  42467. private _observer;
  42468. private previousPosition;
  42469. /**
  42470. * Manage the mouse inputs to control the movement of a free camera.
  42471. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42472. * @param touchEnabled Defines if touch is enabled or not
  42473. */
  42474. constructor(
  42475. /**
  42476. * Define if touch is enabled in the mouse input
  42477. */
  42478. touchEnabled?: boolean);
  42479. /**
  42480. * Attach the input controls to a specific dom element to get the input from.
  42481. * @param element Defines the element the controls should be listened from
  42482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42483. */
  42484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42485. /**
  42486. * Detach the current controls from the specified dom element.
  42487. * @param element Defines the element to stop listening the inputs from
  42488. */
  42489. detachControl(element: Nullable<HTMLElement>): void;
  42490. /**
  42491. * Gets the class name of the current intput.
  42492. * @returns the class name
  42493. */
  42494. getClassName(): string;
  42495. /**
  42496. * Get the friendly name associated with the input class.
  42497. * @returns the input friendly name
  42498. */
  42499. getSimpleName(): string;
  42500. }
  42501. }
  42502. declare module BABYLON {
  42503. /**
  42504. * Manage the touch inputs to control the movement of a free camera.
  42505. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42506. */
  42507. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  42508. /**
  42509. * Defines the camera the input is attached to.
  42510. */
  42511. camera: FreeCamera;
  42512. /**
  42513. * Defines the touch sensibility for rotation.
  42514. * The higher the faster.
  42515. */
  42516. touchAngularSensibility: number;
  42517. /**
  42518. * Defines the touch sensibility for move.
  42519. * The higher the faster.
  42520. */
  42521. touchMoveSensibility: number;
  42522. private _offsetX;
  42523. private _offsetY;
  42524. private _pointerPressed;
  42525. private _pointerInput;
  42526. private _observer;
  42527. private _onLostFocus;
  42528. /**
  42529. * Attach the input controls to a specific dom element to get the input from.
  42530. * @param element Defines the element the controls should be listened from
  42531. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42532. */
  42533. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42534. /**
  42535. * Detach the current controls from the specified dom element.
  42536. * @param element Defines the element to stop listening the inputs from
  42537. */
  42538. detachControl(element: Nullable<HTMLElement>): void;
  42539. /**
  42540. * Update the current camera state depending on the inputs that have been used this frame.
  42541. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42542. */
  42543. checkInputs(): void;
  42544. /**
  42545. * Gets the class name of the current intput.
  42546. * @returns the class name
  42547. */
  42548. getClassName(): string;
  42549. /**
  42550. * Get the friendly name associated with the input class.
  42551. * @returns the input friendly name
  42552. */
  42553. getSimpleName(): string;
  42554. }
  42555. }
  42556. declare module BABYLON {
  42557. /**
  42558. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42559. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42560. */
  42561. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42562. /**
  42563. * Defines the camera the input is attached to.
  42564. */
  42565. camera: FreeCamera;
  42566. private _leftjoystick;
  42567. private _rightjoystick;
  42568. /**
  42569. * Gets the left stick of the virtual joystick.
  42570. * @returns The virtual Joystick
  42571. */
  42572. getLeftJoystick(): VirtualJoystick;
  42573. /**
  42574. * Gets the right stick of the virtual joystick.
  42575. * @returns The virtual Joystick
  42576. */
  42577. getRightJoystick(): VirtualJoystick;
  42578. /**
  42579. * Update the current camera state depending on the inputs that have been used this frame.
  42580. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42581. */
  42582. checkInputs(): void;
  42583. /**
  42584. * Attach the input controls to a specific dom element to get the input from.
  42585. * @param element Defines the element the controls should be listened from
  42586. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42587. */
  42588. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42589. /**
  42590. * Detach the current controls from the specified dom element.
  42591. * @param element Defines the element to stop listening the inputs from
  42592. */
  42593. detachControl(element: Nullable<HTMLElement>): void;
  42594. /**
  42595. * Gets the class name of the current intput.
  42596. * @returns the class name
  42597. */
  42598. getClassName(): string;
  42599. /**
  42600. * Get the friendly name associated with the input class.
  42601. * @returns the input friendly name
  42602. */
  42603. getSimpleName(): string;
  42604. }
  42605. }
  42606. declare module BABYLON {
  42607. /**
  42608. * This represents all the required metrics to create a VR camera.
  42609. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42610. */
  42611. class VRCameraMetrics {
  42612. /**
  42613. * Define the horizontal resolution off the screen.
  42614. */
  42615. hResolution: number;
  42616. /**
  42617. * Define the vertical resolution off the screen.
  42618. */
  42619. vResolution: number;
  42620. /**
  42621. * Define the horizontal screen size.
  42622. */
  42623. hScreenSize: number;
  42624. /**
  42625. * Define the vertical screen size.
  42626. */
  42627. vScreenSize: number;
  42628. /**
  42629. * Define the vertical screen center position.
  42630. */
  42631. vScreenCenter: number;
  42632. /**
  42633. * Define the distance of the eyes to the screen.
  42634. */
  42635. eyeToScreenDistance: number;
  42636. /**
  42637. * Define the distance between both lenses
  42638. */
  42639. lensSeparationDistance: number;
  42640. /**
  42641. * Define the distance between both viewer's eyes.
  42642. */
  42643. interpupillaryDistance: number;
  42644. /**
  42645. * Define the distortion factor of the VR postprocess.
  42646. * Please, touch with care.
  42647. */
  42648. distortionK: number[];
  42649. /**
  42650. * Define the chromatic aberration correction factors for the VR post process.
  42651. */
  42652. chromaAbCorrection: number[];
  42653. /**
  42654. * Define the scale factor of the post process.
  42655. * The smaller the better but the slower.
  42656. */
  42657. postProcessScaleFactor: number;
  42658. /**
  42659. * Define an offset for the lens center.
  42660. */
  42661. lensCenterOffset: number;
  42662. /**
  42663. * Define if the current vr camera should compensate the distortion of the lense or not.
  42664. */
  42665. compensateDistortion: boolean;
  42666. /**
  42667. * Gets the rendering aspect ratio based on the provided resolutions.
  42668. */
  42669. readonly aspectRatio: number;
  42670. /**
  42671. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42672. */
  42673. readonly aspectRatioFov: number;
  42674. /**
  42675. * @hidden
  42676. */
  42677. readonly leftHMatrix: Matrix;
  42678. /**
  42679. * @hidden
  42680. */
  42681. readonly rightHMatrix: Matrix;
  42682. /**
  42683. * @hidden
  42684. */
  42685. readonly leftPreViewMatrix: Matrix;
  42686. /**
  42687. * @hidden
  42688. */
  42689. readonly rightPreViewMatrix: Matrix;
  42690. /**
  42691. * Get the default VRMetrics based on the most generic setup.
  42692. * @returns the default vr metrics
  42693. */
  42694. static GetDefault(): VRCameraMetrics;
  42695. }
  42696. }
  42697. declare module BABYLON {
  42698. /**
  42699. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42700. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42701. */
  42702. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42703. /**
  42704. * Creates a new VRDeviceOrientationArcRotateCamera
  42705. * @param name defines camera name
  42706. * @param alpha defines the camera rotation along the logitudinal axis
  42707. * @param beta defines the camera rotation along the latitudinal axis
  42708. * @param radius defines the camera distance from its target
  42709. * @param target defines the camera target
  42710. * @param scene defines the scene the camera belongs to
  42711. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42712. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42713. */
  42714. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42715. /**
  42716. * Gets camera class name
  42717. * @returns VRDeviceOrientationArcRotateCamera
  42718. */
  42719. getClassName(): string;
  42720. }
  42721. }
  42722. declare module BABYLON {
  42723. /**
  42724. * Camera used to simulate VR rendering (based on FreeCamera)
  42725. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42726. */
  42727. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42728. /**
  42729. * Creates a new VRDeviceOrientationFreeCamera
  42730. * @param name defines camera name
  42731. * @param position defines the start position of the camera
  42732. * @param scene defines the scene the camera belongs to
  42733. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42734. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42735. */
  42736. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42737. /**
  42738. * Gets camera class name
  42739. * @returns VRDeviceOrientationFreeCamera
  42740. */
  42741. getClassName(): string;
  42742. }
  42743. }
  42744. declare module BABYLON {
  42745. /**
  42746. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42747. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42748. */
  42749. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42750. /**
  42751. * Creates a new VRDeviceOrientationGamepadCamera
  42752. * @param name defines camera name
  42753. * @param position defines the start position of the camera
  42754. * @param scene defines the scene the camera belongs to
  42755. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42756. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42757. */
  42758. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42759. /**
  42760. * Gets camera class name
  42761. * @returns VRDeviceOrientationGamepadCamera
  42762. */
  42763. getClassName(): string;
  42764. }
  42765. }
  42766. declare module BABYLON {
  42767. /**
  42768. * Options to modify the vr teleportation behavior.
  42769. */
  42770. interface VRTeleportationOptions {
  42771. /**
  42772. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42773. */
  42774. floorMeshName?: string;
  42775. /**
  42776. * A list of meshes to be used as the teleportation floor. (default: empty)
  42777. */
  42778. floorMeshes?: Mesh[];
  42779. }
  42780. /**
  42781. * Options to modify the vr experience helper's behavior.
  42782. */
  42783. interface VRExperienceHelperOptions extends WebVROptions {
  42784. /**
  42785. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42786. */
  42787. createDeviceOrientationCamera?: boolean;
  42788. /**
  42789. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42790. */
  42791. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42792. /**
  42793. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42794. */
  42795. laserToggle?: boolean;
  42796. /**
  42797. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42798. */
  42799. floorMeshes?: Mesh[];
  42800. }
  42801. /**
  42802. * Helps to quickly add VR support to an existing scene.
  42803. * See http://doc.babylonjs.com/how_to/webvr_helper
  42804. */
  42805. class VRExperienceHelper {
  42806. /** Options to modify the vr experience helper's behavior. */
  42807. webVROptions: VRExperienceHelperOptions;
  42808. private _scene;
  42809. private _position;
  42810. private _btnVR;
  42811. private _btnVRDisplayed;
  42812. private _webVRsupported;
  42813. private _webVRready;
  42814. private _webVRrequesting;
  42815. private _webVRpresenting;
  42816. private _hasEnteredVR;
  42817. private _fullscreenVRpresenting;
  42818. private _canvas;
  42819. private _webVRCamera;
  42820. private _vrDeviceOrientationCamera;
  42821. private _deviceOrientationCamera;
  42822. private _existingCamera;
  42823. private _onKeyDown;
  42824. private _onVrDisplayPresentChange;
  42825. private _onVRDisplayChanged;
  42826. private _onVRRequestPresentStart;
  42827. private _onVRRequestPresentComplete;
  42828. /**
  42829. * Observable raised when entering VR.
  42830. */
  42831. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42832. /**
  42833. * Observable raised when exiting VR.
  42834. */
  42835. onExitingVRObservable: Observable<VRExperienceHelper>;
  42836. /**
  42837. * Observable raised when controller mesh is loaded.
  42838. */
  42839. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42840. /** Return this.onEnteringVRObservable
  42841. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42842. */
  42843. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42844. /** Return this.onExitingVRObservable
  42845. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42846. */
  42847. readonly onExitingVR: Observable<VRExperienceHelper>;
  42848. /** Return this.onControllerMeshLoadedObservable
  42849. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42850. */
  42851. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42852. private _rayLength;
  42853. private _useCustomVRButton;
  42854. private _teleportationRequested;
  42855. private _teleportActive;
  42856. private _floorMeshName;
  42857. private _floorMeshesCollection;
  42858. private _rotationAllowed;
  42859. private _teleportBackwardsVector;
  42860. private _teleportationTarget;
  42861. private _isDefaultTeleportationTarget;
  42862. private _postProcessMove;
  42863. private _teleportationFillColor;
  42864. private _teleportationBorderColor;
  42865. private _rotationAngle;
  42866. private _haloCenter;
  42867. private _cameraGazer;
  42868. private _padSensibilityUp;
  42869. private _padSensibilityDown;
  42870. private _leftController;
  42871. private _rightController;
  42872. /**
  42873. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42874. */
  42875. onNewMeshSelected: Observable<AbstractMesh>;
  42876. /**
  42877. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42878. */
  42879. onNewMeshPicked: Observable<PickingInfo>;
  42880. private _circleEase;
  42881. /**
  42882. * Observable raised before camera teleportation
  42883. */
  42884. onBeforeCameraTeleport: Observable<Vector3>;
  42885. /**
  42886. * Observable raised after camera teleportation
  42887. */
  42888. onAfterCameraTeleport: Observable<Vector3>;
  42889. /**
  42890. * Observable raised when current selected mesh gets unselected
  42891. */
  42892. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42893. private _raySelectionPredicate;
  42894. /**
  42895. * To be optionaly changed by user to define custom ray selection
  42896. */
  42897. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42898. /**
  42899. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42900. */
  42901. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42902. /**
  42903. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42904. */
  42905. teleportationEnabled: boolean;
  42906. private _defaultHeight;
  42907. private _teleportationInitialized;
  42908. private _interactionsEnabled;
  42909. private _interactionsRequested;
  42910. private _displayGaze;
  42911. private _displayLaserPointer;
  42912. /**
  42913. * The mesh used to display where the user is going to teleport.
  42914. */
  42915. /**
  42916. * Sets the mesh to be used to display where the user is going to teleport.
  42917. */
  42918. teleportationTarget: Mesh;
  42919. /**
  42920. * 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
  42921. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42922. * See http://doc.babylonjs.com/resources/baking_transformations
  42923. */
  42924. gazeTrackerMesh: Mesh;
  42925. /**
  42926. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42927. */
  42928. updateGazeTrackerScale: boolean;
  42929. /**
  42930. * If the gaze trackers color should be updated when selecting meshes
  42931. */
  42932. updateGazeTrackerColor: boolean;
  42933. /**
  42934. * The gaze tracking mesh corresponding to the left controller
  42935. */
  42936. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42937. /**
  42938. * The gaze tracking mesh corresponding to the right controller
  42939. */
  42940. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42941. /**
  42942. * If the ray of the gaze should be displayed.
  42943. */
  42944. /**
  42945. * Sets if the ray of the gaze should be displayed.
  42946. */
  42947. displayGaze: boolean;
  42948. /**
  42949. * If the ray of the LaserPointer should be displayed.
  42950. */
  42951. /**
  42952. * Sets if the ray of the LaserPointer should be displayed.
  42953. */
  42954. displayLaserPointer: boolean;
  42955. /**
  42956. * The deviceOrientationCamera used as the camera when not in VR.
  42957. */
  42958. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42959. /**
  42960. * Based on the current WebVR support, returns the current VR camera used.
  42961. */
  42962. readonly currentVRCamera: Nullable<Camera>;
  42963. /**
  42964. * The webVRCamera which is used when in VR.
  42965. */
  42966. readonly webVRCamera: WebVRFreeCamera;
  42967. /**
  42968. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42969. */
  42970. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42971. private readonly _teleportationRequestInitiated;
  42972. /**
  42973. * Instantiates a VRExperienceHelper.
  42974. * Helps to quickly add VR support to an existing scene.
  42975. * @param scene The scene the VRExperienceHelper belongs to.
  42976. * @param webVROptions Options to modify the vr experience helper's behavior.
  42977. */
  42978. constructor(scene: Scene,
  42979. /** Options to modify the vr experience helper's behavior. */
  42980. webVROptions?: VRExperienceHelperOptions);
  42981. private _onDefaultMeshLoaded;
  42982. private _onResize;
  42983. private _onFullscreenChange;
  42984. /**
  42985. * Gets a value indicating if we are currently in VR mode.
  42986. */
  42987. readonly isInVRMode: boolean;
  42988. private onVrDisplayPresentChange;
  42989. private onVRDisplayChanged;
  42990. private moveButtonToBottomRight;
  42991. private displayVRButton;
  42992. private updateButtonVisibility;
  42993. private _cachedAngularSensibility;
  42994. /**
  42995. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42996. * Otherwise, will use the fullscreen API.
  42997. */
  42998. enterVR(): void;
  42999. /**
  43000. * Attempt to exit VR, or fullscreen.
  43001. */
  43002. exitVR(): void;
  43003. /**
  43004. * The position of the vr experience helper.
  43005. */
  43006. /**
  43007. * Sets the position of the vr experience helper.
  43008. */
  43009. position: Vector3;
  43010. /**
  43011. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43012. */
  43013. enableInteractions(): void;
  43014. private readonly _noControllerIsActive;
  43015. private beforeRender;
  43016. private _isTeleportationFloor;
  43017. /**
  43018. * Adds a floor mesh to be used for teleportation.
  43019. * @param floorMesh the mesh to be used for teleportation.
  43020. */
  43021. addFloorMesh(floorMesh: Mesh): void;
  43022. /**
  43023. * Removes a floor mesh from being used for teleportation.
  43024. * @param floorMesh the mesh to be removed.
  43025. */
  43026. removeFloorMesh(floorMesh: Mesh): void;
  43027. /**
  43028. * Enables interactions and teleportation using the VR controllers and gaze.
  43029. * @param vrTeleportationOptions options to modify teleportation behavior.
  43030. */
  43031. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43032. private _onNewGamepadConnected;
  43033. private _tryEnableInteractionOnController;
  43034. private _onNewGamepadDisconnected;
  43035. private _enableInteractionOnController;
  43036. private _checkTeleportWithRay;
  43037. private _checkRotate;
  43038. private _checkTeleportBackwards;
  43039. private _enableTeleportationOnController;
  43040. private _createTeleportationCircles;
  43041. private _displayTeleportationTarget;
  43042. private _hideTeleportationTarget;
  43043. private _rotateCamera;
  43044. private _moveTeleportationSelectorTo;
  43045. private _workingVector;
  43046. private _workingQuaternion;
  43047. private _workingMatrix;
  43048. /**
  43049. * Teleports the users feet to the desired location
  43050. * @param location The location where the user's feet should be placed
  43051. */
  43052. teleportCamera(location: Vector3): void;
  43053. private _convertNormalToDirectionOfRay;
  43054. private _castRayAndSelectObject;
  43055. private _notifySelectedMeshUnselected;
  43056. /**
  43057. * Sets the color of the laser ray from the vr controllers.
  43058. * @param color new color for the ray.
  43059. */
  43060. changeLaserColor(color: Color3): void;
  43061. /**
  43062. * Sets the color of the ray from the vr headsets gaze.
  43063. * @param color new color for the ray.
  43064. */
  43065. changeGazeColor(color: Color3): void;
  43066. /**
  43067. * Exits VR and disposes of the vr experience helper
  43068. */
  43069. dispose(): void;
  43070. /**
  43071. * Gets the name of the VRExperienceHelper class
  43072. * @returns "VRExperienceHelper"
  43073. */
  43074. getClassName(): string;
  43075. }
  43076. }
  43077. declare module BABYLON {
  43078. /**
  43079. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  43080. * IMPORTANT!! The data is right-hand data.
  43081. * @export
  43082. * @interface DevicePose
  43083. */
  43084. interface DevicePose {
  43085. /**
  43086. * The position of the device, values in array are [x,y,z].
  43087. */
  43088. readonly position: Nullable<Float32Array>;
  43089. /**
  43090. * The linearVelocity of the device, values in array are [x,y,z].
  43091. */
  43092. readonly linearVelocity: Nullable<Float32Array>;
  43093. /**
  43094. * The linearAcceleration of the device, values in array are [x,y,z].
  43095. */
  43096. readonly linearAcceleration: Nullable<Float32Array>;
  43097. /**
  43098. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  43099. */
  43100. readonly orientation: Nullable<Float32Array>;
  43101. /**
  43102. * The angularVelocity of the device, values in array are [x,y,z].
  43103. */
  43104. readonly angularVelocity: Nullable<Float32Array>;
  43105. /**
  43106. * The angularAcceleration of the device, values in array are [x,y,z].
  43107. */
  43108. readonly angularAcceleration: Nullable<Float32Array>;
  43109. }
  43110. /**
  43111. * Interface representing a pose controlled object in Babylon.
  43112. * A pose controlled object has both regular pose values as well as pose values
  43113. * from an external device such as a VR head mounted display
  43114. */
  43115. interface PoseControlled {
  43116. /**
  43117. * The position of the object in babylon space.
  43118. */
  43119. position: Vector3;
  43120. /**
  43121. * The rotation quaternion of the object in babylon space.
  43122. */
  43123. rotationQuaternion: Quaternion;
  43124. /**
  43125. * The position of the device in babylon space.
  43126. */
  43127. devicePosition?: Vector3;
  43128. /**
  43129. * The rotation quaternion of the device in babylon space.
  43130. */
  43131. deviceRotationQuaternion: Quaternion;
  43132. /**
  43133. * The raw pose coming from the device.
  43134. */
  43135. rawPose: Nullable<DevicePose>;
  43136. /**
  43137. * The scale of the device to be used when translating from device space to babylon space.
  43138. */
  43139. deviceScaleFactor: number;
  43140. /**
  43141. * Updates the poseControlled values based on the input device pose.
  43142. * @param poseData the pose data to update the object with
  43143. */
  43144. updateFromDevice(poseData: DevicePose): void;
  43145. }
  43146. /**
  43147. * Set of options to customize the webVRCamera
  43148. */
  43149. interface WebVROptions {
  43150. /**
  43151. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  43152. */
  43153. trackPosition?: boolean;
  43154. /**
  43155. * Sets the scale of the vrDevice in babylon space. (default: 1)
  43156. */
  43157. positionScale?: number;
  43158. /**
  43159. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  43160. */
  43161. displayName?: string;
  43162. /**
  43163. * Should the native controller meshes be initialized. (default: true)
  43164. */
  43165. controllerMeshes?: boolean;
  43166. /**
  43167. * Creating a default HemiLight only on controllers. (default: true)
  43168. */
  43169. defaultLightingOnControllers?: boolean;
  43170. /**
  43171. * If you don't want to use the default VR button of the helper. (default: false)
  43172. */
  43173. useCustomVRButton?: boolean;
  43174. /**
  43175. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  43176. */
  43177. customVRButton?: HTMLButtonElement;
  43178. /**
  43179. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  43180. */
  43181. rayLength?: number;
  43182. /**
  43183. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  43184. */
  43185. defaultHeight?: number;
  43186. }
  43187. /**
  43188. * This represents a WebVR camera.
  43189. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  43190. * @example http://doc.babylonjs.com/how_to/webvr_camera
  43191. */
  43192. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  43193. private webVROptions;
  43194. /**
  43195. * @hidden
  43196. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  43197. */
  43198. _vrDevice: any;
  43199. /**
  43200. * The rawPose of the vrDevice.
  43201. */
  43202. rawPose: Nullable<DevicePose>;
  43203. private _onVREnabled;
  43204. private _specsVersion;
  43205. private _attached;
  43206. private _frameData;
  43207. protected _descendants: Array<Node>;
  43208. private _deviceRoomPosition;
  43209. /** @hidden */
  43210. _deviceRoomRotationQuaternion: Quaternion;
  43211. private _standingMatrix;
  43212. /**
  43213. * Represents device position in babylon space.
  43214. */
  43215. devicePosition: Vector3;
  43216. /**
  43217. * Represents device rotation in babylon space.
  43218. */
  43219. deviceRotationQuaternion: Quaternion;
  43220. /**
  43221. * The scale of the device to be used when translating from device space to babylon space.
  43222. */
  43223. deviceScaleFactor: number;
  43224. private _deviceToWorld;
  43225. private _worldToDevice;
  43226. /**
  43227. * References to the webVR controllers for the vrDevice.
  43228. */
  43229. controllers: Array<WebVRController>;
  43230. /**
  43231. * Emits an event when a controller is attached.
  43232. */
  43233. onControllersAttachedObservable: Observable<WebVRController[]>;
  43234. /**
  43235. * Emits an event when a controller's mesh has been loaded;
  43236. */
  43237. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43238. /**
  43239. * Emits an event when the HMD's pose has been updated.
  43240. */
  43241. onPoseUpdatedFromDeviceObservable: Observable<any>;
  43242. private _poseSet;
  43243. /**
  43244. * If the rig cameras be used as parent instead of this camera.
  43245. */
  43246. rigParenting: boolean;
  43247. private _lightOnControllers;
  43248. private _defaultHeight?;
  43249. /**
  43250. * Instantiates a WebVRFreeCamera.
  43251. * @param name The name of the WebVRFreeCamera
  43252. * @param position The starting anchor position for the camera
  43253. * @param scene The scene the camera belongs to
  43254. * @param webVROptions a set of customizable options for the webVRCamera
  43255. */
  43256. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  43257. /**
  43258. * Gets the device distance from the ground in meters.
  43259. * @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.
  43260. */
  43261. deviceDistanceToRoomGround(): number;
  43262. /**
  43263. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  43264. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  43265. */
  43266. useStandingMatrix(callback?: (bool: boolean) => void): void;
  43267. /**
  43268. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  43269. * @returns A promise with a boolean set to if the standing matrix is supported.
  43270. */
  43271. useStandingMatrixAsync(): Promise<boolean>;
  43272. /**
  43273. * Disposes the camera
  43274. */
  43275. dispose(): void;
  43276. /**
  43277. * Gets a vrController by name.
  43278. * @param name The name of the controller to retreive
  43279. * @returns the controller matching the name specified or null if not found
  43280. */
  43281. getControllerByName(name: string): Nullable<WebVRController>;
  43282. private _leftController;
  43283. /**
  43284. * The controller corrisponding to the users left hand.
  43285. */
  43286. readonly leftController: Nullable<WebVRController>;
  43287. private _rightController;
  43288. /**
  43289. * The controller corrisponding to the users right hand.
  43290. */
  43291. readonly rightController: Nullable<WebVRController>;
  43292. /**
  43293. * Casts a ray forward from the vrCamera's gaze.
  43294. * @param length Length of the ray (default: 100)
  43295. * @returns the ray corrisponding to the gaze
  43296. */
  43297. getForwardRay(length?: number): Ray;
  43298. /**
  43299. * @hidden
  43300. * Updates the camera based on device's frame data
  43301. */
  43302. _checkInputs(): void;
  43303. /**
  43304. * Updates the poseControlled values based on the input device pose.
  43305. * @param poseData Pose coming from the device
  43306. */
  43307. updateFromDevice(poseData: DevicePose): void;
  43308. private _htmlElementAttached;
  43309. private _detachIfAttached;
  43310. /**
  43311. * WebVR's attach control will start broadcasting frames to the device.
  43312. * Note that in certain browsers (chrome for example) this function must be called
  43313. * within a user-interaction callback. Example:
  43314. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  43315. *
  43316. * @param element html element to attach the vrDevice to
  43317. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  43318. */
  43319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43320. /**
  43321. * Detaches the camera from the html element and disables VR
  43322. *
  43323. * @param element html element to detach from
  43324. */
  43325. detachControl(element: HTMLElement): void;
  43326. /**
  43327. * @returns the name of this class
  43328. */
  43329. getClassName(): string;
  43330. /**
  43331. * Calls resetPose on the vrDisplay
  43332. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  43333. */
  43334. resetToCurrentRotation(): void;
  43335. /**
  43336. * @hidden
  43337. * Updates the rig cameras (left and right eye)
  43338. */
  43339. _updateRigCameras(): void;
  43340. private _workingVector;
  43341. private _oneVector;
  43342. private _workingMatrix;
  43343. private updateCacheCalled;
  43344. private _correctPositionIfNotTrackPosition;
  43345. /**
  43346. * @hidden
  43347. * Updates the cached values of the camera
  43348. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  43349. */
  43350. _updateCache(ignoreParentClass?: boolean): void;
  43351. /**
  43352. * @hidden
  43353. * Get current device position in babylon world
  43354. */
  43355. _computeDevicePosition(): void;
  43356. /**
  43357. * Updates the current device position and rotation in the babylon world
  43358. */
  43359. update(): void;
  43360. /**
  43361. * @hidden
  43362. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  43363. * @returns an identity matrix
  43364. */
  43365. _getViewMatrix(): Matrix;
  43366. private _tmpMatrix;
  43367. /**
  43368. * This function is called by the two RIG cameras.
  43369. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  43370. */
  43371. protected _getWebVRViewMatrix(): Matrix;
  43372. protected _getWebVRProjectionMatrix(): Matrix;
  43373. private _onGamepadConnectedObserver;
  43374. private _onGamepadDisconnectedObserver;
  43375. private _updateCacheWhenTrackingDisabledObserver;
  43376. /**
  43377. * Initializes the controllers and their meshes
  43378. */
  43379. initControllers(): void;
  43380. }
  43381. }
  43382. declare module BABYLON {
  43383. /**
  43384. * WebXR Camera which holds the views for the xrSession
  43385. * @see https://doc.babylonjs.com/how_to/webxr
  43386. */
  43387. class WebXRCamera extends FreeCamera {
  43388. private static _TmpMatrix;
  43389. /**
  43390. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43391. * @param name the name of the camera
  43392. * @param scene the scene to add the camera to
  43393. */
  43394. constructor(name: string, scene: BABYLON.Scene);
  43395. private _updateNumberOfRigCameras;
  43396. /** @hidden */
  43397. _updateForDualEyeDebugging(pupilDistance?: number): void;
  43398. /**
  43399. * Updates the cameras position from the current pose information of the XR session
  43400. * @param xrSessionManager the session containing pose information
  43401. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43402. */
  43403. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43404. }
  43405. }
  43406. declare module BABYLON {
  43407. /**
  43408. * Button which can be used to enter a different mode of XR
  43409. */
  43410. class WebXREnterExitUIButton {
  43411. /** button element */
  43412. element: HTMLElement;
  43413. /** XR initialization options for the button */
  43414. initializationOptions: XRSessionCreationOptions;
  43415. /**
  43416. * Creates a WebXREnterExitUIButton
  43417. * @param element button element
  43418. * @param initializationOptions XR initialization options for the button
  43419. */
  43420. constructor(
  43421. /** button element */
  43422. element: HTMLElement,
  43423. /** XR initialization options for the button */
  43424. initializationOptions: XRSessionCreationOptions);
  43425. /**
  43426. * Overwritable function which can be used to update the button's visuals when the state changes
  43427. * @param activeButton the current active button in the UI
  43428. */
  43429. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43430. }
  43431. /**
  43432. * Options to create the webXR UI
  43433. */
  43434. class WebXREnterExitUIOptions {
  43435. /**
  43436. * Context to enter xr with
  43437. */
  43438. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  43439. /**
  43440. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43441. */
  43442. customButtons?: Array<WebXREnterExitUIButton>;
  43443. }
  43444. /**
  43445. * UI to allow the user to enter/exit XR mode
  43446. */
  43447. class WebXREnterExitUI implements IDisposable {
  43448. private scene;
  43449. private _overlay;
  43450. private _buttons;
  43451. private _activeButton;
  43452. /**
  43453. * Fired every time the active button is changed.
  43454. *
  43455. * When xr is entered via a button that launches xr that button will be the callback parameter
  43456. *
  43457. * When exiting xr the callback parameter will be null)
  43458. */
  43459. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43460. /**
  43461. * Creates UI to allow the user to enter/exit XR mode
  43462. * @param scene the scene to add the ui to
  43463. * @param helper the xr experience helper to enter/exit xr with
  43464. * @param options options to configure the UI
  43465. * @returns the created ui
  43466. */
  43467. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43468. private constructor();
  43469. private _updateButtons;
  43470. /**
  43471. * Disposes of the object
  43472. */
  43473. dispose(): void;
  43474. }
  43475. }
  43476. declare module BABYLON {
  43477. /**
  43478. * States of the webXR experience
  43479. */
  43480. enum WebXRState {
  43481. /**
  43482. * Transitioning to being in XR mode
  43483. */
  43484. ENTERING_XR = 0,
  43485. /**
  43486. * Transitioning to non XR mode
  43487. */
  43488. EXITING_XR = 1,
  43489. /**
  43490. * In XR mode and presenting
  43491. */
  43492. IN_XR = 2,
  43493. /**
  43494. * Not entered XR mode
  43495. */
  43496. NOT_IN_XR = 3
  43497. }
  43498. /**
  43499. * Helper class used to enable XR
  43500. * @see https://doc.babylonjs.com/how_to/webxr
  43501. */
  43502. class WebXRExperienceHelper implements IDisposable {
  43503. private scene;
  43504. /**
  43505. * 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
  43506. */
  43507. container: AbstractMesh;
  43508. /**
  43509. * Camera used to render xr content
  43510. */
  43511. camera: WebXRCamera;
  43512. /**
  43513. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43514. */
  43515. state: WebXRState;
  43516. private _setState;
  43517. private static _TmpVector;
  43518. /**
  43519. * Fires when the state of the experience helper has changed
  43520. */
  43521. onStateChangedObservable: Observable<WebXRState>;
  43522. /** @hidden */
  43523. _sessionManager: WebXRSessionManager;
  43524. private _nonVRCamera;
  43525. private _originalSceneAutoClear;
  43526. private _supported;
  43527. /**
  43528. * Creates the experience helper
  43529. * @param scene the scene to attach the experience helper to
  43530. * @returns a promise for the experience helper
  43531. */
  43532. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  43533. /**
  43534. * Creates a WebXRExperienceHelper
  43535. * @param scene The scene the helper should be created in
  43536. */
  43537. private constructor();
  43538. /**
  43539. * Exits XR mode and returns the scene to its original state
  43540. * @returns promise that resolves after xr mode has exited
  43541. */
  43542. exitXRAsync(): Promise<void>;
  43543. /**
  43544. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43545. * @param sessionCreationOptions options for the XR session
  43546. * @param frameOfReference frame of reference of the XR session
  43547. * @returns promise that resolves after xr mode has entered
  43548. */
  43549. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  43550. /**
  43551. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43552. * @param ray ray to cast into the environment
  43553. * @returns Promise which resolves with a collision point in the environment if it exists
  43554. */
  43555. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43556. /**
  43557. * Updates the global position of the camera by moving the camera's container
  43558. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43559. * @param position The desired global position of the camera
  43560. */
  43561. setPositionOfCameraUsingContainer(position: Vector3): void;
  43562. /**
  43563. * Rotates the xr camera by rotating the camera's container around the camera's position
  43564. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43565. * @param rotation the desired quaternion rotation to apply to the camera
  43566. */
  43567. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43568. /**
  43569. * Checks if the creation options are supported by the xr session
  43570. * @param options creation options
  43571. * @returns true if supported
  43572. */
  43573. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43574. /**
  43575. * Disposes of the experience helper
  43576. */
  43577. dispose(): void;
  43578. }
  43579. }
  43580. declare module BABYLON {
  43581. /**
  43582. * Represents an XR input
  43583. */
  43584. class WebXRController {
  43585. /**
  43586. * 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
  43587. */
  43588. grip?: BABYLON.AbstractMesh;
  43589. /**
  43590. * Pointer which can be used to select objects or attach a visible laser to
  43591. */
  43592. pointer: BABYLON.AbstractMesh;
  43593. /**
  43594. * Creates the controller
  43595. * @see https://doc.babylonjs.com/how_to/webxr
  43596. * @param scene the scene which the controller should be associated to
  43597. */
  43598. constructor(scene: BABYLON.Scene);
  43599. /**
  43600. * Disposes of the object
  43601. */
  43602. dispose(): void;
  43603. }
  43604. /**
  43605. * XR input used to track XR inputs such as controllers/rays
  43606. */
  43607. class WebXRInput implements IDisposable {
  43608. private helper;
  43609. /**
  43610. * XR controllers being tracked
  43611. */
  43612. controllers: Array<WebXRController>;
  43613. private _tmpMatrix;
  43614. private _frameObserver;
  43615. /**
  43616. * Initializes the WebXRInput
  43617. * @param helper experience helper which the input should be created for
  43618. */
  43619. constructor(helper: WebXRExperienceHelper);
  43620. /**
  43621. * Disposes of the object
  43622. */
  43623. dispose(): void;
  43624. }
  43625. }
  43626. declare module BABYLON {
  43627. /**
  43628. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43629. */
  43630. class WebXRManagedOutputCanvas implements IDisposable {
  43631. private _canvas;
  43632. /**
  43633. * xrpresent context of the canvas which can be used to display/mirror xr content
  43634. */
  43635. canvasContext: Nullable<WebGLRenderingContext>;
  43636. /**
  43637. * Initializes the canvas to be added/removed upon entering/exiting xr
  43638. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43639. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43640. */
  43641. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43642. /**
  43643. * Disposes of the object
  43644. */
  43645. dispose(): void;
  43646. private _setManagedOutputCanvas;
  43647. private _addCanvas;
  43648. private _removeCanvas;
  43649. }
  43650. }
  43651. declare module BABYLON {
  43652. /**
  43653. * Manages an XRSession
  43654. * @see https://doc.babylonjs.com/how_to/webxr
  43655. */
  43656. class WebXRSessionManager implements IDisposable {
  43657. private scene;
  43658. /**
  43659. * Fires every time a new xrFrame arrives which can be used to update the camera
  43660. */
  43661. onXRFrameObservable: Observable<any>;
  43662. /**
  43663. * Fires when the xr session is ended either by the device or manually done
  43664. */
  43665. onXRSessionEnded: Observable<any>;
  43666. /** @hidden */
  43667. _xrSession: XRSession;
  43668. /** @hidden */
  43669. _frameOfReference: XRFrameOfReference;
  43670. /** @hidden */
  43671. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  43672. /** @hidden */
  43673. _currentXRFrame: Nullable<XRFrame>;
  43674. private _xrNavigator;
  43675. private _xrDevice;
  43676. private _tmpMatrix;
  43677. /**
  43678. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43679. * @param scene The scene which the session should be created for
  43680. */
  43681. constructor(scene: BABYLON.Scene);
  43682. /**
  43683. * Initializes the manager
  43684. * After initialization enterXR can be called to start an XR session
  43685. * @returns Promise which resolves after it is initialized
  43686. */
  43687. initializeAsync(): Promise<void>;
  43688. /**
  43689. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  43690. * @param sessionCreationOptions xr options to create the session with
  43691. * @param frameOfReferenceType option to configure how the xr pose is expressed
  43692. * @returns Promise which resolves after it enters XR
  43693. */
  43694. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  43695. /**
  43696. * Stops the xrSession and restores the renderloop
  43697. * @returns Promise which resolves after it exits XR
  43698. */
  43699. exitXRAsync(): Promise<void>;
  43700. /**
  43701. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43702. * @param ray ray to cast into the environment
  43703. * @returns Promise which resolves with a collision point in the environment if it exists
  43704. */
  43705. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43706. /**
  43707. * Checks if a session would be supported for the creation options specified
  43708. * @param options creation options to check if they are supported
  43709. * @returns true if supported
  43710. */
  43711. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43712. /**
  43713. * @hidden
  43714. * Converts the render layer of xrSession to a render target
  43715. * @param session session to create render target for
  43716. * @param scene scene the new render target should be created for
  43717. */
  43718. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  43719. /**
  43720. * Disposes of the session manager
  43721. */
  43722. dispose(): void;
  43723. }
  43724. }
  43725. declare module BABYLON {
  43726. /** @hidden */
  43727. class _OcclusionDataStorage {
  43728. /** @hidden */
  43729. occlusionInternalRetryCounter: number;
  43730. /** @hidden */
  43731. isOcclusionQueryInProgress: boolean;
  43732. /** @hidden */
  43733. isOccluded: boolean;
  43734. /** @hidden */
  43735. occlusionRetryCount: number;
  43736. /** @hidden */
  43737. occlusionType: number;
  43738. /** @hidden */
  43739. occlusionQueryAlgorithmType: number;
  43740. }
  43741. interface Engine {
  43742. /**
  43743. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43744. * @return the new query
  43745. */
  43746. createQuery(): WebGLQuery;
  43747. /**
  43748. * Delete and release a webGL query
  43749. * @param query defines the query to delete
  43750. * @return the current engine
  43751. */
  43752. deleteQuery(query: WebGLQuery): Engine;
  43753. /**
  43754. * Check if a given query has resolved and got its value
  43755. * @param query defines the query to check
  43756. * @returns true if the query got its value
  43757. */
  43758. isQueryResultAvailable(query: WebGLQuery): boolean;
  43759. /**
  43760. * Gets the value of a given query
  43761. * @param query defines the query to check
  43762. * @returns the value of the query
  43763. */
  43764. getQueryResult(query: WebGLQuery): number;
  43765. /**
  43766. * Initiates an occlusion query
  43767. * @param algorithmType defines the algorithm to use
  43768. * @param query defines the query to use
  43769. * @returns the current engine
  43770. * @see http://doc.babylonjs.com/features/occlusionquery
  43771. */
  43772. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43773. /**
  43774. * Ends an occlusion query
  43775. * @see http://doc.babylonjs.com/features/occlusionquery
  43776. * @param algorithmType defines the algorithm to use
  43777. * @returns the current engine
  43778. */
  43779. endOcclusionQuery(algorithmType: number): Engine;
  43780. /**
  43781. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43782. * Please note that only one query can be issued at a time
  43783. * @returns a time token used to track the time span
  43784. */
  43785. startTimeQuery(): Nullable<_TimeToken>;
  43786. /**
  43787. * Ends a time query
  43788. * @param token defines the token used to measure the time span
  43789. * @returns the time spent (in ns)
  43790. */
  43791. endTimeQuery(token: _TimeToken): int;
  43792. /** @hidden */
  43793. _currentNonTimestampToken: Nullable<_TimeToken>;
  43794. /** @hidden */
  43795. _createTimeQuery(): WebGLQuery;
  43796. /** @hidden */
  43797. _deleteTimeQuery(query: WebGLQuery): void;
  43798. /** @hidden */
  43799. _getGlAlgorithmType(algorithmType: number): number;
  43800. /** @hidden */
  43801. _getTimeQueryResult(query: WebGLQuery): any;
  43802. /** @hidden */
  43803. _getTimeQueryAvailability(query: WebGLQuery): any;
  43804. }
  43805. interface AbstractMesh {
  43806. /**
  43807. * Backing filed
  43808. * @hidden
  43809. */
  43810. __occlusionDataStorage: _OcclusionDataStorage;
  43811. /**
  43812. * Access property
  43813. * @hidden
  43814. */
  43815. _occlusionDataStorage: _OcclusionDataStorage;
  43816. /**
  43817. * 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.
  43818. * The default value is -1 which means don't break the query and wait till the result
  43819. * @see http://doc.babylonjs.com/features/occlusionquery
  43820. */
  43821. occlusionRetryCount: number;
  43822. /**
  43823. * 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:
  43824. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43825. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43826. * * 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.
  43827. * @see http://doc.babylonjs.com/features/occlusionquery
  43828. */
  43829. occlusionType: number;
  43830. /**
  43831. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43832. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43833. * * 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.
  43834. * @see http://doc.babylonjs.com/features/occlusionquery
  43835. */
  43836. occlusionQueryAlgorithmType: number;
  43837. /**
  43838. * 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
  43839. * @see http://doc.babylonjs.com/features/occlusionquery
  43840. */
  43841. isOccluded: boolean;
  43842. /**
  43843. * Flag to check the progress status of the query
  43844. * @see http://doc.babylonjs.com/features/occlusionquery
  43845. */
  43846. isOcclusionQueryInProgress: boolean;
  43847. }
  43848. }
  43849. declare module BABYLON {
  43850. interface Engine {
  43851. /**
  43852. * Creates a webGL transform feedback object
  43853. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43854. * @returns the webGL transform feedback object
  43855. */
  43856. createTransformFeedback(): WebGLTransformFeedback;
  43857. /**
  43858. * Delete a webGL transform feedback object
  43859. * @param value defines the webGL transform feedback object to delete
  43860. */
  43861. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43862. /**
  43863. * Bind a webGL transform feedback object to the webgl context
  43864. * @param value defines the webGL transform feedback object to bind
  43865. */
  43866. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43867. /**
  43868. * Begins a transform feedback operation
  43869. * @param usePoints defines if points or triangles must be used
  43870. */
  43871. beginTransformFeedback(usePoints: boolean): void;
  43872. /**
  43873. * Ends a transform feedback operation
  43874. */
  43875. endTransformFeedback(): void;
  43876. /**
  43877. * Specify the varyings to use with transform feedback
  43878. * @param program defines the associated webGL program
  43879. * @param value defines the list of strings representing the varying names
  43880. */
  43881. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43882. /**
  43883. * Bind a webGL buffer for a transform feedback operation
  43884. * @param value defines the webGL buffer to bind
  43885. */
  43886. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43887. }
  43888. }
  43889. declare module BABYLON {
  43890. /**
  43891. * Google Daydream controller
  43892. */
  43893. class DaydreamController extends WebVRController {
  43894. /**
  43895. * Base Url for the controller model.
  43896. */
  43897. static MODEL_BASE_URL: string;
  43898. /**
  43899. * File name for the controller model.
  43900. */
  43901. static MODEL_FILENAME: string;
  43902. /**
  43903. * Gamepad Id prefix used to identify Daydream Controller.
  43904. */
  43905. static readonly GAMEPAD_ID_PREFIX: string;
  43906. /**
  43907. * Creates a new DaydreamController from a gamepad
  43908. * @param vrGamepad the gamepad that the controller should be created from
  43909. */
  43910. constructor(vrGamepad: any);
  43911. /**
  43912. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43913. * @param scene scene in which to add meshes
  43914. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43915. */
  43916. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43917. /**
  43918. * Called once for each button that changed state since the last frame
  43919. * @param buttonIdx Which button index changed
  43920. * @param state New state of the button
  43921. * @param changes Which properties on the state changed since last frame
  43922. */
  43923. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43924. }
  43925. }
  43926. declare module BABYLON {
  43927. /**
  43928. * Gear VR Controller
  43929. */
  43930. class GearVRController extends WebVRController {
  43931. /**
  43932. * Base Url for the controller model.
  43933. */
  43934. static MODEL_BASE_URL: string;
  43935. /**
  43936. * File name for the controller model.
  43937. */
  43938. static MODEL_FILENAME: string;
  43939. /**
  43940. * Gamepad Id prefix used to identify this controller.
  43941. */
  43942. static readonly GAMEPAD_ID_PREFIX: string;
  43943. private readonly _buttonIndexToObservableNameMap;
  43944. /**
  43945. * Creates a new GearVRController from a gamepad
  43946. * @param vrGamepad the gamepad that the controller should be created from
  43947. */
  43948. constructor(vrGamepad: any);
  43949. /**
  43950. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43951. * @param scene scene in which to add meshes
  43952. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43953. */
  43954. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43955. /**
  43956. * Called once for each button that changed state since the last frame
  43957. * @param buttonIdx Which button index changed
  43958. * @param state New state of the button
  43959. * @param changes Which properties on the state changed since last frame
  43960. */
  43961. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43962. }
  43963. }
  43964. declare module BABYLON {
  43965. /**
  43966. * Generic Controller
  43967. */
  43968. class GenericController extends WebVRController {
  43969. /**
  43970. * Base Url for the controller model.
  43971. */
  43972. static readonly MODEL_BASE_URL: string;
  43973. /**
  43974. * File name for the controller model.
  43975. */
  43976. static readonly MODEL_FILENAME: string;
  43977. /**
  43978. * Creates a new GenericController from a gamepad
  43979. * @param vrGamepad the gamepad that the controller should be created from
  43980. */
  43981. constructor(vrGamepad: any);
  43982. /**
  43983. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43984. * @param scene scene in which to add meshes
  43985. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43986. */
  43987. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43988. /**
  43989. * Called once for each button that changed state since the last frame
  43990. * @param buttonIdx Which button index changed
  43991. * @param state New state of the button
  43992. * @param changes Which properties on the state changed since last frame
  43993. */
  43994. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43995. }
  43996. }
  43997. declare module BABYLON {
  43998. /**
  43999. * Oculus Touch Controller
  44000. */
  44001. class OculusTouchController extends WebVRController {
  44002. /**
  44003. * Base Url for the controller model.
  44004. */
  44005. static MODEL_BASE_URL: string;
  44006. /**
  44007. * File name for the left controller model.
  44008. */
  44009. static MODEL_LEFT_FILENAME: string;
  44010. /**
  44011. * File name for the right controller model.
  44012. */
  44013. static MODEL_RIGHT_FILENAME: string;
  44014. /**
  44015. * Fired when the secondary trigger on this controller is modified
  44016. */
  44017. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44018. /**
  44019. * Fired when the thumb rest on this controller is modified
  44020. */
  44021. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44022. /**
  44023. * Creates a new OculusTouchController from a gamepad
  44024. * @param vrGamepad the gamepad that the controller should be created from
  44025. */
  44026. constructor(vrGamepad: any);
  44027. /**
  44028. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44029. * @param scene scene in which to add meshes
  44030. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44031. */
  44032. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44033. /**
  44034. * Fired when the A button on this controller is modified
  44035. */
  44036. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44037. /**
  44038. * Fired when the B button on this controller is modified
  44039. */
  44040. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44041. /**
  44042. * Fired when the X button on this controller is modified
  44043. */
  44044. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44045. /**
  44046. * Fired when the Y button on this controller is modified
  44047. */
  44048. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44049. /**
  44050. * Called once for each button that changed state since the last frame
  44051. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44052. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44053. * 2) secondary trigger (same)
  44054. * 3) A (right) X (left), touch, pressed = value
  44055. * 4) B / Y
  44056. * 5) thumb rest
  44057. * @param buttonIdx Which button index changed
  44058. * @param state New state of the button
  44059. * @param changes Which properties on the state changed since last frame
  44060. */
  44061. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44062. }
  44063. }
  44064. declare module BABYLON {
  44065. /**
  44066. * Defines the types of pose enabled controllers that are supported
  44067. */
  44068. enum PoseEnabledControllerType {
  44069. /**
  44070. * HTC Vive
  44071. */
  44072. VIVE = 0,
  44073. /**
  44074. * Oculus Rift
  44075. */
  44076. OCULUS = 1,
  44077. /**
  44078. * Windows mixed reality
  44079. */
  44080. WINDOWS = 2,
  44081. /**
  44082. * Samsung gear VR
  44083. */
  44084. GEAR_VR = 3,
  44085. /**
  44086. * Google Daydream
  44087. */
  44088. DAYDREAM = 4,
  44089. /**
  44090. * Generic
  44091. */
  44092. GENERIC = 5
  44093. }
  44094. /**
  44095. * Defines the MutableGamepadButton interface for the state of a gamepad button
  44096. */
  44097. interface MutableGamepadButton {
  44098. /**
  44099. * Value of the button/trigger
  44100. */
  44101. value: number;
  44102. /**
  44103. * If the button/trigger is currently touched
  44104. */
  44105. touched: boolean;
  44106. /**
  44107. * If the button/trigger is currently pressed
  44108. */
  44109. pressed: boolean;
  44110. }
  44111. /**
  44112. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  44113. * @hidden
  44114. */
  44115. interface ExtendedGamepadButton extends GamepadButton {
  44116. /**
  44117. * If the button/trigger is currently pressed
  44118. */
  44119. readonly pressed: boolean;
  44120. /**
  44121. * If the button/trigger is currently touched
  44122. */
  44123. readonly touched: boolean;
  44124. /**
  44125. * Value of the button/trigger
  44126. */
  44127. readonly value: number;
  44128. }
  44129. /**
  44130. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44131. */
  44132. class PoseEnabledControllerHelper {
  44133. /**
  44134. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44135. * @param vrGamepad the gamepad to initialized
  44136. * @returns a vr controller of the type the gamepad identified as
  44137. */
  44138. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  44139. }
  44140. /**
  44141. * Defines the PoseEnabledController object that contains state of a vr capable controller
  44142. */
  44143. class PoseEnabledController extends Gamepad implements PoseControlled {
  44144. private _deviceRoomPosition;
  44145. private _deviceRoomRotationQuaternion;
  44146. /**
  44147. * The device position in babylon space
  44148. */
  44149. devicePosition: Vector3;
  44150. /**
  44151. * The device rotation in babylon space
  44152. */
  44153. deviceRotationQuaternion: Quaternion;
  44154. /**
  44155. * The scale factor of the device in babylon space
  44156. */
  44157. deviceScaleFactor: number;
  44158. /**
  44159. * (Likely devicePosition should be used instead) The device position in its room space
  44160. */
  44161. position: Vector3;
  44162. /**
  44163. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  44164. */
  44165. rotationQuaternion: Quaternion;
  44166. /**
  44167. * The type of controller (Eg. Windows mixed reality)
  44168. */
  44169. controllerType: PoseEnabledControllerType;
  44170. protected _calculatedPosition: Vector3;
  44171. private _calculatedRotation;
  44172. /**
  44173. * The raw pose from the device
  44174. */
  44175. rawPose: DevicePose;
  44176. private _trackPosition;
  44177. private _maxRotationDistFromHeadset;
  44178. private _draggedRoomRotation;
  44179. /**
  44180. * @hidden
  44181. */
  44182. _disableTrackPosition(fixedPosition: Vector3): void;
  44183. /**
  44184. * Internal, the mesh attached to the controller
  44185. * @hidden
  44186. */
  44187. _mesh: Nullable<AbstractMesh>;
  44188. private _poseControlledCamera;
  44189. private _leftHandSystemQuaternion;
  44190. /**
  44191. * Internal, matrix used to convert room space to babylon space
  44192. * @hidden
  44193. */
  44194. _deviceToWorld: Matrix;
  44195. /**
  44196. * Node to be used when casting a ray from the controller
  44197. * @hidden
  44198. */
  44199. _pointingPoseNode: Nullable<TransformNode>;
  44200. /**
  44201. * Name of the child mesh that can be used to cast a ray from the controller
  44202. */
  44203. static readonly POINTING_POSE: string;
  44204. /**
  44205. * Creates a new PoseEnabledController from a gamepad
  44206. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  44207. */
  44208. constructor(browserGamepad: any);
  44209. private _workingMatrix;
  44210. /**
  44211. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  44212. */
  44213. update(): void;
  44214. /**
  44215. * Updates only the pose device and mesh without doing any button event checking
  44216. */
  44217. protected _updatePoseAndMesh(): void;
  44218. /**
  44219. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  44220. * @param poseData raw pose fromthe device
  44221. */
  44222. updateFromDevice(poseData: DevicePose): void;
  44223. /**
  44224. * @hidden
  44225. */
  44226. _meshAttachedObservable: Observable<AbstractMesh>;
  44227. /**
  44228. * Attaches a mesh to the controller
  44229. * @param mesh the mesh to be attached
  44230. */
  44231. attachToMesh(mesh: AbstractMesh): void;
  44232. /**
  44233. * Attaches the controllers mesh to a camera
  44234. * @param camera the camera the mesh should be attached to
  44235. */
  44236. attachToPoseControlledCamera(camera: TargetCamera): void;
  44237. /**
  44238. * Disposes of the controller
  44239. */
  44240. dispose(): void;
  44241. /**
  44242. * The mesh that is attached to the controller
  44243. */
  44244. readonly mesh: Nullable<AbstractMesh>;
  44245. /**
  44246. * Gets the ray of the controller in the direction the controller is pointing
  44247. * @param length the length the resulting ray should be
  44248. * @returns a ray in the direction the controller is pointing
  44249. */
  44250. getForwardRay(length?: number): Ray;
  44251. }
  44252. }
  44253. declare module BABYLON {
  44254. /**
  44255. * Vive Controller
  44256. */
  44257. class ViveController extends WebVRController {
  44258. /**
  44259. * Base Url for the controller model.
  44260. */
  44261. static MODEL_BASE_URL: string;
  44262. /**
  44263. * File name for the controller model.
  44264. */
  44265. static MODEL_FILENAME: string;
  44266. /**
  44267. * Creates a new ViveController from a gamepad
  44268. * @param vrGamepad the gamepad that the controller should be created from
  44269. */
  44270. constructor(vrGamepad: any);
  44271. /**
  44272. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44273. * @param scene scene in which to add meshes
  44274. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44275. */
  44276. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44277. /**
  44278. * Fired when the left button on this controller is modified
  44279. */
  44280. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44281. /**
  44282. * Fired when the right button on this controller is modified
  44283. */
  44284. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44285. /**
  44286. * Fired when the menu button on this controller is modified
  44287. */
  44288. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44289. /**
  44290. * Called once for each button that changed state since the last frame
  44291. * Vive mapping:
  44292. * 0: touchpad
  44293. * 1: trigger
  44294. * 2: left AND right buttons
  44295. * 3: menu button
  44296. * @param buttonIdx Which button index changed
  44297. * @param state New state of the button
  44298. * @param changes Which properties on the state changed since last frame
  44299. */
  44300. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44301. }
  44302. }
  44303. declare module BABYLON {
  44304. /**
  44305. * Defines the WebVRController object that represents controllers tracked in 3D space
  44306. */
  44307. abstract class WebVRController extends PoseEnabledController {
  44308. /**
  44309. * Internal, the default controller model for the controller
  44310. */
  44311. protected _defaultModel: AbstractMesh;
  44312. /**
  44313. * Fired when the trigger state has changed
  44314. */
  44315. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44316. /**
  44317. * Fired when the main button state has changed
  44318. */
  44319. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44320. /**
  44321. * Fired when the secondary button state has changed
  44322. */
  44323. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44324. /**
  44325. * Fired when the pad state has changed
  44326. */
  44327. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  44328. /**
  44329. * Fired when controllers stick values have changed
  44330. */
  44331. onPadValuesChangedObservable: Observable<StickValues>;
  44332. /**
  44333. * Array of button availible on the controller
  44334. */
  44335. protected _buttons: Array<MutableGamepadButton>;
  44336. private _onButtonStateChange;
  44337. /**
  44338. * Fired when a controller button's state has changed
  44339. * @param callback the callback containing the button that was modified
  44340. */
  44341. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  44342. /**
  44343. * X and Y axis corrisponding to the controllers joystick
  44344. */
  44345. pad: StickValues;
  44346. /**
  44347. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  44348. */
  44349. hand: string;
  44350. /**
  44351. * The default controller model for the controller
  44352. */
  44353. readonly defaultModel: AbstractMesh;
  44354. /**
  44355. * Creates a new WebVRController from a gamepad
  44356. * @param vrGamepad the gamepad that the WebVRController should be created from
  44357. */
  44358. constructor(vrGamepad: any);
  44359. /**
  44360. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  44361. */
  44362. update(): void;
  44363. /**
  44364. * Function to be called when a button is modified
  44365. */
  44366. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44367. /**
  44368. * Loads a mesh and attaches it to the controller
  44369. * @param scene the scene the mesh should be added to
  44370. * @param meshLoaded callback for when the mesh has been loaded
  44371. */
  44372. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44373. private _setButtonValue;
  44374. private _changes;
  44375. private _checkChanges;
  44376. /**
  44377. * Disposes of th webVRCOntroller
  44378. */
  44379. dispose(): void;
  44380. }
  44381. }
  44382. declare module BABYLON {
  44383. /**
  44384. * Defines the WindowsMotionController object that the state of the windows motion controller
  44385. */
  44386. class WindowsMotionController extends WebVRController {
  44387. /**
  44388. * The base url used to load the left and right controller models
  44389. */
  44390. static MODEL_BASE_URL: string;
  44391. /**
  44392. * The name of the left controller model file
  44393. */
  44394. static MODEL_LEFT_FILENAME: string;
  44395. /**
  44396. * The name of the right controller model file
  44397. */
  44398. static MODEL_RIGHT_FILENAME: string;
  44399. /**
  44400. * The controller name prefix for this controller type
  44401. */
  44402. static readonly GAMEPAD_ID_PREFIX: string;
  44403. /**
  44404. * The controller id pattern for this controller type
  44405. */
  44406. private static readonly GAMEPAD_ID_PATTERN;
  44407. private _loadedMeshInfo;
  44408. private readonly _mapping;
  44409. /**
  44410. * Fired when the trackpad on this controller is clicked
  44411. */
  44412. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44413. /**
  44414. * Fired when the trackpad on this controller is modified
  44415. */
  44416. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44417. /**
  44418. * The current x and y values of this controller's trackpad
  44419. */
  44420. trackpad: StickValues;
  44421. /**
  44422. * Creates a new WindowsMotionController from a gamepad
  44423. * @param vrGamepad the gamepad that the controller should be created from
  44424. */
  44425. constructor(vrGamepad: any);
  44426. /**
  44427. * Fired when the trigger on this controller is modified
  44428. */
  44429. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44430. /**
  44431. * Fired when the menu button on this controller is modified
  44432. */
  44433. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44434. /**
  44435. * Fired when the grip button on this controller is modified
  44436. */
  44437. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44438. /**
  44439. * Fired when the thumbstick button on this controller is modified
  44440. */
  44441. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44442. /**
  44443. * Fired when the touchpad button on this controller is modified
  44444. */
  44445. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44446. /**
  44447. * Fired when the touchpad values on this controller are modified
  44448. */
  44449. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44450. private _updateTrackpad;
  44451. /**
  44452. * Called once per frame by the engine.
  44453. */
  44454. update(): void;
  44455. /**
  44456. * Called once for each button that changed state since the last frame
  44457. * @param buttonIdx Which button index changed
  44458. * @param state New state of the button
  44459. * @param changes Which properties on the state changed since last frame
  44460. */
  44461. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44462. /**
  44463. * Moves the buttons on the controller mesh based on their current state
  44464. * @param buttonName the name of the button to move
  44465. * @param buttonValue the value of the button which determines the buttons new position
  44466. */
  44467. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44468. /**
  44469. * Moves the axis on the controller mesh based on its current state
  44470. * @param axis the index of the axis
  44471. * @param axisValue the value of the axis which determines the meshes new position
  44472. * @hidden
  44473. */
  44474. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44475. /**
  44476. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44477. * @param scene scene in which to add meshes
  44478. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44479. */
  44480. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44481. /**
  44482. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44483. * can be transformed by button presses and axes values, based on this._mapping.
  44484. *
  44485. * @param scene scene in which the meshes exist
  44486. * @param meshes list of meshes that make up the controller model to process
  44487. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44488. */
  44489. private processModel;
  44490. private createMeshInfo;
  44491. /**
  44492. * Gets the ray of the controller in the direction the controller is pointing
  44493. * @param length the length the resulting ray should be
  44494. * @returns a ray in the direction the controller is pointing
  44495. */
  44496. getForwardRay(length?: number): Ray;
  44497. /**
  44498. * Disposes of the controller
  44499. */
  44500. dispose(): void;
  44501. }
  44502. }
  44503. declare module BABYLON {
  44504. /**
  44505. * Interface to implement to create a shadow generator compatible with BJS.
  44506. */
  44507. interface IShadowGenerator {
  44508. /**
  44509. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44510. * @returns The render target texture if present otherwise, null
  44511. */
  44512. getShadowMap(): Nullable<RenderTargetTexture>;
  44513. /**
  44514. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44515. * @returns The render target texture if the shadow map is present otherwise, null
  44516. */
  44517. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44518. /**
  44519. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44520. * @param subMesh The submesh we want to render in the shadow map
  44521. * @param useInstances Defines wether will draw in the map using instances
  44522. * @returns true if ready otherwise, false
  44523. */
  44524. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44525. /**
  44526. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44527. * @param defines Defines of the material we want to update
  44528. * @param lightIndex Index of the light in the enabled light list of the material
  44529. */
  44530. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  44531. /**
  44532. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44533. * defined in the generator but impacting the effect).
  44534. * It implies the unifroms available on the materials are the standard BJS ones.
  44535. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44536. * @param effect The effect we are binfing the information for
  44537. */
  44538. bindShadowLight(lightIndex: string, effect: Effect): void;
  44539. /**
  44540. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44541. * (eq to shadow prjection matrix * light transform matrix)
  44542. * @returns The transform matrix used to create the shadow map
  44543. */
  44544. getTransformMatrix(): Matrix;
  44545. /**
  44546. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44547. * Cube and 2D textures for instance.
  44548. */
  44549. recreateShadowMap(): void;
  44550. /**
  44551. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44552. * @param onCompiled Callback triggered at the and of the effects compilation
  44553. * @param options Sets of optional options forcing the compilation with different modes
  44554. */
  44555. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44556. useInstances: boolean;
  44557. }>): void;
  44558. /**
  44559. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44560. * @param options Sets of optional options forcing the compilation with different modes
  44561. * @returns A promise that resolves when the compilation completes
  44562. */
  44563. forceCompilationAsync(options?: Partial<{
  44564. useInstances: boolean;
  44565. }>): Promise<void>;
  44566. /**
  44567. * Serializes the shadow generator setup to a json object.
  44568. * @returns The serialized JSON object
  44569. */
  44570. serialize(): any;
  44571. /**
  44572. * Disposes the Shadow map and related Textures and effects.
  44573. */
  44574. dispose(): void;
  44575. }
  44576. /**
  44577. * Default implementation IShadowGenerator.
  44578. * This is the main object responsible of generating shadows in the framework.
  44579. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44580. */
  44581. class ShadowGenerator implements IShadowGenerator {
  44582. /**
  44583. * Shadow generator mode None: no filtering applied.
  44584. */
  44585. static readonly FILTER_NONE: number;
  44586. /**
  44587. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44588. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44589. */
  44590. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  44591. /**
  44592. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44593. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44594. */
  44595. static readonly FILTER_POISSONSAMPLING: number;
  44596. /**
  44597. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44598. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44599. */
  44600. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  44601. /**
  44602. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44603. * edge artifacts on steep falloff.
  44604. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44605. */
  44606. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  44607. /**
  44608. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44609. * edge artifacts on steep falloff.
  44610. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44611. */
  44612. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  44613. /**
  44614. * Shadow generator mode PCF: Percentage Closer Filtering
  44615. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44616. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44617. */
  44618. static readonly FILTER_PCF: number;
  44619. /**
  44620. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44621. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44622. * Contact Hardening
  44623. */
  44624. static readonly FILTER_PCSS: number;
  44625. /**
  44626. * Reserved for PCF and PCSS
  44627. * Highest Quality.
  44628. *
  44629. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44630. *
  44631. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44632. */
  44633. static readonly QUALITY_HIGH: number;
  44634. /**
  44635. * Reserved for PCF and PCSS
  44636. * Good tradeoff for quality/perf cross devices
  44637. *
  44638. * Execute PCF on a 3*3 kernel.
  44639. *
  44640. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44641. */
  44642. static readonly QUALITY_MEDIUM: number;
  44643. /**
  44644. * Reserved for PCF and PCSS
  44645. * The lowest quality but the fastest.
  44646. *
  44647. * Execute PCF on a 1*1 kernel.
  44648. *
  44649. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44650. */
  44651. static readonly QUALITY_LOW: number;
  44652. private _bias;
  44653. /**
  44654. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44655. */
  44656. /**
  44657. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44658. */
  44659. bias: number;
  44660. private _normalBias;
  44661. /**
  44662. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44663. */
  44664. /**
  44665. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44666. */
  44667. normalBias: number;
  44668. private _blurBoxOffset;
  44669. /**
  44670. * Gets the blur box offset: offset applied during the blur pass.
  44671. * Only useful if useKernelBlur = false
  44672. */
  44673. /**
  44674. * Sets the blur box offset: offset applied during the blur pass.
  44675. * Only useful if useKernelBlur = false
  44676. */
  44677. blurBoxOffset: number;
  44678. private _blurScale;
  44679. /**
  44680. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44681. * 2 means half of the size.
  44682. */
  44683. /**
  44684. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44685. * 2 means half of the size.
  44686. */
  44687. blurScale: number;
  44688. private _blurKernel;
  44689. /**
  44690. * Gets the blur kernel: kernel size of the blur pass.
  44691. * Only useful if useKernelBlur = true
  44692. */
  44693. /**
  44694. * Sets the blur kernel: kernel size of the blur pass.
  44695. * Only useful if useKernelBlur = true
  44696. */
  44697. blurKernel: number;
  44698. private _useKernelBlur;
  44699. /**
  44700. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44701. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44702. */
  44703. /**
  44704. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44705. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44706. */
  44707. useKernelBlur: boolean;
  44708. private _depthScale;
  44709. /**
  44710. * Gets the depth scale used in ESM mode.
  44711. */
  44712. /**
  44713. * Sets the depth scale used in ESM mode.
  44714. * This can override the scale stored on the light.
  44715. */
  44716. depthScale: number;
  44717. private _filter;
  44718. /**
  44719. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44720. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44721. */
  44722. /**
  44723. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44724. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44725. */
  44726. filter: number;
  44727. /**
  44728. * Gets if the current filter is set to Poisson Sampling.
  44729. */
  44730. /**
  44731. * Sets the current filter to Poisson Sampling.
  44732. */
  44733. usePoissonSampling: boolean;
  44734. /**
  44735. * Gets if the current filter is set to ESM.
  44736. */
  44737. /**
  44738. * Sets the current filter is to ESM.
  44739. */
  44740. useExponentialShadowMap: boolean;
  44741. /**
  44742. * Gets if the current filter is set to filtered ESM.
  44743. */
  44744. /**
  44745. * Gets if the current filter is set to filtered ESM.
  44746. */
  44747. useBlurExponentialShadowMap: boolean;
  44748. /**
  44749. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44750. * exponential to prevent steep falloff artifacts).
  44751. */
  44752. /**
  44753. * Sets the current filter to "close ESM" (using the inverse of the
  44754. * exponential to prevent steep falloff artifacts).
  44755. */
  44756. useCloseExponentialShadowMap: boolean;
  44757. /**
  44758. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44759. * exponential to prevent steep falloff artifacts).
  44760. */
  44761. /**
  44762. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44763. * exponential to prevent steep falloff artifacts).
  44764. */
  44765. useBlurCloseExponentialShadowMap: boolean;
  44766. /**
  44767. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44768. */
  44769. /**
  44770. * Sets the current filter to "PCF" (percentage closer filtering).
  44771. */
  44772. usePercentageCloserFiltering: boolean;
  44773. private _filteringQuality;
  44774. /**
  44775. * Gets the PCF or PCSS Quality.
  44776. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44777. */
  44778. /**
  44779. * Sets the PCF or PCSS Quality.
  44780. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44781. */
  44782. filteringQuality: number;
  44783. /**
  44784. * Gets if the current filter is set to "PCSS" (contact hardening).
  44785. */
  44786. /**
  44787. * Sets the current filter to "PCSS" (contact hardening).
  44788. */
  44789. useContactHardeningShadow: boolean;
  44790. private _contactHardeningLightSizeUVRatio;
  44791. /**
  44792. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44793. * Using a ratio helps keeping shape stability independently of the map size.
  44794. *
  44795. * It does not account for the light projection as it was having too much
  44796. * instability during the light setup or during light position changes.
  44797. *
  44798. * Only valid if useContactHardeningShadow is true.
  44799. */
  44800. /**
  44801. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44802. * Using a ratio helps keeping shape stability independently of the map size.
  44803. *
  44804. * It does not account for the light projection as it was having too much
  44805. * instability during the light setup or during light position changes.
  44806. *
  44807. * Only valid if useContactHardeningShadow is true.
  44808. */
  44809. contactHardeningLightSizeUVRatio: number;
  44810. private _darkness;
  44811. /**
  44812. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44813. * 0 means strongest and 1 would means no shadow.
  44814. * @returns the darkness.
  44815. */
  44816. getDarkness(): number;
  44817. /**
  44818. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44819. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44820. * @returns the shadow generator allowing fluent coding.
  44821. */
  44822. setDarkness(darkness: number): ShadowGenerator;
  44823. private _transparencyShadow;
  44824. /**
  44825. * Sets the ability to have transparent shadow (boolean).
  44826. * @param transparent True if transparent else False
  44827. * @returns the shadow generator allowing fluent coding
  44828. */
  44829. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44830. private _shadowMap;
  44831. private _shadowMap2;
  44832. /**
  44833. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44834. * @returns The render target texture if present otherwise, null
  44835. */
  44836. getShadowMap(): Nullable<RenderTargetTexture>;
  44837. /**
  44838. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44839. * @returns The render target texture if the shadow map is present otherwise, null
  44840. */
  44841. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44842. /**
  44843. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44844. * @param mesh Mesh to add
  44845. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44846. * @returns the Shadow Generator itself
  44847. */
  44848. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44849. /**
  44850. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44851. * @param mesh Mesh to remove
  44852. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44853. * @returns the Shadow Generator itself
  44854. */
  44855. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44856. /**
  44857. * Controls the extent to which the shadows fade out at the edge of the frustum
  44858. * Used only by directionals and spots
  44859. */
  44860. frustumEdgeFalloff: number;
  44861. private _light;
  44862. /**
  44863. * Returns the associated light object.
  44864. * @returns the light generating the shadow
  44865. */
  44866. getLight(): IShadowLight;
  44867. /**
  44868. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44869. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44870. * It might on the other hand introduce peter panning.
  44871. */
  44872. forceBackFacesOnly: boolean;
  44873. private _scene;
  44874. private _lightDirection;
  44875. private _effect;
  44876. private _viewMatrix;
  44877. private _projectionMatrix;
  44878. private _transformMatrix;
  44879. private _cachedPosition;
  44880. private _cachedDirection;
  44881. private _cachedDefines;
  44882. private _currentRenderID;
  44883. private _boxBlurPostprocess;
  44884. private _kernelBlurXPostprocess;
  44885. private _kernelBlurYPostprocess;
  44886. private _blurPostProcesses;
  44887. private _mapSize;
  44888. private _currentFaceIndex;
  44889. private _currentFaceIndexCache;
  44890. private _textureType;
  44891. private _defaultTextureMatrix;
  44892. /**
  44893. * Creates a ShadowGenerator object.
  44894. * A ShadowGenerator is the required tool to use the shadows.
  44895. * Each light casting shadows needs to use its own ShadowGenerator.
  44896. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44897. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44898. * @param light The light object generating the shadows.
  44899. * @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.
  44900. */
  44901. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  44902. private _initializeGenerator;
  44903. private _initializeShadowMap;
  44904. private _initializeBlurRTTAndPostProcesses;
  44905. private _renderForShadowMap;
  44906. private _renderSubMeshForShadowMap;
  44907. private _applyFilterValues;
  44908. /**
  44909. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44910. * @param onCompiled Callback triggered at the and of the effects compilation
  44911. * @param options Sets of optional options forcing the compilation with different modes
  44912. */
  44913. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44914. useInstances: boolean;
  44915. }>): void;
  44916. /**
  44917. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44918. * @param options Sets of optional options forcing the compilation with different modes
  44919. * @returns A promise that resolves when the compilation completes
  44920. */
  44921. forceCompilationAsync(options?: Partial<{
  44922. useInstances: boolean;
  44923. }>): Promise<void>;
  44924. /**
  44925. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44926. * @param subMesh The submesh we want to render in the shadow map
  44927. * @param useInstances Defines wether will draw in the map using instances
  44928. * @returns true if ready otherwise, false
  44929. */
  44930. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44931. /**
  44932. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44933. * @param defines Defines of the material we want to update
  44934. * @param lightIndex Index of the light in the enabled light list of the material
  44935. */
  44936. prepareDefines(defines: any, lightIndex: number): void;
  44937. /**
  44938. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44939. * defined in the generator but impacting the effect).
  44940. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44941. * @param effect The effect we are binfing the information for
  44942. */
  44943. bindShadowLight(lightIndex: string, effect: Effect): void;
  44944. /**
  44945. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44946. * (eq to shadow prjection matrix * light transform matrix)
  44947. * @returns The transform matrix used to create the shadow map
  44948. */
  44949. getTransformMatrix(): Matrix;
  44950. /**
  44951. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44952. * Cube and 2D textures for instance.
  44953. */
  44954. recreateShadowMap(): void;
  44955. private _disposeBlurPostProcesses;
  44956. private _disposeRTTandPostProcesses;
  44957. /**
  44958. * Disposes the ShadowGenerator.
  44959. * Returns nothing.
  44960. */
  44961. dispose(): void;
  44962. /**
  44963. * Serializes the shadow generator setup to a json object.
  44964. * @returns The serialized JSON object
  44965. */
  44966. serialize(): any;
  44967. /**
  44968. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44969. * @param parsedShadowGenerator The JSON object to parse
  44970. * @param scene The scene to create the shadow map for
  44971. * @returns The parsed shadow generator
  44972. */
  44973. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44974. }
  44975. }
  44976. declare module BABYLON {
  44977. /**
  44978. * Defines the shadow generator component responsible to manage any shadow generators
  44979. * in a given scene.
  44980. */
  44981. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44982. /**
  44983. * The component name helpfull to identify the component in the list of scene components.
  44984. */
  44985. readonly name: string;
  44986. /**
  44987. * The scene the component belongs to.
  44988. */
  44989. scene: Scene;
  44990. /**
  44991. * Creates a new instance of the component for the given scene
  44992. * @param scene Defines the scene to register the component in
  44993. */
  44994. constructor(scene: Scene);
  44995. /**
  44996. * Registers the component in a given scene
  44997. */
  44998. register(): void;
  44999. /**
  45000. * Rebuilds the elements related to this component in case of
  45001. * context lost for instance.
  45002. */
  45003. rebuild(): void;
  45004. /**
  45005. * Serializes the component data to the specified json object
  45006. * @param serializationObject The object to serialize to
  45007. */
  45008. serialize(serializationObject: any): void;
  45009. /**
  45010. * Adds all the element from the container to the scene
  45011. * @param container the container holding the elements
  45012. */
  45013. addFromContainer(container: AbstractScene): void;
  45014. /**
  45015. * Removes all the elements in the container from the scene
  45016. * @param container contains the elements to remove
  45017. */
  45018. removeFromContainer(container: AbstractScene): void;
  45019. /**
  45020. * Rebuilds the elements related to this component in case of
  45021. * context lost for instance.
  45022. */
  45023. dispose(): void;
  45024. private _gatherRenderTargets;
  45025. }
  45026. }
  45027. declare module BABYLON {
  45028. }
  45029. declare module BABYLON {
  45030. /**
  45031. * Background material used to create an efficient environement around your scene.
  45032. */
  45033. class BackgroundMaterial extends PushMaterial {
  45034. /**
  45035. * Standard reflectance value at parallel view angle.
  45036. */
  45037. static StandardReflectance0: number;
  45038. /**
  45039. * Standard reflectance value at grazing angle.
  45040. */
  45041. static StandardReflectance90: number;
  45042. protected _primaryColor: Color3;
  45043. /**
  45044. * Key light Color (multiply against the environement texture)
  45045. */
  45046. primaryColor: Color3;
  45047. protected __perceptualColor: Nullable<Color3>;
  45048. /**
  45049. * Experimental Internal Use Only.
  45050. *
  45051. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45052. * This acts as a helper to set the primary color to a more "human friendly" value.
  45053. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45054. * output color as close as possible from the chosen value.
  45055. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45056. * part of lighting setup.)
  45057. */
  45058. _perceptualColor: Nullable<Color3>;
  45059. protected _primaryColorShadowLevel: float;
  45060. /**
  45061. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45062. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45063. */
  45064. primaryColorShadowLevel: float;
  45065. protected _primaryColorHighlightLevel: float;
  45066. /**
  45067. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45068. * The primary color is used at the level chosen to define what the white area would look.
  45069. */
  45070. primaryColorHighlightLevel: float;
  45071. protected _reflectionTexture: Nullable<BaseTexture>;
  45072. /**
  45073. * Reflection Texture used in the material.
  45074. * Should be author in a specific way for the best result (refer to the documentation).
  45075. */
  45076. reflectionTexture: Nullable<BaseTexture>;
  45077. protected _reflectionBlur: float;
  45078. /**
  45079. * Reflection Texture level of blur.
  45080. *
  45081. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45082. * texture twice.
  45083. */
  45084. reflectionBlur: float;
  45085. protected _diffuseTexture: Nullable<BaseTexture>;
  45086. /**
  45087. * Diffuse Texture used in the material.
  45088. * Should be author in a specific way for the best result (refer to the documentation).
  45089. */
  45090. diffuseTexture: Nullable<BaseTexture>;
  45091. protected _shadowLights: Nullable<IShadowLight[]>;
  45092. /**
  45093. * Specify the list of lights casting shadow on the material.
  45094. * All scene shadow lights will be included if null.
  45095. */
  45096. shadowLights: Nullable<IShadowLight[]>;
  45097. protected _shadowLevel: float;
  45098. /**
  45099. * Helps adjusting the shadow to a softer level if required.
  45100. * 0 means black shadows and 1 means no shadows.
  45101. */
  45102. shadowLevel: float;
  45103. protected _sceneCenter: Vector3;
  45104. /**
  45105. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45106. * It is usually zero but might be interesting to modify according to your setup.
  45107. */
  45108. sceneCenter: Vector3;
  45109. protected _opacityFresnel: boolean;
  45110. /**
  45111. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45112. * This helps ensuring a nice transition when the camera goes under the ground.
  45113. */
  45114. opacityFresnel: boolean;
  45115. protected _reflectionFresnel: boolean;
  45116. /**
  45117. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45118. * This helps adding a mirror texture on the ground.
  45119. */
  45120. reflectionFresnel: boolean;
  45121. protected _reflectionFalloffDistance: number;
  45122. /**
  45123. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45124. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45125. */
  45126. reflectionFalloffDistance: number;
  45127. protected _reflectionAmount: number;
  45128. /**
  45129. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45130. */
  45131. reflectionAmount: number;
  45132. protected _reflectionReflectance0: number;
  45133. /**
  45134. * This specifies the weight of the reflection at grazing angle.
  45135. */
  45136. reflectionReflectance0: number;
  45137. protected _reflectionReflectance90: number;
  45138. /**
  45139. * This specifies the weight of the reflection at a perpendicular point of view.
  45140. */
  45141. reflectionReflectance90: number;
  45142. /**
  45143. * Sets the reflection reflectance fresnel values according to the default standard
  45144. * empirically know to work well :-)
  45145. */
  45146. reflectionStandardFresnelWeight: number;
  45147. protected _useRGBColor: boolean;
  45148. /**
  45149. * Helps to directly use the maps channels instead of their level.
  45150. */
  45151. useRGBColor: boolean;
  45152. protected _enableNoise: boolean;
  45153. /**
  45154. * This helps reducing the banding effect that could occur on the background.
  45155. */
  45156. enableNoise: boolean;
  45157. /**
  45158. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45159. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45160. * Recommended to be keep at 1.0 except for special cases.
  45161. */
  45162. fovMultiplier: number;
  45163. private _fovMultiplier;
  45164. /**
  45165. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45166. */
  45167. useEquirectangularFOV: boolean;
  45168. private _maxSimultaneousLights;
  45169. /**
  45170. * Number of Simultaneous lights allowed on the material.
  45171. */
  45172. maxSimultaneousLights: int;
  45173. /**
  45174. * Default configuration related to image processing available in the Background Material.
  45175. */
  45176. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45177. /**
  45178. * Keep track of the image processing observer to allow dispose and replace.
  45179. */
  45180. private _imageProcessingObserver;
  45181. /**
  45182. * Attaches a new image processing configuration to the PBR Material.
  45183. * @param configuration (if null the scene configuration will be use)
  45184. */
  45185. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45186. /**
  45187. * Gets the image processing configuration used either in this material.
  45188. */
  45189. /**
  45190. * Sets the Default image processing configuration used either in the this material.
  45191. *
  45192. * If sets to null, the scene one is in use.
  45193. */
  45194. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45195. /**
  45196. * Gets wether the color curves effect is enabled.
  45197. */
  45198. /**
  45199. * Sets wether the color curves effect is enabled.
  45200. */
  45201. cameraColorCurvesEnabled: boolean;
  45202. /**
  45203. * Gets wether the color grading effect is enabled.
  45204. */
  45205. /**
  45206. * Gets wether the color grading effect is enabled.
  45207. */
  45208. cameraColorGradingEnabled: boolean;
  45209. /**
  45210. * Gets wether tonemapping is enabled or not.
  45211. */
  45212. /**
  45213. * Sets wether tonemapping is enabled or not
  45214. */
  45215. cameraToneMappingEnabled: boolean;
  45216. /**
  45217. * The camera exposure used on this material.
  45218. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45219. * This corresponds to a photographic exposure.
  45220. */
  45221. /**
  45222. * The camera exposure used on this material.
  45223. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45224. * This corresponds to a photographic exposure.
  45225. */
  45226. cameraExposure: float;
  45227. /**
  45228. * Gets The camera contrast used on this material.
  45229. */
  45230. /**
  45231. * Sets The camera contrast used on this material.
  45232. */
  45233. cameraContrast: float;
  45234. /**
  45235. * Gets the Color Grading 2D Lookup Texture.
  45236. */
  45237. /**
  45238. * Sets the Color Grading 2D Lookup Texture.
  45239. */
  45240. cameraColorGradingTexture: Nullable<BaseTexture>;
  45241. /**
  45242. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45243. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45244. * 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;
  45245. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45246. */
  45247. /**
  45248. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45249. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45250. * 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;
  45251. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45252. */
  45253. cameraColorCurves: Nullable<ColorCurves>;
  45254. /**
  45255. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45256. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45257. */
  45258. switchToBGR: boolean;
  45259. private _renderTargets;
  45260. private _reflectionControls;
  45261. private _white;
  45262. private _primaryShadowColor;
  45263. private _primaryHighlightColor;
  45264. /**
  45265. * Instantiates a Background Material in the given scene
  45266. * @param name The friendly name of the material
  45267. * @param scene The scene to add the material to
  45268. */
  45269. constructor(name: string, scene: Scene);
  45270. /**
  45271. * Gets a boolean indicating that current material needs to register RTT
  45272. */
  45273. readonly hasRenderTargetTextures: boolean;
  45274. /**
  45275. * The entire material has been created in order to prevent overdraw.
  45276. * @returns false
  45277. */
  45278. needAlphaTesting(): boolean;
  45279. /**
  45280. * The entire material has been created in order to prevent overdraw.
  45281. * @returns true if blending is enable
  45282. */
  45283. needAlphaBlending(): boolean;
  45284. /**
  45285. * Checks wether the material is ready to be rendered for a given mesh.
  45286. * @param mesh The mesh to render
  45287. * @param subMesh The submesh to check against
  45288. * @param useInstances Specify wether or not the material is used with instances
  45289. * @returns true if all the dependencies are ready (Textures, Effects...)
  45290. */
  45291. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45292. /**
  45293. * Compute the primary color according to the chosen perceptual color.
  45294. */
  45295. private _computePrimaryColorFromPerceptualColor;
  45296. /**
  45297. * Compute the highlights and shadow colors according to their chosen levels.
  45298. */
  45299. private _computePrimaryColors;
  45300. /**
  45301. * Build the uniform buffer used in the material.
  45302. */
  45303. buildUniformLayout(): void;
  45304. /**
  45305. * Unbind the material.
  45306. */
  45307. unbind(): void;
  45308. /**
  45309. * Bind only the world matrix to the material.
  45310. * @param world The world matrix to bind.
  45311. */
  45312. bindOnlyWorldMatrix(world: Matrix): void;
  45313. /**
  45314. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45315. * @param world The world matrix to bind.
  45316. * @param subMesh The submesh to bind for.
  45317. */
  45318. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45319. /**
  45320. * Dispose the material.
  45321. * @param forceDisposeEffect Force disposal of the associated effect.
  45322. * @param forceDisposeTextures Force disposal of the associated textures.
  45323. */
  45324. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45325. /**
  45326. * Clones the material.
  45327. * @param name The cloned name.
  45328. * @returns The cloned material.
  45329. */
  45330. clone(name: string): BackgroundMaterial;
  45331. /**
  45332. * Serializes the current material to its JSON representation.
  45333. * @returns The JSON representation.
  45334. */
  45335. serialize(): any;
  45336. /**
  45337. * Gets the class name of the material
  45338. * @returns "BackgroundMaterial"
  45339. */
  45340. getClassName(): string;
  45341. /**
  45342. * Parse a JSON input to create back a background material.
  45343. * @param source The JSON data to parse
  45344. * @param scene The scene to create the parsed material in
  45345. * @param rootUrl The root url of the assets the material depends upon
  45346. * @returns the instantiated BackgroundMaterial.
  45347. */
  45348. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45349. }
  45350. }
  45351. declare module BABYLON {
  45352. /**
  45353. * The Physically based material base class of BJS.
  45354. *
  45355. * This offers the main features of a standard PBR material.
  45356. * For more information, please refer to the documentation :
  45357. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45358. */
  45359. abstract class PBRBaseMaterial extends PushMaterial {
  45360. /**
  45361. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45362. */
  45363. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45364. /**
  45365. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45366. * to enhance interoperability with other engines.
  45367. */
  45368. static readonly LIGHTFALLOFF_GLTF: number;
  45369. /**
  45370. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45371. * to enhance interoperability with other materials.
  45372. */
  45373. static readonly LIGHTFALLOFF_STANDARD: number;
  45374. /**
  45375. * Intensity of the direct lights e.g. the four lights available in your scene.
  45376. * This impacts both the direct diffuse and specular highlights.
  45377. */
  45378. protected _directIntensity: number;
  45379. /**
  45380. * Intensity of the emissive part of the material.
  45381. * This helps controlling the emissive effect without modifying the emissive color.
  45382. */
  45383. protected _emissiveIntensity: number;
  45384. /**
  45385. * Intensity of the environment e.g. how much the environment will light the object
  45386. * either through harmonics for rough material or through the refelction for shiny ones.
  45387. */
  45388. protected _environmentIntensity: number;
  45389. /**
  45390. * This is a special control allowing the reduction of the specular highlights coming from the
  45391. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45392. */
  45393. protected _specularIntensity: number;
  45394. /**
  45395. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45396. */
  45397. private _lightingInfos;
  45398. /**
  45399. * Debug Control allowing disabling the bump map on this material.
  45400. */
  45401. protected _disableBumpMap: boolean;
  45402. /**
  45403. * AKA Diffuse Texture in standard nomenclature.
  45404. */
  45405. protected _albedoTexture: BaseTexture;
  45406. /**
  45407. * AKA Occlusion Texture in other nomenclature.
  45408. */
  45409. protected _ambientTexture: BaseTexture;
  45410. /**
  45411. * AKA Occlusion Texture Intensity in other nomenclature.
  45412. */
  45413. protected _ambientTextureStrength: number;
  45414. /**
  45415. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45416. * 1 means it completely occludes it
  45417. * 0 mean it has no impact
  45418. */
  45419. protected _ambientTextureImpactOnAnalyticalLights: number;
  45420. /**
  45421. * Stores the alpha values in a texture.
  45422. */
  45423. protected _opacityTexture: BaseTexture;
  45424. /**
  45425. * Stores the reflection values in a texture.
  45426. */
  45427. protected _reflectionTexture: BaseTexture;
  45428. /**
  45429. * Stores the refraction values in a texture.
  45430. */
  45431. protected _refractionTexture: BaseTexture;
  45432. /**
  45433. * Stores the emissive values in a texture.
  45434. */
  45435. protected _emissiveTexture: BaseTexture;
  45436. /**
  45437. * AKA Specular texture in other nomenclature.
  45438. */
  45439. protected _reflectivityTexture: BaseTexture;
  45440. /**
  45441. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45442. */
  45443. protected _metallicTexture: BaseTexture;
  45444. /**
  45445. * Specifies the metallic scalar of the metallic/roughness workflow.
  45446. * Can also be used to scale the metalness values of the metallic texture.
  45447. */
  45448. protected _metallic: Nullable<number>;
  45449. /**
  45450. * Specifies the roughness scalar of the metallic/roughness workflow.
  45451. * Can also be used to scale the roughness values of the metallic texture.
  45452. */
  45453. protected _roughness: Nullable<number>;
  45454. /**
  45455. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45456. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45457. */
  45458. protected _microSurfaceTexture: BaseTexture;
  45459. /**
  45460. * Stores surface normal data used to displace a mesh in a texture.
  45461. */
  45462. protected _bumpTexture: BaseTexture;
  45463. /**
  45464. * Stores the pre-calculated light information of a mesh in a texture.
  45465. */
  45466. protected _lightmapTexture: BaseTexture;
  45467. /**
  45468. * The color of a material in ambient lighting.
  45469. */
  45470. protected _ambientColor: Color3;
  45471. /**
  45472. * AKA Diffuse Color in other nomenclature.
  45473. */
  45474. protected _albedoColor: Color3;
  45475. /**
  45476. * AKA Specular Color in other nomenclature.
  45477. */
  45478. protected _reflectivityColor: Color3;
  45479. /**
  45480. * The color applied when light is reflected from a material.
  45481. */
  45482. protected _reflectionColor: Color3;
  45483. /**
  45484. * The color applied when light is emitted from a material.
  45485. */
  45486. protected _emissiveColor: Color3;
  45487. /**
  45488. * AKA Glossiness in other nomenclature.
  45489. */
  45490. protected _microSurface: number;
  45491. /**
  45492. * source material index of refraction (IOR)' / 'destination material IOR.
  45493. */
  45494. protected _indexOfRefraction: number;
  45495. /**
  45496. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45497. */
  45498. protected _invertRefractionY: boolean;
  45499. /**
  45500. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45501. * Materials half opaque for instance using refraction could benefit from this control.
  45502. */
  45503. protected _linkRefractionWithTransparency: boolean;
  45504. /**
  45505. * Specifies that the material will use the light map as a show map.
  45506. */
  45507. protected _useLightmapAsShadowmap: boolean;
  45508. /**
  45509. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45510. * makes the reflect vector face the model (under horizon).
  45511. */
  45512. protected _useHorizonOcclusion: boolean;
  45513. /**
  45514. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45515. * too much the area relying on ambient texture to define their ambient occlusion.
  45516. */
  45517. protected _useRadianceOcclusion: boolean;
  45518. /**
  45519. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45520. */
  45521. protected _useAlphaFromAlbedoTexture: boolean;
  45522. /**
  45523. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45524. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45525. */
  45526. protected _useSpecularOverAlpha: boolean;
  45527. /**
  45528. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45529. */
  45530. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45531. /**
  45532. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45533. */
  45534. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45535. /**
  45536. * Specifies if the metallic texture contains the roughness information in its green channel.
  45537. */
  45538. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45539. /**
  45540. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45541. */
  45542. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45543. /**
  45544. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45545. */
  45546. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45547. /**
  45548. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45549. */
  45550. protected _useAmbientInGrayScale: boolean;
  45551. /**
  45552. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45553. * The material will try to infer what glossiness each pixel should be.
  45554. */
  45555. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45556. /**
  45557. * Defines the falloff type used in this material.
  45558. * It by default is Physical.
  45559. */
  45560. protected _lightFalloff: number;
  45561. /**
  45562. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45563. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45564. */
  45565. protected _useRadianceOverAlpha: boolean;
  45566. /**
  45567. * Allows using an object space normal map (instead of tangent space).
  45568. */
  45569. protected _useObjectSpaceNormalMap: boolean;
  45570. /**
  45571. * Allows using the bump map in parallax mode.
  45572. */
  45573. protected _useParallax: boolean;
  45574. /**
  45575. * Allows using the bump map in parallax occlusion mode.
  45576. */
  45577. protected _useParallaxOcclusion: boolean;
  45578. /**
  45579. * Controls the scale bias of the parallax mode.
  45580. */
  45581. protected _parallaxScaleBias: number;
  45582. /**
  45583. * If sets to true, disables all the lights affecting the material.
  45584. */
  45585. protected _disableLighting: boolean;
  45586. /**
  45587. * Number of Simultaneous lights allowed on the material.
  45588. */
  45589. protected _maxSimultaneousLights: number;
  45590. /**
  45591. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45592. */
  45593. protected _invertNormalMapX: boolean;
  45594. /**
  45595. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45596. */
  45597. protected _invertNormalMapY: boolean;
  45598. /**
  45599. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45600. */
  45601. protected _twoSidedLighting: boolean;
  45602. /**
  45603. * Defines the alpha limits in alpha test mode.
  45604. */
  45605. protected _alphaCutOff: number;
  45606. /**
  45607. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45608. */
  45609. protected _forceAlphaTest: boolean;
  45610. /**
  45611. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45612. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45613. */
  45614. protected _useAlphaFresnel: boolean;
  45615. /**
  45616. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45617. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45618. */
  45619. protected _useLinearAlphaFresnel: boolean;
  45620. /**
  45621. * The transparency mode of the material.
  45622. */
  45623. protected _transparencyMode: Nullable<number>;
  45624. /**
  45625. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45626. * from cos thetav and roughness:
  45627. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45628. */
  45629. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45630. /**
  45631. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45632. */
  45633. protected _forceIrradianceInFragment: boolean;
  45634. /**
  45635. * Force normal to face away from face.
  45636. */
  45637. protected _forceNormalForward: boolean;
  45638. /**
  45639. * Enables specular anti aliasing in the PBR shader.
  45640. * It will both interacts on the Geometry for analytical and IBL lighting.
  45641. * It also prefilter the roughness map based on the bump values.
  45642. */
  45643. protected _enableSpecularAntiAliasing: boolean;
  45644. /**
  45645. * Default configuration related to image processing available in the PBR Material.
  45646. */
  45647. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45648. /**
  45649. * Keep track of the image processing observer to allow dispose and replace.
  45650. */
  45651. private _imageProcessingObserver;
  45652. /**
  45653. * Attaches a new image processing configuration to the PBR Material.
  45654. * @param configuration
  45655. */
  45656. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45657. /**
  45658. * Stores the available render targets.
  45659. */
  45660. private _renderTargets;
  45661. /**
  45662. * Sets the global ambient color for the material used in lighting calculations.
  45663. */
  45664. private _globalAmbientColor;
  45665. /**
  45666. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45667. */
  45668. private _useLogarithmicDepth;
  45669. /**
  45670. * If set to true, no lighting calculations will be applied.
  45671. */
  45672. private _unlit;
  45673. /**
  45674. * Instantiates a new PBRMaterial instance.
  45675. *
  45676. * @param name The material name
  45677. * @param scene The scene the material will be use in.
  45678. */
  45679. constructor(name: string, scene: Scene);
  45680. /**
  45681. * Gets a boolean indicating that current material needs to register RTT
  45682. */
  45683. readonly hasRenderTargetTextures: boolean;
  45684. /**
  45685. * Gets the name of the material class.
  45686. */
  45687. getClassName(): string;
  45688. /**
  45689. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45690. */
  45691. /**
  45692. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45693. */
  45694. useLogarithmicDepth: boolean;
  45695. /**
  45696. * Gets the current transparency mode.
  45697. */
  45698. /**
  45699. * Sets the transparency mode of the material.
  45700. *
  45701. * | Value | Type | Description |
  45702. * | ----- | ----------------------------------- | ----------- |
  45703. * | 0 | OPAQUE | |
  45704. * | 1 | ALPHATEST | |
  45705. * | 2 | ALPHABLEND | |
  45706. * | 3 | ALPHATESTANDBLEND | |
  45707. *
  45708. */
  45709. transparencyMode: Nullable<number>;
  45710. /**
  45711. * Returns true if alpha blending should be disabled.
  45712. */
  45713. private readonly _disableAlphaBlending;
  45714. /**
  45715. * Specifies whether or not this material should be rendered in alpha blend mode.
  45716. */
  45717. needAlphaBlending(): boolean;
  45718. /**
  45719. * Specifies if the mesh will require alpha blending.
  45720. * @param mesh - BJS mesh.
  45721. */
  45722. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45723. /**
  45724. * Specifies whether or not this material should be rendered in alpha test mode.
  45725. */
  45726. needAlphaTesting(): boolean;
  45727. /**
  45728. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45729. */
  45730. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45731. /**
  45732. * Gets the texture used for the alpha test.
  45733. */
  45734. getAlphaTestTexture(): BaseTexture;
  45735. /**
  45736. * Stores the reflectivity values based on metallic roughness workflow.
  45737. */
  45738. private static _scaledReflectivity;
  45739. /**
  45740. * Specifies that the submesh is ready to be used.
  45741. * @param mesh - BJS mesh.
  45742. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45743. * @param useInstances - Specifies that instances should be used.
  45744. * @returns - boolean indicating that the submesh is ready or not.
  45745. */
  45746. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45747. /**
  45748. * Specifies if the material uses metallic roughness workflow.
  45749. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45750. */
  45751. isMetallicWorkflow(): boolean;
  45752. private _prepareEffect;
  45753. private _prepareDefines;
  45754. /**
  45755. * Force shader compilation
  45756. */
  45757. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45758. clipPlane: boolean;
  45759. }>): void;
  45760. /**
  45761. * Initializes the uniform buffer layout for the shader.
  45762. */
  45763. buildUniformLayout(): void;
  45764. /**
  45765. * Unbinds the textures.
  45766. */
  45767. unbind(): void;
  45768. /**
  45769. * Binds the submesh data.
  45770. * @param world - The world matrix.
  45771. * @param mesh - The BJS mesh.
  45772. * @param subMesh - A submesh of the BJS mesh.
  45773. */
  45774. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45775. /**
  45776. * Returns the animatable textures.
  45777. * @returns - Array of animatable textures.
  45778. */
  45779. getAnimatables(): IAnimatable[];
  45780. /**
  45781. * Returns the texture used for reflections.
  45782. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45783. */
  45784. private _getReflectionTexture;
  45785. /**
  45786. * Returns the texture used for refraction or null if none is used.
  45787. * @returns - Refection texture if present. If no refraction texture and refraction
  45788. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45789. */
  45790. private _getRefractionTexture;
  45791. /**
  45792. * Disposes the resources of the material.
  45793. * @param forceDisposeEffect - Forces the disposal of effects.
  45794. * @param forceDisposeTextures - Forces the disposal of all textures.
  45795. */
  45796. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45797. }
  45798. }
  45799. declare module BABYLON {
  45800. /**
  45801. * The Physically based simple base material of BJS.
  45802. *
  45803. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45804. * It is used as the base class for both the specGloss and metalRough conventions.
  45805. */
  45806. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45807. /**
  45808. * Number of Simultaneous lights allowed on the material.
  45809. */
  45810. maxSimultaneousLights: number;
  45811. /**
  45812. * If sets to true, disables all the lights affecting the material.
  45813. */
  45814. disableLighting: boolean;
  45815. /**
  45816. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45817. */
  45818. environmentTexture: BaseTexture;
  45819. /**
  45820. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45821. */
  45822. invertNormalMapX: boolean;
  45823. /**
  45824. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45825. */
  45826. invertNormalMapY: boolean;
  45827. /**
  45828. * Normal map used in the model.
  45829. */
  45830. normalTexture: BaseTexture;
  45831. /**
  45832. * Emissivie color used to self-illuminate the model.
  45833. */
  45834. emissiveColor: Color3;
  45835. /**
  45836. * Emissivie texture used to self-illuminate the model.
  45837. */
  45838. emissiveTexture: BaseTexture;
  45839. /**
  45840. * Occlusion Channel Strenght.
  45841. */
  45842. occlusionStrength: number;
  45843. /**
  45844. * Occlusion Texture of the material (adding extra occlusion effects).
  45845. */
  45846. occlusionTexture: BaseTexture;
  45847. /**
  45848. * Defines the alpha limits in alpha test mode.
  45849. */
  45850. alphaCutOff: number;
  45851. /**
  45852. * Gets the current double sided mode.
  45853. */
  45854. /**
  45855. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45856. */
  45857. doubleSided: boolean;
  45858. /**
  45859. * Stores the pre-calculated light information of a mesh in a texture.
  45860. */
  45861. lightmapTexture: BaseTexture;
  45862. /**
  45863. * If true, the light map contains occlusion information instead of lighting info.
  45864. */
  45865. useLightmapAsShadowmap: boolean;
  45866. /**
  45867. * Return the active textures of the material.
  45868. */
  45869. getActiveTextures(): BaseTexture[];
  45870. hasTexture(texture: BaseTexture): boolean;
  45871. /**
  45872. * Instantiates a new PBRMaterial instance.
  45873. *
  45874. * @param name The material name
  45875. * @param scene The scene the material will be use in.
  45876. */
  45877. constructor(name: string, scene: Scene);
  45878. getClassName(): string;
  45879. }
  45880. }
  45881. declare module BABYLON {
  45882. /**
  45883. * The Physically based material of BJS.
  45884. *
  45885. * This offers the main features of a standard PBR material.
  45886. * For more information, please refer to the documentation :
  45887. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45888. */
  45889. class PBRMaterial extends PBRBaseMaterial {
  45890. /**
  45891. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45892. */
  45893. static readonly PBRMATERIAL_OPAQUE: number;
  45894. /**
  45895. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45896. */
  45897. static readonly PBRMATERIAL_ALPHATEST: number;
  45898. /**
  45899. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45900. */
  45901. static readonly PBRMATERIAL_ALPHABLEND: number;
  45902. /**
  45903. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45904. * They are also discarded below the alpha cutoff threshold to improve performances.
  45905. */
  45906. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45907. /**
  45908. * Defines the default value of how much AO map is occluding the analytical lights
  45909. * (point spot...).
  45910. */
  45911. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45912. /**
  45913. * Intensity of the direct lights e.g. the four lights available in your scene.
  45914. * This impacts both the direct diffuse and specular highlights.
  45915. */
  45916. directIntensity: number;
  45917. /**
  45918. * Intensity of the emissive part of the material.
  45919. * This helps controlling the emissive effect without modifying the emissive color.
  45920. */
  45921. emissiveIntensity: number;
  45922. /**
  45923. * Intensity of the environment e.g. how much the environment will light the object
  45924. * either through harmonics for rough material or through the refelction for shiny ones.
  45925. */
  45926. environmentIntensity: number;
  45927. /**
  45928. * This is a special control allowing the reduction of the specular highlights coming from the
  45929. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45930. */
  45931. specularIntensity: number;
  45932. /**
  45933. * Debug Control allowing disabling the bump map on this material.
  45934. */
  45935. disableBumpMap: boolean;
  45936. /**
  45937. * AKA Diffuse Texture in standard nomenclature.
  45938. */
  45939. albedoTexture: BaseTexture;
  45940. /**
  45941. * AKA Occlusion Texture in other nomenclature.
  45942. */
  45943. ambientTexture: BaseTexture;
  45944. /**
  45945. * AKA Occlusion Texture Intensity in other nomenclature.
  45946. */
  45947. ambientTextureStrength: number;
  45948. /**
  45949. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45950. * 1 means it completely occludes it
  45951. * 0 mean it has no impact
  45952. */
  45953. ambientTextureImpactOnAnalyticalLights: number;
  45954. /**
  45955. * Stores the alpha values in a texture.
  45956. */
  45957. opacityTexture: BaseTexture;
  45958. /**
  45959. * Stores the reflection values in a texture.
  45960. */
  45961. reflectionTexture: Nullable<BaseTexture>;
  45962. /**
  45963. * Stores the emissive values in a texture.
  45964. */
  45965. emissiveTexture: BaseTexture;
  45966. /**
  45967. * AKA Specular texture in other nomenclature.
  45968. */
  45969. reflectivityTexture: BaseTexture;
  45970. /**
  45971. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45972. */
  45973. metallicTexture: BaseTexture;
  45974. /**
  45975. * Specifies the metallic scalar of the metallic/roughness workflow.
  45976. * Can also be used to scale the metalness values of the metallic texture.
  45977. */
  45978. metallic: Nullable<number>;
  45979. /**
  45980. * Specifies the roughness scalar of the metallic/roughness workflow.
  45981. * Can also be used to scale the roughness values of the metallic texture.
  45982. */
  45983. roughness: Nullable<number>;
  45984. /**
  45985. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45986. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45987. */
  45988. microSurfaceTexture: BaseTexture;
  45989. /**
  45990. * Stores surface normal data used to displace a mesh in a texture.
  45991. */
  45992. bumpTexture: BaseTexture;
  45993. /**
  45994. * Stores the pre-calculated light information of a mesh in a texture.
  45995. */
  45996. lightmapTexture: BaseTexture;
  45997. /**
  45998. * Stores the refracted light information in a texture.
  45999. */
  46000. refractionTexture: BaseTexture;
  46001. /**
  46002. * The color of a material in ambient lighting.
  46003. */
  46004. ambientColor: Color3;
  46005. /**
  46006. * AKA Diffuse Color in other nomenclature.
  46007. */
  46008. albedoColor: Color3;
  46009. /**
  46010. * AKA Specular Color in other nomenclature.
  46011. */
  46012. reflectivityColor: Color3;
  46013. /**
  46014. * The color reflected from the material.
  46015. */
  46016. reflectionColor: Color3;
  46017. /**
  46018. * The color emitted from the material.
  46019. */
  46020. emissiveColor: Color3;
  46021. /**
  46022. * AKA Glossiness in other nomenclature.
  46023. */
  46024. microSurface: number;
  46025. /**
  46026. * source material index of refraction (IOR)' / 'destination material IOR.
  46027. */
  46028. indexOfRefraction: number;
  46029. /**
  46030. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46031. */
  46032. invertRefractionY: boolean;
  46033. /**
  46034. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46035. * Materials half opaque for instance using refraction could benefit from this control.
  46036. */
  46037. linkRefractionWithTransparency: boolean;
  46038. /**
  46039. * If true, the light map contains occlusion information instead of lighting info.
  46040. */
  46041. useLightmapAsShadowmap: boolean;
  46042. /**
  46043. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46044. */
  46045. useAlphaFromAlbedoTexture: boolean;
  46046. /**
  46047. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46048. */
  46049. forceAlphaTest: boolean;
  46050. /**
  46051. * Defines the alpha limits in alpha test mode.
  46052. */
  46053. alphaCutOff: number;
  46054. /**
  46055. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46056. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46057. */
  46058. useSpecularOverAlpha: boolean;
  46059. /**
  46060. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46061. */
  46062. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46063. /**
  46064. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46065. */
  46066. useRoughnessFromMetallicTextureAlpha: boolean;
  46067. /**
  46068. * Specifies if the metallic texture contains the roughness information in its green channel.
  46069. */
  46070. useRoughnessFromMetallicTextureGreen: boolean;
  46071. /**
  46072. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46073. */
  46074. useMetallnessFromMetallicTextureBlue: boolean;
  46075. /**
  46076. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46077. */
  46078. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46079. /**
  46080. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46081. */
  46082. useAmbientInGrayScale: boolean;
  46083. /**
  46084. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46085. * The material will try to infer what glossiness each pixel should be.
  46086. */
  46087. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46088. /**
  46089. * BJS is using an harcoded light falloff based on a manually sets up range.
  46090. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46091. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46092. */
  46093. /**
  46094. * BJS is using an harcoded light falloff based on a manually sets up range.
  46095. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46096. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46097. */
  46098. usePhysicalLightFalloff: boolean;
  46099. /**
  46100. * In order to support the falloff compatibility with gltf, a special mode has been added
  46101. * to reproduce the gltf light falloff.
  46102. */
  46103. /**
  46104. * In order to support the falloff compatibility with gltf, a special mode has been added
  46105. * to reproduce the gltf light falloff.
  46106. */
  46107. useGLTFLightFalloff: boolean;
  46108. /**
  46109. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46110. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46111. */
  46112. useRadianceOverAlpha: boolean;
  46113. /**
  46114. * Allows using an object space normal map (instead of tangent space).
  46115. */
  46116. useObjectSpaceNormalMap: boolean;
  46117. /**
  46118. * Allows using the bump map in parallax mode.
  46119. */
  46120. useParallax: boolean;
  46121. /**
  46122. * Allows using the bump map in parallax occlusion mode.
  46123. */
  46124. useParallaxOcclusion: boolean;
  46125. /**
  46126. * Controls the scale bias of the parallax mode.
  46127. */
  46128. parallaxScaleBias: number;
  46129. /**
  46130. * If sets to true, disables all the lights affecting the material.
  46131. */
  46132. disableLighting: boolean;
  46133. /**
  46134. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46135. */
  46136. forceIrradianceInFragment: boolean;
  46137. /**
  46138. * Number of Simultaneous lights allowed on the material.
  46139. */
  46140. maxSimultaneousLights: number;
  46141. /**
  46142. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46143. */
  46144. invertNormalMapX: boolean;
  46145. /**
  46146. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46147. */
  46148. invertNormalMapY: boolean;
  46149. /**
  46150. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46151. */
  46152. twoSidedLighting: boolean;
  46153. /**
  46154. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46155. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46156. */
  46157. useAlphaFresnel: boolean;
  46158. /**
  46159. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46160. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46161. */
  46162. useLinearAlphaFresnel: boolean;
  46163. /**
  46164. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46165. * And/Or occlude the blended part.
  46166. */
  46167. environmentBRDFTexture: Nullable<BaseTexture>;
  46168. /**
  46169. * Force normal to face away from face.
  46170. */
  46171. forceNormalForward: boolean;
  46172. /**
  46173. * Enables specular anti aliasing in the PBR shader.
  46174. * It will both interacts on the Geometry for analytical and IBL lighting.
  46175. * It also prefilter the roughness map based on the bump values.
  46176. */
  46177. enableSpecularAntiAliasing: boolean;
  46178. /**
  46179. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46180. * makes the reflect vector face the model (under horizon).
  46181. */
  46182. useHorizonOcclusion: boolean;
  46183. /**
  46184. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46185. * too much the area relying on ambient texture to define their ambient occlusion.
  46186. */
  46187. useRadianceOcclusion: boolean;
  46188. /**
  46189. * If set to true, no lighting calculations will be applied.
  46190. */
  46191. unlit: boolean;
  46192. /**
  46193. * Gets the image processing configuration used either in this material.
  46194. */
  46195. /**
  46196. * Sets the Default image processing configuration used either in the this material.
  46197. *
  46198. * If sets to null, the scene one is in use.
  46199. */
  46200. imageProcessingConfiguration: ImageProcessingConfiguration;
  46201. /**
  46202. * Gets wether the color curves effect is enabled.
  46203. */
  46204. /**
  46205. * Sets wether the color curves effect is enabled.
  46206. */
  46207. cameraColorCurvesEnabled: boolean;
  46208. /**
  46209. * Gets wether the color grading effect is enabled.
  46210. */
  46211. /**
  46212. * Gets wether the color grading effect is enabled.
  46213. */
  46214. cameraColorGradingEnabled: boolean;
  46215. /**
  46216. * Gets wether tonemapping is enabled or not.
  46217. */
  46218. /**
  46219. * Sets wether tonemapping is enabled or not
  46220. */
  46221. cameraToneMappingEnabled: boolean;
  46222. /**
  46223. * The camera exposure used on this material.
  46224. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46225. * This corresponds to a photographic exposure.
  46226. */
  46227. /**
  46228. * The camera exposure used on this material.
  46229. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46230. * This corresponds to a photographic exposure.
  46231. */
  46232. cameraExposure: number;
  46233. /**
  46234. * Gets The camera contrast used on this material.
  46235. */
  46236. /**
  46237. * Sets The camera contrast used on this material.
  46238. */
  46239. cameraContrast: number;
  46240. /**
  46241. * Gets the Color Grading 2D Lookup Texture.
  46242. */
  46243. /**
  46244. * Sets the Color Grading 2D Lookup Texture.
  46245. */
  46246. cameraColorGradingTexture: Nullable<BaseTexture>;
  46247. /**
  46248. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46249. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46250. * 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;
  46251. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46252. */
  46253. /**
  46254. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46255. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46256. * 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;
  46257. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46258. */
  46259. cameraColorCurves: Nullable<ColorCurves>;
  46260. /**
  46261. * Instantiates a new PBRMaterial instance.
  46262. *
  46263. * @param name The material name
  46264. * @param scene The scene the material will be use in.
  46265. */
  46266. constructor(name: string, scene: Scene);
  46267. /**
  46268. * Returns the name of this material class.
  46269. */
  46270. getClassName(): string;
  46271. /**
  46272. * Returns an array of the actively used textures.
  46273. * @returns - Array of BaseTextures
  46274. */
  46275. getActiveTextures(): BaseTexture[];
  46276. /**
  46277. * Checks to see if a texture is used in the material.
  46278. * @param texture - Base texture to use.
  46279. * @returns - Boolean specifying if a texture is used in the material.
  46280. */
  46281. hasTexture(texture: BaseTexture): boolean;
  46282. /**
  46283. * Makes a duplicate of the current material.
  46284. * @param name - name to use for the new material.
  46285. */
  46286. clone(name: string): PBRMaterial;
  46287. /**
  46288. * Serializes this PBR Material.
  46289. * @returns - An object with the serialized material.
  46290. */
  46291. serialize(): any;
  46292. /**
  46293. * Parses a PBR Material from a serialized object.
  46294. * @param source - Serialized object.
  46295. * @param scene - BJS scene instance.
  46296. * @param rootUrl - url for the scene object
  46297. * @returns - PBRMaterial
  46298. */
  46299. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46300. }
  46301. }
  46302. declare module BABYLON {
  46303. /**
  46304. * The PBR material of BJS following the metal roughness convention.
  46305. *
  46306. * This fits to the PBR convention in the GLTF definition:
  46307. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  46308. */
  46309. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  46310. /**
  46311. * The base color has two different interpretations depending on the value of metalness.
  46312. * When the material is a metal, the base color is the specific measured reflectance value
  46313. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  46314. * of the material.
  46315. */
  46316. baseColor: Color3;
  46317. /**
  46318. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  46319. * well as opacity information in the alpha channel.
  46320. */
  46321. baseTexture: BaseTexture;
  46322. /**
  46323. * Specifies the metallic scalar value of the material.
  46324. * Can also be used to scale the metalness values of the metallic texture.
  46325. */
  46326. metallic: number;
  46327. /**
  46328. * Specifies the roughness scalar value of the material.
  46329. * Can also be used to scale the roughness values of the metallic texture.
  46330. */
  46331. roughness: number;
  46332. /**
  46333. * Texture containing both the metallic value in the B channel and the
  46334. * roughness value in the G channel to keep better precision.
  46335. */
  46336. metallicRoughnessTexture: BaseTexture;
  46337. /**
  46338. * Instantiates a new PBRMetalRoughnessMaterial instance.
  46339. *
  46340. * @param name The material name
  46341. * @param scene The scene the material will be use in.
  46342. */
  46343. constructor(name: string, scene: Scene);
  46344. /**
  46345. * Return the currrent class name of the material.
  46346. */
  46347. getClassName(): string;
  46348. /**
  46349. * Return the active textures of the material.
  46350. */
  46351. getActiveTextures(): BaseTexture[];
  46352. /**
  46353. * Checks to see if a texture is used in the material.
  46354. * @param texture - Base texture to use.
  46355. * @returns - Boolean specifying if a texture is used in the material.
  46356. */
  46357. hasTexture(texture: BaseTexture): boolean;
  46358. /**
  46359. * Makes a duplicate of the current material.
  46360. * @param name - name to use for the new material.
  46361. */
  46362. clone(name: string): PBRMetallicRoughnessMaterial;
  46363. /**
  46364. * Serialize the material to a parsable JSON object.
  46365. */
  46366. serialize(): any;
  46367. /**
  46368. * Parses a JSON object correponding to the serialize function.
  46369. */
  46370. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46371. }
  46372. }
  46373. declare module BABYLON {
  46374. /**
  46375. * The PBR material of BJS following the specular glossiness convention.
  46376. *
  46377. * This fits to the PBR convention in the GLTF definition:
  46378. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46379. */
  46380. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46381. /**
  46382. * Specifies the diffuse color of the material.
  46383. */
  46384. diffuseColor: Color3;
  46385. /**
  46386. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46387. * channel.
  46388. */
  46389. diffuseTexture: BaseTexture;
  46390. /**
  46391. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46392. */
  46393. specularColor: Color3;
  46394. /**
  46395. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46396. */
  46397. glossiness: number;
  46398. /**
  46399. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46400. */
  46401. specularGlossinessTexture: BaseTexture;
  46402. /**
  46403. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46404. *
  46405. * @param name The material name
  46406. * @param scene The scene the material will be use in.
  46407. */
  46408. constructor(name: string, scene: Scene);
  46409. /**
  46410. * Return the currrent class name of the material.
  46411. */
  46412. getClassName(): string;
  46413. /**
  46414. * Return the active textures of the material.
  46415. */
  46416. getActiveTextures(): BaseTexture[];
  46417. /**
  46418. * Checks to see if a texture is used in the material.
  46419. * @param texture - Base texture to use.
  46420. * @returns - Boolean specifying if a texture is used in the material.
  46421. */
  46422. hasTexture(texture: BaseTexture): boolean;
  46423. /**
  46424. * Makes a duplicate of the current material.
  46425. * @param name - name to use for the new material.
  46426. */
  46427. clone(name: string): PBRSpecularGlossinessMaterial;
  46428. /**
  46429. * Serialize the material to a parsable JSON object.
  46430. */
  46431. serialize(): any;
  46432. /**
  46433. * Parses a JSON object correponding to the serialize function.
  46434. */
  46435. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46436. }
  46437. }
  46438. declare module BABYLON {
  46439. /**
  46440. * Base class of all the textures in babylon.
  46441. * It groups all the common properties the materials, post process, lights... might need
  46442. * in order to make a correct use of the texture.
  46443. */
  46444. class BaseTexture {
  46445. /**
  46446. * Default anisotropic filtering level for the application.
  46447. * It is set to 4 as a good tradeoff between perf and quality.
  46448. */
  46449. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  46450. /**
  46451. * Gets or sets the unique id of the texture
  46452. */
  46453. uniqueId: number;
  46454. /**
  46455. * Define the name of the texture.
  46456. */
  46457. name: string;
  46458. /**
  46459. * Gets or sets an object used to store user defined information.
  46460. */
  46461. metadata: any;
  46462. /**
  46463. * For internal use only. Please do not use.
  46464. */
  46465. reservedDataStore: any;
  46466. private _hasAlpha;
  46467. /**
  46468. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  46469. */
  46470. hasAlpha: boolean;
  46471. /**
  46472. * Defines if the alpha value should be determined via the rgb values.
  46473. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  46474. */
  46475. getAlphaFromRGB: boolean;
  46476. /**
  46477. * Intensity or strength of the texture.
  46478. * It is commonly used by materials to fine tune the intensity of the texture
  46479. */
  46480. level: number;
  46481. /**
  46482. * Define the UV chanel to use starting from 0 and defaulting to 0.
  46483. * This is part of the texture as textures usually maps to one uv set.
  46484. */
  46485. coordinatesIndex: number;
  46486. private _coordinatesMode;
  46487. /**
  46488. * How a texture is mapped.
  46489. *
  46490. * | Value | Type | Description |
  46491. * | ----- | ----------------------------------- | ----------- |
  46492. * | 0 | EXPLICIT_MODE | |
  46493. * | 1 | SPHERICAL_MODE | |
  46494. * | 2 | PLANAR_MODE | |
  46495. * | 3 | CUBIC_MODE | |
  46496. * | 4 | PROJECTION_MODE | |
  46497. * | 5 | SKYBOX_MODE | |
  46498. * | 6 | INVCUBIC_MODE | |
  46499. * | 7 | EQUIRECTANGULAR_MODE | |
  46500. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  46501. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  46502. */
  46503. coordinatesMode: number;
  46504. /**
  46505. * | Value | Type | Description |
  46506. * | ----- | ------------------ | ----------- |
  46507. * | 0 | CLAMP_ADDRESSMODE | |
  46508. * | 1 | WRAP_ADDRESSMODE | |
  46509. * | 2 | MIRROR_ADDRESSMODE | |
  46510. */
  46511. wrapU: number;
  46512. /**
  46513. * | Value | Type | Description |
  46514. * | ----- | ------------------ | ----------- |
  46515. * | 0 | CLAMP_ADDRESSMODE | |
  46516. * | 1 | WRAP_ADDRESSMODE | |
  46517. * | 2 | MIRROR_ADDRESSMODE | |
  46518. */
  46519. wrapV: number;
  46520. /**
  46521. * | Value | Type | Description |
  46522. * | ----- | ------------------ | ----------- |
  46523. * | 0 | CLAMP_ADDRESSMODE | |
  46524. * | 1 | WRAP_ADDRESSMODE | |
  46525. * | 2 | MIRROR_ADDRESSMODE | |
  46526. */
  46527. wrapR: number;
  46528. /**
  46529. * With compliant hardware and browser (supporting anisotropic filtering)
  46530. * this defines the level of anisotropic filtering in the texture.
  46531. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  46532. */
  46533. anisotropicFilteringLevel: number;
  46534. /**
  46535. * Define if the texture is a cube texture or if false a 2d texture.
  46536. */
  46537. isCube: boolean;
  46538. /**
  46539. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  46540. */
  46541. is3D: boolean;
  46542. /**
  46543. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  46544. * HDR texture are usually stored in linear space.
  46545. * This only impacts the PBR and Background materials
  46546. */
  46547. gammaSpace: boolean;
  46548. /**
  46549. * Gets whether or not the texture contains RGBD data.
  46550. */
  46551. readonly isRGBD: boolean;
  46552. /**
  46553. * Is Z inverted in the texture (useful in a cube texture).
  46554. */
  46555. invertZ: boolean;
  46556. /**
  46557. * Are mip maps generated for this texture or not.
  46558. */
  46559. readonly noMipmap: boolean;
  46560. /**
  46561. * @hidden
  46562. */
  46563. lodLevelInAlpha: boolean;
  46564. /**
  46565. * With prefiltered texture, defined the offset used during the prefiltering steps.
  46566. */
  46567. lodGenerationOffset: number;
  46568. /**
  46569. * With prefiltered texture, defined the scale used during the prefiltering steps.
  46570. */
  46571. lodGenerationScale: number;
  46572. /**
  46573. * Define if the texture is a render target.
  46574. */
  46575. isRenderTarget: boolean;
  46576. /**
  46577. * Define the unique id of the texture in the scene.
  46578. */
  46579. readonly uid: string;
  46580. /**
  46581. * Return a string representation of the texture.
  46582. * @returns the texture as a string
  46583. */
  46584. toString(): string;
  46585. /**
  46586. * Get the class name of the texture.
  46587. * @returns "BaseTexture"
  46588. */
  46589. getClassName(): string;
  46590. /**
  46591. * Define the list of animation attached to the texture.
  46592. */
  46593. animations: Animation[];
  46594. /**
  46595. * An event triggered when the texture is disposed.
  46596. */
  46597. onDisposeObservable: Observable<BaseTexture>;
  46598. private _onDisposeObserver;
  46599. /**
  46600. * Callback triggered when the texture has been disposed.
  46601. * Kept for back compatibility, you can use the onDisposeObservable instead.
  46602. */
  46603. onDispose: () => void;
  46604. /**
  46605. * Define the current state of the loading sequence when in delayed load mode.
  46606. */
  46607. delayLoadState: number;
  46608. private _scene;
  46609. /** @hidden */
  46610. _texture: Nullable<InternalTexture>;
  46611. private _uid;
  46612. /**
  46613. * Define if the texture is preventinga material to render or not.
  46614. * If not and the texture is not ready, the engine will use a default black texture instead.
  46615. */
  46616. readonly isBlocking: boolean;
  46617. /**
  46618. * Instantiates a new BaseTexture.
  46619. * Base class of all the textures in babylon.
  46620. * It groups all the common properties the materials, post process, lights... might need
  46621. * in order to make a correct use of the texture.
  46622. * @param scene Define the scene the texture blongs to
  46623. */
  46624. constructor(scene: Nullable<Scene>);
  46625. /**
  46626. * Get the scene the texture belongs to.
  46627. * @returns the scene or null if undefined
  46628. */
  46629. getScene(): Nullable<Scene>;
  46630. /**
  46631. * Get the texture transform matrix used to offset tile the texture for istance.
  46632. * @returns the transformation matrix
  46633. */
  46634. getTextureMatrix(): Matrix;
  46635. /**
  46636. * Get the texture reflection matrix used to rotate/transform the reflection.
  46637. * @returns the reflection matrix
  46638. */
  46639. getReflectionTextureMatrix(): Matrix;
  46640. /**
  46641. * Get the underlying lower level texture from Babylon.
  46642. * @returns the insternal texture
  46643. */
  46644. getInternalTexture(): Nullable<InternalTexture>;
  46645. /**
  46646. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  46647. * @returns true if ready or not blocking
  46648. */
  46649. isReadyOrNotBlocking(): boolean;
  46650. /**
  46651. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  46652. * @returns true if fully ready
  46653. */
  46654. isReady(): boolean;
  46655. private _cachedSize;
  46656. /**
  46657. * Get the size of the texture.
  46658. * @returns the texture size.
  46659. */
  46660. getSize(): ISize;
  46661. /**
  46662. * Get the base size of the texture.
  46663. * It can be different from the size if the texture has been resized for POT for instance
  46664. * @returns the base size
  46665. */
  46666. getBaseSize(): ISize;
  46667. /**
  46668. * Update the sampling mode of the texture.
  46669. * Default is Trilinear mode.
  46670. *
  46671. * | Value | Type | Description |
  46672. * | ----- | ------------------ | ----------- |
  46673. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  46674. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  46675. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  46676. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  46677. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  46678. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  46679. * | 7 | NEAREST_LINEAR | |
  46680. * | 8 | NEAREST_NEAREST | |
  46681. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  46682. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  46683. * | 11 | LINEAR_LINEAR | |
  46684. * | 12 | LINEAR_NEAREST | |
  46685. *
  46686. * > _mag_: magnification filter (close to the viewer)
  46687. * > _min_: minification filter (far from the viewer)
  46688. * > _mip_: filter used between mip map levels
  46689. *@param samplingMode Define the new sampling mode of the texture
  46690. */
  46691. updateSamplingMode(samplingMode: number): void;
  46692. /**
  46693. * Scales the texture if is `canRescale()`
  46694. * @param ratio the resize factor we want to use to rescale
  46695. */
  46696. scale(ratio: number): void;
  46697. /**
  46698. * Get if the texture can rescale.
  46699. */
  46700. readonly canRescale: boolean;
  46701. /** @hidden */
  46702. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  46703. /** @hidden */
  46704. _rebuild(): void;
  46705. /**
  46706. * Triggers the load sequence in delayed load mode.
  46707. */
  46708. delayLoad(): void;
  46709. /**
  46710. * Clones the texture.
  46711. * @returns the cloned texture
  46712. */
  46713. clone(): Nullable<BaseTexture>;
  46714. /**
  46715. * Get the texture underlying type (INT, FLOAT...)
  46716. */
  46717. readonly textureType: number;
  46718. /**
  46719. * Get the texture underlying format (RGB, RGBA...)
  46720. */
  46721. readonly textureFormat: number;
  46722. /**
  46723. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46724. * This will returns an RGBA array buffer containing either in values (0-255) or
  46725. * float values (0-1) depending of the underlying buffer type.
  46726. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46727. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46728. * @param buffer defines a user defined buffer to fill with data (can be null)
  46729. * @returns The Array buffer containing the pixels data.
  46730. */
  46731. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46732. /**
  46733. * Release and destroy the underlying lower level texture aka internalTexture.
  46734. */
  46735. releaseInternalTexture(): void;
  46736. /**
  46737. * Get the polynomial representation of the texture data.
  46738. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46739. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46740. */
  46741. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46742. /** @hidden */
  46743. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46744. /** @hidden */
  46745. readonly _lodTextureMid: Nullable<BaseTexture>;
  46746. /** @hidden */
  46747. readonly _lodTextureLow: Nullable<BaseTexture>;
  46748. /**
  46749. * Dispose the texture and release its associated resources.
  46750. */
  46751. dispose(): void;
  46752. /**
  46753. * Serialize the texture into a JSON representation that can be parsed later on.
  46754. * @returns the JSON representation of the texture
  46755. */
  46756. serialize(): any;
  46757. /**
  46758. * Helper function to be called back once a list of texture contains only ready textures.
  46759. * @param textures Define the list of textures to wait for
  46760. * @param callback Define the callback triggered once the entire list will be ready
  46761. */
  46762. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46763. }
  46764. }
  46765. declare module BABYLON {
  46766. /**
  46767. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46768. * It can help converting any input color in a desired output one. This can then be used to create effects
  46769. * from sepia, black and white to sixties or futuristic rendering...
  46770. *
  46771. * The only supported format is currently 3dl.
  46772. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46773. */
  46774. class ColorGradingTexture extends BaseTexture {
  46775. /**
  46776. * The current texture matrix. (will always be identity in color grading texture)
  46777. */
  46778. private _textureMatrix;
  46779. /**
  46780. * The texture URL.
  46781. */
  46782. url: string;
  46783. /**
  46784. * Empty line regex stored for GC.
  46785. */
  46786. private static _noneEmptyLineRegex;
  46787. private _engine;
  46788. /**
  46789. * Instantiates a ColorGradingTexture from the following parameters.
  46790. *
  46791. * @param url The location of the color gradind data (currently only supporting 3dl)
  46792. * @param scene The scene the texture will be used in
  46793. */
  46794. constructor(url: string, scene: Scene);
  46795. /**
  46796. * Returns the texture matrix used in most of the material.
  46797. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46798. */
  46799. getTextureMatrix(): Matrix;
  46800. /**
  46801. * Occurs when the file being loaded is a .3dl LUT file.
  46802. */
  46803. private load3dlTexture;
  46804. /**
  46805. * Starts the loading process of the texture.
  46806. */
  46807. private loadTexture;
  46808. /**
  46809. * Clones the color gradind texture.
  46810. */
  46811. clone(): ColorGradingTexture;
  46812. /**
  46813. * Called during delayed load for textures.
  46814. */
  46815. delayLoad(): void;
  46816. /**
  46817. * Parses a color grading texture serialized by Babylon.
  46818. * @param parsedTexture The texture information being parsedTexture
  46819. * @param scene The scene to load the texture in
  46820. * @param rootUrl The root url of the data assets to load
  46821. * @return A color gradind texture
  46822. */
  46823. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46824. /**
  46825. * Serializes the LUT texture to json format.
  46826. */
  46827. serialize(): any;
  46828. }
  46829. }
  46830. declare module BABYLON {
  46831. /**
  46832. * Class for creating a cube texture
  46833. */
  46834. class CubeTexture extends BaseTexture {
  46835. private _delayedOnLoad;
  46836. /**
  46837. * The url of the texture
  46838. */
  46839. url: string;
  46840. /**
  46841. * Gets or sets the center of the bounding box associated with the cube texture.
  46842. * It must define where the camera used to render the texture was set
  46843. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46844. */
  46845. boundingBoxPosition: Vector3;
  46846. private _boundingBoxSize;
  46847. /**
  46848. * Gets or sets the size of the bounding box associated with the cube texture
  46849. * When defined, the cubemap will switch to local mode
  46850. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46851. * @example https://www.babylonjs-playground.com/#RNASML
  46852. */
  46853. /**
  46854. * Returns the bounding box size
  46855. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46856. */
  46857. boundingBoxSize: Vector3;
  46858. protected _rotationY: number;
  46859. /**
  46860. * Sets texture matrix rotation angle around Y axis in radians.
  46861. */
  46862. /**
  46863. * Gets texture matrix rotation angle around Y axis radians.
  46864. */
  46865. rotationY: number;
  46866. /**
  46867. * Are mip maps generated for this texture or not.
  46868. */
  46869. readonly noMipmap: boolean;
  46870. private _noMipmap;
  46871. private _files;
  46872. private _extensions;
  46873. private _textureMatrix;
  46874. private _format;
  46875. private _createPolynomials;
  46876. /** @hidden */
  46877. _prefiltered: boolean;
  46878. /**
  46879. * Creates a cube texture from an array of image urls
  46880. * @param files defines an array of image urls
  46881. * @param scene defines the hosting scene
  46882. * @param noMipmap specifies if mip maps are not used
  46883. * @returns a cube texture
  46884. */
  46885. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46886. /**
  46887. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46888. * @param url defines the url of the prefiltered texture
  46889. * @param scene defines the scene the texture is attached to
  46890. * @param forcedExtension defines the extension of the file if different from the url
  46891. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46892. * @return the prefiltered texture
  46893. */
  46894. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46895. /**
  46896. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46897. * as prefiltered data.
  46898. * @param rootUrl defines the url of the texture or the root name of the six images
  46899. * @param scene defines the scene the texture is attached to
  46900. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46901. * @param noMipmap defines if mipmaps should be created or not
  46902. * @param files defines the six files to load for the different faces
  46903. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46904. * @param onError defines a callback triggered in case of error during load
  46905. * @param format defines the internal format to use for the texture once loaded
  46906. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46907. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46908. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46909. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46910. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46911. * @return the cube texture
  46912. */
  46913. 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);
  46914. /**
  46915. * Get the current class name of the texture useful for serialization or dynamic coding.
  46916. * @returns "CubeTexture"
  46917. */
  46918. getClassName(): string;
  46919. /**
  46920. * Update the url (and optional buffer) of this texture if url was null during construction.
  46921. * @param url the url of the texture
  46922. * @param forcedExtension defines the extension to use
  46923. * @param onLoad callback called when the texture is loaded (defaults to null)
  46924. */
  46925. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  46926. /**
  46927. * Delays loading of the cube texture
  46928. * @param forcedExtension defines the extension to use
  46929. */
  46930. delayLoad(forcedExtension?: string): void;
  46931. /**
  46932. * Returns the reflection texture matrix
  46933. * @returns the reflection texture matrix
  46934. */
  46935. getReflectionTextureMatrix(): Matrix;
  46936. /**
  46937. * Sets the reflection texture matrix
  46938. * @param value Reflection texture matrix
  46939. */
  46940. setReflectionTextureMatrix(value: Matrix): void;
  46941. /**
  46942. * Parses text to create a cube texture
  46943. * @param parsedTexture define the serialized text to read from
  46944. * @param scene defines the hosting scene
  46945. * @param rootUrl defines the root url of the cube texture
  46946. * @returns a cube texture
  46947. */
  46948. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46949. /**
  46950. * Makes a clone, or deep copy, of the cube texture
  46951. * @returns a new cube texture
  46952. */
  46953. clone(): CubeTexture;
  46954. }
  46955. }
  46956. declare module BABYLON {
  46957. /**
  46958. * A class extending Texture allowing drawing on a texture
  46959. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46960. */
  46961. class DynamicTexture extends Texture {
  46962. private _generateMipMaps;
  46963. private _canvas;
  46964. private _context;
  46965. private _engine;
  46966. /**
  46967. * Creates a DynamicTexture
  46968. * @param name defines the name of the texture
  46969. * @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
  46970. * @param scene defines the scene where you want the texture
  46971. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46972. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46973. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46974. */
  46975. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46976. /**
  46977. * Get the current class name of the texture useful for serialization or dynamic coding.
  46978. * @returns "DynamicTexture"
  46979. */
  46980. getClassName(): string;
  46981. /**
  46982. * Gets the current state of canRescale
  46983. */
  46984. readonly canRescale: boolean;
  46985. private _recreate;
  46986. /**
  46987. * Scales the texture
  46988. * @param ratio the scale factor to apply to both width and height
  46989. */
  46990. scale(ratio: number): void;
  46991. /**
  46992. * Resizes the texture
  46993. * @param width the new width
  46994. * @param height the new height
  46995. */
  46996. scaleTo(width: number, height: number): void;
  46997. /**
  46998. * Gets the context of the canvas used by the texture
  46999. * @returns the canvas context of the dynamic texture
  47000. */
  47001. getContext(): CanvasRenderingContext2D;
  47002. /**
  47003. * Clears the texture
  47004. */
  47005. clear(): void;
  47006. /**
  47007. * Updates the texture
  47008. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47009. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  47010. */
  47011. update(invertY?: boolean, premulAlpha?: boolean): void;
  47012. /**
  47013. * Draws text onto the texture
  47014. * @param text defines the text to be drawn
  47015. * @param x defines the placement of the text from the left
  47016. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  47017. * @param font defines the font to be used with font-style, font-size, font-name
  47018. * @param color defines the color used for the text
  47019. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  47020. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47021. * @param update defines whether texture is immediately update (default is true)
  47022. */
  47023. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  47024. /**
  47025. * Clones the texture
  47026. * @returns the clone of the texture.
  47027. */
  47028. clone(): DynamicTexture;
  47029. /**
  47030. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  47031. * @returns a serialized dynamic texture object
  47032. */
  47033. serialize(): any;
  47034. /** @hidden */
  47035. _rebuild(): void;
  47036. }
  47037. }
  47038. declare module BABYLON {
  47039. /**
  47040. * This represents a texture coming from an HDR input.
  47041. *
  47042. * The only supported format is currently panorama picture stored in RGBE format.
  47043. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47044. */
  47045. class HDRCubeTexture extends BaseTexture {
  47046. private static _facesMapping;
  47047. private _generateHarmonics;
  47048. private _noMipmap;
  47049. private _textureMatrix;
  47050. private _size;
  47051. private _onLoad;
  47052. private _onError;
  47053. /**
  47054. * The texture URL.
  47055. */
  47056. url: string;
  47057. /**
  47058. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47059. */
  47060. coordinatesMode: number;
  47061. protected _isBlocking: boolean;
  47062. /**
  47063. * Sets wether or not the texture is blocking during loading.
  47064. */
  47065. /**
  47066. * Gets wether or not the texture is blocking during loading.
  47067. */
  47068. isBlocking: boolean;
  47069. protected _rotationY: number;
  47070. /**
  47071. * Sets texture matrix rotation angle around Y axis in radians.
  47072. */
  47073. /**
  47074. * Gets texture matrix rotation angle around Y axis radians.
  47075. */
  47076. rotationY: number;
  47077. /**
  47078. * Gets or sets the center of the bounding box associated with the cube texture
  47079. * It must define where the camera used to render the texture was set
  47080. */
  47081. boundingBoxPosition: Vector3;
  47082. private _boundingBoxSize;
  47083. /**
  47084. * Gets or sets the size of the bounding box associated with the cube texture
  47085. * When defined, the cubemap will switch to local mode
  47086. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47087. * @example https://www.babylonjs-playground.com/#RNASML
  47088. */
  47089. boundingBoxSize: Vector3;
  47090. /**
  47091. * Instantiates an HDRTexture from the following parameters.
  47092. *
  47093. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47094. * @param scene The scene the texture will be used in
  47095. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47096. * @param noMipmap Forces to not generate the mipmap if true
  47097. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47098. * @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)
  47099. * @param reserved Reserved flag for internal use.
  47100. */
  47101. 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>);
  47102. /**
  47103. * Get the current class name of the texture useful for serialization or dynamic coding.
  47104. * @returns "HDRCubeTexture"
  47105. */
  47106. getClassName(): string;
  47107. /**
  47108. * Occurs when the file is raw .hdr file.
  47109. */
  47110. private loadTexture;
  47111. clone(): HDRCubeTexture;
  47112. delayLoad(): void;
  47113. /**
  47114. * Get the texture reflection matrix used to rotate/transform the reflection.
  47115. * @returns the reflection matrix
  47116. */
  47117. getReflectionTextureMatrix(): Matrix;
  47118. /**
  47119. * Set the texture reflection matrix used to rotate/transform the reflection.
  47120. * @param value Define the reflection matrix to set
  47121. */
  47122. setReflectionTextureMatrix(value: Matrix): void;
  47123. /**
  47124. * Parses a JSON representation of an HDR Texture in order to create the texture
  47125. * @param parsedTexture Define the JSON representation
  47126. * @param scene Define the scene the texture should be created in
  47127. * @param rootUrl Define the root url in case we need to load relative dependencies
  47128. * @returns the newly created texture after parsing
  47129. */
  47130. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47131. serialize(): any;
  47132. }
  47133. }
  47134. declare module BABYLON {
  47135. /**
  47136. * Class used to store data associated with WebGL texture data for the engine
  47137. * This class should not be used directly
  47138. */
  47139. class InternalTexture implements IInternalTextureTracker {
  47140. /**
  47141. * The source of the texture data is unknown
  47142. */
  47143. static DATASOURCE_UNKNOWN: number;
  47144. /**
  47145. * Texture data comes from an URL
  47146. */
  47147. static DATASOURCE_URL: number;
  47148. /**
  47149. * Texture data is only used for temporary storage
  47150. */
  47151. static DATASOURCE_TEMP: number;
  47152. /**
  47153. * Texture data comes from raw data (ArrayBuffer)
  47154. */
  47155. static DATASOURCE_RAW: number;
  47156. /**
  47157. * Texture content is dynamic (video or dynamic texture)
  47158. */
  47159. static DATASOURCE_DYNAMIC: number;
  47160. /**
  47161. * Texture content is generated by rendering to it
  47162. */
  47163. static DATASOURCE_RENDERTARGET: number;
  47164. /**
  47165. * Texture content is part of a multi render target process
  47166. */
  47167. static DATASOURCE_MULTIRENDERTARGET: number;
  47168. /**
  47169. * Texture data comes from a cube data file
  47170. */
  47171. static DATASOURCE_CUBE: number;
  47172. /**
  47173. * Texture data comes from a raw cube data
  47174. */
  47175. static DATASOURCE_CUBERAW: number;
  47176. /**
  47177. * Texture data come from a prefiltered cube data file
  47178. */
  47179. static DATASOURCE_CUBEPREFILTERED: number;
  47180. /**
  47181. * Texture content is raw 3D data
  47182. */
  47183. static DATASOURCE_RAW3D: number;
  47184. /**
  47185. * Texture content is a depth texture
  47186. */
  47187. static DATASOURCE_DEPTHTEXTURE: number;
  47188. /**
  47189. * Texture data comes from a raw cube data encoded with RGBD
  47190. */
  47191. static DATASOURCE_CUBERAW_RGBD: number;
  47192. /**
  47193. * Defines if the texture is ready
  47194. */
  47195. isReady: boolean;
  47196. /**
  47197. * Defines if the texture is a cube texture
  47198. */
  47199. isCube: boolean;
  47200. /**
  47201. * Defines if the texture contains 3D data
  47202. */
  47203. is3D: boolean;
  47204. /**
  47205. * Gets the URL used to load this texture
  47206. */
  47207. url: string;
  47208. /**
  47209. * Gets the sampling mode of the texture
  47210. */
  47211. samplingMode: number;
  47212. /**
  47213. * Gets a boolean indicating if the texture needs mipmaps generation
  47214. */
  47215. generateMipMaps: boolean;
  47216. /**
  47217. * Gets the number of samples used by the texture (WebGL2+ only)
  47218. */
  47219. samples: number;
  47220. /**
  47221. * Gets the type of the texture (int, float...)
  47222. */
  47223. type: number;
  47224. /**
  47225. * Gets the format of the texture (RGB, RGBA...)
  47226. */
  47227. format: number;
  47228. /**
  47229. * Observable called when the texture is loaded
  47230. */
  47231. onLoadedObservable: Observable<InternalTexture>;
  47232. /**
  47233. * Gets the width of the texture
  47234. */
  47235. width: number;
  47236. /**
  47237. * Gets the height of the texture
  47238. */
  47239. height: number;
  47240. /**
  47241. * Gets the depth of the texture
  47242. */
  47243. depth: number;
  47244. /**
  47245. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  47246. */
  47247. baseWidth: number;
  47248. /**
  47249. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  47250. */
  47251. baseHeight: number;
  47252. /**
  47253. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  47254. */
  47255. baseDepth: number;
  47256. /**
  47257. * Gets a boolean indicating if the texture is inverted on Y axis
  47258. */
  47259. invertY: boolean;
  47260. /**
  47261. * Gets or set the previous tracker in the list
  47262. */
  47263. previous: Nullable<IInternalTextureTracker>;
  47264. /**
  47265. * Gets or set the next tracker in the list
  47266. */
  47267. next: Nullable<IInternalTextureTracker>;
  47268. /** @hidden */
  47269. _invertVScale: boolean;
  47270. /** @hidden */
  47271. _initialSlot: number;
  47272. /** @hidden */
  47273. _designatedSlot: number;
  47274. /** @hidden */
  47275. _dataSource: number;
  47276. /** @hidden */
  47277. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47278. /** @hidden */
  47279. _bufferView: Nullable<ArrayBufferView>;
  47280. /** @hidden */
  47281. _bufferViewArray: Nullable<ArrayBufferView[]>;
  47282. /** @hidden */
  47283. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  47284. /** @hidden */
  47285. _size: number;
  47286. /** @hidden */
  47287. _extension: string;
  47288. /** @hidden */
  47289. _files: Nullable<string[]>;
  47290. /** @hidden */
  47291. _workingCanvas: HTMLCanvasElement;
  47292. /** @hidden */
  47293. _workingContext: CanvasRenderingContext2D;
  47294. /** @hidden */
  47295. _framebuffer: Nullable<WebGLFramebuffer>;
  47296. /** @hidden */
  47297. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  47298. /** @hidden */
  47299. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  47300. /** @hidden */
  47301. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  47302. /** @hidden */
  47303. _attachments: Nullable<number[]>;
  47304. /** @hidden */
  47305. _cachedCoordinatesMode: Nullable<number>;
  47306. /** @hidden */
  47307. _cachedWrapU: Nullable<number>;
  47308. /** @hidden */
  47309. _cachedWrapV: Nullable<number>;
  47310. /** @hidden */
  47311. _cachedWrapR: Nullable<number>;
  47312. /** @hidden */
  47313. _cachedAnisotropicFilteringLevel: Nullable<number>;
  47314. /** @hidden */
  47315. _isDisabled: boolean;
  47316. /** @hidden */
  47317. _compression: Nullable<string>;
  47318. /** @hidden */
  47319. _generateStencilBuffer: boolean;
  47320. /** @hidden */
  47321. _generateDepthBuffer: boolean;
  47322. /** @hidden */
  47323. _comparisonFunction: number;
  47324. /** @hidden */
  47325. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  47326. /** @hidden */
  47327. _lodGenerationScale: number;
  47328. /** @hidden */
  47329. _lodGenerationOffset: number;
  47330. /** @hidden */
  47331. _lodTextureHigh: BaseTexture;
  47332. /** @hidden */
  47333. _lodTextureMid: BaseTexture;
  47334. /** @hidden */
  47335. _lodTextureLow: BaseTexture;
  47336. /** @hidden */
  47337. _isRGBD: boolean;
  47338. /** @hidden */
  47339. _webGLTexture: Nullable<WebGLTexture>;
  47340. /** @hidden */
  47341. _references: number;
  47342. private _engine;
  47343. /**
  47344. * Gets the Engine the texture belongs to.
  47345. * @returns The babylon engine
  47346. */
  47347. getEngine(): Engine;
  47348. /**
  47349. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  47350. */
  47351. readonly dataSource: number;
  47352. /**
  47353. * Creates a new InternalTexture
  47354. * @param engine defines the engine to use
  47355. * @param dataSource defines the type of data that will be used
  47356. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47357. */
  47358. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  47359. /**
  47360. * Increments the number of references (ie. the number of Texture that point to it)
  47361. */
  47362. incrementReferences(): void;
  47363. /**
  47364. * Change the size of the texture (not the size of the content)
  47365. * @param width defines the new width
  47366. * @param height defines the new height
  47367. * @param depth defines the new depth (1 by default)
  47368. */
  47369. updateSize(width: int, height: int, depth?: int): void;
  47370. /** @hidden */
  47371. _rebuild(): void;
  47372. /** @hidden */
  47373. _swapAndDie(target: InternalTexture): void;
  47374. /**
  47375. * Dispose the current allocated resources
  47376. */
  47377. dispose(): void;
  47378. }
  47379. }
  47380. declare module BABYLON {
  47381. /**
  47382. * This represents the required contract to create a new type of texture loader.
  47383. */
  47384. interface IInternalTextureLoader {
  47385. /**
  47386. * Defines wether the loader supports cascade loading the different faces.
  47387. */
  47388. supportCascades: boolean;
  47389. /**
  47390. * This returns if the loader support the current file information.
  47391. * @param extension defines the file extension of the file being loaded
  47392. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47393. * @param fallback defines the fallback internal texture if any
  47394. * @param isBase64 defines whether the texture is encoded as a base64
  47395. * @param isBuffer defines whether the texture data are stored as a buffer
  47396. * @returns true if the loader can load the specified file
  47397. */
  47398. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47399. /**
  47400. * Transform the url before loading if required.
  47401. * @param rootUrl the url of the texture
  47402. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47403. * @returns the transformed texture
  47404. */
  47405. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47406. /**
  47407. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47408. * @param rootUrl the url of the texture
  47409. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47410. * @returns the fallback texture
  47411. */
  47412. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47413. /**
  47414. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47415. * @param data contains the texture data
  47416. * @param texture defines the BabylonJS internal texture
  47417. * @param createPolynomials will be true if polynomials have been requested
  47418. * @param onLoad defines the callback to trigger once the texture is ready
  47419. * @param onError defines the callback to trigger in case of error
  47420. */
  47421. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47422. /**
  47423. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47424. * @param data contains the texture data
  47425. * @param texture defines the BabylonJS internal texture
  47426. * @param callback defines the method to call once ready to upload
  47427. */
  47428. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  47429. }
  47430. }
  47431. declare module BABYLON {
  47432. /**
  47433. * Internal interface used to track InternalTexture already bound to the GL context
  47434. */
  47435. interface IInternalTextureTracker {
  47436. /**
  47437. * Gets or set the previous tracker in the list
  47438. */
  47439. previous: Nullable<IInternalTextureTracker>;
  47440. /**
  47441. * Gets or set the next tracker in the list
  47442. */
  47443. next: Nullable<IInternalTextureTracker>;
  47444. }
  47445. /**
  47446. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  47447. */
  47448. class DummyInternalTextureTracker {
  47449. /**
  47450. * Gets or set the previous tracker in the list
  47451. */
  47452. previous: Nullable<IInternalTextureTracker>;
  47453. /**
  47454. * Gets or set the next tracker in the list
  47455. */
  47456. next: Nullable<IInternalTextureTracker>;
  47457. }
  47458. }
  47459. declare module BABYLON {
  47460. /**
  47461. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47462. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47463. * You can then easily use it as a reflectionTexture on a flat surface.
  47464. * In case the surface is not a plane, please consider relying on reflection probes.
  47465. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47466. */
  47467. class MirrorTexture extends RenderTargetTexture {
  47468. private scene;
  47469. /**
  47470. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  47471. * 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.
  47472. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47473. */
  47474. mirrorPlane: Plane;
  47475. /**
  47476. * Define the blur ratio used to blur the reflection if needed.
  47477. */
  47478. blurRatio: number;
  47479. /**
  47480. * Define the adaptive blur kernel used to blur the reflection if needed.
  47481. * This will autocompute the closest best match for the `blurKernel`
  47482. */
  47483. adaptiveBlurKernel: number;
  47484. /**
  47485. * Define the blur kernel used to blur the reflection if needed.
  47486. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47487. */
  47488. blurKernel: number;
  47489. /**
  47490. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  47491. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47492. */
  47493. blurKernelX: number;
  47494. /**
  47495. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  47496. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47497. */
  47498. blurKernelY: number;
  47499. private _autoComputeBlurKernel;
  47500. protected _onRatioRescale(): void;
  47501. private _updateGammaSpace;
  47502. private _imageProcessingConfigChangeObserver;
  47503. private _transformMatrix;
  47504. private _mirrorMatrix;
  47505. private _savedViewMatrix;
  47506. private _blurX;
  47507. private _blurY;
  47508. private _adaptiveBlurKernel;
  47509. private _blurKernelX;
  47510. private _blurKernelY;
  47511. private _blurRatio;
  47512. /**
  47513. * Instantiates a Mirror Texture.
  47514. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47515. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47516. * You can then easily use it as a reflectionTexture on a flat surface.
  47517. * In case the surface is not a plane, please consider relying on reflection probes.
  47518. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47519. * @param name
  47520. * @param size
  47521. * @param scene
  47522. * @param generateMipMaps
  47523. * @param type
  47524. * @param samplingMode
  47525. * @param generateDepthBuffer
  47526. */
  47527. constructor(name: string, size: number | {
  47528. width: number;
  47529. height: number;
  47530. } | {
  47531. ratio: number;
  47532. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  47533. private _preparePostProcesses;
  47534. /**
  47535. * Clone the mirror texture.
  47536. * @returns the cloned texture
  47537. */
  47538. clone(): MirrorTexture;
  47539. /**
  47540. * Serialize the texture to a JSON representation you could use in Parse later on
  47541. * @returns the serialized JSON representation
  47542. */
  47543. serialize(): any;
  47544. /**
  47545. * Dispose the texture and release its associated resources.
  47546. */
  47547. dispose(): void;
  47548. }
  47549. }
  47550. declare module BABYLON {
  47551. /**
  47552. * Creation options of the multi render target texture.
  47553. */
  47554. interface IMultiRenderTargetOptions {
  47555. /**
  47556. * Define if the texture needs to create mip maps after render.
  47557. */
  47558. generateMipMaps?: boolean;
  47559. /**
  47560. * Define the types of all the draw buffers we want to create
  47561. */
  47562. types?: number[];
  47563. /**
  47564. * Define the sampling modes of all the draw buffers we want to create
  47565. */
  47566. samplingModes?: number[];
  47567. /**
  47568. * Define if a depth buffer is required
  47569. */
  47570. generateDepthBuffer?: boolean;
  47571. /**
  47572. * Define if a stencil buffer is required
  47573. */
  47574. generateStencilBuffer?: boolean;
  47575. /**
  47576. * Define if a depth texture is required instead of a depth buffer
  47577. */
  47578. generateDepthTexture?: boolean;
  47579. /**
  47580. * Define the number of desired draw buffers
  47581. */
  47582. textureCount?: number;
  47583. /**
  47584. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47585. */
  47586. doNotChangeAspectRatio?: boolean;
  47587. /**
  47588. * Define the default type of the buffers we are creating
  47589. */
  47590. defaultType?: number;
  47591. }
  47592. /**
  47593. * A multi render target, like a render target provides the ability to render to a texture.
  47594. * Unlike the render target, it can render to several draw buffers in one draw.
  47595. * This is specially interesting in deferred rendering or for any effects requiring more than
  47596. * just one color from a single pass.
  47597. */
  47598. class MultiRenderTarget extends RenderTargetTexture {
  47599. private _internalTextures;
  47600. private _textures;
  47601. private _multiRenderTargetOptions;
  47602. /**
  47603. * Get if draw buffers are currently supported by the used hardware and browser.
  47604. */
  47605. readonly isSupported: boolean;
  47606. /**
  47607. * Get the list of textures generated by the multi render target.
  47608. */
  47609. readonly textures: Texture[];
  47610. /**
  47611. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47612. */
  47613. readonly depthTexture: Texture;
  47614. /**
  47615. * Set the wrapping mode on U of all the textures we are rendering to.
  47616. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47617. */
  47618. wrapU: number;
  47619. /**
  47620. * Set the wrapping mode on V of all the textures we are rendering to.
  47621. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47622. */
  47623. wrapV: number;
  47624. /**
  47625. * Instantiate a new multi render target texture.
  47626. * A multi render target, like a render target provides the ability to render to a texture.
  47627. * Unlike the render target, it can render to several draw buffers in one draw.
  47628. * This is specially interesting in deferred rendering or for any effects requiring more than
  47629. * just one color from a single pass.
  47630. * @param name Define the name of the texture
  47631. * @param size Define the size of the buffers to render to
  47632. * @param count Define the number of target we are rendering into
  47633. * @param scene Define the scene the texture belongs to
  47634. * @param options Define the options used to create the multi render target
  47635. */
  47636. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47637. /** @hidden */
  47638. _rebuild(): void;
  47639. private _createInternalTextures;
  47640. private _createTextures;
  47641. /**
  47642. * Define the number of samples used if MSAA is enabled.
  47643. */
  47644. samples: number;
  47645. /**
  47646. * Resize all the textures in the multi render target.
  47647. * Be carrefull as it will recreate all the data in the new texture.
  47648. * @param size Define the new size
  47649. */
  47650. resize(size: any): void;
  47651. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47652. /**
  47653. * Dispose the render targets and their associated resources
  47654. */
  47655. dispose(): void;
  47656. /**
  47657. * Release all the underlying texture used as draw buffers.
  47658. */
  47659. releaseInternalTextures(): void;
  47660. }
  47661. }
  47662. declare module BABYLON {
  47663. /**
  47664. * Raw cube texture where the raw buffers are passed in
  47665. */
  47666. class RawCubeTexture extends CubeTexture {
  47667. /**
  47668. * Creates a cube texture where the raw buffers are passed in.
  47669. * @param scene defines the scene the texture is attached to
  47670. * @param data defines the array of data to use to create each face
  47671. * @param size defines the size of the textures
  47672. * @param format defines the format of the data
  47673. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  47674. * @param generateMipMaps defines if the engine should generate the mip levels
  47675. * @param invertY defines if data must be stored with Y axis inverted
  47676. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  47677. * @param compression defines the compression used (null by default)
  47678. */
  47679. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47680. /**
  47681. * Updates the raw cube texture.
  47682. * @param data defines the data to store
  47683. * @param format defines the data format
  47684. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47685. * @param invertY defines if data must be stored with Y axis inverted
  47686. * @param compression defines the compression used (null by default)
  47687. * @param level defines which level of the texture to update
  47688. */
  47689. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47690. /**
  47691. * Updates a raw cube texture with RGBD encoded data.
  47692. * @param data defines the array of data [mipmap][face] to use to create each face
  47693. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47694. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47695. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47696. * @returns a promsie that resolves when the operation is complete
  47697. */
  47698. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47699. /**
  47700. * Clones the raw cube texture.
  47701. * @return a new cube texture
  47702. */
  47703. clone(): CubeTexture;
  47704. /** @hidden */
  47705. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47706. }
  47707. }
  47708. declare module BABYLON {
  47709. /**
  47710. * Raw texture can help creating a texture directly from an array of data.
  47711. * This can be super useful if you either get the data from an uncompressed source or
  47712. * if you wish to create your texture pixel by pixel.
  47713. */
  47714. class RawTexture extends Texture {
  47715. /**
  47716. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47717. */
  47718. format: number;
  47719. private _engine;
  47720. /**
  47721. * Instantiates a new RawTexture.
  47722. * Raw texture can help creating a texture directly from an array of data.
  47723. * This can be super useful if you either get the data from an uncompressed source or
  47724. * if you wish to create your texture pixel by pixel.
  47725. * @param data define the array of data to use to create the texture
  47726. * @param width define the width of the texture
  47727. * @param height define the height of the texture
  47728. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47729. * @param scene define the scene the texture belongs to
  47730. * @param generateMipMaps define whether mip maps should be generated or not
  47731. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47732. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47733. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47734. */
  47735. constructor(data: ArrayBufferView, width: number, height: number,
  47736. /**
  47737. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47738. */
  47739. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  47740. /**
  47741. * Updates the texture underlying data.
  47742. * @param data Define the new data of the texture
  47743. */
  47744. update(data: ArrayBufferView): void;
  47745. /**
  47746. * Creates a luminance texture from some data.
  47747. * @param data Define the texture data
  47748. * @param width Define the width of the texture
  47749. * @param height Define the height of the texture
  47750. * @param scene Define the scene the texture belongs to
  47751. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47752. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47753. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47754. * @returns the luminance texture
  47755. */
  47756. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47757. /**
  47758. * Creates a luminance alpha texture from some data.
  47759. * @param data Define the texture data
  47760. * @param width Define the width of the texture
  47761. * @param height Define the height of the texture
  47762. * @param scene Define the scene the texture belongs to
  47763. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47764. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47765. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47766. * @returns the luminance alpha texture
  47767. */
  47768. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47769. /**
  47770. * Creates an alpha texture from some data.
  47771. * @param data Define the texture data
  47772. * @param width Define the width of the texture
  47773. * @param height Define the height of the texture
  47774. * @param scene Define the scene the texture belongs to
  47775. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47776. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47777. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47778. * @returns the alpha texture
  47779. */
  47780. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47781. /**
  47782. * Creates a RGB texture from some data.
  47783. * @param data Define the texture data
  47784. * @param width Define the width of the texture
  47785. * @param height Define the height of the texture
  47786. * @param scene Define the scene the texture belongs to
  47787. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47788. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47789. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47790. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47791. * @returns the RGB alpha texture
  47792. */
  47793. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47794. /**
  47795. * Creates a RGBA texture from some data.
  47796. * @param data Define the texture data
  47797. * @param width Define the width of the texture
  47798. * @param height Define the height of the texture
  47799. * @param scene Define the scene the texture belongs to
  47800. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47801. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47802. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47803. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47804. * @returns the RGBA texture
  47805. */
  47806. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47807. /**
  47808. * Creates a R texture from some data.
  47809. * @param data Define the texture data
  47810. * @param width Define the width of the texture
  47811. * @param height Define the height of the texture
  47812. * @param scene Define the scene the texture belongs to
  47813. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47814. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47815. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47816. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47817. * @returns the R texture
  47818. */
  47819. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47820. }
  47821. }
  47822. declare module BABYLON {
  47823. /**
  47824. * Class used to store 3D textures containing user data
  47825. */
  47826. class RawTexture3D extends Texture {
  47827. /** Gets or sets the texture format to use */
  47828. format: number;
  47829. private _engine;
  47830. /**
  47831. * Create a new RawTexture3D
  47832. * @param data defines the data of the texture
  47833. * @param width defines the width of the texture
  47834. * @param height defines the height of the texture
  47835. * @param depth defines the depth of the texture
  47836. * @param format defines the texture format to use
  47837. * @param scene defines the hosting scene
  47838. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47839. * @param invertY defines if texture must be stored with Y axis inverted
  47840. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47841. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47842. */
  47843. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47844. /** Gets or sets the texture format to use */
  47845. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47846. /**
  47847. * Update the texture with new data
  47848. * @param data defines the data to store in the texture
  47849. */
  47850. update(data: ArrayBufferView): void;
  47851. }
  47852. }
  47853. declare module BABYLON {
  47854. /**
  47855. * Creates a refraction texture used by refraction channel of the standard material.
  47856. * It is like a mirror but to see through a material.
  47857. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47858. */
  47859. class RefractionTexture extends RenderTargetTexture {
  47860. /**
  47861. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47862. * 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.
  47863. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47864. */
  47865. refractionPlane: Plane;
  47866. /**
  47867. * Define how deep under the surface we should see.
  47868. */
  47869. depth: number;
  47870. /**
  47871. * Creates a refraction texture used by refraction channel of the standard material.
  47872. * It is like a mirror but to see through a material.
  47873. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47874. * @param name Define the texture name
  47875. * @param size Define the size of the underlying texture
  47876. * @param scene Define the scene the refraction belongs to
  47877. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47878. */
  47879. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47880. /**
  47881. * Clone the refraction texture.
  47882. * @returns the cloned texture
  47883. */
  47884. clone(): RefractionTexture;
  47885. /**
  47886. * Serialize the texture to a JSON representation you could use in Parse later on
  47887. * @returns the serialized JSON representation
  47888. */
  47889. serialize(): any;
  47890. }
  47891. }
  47892. declare module BABYLON {
  47893. /**
  47894. * This Helps creating a texture that will be created from a camera in your scene.
  47895. * It is basically a dynamic texture that could be used to create special effects for instance.
  47896. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47897. */
  47898. class RenderTargetTexture extends Texture {
  47899. isCube: boolean;
  47900. /**
  47901. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47902. */
  47903. static readonly REFRESHRATE_RENDER_ONCE: number;
  47904. /**
  47905. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47906. */
  47907. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47908. /**
  47909. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47910. * the central point of your effect and can save a lot of performances.
  47911. */
  47912. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47913. /**
  47914. * Use this predicate to dynamically define the list of mesh you want to render.
  47915. * If set, the renderList property will be overwritten.
  47916. */
  47917. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47918. private _renderList;
  47919. /**
  47920. * Use this list to define the list of mesh you want to render.
  47921. */
  47922. renderList: Nullable<Array<AbstractMesh>>;
  47923. private _hookArray;
  47924. /**
  47925. * Define if particles should be rendered in your texture.
  47926. */
  47927. renderParticles: boolean;
  47928. /**
  47929. * Define if sprites should be rendered in your texture.
  47930. */
  47931. renderSprites: boolean;
  47932. /**
  47933. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47934. */
  47935. coordinatesMode: number;
  47936. /**
  47937. * Define the camera used to render the texture.
  47938. */
  47939. activeCamera: Nullable<Camera>;
  47940. /**
  47941. * Override the render function of the texture with your own one.
  47942. */
  47943. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47944. /**
  47945. * Define if camera post processes should be use while rendering the texture.
  47946. */
  47947. useCameraPostProcesses: boolean;
  47948. /**
  47949. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47950. */
  47951. ignoreCameraViewport: boolean;
  47952. private _postProcessManager;
  47953. private _postProcesses;
  47954. private _resizeObserver;
  47955. /**
  47956. * An event triggered when the texture is unbind.
  47957. */
  47958. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47959. /**
  47960. * An event triggered when the texture is unbind.
  47961. */
  47962. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47963. private _onAfterUnbindObserver;
  47964. /**
  47965. * Set a after unbind callback in the texture.
  47966. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47967. */
  47968. onAfterUnbind: () => void;
  47969. /**
  47970. * An event triggered before rendering the texture
  47971. */
  47972. onBeforeRenderObservable: Observable<number>;
  47973. private _onBeforeRenderObserver;
  47974. /**
  47975. * Set a before render callback in the texture.
  47976. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47977. */
  47978. onBeforeRender: (faceIndex: number) => void;
  47979. /**
  47980. * An event triggered after rendering the texture
  47981. */
  47982. onAfterRenderObservable: Observable<number>;
  47983. private _onAfterRenderObserver;
  47984. /**
  47985. * Set a after render callback in the texture.
  47986. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47987. */
  47988. onAfterRender: (faceIndex: number) => void;
  47989. /**
  47990. * An event triggered after the texture clear
  47991. */
  47992. onClearObservable: Observable<Engine>;
  47993. private _onClearObserver;
  47994. /**
  47995. * Set a clear callback in the texture.
  47996. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47997. */
  47998. onClear: (Engine: Engine) => void;
  47999. /**
  48000. * Define the clear color of the Render Target if it should be different from the scene.
  48001. */
  48002. clearColor: Color4;
  48003. protected _size: number | {
  48004. width: number;
  48005. height: number;
  48006. };
  48007. protected _initialSizeParameter: number | {
  48008. width: number;
  48009. height: number;
  48010. } | {
  48011. ratio: number;
  48012. };
  48013. protected _sizeRatio: Nullable<number>;
  48014. /** @hidden */
  48015. _generateMipMaps: boolean;
  48016. protected _renderingManager: RenderingManager;
  48017. /** @hidden */
  48018. _waitingRenderList: string[];
  48019. protected _doNotChangeAspectRatio: boolean;
  48020. protected _currentRefreshId: number;
  48021. protected _refreshRate: number;
  48022. protected _textureMatrix: Matrix;
  48023. protected _samples: number;
  48024. protected _renderTargetOptions: RenderTargetCreationOptions;
  48025. /**
  48026. * Gets render target creation options that were used.
  48027. */
  48028. readonly renderTargetOptions: RenderTargetCreationOptions;
  48029. protected _engine: Engine;
  48030. protected _onRatioRescale(): void;
  48031. /**
  48032. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  48033. * It must define where the camera used to render the texture is set
  48034. */
  48035. boundingBoxPosition: Vector3;
  48036. private _boundingBoxSize;
  48037. /**
  48038. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  48039. * When defined, the cubemap will switch to local mode
  48040. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48041. * @example https://www.babylonjs-playground.com/#RNASML
  48042. */
  48043. boundingBoxSize: Vector3;
  48044. /**
  48045. * In case the RTT has been created with a depth texture, get the associated
  48046. * depth texture.
  48047. * Otherwise, return null.
  48048. */
  48049. depthStencilTexture: Nullable<InternalTexture>;
  48050. /**
  48051. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  48052. * or used a shadow, depth texture...
  48053. * @param name The friendly name of the texture
  48054. * @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)
  48055. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  48056. * @param generateMipMaps True if mip maps need to be generated after render.
  48057. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  48058. * @param type The type of the buffer in the RTT (int, half float, float...)
  48059. * @param isCube True if a cube texture needs to be created
  48060. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  48061. * @param generateDepthBuffer True to generate a depth buffer
  48062. * @param generateStencilBuffer True to generate a stencil buffer
  48063. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  48064. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  48065. * @param delayAllocation if the texture allocation should be delayed (default: false)
  48066. */
  48067. constructor(name: string, size: number | {
  48068. width: number;
  48069. height: number;
  48070. } | {
  48071. ratio: number;
  48072. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  48073. /**
  48074. * Creates a depth stencil texture.
  48075. * This is only available in WebGL 2 or with the depth texture extension available.
  48076. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  48077. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  48078. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  48079. */
  48080. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  48081. private _processSizeParameter;
  48082. /**
  48083. * Define the number of samples to use in case of MSAA.
  48084. * It defaults to one meaning no MSAA has been enabled.
  48085. */
  48086. samples: number;
  48087. /**
  48088. * Resets the refresh counter of the texture and start bak from scratch.
  48089. * Could be useful to regenerate the texture if it is setup to render only once.
  48090. */
  48091. resetRefreshCounter(): void;
  48092. /**
  48093. * Define the refresh rate of the texture or the rendering frequency.
  48094. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  48095. */
  48096. refreshRate: number;
  48097. /**
  48098. * Adds a post process to the render target rendering passes.
  48099. * @param postProcess define the post process to add
  48100. */
  48101. addPostProcess(postProcess: PostProcess): void;
  48102. /**
  48103. * Clear all the post processes attached to the render target
  48104. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  48105. */
  48106. clearPostProcesses(dispose?: boolean): void;
  48107. /**
  48108. * Remove one of the post process from the list of attached post processes to the texture
  48109. * @param postProcess define the post process to remove from the list
  48110. */
  48111. removePostProcess(postProcess: PostProcess): void;
  48112. /** @hidden */
  48113. _shouldRender(): boolean;
  48114. /**
  48115. * Gets the actual render size of the texture.
  48116. * @returns the width of the render size
  48117. */
  48118. getRenderSize(): number;
  48119. /**
  48120. * Gets the actual render width of the texture.
  48121. * @returns the width of the render size
  48122. */
  48123. getRenderWidth(): number;
  48124. /**
  48125. * Gets the actual render height of the texture.
  48126. * @returns the height of the render size
  48127. */
  48128. getRenderHeight(): number;
  48129. /**
  48130. * Get if the texture can be rescaled or not.
  48131. */
  48132. readonly canRescale: boolean;
  48133. /**
  48134. * Resize the texture using a ratio.
  48135. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  48136. */
  48137. scale(ratio: number): void;
  48138. /**
  48139. * Get the texture reflection matrix used to rotate/transform the reflection.
  48140. * @returns the reflection matrix
  48141. */
  48142. getReflectionTextureMatrix(): Matrix;
  48143. /**
  48144. * Resize the texture to a new desired size.
  48145. * Be carrefull as it will recreate all the data in the new texture.
  48146. * @param size Define the new size. It can be:
  48147. * - a number for squared texture,
  48148. * - an object containing { width: number, height: number }
  48149. * - or an object containing a ratio { ratio: number }
  48150. */
  48151. resize(size: number | {
  48152. width: number;
  48153. height: number;
  48154. } | {
  48155. ratio: number;
  48156. }): void;
  48157. /**
  48158. * Renders all the objects from the render list into the texture.
  48159. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  48160. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  48161. */
  48162. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  48163. private _bestReflectionRenderTargetDimension;
  48164. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48165. private renderToTarget;
  48166. /**
  48167. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48168. * This allowed control for front to back rendering or reversly depending of the special needs.
  48169. *
  48170. * @param renderingGroupId The rendering group id corresponding to its index
  48171. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48172. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48173. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48174. */
  48175. 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;
  48176. /**
  48177. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48178. *
  48179. * @param renderingGroupId The rendering group id corresponding to its index
  48180. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48181. */
  48182. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48183. /**
  48184. * Clones the texture.
  48185. * @returns the cloned texture
  48186. */
  48187. clone(): RenderTargetTexture;
  48188. /**
  48189. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48190. * @returns The JSON representation of the texture
  48191. */
  48192. serialize(): any;
  48193. /**
  48194. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  48195. */
  48196. disposeFramebufferObjects(): void;
  48197. /**
  48198. * Dispose the texture and release its associated resources.
  48199. */
  48200. dispose(): void;
  48201. /** @hidden */
  48202. _rebuild(): void;
  48203. /**
  48204. * Clear the info related to rendering groups preventing retention point in material dispose.
  48205. */
  48206. freeRenderingGroups(): void;
  48207. }
  48208. }
  48209. declare module BABYLON {
  48210. /**
  48211. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48212. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48213. */
  48214. class Texture extends BaseTexture {
  48215. /** nearest is mag = nearest and min = nearest and mip = linear */
  48216. static readonly NEAREST_SAMPLINGMODE: number;
  48217. /** nearest is mag = nearest and min = nearest and mip = linear */
  48218. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  48219. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48220. static readonly BILINEAR_SAMPLINGMODE: number;
  48221. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48222. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  48223. /** Trilinear is mag = linear and min = linear and mip = linear */
  48224. static readonly TRILINEAR_SAMPLINGMODE: number;
  48225. /** Trilinear is mag = linear and min = linear and mip = linear */
  48226. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  48227. /** mag = nearest and min = nearest and mip = nearest */
  48228. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  48229. /** mag = nearest and min = linear and mip = nearest */
  48230. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  48231. /** mag = nearest and min = linear and mip = linear */
  48232. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  48233. /** mag = nearest and min = linear and mip = none */
  48234. static readonly NEAREST_LINEAR: number;
  48235. /** mag = nearest and min = nearest and mip = none */
  48236. static readonly NEAREST_NEAREST: number;
  48237. /** mag = linear and min = nearest and mip = nearest */
  48238. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  48239. /** mag = linear and min = nearest and mip = linear */
  48240. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  48241. /** mag = linear and min = linear and mip = none */
  48242. static readonly LINEAR_LINEAR: number;
  48243. /** mag = linear and min = nearest and mip = none */
  48244. static readonly LINEAR_NEAREST: number;
  48245. /** Explicit coordinates mode */
  48246. static readonly EXPLICIT_MODE: number;
  48247. /** Spherical coordinates mode */
  48248. static readonly SPHERICAL_MODE: number;
  48249. /** Planar coordinates mode */
  48250. static readonly PLANAR_MODE: number;
  48251. /** Cubic coordinates mode */
  48252. static readonly CUBIC_MODE: number;
  48253. /** Projection coordinates mode */
  48254. static readonly PROJECTION_MODE: number;
  48255. /** Inverse Cubic coordinates mode */
  48256. static readonly SKYBOX_MODE: number;
  48257. /** Inverse Cubic coordinates mode */
  48258. static readonly INVCUBIC_MODE: number;
  48259. /** Equirectangular coordinates mode */
  48260. static readonly EQUIRECTANGULAR_MODE: number;
  48261. /** Equirectangular Fixed coordinates mode */
  48262. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  48263. /** Equirectangular Fixed Mirrored coordinates mode */
  48264. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  48265. /** Texture is not repeating outside of 0..1 UVs */
  48266. static readonly CLAMP_ADDRESSMODE: number;
  48267. /** Texture is repeating outside of 0..1 UVs */
  48268. static readonly WRAP_ADDRESSMODE: number;
  48269. /** Texture is repeating and mirrored */
  48270. static readonly MIRROR_ADDRESSMODE: number;
  48271. /**
  48272. * 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
  48273. */
  48274. static UseSerializedUrlIfAny: boolean;
  48275. /**
  48276. * Define the url of the texture.
  48277. */
  48278. url: Nullable<string>;
  48279. /**
  48280. * Define an offset on the texture to offset the u coordinates of the UVs
  48281. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48282. */
  48283. uOffset: number;
  48284. /**
  48285. * Define an offset on the texture to offset the v coordinates of the UVs
  48286. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48287. */
  48288. vOffset: number;
  48289. /**
  48290. * Define an offset on the texture to scale the u coordinates of the UVs
  48291. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48292. */
  48293. uScale: number;
  48294. /**
  48295. * Define an offset on the texture to scale the v coordinates of the UVs
  48296. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48297. */
  48298. vScale: number;
  48299. /**
  48300. * Define an offset on the texture to rotate around the u coordinates of the UVs
  48301. * @see http://doc.babylonjs.com/how_to/more_materials
  48302. */
  48303. uAng: number;
  48304. /**
  48305. * Define an offset on the texture to rotate around the v coordinates of the UVs
  48306. * @see http://doc.babylonjs.com/how_to/more_materials
  48307. */
  48308. vAng: number;
  48309. /**
  48310. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  48311. * @see http://doc.babylonjs.com/how_to/more_materials
  48312. */
  48313. wAng: number;
  48314. /**
  48315. * Defines the center of rotation (U)
  48316. */
  48317. uRotationCenter: number;
  48318. /**
  48319. * Defines the center of rotation (V)
  48320. */
  48321. vRotationCenter: number;
  48322. /**
  48323. * Defines the center of rotation (W)
  48324. */
  48325. wRotationCenter: number;
  48326. /**
  48327. * Are mip maps generated for this texture or not.
  48328. */
  48329. readonly noMipmap: boolean;
  48330. private _noMipmap;
  48331. /** @hidden */
  48332. _invertY: boolean;
  48333. private _rowGenerationMatrix;
  48334. private _cachedTextureMatrix;
  48335. private _projectionModeMatrix;
  48336. private _t0;
  48337. private _t1;
  48338. private _t2;
  48339. private _cachedUOffset;
  48340. private _cachedVOffset;
  48341. private _cachedUScale;
  48342. private _cachedVScale;
  48343. private _cachedUAng;
  48344. private _cachedVAng;
  48345. private _cachedWAng;
  48346. private _cachedProjectionMatrixId;
  48347. private _cachedCoordinatesMode;
  48348. /** @hidden */
  48349. protected _initialSamplingMode: number;
  48350. /** @hidden */
  48351. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  48352. private _deleteBuffer;
  48353. protected _format: Nullable<number>;
  48354. private _delayedOnLoad;
  48355. private _delayedOnError;
  48356. /**
  48357. * Observable triggered once the texture has been loaded.
  48358. */
  48359. onLoadObservable: Observable<Texture>;
  48360. protected _isBlocking: boolean;
  48361. /**
  48362. * Is the texture preventing material to render while loading.
  48363. * If false, a default texture will be used instead of the loading one during the preparation step.
  48364. */
  48365. isBlocking: boolean;
  48366. /**
  48367. * Get the current sampling mode associated with the texture.
  48368. */
  48369. readonly samplingMode: number;
  48370. /**
  48371. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  48372. */
  48373. readonly invertY: boolean;
  48374. /**
  48375. * Instantiates a new texture.
  48376. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48377. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48378. * @param url define the url of the picture to load as a texture
  48379. * @param scene define the scene the texture will belong to
  48380. * @param noMipmap define if the texture will require mip maps or not
  48381. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48382. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48383. * @param onLoad define a callback triggered when the texture has been loaded
  48384. * @param onError define a callback triggered when an error occurred during the loading session
  48385. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48386. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48387. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48388. */
  48389. 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);
  48390. /**
  48391. * Update the url (and optional buffer) of this texture if url was null during construction.
  48392. * @param url the url of the texture
  48393. * @param buffer the buffer of the texture (defaults to null)
  48394. * @param onLoad callback called when the texture is loaded (defaults to null)
  48395. */
  48396. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  48397. /**
  48398. * Finish the loading sequence of a texture flagged as delayed load.
  48399. * @hidden
  48400. */
  48401. delayLoad(): void;
  48402. private _prepareRowForTextureGeneration;
  48403. /**
  48404. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  48405. * @returns the transform matrix of the texture.
  48406. */
  48407. getTextureMatrix(): Matrix;
  48408. /**
  48409. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  48410. * @returns The reflection texture transform
  48411. */
  48412. getReflectionTextureMatrix(): Matrix;
  48413. /**
  48414. * Clones the texture.
  48415. * @returns the cloned texture
  48416. */
  48417. clone(): Texture;
  48418. /**
  48419. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48420. * @returns The JSON representation of the texture
  48421. */
  48422. serialize(): any;
  48423. /**
  48424. * Get the current class name of the texture useful for serialization or dynamic coding.
  48425. * @returns "Texture"
  48426. */
  48427. getClassName(): string;
  48428. /**
  48429. * Dispose the texture and release its associated resources.
  48430. */
  48431. dispose(): void;
  48432. /**
  48433. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  48434. * @param parsedTexture Define the JSON representation of the texture
  48435. * @param scene Define the scene the parsed texture should be instantiated in
  48436. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48437. * @returns The parsed texture if successful
  48438. */
  48439. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  48440. /**
  48441. * Creates a texture from its base 64 representation.
  48442. * @param data Define the base64 payload without the data: prefix
  48443. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48444. * @param scene Define the scene the texture should belong to
  48445. * @param noMipmap Forces the texture to not create mip map information if true
  48446. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48447. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48448. * @param onLoad define a callback triggered when the texture has been loaded
  48449. * @param onError define a callback triggered when an error occurred during the loading session
  48450. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48451. * @returns the created texture
  48452. */
  48453. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  48454. /**
  48455. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  48456. * @param data Define the base64 payload without the data: prefix
  48457. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48458. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48459. * @param scene Define the scene the texture should belong to
  48460. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48461. * @param noMipmap Forces the texture to not create mip map information if true
  48462. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48463. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48464. * @param onLoad define a callback triggered when the texture has been loaded
  48465. * @param onError define a callback triggered when an error occurred during the loading session
  48466. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48467. * @returns the created texture
  48468. */
  48469. 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;
  48470. }
  48471. }
  48472. declare module BABYLON {
  48473. /**
  48474. * Settings for finer control over video usage
  48475. */
  48476. interface VideoTextureSettings {
  48477. /**
  48478. * Applies `autoplay` to video, if specified
  48479. */
  48480. autoPlay?: boolean;
  48481. /**
  48482. * Applies `loop` to video, if specified
  48483. */
  48484. loop?: boolean;
  48485. /**
  48486. * Automatically updates internal texture from video at every frame in the render loop
  48487. */
  48488. autoUpdateTexture: boolean;
  48489. /**
  48490. * Image src displayed during the video loading or until the user interacts with the video.
  48491. */
  48492. poster?: string;
  48493. }
  48494. /**
  48495. * If you want to display a video in your scene, this is the special texture for that.
  48496. * This special texture works similar to other textures, with the exception of a few parameters.
  48497. * @see https://doc.babylonjs.com/how_to/video_texture
  48498. */
  48499. class VideoTexture extends Texture {
  48500. /**
  48501. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  48502. */
  48503. readonly autoUpdateTexture: boolean;
  48504. /**
  48505. * The video instance used by the texture internally
  48506. */
  48507. readonly video: HTMLVideoElement;
  48508. private _onUserActionRequestedObservable;
  48509. /**
  48510. * Event triggerd when a dom action is required by the user to play the video.
  48511. * This happens due to recent changes in browser policies preventing video to auto start.
  48512. */
  48513. readonly onUserActionRequestedObservable: Observable<Texture>;
  48514. private _generateMipMaps;
  48515. private _engine;
  48516. private _stillImageCaptured;
  48517. private _displayingPosterTexture;
  48518. private _settings;
  48519. private _createInternalTextureOnEvent;
  48520. /**
  48521. * Creates a video texture.
  48522. * If you want to display a video in your scene, this is the special texture for that.
  48523. * This special texture works similar to other textures, with the exception of a few parameters.
  48524. * @see https://doc.babylonjs.com/how_to/video_texture
  48525. * @param name optional name, will detect from video source, if not defined
  48526. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  48527. * @param scene is obviously the current scene.
  48528. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  48529. * @param invertY is false by default but can be used to invert video on Y axis
  48530. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  48531. * @param settings allows finer control over video usage
  48532. */
  48533. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  48534. private _getName;
  48535. private _getVideo;
  48536. private _createInternalTexture;
  48537. private reset;
  48538. /**
  48539. * @hidden Internal method to initiate `update`.
  48540. */
  48541. _rebuild(): void;
  48542. /**
  48543. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  48544. */
  48545. update(): void;
  48546. /**
  48547. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  48548. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  48549. */
  48550. updateTexture(isVisible: boolean): void;
  48551. protected _updateInternalTexture: (e?: Event | undefined) => void;
  48552. /**
  48553. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  48554. * @param url New url.
  48555. */
  48556. updateURL(url: string): void;
  48557. /**
  48558. * Dispose the texture and release its associated resources.
  48559. */
  48560. dispose(): void;
  48561. /**
  48562. * Creates a video texture straight from your WebCam video feed.
  48563. * @param scene Define the scene the texture should be created in
  48564. * @param onReady Define a callback to triggered once the texture will be ready
  48565. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  48566. */
  48567. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  48568. minWidth: number;
  48569. maxWidth: number;
  48570. minHeight: number;
  48571. maxHeight: number;
  48572. deviceId: string;
  48573. }): void;
  48574. }
  48575. }
  48576. declare var DracoDecoderModule: any;
  48577. declare var WebAssembly: any;
  48578. declare module BABYLON {
  48579. /**
  48580. * Configuration for Draco compression
  48581. */
  48582. interface IDracoCompressionConfiguration {
  48583. /**
  48584. * Configuration for the decoder.
  48585. */
  48586. decoder?: {
  48587. /**
  48588. * The url to the WebAssembly module.
  48589. */
  48590. wasmUrl?: string;
  48591. /**
  48592. * The url to the WebAssembly binary.
  48593. */
  48594. wasmBinaryUrl?: string;
  48595. /**
  48596. * The url to the fallback JavaScript module.
  48597. */
  48598. fallbackUrl?: string;
  48599. };
  48600. }
  48601. /**
  48602. * Draco compression (https://google.github.io/draco/)
  48603. *
  48604. * This class wraps the Draco module.
  48605. *
  48606. * **Encoder**
  48607. *
  48608. * The encoder is not currently implemented.
  48609. *
  48610. * **Decoder**
  48611. *
  48612. * 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.
  48613. *
  48614. * To update the configuration, use the following code:
  48615. * ```javascript
  48616. * BABYLON.DracoCompression.Configuration = {
  48617. * decoder: {
  48618. * wasmUrl: "<url to the WebAssembly library>",
  48619. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48620. * fallbackUrl: "<url to the fallback JavaScript library>",
  48621. * }
  48622. * };
  48623. * ```
  48624. *
  48625. * 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.
  48626. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48627. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48628. *
  48629. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48630. * ```javascript
  48631. * var dracoCompression = new BABYLON.DracoCompression();
  48632. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48633. * [BABYLON.VertexBuffer.PositionKind]: 0
  48634. * });
  48635. * ```
  48636. *
  48637. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48638. */
  48639. class DracoCompression implements IDisposable {
  48640. private static _DecoderModulePromise;
  48641. /**
  48642. * The configuration. Defaults to the following urls:
  48643. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48644. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48645. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48646. */
  48647. static Configuration: IDracoCompressionConfiguration;
  48648. /**
  48649. * Returns true if the decoder is available.
  48650. */
  48651. static readonly DecoderAvailable: boolean;
  48652. /**
  48653. * Constructor
  48654. */
  48655. constructor();
  48656. /**
  48657. * Stop all async operations and release resources.
  48658. */
  48659. dispose(): void;
  48660. /**
  48661. * Decode Draco compressed mesh data to vertex data.
  48662. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48663. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48664. * @returns A promise that resolves with the decoded vertex data
  48665. */
  48666. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48667. [kind: string]: number;
  48668. }): Promise<VertexData>;
  48669. private static _GetDecoderModule;
  48670. private static _LoadScriptAsync;
  48671. private static _LoadFileAsync;
  48672. }
  48673. }
  48674. declare module BABYLON {
  48675. /**
  48676. * Particle emitter emitting particles from the inside of a box.
  48677. * It emits the particles randomly between 2 given directions.
  48678. */
  48679. class BoxParticleEmitter implements IParticleEmitterType {
  48680. /**
  48681. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48682. */
  48683. direction1: Vector3;
  48684. /**
  48685. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48686. */
  48687. direction2: Vector3;
  48688. /**
  48689. * 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.
  48690. */
  48691. minEmitBox: Vector3;
  48692. /**
  48693. * 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.
  48694. */
  48695. maxEmitBox: Vector3;
  48696. /**
  48697. * Creates a new instance BoxParticleEmitter
  48698. */
  48699. constructor();
  48700. /**
  48701. * Called by the particle System when the direction is computed for the created particle.
  48702. * @param worldMatrix is the world matrix of the particle system
  48703. * @param directionToUpdate is the direction vector to update with the result
  48704. * @param particle is the particle we are computed the direction for
  48705. */
  48706. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48707. /**
  48708. * Called by the particle System when the position is computed for the created particle.
  48709. * @param worldMatrix is the world matrix of the particle system
  48710. * @param positionToUpdate is the position vector to update with the result
  48711. * @param particle is the particle we are computed the position for
  48712. */
  48713. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48714. /**
  48715. * Clones the current emitter and returns a copy of it
  48716. * @returns the new emitter
  48717. */
  48718. clone(): BoxParticleEmitter;
  48719. /**
  48720. * Called by the GPUParticleSystem to setup the update shader
  48721. * @param effect defines the update shader
  48722. */
  48723. applyToShader(effect: Effect): void;
  48724. /**
  48725. * Returns a string to use to update the GPU particles update shader
  48726. * @returns a string containng the defines string
  48727. */
  48728. getEffectDefines(): string;
  48729. /**
  48730. * Returns the string "BoxParticleEmitter"
  48731. * @returns a string containing the class name
  48732. */
  48733. getClassName(): string;
  48734. /**
  48735. * Serializes the particle system to a JSON object.
  48736. * @returns the JSON object
  48737. */
  48738. serialize(): any;
  48739. /**
  48740. * Parse properties from a JSON object
  48741. * @param serializationObject defines the JSON object
  48742. */
  48743. parse(serializationObject: any): void;
  48744. }
  48745. }
  48746. declare module BABYLON {
  48747. /**
  48748. * Particle emitter emitting particles from the inside of a cone.
  48749. * It emits the particles alongside the cone volume from the base to the particle.
  48750. * The emission direction might be randomized.
  48751. */
  48752. class ConeParticleEmitter implements IParticleEmitterType {
  48753. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48754. directionRandomizer: number;
  48755. private _radius;
  48756. private _angle;
  48757. private _height;
  48758. /**
  48759. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  48760. */
  48761. radiusRange: number;
  48762. /**
  48763. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  48764. */
  48765. heightRange: number;
  48766. /**
  48767. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  48768. */
  48769. emitFromSpawnPointOnly: boolean;
  48770. /**
  48771. * Gets or sets the radius of the emission cone
  48772. */
  48773. radius: number;
  48774. /**
  48775. * Gets or sets the angle of the emission cone
  48776. */
  48777. angle: number;
  48778. private _buildHeight;
  48779. /**
  48780. * Creates a new instance ConeParticleEmitter
  48781. * @param radius the radius of the emission cone (1 by default)
  48782. * @param angles the cone base angle (PI by default)
  48783. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  48784. */
  48785. constructor(radius?: number, angle?: number,
  48786. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48787. directionRandomizer?: number);
  48788. /**
  48789. * Called by the particle System when the direction is computed for the created particle.
  48790. * @param worldMatrix is the world matrix of the particle system
  48791. * @param directionToUpdate is the direction vector to update with the result
  48792. * @param particle is the particle we are computed the direction for
  48793. */
  48794. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48795. /**
  48796. * Called by the particle System when the position is computed for the created particle.
  48797. * @param worldMatrix is the world matrix of the particle system
  48798. * @param positionToUpdate is the position vector to update with the result
  48799. * @param particle is the particle we are computed the position for
  48800. */
  48801. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48802. /**
  48803. * Clones the current emitter and returns a copy of it
  48804. * @returns the new emitter
  48805. */
  48806. clone(): ConeParticleEmitter;
  48807. /**
  48808. * Called by the GPUParticleSystem to setup the update shader
  48809. * @param effect defines the update shader
  48810. */
  48811. applyToShader(effect: Effect): void;
  48812. /**
  48813. * Returns a string to use to update the GPU particles update shader
  48814. * @returns a string containng the defines string
  48815. */
  48816. getEffectDefines(): string;
  48817. /**
  48818. * Returns the string "ConeParticleEmitter"
  48819. * @returns a string containing the class name
  48820. */
  48821. getClassName(): string;
  48822. /**
  48823. * Serializes the particle system to a JSON object.
  48824. * @returns the JSON object
  48825. */
  48826. serialize(): any;
  48827. /**
  48828. * Parse properties from a JSON object
  48829. * @param serializationObject defines the JSON object
  48830. */
  48831. parse(serializationObject: any): void;
  48832. }
  48833. }
  48834. declare module BABYLON {
  48835. /**
  48836. * Particle emitter emitting particles from the inside of a cylinder.
  48837. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  48838. */
  48839. class CylinderParticleEmitter implements IParticleEmitterType {
  48840. /**
  48841. * The radius of the emission cylinder.
  48842. */
  48843. radius: number;
  48844. /**
  48845. * The height of the emission cylinder.
  48846. */
  48847. height: number;
  48848. /**
  48849. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48850. */
  48851. radiusRange: number;
  48852. /**
  48853. * How much to randomize the particle direction [0-1].
  48854. */
  48855. directionRandomizer: number;
  48856. /**
  48857. * Creates a new instance CylinderParticleEmitter
  48858. * @param radius the radius of the emission cylinder (1 by default)
  48859. * @param height the height of the emission cylinder (1 by default)
  48860. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48861. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48862. */
  48863. constructor(
  48864. /**
  48865. * The radius of the emission cylinder.
  48866. */
  48867. radius?: number,
  48868. /**
  48869. * The height of the emission cylinder.
  48870. */
  48871. height?: number,
  48872. /**
  48873. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48874. */
  48875. radiusRange?: number,
  48876. /**
  48877. * How much to randomize the particle direction [0-1].
  48878. */
  48879. directionRandomizer?: number);
  48880. /**
  48881. * Called by the particle System when the direction is computed for the created particle.
  48882. * @param worldMatrix is the world matrix of the particle system
  48883. * @param directionToUpdate is the direction vector to update with the result
  48884. * @param particle is the particle we are computed the direction for
  48885. */
  48886. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48887. /**
  48888. * Called by the particle System when the position is computed for the created particle.
  48889. * @param worldMatrix is the world matrix of the particle system
  48890. * @param positionToUpdate is the position vector to update with the result
  48891. * @param particle is the particle we are computed the position for
  48892. */
  48893. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48894. /**
  48895. * Clones the current emitter and returns a copy of it
  48896. * @returns the new emitter
  48897. */
  48898. clone(): CylinderParticleEmitter;
  48899. /**
  48900. * Called by the GPUParticleSystem to setup the update shader
  48901. * @param effect defines the update shader
  48902. */
  48903. applyToShader(effect: Effect): void;
  48904. /**
  48905. * Returns a string to use to update the GPU particles update shader
  48906. * @returns a string containng the defines string
  48907. */
  48908. getEffectDefines(): string;
  48909. /**
  48910. * Returns the string "CylinderParticleEmitter"
  48911. * @returns a string containing the class name
  48912. */
  48913. getClassName(): string;
  48914. /**
  48915. * Serializes the particle system to a JSON object.
  48916. * @returns the JSON object
  48917. */
  48918. serialize(): any;
  48919. /**
  48920. * Parse properties from a JSON object
  48921. * @param serializationObject defines the JSON object
  48922. */
  48923. parse(serializationObject: any): void;
  48924. }
  48925. /**
  48926. * Particle emitter emitting particles from the inside of a cylinder.
  48927. * It emits the particles randomly between two vectors.
  48928. */
  48929. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  48930. /**
  48931. * The min limit of the emission direction.
  48932. */
  48933. direction1: Vector3;
  48934. /**
  48935. * The max limit of the emission direction.
  48936. */
  48937. direction2: Vector3;
  48938. /**
  48939. * Creates a new instance CylinderDirectedParticleEmitter
  48940. * @param radius the radius of the emission cylinder (1 by default)
  48941. * @param height the height of the emission cylinder (1 by default)
  48942. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48943. * @param direction1 the min limit of the emission direction (up vector by default)
  48944. * @param direction2 the max limit of the emission direction (up vector by default)
  48945. */
  48946. constructor(radius?: number, height?: number, radiusRange?: number,
  48947. /**
  48948. * The min limit of the emission direction.
  48949. */
  48950. direction1?: Vector3,
  48951. /**
  48952. * The max limit of the emission direction.
  48953. */
  48954. direction2?: Vector3);
  48955. /**
  48956. * Called by the particle System when the direction is computed for the created particle.
  48957. * @param worldMatrix is the world matrix of the particle system
  48958. * @param directionToUpdate is the direction vector to update with the result
  48959. * @param particle is the particle we are computed the direction for
  48960. */
  48961. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48962. /**
  48963. * Clones the current emitter and returns a copy of it
  48964. * @returns the new emitter
  48965. */
  48966. clone(): CylinderDirectedParticleEmitter;
  48967. /**
  48968. * Called by the GPUParticleSystem to setup the update shader
  48969. * @param effect defines the update shader
  48970. */
  48971. applyToShader(effect: Effect): void;
  48972. /**
  48973. * Returns a string to use to update the GPU particles update shader
  48974. * @returns a string containng the defines string
  48975. */
  48976. getEffectDefines(): string;
  48977. /**
  48978. * Returns the string "CylinderDirectedParticleEmitter"
  48979. * @returns a string containing the class name
  48980. */
  48981. getClassName(): string;
  48982. /**
  48983. * Serializes the particle system to a JSON object.
  48984. * @returns the JSON object
  48985. */
  48986. serialize(): any;
  48987. /**
  48988. * Parse properties from a JSON object
  48989. * @param serializationObject defines the JSON object
  48990. */
  48991. parse(serializationObject: any): void;
  48992. }
  48993. }
  48994. declare module BABYLON {
  48995. /**
  48996. * Particle emitter emitting particles from the inside of a hemisphere.
  48997. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  48998. */
  48999. class HemisphericParticleEmitter implements IParticleEmitterType {
  49000. /**
  49001. * The radius of the emission hemisphere.
  49002. */
  49003. radius: number;
  49004. /**
  49005. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49006. */
  49007. radiusRange: number;
  49008. /**
  49009. * How much to randomize the particle direction [0-1].
  49010. */
  49011. directionRandomizer: number;
  49012. /**
  49013. * Creates a new instance HemisphericParticleEmitter
  49014. * @param radius the radius of the emission hemisphere (1 by default)
  49015. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49016. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49017. */
  49018. constructor(
  49019. /**
  49020. * The radius of the emission hemisphere.
  49021. */
  49022. radius?: number,
  49023. /**
  49024. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49025. */
  49026. radiusRange?: number,
  49027. /**
  49028. * How much to randomize the particle direction [0-1].
  49029. */
  49030. directionRandomizer?: number);
  49031. /**
  49032. * Called by the particle System when the direction is computed for the created particle.
  49033. * @param worldMatrix is the world matrix of the particle system
  49034. * @param directionToUpdate is the direction vector to update with the result
  49035. * @param particle is the particle we are computed the direction for
  49036. */
  49037. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49038. /**
  49039. * Called by the particle System when the position is computed for the created particle.
  49040. * @param worldMatrix is the world matrix of the particle system
  49041. * @param positionToUpdate is the position vector to update with the result
  49042. * @param particle is the particle we are computed the position for
  49043. */
  49044. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49045. /**
  49046. * Clones the current emitter and returns a copy of it
  49047. * @returns the new emitter
  49048. */
  49049. clone(): HemisphericParticleEmitter;
  49050. /**
  49051. * Called by the GPUParticleSystem to setup the update shader
  49052. * @param effect defines the update shader
  49053. */
  49054. applyToShader(effect: Effect): void;
  49055. /**
  49056. * Returns a string to use to update the GPU particles update shader
  49057. * @returns a string containng the defines string
  49058. */
  49059. getEffectDefines(): string;
  49060. /**
  49061. * Returns the string "HemisphericParticleEmitter"
  49062. * @returns a string containing the class name
  49063. */
  49064. getClassName(): string;
  49065. /**
  49066. * Serializes the particle system to a JSON object.
  49067. * @returns the JSON object
  49068. */
  49069. serialize(): any;
  49070. /**
  49071. * Parse properties from a JSON object
  49072. * @param serializationObject defines the JSON object
  49073. */
  49074. parse(serializationObject: any): void;
  49075. }
  49076. }
  49077. declare module BABYLON {
  49078. /**
  49079. * Particle emitter represents a volume emitting particles.
  49080. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  49081. */
  49082. interface IParticleEmitterType {
  49083. /**
  49084. * Called by the particle System when the direction is computed for the created particle.
  49085. * @param worldMatrix is the world matrix of the particle system
  49086. * @param directionToUpdate is the direction vector to update with the result
  49087. * @param particle is the particle we are computed the direction for
  49088. */
  49089. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49090. /**
  49091. * Called by the particle System when the position is computed for the created particle.
  49092. * @param worldMatrix is the world matrix of the particle system
  49093. * @param positionToUpdate is the position vector to update with the result
  49094. * @param particle is the particle we are computed the position for
  49095. */
  49096. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49097. /**
  49098. * Clones the current emitter and returns a copy of it
  49099. * @returns the new emitter
  49100. */
  49101. clone(): IParticleEmitterType;
  49102. /**
  49103. * Called by the GPUParticleSystem to setup the update shader
  49104. * @param effect defines the update shader
  49105. */
  49106. applyToShader(effect: Effect): void;
  49107. /**
  49108. * Returns a string to use to update the GPU particles update shader
  49109. * @returns the effect defines string
  49110. */
  49111. getEffectDefines(): string;
  49112. /**
  49113. * Returns a string representing the class name
  49114. * @returns a string containing the class name
  49115. */
  49116. getClassName(): string;
  49117. /**
  49118. * Serializes the particle system to a JSON object.
  49119. * @returns the JSON object
  49120. */
  49121. serialize(): any;
  49122. /**
  49123. * Parse properties from a JSON object
  49124. * @param serializationObject defines the JSON object
  49125. */
  49126. parse(serializationObject: any): void;
  49127. }
  49128. }
  49129. declare module BABYLON {
  49130. /**
  49131. * Particle emitter emitting particles from a point.
  49132. * It emits the particles randomly between 2 given directions.
  49133. */
  49134. class PointParticleEmitter implements IParticleEmitterType {
  49135. /**
  49136. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49137. */
  49138. direction1: Vector3;
  49139. /**
  49140. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49141. */
  49142. direction2: Vector3;
  49143. /**
  49144. * Creates a new instance PointParticleEmitter
  49145. */
  49146. constructor();
  49147. /**
  49148. * Called by the particle System when the direction is computed for the created particle.
  49149. * @param worldMatrix is the world matrix of the particle system
  49150. * @param directionToUpdate is the direction vector to update with the result
  49151. * @param particle is the particle we are computed the direction for
  49152. */
  49153. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49154. /**
  49155. * Called by the particle System when the position is computed for the created particle.
  49156. * @param worldMatrix is the world matrix of the particle system
  49157. * @param positionToUpdate is the position vector to update with the result
  49158. * @param particle is the particle we are computed the position for
  49159. */
  49160. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49161. /**
  49162. * Clones the current emitter and returns a copy of it
  49163. * @returns the new emitter
  49164. */
  49165. clone(): PointParticleEmitter;
  49166. /**
  49167. * Called by the GPUParticleSystem to setup the update shader
  49168. * @param effect defines the update shader
  49169. */
  49170. applyToShader(effect: Effect): void;
  49171. /**
  49172. * Returns a string to use to update the GPU particles update shader
  49173. * @returns a string containng the defines string
  49174. */
  49175. getEffectDefines(): string;
  49176. /**
  49177. * Returns the string "PointParticleEmitter"
  49178. * @returns a string containing the class name
  49179. */
  49180. getClassName(): string;
  49181. /**
  49182. * Serializes the particle system to a JSON object.
  49183. * @returns the JSON object
  49184. */
  49185. serialize(): any;
  49186. /**
  49187. * Parse properties from a JSON object
  49188. * @param serializationObject defines the JSON object
  49189. */
  49190. parse(serializationObject: any): void;
  49191. }
  49192. }
  49193. declare module BABYLON {
  49194. /**
  49195. * Particle emitter emitting particles from the inside of a sphere.
  49196. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  49197. */
  49198. class SphereParticleEmitter implements IParticleEmitterType {
  49199. /**
  49200. * The radius of the emission sphere.
  49201. */
  49202. radius: number;
  49203. /**
  49204. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49205. */
  49206. radiusRange: number;
  49207. /**
  49208. * How much to randomize the particle direction [0-1].
  49209. */
  49210. directionRandomizer: number;
  49211. /**
  49212. * Creates a new instance SphereParticleEmitter
  49213. * @param radius the radius of the emission sphere (1 by default)
  49214. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49215. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49216. */
  49217. constructor(
  49218. /**
  49219. * The radius of the emission sphere.
  49220. */
  49221. radius?: number,
  49222. /**
  49223. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49224. */
  49225. radiusRange?: number,
  49226. /**
  49227. * How much to randomize the particle direction [0-1].
  49228. */
  49229. directionRandomizer?: number);
  49230. /**
  49231. * Called by the particle System when the direction is computed for the created particle.
  49232. * @param worldMatrix is the world matrix of the particle system
  49233. * @param directionToUpdate is the direction vector to update with the result
  49234. * @param particle is the particle we are computed the direction for
  49235. */
  49236. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49237. /**
  49238. * Called by the particle System when the position is computed for the created particle.
  49239. * @param worldMatrix is the world matrix of the particle system
  49240. * @param positionToUpdate is the position vector to update with the result
  49241. * @param particle is the particle we are computed the position for
  49242. */
  49243. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49244. /**
  49245. * Clones the current emitter and returns a copy of it
  49246. * @returns the new emitter
  49247. */
  49248. clone(): SphereParticleEmitter;
  49249. /**
  49250. * Called by the GPUParticleSystem to setup the update shader
  49251. * @param effect defines the update shader
  49252. */
  49253. applyToShader(effect: Effect): void;
  49254. /**
  49255. * Returns a string to use to update the GPU particles update shader
  49256. * @returns a string containng the defines string
  49257. */
  49258. getEffectDefines(): string;
  49259. /**
  49260. * Returns the string "SphereParticleEmitter"
  49261. * @returns a string containing the class name
  49262. */
  49263. getClassName(): string;
  49264. /**
  49265. * Serializes the particle system to a JSON object.
  49266. * @returns the JSON object
  49267. */
  49268. serialize(): any;
  49269. /**
  49270. * Parse properties from a JSON object
  49271. * @param serializationObject defines the JSON object
  49272. */
  49273. parse(serializationObject: any): void;
  49274. }
  49275. /**
  49276. * Particle emitter emitting particles from the inside of a sphere.
  49277. * It emits the particles randomly between two vectors.
  49278. */
  49279. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  49280. /**
  49281. * The min limit of the emission direction.
  49282. */
  49283. direction1: Vector3;
  49284. /**
  49285. * The max limit of the emission direction.
  49286. */
  49287. direction2: Vector3;
  49288. /**
  49289. * Creates a new instance SphereDirectedParticleEmitter
  49290. * @param radius the radius of the emission sphere (1 by default)
  49291. * @param direction1 the min limit of the emission direction (up vector by default)
  49292. * @param direction2 the max limit of the emission direction (up vector by default)
  49293. */
  49294. constructor(radius?: number,
  49295. /**
  49296. * The min limit of the emission direction.
  49297. */
  49298. direction1?: Vector3,
  49299. /**
  49300. * The max limit of the emission direction.
  49301. */
  49302. direction2?: Vector3);
  49303. /**
  49304. * Called by the particle System when the direction is computed for the created particle.
  49305. * @param worldMatrix is the world matrix of the particle system
  49306. * @param directionToUpdate is the direction vector to update with the result
  49307. * @param particle is the particle we are computed the direction for
  49308. */
  49309. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49310. /**
  49311. * Clones the current emitter and returns a copy of it
  49312. * @returns the new emitter
  49313. */
  49314. clone(): SphereDirectedParticleEmitter;
  49315. /**
  49316. * Called by the GPUParticleSystem to setup the update shader
  49317. * @param effect defines the update shader
  49318. */
  49319. applyToShader(effect: Effect): void;
  49320. /**
  49321. * Returns a string to use to update the GPU particles update shader
  49322. * @returns a string containng the defines string
  49323. */
  49324. getEffectDefines(): string;
  49325. /**
  49326. * Returns the string "SphereDirectedParticleEmitter"
  49327. * @returns a string containing the class name
  49328. */
  49329. getClassName(): string;
  49330. /**
  49331. * Serializes the particle system to a JSON object.
  49332. * @returns the JSON object
  49333. */
  49334. serialize(): any;
  49335. /**
  49336. * Parse properties from a JSON object
  49337. * @param serializationObject defines the JSON object
  49338. */
  49339. parse(serializationObject: any): void;
  49340. }
  49341. }
  49342. declare module BABYLON {
  49343. /**
  49344. * AmmoJS Physics plugin
  49345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49346. * @see https://github.com/kripken/ammo.js/
  49347. */
  49348. class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49349. private _useDeltaForWorldStep;
  49350. /**
  49351. * Reference to the Ammo library
  49352. */
  49353. bjsAMMO: any;
  49354. /**
  49355. * Created ammoJS world which physics bodies are added to
  49356. */
  49357. world: any;
  49358. /**
  49359. * Name of the plugin
  49360. */
  49361. name: string;
  49362. private _timeStep;
  49363. private _fixedTimeStep;
  49364. private _maxSteps;
  49365. private _tmpQuaternion;
  49366. private _tmpAmmoTransform;
  49367. private _tmpAmmoQuaternion;
  49368. private _tmpAmmoConcreteContactResultCallback;
  49369. private _collisionConfiguration;
  49370. private _dispatcher;
  49371. private _overlappingPairCache;
  49372. private _solver;
  49373. private _tmpAmmoVectorA;
  49374. private _tmpAmmoVectorB;
  49375. private _tmpAmmoVectorC;
  49376. private _tmpContactCallbackResult;
  49377. private static readonly DISABLE_COLLISION_FLAG;
  49378. private static readonly KINEMATIC_FLAG;
  49379. private static readonly DISABLE_DEACTIVATION_FLAG;
  49380. /**
  49381. * Initializes the ammoJS plugin
  49382. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49383. */
  49384. constructor(_useDeltaForWorldStep?: boolean);
  49385. /**
  49386. * Sets the gravity of the physics world (m/(s^2))
  49387. * @param gravity Gravity to set
  49388. */
  49389. setGravity(gravity: Vector3): void;
  49390. /**
  49391. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49392. * @param timeStep timestep to use in seconds
  49393. */
  49394. setTimeStep(timeStep: number): void;
  49395. /**
  49396. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  49397. * @param fixedTimeStep fixedTimeStep to use in seconds
  49398. */
  49399. setFixedTimeStep(fixedTimeStep: number): void;
  49400. /**
  49401. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49402. * @param maxSteps the maximum number of steps by the physics engine per frame
  49403. */
  49404. setMaxSteps(maxSteps: number): void;
  49405. /**
  49406. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49407. * @returns the current timestep in seconds
  49408. */
  49409. getTimeStep(): number;
  49410. private _isImpostorInContact;
  49411. private _isImpostorPairInContact;
  49412. private _stepSimulation;
  49413. /**
  49414. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49415. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49416. * After the step the babylon meshes are set to the position of the physics imposters
  49417. * @param delta amount of time to step forward
  49418. * @param impostors array of imposters to update before/after the step
  49419. */
  49420. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49421. /**
  49422. * Applies an implulse on the imposter
  49423. * @param impostor imposter to apply impulse
  49424. * @param force amount of force to be applied to the imposter
  49425. * @param contactPoint the location to apply the impulse on the imposter
  49426. */
  49427. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49428. /**
  49429. * Applies a force on the imposter
  49430. * @param impostor imposter to apply force
  49431. * @param force amount of force to be applied to the imposter
  49432. * @param contactPoint the location to apply the force on the imposter
  49433. */
  49434. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49435. /**
  49436. * Creates a physics body using the plugin
  49437. * @param impostor the imposter to create the physics body on
  49438. */
  49439. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49440. /**
  49441. * Removes the physics body from the imposter and disposes of the body's memory
  49442. * @param impostor imposter to remove the physics body from
  49443. */
  49444. removePhysicsBody(impostor: PhysicsImpostor): void;
  49445. /**
  49446. * Generates a joint
  49447. * @param impostorJoint the imposter joint to create the joint with
  49448. */
  49449. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49450. /**
  49451. * Removes a joint
  49452. * @param impostorJoint the imposter joint to remove the joint from
  49453. */
  49454. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49455. private _addMeshVerts;
  49456. private _createShape;
  49457. /**
  49458. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49459. * @param impostor imposter containing the physics body and babylon object
  49460. */
  49461. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49462. /**
  49463. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49464. * @param impostor imposter containing the physics body and babylon object
  49465. * @param newPosition new position
  49466. * @param newRotation new rotation
  49467. */
  49468. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49469. /**
  49470. * If this plugin is supported
  49471. * @returns true if its supported
  49472. */
  49473. isSupported(): boolean;
  49474. /**
  49475. * Sets the linear velocity of the physics body
  49476. * @param impostor imposter to set the velocity on
  49477. * @param velocity velocity to set
  49478. */
  49479. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49480. /**
  49481. * Sets the angular velocity of the physics body
  49482. * @param impostor imposter to set the velocity on
  49483. * @param velocity velocity to set
  49484. */
  49485. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49486. /**
  49487. * gets the linear velocity
  49488. * @param impostor imposter to get linear velocity from
  49489. * @returns linear velocity
  49490. */
  49491. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49492. /**
  49493. * gets the angular velocity
  49494. * @param impostor imposter to get angular velocity from
  49495. * @returns angular velocity
  49496. */
  49497. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49498. /**
  49499. * Sets the mass of physics body
  49500. * @param impostor imposter to set the mass on
  49501. * @param mass mass to set
  49502. */
  49503. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49504. /**
  49505. * Gets the mass of the physics body
  49506. * @param impostor imposter to get the mass from
  49507. * @returns mass
  49508. */
  49509. getBodyMass(impostor: PhysicsImpostor): number;
  49510. /**
  49511. * Gets friction of the impostor
  49512. * @param impostor impostor to get friction from
  49513. * @returns friction value
  49514. */
  49515. getBodyFriction(impostor: PhysicsImpostor): number;
  49516. /**
  49517. * Sets friction of the impostor
  49518. * @param impostor impostor to set friction on
  49519. * @param friction friction value
  49520. */
  49521. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49522. /**
  49523. * Gets restitution of the impostor
  49524. * @param impostor impostor to get restitution from
  49525. * @returns restitution value
  49526. */
  49527. getBodyRestitution(impostor: PhysicsImpostor): number;
  49528. /**
  49529. * Sets resitution of the impostor
  49530. * @param impostor impostor to set resitution on
  49531. * @param restitution resitution value
  49532. */
  49533. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49534. /**
  49535. * Sleeps the physics body and stops it from being active
  49536. * @param impostor impostor to sleep
  49537. */
  49538. sleepBody(impostor: PhysicsImpostor): void;
  49539. /**
  49540. * Activates the physics body
  49541. * @param impostor impostor to activate
  49542. */
  49543. wakeUpBody(impostor: PhysicsImpostor): void;
  49544. /**
  49545. * Updates the distance parameters of the joint
  49546. * @param joint joint to update
  49547. * @param maxDistance maximum distance of the joint
  49548. * @param minDistance minimum distance of the joint
  49549. */
  49550. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49551. /**
  49552. * Sets a motor on the joint
  49553. * @param joint joint to set motor on
  49554. * @param speed speed of the motor
  49555. * @param maxForce maximum force of the motor
  49556. * @param motorIndex index of the motor
  49557. */
  49558. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49559. /**
  49560. * Sets the motors limit
  49561. * @param joint joint to set limit on
  49562. * @param upperLimit upper limit
  49563. * @param lowerLimit lower limit
  49564. */
  49565. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49566. /**
  49567. * Syncs the position and rotation of a mesh with the impostor
  49568. * @param mesh mesh to sync
  49569. * @param impostor impostor to update the mesh with
  49570. */
  49571. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49572. /**
  49573. * Gets the radius of the impostor
  49574. * @param impostor impostor to get radius from
  49575. * @returns the radius
  49576. */
  49577. getRadius(impostor: PhysicsImpostor): number;
  49578. /**
  49579. * Gets the box size of the impostor
  49580. * @param impostor impostor to get box size from
  49581. * @param result the resulting box size
  49582. */
  49583. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49584. /**
  49585. * Disposes of the impostor
  49586. */
  49587. dispose(): void;
  49588. }
  49589. }
  49590. declare module BABYLON {
  49591. /** @hidden */
  49592. class CannonJSPlugin implements IPhysicsEnginePlugin {
  49593. private _useDeltaForWorldStep;
  49594. world: any;
  49595. name: string;
  49596. private _physicsMaterials;
  49597. private _fixedTimeStep;
  49598. BJSCANNON: any;
  49599. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  49600. setGravity(gravity: Vector3): void;
  49601. setTimeStep(timeStep: number): void;
  49602. getTimeStep(): number;
  49603. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49604. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49605. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49606. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49607. private _processChildMeshes;
  49608. removePhysicsBody(impostor: PhysicsImpostor): void;
  49609. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49610. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49611. private _addMaterial;
  49612. private _checkWithEpsilon;
  49613. private _createShape;
  49614. private _createHeightmap;
  49615. private _minus90X;
  49616. private _plus90X;
  49617. private _tmpPosition;
  49618. private _tmpDeltaPosition;
  49619. private _tmpUnityRotation;
  49620. private _updatePhysicsBodyTransformation;
  49621. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49622. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49623. isSupported(): boolean;
  49624. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49625. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49626. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49627. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49628. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49629. getBodyMass(impostor: PhysicsImpostor): number;
  49630. getBodyFriction(impostor: PhysicsImpostor): number;
  49631. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49632. getBodyRestitution(impostor: PhysicsImpostor): number;
  49633. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49634. sleepBody(impostor: PhysicsImpostor): void;
  49635. wakeUpBody(impostor: PhysicsImpostor): void;
  49636. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49637. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49638. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49639. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49640. getRadius(impostor: PhysicsImpostor): number;
  49641. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49642. dispose(): void;
  49643. private _extendNamespace;
  49644. }
  49645. }
  49646. declare module BABYLON {
  49647. /** @hidden */
  49648. class OimoJSPlugin implements IPhysicsEnginePlugin {
  49649. world: any;
  49650. name: string;
  49651. BJSOIMO: any;
  49652. constructor(iterations?: number);
  49653. setGravity(gravity: Vector3): void;
  49654. setTimeStep(timeStep: number): void;
  49655. getTimeStep(): number;
  49656. private _tmpImpostorsArray;
  49657. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49658. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49659. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49660. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49661. private _tmpPositionVector;
  49662. removePhysicsBody(impostor: PhysicsImpostor): void;
  49663. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49664. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49665. isSupported(): boolean;
  49666. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49667. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49668. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49669. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49670. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49671. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49672. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49673. getBodyMass(impostor: PhysicsImpostor): number;
  49674. getBodyFriction(impostor: PhysicsImpostor): number;
  49675. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49676. getBodyRestitution(impostor: PhysicsImpostor): number;
  49677. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49678. sleepBody(impostor: PhysicsImpostor): void;
  49679. wakeUpBody(impostor: PhysicsImpostor): void;
  49680. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49681. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  49682. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49683. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49684. getRadius(impostor: PhysicsImpostor): number;
  49685. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49686. dispose(): void;
  49687. }
  49688. }
  49689. declare module BABYLON {
  49690. /**
  49691. * This represents a set of one or more post processes in Babylon.
  49692. * A post process can be used to apply a shader to a texture after it is rendered.
  49693. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49694. */
  49695. class PostProcessRenderEffect {
  49696. private _postProcesses;
  49697. private _getPostProcesses;
  49698. private _singleInstance;
  49699. private _cameras;
  49700. private _indicesForCamera;
  49701. /**
  49702. * Name of the effect
  49703. * @hidden
  49704. */
  49705. _name: string;
  49706. /**
  49707. * Instantiates a post process render effect.
  49708. * A post process can be used to apply a shader to a texture after it is rendered.
  49709. * @param engine The engine the effect is tied to
  49710. * @param name The name of the effect
  49711. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49712. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49713. */
  49714. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49715. /**
  49716. * Checks if all the post processes in the effect are supported.
  49717. */
  49718. readonly isSupported: boolean;
  49719. /**
  49720. * Updates the current state of the effect
  49721. * @hidden
  49722. */
  49723. _update(): void;
  49724. /**
  49725. * Attaches the effect on cameras
  49726. * @param cameras The camera to attach to.
  49727. * @hidden
  49728. */
  49729. _attachCameras(cameras: Camera): void;
  49730. /**
  49731. * Attaches the effect on cameras
  49732. * @param cameras The camera to attach to.
  49733. * @hidden
  49734. */
  49735. _attachCameras(cameras: Camera[]): void;
  49736. /**
  49737. * Detatches the effect on cameras
  49738. * @param cameras The camera to detatch from.
  49739. * @hidden
  49740. */
  49741. _detachCameras(cameras: Camera): void;
  49742. /**
  49743. * Detatches the effect on cameras
  49744. * @param cameras The camera to detatch from.
  49745. * @hidden
  49746. */
  49747. _detachCameras(cameras: Camera[]): void;
  49748. /**
  49749. * Enables the effect on given cameras
  49750. * @param cameras The camera to enable.
  49751. * @hidden
  49752. */
  49753. _enable(cameras: Camera): void;
  49754. /**
  49755. * Enables the effect on given cameras
  49756. * @param cameras The camera to enable.
  49757. * @hidden
  49758. */
  49759. _enable(cameras: Nullable<Camera[]>): void;
  49760. /**
  49761. * Disables the effect on the given cameras
  49762. * @param cameras The camera to disable.
  49763. * @hidden
  49764. */
  49765. _disable(cameras: Camera): void;
  49766. /**
  49767. * Disables the effect on the given cameras
  49768. * @param cameras The camera to disable.
  49769. * @hidden
  49770. */
  49771. _disable(cameras: Nullable<Camera[]>): void;
  49772. /**
  49773. * Gets a list of the post processes contained in the effect.
  49774. * @param camera The camera to get the post processes on.
  49775. * @returns The list of the post processes in the effect.
  49776. */
  49777. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49778. }
  49779. }
  49780. declare module BABYLON {
  49781. /**
  49782. * PostProcessRenderPipeline
  49783. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49784. */
  49785. class PostProcessRenderPipeline {
  49786. private engine;
  49787. private _renderEffects;
  49788. private _renderEffectsForIsolatedPass;
  49789. /**
  49790. * @hidden
  49791. */
  49792. protected _cameras: Camera[];
  49793. /** @hidden */
  49794. _name: string;
  49795. /**
  49796. * Initializes a PostProcessRenderPipeline
  49797. * @param engine engine to add the pipeline to
  49798. * @param name name of the pipeline
  49799. */
  49800. constructor(engine: Engine, name: string);
  49801. /**
  49802. * "PostProcessRenderPipeline"
  49803. * @returns "PostProcessRenderPipeline"
  49804. */
  49805. getClassName(): string;
  49806. /**
  49807. * If all the render effects in the pipeline are support
  49808. */
  49809. readonly isSupported: boolean;
  49810. /**
  49811. * Adds an effect to the pipeline
  49812. * @param renderEffect the effect to add
  49813. */
  49814. addEffect(renderEffect: PostProcessRenderEffect): void;
  49815. /** @hidden */
  49816. _rebuild(): void;
  49817. /** @hidden */
  49818. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49819. /** @hidden */
  49820. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49821. /** @hidden */
  49822. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49823. /** @hidden */
  49824. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49825. /** @hidden */
  49826. _attachCameras(cameras: Camera, unique: boolean): void;
  49827. /** @hidden */
  49828. _attachCameras(cameras: Camera[], unique: boolean): void;
  49829. /** @hidden */
  49830. _detachCameras(cameras: Camera): void;
  49831. /** @hidden */
  49832. _detachCameras(cameras: Nullable<Camera[]>): void;
  49833. /** @hidden */
  49834. _update(): void;
  49835. /** @hidden */
  49836. _reset(): void;
  49837. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49838. /**
  49839. * Disposes of the pipeline
  49840. */
  49841. dispose(): void;
  49842. }
  49843. }
  49844. declare module BABYLON {
  49845. /**
  49846. * PostProcessRenderPipelineManager class
  49847. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49848. */
  49849. class PostProcessRenderPipelineManager {
  49850. private _renderPipelines;
  49851. /**
  49852. * Initializes a PostProcessRenderPipelineManager
  49853. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49854. */
  49855. constructor();
  49856. /**
  49857. * Adds a pipeline to the manager
  49858. * @param renderPipeline The pipeline to add
  49859. */
  49860. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  49861. /**
  49862. * Attaches a camera to the pipeline
  49863. * @param renderPipelineName The name of the pipeline to attach to
  49864. * @param cameras the camera to attach
  49865. * @param unique if the camera can be attached multiple times to the pipeline
  49866. */
  49867. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  49868. /**
  49869. * Detaches a camera from the pipeline
  49870. * @param renderPipelineName The name of the pipeline to detach from
  49871. * @param cameras the camera to detach
  49872. */
  49873. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  49874. /**
  49875. * Enables an effect by name on a pipeline
  49876. * @param renderPipelineName the name of the pipeline to enable the effect in
  49877. * @param renderEffectName the name of the effect to enable
  49878. * @param cameras the cameras that the effect should be enabled on
  49879. */
  49880. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49881. /**
  49882. * Disables an effect by name on a pipeline
  49883. * @param renderPipelineName the name of the pipeline to disable the effect in
  49884. * @param renderEffectName the name of the effect to disable
  49885. * @param cameras the cameras that the effect should be disabled on
  49886. */
  49887. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49888. /**
  49889. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  49890. */
  49891. update(): void;
  49892. /** @hidden */
  49893. _rebuild(): void;
  49894. /**
  49895. * Disposes of the manager and pipelines
  49896. */
  49897. dispose(): void;
  49898. }
  49899. }
  49900. declare module BABYLON {
  49901. interface Scene {
  49902. /** @hidden (Backing field) */
  49903. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49904. /**
  49905. * Gets the postprocess render pipeline manager
  49906. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49907. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49908. */
  49909. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49910. }
  49911. /**
  49912. * Defines the Render Pipeline scene component responsible to rendering pipelines
  49913. */
  49914. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  49915. /**
  49916. * The component name helpfull to identify the component in the list of scene components.
  49917. */
  49918. readonly name: string;
  49919. /**
  49920. * The scene the component belongs to.
  49921. */
  49922. scene: Scene;
  49923. /**
  49924. * Creates a new instance of the component for the given scene
  49925. * @param scene Defines the scene to register the component in
  49926. */
  49927. constructor(scene: Scene);
  49928. /**
  49929. * Registers the component in a given scene
  49930. */
  49931. register(): void;
  49932. /**
  49933. * Rebuilds the elements related to this component in case of
  49934. * context lost for instance.
  49935. */
  49936. rebuild(): void;
  49937. /**
  49938. * Disposes the component and the associated ressources
  49939. */
  49940. dispose(): void;
  49941. private _gatherRenderTargets;
  49942. }
  49943. }
  49944. declare module BABYLON {
  49945. /**
  49946. * Helper class dealing with the extraction of spherical polynomial dataArray
  49947. * from a cube map.
  49948. */
  49949. class CubeMapToSphericalPolynomialTools {
  49950. private static FileFaces;
  49951. /**
  49952. * Converts a texture to the according Spherical Polynomial data.
  49953. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49954. *
  49955. * @param texture The texture to extract the information from.
  49956. * @return The Spherical Polynomial data.
  49957. */
  49958. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49959. /**
  49960. * Converts a cubemap to the according Spherical Polynomial data.
  49961. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49962. *
  49963. * @param cubeInfo The Cube map to extract the information from.
  49964. * @return The Spherical Polynomial data.
  49965. */
  49966. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49967. }
  49968. }
  49969. declare module BABYLON {
  49970. /**
  49971. * Header information of HDR texture files.
  49972. */
  49973. interface HDRInfo {
  49974. /**
  49975. * The height of the texture in pixels.
  49976. */
  49977. height: number;
  49978. /**
  49979. * The width of the texture in pixels.
  49980. */
  49981. width: number;
  49982. /**
  49983. * The index of the beginning of the data in the binary file.
  49984. */
  49985. dataPosition: number;
  49986. }
  49987. /**
  49988. * This groups tools to convert HDR texture to native colors array.
  49989. */
  49990. class HDRTools {
  49991. private static Ldexp;
  49992. private static Rgbe2float;
  49993. private static readStringLine;
  49994. /**
  49995. * Reads header information from an RGBE texture stored in a native array.
  49996. * More information on this format are available here:
  49997. * https://en.wikipedia.org/wiki/RGBE_image_format
  49998. *
  49999. * @param uint8array The binary file stored in native array.
  50000. * @return The header information.
  50001. */
  50002. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50003. /**
  50004. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50005. * This RGBE texture needs to store the information as a panorama.
  50006. *
  50007. * More information on this format are available here:
  50008. * https://en.wikipedia.org/wiki/RGBE_image_format
  50009. *
  50010. * @param buffer The binary file stored in an array buffer.
  50011. * @param size The expected size of the extracted cubemap.
  50012. * @return The Cube Map information.
  50013. */
  50014. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50015. /**
  50016. * Returns the pixels data extracted from an RGBE texture.
  50017. * This pixels will be stored left to right up to down in the R G B order in one array.
  50018. *
  50019. * More information on this format are available here:
  50020. * https://en.wikipedia.org/wiki/RGBE_image_format
  50021. *
  50022. * @param uint8array The binary file stored in an array buffer.
  50023. * @param hdrInfo The header information of the file.
  50024. * @return The pixels data in RGB right to left up to down order.
  50025. */
  50026. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50027. private static RGBE_ReadPixels_RLE;
  50028. }
  50029. }
  50030. declare module BABYLON {
  50031. /**
  50032. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  50033. */
  50034. interface CubeMapInfo {
  50035. /**
  50036. * The pixel array for the front face.
  50037. * This is stored in format, left to right, up to down format.
  50038. */
  50039. front: Nullable<ArrayBufferView>;
  50040. /**
  50041. * The pixel array for the back face.
  50042. * This is stored in format, left to right, up to down format.
  50043. */
  50044. back: Nullable<ArrayBufferView>;
  50045. /**
  50046. * The pixel array for the left face.
  50047. * This is stored in format, left to right, up to down format.
  50048. */
  50049. left: Nullable<ArrayBufferView>;
  50050. /**
  50051. * The pixel array for the right face.
  50052. * This is stored in format, left to right, up to down format.
  50053. */
  50054. right: Nullable<ArrayBufferView>;
  50055. /**
  50056. * The pixel array for the up face.
  50057. * This is stored in format, left to right, up to down format.
  50058. */
  50059. up: Nullable<ArrayBufferView>;
  50060. /**
  50061. * The pixel array for the down face.
  50062. * This is stored in format, left to right, up to down format.
  50063. */
  50064. down: Nullable<ArrayBufferView>;
  50065. /**
  50066. * The size of the cubemap stored.
  50067. *
  50068. * Each faces will be size * size pixels.
  50069. */
  50070. size: number;
  50071. /**
  50072. * The format of the texture.
  50073. *
  50074. * RGBA, RGB.
  50075. */
  50076. format: number;
  50077. /**
  50078. * The type of the texture data.
  50079. *
  50080. * UNSIGNED_INT, FLOAT.
  50081. */
  50082. type: number;
  50083. /**
  50084. * Specifies whether the texture is in gamma space.
  50085. */
  50086. gammaSpace: boolean;
  50087. }
  50088. /**
  50089. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50090. */
  50091. class PanoramaToCubeMapTools {
  50092. private static FACE_FRONT;
  50093. private static FACE_BACK;
  50094. private static FACE_RIGHT;
  50095. private static FACE_LEFT;
  50096. private static FACE_DOWN;
  50097. private static FACE_UP;
  50098. /**
  50099. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50100. *
  50101. * @param float32Array The source data.
  50102. * @param inputWidth The width of the input panorama.
  50103. * @param inputHeight The height of the input panorama.
  50104. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50105. * @return The cubemap data
  50106. */
  50107. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50108. private static CreateCubemapTexture;
  50109. private static CalcProjectionSpherical;
  50110. }
  50111. }
  50112. declare module BABYLON {
  50113. }
  50114. declare module BABYLON {
  50115. }
  50116. declare module BABYLON {
  50117. }
  50118. declare module BABYLON {
  50119. }
  50120. declare module BABYLON {
  50121. /**
  50122. * 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.
  50123. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50124. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50125. */
  50126. class CustomProceduralTexture extends ProceduralTexture {
  50127. private _animate;
  50128. private _time;
  50129. private _config;
  50130. private _texturePath;
  50131. /**
  50132. * Instantiates a new Custom Procedural Texture.
  50133. * 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.
  50134. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50135. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50136. * @param name Define the name of the texture
  50137. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50138. * @param size Define the size of the texture to create
  50139. * @param scene Define the scene the texture belongs to
  50140. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50141. * @param generateMipMaps Define if the texture should creates mip maps or not
  50142. */
  50143. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50144. private _loadJson;
  50145. /**
  50146. * Is the texture ready to be used ? (rendered at least once)
  50147. * @returns true if ready, otherwise, false.
  50148. */
  50149. isReady(): boolean;
  50150. /**
  50151. * Render the texture to its associated render target.
  50152. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50153. */
  50154. render(useCameraPostProcess?: boolean): void;
  50155. /**
  50156. * Update the list of dependant textures samplers in the shader.
  50157. */
  50158. updateTextures(): void;
  50159. /**
  50160. * Update the uniform values of the procedural texture in the shader.
  50161. */
  50162. updateShaderUniforms(): void;
  50163. /**
  50164. * Define if the texture animates or not.
  50165. */
  50166. animate: boolean;
  50167. }
  50168. }
  50169. declare module BABYLON {
  50170. /**
  50171. * Class used to generate noise procedural textures
  50172. */
  50173. class NoiseProceduralTexture extends ProceduralTexture {
  50174. private _time;
  50175. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50176. brightness: number;
  50177. /** Defines the number of octaves to process */
  50178. octaves: number;
  50179. /** Defines the level of persistence (0.8 by default) */
  50180. persistence: number;
  50181. /** Gets or sets animation speed factor (default is 1) */
  50182. animationSpeedFactor: number;
  50183. /**
  50184. * Creates a new NoiseProceduralTexture
  50185. * @param name defines the name fo the texture
  50186. * @param size defines the size of the texture (default is 256)
  50187. * @param scene defines the hosting scene
  50188. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50189. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50190. */
  50191. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50192. private _updateShaderUniforms;
  50193. protected _getDefines(): string;
  50194. /** Generate the current state of the procedural texture */
  50195. render(useCameraPostProcess?: boolean): void;
  50196. /**
  50197. * Serializes this noise procedural texture
  50198. * @returns a serialized noise procedural texture object
  50199. */
  50200. serialize(): any;
  50201. /**
  50202. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50203. * @param parsedTexture defines parsed texture data
  50204. * @param scene defines the current scene
  50205. * @param rootUrl defines the root URL containing noise procedural texture information
  50206. * @returns a parsed NoiseProceduralTexture
  50207. */
  50208. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  50209. }
  50210. }
  50211. declare module BABYLON {
  50212. /**
  50213. * 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.
  50214. * This is the base class of any Procedural texture and contains most of the shareable code.
  50215. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50216. */
  50217. class ProceduralTexture extends Texture {
  50218. isCube: boolean;
  50219. /**
  50220. * Define if the texture is enabled or not (disabled texture will not render)
  50221. */
  50222. isEnabled: boolean;
  50223. /**
  50224. * Define if the texture must be cleared before rendering (default is true)
  50225. */
  50226. autoClear: boolean;
  50227. /**
  50228. * Callback called when the texture is generated
  50229. */
  50230. onGenerated: () => void;
  50231. /**
  50232. * Event raised when the texture is generated
  50233. */
  50234. onGeneratedObservable: Observable<ProceduralTexture>;
  50235. /** @hidden */
  50236. _generateMipMaps: boolean;
  50237. /** @hidden **/
  50238. _effect: Effect;
  50239. /** @hidden */
  50240. _textures: {
  50241. [key: string]: Texture;
  50242. };
  50243. private _size;
  50244. private _currentRefreshId;
  50245. private _refreshRate;
  50246. private _vertexBuffers;
  50247. private _indexBuffer;
  50248. private _uniforms;
  50249. private _samplers;
  50250. private _fragment;
  50251. private _floats;
  50252. private _ints;
  50253. private _floatsArrays;
  50254. private _colors3;
  50255. private _colors4;
  50256. private _vectors2;
  50257. private _vectors3;
  50258. private _matrices;
  50259. private _fallbackTexture;
  50260. private _fallbackTextureUsed;
  50261. private _engine;
  50262. private _cachedDefines;
  50263. private _contentUpdateId;
  50264. private _contentData;
  50265. /**
  50266. * Instantiates a new procedural texture.
  50267. * 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.
  50268. * This is the base class of any Procedural texture and contains most of the shareable code.
  50269. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50270. * @param name Define the name of the texture
  50271. * @param size Define the size of the texture to create
  50272. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  50273. * @param scene Define the scene the texture belongs to
  50274. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50275. * @param generateMipMaps Define if the texture should creates mip maps or not
  50276. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  50277. */
  50278. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  50279. /**
  50280. * The effect that is created when initializing the post process.
  50281. * @returns The created effect corrisponding the the postprocess.
  50282. */
  50283. getEffect(): Effect;
  50284. /**
  50285. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  50286. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  50287. */
  50288. getContent(): Nullable<ArrayBufferView>;
  50289. private _createIndexBuffer;
  50290. /** @hidden */
  50291. _rebuild(): void;
  50292. /**
  50293. * Resets the texture in order to recreate its associated resources.
  50294. * This can be called in case of context loss
  50295. */
  50296. reset(): void;
  50297. protected _getDefines(): string;
  50298. /**
  50299. * Is the texture ready to be used ? (rendered at least once)
  50300. * @returns true if ready, otherwise, false.
  50301. */
  50302. isReady(): boolean;
  50303. /**
  50304. * Resets the refresh counter of the texture and start bak from scratch.
  50305. * Could be useful to regenerate the texture if it is setup to render only once.
  50306. */
  50307. resetRefreshCounter(): void;
  50308. /**
  50309. * Set the fragment shader to use in order to render the texture.
  50310. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  50311. */
  50312. setFragment(fragment: any): void;
  50313. /**
  50314. * Define the refresh rate of the texture or the rendering frequency.
  50315. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  50316. */
  50317. refreshRate: number;
  50318. /** @hidden */
  50319. _shouldRender(): boolean;
  50320. /**
  50321. * Get the size the texture is rendering at.
  50322. * @returns the size (texture is always squared)
  50323. */
  50324. getRenderSize(): number;
  50325. /**
  50326. * Resize the texture to new value.
  50327. * @param size Define the new size the texture should have
  50328. * @param generateMipMaps Define whether the new texture should create mip maps
  50329. */
  50330. resize(size: number, generateMipMaps: boolean): void;
  50331. private _checkUniform;
  50332. /**
  50333. * Set a texture in the shader program used to render.
  50334. * @param name Define the name of the uniform samplers as defined in the shader
  50335. * @param texture Define the texture to bind to this sampler
  50336. * @return the texture itself allowing "fluent" like uniform updates
  50337. */
  50338. setTexture(name: string, texture: Texture): ProceduralTexture;
  50339. /**
  50340. * Set a float in the shader.
  50341. * @param name Define the name of the uniform as defined in the shader
  50342. * @param value Define the value to give to the uniform
  50343. * @return the texture itself allowing "fluent" like uniform updates
  50344. */
  50345. setFloat(name: string, value: number): ProceduralTexture;
  50346. /**
  50347. * Set a int in the shader.
  50348. * @param name Define the name of the uniform as defined in the shader
  50349. * @param value Define the value to give to the uniform
  50350. * @return the texture itself allowing "fluent" like uniform updates
  50351. */
  50352. setInt(name: string, value: number): ProceduralTexture;
  50353. /**
  50354. * Set an array of floats in the shader.
  50355. * @param name Define the name of the uniform as defined in the shader
  50356. * @param value Define the value to give to the uniform
  50357. * @return the texture itself allowing "fluent" like uniform updates
  50358. */
  50359. setFloats(name: string, value: number[]): ProceduralTexture;
  50360. /**
  50361. * Set a vec3 in the shader from a Color3.
  50362. * @param name Define the name of the uniform as defined in the shader
  50363. * @param value Define the value to give to the uniform
  50364. * @return the texture itself allowing "fluent" like uniform updates
  50365. */
  50366. setColor3(name: string, value: Color3): ProceduralTexture;
  50367. /**
  50368. * Set a vec4 in the shader from a Color4.
  50369. * @param name Define the name of the uniform as defined in the shader
  50370. * @param value Define the value to give to the uniform
  50371. * @return the texture itself allowing "fluent" like uniform updates
  50372. */
  50373. setColor4(name: string, value: Color4): ProceduralTexture;
  50374. /**
  50375. * Set a vec2 in the shader from a Vector2.
  50376. * @param name Define the name of the uniform as defined in the shader
  50377. * @param value Define the value to give to the uniform
  50378. * @return the texture itself allowing "fluent" like uniform updates
  50379. */
  50380. setVector2(name: string, value: Vector2): ProceduralTexture;
  50381. /**
  50382. * Set a vec3 in the shader from a Vector3.
  50383. * @param name Define the name of the uniform as defined in the shader
  50384. * @param value Define the value to give to the uniform
  50385. * @return the texture itself allowing "fluent" like uniform updates
  50386. */
  50387. setVector3(name: string, value: Vector3): ProceduralTexture;
  50388. /**
  50389. * Set a mat4 in the shader from a MAtrix.
  50390. * @param name Define the name of the uniform as defined in the shader
  50391. * @param value Define the value to give to the uniform
  50392. * @return the texture itself allowing "fluent" like uniform updates
  50393. */
  50394. setMatrix(name: string, value: Matrix): ProceduralTexture;
  50395. /**
  50396. * Render the texture to its associated render target.
  50397. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50398. */
  50399. render(useCameraPostProcess?: boolean): void;
  50400. /**
  50401. * Clone the texture.
  50402. * @returns the cloned texture
  50403. */
  50404. clone(): ProceduralTexture;
  50405. /**
  50406. * Dispose the texture and release its asoociated resources.
  50407. */
  50408. dispose(): void;
  50409. }
  50410. }
  50411. declare module BABYLON {
  50412. interface AbstractScene {
  50413. /**
  50414. * The list of procedural textures added to the scene
  50415. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50416. */
  50417. proceduralTextures: Array<ProceduralTexture>;
  50418. }
  50419. /**
  50420. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  50421. * in a given scene.
  50422. */
  50423. class ProceduralTextureSceneComponent implements ISceneComponent {
  50424. /**
  50425. * The component name helpfull to identify the component in the list of scene components.
  50426. */
  50427. readonly name: string;
  50428. /**
  50429. * The scene the component belongs to.
  50430. */
  50431. scene: Scene;
  50432. /**
  50433. * Creates a new instance of the component for the given scene
  50434. * @param scene Defines the scene to register the component in
  50435. */
  50436. constructor(scene: Scene);
  50437. /**
  50438. * Registers the component in a given scene
  50439. */
  50440. register(): void;
  50441. /**
  50442. * Rebuilds the elements related to this component in case of
  50443. * context lost for instance.
  50444. */
  50445. rebuild(): void;
  50446. /**
  50447. * Disposes the component and the associated ressources.
  50448. */
  50449. dispose(): void;
  50450. private _beforeClear;
  50451. }
  50452. }
  50453. declare module BABYLON {
  50454. /**
  50455. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  50456. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50457. */
  50458. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50459. private _scene;
  50460. private _camerasToBeAttached;
  50461. /**
  50462. * ID of the sharpen post process,
  50463. */
  50464. private readonly SharpenPostProcessId;
  50465. /**
  50466. * @ignore
  50467. * ID of the image processing post process;
  50468. */
  50469. readonly ImageProcessingPostProcessId: string;
  50470. /**
  50471. * @ignore
  50472. * ID of the Fast Approximate Anti-Aliasing post process;
  50473. */
  50474. readonly FxaaPostProcessId: string;
  50475. /**
  50476. * ID of the chromatic aberration post process,
  50477. */
  50478. private readonly ChromaticAberrationPostProcessId;
  50479. /**
  50480. * ID of the grain post process
  50481. */
  50482. private readonly GrainPostProcessId;
  50483. /**
  50484. * Sharpen post process which will apply a sharpen convolution to enhance edges
  50485. */
  50486. sharpen: SharpenPostProcess;
  50487. private _sharpenEffect;
  50488. private bloom;
  50489. /**
  50490. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  50491. */
  50492. depthOfField: DepthOfFieldEffect;
  50493. /**
  50494. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50495. */
  50496. fxaa: FxaaPostProcess;
  50497. /**
  50498. * Image post processing pass used to perform operations such as tone mapping or color grading.
  50499. */
  50500. imageProcessing: ImageProcessingPostProcess;
  50501. /**
  50502. * Chromatic aberration post process which will shift rgb colors in the image
  50503. */
  50504. chromaticAberration: ChromaticAberrationPostProcess;
  50505. private _chromaticAberrationEffect;
  50506. /**
  50507. * Grain post process which add noise to the image
  50508. */
  50509. grain: GrainPostProcess;
  50510. private _grainEffect;
  50511. /**
  50512. * Glow post process which adds a glow to emmisive areas of the image
  50513. */
  50514. private _glowLayer;
  50515. /**
  50516. * Animations which can be used to tweak settings over a period of time
  50517. */
  50518. animations: Animation[];
  50519. private _imageProcessingConfigurationObserver;
  50520. private _sharpenEnabled;
  50521. private _bloomEnabled;
  50522. private _depthOfFieldEnabled;
  50523. private _depthOfFieldBlurLevel;
  50524. private _fxaaEnabled;
  50525. private _imageProcessingEnabled;
  50526. private _defaultPipelineTextureType;
  50527. private _bloomScale;
  50528. private _chromaticAberrationEnabled;
  50529. private _grainEnabled;
  50530. private _buildAllowed;
  50531. /**
  50532. * Enable or disable the sharpen process from the pipeline
  50533. */
  50534. sharpenEnabled: boolean;
  50535. private _resizeObserver;
  50536. private _hardwareScaleLevel;
  50537. private _bloomKernel;
  50538. /**
  50539. * Specifies the size of the bloom blur kernel, relative to the final output size
  50540. */
  50541. bloomKernel: number;
  50542. /**
  50543. * Specifies the weight of the bloom in the final rendering
  50544. */
  50545. private _bloomWeight;
  50546. /**
  50547. * Specifies the luma threshold for the area that will be blurred by the bloom
  50548. */
  50549. private _bloomThreshold;
  50550. private _hdr;
  50551. /**
  50552. * The strength of the bloom.
  50553. */
  50554. bloomWeight: number;
  50555. /**
  50556. * The strength of the bloom.
  50557. */
  50558. bloomThreshold: number;
  50559. /**
  50560. * The scale of the bloom, lower value will provide better performance.
  50561. */
  50562. bloomScale: number;
  50563. /**
  50564. * Enable or disable the bloom from the pipeline
  50565. */
  50566. bloomEnabled: boolean;
  50567. private _rebuildBloom;
  50568. /**
  50569. * If the depth of field is enabled.
  50570. */
  50571. depthOfFieldEnabled: boolean;
  50572. /**
  50573. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50574. */
  50575. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50576. /**
  50577. * If the anti aliasing is enabled.
  50578. */
  50579. fxaaEnabled: boolean;
  50580. private _samples;
  50581. /**
  50582. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50583. */
  50584. samples: number;
  50585. /**
  50586. * If image processing is enabled.
  50587. */
  50588. imageProcessingEnabled: boolean;
  50589. /**
  50590. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50591. */
  50592. glowLayerEnabled: boolean;
  50593. /**
  50594. * Enable or disable the chromaticAberration process from the pipeline
  50595. */
  50596. chromaticAberrationEnabled: boolean;
  50597. /**
  50598. * Enable or disable the grain process from the pipeline
  50599. */
  50600. grainEnabled: boolean;
  50601. /**
  50602. * @constructor
  50603. * @param name - The rendering pipeline name (default: "")
  50604. * @param hdr - If high dynamic range textures should be used (default: true)
  50605. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50606. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50607. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50608. */
  50609. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50610. /**
  50611. * Force the compilation of the entire pipeline.
  50612. */
  50613. prepare(): void;
  50614. private _hasCleared;
  50615. private _prevPostProcess;
  50616. private _prevPrevPostProcess;
  50617. private _setAutoClearAndTextureSharing;
  50618. private _depthOfFieldSceneObserver;
  50619. private _buildPipeline;
  50620. private _disposePostProcesses;
  50621. /**
  50622. * Adds a camera to the pipeline
  50623. * @param camera the camera to be added
  50624. */
  50625. addCamera(camera: Camera): void;
  50626. /**
  50627. * Removes a camera from the pipeline
  50628. * @param camera the camera to remove
  50629. */
  50630. removeCamera(camera: Camera): void;
  50631. /**
  50632. * Dispose of the pipeline and stop all post processes
  50633. */
  50634. dispose(): void;
  50635. /**
  50636. * Serialize the rendering pipeline (Used when exporting)
  50637. * @returns the serialized object
  50638. */
  50639. serialize(): any;
  50640. /**
  50641. * Parse the serialized pipeline
  50642. * @param source Source pipeline.
  50643. * @param scene The scene to load the pipeline to.
  50644. * @param rootUrl The URL of the serialized pipeline.
  50645. * @returns An instantiated pipeline from the serialized object.
  50646. */
  50647. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50648. }
  50649. }
  50650. declare module BABYLON {
  50651. /**
  50652. * BABYLON.JS Chromatic Aberration GLSL Shader
  50653. * Author: Olivier Guyot
  50654. * Separates very slightly R, G and B colors on the edges of the screen
  50655. * Inspired by Francois Tarlier & Martins Upitis
  50656. */
  50657. class LensRenderingPipeline extends PostProcessRenderPipeline {
  50658. /**
  50659. * @ignore
  50660. * The chromatic aberration PostProcess id in the pipeline
  50661. */
  50662. LensChromaticAberrationEffect: string;
  50663. /**
  50664. * @ignore
  50665. * The highlights enhancing PostProcess id in the pipeline
  50666. */
  50667. HighlightsEnhancingEffect: string;
  50668. /**
  50669. * @ignore
  50670. * The depth-of-field PostProcess id in the pipeline
  50671. */
  50672. LensDepthOfFieldEffect: string;
  50673. private _scene;
  50674. private _depthTexture;
  50675. private _grainTexture;
  50676. private _chromaticAberrationPostProcess;
  50677. private _highlightsPostProcess;
  50678. private _depthOfFieldPostProcess;
  50679. private _edgeBlur;
  50680. private _grainAmount;
  50681. private _chromaticAberration;
  50682. private _distortion;
  50683. private _highlightsGain;
  50684. private _highlightsThreshold;
  50685. private _dofDistance;
  50686. private _dofAperture;
  50687. private _dofDarken;
  50688. private _dofPentagon;
  50689. private _blurNoise;
  50690. /**
  50691. * @constructor
  50692. *
  50693. * Effect parameters are as follow:
  50694. * {
  50695. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50696. * edge_blur: number; // from 0 to x (1 for realism)
  50697. * distortion: number; // from 0 to x (1 for realism)
  50698. * grain_amount: number; // from 0 to 1
  50699. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50700. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50701. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50702. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50703. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50704. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50705. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50706. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50707. * }
  50708. * Note: if an effect parameter is unset, effect is disabled
  50709. *
  50710. * @param name The rendering pipeline name
  50711. * @param parameters - An object containing all parameters (see above)
  50712. * @param scene The scene linked to this pipeline
  50713. * @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)
  50714. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50715. */
  50716. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50717. /**
  50718. * Sets the amount of blur at the edges
  50719. * @param amount blur amount
  50720. */
  50721. setEdgeBlur(amount: number): void;
  50722. /**
  50723. * Sets edge blur to 0
  50724. */
  50725. disableEdgeBlur(): void;
  50726. /**
  50727. * Sets the amout of grain
  50728. * @param amount Amount of grain
  50729. */
  50730. setGrainAmount(amount: number): void;
  50731. /**
  50732. * Set grain amount to 0
  50733. */
  50734. disableGrain(): void;
  50735. /**
  50736. * Sets the chromatic aberration amount
  50737. * @param amount amount of chromatic aberration
  50738. */
  50739. setChromaticAberration(amount: number): void;
  50740. /**
  50741. * Sets chromatic aberration amount to 0
  50742. */
  50743. disableChromaticAberration(): void;
  50744. /**
  50745. * Sets the EdgeDistortion amount
  50746. * @param amount amount of EdgeDistortion
  50747. */
  50748. setEdgeDistortion(amount: number): void;
  50749. /**
  50750. * Sets edge distortion to 0
  50751. */
  50752. disableEdgeDistortion(): void;
  50753. /**
  50754. * Sets the FocusDistance amount
  50755. * @param amount amount of FocusDistance
  50756. */
  50757. setFocusDistance(amount: number): void;
  50758. /**
  50759. * Disables depth of field
  50760. */
  50761. disableDepthOfField(): void;
  50762. /**
  50763. * Sets the Aperture amount
  50764. * @param amount amount of Aperture
  50765. */
  50766. setAperture(amount: number): void;
  50767. /**
  50768. * Sets the DarkenOutOfFocus amount
  50769. * @param amount amount of DarkenOutOfFocus
  50770. */
  50771. setDarkenOutOfFocus(amount: number): void;
  50772. /**
  50773. * Creates a pentagon bokeh effect
  50774. */
  50775. enablePentagonBokeh(): void;
  50776. /**
  50777. * Disables the pentagon bokeh effect
  50778. */
  50779. disablePentagonBokeh(): void;
  50780. /**
  50781. * Enables noise blur
  50782. */
  50783. enableNoiseBlur(): void;
  50784. /**
  50785. * Disables noise blur
  50786. */
  50787. disableNoiseBlur(): void;
  50788. /**
  50789. * Sets the HighlightsGain amount
  50790. * @param amount amount of HighlightsGain
  50791. */
  50792. setHighlightsGain(amount: number): void;
  50793. /**
  50794. * Sets the HighlightsThreshold amount
  50795. * @param amount amount of HighlightsThreshold
  50796. */
  50797. setHighlightsThreshold(amount: number): void;
  50798. /**
  50799. * Disables highlights
  50800. */
  50801. disableHighlights(): void;
  50802. /**
  50803. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50804. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50805. */
  50806. dispose(disableDepthRender?: boolean): void;
  50807. private _createChromaticAberrationPostProcess;
  50808. private _createHighlightsPostProcess;
  50809. private _createDepthOfFieldPostProcess;
  50810. private _createGrainTexture;
  50811. }
  50812. }
  50813. declare module BABYLON {
  50814. /**
  50815. * Render pipeline to produce ssao effect
  50816. */
  50817. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50818. /**
  50819. * @ignore
  50820. * The PassPostProcess id in the pipeline that contains the original scene color
  50821. */
  50822. SSAOOriginalSceneColorEffect: string;
  50823. /**
  50824. * @ignore
  50825. * The SSAO PostProcess id in the pipeline
  50826. */
  50827. SSAORenderEffect: string;
  50828. /**
  50829. * @ignore
  50830. * The horizontal blur PostProcess id in the pipeline
  50831. */
  50832. SSAOBlurHRenderEffect: string;
  50833. /**
  50834. * @ignore
  50835. * The vertical blur PostProcess id in the pipeline
  50836. */
  50837. SSAOBlurVRenderEffect: string;
  50838. /**
  50839. * @ignore
  50840. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50841. */
  50842. SSAOCombineRenderEffect: string;
  50843. /**
  50844. * The output strength of the SSAO post-process. Default value is 1.0.
  50845. */
  50846. totalStrength: number;
  50847. /**
  50848. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50849. */
  50850. maxZ: number;
  50851. /**
  50852. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50853. */
  50854. minZAspect: number;
  50855. private _samples;
  50856. /**
  50857. * Number of samples used for the SSAO calculations. Default value is 8
  50858. */
  50859. samples: number;
  50860. private _textureSamples;
  50861. /**
  50862. * Number of samples to use for antialiasing
  50863. */
  50864. textureSamples: number;
  50865. /**
  50866. * Ratio object used for SSAO ratio and blur ratio
  50867. */
  50868. private _ratio;
  50869. /**
  50870. * Dynamically generated sphere sampler.
  50871. */
  50872. private _sampleSphere;
  50873. /**
  50874. * Blur filter offsets
  50875. */
  50876. private _samplerOffsets;
  50877. private _expensiveBlur;
  50878. /**
  50879. * If bilateral blur should be used
  50880. */
  50881. expensiveBlur: boolean;
  50882. /**
  50883. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50884. */
  50885. radius: number;
  50886. /**
  50887. * The base color of the SSAO post-process
  50888. * The final result is "base + ssao" between [0, 1]
  50889. */
  50890. base: number;
  50891. /**
  50892. * Support test.
  50893. */
  50894. static readonly IsSupported: boolean;
  50895. private _scene;
  50896. private _depthTexture;
  50897. private _normalTexture;
  50898. private _randomTexture;
  50899. private _originalColorPostProcess;
  50900. private _ssaoPostProcess;
  50901. private _blurHPostProcess;
  50902. private _blurVPostProcess;
  50903. private _ssaoCombinePostProcess;
  50904. private _firstUpdate;
  50905. /**
  50906. * @constructor
  50907. * @param name The rendering pipeline name
  50908. * @param scene The scene linked to this pipeline
  50909. * @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 }
  50910. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50911. */
  50912. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50913. /**
  50914. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50915. */
  50916. dispose(disableGeometryBufferRenderer?: boolean): void;
  50917. private _createBlurPostProcess;
  50918. /** @hidden */
  50919. _rebuild(): void;
  50920. private _bits;
  50921. private _radicalInverse_VdC;
  50922. private _hammersley;
  50923. private _hemisphereSample_uniform;
  50924. private _generateHemisphere;
  50925. private _createSSAOPostProcess;
  50926. private _createSSAOCombinePostProcess;
  50927. private _createRandomTexture;
  50928. /**
  50929. * Serialize the rendering pipeline (Used when exporting)
  50930. * @returns the serialized object
  50931. */
  50932. serialize(): any;
  50933. /**
  50934. * Parse the serialized pipeline
  50935. * @param source Source pipeline.
  50936. * @param scene The scene to load the pipeline to.
  50937. * @param rootUrl The URL of the serialized pipeline.
  50938. * @returns An instantiated pipeline from the serialized object.
  50939. */
  50940. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50941. }
  50942. }
  50943. declare module BABYLON {
  50944. /**
  50945. * Render pipeline to produce ssao effect
  50946. */
  50947. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50948. /**
  50949. * @ignore
  50950. * The PassPostProcess id in the pipeline that contains the original scene color
  50951. */
  50952. SSAOOriginalSceneColorEffect: string;
  50953. /**
  50954. * @ignore
  50955. * The SSAO PostProcess id in the pipeline
  50956. */
  50957. SSAORenderEffect: string;
  50958. /**
  50959. * @ignore
  50960. * The horizontal blur PostProcess id in the pipeline
  50961. */
  50962. SSAOBlurHRenderEffect: string;
  50963. /**
  50964. * @ignore
  50965. * The vertical blur PostProcess id in the pipeline
  50966. */
  50967. SSAOBlurVRenderEffect: string;
  50968. /**
  50969. * @ignore
  50970. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50971. */
  50972. SSAOCombineRenderEffect: string;
  50973. /**
  50974. * The output strength of the SSAO post-process. Default value is 1.0.
  50975. */
  50976. totalStrength: number;
  50977. /**
  50978. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50979. */
  50980. radius: number;
  50981. /**
  50982. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50983. * Must not be equal to fallOff and superior to fallOff.
  50984. * Default value is 0.975
  50985. */
  50986. area: number;
  50987. /**
  50988. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50989. * Must not be equal to area and inferior to area.
  50990. * Default value is 0.0
  50991. */
  50992. fallOff: number;
  50993. /**
  50994. * The base color of the SSAO post-process
  50995. * The final result is "base + ssao" between [0, 1]
  50996. */
  50997. base: number;
  50998. private _scene;
  50999. private _depthTexture;
  51000. private _randomTexture;
  51001. private _originalColorPostProcess;
  51002. private _ssaoPostProcess;
  51003. private _blurHPostProcess;
  51004. private _blurVPostProcess;
  51005. private _ssaoCombinePostProcess;
  51006. private _firstUpdate;
  51007. /**
  51008. * @constructor
  51009. * @param name - The rendering pipeline name
  51010. * @param scene - The scene linked to this pipeline
  51011. * @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 }
  51012. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  51013. */
  51014. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  51015. /**
  51016. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  51017. */
  51018. dispose(disableDepthRender?: boolean): void;
  51019. private _createBlurPostProcess;
  51020. /** @hidden */
  51021. _rebuild(): void;
  51022. private _createSSAOPostProcess;
  51023. private _createSSAOCombinePostProcess;
  51024. private _createRandomTexture;
  51025. }
  51026. }
  51027. declare module BABYLON {
  51028. /**
  51029. * Standard rendering pipeline
  51030. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51031. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  51032. */
  51033. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  51034. /**
  51035. * Public members
  51036. */
  51037. /**
  51038. * Post-process which contains the original scene color before the pipeline applies all the effects
  51039. */
  51040. originalPostProcess: Nullable<PostProcess>;
  51041. /**
  51042. * Post-process used to down scale an image x4
  51043. */
  51044. downSampleX4PostProcess: Nullable<PostProcess>;
  51045. /**
  51046. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  51047. */
  51048. brightPassPostProcess: Nullable<PostProcess>;
  51049. /**
  51050. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  51051. */
  51052. blurHPostProcesses: PostProcess[];
  51053. /**
  51054. * Post-process array storing all the vertical blur post-processes used by the pipeline
  51055. */
  51056. blurVPostProcesses: PostProcess[];
  51057. /**
  51058. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  51059. */
  51060. textureAdderPostProcess: Nullable<PostProcess>;
  51061. /**
  51062. * Post-process used to create volumetric lighting effect
  51063. */
  51064. volumetricLightPostProcess: Nullable<PostProcess>;
  51065. /**
  51066. * Post-process used to smooth the previous volumetric light post-process on the X axis
  51067. */
  51068. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  51069. /**
  51070. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  51071. */
  51072. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  51073. /**
  51074. * Post-process used to merge the volumetric light effect and the real scene color
  51075. */
  51076. volumetricLightMergePostProces: Nullable<PostProcess>;
  51077. /**
  51078. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  51079. */
  51080. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  51081. /**
  51082. * Base post-process used to calculate the average luminance of the final image for HDR
  51083. */
  51084. luminancePostProcess: Nullable<PostProcess>;
  51085. /**
  51086. * Post-processes used to create down sample post-processes in order to get
  51087. * the average luminance of the final image for HDR
  51088. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  51089. */
  51090. luminanceDownSamplePostProcesses: PostProcess[];
  51091. /**
  51092. * Post-process used to create a HDR effect (light adaptation)
  51093. */
  51094. hdrPostProcess: Nullable<PostProcess>;
  51095. /**
  51096. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  51097. */
  51098. textureAdderFinalPostProcess: Nullable<PostProcess>;
  51099. /**
  51100. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  51101. */
  51102. lensFlareFinalPostProcess: Nullable<PostProcess>;
  51103. /**
  51104. * Post-process used to merge the final HDR post-process and the real scene color
  51105. */
  51106. hdrFinalPostProcess: Nullable<PostProcess>;
  51107. /**
  51108. * Post-process used to create a lens flare effect
  51109. */
  51110. lensFlarePostProcess: Nullable<PostProcess>;
  51111. /**
  51112. * Post-process that merges the result of the lens flare post-process and the real scene color
  51113. */
  51114. lensFlareComposePostProcess: Nullable<PostProcess>;
  51115. /**
  51116. * Post-process used to create a motion blur effect
  51117. */
  51118. motionBlurPostProcess: Nullable<PostProcess>;
  51119. /**
  51120. * Post-process used to create a depth of field effect
  51121. */
  51122. depthOfFieldPostProcess: Nullable<PostProcess>;
  51123. /**
  51124. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  51125. */
  51126. fxaaPostProcess: Nullable<FxaaPostProcess>;
  51127. /**
  51128. * Represents the brightness threshold in order to configure the illuminated surfaces
  51129. */
  51130. brightThreshold: number;
  51131. /**
  51132. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  51133. */
  51134. blurWidth: number;
  51135. /**
  51136. * Sets if the blur for highlighted surfaces must be only horizontal
  51137. */
  51138. horizontalBlur: boolean;
  51139. /**
  51140. * Sets the overall exposure used by the pipeline
  51141. */
  51142. exposure: number;
  51143. /**
  51144. * Texture used typically to simulate "dirty" on camera lens
  51145. */
  51146. lensTexture: Nullable<Texture>;
  51147. /**
  51148. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  51149. */
  51150. volumetricLightCoefficient: number;
  51151. /**
  51152. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  51153. */
  51154. volumetricLightPower: number;
  51155. /**
  51156. * Used the set the blur intensity to smooth the volumetric lights
  51157. */
  51158. volumetricLightBlurScale: number;
  51159. /**
  51160. * Light (spot or directional) used to generate the volumetric lights rays
  51161. * The source light must have a shadow generate so the pipeline can get its
  51162. * depth map
  51163. */
  51164. sourceLight: Nullable<SpotLight | DirectionalLight>;
  51165. /**
  51166. * For eye adaptation, represents the minimum luminance the eye can see
  51167. */
  51168. hdrMinimumLuminance: number;
  51169. /**
  51170. * For eye adaptation, represents the decrease luminance speed
  51171. */
  51172. hdrDecreaseRate: number;
  51173. /**
  51174. * For eye adaptation, represents the increase luminance speed
  51175. */
  51176. hdrIncreaseRate: number;
  51177. /**
  51178. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  51179. */
  51180. lensColorTexture: Nullable<Texture>;
  51181. /**
  51182. * The overall strengh for the lens flare effect
  51183. */
  51184. lensFlareStrength: number;
  51185. /**
  51186. * Dispersion coefficient for lens flare ghosts
  51187. */
  51188. lensFlareGhostDispersal: number;
  51189. /**
  51190. * Main lens flare halo width
  51191. */
  51192. lensFlareHaloWidth: number;
  51193. /**
  51194. * Based on the lens distortion effect, defines how much the lens flare result
  51195. * is distorted
  51196. */
  51197. lensFlareDistortionStrength: number;
  51198. /**
  51199. * Lens star texture must be used to simulate rays on the flares and is available
  51200. * in the documentation
  51201. */
  51202. lensStarTexture: Nullable<Texture>;
  51203. /**
  51204. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  51205. * flare effect by taking account of the dirt texture
  51206. */
  51207. lensFlareDirtTexture: Nullable<Texture>;
  51208. /**
  51209. * Represents the focal length for the depth of field effect
  51210. */
  51211. depthOfFieldDistance: number;
  51212. /**
  51213. * Represents the blur intensity for the blurred part of the depth of field effect
  51214. */
  51215. depthOfFieldBlurWidth: number;
  51216. /**
  51217. * For motion blur, defines how much the image is blurred by the movement
  51218. */
  51219. motionStrength: number;
  51220. /**
  51221. * List of animations for the pipeline (IAnimatable implementation)
  51222. */
  51223. animations: Animation[];
  51224. /**
  51225. * Private members
  51226. */
  51227. private _scene;
  51228. private _currentDepthOfFieldSource;
  51229. private _basePostProcess;
  51230. private _hdrCurrentLuminance;
  51231. private _floatTextureType;
  51232. private _ratio;
  51233. private _bloomEnabled;
  51234. private _depthOfFieldEnabled;
  51235. private _vlsEnabled;
  51236. private _lensFlareEnabled;
  51237. private _hdrEnabled;
  51238. private _motionBlurEnabled;
  51239. private _fxaaEnabled;
  51240. private _motionBlurSamples;
  51241. private _volumetricLightStepsCount;
  51242. private _samples;
  51243. /**
  51244. * @ignore
  51245. * Specifies if the bloom pipeline is enabled
  51246. */
  51247. BloomEnabled: boolean;
  51248. /**
  51249. * @ignore
  51250. * Specifies if the depth of field pipeline is enabed
  51251. */
  51252. DepthOfFieldEnabled: boolean;
  51253. /**
  51254. * @ignore
  51255. * Specifies if the lens flare pipeline is enabed
  51256. */
  51257. LensFlareEnabled: boolean;
  51258. /**
  51259. * @ignore
  51260. * Specifies if the HDR pipeline is enabled
  51261. */
  51262. HDREnabled: boolean;
  51263. /**
  51264. * @ignore
  51265. * Specifies if the volumetric lights scattering effect is enabled
  51266. */
  51267. VLSEnabled: boolean;
  51268. /**
  51269. * @ignore
  51270. * Specifies if the motion blur effect is enabled
  51271. */
  51272. MotionBlurEnabled: boolean;
  51273. /**
  51274. * Specifies if anti-aliasing is enabled
  51275. */
  51276. fxaaEnabled: boolean;
  51277. /**
  51278. * Specifies the number of steps used to calculate the volumetric lights
  51279. * Typically in interval [50, 200]
  51280. */
  51281. volumetricLightStepsCount: number;
  51282. /**
  51283. * Specifies the number of samples used for the motion blur effect
  51284. * Typically in interval [16, 64]
  51285. */
  51286. motionBlurSamples: number;
  51287. /**
  51288. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  51289. */
  51290. samples: number;
  51291. /**
  51292. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51293. * @constructor
  51294. * @param name The rendering pipeline name
  51295. * @param scene The scene linked to this pipeline
  51296. * @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)
  51297. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  51298. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51299. */
  51300. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  51301. private _buildPipeline;
  51302. private _createDownSampleX4PostProcess;
  51303. private _createBrightPassPostProcess;
  51304. private _createBlurPostProcesses;
  51305. private _createTextureAdderPostProcess;
  51306. private _createVolumetricLightPostProcess;
  51307. private _createLuminancePostProcesses;
  51308. private _createHdrPostProcess;
  51309. private _createLensFlarePostProcess;
  51310. private _createDepthOfFieldPostProcess;
  51311. private _createMotionBlurPostProcess;
  51312. private _getDepthTexture;
  51313. private _disposePostProcesses;
  51314. /**
  51315. * Dispose of the pipeline and stop all post processes
  51316. */
  51317. dispose(): void;
  51318. /**
  51319. * Serialize the rendering pipeline (Used when exporting)
  51320. * @returns the serialized object
  51321. */
  51322. serialize(): any;
  51323. /**
  51324. * Parse the serialized pipeline
  51325. * @param source Source pipeline.
  51326. * @param scene The scene to load the pipeline to.
  51327. * @param rootUrl The URL of the serialized pipeline.
  51328. * @returns An instantiated pipeline from the serialized object.
  51329. */
  51330. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  51331. /**
  51332. * Luminance steps
  51333. */
  51334. static LuminanceSteps: number;
  51335. }
  51336. }